From 445d00fed322f1929959e721a202739f61bec8bb Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 15 Sep 2017 09:31:19 -0700 Subject: [PATCH] Prevent the user from flipping the camera upside down in the 3D view --- demo/client/src/camera.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/demo/client/src/camera.ts b/demo/client/src/camera.ts index abcac12a..069f295a 100644 --- a/demo/client/src/camera.ts +++ b/demo/client/src/camera.ts @@ -277,7 +277,9 @@ export class PerspectiveCamera extends Camera { return; this.rotation[0] += event.movementX * PERSPECTIVE_ROTATION_SPEED; - this.rotation[1] += event.movementY * PERSPECTIVE_ROTATION_SPEED; + + const trialYRotation = this.rotation[1] + event.movementY * PERSPECTIVE_ROTATION_SPEED; + this.rotation[1] = _.clamp(trialYRotation, -Math.PI * 0.5, Math.PI * 0.5); if (this.onChange != null) this.onChange();