Skip to content

Latest commit

 

History

History
109 lines (102 loc) · 18 KB

decentraland-ecs.vector3.md

File metadata and controls

109 lines (102 loc) · 18 KB

Home > decentraland-ecs > Vector3

Vector3 class

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

Properties

Property Access Modifier Type Description
isNonUniform boolean Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
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)

Methods

Method Access Modifier Returns Description
constructor(x, y, z) Creates a new Vector3 object from the given x, y, z (floats) coordinates.
add(otherVector) Vector3 Gets a new Vector3, result of the addition the current Vector3 and the given vector
Add(vector1, vector2) Vector3 Returns a new Vector3 as the result of the addition of the two given vectors.
addInPlace(otherVector) Vector3 Adds the given vector to the current Vector3
addInPlaceFromFloats(x, y, z) Vector3 Adds the given coordinates to the current Vector3
addToRef(otherVector, result) Vector3 Adds the current Vector3 to the given one and stores the result in the vector "result"
asArray() number[] Creates an array containing three elements : the coordinates of the Vector3
Backward() Vector3 Returns a new Vector3 set to (0.0, 0.0, -1.0)
CatmullRom(value1, value2, value3, value4, amount) Vector3 Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
Center(value1, value2) Vector3 Returns a new Vector3 located at the center between "value1" and "value2"
Clamp(value, min, max) Vector3 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
ClampToRef(value, min, max, result) void 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
clone() Vector3 Creates a new Vector3 copied from the current Vector3
copyFrom(source) Vector3 Copies the given vector coordinates to the current Vector3 ones
copyFromFloats(x, y, z) Vector3 Copies the given floats to the current Vector3 coordinates
Cross(left, right) Vector3 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"
CrossToRef(left, right, result) void Sets the given vector "result" with the cross product of "left" and "right" The cross product is then orthogonal to both "left" and "right"
Distance(value1, value2) number Returns the distance between the vectors "value1" and "value2"
DistanceSquared(value1, value2) number Returns the squared distance between the vectors "value1" and "value2"
divide(otherVector) Vector3 Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
divideInPlace(otherVector) Vector3 Divides the current Vector3 coordinates by the given ones.
divideToRef(otherVector, result) Vector3 Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
Dot(left, right) number Returns the dot product (float) between the vectors "left" and "right"
Down() Vector3 Returns a new Vector3 set to (0.0, -1.0, 0.0)
equals(otherVector) boolean Returns true if the current Vector3 and the given vector coordinates are strictly equal
equalsToFloats(x, y, z) boolean Returns true if the current Vector3 coordinates equals the given floats
equalsWithEpsilon(otherVector, epsilon) boolean Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
floor() Vector3 Gets a new Vector3 from current Vector3 floored values
Forward() Vector3 Returns a new Vector3 set to (0.0, 0.0, 1.0)
fract() Vector3 Gets a new Vector3 from current Vector3 floored values
FromArray(array, offset) Vector3 Returns a new Vector3 set from the index "offset" of the given array
FromArrayToRef(array, offset, result) void Sets the given vector "result" with the element values from the index "offset" of the given array
FromFloatArray(array, offset) Vector3 Returns a new Vector3 set from the index "offset" of the given FloatArray This function is deprecated. Use FromArray instead
FromFloatArrayToRef(array, offset, result) void Sets the given vector "result" with the element values from the index "offset" of the given FloatArray This function is deprecated. Use FromArrayToRef instead.
FromFloatsToRef(x, y, z, result) void Sets the given vector "result" with the given floats.
GetAngleBetweenVectors(vector0, vector1, normal) number Get angle between two vectors
getClassName() string Gets the class name
GetClipFactor(vector0, vector1, axis, size) number Get the clip factor between two vectors
getHashCode() number Creates the Vector3 hash code
Hermite(value1, tangent1, value2, tangent2, amount) Vector3 Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
Left() Vector3 Returns a new Vector3 set to (-1.0, 0.0, 0.0)
length() number Gets the length of the Vector3
lengthSquared() number Gets the squared length of the Vector3
Lerp(start, end, amount) Vector3 Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
LerpToRef(start, end, amount, result) void Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
Maximize(left, right) Vector3 Gets the maximal coordinate values between two Vector3
maximizeInPlace(other) Vector3 Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
maximizeInPlaceFromFloats(x, y, z) Vector3 Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
Minimize(left, right) Vector3 Gets the minimal coordinate values between two Vector3
minimizeInPlace(other) Vector3 Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
minimizeInPlaceFromFloats(x, y, z) Vector3 Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
multiply(otherVector) Vector3 Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
multiplyByFloats(x, y, z) Vector3 Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
multiplyInPlace(otherVector) Vector3 Multiplies the current Vector3 coordinates by the given ones
multiplyToRef(otherVector, result) Vector3 Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
negate() Vector3 Gets a new Vector3 set with the current Vector3 negated coordinates
normalize() Vector3 Normalize the current Vector3. Please note that this is an in place operation.
Normalize(vector) Vector3 Returns a new Vector3 as the normalization of the given vector
normalizeFromLength(len) Vector3 Normalize the current Vector3 with the given input length. Please note that this is an in place operation.
normalizeToNew() Vector3 Normalize the current Vector3 to a new vector
normalizeToRef(reference) Vector3 Normalize the current Vector3 to the reference
NormalizeToRef(vector, result) void Sets the given vector "result" with the normalization of the given first vector
One() Vector3 Returns a new Vector3 set to (1.0, 1.0, 1.0)
Right() Vector3 Returns a new Vector3 set to (1.0, 0.0, 0.0)
rotate(q) Vector3 Rotates the current Vector3 based on the given quaternion
rotateToRef(q, target) void Rotates current Vector3 based on the given quaternion, but applies the rotation to target Vector3.
RotationFromAxis(axis1, axis2, axis3) Vector3 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
RotationFromAxisToRef(axis1, axis2, axis3, ref) void The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
scale(scale) Vector3 Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
scaleAndAddToRef(scale, result) Vector3 Scale the current Vector3 values by a factor and add the result to a given Vector3
scaleInPlace(scale) Vector3 Multiplies the Vector3 coordinates by the float "scale"
scaleToRef(scale, result) Vector3 Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
set(x, y, z) Vector3 Copies the given floats to the current Vector3 coordinates
setAll(v) Vector3 Copies the given float to the current Vector3 coordinates
subtract(otherVector) Vector3 Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
subtractFromFloats(x, y, z) Vector3 Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
subtractFromFloatsToRef(x, y, z, result) Vector3 Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
subtractInPlace(otherVector) Vector3 Subtract the given vector from the current Vector3
subtractToRef(otherVector, result) Vector3 Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
toArray(array, index) Vector3 Populates the given array or FloatArray from the given index with the successive coordinates of the Vector3
toQuaternion() Quaternion Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
TransformCoordinates(vector, transformation) Vector3 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)
TransformCoordinatesFromFloatsToRef(x, y, z, transformation, result) 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
TransformCoordinatesToRef(vector, transformation, result) void 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)
TransformNormal(vector, transformation) Vector3 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)
TransformNormalFromFloatsToRef(x, y, z, transformation, result) 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)
TransformNormalToRef(vector, transformation, result) void 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)
Up() Vector3 Returns a new Vector3 set to (0.0, 1.0, 0.0)
Zero() Vector3 Returns a new Vector3 set to (0.0, 0.0, 0.0)