Class used to store (x,y,z) vector representation A Vector3 is the main object used in 3D geometry It can represent either the coordinates of a point the space, either a direction Reminder: js uses a left handed forward facing system Example Playground - Overview - https://playground.babylonjs.com/#R1F8YU

Hierarchy

  • Vector3

Constructors

Accessors

Methods

add addInPlace addInPlaceFromFloats addToRef applyRotationQuaternion applyRotationQuaternionInPlace applyRotationQuaternionToRef asArray clone copyFrom copyFromFloats cross divide divideInPlace divideToRef equals equalsToFloats equalsWithEpsilon floor fract fromArray getClassName getHashCode getNormalToRef isNonUniformWithinEpsilon length lengthSquared maximizeInPlace maximizeInPlaceFromFloats minimizeInPlace minimizeInPlaceFromFloats multiply multiplyByFloats multiplyInPlace multiplyToRef negate negateInPlace negateToRef normalize normalizeFromLength normalizeToNew normalizeToRef projectOnPlane projectOnPlaneToRef reorderInPlace rotateByQuaternionAroundPointToRef rotateByQuaternionToRef scale scaleAndAddToRef scaleInPlace scaleToRef set setAll subtract subtractFromFloats subtractFromFloatsToRef subtractInPlace subtractToRef toArray toQuaternion toString Backward CatmullRom Center CenterToRef CheckExtends Clamp ClampToRef Cross CrossToRef Distance DistanceSquared Dot Down Forward FromArray FromArrayToRef FromFloatArray FromFloatArrayToRef FromFloatsToRef GetAngleBetweenVectors GetAngleBetweenVectorsOnPlane GetClipFactor Hermite Hermite1stDerivative Hermite1stDerivativeToRef Left Lerp LerpToRef Maximize Minimize Normalize NormalizeToRef One PitchYawRollToMoveBetweenPoints PitchYawRollToMoveBetweenPointsToRef Project ProjectOnTriangleToRef ProjectToRef Random Reflect ReflectToRef Right RotationFromAxis RotationFromAxisToRef SlerpToRef SmoothToRef TransformCoordinates TransformCoordinatesFromFloatsToRef TransformCoordinatesToRef TransformNormal TransformNormalFromFloatsToRef TransformNormalToRef Unproject UnprojectFloatsToRef UnprojectFromTransform UnprojectToRef Up Zero

Constructors

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

    Parameters

    • Optional x: number

      defines the first coordinates (on X axis)

    • Optional y: number

      defines the second coordinates (on Y axis)

    • Optional z: number

      defines the third coordinates (on Z axis)

    Returns Vector3

Accessors

  • get hasAZeroComponent(): boolean
  • Gets a boolean indicating if the vector contains a zero in one of its components Example Playground https://playground.babylonjs.com/#R1F8YU#1

    Returns boolean

  • get isNonUniform(): boolean
  • Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same

    Returns boolean

  • get x(): number
  • Gets or sets the x coordinate

    Returns number

  • set x(value: number): void
  • Parameters

    • value: number

    Returns void

  • get y(): number
  • Gets or sets the y coordinate

    Returns number

  • set y(value: number): void
  • Parameters

    • value: number

    Returns void

  • get z(): number
  • Gets or sets the z coordinate

    Returns number

  • set z(value: number): void
  • Parameters

    • value: number

    Returns void

  • get DownReadOnly(): DeepImmutableObject<Vector3>
  • Gets a down Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

  • get LeftHandedBackwardReadOnly(): DeepImmutableObject<Vector3>
  • Gets a backward Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

  • get LeftHandedForwardReadOnly(): DeepImmutableObject<Vector3>
  • Gets a forward Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

  • get LeftReadOnly(): DeepImmutableObject<Vector3>
  • Gets a left Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

  • get OneReadOnly(): DeepImmutableObject<Vector3>
  • Gets a one Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

  • get RightHandedBackwardReadOnly(): DeepImmutableObject<Vector3>
  • Gets a backward Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

  • get RightHandedForwardReadOnly(): DeepImmutableObject<Vector3>
  • Gets a forward Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

  • get RightReadOnly(): DeepImmutableObject<Vector3>
  • Gets a right Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

  • get UpReadOnly(): DeepImmutableObject<Vector3>
  • Gets an up Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

  • get ZeroReadOnly(): DeepImmutableObject<Vector3>
  • Gets a zero Vector3 that must not be updated

    Returns DeepImmutableObject<Vector3>

