The setRotationFromEuler()
method of the Object3D
class in three.js sets the orientation of the object based on euler angles.
setRotationFromEuler(euler: Euler): this
Euler
class representing the desired orientation of the object.The setRotationFromEuler()
method sets the orientation of the object based on euler angles, measured in radians. The euler angles specify the rotation around each of the object's axes in a specific order, known as the intrinsic rotation sequence.
The intrinsic rotation sequence used by three.js for euler angles is ZYX, which means that the object is first rotated around its z-axis, then around its y-axis, and finally around its x-axis.
The euler angles can be set either as separate x, y, and z values, or as an instance of the Euler
class. When using separate values, the order of rotation is always ZYX.
The setRotationFromEuler()
method returns the Object3D
instance on which it was called. This allows for method chaining.
const object = new THREE.Object3D();
// Set the orientation to 90 degrees around the y-axis
object.setRotationFromEuler(new THREE.Euler(0, Math.PI/2, 0));
const object = new THREE.Object3D();
const euler = new THREE.Euler();
// Set the orientation to 45 degrees around the y-axis and 30 degrees around the x-axis
euler.set(Math.PI/6, Math.PI/4, 0);
object.setRotationFromEuler(euler);
Vector3
.