How to move the red sphere on the surface of the white sphere to the Y axis by rotating the white sphere?

like this:

A simple playground:
https://www.babylonjs-playground.com/#SFA6BT#1

Hi.

Not sure if I understand your intentions correctly, but you already parented red sphere to the white sphere. Which means that if you rotate white sphere, the red sphere will follow the rotation of it’s parent. So if that’s what you want, you basically already did it :smiley:

I added rotationGizmo here, to demonstrated that behavior.

https://www.babylonjs-playground.com/#SFA6BT#5

Thank you for your reply.I’m sorry I didn’t make it clear. I want use code to do rotation. Automatic Rotating white sphere.

https://www.babylonjs-playground.com/#SFA6BT#6

?

You’re almost done. Can you stop it when red sphere on the y-axis ?

https://www.babylonjs-playground.com/#SFA6BT#7

Well, there are many ways to do this. Many methods of rotating the object. Here is one approach.

1 Like

Thank you very much for your patience.Seems that the position I set is too standard. In fact, my red sphere may be anywhere on the surface of the white sphere. So I don’t know how to judge. Do you have any idea ?

So you want red sphere to come to the top of the white sphere, no matter where it is positioned on the white sphere?

Yes, that’s what I mean

Okay. That can be a bit trickier.

I am not sure if this is right solution for you. But it should work. It requires a bit of linear algebra though

https://www.babylonjs-playground.com/#SFA6BT#11

Check it out, and if you have further questions be free to ask. :slight_smile:

3 Likes

There were several threads about this - Detecting position on surface of mesh after moving a point in mesh on a certain direction by a certain amount and Ride on surface of mesh
Some PGs from there may help.

1 Like

You made it ! Now I know why I can’t solve it :joy: Thanks again

2 Likes