From 838800891b4bcfb71d7b450ad0ff77392142e4a5 Mon Sep 17 00:00:00 2001 From: ydcjeff Date: Wed, 20 Dec 2023 00:33:45 +0800 Subject: [PATCH] urban zoom in/out --- src/main.ts | 4 ++-- src/scenes/urban-scene.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index 80090e4..afa3251 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,11 +23,11 @@ const engine = new Engine(canvas); (async () => { // await engine.setScene(AxisScene); // await engine.setScene(RotatingScene); - await engine.setScene(CameraRotatingScene); + // await engine.setScene(CameraRotatingScene); // await engine.setScene(ScaleScene); // await engine.setScene(TranslationScene); // await engine.setScene(UrbanScene); - await engine.setScene(SolarScene); + // await engine.setScene(SolarScene); // await engine.setScene(TestScene); // await engine.setScene(CubeScene); // await engine.setScene(DirectLightScene); diff --git a/src/scenes/urban-scene.ts b/src/scenes/urban-scene.ts index e54907f..2204d43 100644 --- a/src/scenes/urban-scene.ts +++ b/src/scenes/urban-scene.ts @@ -93,6 +93,16 @@ export class UrbanScene extends Scene { return; } + if (e.ctrlKey) { + if (e.key === '=') { + e.preventDefault(); + this.mainCamera.fov -= 0.01; + } else if (e.key === '-') { + e.preventDefault(); + this.mainCamera.fov += 0.01; + } + } + if (e.key === 'w') camera.setPosition(Vector3.add(camera.position, Vector3.forward.multiply(speed))); if (e.key === 'a') camera.setPosition(Vector3.add(camera.position, Vector3.left.multiply(speed)));