I stumbled upon a fascinating snippet that allows elements to rotate around another element, mimicking planetary rotation. I'm eager to incorporate this 2D rotation feature into a three.js project for a more immersive 3D experience.
The demo showcasing the 2D functionality can be found in this example.
However, I'm encountering difficulties while trying to integrate it into my own scene. Identifying the IDs of meshes in three.js poses a challenge initially.
myObject.name = "objectName";
...
var object = scene.getObjectByName( "objectName" );
The suggested method of naming and retrieving meshes didn't work out as expected - unfortunately, it was the only reliable solution I could locate.
Furthermore, I am struggling to comprehend how to adjust trigonometric functions when transitioning from 2D to 3D.
return {
x: Math.cos(ang) * r - Math.sin(ang) * r + coorX,
y: Math.sin(ang) * r + Math.cos(ang) * r + coorY
};
It seems there are complexities beyond my current skill level. If anyone could shed light on how this functionality should look like in a 3D environment, I would greatly appreciate your assistance.