commit b7dbff6abf219d0757a2e4a0b278c9c0add66ba5 parent 081aee5eb625cbd4efbdda476ce5ed2b67aabf57 Author: Martin Kloeckner <mjkloeckner@gmail.com> Date: Thu, 4 Jul 2024 14:28:47 -0300 bind key `C` (capital `c`) to previous camera Diffstat:
M | tp/src/scene.js | | | 24 | ++++++++++++++++++++++++ |
1 file changed, 24 insertions(+), 0 deletions(-) diff --git a/tp/src/scene.js b/tp/src/scene.js @@ -61,6 +61,27 @@ function onResize() { } renderer.setSize( window.innerWidth, window.innerHeight ); + +function prevCamera() { + const camerasCount = cameras.length; + + if(cameras[settings.currCameraIndex].name == "firstPersonCamera") { + firstPersonControls.unlock(); + blocker.style.display = 'none'; + instructions.style.display = 'flex'; + } + + if(settings.currCameraIndex == 0) { + settings.currCameraIndex = (camerasCount - 1); + } else { + settings.currCameraIndex -= 1; + } + + if(cameras[settings.currCameraIndex].name == "firstPersonCamera") { + firstPersonControls.unlock(); + blocker.style.display = 'block'; + instructions.style.display = 'flex'; + } } function nextCamera() { @@ -191,6 +212,9 @@ function setupThreeJs() { case "c": nextCamera(); break; + case "C": + prevCamera(); + break; case ' ': console.log("Toggling train animations"); settings.animationEnable = !settings.animationEnable;