Jim
Jim

Reputation: 1

Rotating an object on itself and around another central object in three.js

In three.js, how do you rotate an object on itself and around another central object?

Upvotes: 0

Views: 598

Answers (1)

Wilt
Wilt

Reputation: 44316

Here an example in a Fiddle that shows how rotation works in three.js.

You can rotate an object around itself by changing the rotation:

object.rotation += 0.01;

You can rotate an object around its parent by adding it to the parent and rotating the parent:

parent.add( object );
parent.rotation += 0.01;

When you rotate the object itself after adding it to the parent, you will rotate it inside the local coordinate system (in this case the coordinate system of the parent).

Check also this answer that handles the rotation direction in three.js

Upvotes: 2

Related Questions