From aefbae257b541b198de2df39873a3ab8ab7f3d68 Mon Sep 17 00:00:00 2001 From: Pepper Date: Fri, 13 Feb 2015 06:20:50 -0500 Subject: fixed keys --- js/3D_Landscape.js | 191 ++++++++++++++++++++++------------------------------- 1 file changed, 78 insertions(+), 113 deletions(-) (limited to 'js/3D_Landscape.js') diff --git a/js/3D_Landscape.js b/js/3D_Landscape.js index 3c4eb08..777323f 100644 --- a/js/3D_Landscape.js +++ b/js/3D_Landscape.js @@ -132,49 +132,75 @@ function render() { renderer.render(scene, camera); } -function init_controls2(){ +function init_controls(){ var listener = new window.keypress.Listener(); - listener.simple_combo("space", function() { - wf = !wf; - material.wireframe = wf; - }); - listener.simple_combo("shift up", function() { - mesh.rotation.x += 0.1; - }); - listener.simple_combo("shift down", function() { - mesh.rotation.x -= 0.1; - }); - listener.simple_combo("shift left", function() { - mesh.rotation.z += 0.1; - }); - listener.simple_combo("shift right", function() { - mesh.rotation.z -= 0.1; - }); - listener.simple_combo("pageup", function() { - mesh.position.z += 150; - }); - listener.simple_combo("pagedown", function() { - mesh.position.z -= 150; - }); - - listener.simple_combo("up",function() { - mesh.position.y += 150; - }); - - //Down - listener.simple_combo("down",function() { - mesh.position.y -= 150; - }); - - //Left - listener.simple_combo("left",function() { - mesh.position.x -= 150; - }); - - //Right - listener.simple_combo("right",function() { - mesh.position.x += 150; - }); + var my_scope = this; + var my_combos = listener.register_many([ + { + "keys" : "up", + "is_solitary" : true, + "on_keydown" : function() { + mesh.position.y += 150; + }, + "this" : my_scope + }, + { + "keys" : "down", + "is_solitary" : true, + "on_keydown" : function() { + mesh.position.y -= 150; + }, + "this" : my_scope + }, + { + "keys" : "right", + "is_solitary" : true, + "on_keydown" : function() { + mesh.position.x += 150; + }, + "this" : my_scope + }, + { + "keys" : "left", + "is_solitary" : true, + "on_keydown" : function() { + mesh.position.x -= 150; + }, + "this" : my_scope + }, + { + "keys" : "shift up", + "is_exclusive" : true, + "on_keydown" : function() { + mesh.rotation.x += 0.1; + }, + "this" : my_scope + }, + { + "keys" : "shift down", + "is_exclusive" : true, + "on_keydown" : function() { + mesh.rotation.x -= 0.1; + }, + "this" : my_scope + }, + { + "keys" : "shift right", + "is_exclusive" : true, + "on_keydown" : function() { + mesh.rotation.z -= 0.1; + }, + "this" : my_scope + }, + { + "keys" : "shift left", + "is_exclusive" : true, + "on_keydown" : function() { + mesh.rotation.z += 0.1; + }, + "this" : my_scope + }, + ]); //Reset listener.simple_combo("delete",function() { mesh.position.x = pos_x; @@ -185,81 +211,20 @@ function init_controls2(){ mesh.rotation.z = rot_z; }); + //Zoom In + listener.simple_combo("pageup",function() { + mesh.position.z += 150; + }); -} - - -function init_controls(){ - //{{{init controls - - //Toggle wire-frame - shortcut.add("Space",function() { - wf = !wf; - material.wireframe = wf; - }); - - //Rotate Up - shortcut.add("Shift+Up",function() { - mesh.rotation.x += 0.1; - }); - - //Rotate Down - shortcut.add("Shift+Down",function() { - mesh.rotation.x -= 0.1; - }); - - //Rotate Left - shortcut.add("Shift+Left",function() { - mesh.rotation.z += 0.1; - }); - - //Rotate Right - shortcut.add("Shift+Right",function() { - mesh.rotation.z -= 0.1; - }); - - //Zoom In - shortcut.add("Page_up",function() { - mesh.position.z += 150; - }); - - //Zoom Out - shortcut.add("Page_down",function() { - mesh.position.z -= 150; - }); + //Zoom Out + listener.simple_combo("pagedown",function() { + mesh.position.z -= 150; + }); - //Up - shortcut.add("Up",function() { - mesh.position.y += 150; - }); +} - //Down - shortcut.add("Down",function() { - mesh.position.y -= 150; - }); - - //Left - shortcut.add("Left",function() { - mesh.position.x -= 150; - }); - //Right - shortcut.add("Right",function() { - mesh.position.x += 150; - }); - //Reset - shortcut.add("Delete",function() { - mesh.position.x = pos_x; - mesh.position.y = pos_y; - mesh.position.z = pos_z; - mesh.rotation.x = rot_x; - mesh.rotation.y = rot_y; - mesh.rotation.z = rot_z; - - }); - //}}} -} window.onload= function(e){ runWebGLSimulation(); - init_controls2(); + init_controls(); } -- cgit v1.2.3-70-g09d2