BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

Object3D.setRotationFromEuler()

The setRotationFromEuler() method of the Object3D class in three.js sets the orientation of the object based on euler angles.

Syntax

setRotationFromEuler(euler: Euler): this
  • euler - An instance of the Euler class representing the desired orientation of the object.

Description

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.

Return value

The setRotationFromEuler() method returns the Object3D instance on which it was called. This allows for method chaining.

Examples

Setting euler angles with separate values

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));

Setting euler angles with an Euler object

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);

See also

  • Object3D.rotation - The object's rotation as a Vector3.
  • Euler - The class used to represent euler angles in three.js.