Skip to main content
Version: Phaser v4.0.0

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

nametypeoptionaldefaultdescription
xnumberYes0The rotation around the X axis, in radians.
ynumberYes0The rotation around the Y axis, in radians.
znumberYes0The rotation around the Z axis, in radians.
orderstringYes"'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:

nametypeoptionaldescription
eulerPhaser.Math.EulerNoThe 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:

nametypeoptionaldescription
xnumberNoThe rotation around the X axis, in radians.
ynumberNoThe rotation around the Y axis, in radians.
znumberNoThe rotation around the Z axis, in radians.
orderstringYesThe 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:

nametypeoptionaldefaultdescription
quaternionPhaser.Math.QuaternionNoThe quaternion to derive Euler angles from.
orderstringYesThe rotation order to use. Defaults to the current order if not specified.
updatebooleanYesfalseWhether 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:

nametypeoptionaldefaultdescription
matrixPhaser.Math.Matrix4NoThe rotation matrix to derive Euler angles from. Must be a pure (un-scaled) rotation matrix.
orderstringYesThe rotation order to use. Defaults to the current order if not specified.
updatebooleanYesfalseWhether to invoke onChangeCallback after setting the values.

Returns: Phaser.Math.Euler - This Euler instance.

Source: src/math/Euler.js#L215
Since: 3.50.0