From 91d5a6e02ebb1535026887d49da3ef2f48406519 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 28 Aug 2023 15:35:33 +0300 Subject: [WGL/P/level] Reset looking direction upon load --- .../Computer Graphics with WebGL/Project/camera-movement.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Year 2/Computer Graphics with WebGL/Project/camera-movement.js') 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; -- cgit v1.3.1-26-gb76a