Vector3

Classed used to store (x,y,z) vector representation A Vector3 is the main object used in 3D geometry It can represent etiher the coordinates of a point the space, either a direction Reminder: Babylon.js uses a left handed forward facing system

Hierarchy

  • Vector3

Index

Constructors

constructor

  • new Vector3(x: number, y: number, z: number): Vector3
  • Creates a new Vector3 object from the given x, y, z (floats) coordinates.

    Parameters

    • x: number

      defines the first coordinates (on X axis)

    • y: number

      defines the second coordinates (on Y axis)

    • z: number

      defines the third coordinates (on Z axis)

    Returns Vector3

Properties

isNonUniform

isNonUniform: boolean

Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same

x

x: number

Defines the first coordinates (on X axis)

y

y: number

Defines the second coordinates (on Y axis)

z

z: number

Defines the third coordinates (on Z axis)

Methods

add

  • Gets a new Vector3, result of the addition the current Vector3 and the given vector

    Parameters

    • otherVector: Vector3

      defines the second operand

    Returns Vector3

    the resulting Vector3

addInPlace

  • Adds the given vector to the current Vector3

    Parameters

    • otherVector: Vector3

      defines the second operand

    Returns Vector3

    the current updated Vector3

addToRef

  • Adds the current Vector3 to the given one and stores the result in the vector "result"

    Parameters

    • otherVector: Vector3

      defines the second operand

    • result: Vector3

      defines the Vector3 object where to store the result

    Returns Vector3

    the current Vector3

asArray

  • asArray(): number[]
  • Creates an array containing three elements : the coordinates of the Vector3

    Returns number[]

    a new array of numbers

clone

  • Creates a new Vector3 copied from the current Vector3

    Returns Vector3

    the new Vector3

copyFrom

  • Copies the given vector coordinates to the current Vector3 ones

    Parameters

    • source: Vector3

      defines the source Vector3

    Returns Vector3

    the current updated Vector3

copyFromFloats

  • copyFromFloats(x: number, y: number, z: number): Vector3
  • Copies the given floats to the current Vector3 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

    Returns Vector3

    the current updated Vector3

divide

  • Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones

    Parameters

    • otherVector: Vector3

      defines the second operand

    Returns Vector3

    the new Vector3

divideInPlace

  • Divides the current Vector3 coordinates by the given ones.

    Parameters

    • otherVector: Vector3

      defines the second operand

    Returns Vector3

    the current updated Vector3

divideToRef

  • Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"

    Parameters

    • otherVector: Vector3

      defines the second operand

    • result: Vector3

      defines the Vector3 object where to store the result

    Returns Vector3

    the current Vector3

equals

  • equals(otherVector: Vector3): boolean
  • Returns true if the current Vector3 and the given vector coordinates are strictly equal

    Parameters

    • otherVector: Vector3

      defines the second operand

    Returns boolean

    true if both vectors are equals

equalsToFloats

  • equalsToFloats(x: number, y: number, z: number): boolean
  • Returns true if the current Vector3 coordinates equals the given floats

    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

    Returns boolean

    true if both vectors are equals

equalsWithEpsilon

  • equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean
  • Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon

    Parameters

    • otherVector: Vector3

      defines the second operand

    • Optional epsilon: number

      defines the minimal distance to define values as equals

    Returns boolean

    true if both vectors are distant less than epsilon

getClassName

  • getClassName(): string
  • Gets the class name

    Returns string

    the string "Vector3"

getHashCode

  • getHashCode(): number
  • Creates the Vector3 hash code

    Returns number

    a number which tends to be unique between Vector3 instances

length

  • length(): number
  • Gets the length of the Vector3

    Returns number

    the length of the Vecto3

lengthSquared

  • lengthSquared(): number
  • Gets the squared length of the Vector3

    Returns number

    squared length of the Vector3

maximizeInPlace

  • Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.

    Parameters

    • other: Vector3

      defines the second operand

    Returns Vector3

    the current updated Vector3

minimizeInPlace

  • Updates the current Vector3 with the minimal coordinate values between its and the given vector ones

    Parameters

    • other: Vector3

      defines the second operand

    Returns Vector3

    the current updated Vector3

multiply

  • Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector

    Parameters

    • otherVector: Vector3

      defines the second operand

    Returns Vector3

    the new Vector3

multiplyByFloats

  • multiplyByFloats(x: number, y: number, z: number): Vector3
  • Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats

    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

    Returns Vector3

    the new Vector3

multiplyInPlace

  • Multiplies the current Vector3 coordinates by the given ones

    Parameters

    • otherVector: Vector3

      defines the second operand

    Returns Vector3

    the current updated Vector3

