From 6ea077e6266ab741038d2cf5e0a507051fb429a8 Mon Sep 17 00:00:00 2001 From: xiange Date: Mon, 1 Jan 2024 09:15:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20Change=20the=20size=20of?= =?UTF-8?q?=20the=20pan=20to=20dynamic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/chili-three/src/cameraController.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/chili-three/src/cameraController.ts b/packages/chili-three/src/cameraController.ts index edfd59ed..ac15639e 100644 --- a/packages/chili-three/src/cameraController.ts +++ b/packages/chili-three/src/cameraController.ts @@ -56,10 +56,11 @@ export class CameraController implements ICameraController { } pan(dx: number, dy: number): void { + let ratio = 0.002 * this.#target.distanceTo(this.#position); let direction = this.#target.clone().sub(this.#position).normalize(); let hor = direction.clone().cross(this.#up).normalize(); let ver = hor.clone().cross(direction).normalize(); - let vector = hor.multiplyScalar(-dx).add(ver.multiplyScalar(dy)); + let vector = hor.multiplyScalar(-dx).add(ver.multiplyScalar(dy)).multiplyScalar(ratio); this.#target.add(vector); this.#position.add(vector);