The Quaternion class is used to create quaternions.

Quaternion 类用于创建四元数。

实现

  • IClone

构造函数

  • 参数

    • x: number = 0

      The x value of the quaternion. Default is 0.

    • y: number = 0

      The y value of the quaternion. Default is 0.

    • z: number = 0

      The z value of the quaternion. Default is 0.

    • w: number = 1

      The w value of the quaternion. Default is 1.

    返回 Quaternion

    Constructor method, initializes the default value.

    构造方法,初始化为默认值。

属性

w: number

W-axis coordinate.

W轴坐标。

x: number

X-axis coordinate.

X轴坐标。

y: number

Y-axis coordinate.

Y轴坐标。

z: number

Z-axis coordinate.

Z轴坐标。

DEFAULT: Readonly<Quaternion> = ...

Default quaternion, read-only.

默认四元数,只读。

NAN: Readonly<Quaternion> = ...

Invalid quaternion, read-only.

无效四元数,只读。

方法

  • 参数

    • array: any[]

      The source array.

    • offset: number = 0

      The start offset in the array. Default is 0.

    返回 void

    Copy values from an array.

    从数组中拷贝值。

  • 参数

    • out: Vector3

      The output Vector3 to store the Euler angles.

    返回 void

    Decompose the quaternion into Euler angles (in the order of Yaw, Pitch, Roll). Note: This method may produce sudden flips when rotating around the X axis beyond ±90 degrees.

    将四元数分解为欧拉角(按Yaw、Pitch、Roll的顺序)。 注意:当绕X轴旋转超过±90度时,此方法可能会产生突然的翻转。

  • 返回 number

    The squared length of the quaternion.

    Calculates the squared length of the quaternion.

    计算四元数长度的平方。

  • 参数

    • rad: number

      The angle of rotation.

    • out: Quaternion

      The output rotated quaternion.

    返回 void

    Rotate the quaternion around the X axis.

    根据绕X轴的角度旋转四元数。

  • 参数

    • rad: number

      The angle of rotation.

    • out: Quaternion

      The output rotated quaternion.

    返回 void

    Rotate the quaternion around the Y axis by a specified angle.

    根据绕Y轴的指定角度旋转四元数。

  • 参数

    • rad: number

      The angle of rotation.

    • out: Quaternion

      The output rotated quaternion.

    返回 void

    Rotate the quaternion around the Z axis by a specified angle.

    根据绕Z轴的指定角度旋转四元数。

  • 参数

    • scaling: number

      The scalar value to scale by.

    • out: Quaternion

      The output quaternion.

    返回 void

    Scale the quaternion by a scalar value.

    根据缩放值缩放四元数。

  • 参数

    • x: number

      The X value.

    • y: number

      The Y value.

    • z: number

      The Z value.

    • w: number

      The W value.

    返回 Quaternion

    The quaternion itself.

    Set the values of the quaternion and return itself.

    设置四元数的值并返回自身。

  • 参数

    • x: number

      The X value.

    • y: number

      The Y value.

    • z: number

      The Z value.

    • w: number

      The W value.

    返回 void

    Set the values of the quaternion.

    设置四元数的值。

  • 参数

    • axis: Vector3

      The axis vector.

    • rad: number

      The angle in radians.

    • out: Quaternion

      The output quaternion.

    返回 void

    Calculate a quaternion from the specified axis and angle.

    从指定的轴和角度计算四元数。

  • 参数

    • yaw: number

      The yaw value

    • pitch: number

      The pitch value

    • roll: number

      The roll value

    • out: Quaternion

      The output quaternion

    返回 void

    Generate a quaternion from Euler angles (order is Yaw, Pitch, Roll)

    从欧拉角生成四元数(顺序为Yaw、Pitch、Roll)

  • 参数

    返回 void

    Calculates a look-at quaternion (suitable for GameObject).

    计算观察四元数(适用于游戏对象)。

  • 参数

    • left: Quaternion

      The left quaternion.

    • right: Quaternion

      The right quaternion.

    • amount: number

      The interpolation factor, ranging from 0 to 1.

    • out: Quaternion

      The output quaternion.

    返回 void

    Calculate the linear interpolation between two quaternions.

    计算两个四元数的线性插值。

  • 参数

    返回 void

    Calculates a look-at quaternion (suitable for Camera and Light).

    计算观察四元数(适用于相机和灯光)。

  • 参数

    • axis: Vector3

      The rotation axis

    • rad: number

      The rotation angle in radians

    • out: Quaternion

      The output quaternion after rotation

    返回 void

    Calculate a quaternion that rotates around an arbitrary axis.

    计算绕任意轴旋转的四元数。