Skip to content

Object.rotation's axis of rotation #910

@sushant24

Description

@sushant24

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions