Convert from ArcRotateCamera, pos + alpha, beta, radius to pos + quaternion

I have stored position and rotations in my database as
vector3
alpha
beta
radius

and we have been using an ArcRotateCamera for most things.

But we now want to change the camera to the UniversalCamera.

I want to be able to position the UniversalCamera in the exact same position that we have stored in the database.

I was able to copy the world position and rotation from an existing ArcRotateCamera using

const arcRotate = new ArcRotateCamera(...)
const pos = arcRotate.globalPosition.clone()
const rot = arcRotate.absoluteRotation.clone()

const universal = new UniversalCamera(...)
universal.position.copyFrom(pos)
universal.rotationQuaternion = rot

but this means I need to instantiate an ArcRotateCamera just to be able to do the math.

How would I implement the function below?

function convertToUniversalCamera(target: Vector3, alpha: number, beta:number, radius: number): { position: Vector3, quaternion: Quaternion } {
  /// how?
}

To simplify I would utilize getFrontPosition() like here:

2 Likes

Hello @Leon just checking in if you need any more help?

I was able to solve my problem, so thank you :slight_smile: