Euler
Represents a set of Euler angles (rotation around X, Y, and Z axes) used for 3D rotations. Euler angles describe orientation using three successive rotations around the coordinate axes. The order property defines which axes and in what sequence the rotations are applied (e.g., 'XYZ' applies rotation around X first, then Y, then Z).
Constructor
new Euler([x], [y], [z], [order])
Parameters
| name | type | optional | default | description |
|---|---|---|---|---|
| x | number | Yes | 0 | The rotation around the X axis, in radians. |
| y | number | Yes | 0 | The rotation around the Y axis, in radians. |
| z | number | Yes | 0 | The rotation around the Z axis, in radians. |
| order | string | Yes | "'XYZ'" | The order in which rotations are applied. One of 'XYZ', 'YXZ', 'ZXY', 'ZYX', 'YZX', or 'XZY'. |
Scope: static
Source: src/math/Euler.js#L14
Since: 3.50.0
Public Members
order
order: string
Description:
The rotation order used when applying Euler angles. Determines the sequence in which rotations around the X, Y, and Z axes are applied. Must be one of: 'XYZ', 'YXZ', 'ZXY', 'ZYX', 'YZX', or 'XZY'.
Setting this property will invoke the onChangeCallback, if one has been set.
Source: src/math/Euler.js#L119
Since: 3.50.0
x
x: number
Description:
The rotation around the X axis, in radians.
Setting this property will invoke the onChangeCallback, if one has been set.
Source: src/math/Euler.js#L50
Since: 3.50.0
y
y: number
Description:
The rotation around the Y axis, in radians.
Setting this property will invoke the onChangeCallback, if one has been set.
Source: src/math/Euler.js#L73
Since: 3.50.0
z
z: number
Description:
The rotation around the Z axis, in radians.
Setting this property will invoke the onChangeCallback, if one has been set.
Source: src/math/Euler.js#L96
Since: 3.50.0
Public Methods
copy
<instance> copy(euler)
Description:
Copies the X, Y, Z, and order properties from another Euler instance into this one.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| euler | Phaser.Math.Euler | No | The Euler instance to copy from. |
Returns: Phaser.Math.Euler - This Euler instance.
Source: src/math/Euler.js#L174
Since: 3.50.0
set
<instance> set(x, y, z, [order])
Description:
Sets the X, Y, Z, and order components of this Euler angle simultaneously.
After updating all internal values, onChangeCallback is invoked with this Euler instance as the argument.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| x | number | No | The rotation around the X axis, in radians. |
| y | number | No | The rotation around the Y axis, in radians. |
| z | number | No | The rotation around the Z axis, in radians. |
| order | string | Yes | The rotation order. Defaults to the current order if not specified. |
Returns: Phaser.Math.Euler - This Euler instance.
Source: src/math/Euler.js#L144
Since: 3.50.0
setFromQuaternion
<instance> setFromQuaternion(quaternion, [order], [update])
Description:
Sets the Euler angles from a Quaternion, using the specified rotation order.
The quaternion is first converted to a rotation matrix internally, then setFromRotationMatrix is called to derive the Euler angles. This avoids gimbal lock issues by working through the matrix representation.
Parameters:
| name | type | optional | default | description |
|---|---|---|---|---|
| quaternion | Phaser.Math.Quaternion | No | The quaternion to derive Euler angles from. | |
| order | string | Yes | The rotation order to use. Defaults to the current order if not specified. | |
| update | boolean | Yes | false | Whether to invoke onChangeCallback after setting the values. |
Returns: Phaser.Math.Euler - This Euler instance.
Source: src/math/Euler.js#L189
Since: 3.50.0
setFromRotationMatrix
<instance> setFromRotationMatrix(matrix, [order], [update])
Description:
Sets the Euler angles from the upper-left 3x3 rotation portion of a 4x4 Matrix4, using the specified rotation order.
The matrix is assumed to be a pure rotation matrix (un-scaled). Each supported rotation order has its own decomposition formula. If the update parameter is true, onChangeCallback is invoked after the values are set.
Parameters:
| name | type | optional | default | description |
|---|---|---|---|---|
| matrix | Phaser.Math.Matrix4 | No | The rotation matrix to derive Euler angles from. Must be a pure (un-scaled) rotation matrix. | |
| order | string | Yes | The rotation order to use. Defaults to the current order if not specified. | |
| update | boolean | Yes | false | Whether to invoke onChangeCallback after setting the values. |
Returns: Phaser.Math.Euler - This Euler instance.
Source: src/math/Euler.js#L215
Since: 3.50.0