Explorar el Código

support moving left and right with the keyboard

Lucas Stadler %!s(int64=10) %!d(string=hace) años
padre
commit
6a1d74b480
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      glsl/raymarching.js

+ 6 - 0
glsl/raymarching.js

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