multiplyToRef

  • Multiplies the current Vector3 by the given one and stores the result in the given vector "result"

    Parameters

    • otherVector: Vector3

      defines the second operand

    • result: Vector3

      defines the Vector3 object where to store the result

    Returns Vector3

    the current Vector3

negate

  • Gets a new Vector3 set with the current Vector3 negated coordinates

    Returns Vector3

    a new Vector3

normalize

  • Normalize the current Vector3. Please note that this is an in place operation.

    Returns Vector3

    the current updated Vector3

normalizeToNew

  • Normalize the current Vector3 to a new vector

    Returns Vector3

    the new Vector3

normalizeToRef

  • Normalize the current Vector3 to the reference

    Parameters

    • reference: Vector3

      define the Vector3 to update

    Returns Vector3

    the updated Vector3

scale

  • Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"

    Parameters

    • scale: number

      defines the multiplier factor

    Returns Vector3

    a new Vector3

scaleAndAddToRef

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

    Parameters

    • scale: number

      defines the scale factor

    • result: Vector3

      defines the Vector3 object where to store the result

    Returns Vector3

    the unmodified current Vector3

scaleInPlace

  • scaleInPlace(scale: number): Vector3
  • Multiplies the Vector3 coordinates by the float "scale"

    Parameters

    • scale: number

      defines the multiplier factor

    Returns Vector3

    the current updated Vector3

scaleToRef

  • Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates

    Parameters

    • scale: number

      defines the multiplier factor

    • result: Vector3

      defines the Vector3 object where to store the result

    Returns Vector3

    the current Vector3

set

  • set(x: number, y: number, z: number): Vector3
  • Copies the given floats to the current Vector3 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

    Returns Vector3

    the current updated Vector3

subtract

  • Returns a new Vector3, result of the subtraction of the given vector from the current Vector3

    Parameters

    • otherVector: Vector3

      defines the second operand

    Returns Vector3

    the resulting Vector3

subtractFromFloats

  • subtractFromFloats(x: number, y: number, z: number): Vector3
  • Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 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

    Returns Vector3

    the resulting Vector3

subtractFromFloatsToRef

  • subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3
  • Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result

    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

    • result: Vector3

      defines the Vector3 object where to store the result

    Returns Vector3

    the current Vector3

subtractInPlace

  • Subtract the given vector from the current Vector3

    Parameters

    • otherVector: Vector3

      defines the second operand

    Returns Vector3

    the current updated Vector3

subtractToRef

  • Subtracts the given vector from the current Vector3 and stores the result in the vector "result".

    Parameters

    • otherVector: Vector3

      defines the second operand

    • result: Vector3

      defines the Vector3 object where to store the result

    Returns Vector3

    the current Vector3

toArray

  • Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3

    Parameters

    • array: FloatArray

      defines the destination array

    • Optional index: number

      defines the offset in the destination array

    Returns Vector3

    the current Vector3

toQuaternion

  • Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)

    Returns Quaternion

    a new Quaternion object, computed from the Vector3 coordinates

toString

  • toString(): string
  • Creates a string representation of the Vector3

    Returns string

    a string with the Vector3 coordinates.

Static CatmullRom

  • Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"

    Parameters

    • value1: Vector3

      defines the first control point

    • value2: Vector3

      defines the second control point

    • value3: Vector3

      defines the third control point

    • value4: Vector3

      defines the fourth control point

    • amount: number

      defines the amount on the spline to use

    Returns Vector3

    the new Vector3

Static Center

  • Returns a new Vector3 located at the center between "value1" and "value2"

    Parameters

    • value1: Vector3

      defines the first operand

    • value2: Vector3

      defines the second operand

    Returns Vector3

    the new Vector3

Static Clamp

  • Returns a new Vector3 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

    • value: Vector3

      defines the current value

    • min: Vector3

      defines the lower range value

    • max: Vector3

      defines the upper range value

    Returns Vector3

    the new Vector3

Static Cross

  • Returns a new Vector3 as the cross product of the vectors "left" and "right" The cross product is then orthogonal to both "left" and "right"

    Parameters

    • left: Vector3

      defines the left operand

    • right: Vector3

      defines the right operand

    Returns Vector3

    the cross product

Static CrossToRef

  • Sets the given vector "result" with the cross product of "left" and "right" The cross product is then orthogonal to both "left" and "right"

    Parameters

    • left: Vector3

      defines the left operand

    • right: Vector3

      defines the right operand

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static Distance

  • Returns the distance between the vectors "value1" and "value2"

    Parameters

    • value1: Vector3

      defines the first operand

    • value2: Vector3

      defines the second operand

    Returns number

    the distance

