I noticed that vector3 can rebuild angles and radius , i want to know how to use angles and radius rebuild vector3

Hi musk,

If I am understanding correctly, you have two angles alpha and beta and a radius, and you want to find the position if we project in that direction from the origin, similar to how the ArcRotateCamera works. In order to compute this position, we can use trigonometry:

x=radius * cos(alpha) * sin(beta)
y=radius * cos(beta)
z=radius * sin(alpha) * sin(beta)

You can see this exact computation happening in ArcRotateCamera.ts: Babylon.js/arcRotateCamera.ts at master · BabylonJS/Babylon.js (github.com)

To demonstrate this in practice, here is a quick playground: Rebuild from arc rotate camera | Babylon.js Playground (babylonjs.com)

In this PG, the sphere is projected in the opposite direction from the arc rotate camera. If you wanted the same position as the camera, you would set radius=camera.radius, instead of -camera.radius.

Hope this is what you were looking for!

5 Likes