mrdoob/three.js — Issue #910: Object.rotation's axis of rotation
Author: sushant24
Created: 2011-12-14 19:23:07+00:00
State: open

Does changing the value of an object's rotation property rotate the object about the world axes or the object's axes? For eg
object.rotation.x += 2.
Will this rotate the object about the world X axis or the object's X axis?
I tried the following example :

var materials = [];
materials.push( [ new THREE.MeshBasicMaterial( { color: 0xff0000 } ) ] );
materials.push( [ new THREE.MeshBasicMaterial( { color: 0xff0000 } ) ] );
materials.push( [ new THREE.MeshBasicMaterial( { color: 0x00ff00 } ) ] );
materials.push( [ new THREE.MeshBasicMaterial( { color: 0x00ff00 } ) ] );
materials.push( [ new THREE.MeshBasicMaterial( { color: 0x0000ff } ) ] );
materials.push( [ new THREE.MeshBasicMaterial( { color: 0x0000ff } ) ] );

object = new THREE.Mesh( new THREE.CubeGeometry( 20, 20, 20, 1, 1, 1, materials ), new THREE.MeshFaceMaterial() );

object.position.x = 0;
object.position.y = 0;
object.position.z = 0;

object.rotation.x = 0;
object.rotation.y = 0;
object.rotation.z = 0;

object.scale.x = 1;
object.scale.y = 1;
object.scale.z = 1;

scene.add( object );

After i have added the object to the scene i tried the following -
object.rotation.x += Math.PI/4;
object.rotation.y += Math.PI/4;
object.rotation.z += Math.PI/4;

Until now the object rotates with respect to its own X,Y and Z axes.
but doing : object.rotation.x += Math.Pi/4;
now rotates the object 45 degrees about the World X axis instead of the object's X axis.