vec3
Lens Studio v1.0.0+
Description
A three dimensional vector.
Constructor
new vec3(Number x, Number y, Number z)
: vec3
Creates a new instance of a vec3.
Methods
add(vec3 vec)
: vec3
Returns the vector plus vec
.
angleTo(vec3 vec)
: Number
Returns the angle in radians between the vector and vec
.
clampLength(Number length)
: vec3
Returns a copy of the vector with its length clamped to length
.
cross(vec3 vec)
: vec3
Returns the cross product of the vector and vec
distance(vec3 vec)
: Number
Returns the distance between the vector and the vector vec
.
div(vec3 vec)
: vec3
Returns the division of the vector by the vector vec
.
dot(vec3 vec)
: Number
Returns the dot product of the vector and vec
.
equal(vec3 vec)
: Boolean
Returns whether this is equal to vec
.
moveTowards(vec3 point, Number magnitude)
: vec3
Returns a copy of the vector moved towards the point point
by the amount magnitude
.
mult(vec3 vec)
: vec3
Returns the component-wise multiplication product of the vector and vec
.
normalize()
: vec3
Returns a copy of the vector with its length scaled to 1.
project(vec3 vec)
: vec3
Returns a copy of the vector projected onto the vector vec
.
projectOnPlane(vec3 normal)
: vec3
Projects the vector onto the plane represented by the normal normal
.
reflect(vec3 vec)
: vec3
Returns a copy of the vector reflected across the plane defined by the normal vec
.
rotateTowards(vec3 point, Number amount)
: vec3
Returns a copy of the vector rotated towards the point point
by amount
.
scale(vec3 vec)
: vec3
Returns the component-wise multiplication product of the vector and vec
.
sub(vec3 vec)
: vec3
Returns the vector minus vec
.
toString()
: String
Returns a string representation of the vector.
uniformScale(Number scale)
: vec3
Multiplies the components by the number scale
.
static back()
: vec3
Returns the vector (0, 0, -1).
static down()
: vec3
Returns the vector (0, -1, 0).
static forward()
: vec3
Returns the vector (0, 0, 1).
static left()
: vec3
Returns the vector (-1, 0, 0).
static lerp(vec3 vecA, vec3 vecB, Number t)
: vec3
Linearly interpolates between the two vectors vecA
and vecB
by the factor t
.
static max(vec3 vecA, vec3 vecB)
: vec3
Returns a new vector containing the largest value of each component in the two vectors.
static min(vec3 vecA, vec3 vecB)
: vec3
Returns a new vector containing the smallest value of each component in the two vectors.
static one()
: vec3
Returns the vector (1, 1, 1).
static orthonormalize(vec3 vecA, vec3 vecB)
: void
Makes the vectors vecA
and vecB
normalized and orthogonal to each other.
static right()
: vec3
Returns the vector (1, 0, 0).
static slerp(vec3 vecA, vec3 vecB, Number t)
: vec3
Spherically interpolates between the two vectors vecA
and vecB
by the factor t
.
static up()
: vec3
Returns the vector (0, 1, 0).
static zero()
: vec3
Returns the vector (0, 0, 0).
Properties
b
: Number
Alternate name for the z component.
g
: Number
Alternate name for the y component.
length
: Number
Returns the length of the vector.
lengthSquared
: Number
Returns the squared length of the vector.
r
: Number
Alternate name for the x component.
x
: Number
x component of the vec3.
y
: Number
y component of the vec3.
z
: Number
z component of the vec3.
Examples
// Check the distance between two objects
//@input SceneObject objectA
//@input SceneObject objectB
//@input float distCheck
var pointA = script.objectA.getTransform().getWorldPosition();
var pointB = script.objectB.getTransform().getWorldPosition();
var distance = pointA.distance(pointB);
if(distance > script.distCheck)
{
print("Too Far.");
}
Still Looking for help?
Visit Support