Static DistanceSquared

  • Returns the squared distance between the vectors "value1" and "value2"

    Parameters

    • value1: Vector3

      defines the first operand

    • value2: Vector3

      defines the second operand

    Returns number

    the squared distance

Static Dot

  • Returns the dot product (float) between the vectors "left" and "right"

    Parameters

    • left: Vector3

      defines the left operand

    • right: Vector3

      defines the right operand

    Returns number

    the dot product

Static Forward

  • Returns a new Vector3 set to (0.0, 0.0, 1.0)

    Returns Vector3

    a new forward Vector3

Static FromArray

  • FromArray(array: ArrayLike<number>, offset?: number): Vector3
  • Returns a new Vector3 set from the index "offset" of the given array

    Parameters

    • array: ArrayLike<number>

      defines the source array

    • Optional offset: number

      defines the offset in the source array

    Returns Vector3

    the new Vector3

Static FromArrayToRef

  • FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void
  • Sets the given vector "result" with the element values from the index "offset" of the given array

    Parameters

    • array: ArrayLike<number>

      defines the source array

    • offset: number

      defines the offset in the source array

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static FromFloatArray

  • FromFloatArray(array: Float32Array, offset?: number): Vector3
  • Returns a new Vector3 set from the index "offset" of the given Float32Array This function is deprecated. Use FromArray instead

    Parameters

    • array: Float32Array

      defines the source array

    • Optional offset: number

      defines the offset in the source array

    Returns Vector3

    the new Vector3

Static FromFloatArrayToRef

  • FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void
  • Sets the given vector "result" with the element values from the index "offset" of the given Float32Array This function is deprecated. Use FromArrayToRef instead.

    Parameters

    • array: Float32Array

      defines the source array

    • offset: number

      defines the offset in the source array

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static FromFloatsToRef

  • FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void
  • Sets the given vector "result" with the given floats.

    Parameters

    • x: number

      defines the x coordinate of the source

    • y: number

      defines the y coordinate of the source

    • z: number

      defines the z coordinate of the source

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static GetAngleBetweenVectors

  • Get angle between two vectors

    Parameters

    • vector0: Vector3

      angle between vector0 and vector1

    • vector1: Vector3

      angle between vector0 and vector1

    • normal: Vector3

      direction of the normal

    Returns number

    the angle between vector0 and vector1

Static GetClipFactor

  • Get the clip factor between two vectors

    Parameters

    • vector0: Vector3

      defines the first operand

    • vector1: Vector3

      defines the second operand

    • axis: Vector3

      defines the axis to use

    • size: number

      defines the size along the axis

    Returns number

    the clip factor

Static Hermite

  • Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"

    Parameters

    • value1: Vector3

      defines the first control point

    • tangent1: Vector3

      defines the first tangent vector

    • value2: Vector3

      defines the second control point

    • tangent2: Vector3

      defines the second tangent vector

    • amount: number

      defines the amount on the interpolation spline (between 0 and 1)

    Returns Vector3

    the new Vector3

Static Left

  • Returns a new Vector3 set to (-1.0, 0.0, 0.0)

    Returns Vector3

    a new left Vector3

Static Lerp

  • Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"

    Parameters

    • start: Vector3

      defines the start value

    • end: Vector3

      defines the end value

    • amount: number

      max defines amount between both (between 0 and 1)

    Returns Vector3

    the new Vector3

Static LerpToRef

  • Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"

    Parameters

    • start: Vector3

      defines the start value

    • end: Vector3

      defines the end value

    • amount: number

      max defines amount between both (between 0 and 1)

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static Maximize

  • Gets the maximal coordinate values between two Vector3

    Parameters

    • left: Vector3

      defines the first operand

    • right: Vector3

      defines the second operand

    Returns Vector3

    the new Vector3

Static Minimize

  • Gets the minimal coordinate values between two Vector3

    Parameters

    • left: Vector3

      defines the first operand

    • right: Vector3

      defines the second operand

    Returns Vector3

    the new Vector3

Static Normalize

  • Returns a new Vector3 as the normalization of the given vector

    Parameters

    • vector: Vector3

      defines the Vector3 to normalize

    Returns Vector3

    the new Vector3

Static NormalizeToRef

  • Sets the given vector "result" with the normalization of the given first vector

    Parameters

    • vector: Vector3

      defines the Vector3 to normalize

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static One

  • Returns a new Vector3 set to (1.0, 1.0, 1.0)

    Returns Vector3

    a new unit Vector3

