in src/core/PointOfInterestFeature.js [385:431]
_setLookAngles() {
// Get the current positions of the tracker and target objects
const targetPos = this.constructor._getWorldPosition(this._target);
const trackerPos = this.constructor._getWorldPosition(this._lookTracker);
// Check if the target has moved
this._isTargetMoving = MathUtils.getVectorMagnitude([
targetPos[0] - this._prevTargetPos[0],
targetPos[1] - this._prevTargetPos[1],
targetPos[2] - this._prevTargetPos[2]]
) > 0;
Object.assign(this._prevTargetPos, targetPos);
// Calculate the horizontal and vertical angles to rotate to the target
const targetSpherical = MathUtils.cartesianToSpherical(
targetPos[0] - trackerPos[0],
targetPos[1] - trackerPos[1],
targetPos[2] - trackerPos[2]
);
const targetAngles = this.constructor._sphericalToBlendValue(
targetSpherical[1],
targetSpherical[2]
);
// Calculate angles relative to the reference objects
this._trackingConfigs.forEach(({
reference,
forwardAxis,
angles
}) => {
// Calculate the horizontal and vertical angles to rotate to the direction of the tracker
const refDirection = this.constructor._getObjectDirection(
reference,
forwardAxis,
);
const refSpherical = MathUtils.cartesianToSpherical(...refDirection);
const refAngles = this.constructor._sphericalToBlendValue(
refSpherical[1],
refSpherical[2]
);
// Store the difference
angles.h = targetAngles.h - refAngles.h;
angles.v = targetAngles.v - refAngles.v;
});
}