Vector3¶
Reference¶
- class Vector3¶
- module:
- x: number¶
- y: number¶
- z: number¶
- static fromData(data)¶
Create a vector object from data
- Parameters:
data (
table
) – the data table- Returns:
the new Transform object
- Return type:
- static new(x, y, z)¶
Create new vector
- Parameters:
x (
number
) – x componenty (
number
) – y componentz (
number
) – z component
- Returns:
the new vector
- Return type:
- set(x, y, z)¶
Set values of vector
- Parameters:
x (
number
) – x componenty (
number
) – y componentz (
number
) – z component
- get()¶
Get values of vector
- Returns:
the values
- Return type:
array
- toData()¶
Get values of vector
- Returns:
the values
- Return type:
table
- static distance(va, vb)¶
Calculate distance between 2 vectors
- static dot(lhs, rhs)¶
Calculate dot product of 2 vectors
- static lerp(from, to, t)¶
Linear iterpolation between 2 vectors
- magnitude()¶
Calculate magnitude of the vector
- Returns:
magnitue value
- Return type:
number
- static max(lhs, rhs)¶
Return the maximum values from both vectors for each component
- static min(lhs, rhs)¶
Return the minimum values from both vectors for each component
- normalized()¶
Return the normalized version of the vector
- Returns:
normalized vector
- Return type:
- sqrMagnitude()¶
Return the squared magnitude of the vector
- Returns:
squared magnitude
- Return type:
number
- static angle(from, to)¶
Calculate ange between vectors
- clampMagnitude(maxLength)¶
Checks the magnitude of the vector and if longer than maxLength, will clamp the vector
- Parameters:
maxLength (
number
) – maximum length of vector- Returns:
returns itself
- Return type:
- static orthoNormalize(va, vb, vc)¶
Orthonormalize 3 vectors
- static scaled(a, b)¶
Scales vector by another vector
- scale(b)¶
Scales vector by another vector
- static cross(lhs, rhs)¶
Calculates cross product
- equals(other)¶
Checks if other vector is equal this one
- Parameters:
other (
Vector3
) – the other vector- Returns:
comparison result
- Return type:
boolean
- static reflect(inDirection, inNormal)¶
Reflects the inDirection vector at the plane defined by inNormal
- static project(vector, onNormal)¶
Project vector onto a normal vector
- static projectOnPlane(vector, planeNormal)¶
Project vector onto plane
- static slerp(from, to, t)¶
Perform spherical linear interpolation on vector
- mul(q)¶
Multiply vector with a scalar or quaternion
- Parameters:
q (
number
) – scalar or quaternion- Returns:
returns itself
- Return type:
- div(d)¶
Divide vector by a scalar
- Parameters:
d (
number
) – scalar- Returns:
returns itself
- Return type:
- add(vb)¶
Adds a vector to this vector
- sub(vb)¶
Subtracts another vector from this vector
- mulQuat(quat)¶
Multiply quaternion with this vector
- Parameters:
quat (
Quaternion
) – input quaternion- Returns:
returns itself
- Return type:
- static createFrustumRays(viewDirection, fov, resX, resY)¶
Creates an array of Vector3 objects which are the direction vectors of the frustum as defined by the parameters
- Parameters:
viewDirection (
Vector3
) – a view vectorfov (
number
) – Field of view value in degreesresX (
number
) – resolution width. Needs to be at least 2resY (
number
) – resolution height Needs to be at least 2
- Returns:
Array of Vector3 objects which have the count width * height
- Return type:
Array