diff options
[WGL/P/level] Reset looking direction upon load
2 files changed, 8 insertions, 4 deletions
| -rw-r--r-- | Year 2/Computer Graphics with WebGL/Project/camera-movement.js | 11 | ||||
| -rw-r--r-- | Year 2/Computer Graphics with WebGL/Project/level.js | 1 |
diff --git a/Year 2/Computer Graphics with WebGL/Project/camera-movement.js b/Year 2/Computer Graphics with WebGL/Project/camera-movement.js index 75d428e..842fbd2 100644 --- a/Year 2/Computer Graphics with WebGL/Project/camera-movement.js +++ b/Year 2/Computer Graphics with WebGL/Project/camera-movement.js @@ -66,10 +66,13 @@ const ROTATION_SPEED = 3; var pos = [1000, 0, 650]; -var forward = new SphericalCoord(Math.PI / 2, 0); -var up = new SphericalCoord(0, 0); - // this vector can be calculated from forward and up, but this way we improve speed -var left = new SphericalCoord(Math.PI / 2, Math.PI / 2); +function initCameraVectors() { + forward = new SphericalCoord(Math.PI / 2, 0); + up = new SphericalCoord(0, 0); + // this vector can be calculated from forward and up, but this way we improve speed + left = new SphericalCoord(Math.PI / 2, Math.PI / 2); +} +initCameraVectors(); var isPaused = true; diff --git a/Year 2/Computer Graphics with WebGL/Project/level.js b/Year 2/Computer Graphics with WebGL/Project/level.js index 2c23ca0..6e10687 100644 --- a/Year 2/Computer Graphics with WebGL/Project/level.js +++ b/Year 2/Computer Graphics with WebGL/Project/level.js @@ -85,6 +85,7 @@ Level.prototype.load = function() { blackHolesBuf = this.blackHolesBuf; animations = this.animations; pos = this.cameraCoords; + initCameraVectors(); for (var i = 0; i < STAR_MAX_COUNT; i++) { var val = (i < starsBuf.length) ? starsBuf[i] : [0,0,0,0]; |
