Skip to content

Commit 6ea077e

Browse files
committed
🐞 fix: Change the size of the pan to dynamic
1 parent fc14480 commit 6ea077e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/chili-three/src/cameraController.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ export class CameraController implements ICameraController {
5656
}
5757

5858
pan(dx: number, dy: number): void {
59+
let ratio = 0.002 * this.#target.distanceTo(this.#position);
5960
let direction = this.#target.clone().sub(this.#position).normalize();
6061
let hor = direction.clone().cross(this.#up).normalize();
6162
let ver = hor.clone().cross(direction).normalize();
62-
let vector = hor.multiplyScalar(-dx).add(ver.multiplyScalar(dy));
63+
let vector = hor.multiplyScalar(-dx).add(ver.multiplyScalar(dy)).multiplyScalar(ratio);
6364
this.#target.add(vector);
6465
this.#position.add(vector);
6566

0 commit comments

Comments
 (0)