Hi, I am doing some animation on four wheels of the car while pressing arrow keys on keyboard. I just add the event listener using following code
document.addEventListener( 'keydown', keyDown );
document.addEventListener( 'keyup', keyUp );
function keyDown(evt){
switch(evt.keyCode){
case 38:
forward = 1;
break;
case 40:
forward = -1;
break;
case 37:
turn = 1;
break;
case 39:
turn = -1;
break;
}
}
To create an animation like running of car, I just rotate all wheels along X axis with following code within animation loop function.
wheel.rotation.x +=0.2;
To create an animation like turning, I need to rotate the wheels in Y axis.
The Problem is, Once I rotate the wheel in an axis, then the next rotation is performing in the updated axis value only. So It affects the actual animation. Please have a look into the following video. I hope it will give clarification about my issue.
So, if the object’s axes being same after rotation too, then the issue can be solved