Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. rotate(ev) {
  2.  
  3. let xOffSet = ev.center.x - this._lastX;
  4. let YOffSet = this._lastY - ev.center.y;
  5.  
  6. this._lastX = ev.center.x;
  7. this._lastY = ev.center.y;
  8.  
  9. let sensitivity = 0.005;
  10. xOffSet *= sensitivity;
  11. YOffSet *= sensitivity;
  12.  
  13. this._yaw += xOffSet;
  14. this._pitch += YOffSet;
  15.  
  16. updateViewProjMatrix() {
  17. let gl = Core.mGetGL();
  18. this._frontVector[0] = Math.cos(this._yaw) * Math.cos(this._pitch);
  19. this._frontVector[1] = Math.sin(this._pitch);
  20. this._frontVector[2] = Math.sin(this._yaw) * Math.cos(this._pitch);
  21.  
  22. vec3.normalize(this._lookAtVector, this._frontVector);
  23. vec3.add(this._lookAtVector, this._lookAtVector, this._positionVector);
  24.  
  25. mat4.lookAt(this._viewMatrix, this._positionVector, this._lookAtVector, this._upVector);
  26. mat4.perspective(this._projMatrix, this._fov * Math.PI / 180, gl.canvas.clientWidth / gl.canvas.clientHeight, this._nearPlane, this._farPlane);
  27. mat4.multiply(this._vpMatrix, this._projMatrix, this._viewMatrix);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement