A 3 dimensional vector.


Maths

Constructors

  • Creates a vector3.

    Parameters

    • Optional pX: number
      in
      x value of the vector.
    • Optional pY: number
      in
      y value of the vector.
    • Optional pZ: number
      in
      z value of the vector.

    Returns Vector3

    The newly constructed Vector3.

Properties

x: number

x value of the vector.

y: number

y value of the vector.

z: number

z value of the vector.

Methods

  • Computes this + (pX,pY,pZ) and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pX: number
      in
      x value of the vector to add.
    • pY: number
      in
      y value of the vector to add.
    • pZ: number
      in
      z value of the vector to add.
    • Optional pOut: Vector3
      out
      The resulting vector3.

    Returns Vector3

    pOut.

  • Computes this + pOther and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pOther: Vector3
      in
      The vector3 to add.
    • Optional pOut: Vector3
      out
      The resulting vector3.

    Returns Vector3

    pOut.

  • Copies this to pOut vector. If pOut is not supplied, a new Vector3 is allocated.

    Parameters

    • Optional pOut: Vector3
      out
      The Vector3 to copy to.

    Returns Vector3

    The copied vector.

  • Computes the cross vector between this and (pX,pY,pZ) (expressed as Other) and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pX: number
      in
      x value of the vector to compute the cross product with.
    • pY: number
      in
      y value of the vector to compute the cross product with.
    • pZ: number
      in
      z value of the vector to compute the cross product with.
    • Optional pOut: Vector3
      out
      The resulting vector3, cross product (this ^ Other).

    Returns Vector3

    pOut.

  • Computes the cross vector between this and pOther and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pOther: Vector3
      in
      The other vector3 to compute the cross product with.
    • Optional pOut: Vector3
      out
      The resulting vector3, cross product (this ^ pOther).

    Returns Vector3

    pOut.

  • Computes the euclidean distance between this and pVec.

    Parameters

    • pVec: Vector3
      in
      The other vector to compute the distance to.

    Returns number

    The distance between this and pVec.

  • Computes the dot product between this and (pX,pY,pZ).

    Parameters

    • pX: number
      in
      x value of the vector to compute the dot with.
    • pY: number
      in
      y value of the vector to compute the dot with.
    • pZ: number
      in
      z value of the vector to compute the dot with.

    Returns number

    The dot product ( dot(this, (pX,pY,pZ)) ) .

  • Computes the dot product between this and pOther.

    Parameters

    • pOther: Vector3
      in
      The other vector3 to compute the dot with.

    Returns number

    The dot product ( dot(this, pOther) ).

  • Tells if the two vectors are strictly identical.

    Parameters

    • pOtherVector: Vector3
      in
      The other vector to compare to.

    Returns boolean

    true if the two vectors are strictly identical.

  • Sets the content of the Vector from a former call to toJSON.

    Parameters

    • pVectorData: string | Object
      in
      Internal Vector3 data to set.

    Returns boolean

    true if the data is set.

  • Gets the euclidean length of this.

    Returns number

    The length of this.

  • Gets the squared euclidean length of this.

    Returns number

    The squared length of this.

  • Computes the linear interpolation between this and (pX,pY,pZ) and stores the result in pOut.

    pOut = this + pTime x ( (pX,pY,pZ) - this).
    If pTime=0, pOut = this.
    If pTime=1, pOut = (pX,pY,pZ).

    If pOut is omitted, the result of the interpolation is stored in this.

    No check is done to ensure pTime is in the range [0,1].

    Parameters

    • pX: number
      in
      x value of the destination vector.
    • pY: number
      in
      y value of the destination vector.
    • pZ: number
      in
      z value of the destination vector.
    • pTime: number
      in
      Interpolation parameter in the range [0,1].
    • Optional pOut: Vector3
      out
      The resulting vector3.

    Returns Vector3

    pOut.

  • Computes the linear interpolation between this and pOther and stores the result in pOut.

    pOut = this + pTime x ( pOther - this).
    If pTime=0, pOut = this.
    If pTime=1, pOut = pOther.

    If pOut is omitted, the result of the interpolation is stored in this.

    No check is done to ensure pTime is in the range [0,1].

    Parameters

    • pOther: Vector3
      in
      The destination vector.
    • pTime: number
      in
      Interpolation parameter in the range [0,1].
    • Optional pOut: Vector3
      out
      The resulting vector3.

    Returns Vector3

    pOut.

  • Computes the opposite of this (-this) and stores the result in pOut.

    If pOut is omitted, the result is stored in this.

    Parameters

    • Optional pOut: Vector3
      out
      The resulting vector.

    Returns Vector3

    pOut.

  • Computes the normalization of this (i.e. scales this such that pOut.length() == 1, a zero vector is left unchanged) and stores the result in pOut.

    If pOut is omitted, this is normalized.

    Parameters

    • Optional pOut: Vector3
      out
      The resulting vector.

    Returns Vector3

    pOut.

  • Computes the scale of this by the scalar pScalar, and stores the result in pOut.

    pOut = pScalar x this.

    If pOut is omitted, the result is stored in this.

    Parameters

    • pScalar: number
      in
      The scale factor.
    • Optional pOut: Vector3
      out
      The resulting vector.

    Returns Vector3

    pOut.

  • Sets the vector components.

    Parameters

    • pX: number
      in
      x value.
    • pY: number
      in
      y value.
    • pZ: number
      in
      z value.

    Returns this

    this.

  • Computes the squared euclidean distance between this and pVec.

    Parameters

    • pVec: Vector3
      in
      The other vector to compute the distance to.

    Returns number

    The squared distance between this and pVec.

  • Computes this - (pX,pY,pZ) and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pX: number
      in
      x value of the vector to subtract.
    • pY: number
      in
      y value of the vector to subtract.
    • pZ: number
      in
      z value of the vector to subtract.
    • Optional pOut: Vector3
      out
      The resulting vector3.

    Returns Vector3

    pOut.

  • Computes this - pOther and stores it into pOut.

    If pOut is omitted, the result is stored in this.

    Returns pOut.

    Parameters

    • pOther: Vector3
      in
      The vector3 to subtract.
    • Optional pOut: Vector3
      out
      The resulting vector3.

    Returns Vector3

    pOut.

  • Serializes the given Vector3 to JSON.

    Parameters

    • Optional pKey: any
      in
      Unused.

    Returns Object

    The JSON representation of the object.

  • Gets the string representation of the vector.

    Returns string

    The string representation of the vector.