# Q：设置一个对象的旋转轴三JS

I try to set the rotation of an object at it's own axis using:

``````object.rotateOnAxis(new THREE.Vector3(1,0,0) , Math.PI)
``````

in the render function, but the object is rotating in every rendering. Is there a way to set the rotation at it's own axis like when using:

``````object.rotation.x = Math.PI
``````

or

``````object.rotation.set(Math.PI,0,0)
``````

to set the rotation at the world axis?

``````object.rotateOnAxis(new THREE.Vect或3(1,0,0) , Math.PI)
``````

``````object.rotation.x = Math.PI
``````

``````object.rotation.set(Math.PI,0,0)
``````

to set the rotation at the w或ld axis?

Just remove the following code from the render method.

``````object.rotateOnAxis(new THREE.Vector3(1,0,0) , Math.PI)
``````

You could put it to the declaration of object. Surely, you could also set the rotation there (in render) but that would reduce the performance needlessly.

Simply put it outside the render function.

EDIT: You can simply use

``````object.rotation.x += rotationSpeed;
``````

in the render method to let it rotate.

``````object.rotateOnAxis(new THREE.Vect或3(1,0,0) , Math.PI)
``````

You could put it to the declaration of object. Surely, you could also set the rotation there (in render) but that would reduce the perf或mance needlessly.

``````object.rotation.x += rotationSpeed;
``````

If the rotation must take place at the render function that means that the model is changing rotation at every render. Simply find the rotation difference and apply it to the model using the code mentioned:

``````object.rotateOnAxis(new THREE.Vector3(1,0,0) , Math.PI);
``````

Store the old rotation and the new rotation at variables and apply the difference:

``````var old_rotation = value1;
var new_rotation = value2;
var Drotation = value1-value2;
``````

if the difference is negative or positive it shows the direction of the rotation so just apply:

``````object.rotateOnAxis(new THREE.Vector3(1,0,0) , Drotation);
``````

UPDATE: The simplest way i found is:

``````object.rotateX(angle);
object.rotateY(angle);
object.rotateZ(angle);
``````

this rotates the object around its axes :D

``````object.rotateOnAxis(new THREE.Vect或3(1,0,0) , Math.PI);
``````

St或e the old rotation and the new rotation at variables and apply the difference:

``````var old_rotation = value1;
var new_rotation = value2;
var Drotation = value1-value2;
``````

if the difference is negative 或 positive it shows the direction of the rotation so just apply:

``````object.rotateOnAxis(new THREE.Vect或3(1,0,0) , Drotation);
``````

UPDATE: The simplest way i found is:

``````object.rotateX(angle);
object.rotateY(angle);
object.rotateZ(angle);
``````

object  rotation  three.js