fix bug where pressing enter updated shader instead of camera distance

This commit is contained in:
gbrochar 2020-11-24 17:04:33 +01:00
parent 4fb99acd00
commit 6a1b25777d
2 changed files with 6 additions and 6 deletions

View File

@ -254,13 +254,13 @@ async function main() {
$('#input1').on('keypress', function(event: any) { $('#input1').on('keypress', function(event: any) {
if (event.which === 13) { if (event.which === 13) {
event.preventDefault(); event.preventDefault();
$('#button3').click(); $('#changedistance').click();
} }
}); });
$('#input2').on('keypress', function(event: any) { $('#input2').on('keypress', function(event: any) {
if (event.which === 13) { if (event.which === 13) {
event.preventDefault(); event.preventDefault();
$('#button4').click(); $('#changecirclesize').click();
} }
}); });
$('#button1').on('click', function() { $('#button1').on('click', function() {
@ -275,11 +275,11 @@ async function main() {
[programInfo, fragmentShader] = changeFragmentShader(gl, [programInfo, fragmentShader] = changeFragmentShader(gl,
shaderProgram, fragmentShader, fsSource3, vsSource); shaderProgram, fragmentShader, fsSource3, vsSource);
}); });
$('#button3').on('click', function() { $('#changedistance').on('click', function() {
distance = $('#input1').val(); distance = $('#input1').val();
distance = parseFloat(distance); distance = parseFloat(distance);
}); });
$('#button4').on('click', function() { $('#changecirclesize').on('click', function() {
circleSize = $('#input2').val(); circleSize = $('#input2').val();
circleSize = parseFloat(circleSize); circleSize = parseFloat(circleSize);
}); });

View File

@ -21,12 +21,12 @@
</div> </div>
<div class='ui-block'> <div class='ui-block'>
<input id='input1' value='50'></input> <input id='input1' value='50'></input>
<button id='button3'>Change camera distance</button> <button id='changedistance'>Change camera distance</button>
<div style='display: inline'>Max distance is 1000</div> <div style='display: inline'>Max distance is 1000</div>
</div> </div>
<div class='ui-block'> <div class='ui-block'>
<input id='input2' value='5'></input> <input id='input2' value='5'></input>
<button id='button4'>Change circle size</button> <button id='changecirclesize'>Change circle size</button>
</div> </div>
<div class='ui-block'> <div class='ui-block'>
<button id='sphere'>Set obj to sphere</button> <button id='sphere'>Set obj to sphere</button>