Static Project

  • Project a Vector3 onto screen space

    Parameters

    • vector: Vector3

      defines the Vector3 to project

    • world: Matrix

      defines the world matrix to use

    • transform: Matrix

      defines the transform (view x projection) matrix to use

    • viewport: Viewport

      defines the screen viewport to use

    Returns Vector3

    the new Vector3

Static Right

  • Returns a new Vector3 set to (1.0, 0.0, 0.0)

    Returns Vector3

    a new right Vector3

Static RotationFromAxis

  • Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply to something in order to rotate it from its local system to the given target system Note: axis1, axis2 and axis3 are normalized during this operation

    Parameters

    • axis1: Vector3

      defines the first axis

    • axis2: Vector3

      defines the second axis

    • axis3: Vector3

      defines the third axis

    Returns Vector3

    a new Vector3

Static RotationFromAxisToRef

  • The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3

    Parameters

    • axis1: Vector3

      defines the first axis

    • axis2: Vector3

      defines the second axis

    • axis3: Vector3

      defines the third axis

    • ref: Vector3

      defines the Vector3 where to store the result

    Returns void

Static TransformCoordinates

  • Returns a new Vector3 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)

    Parameters

    • vector: Vector3

      defines the Vector3 to transform

    • transformation: Matrix

      defines the transformation matrix

    Returns Vector3

    the transformed Vector3

Static TransformCoordinatesFromFloatsToRef

  • TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void
  • 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

    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: Matrix

      defines the transformation matrix

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static TransformCoordinatesToRef

  • 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)

    Parameters

    • vector: Vector3

      defines the Vector3 to transform

    • transformation: Matrix

      defines the transformation matrix

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static TransformNormal

  • Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector This methods computes transformed normalized direction vectors only (ie. it does not apply translation)

    Parameters

    • vector: Vector3

      defines the Vector3 to transform

    • transformation: Matrix

      defines the transformation matrix

    Returns Vector3

    the new Vector3

Static TransformNormalFromFloatsToRef

  • TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void
  • Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z) This methods computes transformed normalized direction vectors only (ie. it does not apply translation)

    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: Matrix

      defines the transformation matrix

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static TransformNormalToRef

  • 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 (ie. it does not apply translation)

    Parameters

    • vector: Vector3

      defines the Vector3 to transform

    • transformation: Matrix

      defines the transformation matrix

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static Unproject

  • Unproject from screen space to object space

    Parameters

    • source: Vector3

      defines the screen space Vector3 to use

    • viewportWidth: number

      defines the current width of the viewport

    • viewportHeight: number

      defines the current height of the viewport

    • world: Matrix

      defines the world matrix to use (can be set to Identity to go to world space)

    • view: Matrix

      defines the view matrix to use

    • projection: Matrix

      defines the projection matrix to use

    Returns Vector3

    the new Vector3

Static UnprojectFloatsToRef

  • Unproject from screen space to object space

    Parameters

    • sourceX: float

      defines the screen space x coordinate to use

    • sourceY: float

      defines the screen space y coordinate to use

    • sourceZ: float

      defines the screen space z coordinate to use

    • viewportWidth: number

      defines the current width of the viewport

    • viewportHeight: number

      defines the current height of the viewport

    • world: Matrix

      defines the world matrix to use (can be set to Identity to go to world space)

    • view: Matrix

      defines the view matrix to use

    • projection: Matrix

      defines the projection matrix to use

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static UnprojectFromTransform

  • UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3
  • Unproject from screen space to object space

    Parameters

    • source: Vector3

      defines the screen space Vector3 to use

    • viewportWidth: number

      defines the current width of the viewport

    • viewportHeight: number

      defines the current height of the viewport

    • world: Matrix

      defines the world matrix to use (can be set to Identity to go to world space)

    • transform: Matrix

      defines the transform (view x projection) matrix to use

    Returns Vector3

    the new Vector3

Static UnprojectToRef

  • Unproject from screen space to object space

    Parameters

    • source: Vector3

      defines the screen space Vector3 to use

    • viewportWidth: number

      defines the current width of the viewport

    • viewportHeight: number

      defines the current height of the viewport

    • world: Matrix

      defines the world matrix to use (can be set to Identity to go to world space)

    • view: Matrix

      defines the view matrix to use

    • projection: Matrix

      defines the projection matrix to use

    • result: Vector3

      defines the Vector3 where to store the result

    Returns void

Static Up

  • Returns a new Vector3 set to (0.0, 1.0, 0.0)

    Returns Vector3

    a new up Vector3

Static Zero

  • Returns a new Vector3 set to (0.0, 0.0, 0.0)

    Returns Vector3

    a new empty Vector3

Generated using TypeDoc