Bladeren bron

support moving left and right with the keyboard

Lucas Stadler 10 jaren geleden
bovenliggende
commit
6a1d74b480
1 gewijzigde bestanden met toevoegingen van 6 en 0 verwijderingen
  1. 6 0
      glsl/raymarching.js

+ 6 - 0
glsl/raymarching.js

@ -209,6 +209,7 @@ void main() {
209 209
    });
210 210
    
211 211
    tt.direction = [0, 0, 1];
212
    tt.right = [-1, 0, 0];
212 213
    tt.angle = {horizontal: 0.0, vertical: 0.0};
213 214
    
214 215
    var iDirection = gl.getUniformLocation(program, 'iDirection');
@ -230,6 +231,9 @@ void main() {
230 231
      tt.direction = [Math.cos(tt.angle.vertical) * Math.sin(tt.angle.horizontal),
231 232
                      Math.sin(tt.angle.vertical),
232 233
                      Math.cos(tt.angle.vertical) * Math.cos(tt.angle.horizontal)];
234
      tt.right = [Math.sin(tt.angle.horizontal - Math.PI/2),
235
                  0,
236
                  Math.cos(tt.angle.horizontal - Math.PI/2)];
233 237
      
234 238
      gl.uniform3f(iDirection, tt.direction[0], tt.direction[1], tt.direction[2]);
235 239
@ -250,6 +254,7 @@ void main() {
250 254
          break;
251 255
        case 37: // Left
252 256
        case 65: // A
257
          origin = [origin[0]-tt.right[0], origin[1]-tt.right[1], origin[2]-tt.right[2]];
253 258
          break;
254 259
        case 40: // Down
255 260
        case 83: // S
@ -257,6 +262,7 @@ void main() {
257 262
          break;
258 263
        case 39: // Right
259 264
        case 68: // D
265
          origin = [origin[0]+tt.right[0], origin[1]+tt.right[1], origin[2]+tt.right[2]];
260 266
          break;
261 267
        default:
262 268
          return