I have make a animation using two obj file. In first obj file have 24 hole. I want to rotate the first obj file.If i give position 3 obj file rotate and 3 position came front of the screen.Attach obj file image.
I wish i understood a single aspect of this question
I want to rotate this obj file.If user give position 2 then Obj file rotate to in negative y direction and when position 2 is come in the place of position1 then the rotation is stop.And same for other position.
…
How about some code, what have you tried so far?
Using this code i can rotate whole group.Stop manually by button click.I have not getting any idea to stop the turntable obj on a particular position dynamically.
function controlanimation()
{
var startButton = document.getElementById(‘btnanimate’);
if (initAnim) {
initAnim = false;
runAnim = true;
theta = 0;
}
// Start and Pause
if (runAnim) {
startButton.value = 'Pause Animation';
runAnim = false;
isPlay = true;
animate();
} else {
startButton.value = 'Restart Animation';
runAnim = true;
isPlay = false;
}
}
function animate(delta) {
requestAnimationFrame(animate);
render();
if (!isPlay) return;
theta = 0.01;
group.rotation.y -= theta;
}
You can do something like
myAngle = Math.acos( myPosition2.normalize().dot( new THREE.Vector3(1,0,0) );
myObject.rotation.y = myAngle
new THREE.Vector3(1,0,0)
makes a vector that lies in the positive x axis, normalize makes your position suitable for the math operation ( unit vector ), dot gives you the cos of the angle. You probably need to use something like Tween.js to manage the actual transition.