Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Update FollowCameraComponent.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
speigg committed Jun 27, 2024
1 parent 1fd95f8 commit 7b3f0da
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/spatial/src/camera/components/FollowCameraComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,15 @@ const computeCameraFollow = (cameraEntity: Entity, referenceEntity: Entity) => {
const thetaRad = MathUtils.degToRad(theta)
const phiRad = MathUtils.degToRad(follow.phi)

direction.set(Math.sin(thetaRad) * Math.cos(phiRad), Math.sin(phiRad), Math.cos(thetaRad) * Math.cos(phiRad))

cameraTransform.position.set(
follow.currentTargetPosition.x + follow.distance * Math.sin(thetaRad) * Math.cos(phiRad),
follow.currentTargetPosition.y + follow.distance * Math.sin(phiRad),
follow.currentTargetPosition.z + follow.distance * Math.cos(thetaRad) * Math.cos(phiRad)
follow.currentTargetPosition.x + follow.distance * direction.x,
follow.currentTargetPosition.y + follow.distance * direction.y,
follow.currentTargetPosition.z + follow.distance * direction.z
)

direction.copy(cameraTransform.position).sub(follow.currentTargetPosition).normalize()
mx.lookAt(direction, empty, upVector)

cameraTransform.rotation.setFromRotationMatrix(mx)

updateCameraTargetRotation(cameraEntity)
Expand Down

0 comments on commit 7b3f0da

Please sign in to comment.