Currently using ThreeJS Library along with the option to incorporate Tween as well
At the moment, I have a pole that is rotating around its center. My goal is to make it rotate around the center of the world (at 0, 0, 0), but I am struggling to figure out how to achieve this effectively. Think of it as a pool cue rotating around the white ball. Any assistance on how to achieve this would be greatly appreciated.
I believe I need to adjust its position based on the current angle it's at, but I'm unsure of the exact steps to take. There might be a simpler way to achieve the same outcome, but so far, I haven't found one.
In my render loop, I am currently animating the rotation using the following code:
//Animation
pole.rotateOnAxis(getAxis(angle), -Math.PI/2 - 0.1);
angle += 0.025;
pole.rotateOnAxis(getAxis(angle), Math.PI/2 + 0.1);
function getAxis(angle){
return new THREE.Vector3(-Math.sin(angle), 0, Math.cos(angle));
}
Due to the amount of code, I have placed it on JSFiddle here.