antimatter15 commited on
Commit
e8dd2e6
1 Parent(s): 59df0c8

adding keyboard orbit controls

Browse files
Files changed (3) hide show
  1. README.md +1 -0
  2. index.html +1 -0
  3. main.js +9 -0
README.md CHANGED
@@ -19,6 +19,7 @@ camera angle (wasd)
19
  - `a`/`d` to turn camera left/right
20
  - `w`/`s` to tilt camera up/down
21
  - `q`/`e` to roll camera counterclockwise/clockwise
 
22
 
23
  trackpad
24
  - scroll up/down to orbit down
 
19
  - `a`/`d` to turn camera left/right
20
  - `w`/`s` to tilt camera up/down
21
  - `q`/`e` to roll camera counterclockwise/clockwise
22
+ - `i`/`k` and `j`/`l` to orbit
23
 
24
  trackpad
25
  - scroll up/down to orbit down
index.html CHANGED
@@ -198,6 +198,7 @@ camera angle (wasd)
198
  - a/d to turn camera left/right
199
  - w/s to tilt camera up/down
200
  - q/e to roll camera counterclockwise/clockwise
 
201
 
202
  trackpad
203
  - scroll up/down/left/right to orbit
 
198
  - a/d to turn camera left/right
199
  - w/s to tilt camera up/down
200
  - q/e to roll camera counterclockwise/clockwise
201
+ - i/k and j/l to orbit
202
 
203
  trackpad
204
  - scroll up/down/left/right to orbit
main.js CHANGED
@@ -1060,6 +1060,15 @@ async function main() {
1060
  if (activeKeys.includes("e")) inv = rotate4(inv, -0.01, 0, 0, 1);
1061
  if (activeKeys.includes("w")) inv = rotate4(inv, 0.005, 1, 0, 0);
1062
  if (activeKeys.includes("s")) inv = rotate4(inv, -0.005, 1, 0, 0);
 
 
 
 
 
 
 
 
 
1063
  // inv[13] = preY;
1064
  viewMatrix = invert4(inv);
1065
 
 
1060
  if (activeKeys.includes("e")) inv = rotate4(inv, -0.01, 0, 0, 1);
1061
  if (activeKeys.includes("w")) inv = rotate4(inv, 0.005, 1, 0, 0);
1062
  if (activeKeys.includes("s")) inv = rotate4(inv, -0.005, 1, 0, 0);
1063
+
1064
+ if(['j', 'k', 'l', 'i'].some(k => activeKeys.includes(k))) {
1065
+ let d = 4;
1066
+ inv = translate4(inv, 0, 0, d);
1067
+ inv = rotate4(inv, activeKeys.includes('j') ? -0.05: activeKeys.includes('l') ? 0.05 : 0, 0, 1, 0);
1068
+ inv = rotate4(inv, activeKeys.includes('i') ? 0.05 : activeKeys.includes('k') ? -0.05 : 0, 1, 0, 0);
1069
+ inv = translate4(inv, 0, 0, -d);
1070
+ }
1071
+
1072
  // inv[13] = preY;
1073
  viewMatrix = invert4(inv);
1074