summaryrefslogtreecommitdiff
path: root/js/3D_Landscape.js
diff options
context:
space:
mode:
authorPepper <pepper@scannerjammer.com>2015-02-13 06:20:50 -0500
committerPepper <pepper@scannerjammer.com>2015-02-13 06:20:50 -0500
commitaefbae257b541b198de2df39873a3ab8ab7f3d68 (patch)
treefd7bee904387f556ebbf8ce623d58abbee404809 /js/3D_Landscape.js
parentc8a28a2ac9721165f78f7aa0c1bd738ff0fa0556 (diff)
fixed keys
Diffstat (limited to 'js/3D_Landscape.js')
-rw-r--r--js/3D_Landscape.js191
1 files changed, 78 insertions, 113 deletions
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();
}