Skip to content

Commit

Permalink
🐞 fix: Change the size of the pan to dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangechen committed Jan 1, 2024
1 parent fc14480 commit 6ea077e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/chili-three/src/cameraController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 6ea077e

Please sign in to comment.