Skip to content

Commit

Permalink
Updated get focus point
Browse files Browse the repository at this point in the history
  • Loading branch information
kpal81xd committed Nov 18, 2024
1 parent 0a85cca commit 04d6f76
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions scripts/camera-controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CameraControls extends Script {
* @private
* @type {Vec3}
*/
_origin = new Vec3(0, 0, 0);
_origin = new Vec3();

/**
* @private
Expand Down Expand Up @@ -296,7 +296,7 @@ class CameraControls extends Script {
}
this.attach(this.entity.camera);

this.focusPoint = focusPoint ?? Vec3.ZERO;
this.focusPoint = focusPoint ?? this._origin;
this.pitchRange = pitchRange ?? this.pitchRange;
this.zoomMin = zoomMin ?? this.zoomMin;
this.zoomMax = zoomMax ?? this.zoomMax;
Expand All @@ -315,13 +315,10 @@ class CameraControls extends Script {
}

get focusPoint() {
if (!this._camera) {
return Vec3.ZERO;
if (this._flying) {
return tmpV1.copy(this.root.forward).mulScalar(this._zoomDist).add(this._origin);
}
return tmpV1
.copy(this._camera.entity.forward)
.mulScalar(this._zoomDist)
.add(this._camera.entity.getPosition());
return this._origin;
}

/**
Expand Down

0 comments on commit 04d6f76

Please sign in to comment.