Methods

  • Gets a new Vector3, result of the addition the current Vector3 and the given vector Example Playground https://playground.babylonjs.com/#R1F8YU#3

    Returns

    the resulting Vector3

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Adds the given vector to the current Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#4

    Returns

    the current updated Vector3

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Adds the given coordinates to the current Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#5

    Returns

    the current updated Vector3

    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

  • Adds the current Vector3 to the given one and stores the result in the vector "result" Example Playground https://playground.babylonjs.com/#R1F8YU#6

    Returns

    the result

    Type Parameters

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    • result: T

      defines the Vector3 object where to store the result

    Returns T

  • Rotates the vector using the given unit quaternion and returns the new vector Example Playground https://playground.babylonjs.com/#R1F8YU#7

    Returns

    a new Vector3

    Parameters

    • q: Quaternion

      the unit quaternion representing the rotation

    Returns Vector3

  • Rotates the vector in place using the given unit quaternion Example Playground https://playground.babylonjs.com/#R1F8YU#8

    Returns

    the current updated Vector3

    Parameters

    • q: Quaternion

      the unit quaternion representing the rotation

    Returns Vector3

  • Rotates the vector using the given unit quaternion and stores the new vector in result Example Playground https://playground.babylonjs.com/#R1F8YU#9

    Returns

    the result

    Type Parameters

    Parameters

    • q: Quaternion

      the unit quaternion representing the rotation

    • result: T

      the output vector

    Returns T

  • Creates an array containing three elements : the coordinates of the Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#10

    Returns

    a new array of numbers

    Returns number[]

  • Copies the given vector coordinates to the current Vector3 ones Example Playground https://playground.babylonjs.com/#R1F8YU#12

    Returns

    the current updated Vector3

    Parameters

    • source: DeepImmutableObject<Vector3>

      defines the source Vector3

    Returns Vector3

  • Copies the given floats to the current Vector3 coordinates Example Playground https://playground.babylonjs.com/#R1F8YU#13

    Returns

    the current updated Vector3

    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

  • Returns a new Vector3 as the cross product of the current vector and the "other" one The cross product is then orthogonal to both current and "other" Example Playground https://playground.babylonjs.com/#R1F8YU#14

    Returns

    the cross product

    Parameters

    • other: Vector3

      defines the right operand

    Returns Vector3

  • Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones Example Playground https://playground.babylonjs.com/#R1F8YU#16

    Returns

    the new Vector3

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result" Example Playground https://playground.babylonjs.com/#R1F8YU#18

    Returns

    the result

    Type Parameters

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    • result: T

      defines the Vector3 object where to store the result

    Returns T

  • Returns true if the current Vector3 and the given vector coordinates are strictly equal Example Playground https://playground.babylonjs.com/#R1F8YU#19

    Returns

    true if both vectors are equals

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    Returns boolean

  • Returns true if the current Vector3 coordinates equals the given floats Example Playground https://playground.babylonjs.com/#R1F8YU#20

    Returns

    true if both vectors are equal

    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

  • Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon Example Playground https://playground.babylonjs.com/#R1F8YU#21

    Returns

    true if both vectors are distant less than epsilon

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    • Optional epsilon: number

      defines the minimal distance to define values as equals

    Returns boolean

  • Update the current vector from an array Example Playground https://playground.babylonjs.com/#R1F8YU#24

    Returns

    the current Vector3

    Parameters

    • array: FloatArray

      defines the destination array

    • Optional index: number

      defines the offset in the destination array

    Returns Vector3

  • Gets the class name

    Returns

    the string "Vector3"

    Returns string

  • Creates the Vector3 hash code

    Returns

    a number which tends to be unique between Vector3 instances

    Returns number

  • Creates a vector normal (perpendicular) to the current Vector3 and stores the result in the given vector Out of the infinite possibilities the normal chosen is the one formed by rotating the current vector 90 degrees about an axis which lies perpendicular to the current vector and its projection on the xz plane. In the case of a current vector in the xz plane the normal is calculated to be along the y axis. Example Playground https://playground.babylonjs.com/#R1F8YU#230 Example Playground https://playground.babylonjs.com/#R1F8YU#231

    Parameters

    • result: DeepImmutableObject<Vector3>

      defines the Vector3 object where to store the resultant normal returns the result

    Returns Vector3

  • Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction Check if is non uniform within a certain amount of decimal places to account for this

    Returns

    if the the vector is non uniform to a certain number of decimal places

    Parameters

    • epsilon: number

      the amount the values can differ

    Returns boolean

  • Gets the length of the Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#25

    Returns

    the length of the Vector3

    Returns number

  • Gets the squared length of the Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#26

    Returns

    squared length of the Vector3

    Returns number

  • Updates the current Vector3 with the maximal coordinate values between its and the given vector ones. Example Playground https://playground.babylonjs.com/#R1F8YU#27

    Returns

    the current updated Vector3

    Parameters

    • other: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Updates the current Vector3 with the maximal coordinate values between its and the given coordinates. Example Playground https://playground.babylonjs.com/#R1F8YU#28

    Returns

    the current updated Vector3

    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

  • Updates the current Vector3 with the minimal coordinate values between its and the given vector ones Example Playground https://playground.babylonjs.com/#R1F8YU#29

    Returns

    the current updated Vector3

    Parameters

    • other: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Updates the current Vector3 with the minimal coordinate values between its and the given coordinates Example Playground https://playground.babylonjs.com/#R1F8YU#30

    Returns

    the current updated Vector3

    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

  • Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector Example Playground https://playground.babylonjs.com/#R1F8YU#31

    Returns

    the new Vector3

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Returns a new Vector3 set with the result of the multiplication of the current Vector3 coordinates by the given floats Example Playground https://playground.babylonjs.com/#R1F8YU#34

    Returns

    the new Vector3

    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

  • Multiplies the current Vector3 coordinates by the given ones Example Playground https://playground.babylonjs.com/#R1F8YU#32

    Returns

    the current updated Vector3

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Multiplies the current Vector3 by the given one and stores the result in the given vector "result" Example Playground https://playground.babylonjs.com/#R1F8YU#33

    Returns

    the result

    Type Parameters

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    • result: T

      defines the Vector3 object where to store the result

    Returns T

  • Negate the current Vector3 and stores the result in the given vector "result" coordinates Example Playground https://playground.babylonjs.com/#R1F8YU#37

    Returns

    the result

    Type Parameters

    Parameters

    • result: T

      defines the Vector3 object where to store the result

    Returns T

  • Normalize the current Vector3 with the given input length. Please note that this is an in place operation. Example Playground https://playground.babylonjs.com/#R1F8YU#123

    Returns

    the current updated Vector3

    Parameters

    • len: number

      the length of the vector

    Returns Vector3

  • Normalize the current Vector3 to the reference Example Playground https://playground.babylonjs.com/#R1F8YU#125

    Returns

    the updated Vector3

    Type Parameters

    Parameters

    • reference: T

      define the Vector3 to update

    Returns T

  • Projects the current point Vector3 to a plane along a ray starting from a specified origin and passing through the current point Vector3. Example Playground https://playground.babylonjs.com/#R1F8YU#48

    Returns

    the projected vector3

    Type Parameters

    Parameters

    • plane: Plane

      defines the plane to project to

    • origin: Vector3

      defines the origin of the projection ray

    Returns T

  • Projects the current point Vector3 to a plane along a ray starting from a specified origin and passing through the current point Vector3. Example Playground https://playground.babylonjs.com/#R1F8YU#49

    Returns

    result input

    Type Parameters

    Parameters

    • plane: Plane

      defines the plane to project to

    • origin: Vector3

      defines the origin of the projection ray

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • Reorders the x y z properties of the vector in place Example Playground https://playground.babylonjs.com/#R1F8YU#44

    Returns

    the current updated vector

    Parameters

    • order: string

      new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)

    Returns Vector3

  • Rotates a vector around a given point Example Playground https://playground.babylonjs.com/#R1F8YU#46

    Returns

    the resulting vector

    Type Parameters

    Parameters

    • quaternion: Quaternion

      the rotation quaternion

    • point: Vector3

      the point to rotate around

    • result: T

      vector to store the result

    Returns T

  • Rotates the vector around 0,0,0 by a quaternion Example Playground https://playground.babylonjs.com/#R1F8YU#47

    Returns

    the resulting vector

    Type Parameters

    Parameters

    • quaternion: Quaternion

      the rotation quaternion

    • result: T

      vector to store the result

    Returns T

  • Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale" Example Playground https://playground.babylonjs.com/#R1F8YU#53

    Returns

    a new Vector3

    Parameters

    • scale: number

      defines the multiplier factor

    Returns Vector3

  • Scale the current Vector3 values by a factor and add the result to a given Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#55

    Returns

    result input

    Type Parameters

    Parameters

    • scale: number

      defines the scale factor

    • result: T

      defines the Vector3 object where to store the result

    Returns T

  • Multiplies the Vector3 coordinates by the float "scale" Example Playground https://playground.babylonjs.com/#R1F8YU#56

    Returns

    the current updated Vector3

    Parameters

    • scale: number

      defines the multiplier factor

    Returns Vector3

  • Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates Example Playground https://playground.babylonjs.com/#R1F8YU#57

    Returns

    the result

    Type Parameters

    Parameters

    • scale: number

      defines the multiplier factor

    • result: T

      defines the Vector3 object where to store the result

    Returns T

  • Copies the given floats to the current Vector3 coordinates Example Playground https://playground.babylonjs.com/#R1F8YU#58

    Returns

    the current updated Vector3

    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

  • Copies the given float to the current Vector3 coordinates Example Playground https://playground.babylonjs.com/#R1F8YU#59

    Returns

    the current updated Vector3

    Parameters

    • v: number

      defines the x, y and z coordinates of the operand

    Returns Vector3

  • Returns a new Vector3, result of the subtraction of the given vector from the current Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#60

    Returns

    the resulting Vector3

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates Example Playground https://playground.babylonjs.com/#R1F8YU#62

    Returns

    the resulting Vector3

    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

  • Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result Example Playground https://playground.babylonjs.com/#R1F8YU#64

    Returns

    the result

    Type Parameters

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

      defines the Vector3 object where to store the result

    Returns T

  • Subtract the given vector from the current Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#61

    Returns

    the current updated Vector3

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Subtracts the given vector from the current Vector3 and stores the result in the vector "result". Example Playground https://playground.babylonjs.com/#R1F8YU#63

    Returns

    the result

    Type Parameters

    Parameters

    • otherVector: DeepImmutableObject<Vector3>

      defines the second operand

    • result: T

      defines the Vector3 object where to store the result

    Returns T

  • Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#65

    Returns

    the current Vector3

    Parameters

    • array: FloatArray

      defines the destination array

    • Optional index: number

      defines the offset in the destination array

    Returns Vector3

  • Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation) Example Playground https://playground.babylonjs.com/#R1F8YU#66

    Returns

    a new Quaternion object, computed from the Vector3 coordinates

    Returns Quaternion

  • Creates a string representation of the Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#67

    Returns

    a string with the Vector3 coordinates.

    Returns string

  • Returns a new Vector3 set to (0.0, 0.0, -1.0) Example Playground https://playground.babylonjs.com/#R1F8YU#71

    Returns

    a new Backward Vector3

    Parameters

    • Optional rightHandedSystem: boolean

      is the scene right-handed (negative-z)

    Returns Vector3

  • Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4" Example Playground https://playground.babylonjs.com/#R1F8YU#69

    Returns

    the new Vector3

    Type Parameters

    Parameters

    • value1: DeepImmutable<T>

      defines the first control point

    • value2: DeepImmutableObject<Vector3>

      defines the second control point

    • value3: DeepImmutableObject<Vector3>

      defines the third control point

    • value4: DeepImmutableObject<Vector3>

      defines the fourth control point

    • amount: number

      defines the amount on the spline to use

    Returns T

  • Returns a new Vector3 located at the center between "value1" and "value2" Example Playground https://playground.babylonjs.com/#R1F8YU#72

    Returns

    the new Vector3

    Parameters

    • value1: DeepImmutableObject<Vector3>

      defines the first operand

    • value2: DeepImmutableObject<Vector3>

      defines the second operand

    Returns Vector3

  • Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref" Example Playground https://playground.babylonjs.com/#R1F8YU#73

    Returns

    ref

    Type Parameters

    Parameters

    • value1: DeepImmutableObject<Vector3>

      defines first vector

    • value2: DeepImmutableObject<Vector3>

      defines second vector

    • ref: T

      defines third vector

    Returns T

  • 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 Example Playground https://playground.babylonjs.com/#R1F8YU#76

    Returns

    the new Vector3

    Type Parameters

    Parameters

    • value: DeepImmutable<T>

      defines the current value

    • min: DeepImmutableObject<Vector3>

      defines the lower range value

    • max: DeepImmutableObject<Vector3>

      defines the upper range value

    Returns T

  • 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 Example Playground https://playground.babylonjs.com/#R1F8YU#77

    Returns

    result input

    Type Parameters

    Parameters

    • value: DeepImmutableObject<Vector3>

      defines the current value

    • min: DeepImmutableObject<Vector3>

      defines the lower range value

    • max: DeepImmutableObject<Vector3>

      defines the upper range value

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • 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" Example Playground https://playground.babylonjs.com/#R1F8YU#15

    Returns

    the cross product

    Type Parameters

    Parameters

    • left: DeepImmutable<T>

      defines the left operand

    • right: DeepImmutableObject<Vector3>

      defines the right operand

    Returns T

  • Sets the given vector "result" with the cross product of "left" and "right" The cross product is then orthogonal to both "left" and "right" Example Playground https://playground.babylonjs.com/#R1F8YU#78

    Returns

    result input

    Type Parameters

    Parameters

    • left: DeepImmutableObject<Vector3>

      defines the left operand

    • right: DeepImmutableObject<Vector3>

      defines the right operand

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • Returns the distance between the vectors "value1" and "value2" Example Playground https://playground.babylonjs.com/#R1F8YU#81

    Returns

    the distance

    Parameters

    • value1: DeepImmutableObject<Vector3>

      defines the first operand

    • value2: DeepImmutableObject<Vector3>

      defines the second operand

    Returns number

  • Returns the squared distance between the vectors "value1" and "value2" Example Playground https://playground.babylonjs.com/#R1F8YU#80

    Returns

    the squared distance

    Parameters

    • value1: DeepImmutableObject<Vector3>

      defines the first operand

    • value2: DeepImmutableObject<Vector3>

      defines the second operand

    Returns number

  • Returns the dot product (float) between the vectors "left" and "right" Example Playground https://playground.babylonjs.com/#R1F8YU#82

    Returns

    the dot product

    Parameters

    • left: DeepImmutableObject<Vector3>

      defines the left operand

    • right: DeepImmutableObject<Vector3>

      defines the right operand

    Returns number

  • Returns a new Vector3 set to (0.0, 0.0, 1.0) Example Playground https://playground.babylonjs.com/#R1F8YU#71

    Returns

    a new forward Vector3

    Parameters

    • Optional rightHandedSystem: boolean

      is the scene right-handed (negative z)

    Returns Vector3

  • Returns a new Vector3 set from the index "offset" of the given array Example Playground https://playground.babylonjs.com/#R1F8YU#83

    Returns

    the new Vector3

    Parameters

    • array: DeepImmutableObject<ArrayLike<number>>

      defines the source array

    • Optional offset: number

      defines the offset in the source array

    Returns Vector3

  • Sets the given vector "result" with the element values from the index "offset" of the given array Example Playground https://playground.babylonjs.com/#R1F8YU#84

    Returns

    result input

    Type Parameters

    Parameters

    • array: DeepImmutableObject<ArrayLike<number>>

      defines the source array

    • offset: number

      defines the offset in the source array

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • Returns a new Vector3 set from the index "offset" of the given Float32Array

    Returns

    the new Vector3

    Deprecated

    Please use FromArray instead.

    Parameters

    • array: DeepImmutableObject<Float32Array>

      defines the source array

    • Optional offset: number

      defines the offset in the source array

    Returns Vector3

  • Sets the given vector "result" with the element values from the index "offset" of the given Float32Array

    Deprecated

    Please use FromArrayToRef instead.

    Type Parameters

    Parameters

    • array: DeepImmutableObject<Float32Array>

      defines the source array

    • offset: number

      defines the offset in the source array

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • Sets the given vector "result" with the given floats. Example Playground https://playground.babylonjs.com/#R1F8YU#85

    Type Parameters

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

      defines the Vector3 where to store the result

    Returns T

  • Get angle between two vectors Example Playground https://playground.babylonjs.com/#R1F8YU#86

    Returns

    the angle between vector0 and vector1

    Parameters

    • vector0: DeepImmutableObject<Vector3>

      the starting point

    • vector1: DeepImmutableObject<Vector3>

      the ending point

    • normal: DeepImmutableObject<Vector3>

      direction of the normal

    Returns number

  • Get angle between two vectors projected on a plane Example Playground https://playground.babylonjs.com/#R1F8YU#87 Expectation compute time: 0.01 ms (median) and 0.02 ms (percentile 95%)

    Returns

    the angle in radians (float) between vector0 and vector1 projected on the plane with the specified normal

    Parameters

    • vector0: Vector3

      angle between vector0 and vector1

    • vector1: Vector3

      angle between vector0 and vector1

    • normal: Vector3

      Normal of the projection plane

    Returns number

  • Get the clip factor between two vectors Example Playground https://playground.babylonjs.com/#R1F8YU#126

    Returns

    the clip factor

    Parameters

    • vector0: DeepImmutableObject<Vector3>

      defines the first operand

    • vector1: DeepImmutableObject<Vector3>

      defines the second operand

    • axis: DeepImmutableObject<Vector3>

      defines the axis to use

    • size: number

      defines the size along the axis

    Returns number

  • Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2" Example Playground https://playground.babylonjs.com/#R1F8YU#89

    Returns

    the new Vector3

    Type Parameters

    Parameters

    • value1: DeepImmutable<T>

      defines the first control point

    • tangent1: DeepImmutableObject<Vector3>

      defines the first tangent vector

    • value2: DeepImmutableObject<Vector3>

      defines the second control point

    • tangent2: DeepImmutableObject<Vector3>

      defines the second tangent vector

    • amount: number

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

    Returns T

  • Returns a new Vector3 which is the 1st derivative of the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2". Example Playground https://playground.babylonjs.com/#R1F8YU#90

    Returns

    1st derivative

    Type Parameters

    Parameters

    • value1: DeepImmutable<T>

      defines the first control point

    • tangent1: DeepImmutableObject<Vector3>

      defines the first tangent

    • value2: DeepImmutableObject<Vector3>

      defines the second control point

    • tangent2: DeepImmutableObject<Vector3>

      defines the second tangent

    • time: number

      define where the derivative must be done

    Returns T

  • Update a Vector3 with the 1st derivative of the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2". Example Playground https://playground.babylonjs.com/#R1F8YU#91

    Returns

    result input

    Type Parameters

    Parameters

    • value1: DeepImmutableObject<Vector3>

      defines the first control point

    • tangent1: DeepImmutableObject<Vector3>

      defines the first tangent

    • value2: DeepImmutableObject<Vector3>

      defines the second control point

    • tangent2: DeepImmutableObject<Vector3>

      defines the second tangent

    • time: number

      define where the derivative must be done

    • result: T

      define where to store the derivative

    Returns T

  • Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end" Example Playground https://playground.babylonjs.com/#R1F8YU#95

    Returns

    the new Vector3

    Type Parameters

    Parameters

    • start: DeepImmutable<T>

      defines the start value

    • end: DeepImmutableObject<Vector3>

      defines the end value

    • amount: number

      max defines amount between both (between 0 and 1)

    Returns T

  • Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end" Example Playground https://playground.babylonjs.com/#R1F8YU#93

    Returns

    result input

    Type Parameters

    Parameters

    • start: DeepImmutableObject<Vector3>

      defines the start value

    • end: DeepImmutableObject<Vector3>

      defines the end value

    • amount: number

      max defines amount between both (between 0 and 1)

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • Gets the maximal coordinate values between two Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#96

    Returns

    the new Vector3

    Type Parameters

    Parameters

    • left: DeepImmutable<T>

      defines the first operand

    • right: DeepImmutableObject<Vector3>

      defines the second operand

    Returns T

  • Gets the minimal coordinate values between two Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#97

    Returns

    the new Vector3

    Type Parameters

    Parameters

    • left: DeepImmutable<T>

      defines the first operand

    • right: DeepImmutableObject<Vector3>

      defines the second operand

    Returns T

  • Returns a new Vector3 as the normalization of the given vector Example Playground https://playground.babylonjs.com/#R1F8YU#98

    Returns

    the new Vector3

    Parameters

    • vector: DeepImmutableObject<Vector3>

      defines the Vector3 to normalize

    Returns Vector3

  • Sets the given vector "result" with the normalization of the given first vector Example Playground https://playground.babylonjs.com/#R1F8YU#98

    Returns

    result input

    Type Parameters

    Parameters

    • vector: DeepImmutableObject<Vector3>

      defines the Vector3 to normalize

    • result: T

      defines the Vector3 where to store the result

    Returns T

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

    Returns

    a new Vector3

    Returns Vector3

  • Gets the rotation that aligns the roll axis (Y) to the line joining the start point to the target point Example PG https://playground.babylonjs.com/#R1F8YU#188

    Returns

    the rotation in the form (pitch, yaw, 0)

    Parameters

    Returns Vector3

  • Gets the rotation that aligns the roll axis (Y) to the line joining the start point to the target point and stores it in the ref Vector3 Example PG https://playground.babylonjs.com/#R1F8YU#189

    Returns

    ref in the form (pitch, yaw, 0)

    Type Parameters

    Parameters

    • start: Vector3

      the starting point

    • target: Vector3

      the target point

    • ref: T

      the vector3 to store the result

    Returns T

  • Project a Vector3 onto screen space Example Playground https://playground.babylonjs.com/#R1F8YU#101

    Returns

    the new Vector3

    Type Parameters

    Parameters

    • vector: DeepImmutable<T>

      defines the Vector3 to project

    • world: DeepImmutableObject<Matrix>

      defines the world matrix to use

    • transform: DeepImmutableObject<Matrix>

      defines the transform (view x projection) matrix to use

    • viewport: DeepImmutableObject<Viewport>

      defines the screen viewport to use

    Returns T

  • Project a Vector3 onto screen space to reference Example Playground https://playground.babylonjs.com/#R1F8YU#102

    Returns

    result input

    Type Parameters

    Parameters

    • vector: DeepImmutableObject<Vector3>

      defines the Vector3 to project

    • world: DeepImmutableObject<Matrix>

      defines the world matrix to use

    • transform: DeepImmutableObject<Matrix>

      defines the transform (view x projection) matrix to use

    • viewport: DeepImmutableObject<Viewport>

      defines the screen viewport to use

    • result: T

      the vector in which the screen space will be stored

    Returns T

  • Returns a new Vector3 with random values between min and max

    Returns

    a Vector3 with random values between min and max

    Parameters

    • Optional min: number

      the minimum random value

    • Optional max: number

      the maximum random value

    Returns Vector3

  • Reflects a vector off the plane defined by a normalized normal

    Returns

    the resulting vector

    Type Parameters

    Parameters

    • inDirection: DeepImmutableObject<Vector3>

      defines the vector direction

    • normal: DeepImmutableObject<Vector3>

      defines the normal - Must be normalized

    Returns Vector3

  • Reflects a vector off the plane defined by a normalized normal to reference

    Returns

    the resulting vector

    Type Parameters

    Parameters

    • inDirection: DeepImmutableObject<Vector3>

      defines the vector direction

    • normal: DeepImmutableObject<Vector3>

      defines the normal - Must be normalized

    • ref: T

    Returns T

  • 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 Example Playground https://playground.babylonjs.com/#R1F8YU#106

    Returns

    a new Vector3

    See

    https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/center_origin/target_align

    Type Parameters

    Parameters

    • axis1: DeepImmutable<T>

      defines the first axis

    • axis2: DeepImmutableObject<Vector3>

      defines the second axis

    • axis3: DeepImmutableObject<Vector3>

      defines the third axis

    Returns T

  • The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3 Example Playground https://playground.babylonjs.com/#R1F8YU#107

    Returns

    result input

    Type Parameters

    Parameters

    • axis1: DeepImmutableObject<Vector3>

      defines the first axis

    • axis2: DeepImmutableObject<Vector3>

      defines the second axis

    • axis3: DeepImmutableObject<Vector3>

      defines the third axis

    • ref: T

      defines the Vector3 where to store the result

    Returns T

  • Smooth interpolation between two vectors using Slerp Example Playground https://playground.babylonjs.com/#R1F8YU#110

    Type Parameters

    Parameters

    • source: Vector3

      source vector

    • goal: Vector3

      goal vector

    • deltaTime: number

      current interpolation frame

    • lerpTime: number

      total interpolation time

    • result: T

      the smoothed vector

    Returns T

  • Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector. This method computes transformed coordinates only, not transformed direction vectors (ie. it takes translation in account) Example Playground https://playground.babylonjs.com/#R1F8YU#111

    Returns

    the transformed Vector3

    Type Parameters

    Parameters

    • vector: DeepImmutableObject<Vector3>

      defines the Vector3 to transform

    • transformation: DeepImmutableObject<Matrix>

      defines the transformation matrix

    Returns Vector3

  • 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 transformed coordinates only, not transformed direction vectors Example Playground https://playground.babylonjs.com/#R1F8YU#115

    Returns

    result input

    Type Parameters

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

      defines the transformation matrix

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector This method computes transformed coordinates only, not transformed direction vectors (ie. it takes translation in account) Example Playground https://playground.babylonjs.com/#R1F8YU#113

    Returns

    result input

    Type Parameters

    Parameters

    • vector: DeepImmutableObject<Vector3>

      defines the Vector3 to transform

    • transformation: DeepImmutableObject<Matrix>

      defines the transformation matrix

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • 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) Example Playground https://playground.babylonjs.com/#R1F8YU#112

    Returns

    the new Vector3

    Parameters

    • vector: DeepImmutableObject<Vector3>

      defines the Vector3 to transform

    • transformation: DeepImmutableObject<Matrix>

      defines the transformation matrix

    Returns Vector3

  • 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) Example Playground https://playground.babylonjs.com/#R1F8YU#116

    Returns

    result input

    Type Parameters

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

      defines the transformation matrix

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • 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) Example Playground https://playground.babylonjs.com/#R1F8YU#114

    Returns

    result input

    Type Parameters

    Parameters

    • vector: DeepImmutableObject<Vector3>

      defines the Vector3 to transform

    • transformation: DeepImmutableObject<Matrix>

      defines the transformation matrix

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • Unproject from screen space to object space Example Playground https://playground.babylonjs.com/#R1F8YU#117

    Returns

    the new Vector3

    Type Parameters

    Parameters

    • source: DeepImmutable<T>

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

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

    • view: DeepImmutableObject<Matrix>

      defines the view matrix to use

    • projection: DeepImmutableObject<Matrix>

      defines the projection matrix to use

    Returns T

  • Unproject from screen space to object space Example Playground https://playground.babylonjs.com/#R1F8YU#120

    Returns

    result input

    Type Parameters

    Parameters

    • sourceX: number

      defines the screen space x coordinate to use

    • sourceY: number

      defines the screen space y coordinate to use

    • sourceZ: number

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

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

    • view: DeepImmutableObject<Matrix>

      defines the view matrix to use

    • projection: DeepImmutableObject<Matrix>

      defines the projection matrix to use

    • result: T

      defines the Vector3 where to store the result

    Returns T

  • Unproject from screen space to object space Example Playground https://playground.babylonjs.com/#R1F8YU#121

    Returns

    the new Vector3

    Type Parameters

    Parameters

    • source: DeepImmutable<T>

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

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

    • transform: DeepImmutableObject<Matrix>

      defines the transform (view x projection) matrix to use

    Returns T

  • Unproject from screen space to object space Example Playground https://playground.babylonjs.com/#R1F8YU#119

    Returns

    result input

    Type Parameters

    Parameters

    • source: DeepImmutableObject<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: DeepImmutableObject<Matrix>

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

    • view: DeepImmutableObject<Matrix>

      defines the view matrix to use

    • projection: DeepImmutableObject<Matrix>

      defines the projection matrix to use

    • result: T

      defines the Vector3 where to store the result

    Returns T

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

    Returns

    a new empty Vector3

    Returns Vector3

Generated using TypeDoc