Vector3 to rotation angles

Hi, I have a Vector3 of a mesh space coordinates. Considering it as a point on a sphere with coordinates of [0;0;0], I’d like to put some object on the sphere’s surface with setting that rotation to the object that it will be look like it’s really located on the sphere.

I researched some math, but I didn’t get radians. So I need your help :smile:

Here are two ways I did that on PGs I posted in your other topic. You need to consider the way the mesh you are placing is created, ie for a cylinder you want the y axis along the normal of the sphere and for a disc the z axis along the sphere normal.

Cylinder placement on click

Disc placement part of build

For method see

2 Likes

Also in some cases you can use lookAt to simplify the process. For example in the quick example below when you click on the sphere a disc is placed at the picked point, using lookAt to make the disc face the center of the sphere.

3 Likes

Thank you

Everything works fine

BTW how to prevent creating these cylinders/disks/whatever when I just click by mouse to rotate the camera?

I assume the solution to be like custom disabling cylinder/disk creation on camera rotation or some pointerEvent

Hmm are you using the pointer move event to place the cylinder I guess? Then you could try setting enablePointerMoveEvents to false on the sphere on the pointer down event and set it back to true on the pointer up event.

2 Likes