Skip to content

Commit

Permalink
fix(HoverCameraController):Fixed the bug occurred when in the top view
Browse files Browse the repository at this point in the history
  • Loading branch information
OriIIusion committed Apr 22, 2024
1 parent 25ba1d8 commit 9cd0979
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/components/controller/HoverCameraController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class HoverCameraController extends ComponentBase {
/**
* Right mouse movement coefficient
*/
public mouseRightFactor: number = 0.5;
public mouseRightFactor: number = 0.25;

/**
* Left mouse movement coefficient
Expand Down Expand Up @@ -231,18 +231,10 @@ export class HoverCameraController extends ComponentBase {
// return;
if (!this.enable) return;
if (this._mouseRightDown) {
let p = 0.25; //this.distance / (this.camera.far - this.camera.near);
let f = this.camera.transform.forward;
Vector3Ex.mulScale(f, e.movementY * p * this.camera.aspect, Vector3.HELP_1);
Vector3.HELP_1.x = -1 * e.movementX * Math.cos((this._roll * Math.PI) / 180) - e.movementY * Math.sin((this._roll * Math.PI) / 180);
Vector3.HELP_1.z = -1 * e.movementY * Math.cos((this._roll * Math.PI) / 180) + e.movementX * Math.sin((this._roll * Math.PI) / 180);
this._targetPos.x += Vector3.HELP_1.x * this.mouseRightFactor;
// this._targetPos.y -= Vector3.HELP_1.y;
this._targetPos.z += Vector3.HELP_1.z * this.mouseRightFactor;

let f2 = this.camera.transform.right;
Vector3Ex.mulScale(f2, -e.movementX * p, Vector3.HELP_1);
this._targetPos.x -= Vector3.HELP_1.x * this.mouseRightFactor;
// this._targetPos.y -= Vector3.HELP_1.y;
this._targetPos.z -= Vector3.HELP_1.z * this.mouseRightFactor;
}

if (this._mouseLeftDown) {
Expand Down

0 comments on commit 9cd0979

Please sign in to comment.