The Vector4 class is used to create four-dimensional vectors.

Vector4 类用于创建四维向量。

实现

  • IClone

构造函数

  • 参数

    • x: number = 0

      X coordinate. Default is 0.

    • y: number = 0

      Y coordinate. Default is 0.

    • z: number = 0

      Z coordinate. Default is 0.

    • w: number = 0

      W coordinate. Default is 0.

    返回 Vector4

    Constructor method, initializes the vector4.

    构造方法,初始化四维向量。

属性

w: number

W coordinate.

W 轴坐标。

x: number

X coordinate.

X 轴坐标。

y: number

Y coordinate.

Y 轴坐标。

z: number

Z coordinate.

Z 轴坐标。

ONE: Readonly<Vector4> = ...

One vector (1, 1, 1, 1).

一向量 (1, 1, 1, 1)。

TEMP: Vector4 = ...
UnitW: Readonly<Vector4> = ...

Unit W vector (0, 0, 0, 1).

W 单位向量 (0, 0, 0, 1)。

UnitX: Readonly<Vector4> = ...

Unit X vector (1, 0, 0, 0).

X 单位向量 (1, 0, 0, 0)。

UnitY: Readonly<Vector4> = ...

Unit Y vector (0, 1, 0, 0).

Y 单位向量 (0, 1, 0, 0)。

UnitZ: Readonly<Vector4> = ...

Unit Z vector (0, 0, 1, 0).

Z 单位向量 (0, 0, 1, 0)。

ZERO: Readonly<Vector4> = ...

Zero vector (0, 0, 0, 0).

零向量 (0, 0, 0, 0)。

方法

  • 返回 any

    A new Vector4 object with the same values as this vector.

    Creates a clone of this vector.

    创建当前向量的克隆。

  • 参数

    • value: Vector4

      The vector to compare with.

    返回 boolean

    True if the vectors are equal, false otherwise.

    Determines whether this vector is equal to another vector.

    判断当前向量是否与另一个向量相等。

  • 参数

    • arr: ArrayLike<number>

      The source array.

    • offset: number = 0

      The offset in the array. Default is 0.

    返回 void

    Copies values from an array.

    从数组中拷贝值。

  • 返回 number

    The squared length of the vector4.

    Calculates the squared length of the vector4.

    计算四维向量长度的平方。

  • 参数

    • x: number

      The x value.

    • y: number

      The y value.

    • z: number

      The z value.

    • w: number

      The w value.

    返回 Vector4

    Sets the x, y, z, and w values of the vector.

    设置向量的 x、y、z 和 w 值。

  • 返回 number[]

    An array containing the vector components [x, y, z, w].

    Converts the vector to an array.

    将向量转换为数组。

  • 参数

    • arr: { [n: number]: number }

      The target array.

    • offset: number = 0

      The offset in the array. Default is 0.

    返回 void

    Writes the vector values to a array.

    将向量值写入数组。

    arr 目标数组。

    offset 数组偏移。默认值为 0。

  • 参数

    返回 number

    The squared distance.

    Calculate the squared distance between two four-dimensional vectors.

    计算两个四维向量之间距离的平方。