API

Class Vector4

Vector4 class created for EulerAngle class conversion to Quaternion

Implements

Index
  • Creates a Vector4 object from the given floats.

    Parameters

    • x: number = 0

      x value of the vector

    • y: number = 0

      y value of the vector

    • z: number = 0

      z value of the vector

    • w: number = 0

      w value of the vector

    Returns Vector4

dimension: readonly [4]

Tensor.dimension

rank: 1

Tensor.rank

_V8PerformanceHack: DeepImmutableObject<Vector4> = ...

If the first vector is flagged with integers (as everything is 0,0,0,0), V8 stores all of the properties as integers internally because it doesn't know any better yet. If subsequent vectors are created with non-integer values, V8 determines that it would be best to represent these properties as doubles instead of integers, and henceforth it will use floating-point representation for all Vector4 instances that it creates. But the original Vector4 instances are unchanged and has a "deprecated map". If we keep using the Vector4 instances from step 1, it will now be a poison pill which will mess up optimizations in any code it touches.

  • Adds the given coordinates to the current Vector4

    Parameters

    • x: number

      defines the x coordinate of the operand

    • y: number

      defines the y coordinate of the operand

    • z: number

      defines the z coordinate of the operand

    • w: number

      defines the w coordinate of the operand

    Returns this

    the current updated Vector4

  • Updates the current Vector4 coordinates with the given floats.

    Parameters

    • x: number

      float to copy from

    • y: number

      float to copy from

    • z: number

      float to copy from

    • w: number

      float to copy from

    Returns this

    the updated Vector4.

  • Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.

    Parameters

    • x: number

      x value to compare against

    • y: number

      y value to compare against

    • z: number

      z value to compare against

    • w: number

      w value to compare against

    Returns boolean

    true if equal

  • Updates the current Vector4 with the maximal coordinate values between its and the given coordinates.

    Parameters

    • x: number

      defines the x coordinate of the operand

    • y: number

      defines the y coordinate of the operand

    • z: number

      defines the z coordinate of the operand

    • w: number

      defines the w coordinate of the operand

    Returns this

    the current updated Vector4

  • Updates the current Vector4 with the minimal coordinate values between its and the given coordinates

    Parameters

    • x: number

      defines the x coordinate of the operand

    • y: number

      defines the y coordinate of the operand

    • z: number

      defines the z coordinate of the operand

    • w: number

      defines the w coordinate of the operand

    Returns this

    the current updated Vector4

  • Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.

    Parameters

    • x: number

      x value multiply with

    • y: number

      y value multiply with

    • z: number

      z value multiply with

    • w: number

      w value multiply with

    Returns Vector4

    resulting new vector

  • Negate the current Vector4 and stores the result in the given vector "result" coordinates

    Type Parameters

    • T extends IVector4Like

    Parameters

    • result: T

      defines the Vector3 object where to store the result

    Returns T

    the result

  • Scale the current Vector4 values by a factor and add the result to a given Vector4

    Type Parameters

    • T extends IVector4Like

    Parameters

    • scale: number

      defines the scale factor

    • result: T

      defines the Vector4 object where to store the result

    Returns T

    result input

  • Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).

    Type Parameters

    • T extends IVector4Like

    Parameters

    • scale: number

      the number to scale with

    • result: T

      a vector to store the result in

    Returns T

    result input

  • Updates the current Vector4 coordinates with the given floats.

    Parameters

    • x: number

      float to set from

    • y: number

      float to set from

    • z: number

      float to set from

    • w: number

      float to set from

    Returns this

    the updated Vector4.

  • Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.

    Parameters

    • x: number

      value to subtract

    • y: number

      value to subtract

    • z: number

      value to subtract

    • w: number

      value to subtract

    Returns Vector4

    new vector containing the result

  • Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.

    Type Parameters

    • T extends IVector4Like

    Parameters

    • x: number

      value to subtract

    • y: number

      value to subtract

    • z: number

      value to subtract

    • w: number

      value to subtract

    • result: T

      the vector to store the result in

    Returns T

    result input

  • Returns a new Vector4 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max" If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one

    Parameters

    Returns Vector4

    the new Vector4

  • Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max" If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one

    Type Parameters

    • T extends IVector4Like

    Parameters

    • value: DeepImmutable<IVector4Like>

      defines the current value

    • min: DeepImmutable<IVector4Like>

      defines the lower range value

    • max: DeepImmutable<IVector4Like>

      defines the upper range value

    • result: T

      defines the Vector4 where to store the result

    Returns T

    result input

  • Updates the given vector "result" from the starting index of the given array.

    Type Parameters

    • T extends IVector4Like

    Parameters

    • array: DeepImmutable<ArrayLike<number>>

      the array to pull values from

    • offset: number

      the offset into the array to start at

    • result: T

      the vector to store the result in

    Returns T

    result input

  • Updates the given vector "result" from the starting index of the given Float32Array.

    Type Parameters

    • T extends IVector4Like

    Parameters

    • array: DeepImmutable<Float32Array>

      the array to pull values from

    • offset: number

      the offset into the array to start at

    • result: T

      the vector to store the result in

    Returns T

    result input

  • Updates the given vector "result" coordinates from the given floats.

    Type Parameters

    • T extends IVector4Like

    Parameters

    • x: number

      float to set from

    • y: number

      float to set from

    • z: number

      float to set from

    • w: number

      float to set from

    • result: T

      the vector to the floats in

    Returns T

    result input

  • Sets a Vector4 with random values between min and max

    Type Parameters

    • T extends IVector4Like

    Parameters

    • min: number = 0

      the minimum random value

    • max: number = 1

      the maximum random value

    • ref: T

      the ref to store the values in

    Returns T

    the ref with random values between min and max

  • Returns a new Vector4 set with the result of the transformation by the given matrix of the given vector. This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) The difference with Vector3.TransformCoordinates is that the w component is not used to divide the other coordinates but is returned in the w coordinate instead

    Parameters

    Returns Vector4

    the transformed Vector4

  • Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z) This method computes tranformed coordinates only, not transformed direction vectors The difference with Vector3.TransformCoordinatesFromFloatsToRef is that the w component is not used to divide the other coordinates but is returned in the w coordinate instead

    Type Parameters

    • T extends IVector4Like

    Parameters

    • x: number

      define the x coordinate of the source vector

    • y: number

      define the y coordinate of the source vector

    • z: number

      define the z coordinate of the source vector

    • transformation: DeepImmutable<Matrix>

      defines the transformation matrix

    • result: T

      defines the Vector4 where to store the result

    Returns T

    result input

  • Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) The difference with Vector3.TransformCoordinatesToRef is that the w component is not used to divide the other coordinates but is returned in the w coordinate instead

    Type Parameters

    • T extends IVector4Like

    Parameters

    Returns T

    result input

  • Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w). This methods computes transformed normalized direction vectors only.

    Type Parameters

    • T extends IVector4Like

    Parameters

    • x: number

      value to transform

    • y: number

      value to transform

    • z: number

      value to transform

    • w: number

      value to transform

    • transformation: DeepImmutable<Matrix>

      the transformation matrix to apply

    • result: T

      the vector to store the results in

    Returns T

    result input

  • Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector. This methods computes transformed normalized direction vectors only.

    Type Parameters

    • T extends IVector4Like

    Parameters

    • vector: DeepImmutable<IVector4Like>

      the vector to transform

    • transformation: DeepImmutable<Matrix>

      the transformation matrix to apply

    • result: T

      the vector to store the result in

    Returns T

    result input