# columnArray()
(getter) Returns the basic array representation of this matrix. this returns the array in column-major form.
# Symbol.iterator()
Adds iteration to the object, allowing it to be destructured and iterated upon in various useful ways.
# columnArray()
(getter) Returns the basic array representation of this matrix. this returns the array in column-major form.
# fromMat4(a)
Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
Parameters
Name | Types | Description |
---|---|---|
a | mat4 |
Mat4 to derive the normal matrix from |
# fromProjection(width, height)
Generates a 2D projection matrix with the given bounds
Parameters
Name | Types | Description |
---|---|---|
width | number |
Width of your gl context |
height | number |
Height of gl context |
# Symbol.iterator()
Adds iteration to the object, allowing it to be destructured and iterated upon in various useful ways.
# fromQuat(q)
Calculates a 4x4 matrix from the given quaternion
Parameters
Name | Types | Description |
---|---|---|
q | quat |
Quaternion to create matrix from |
# fromRotationTranslationScale(q, v, s)
Creates a matrix from a quaternion rotation, vector translation and vector scale This is equivalent to (but much faster than): mat4.identity(dest); mat4.translate(dest, vec); let quatMat = mat4.create(); quat4.toMat4(quat, quatMat); mat4.multiply(dest, quatMat); mat4.scale(dest, scale)
Parameters
Name | Types | Description |
---|---|---|
q | quat4 |
Rotation quaternion |
v | vec3 |
Translation vector |
s | vec3 |
Scaling vector |
# fromRotationTranslationScaleOrigin(q, v, s, o)
Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin This is equivalent to (but much faster than): mat4.identity(dest); mat4.translate(dest, vec); mat4.translate(dest, origin); let quatMat = mat4.create(); quat4.toMat4(quat, quatMat); mat4.multiply(dest, quatMat); mat4.scale(dest, scale) mat4.translate(dest, negativeOrigin);
Parameters
Name | Types | Description |
---|---|---|
q | quat4 |
Rotation quaternion |
v | vec3 |
Translation vector |
s | vec3 |
Scaling vector |
o | vec3 |
The origin vector around which to scale and rotate |
# frustum(left, right, bottom, top, near, far)
Generates a frustum matrix with the given bounds
Parameters
Name | Types | Description |
---|---|---|
left | Number |
Left bound of the frustum |
right | Number |
Right bound of the frustum |
bottom | Number |
Bottom bound of the frustum |
top | Number |
Top bound of the frustum |
near | Number |
Near bound of the frustum |
far | Number |
Far bound of the frustum |
# lookAt(out, eye, center, up)
Generates a look-at matrix with the given eye position, focal point, and up axis. If you want a matrix that actually makes an object look at another object, you should use targetTo instead.
Parameters
Name | Types | Description |
---|---|---|
out | mat4 |
mat4 frustum matrix will be written into |
eye | vec3 |
Position of the viewer |
center | vec3 |
Point the viewer is looking at |
up | vec3 |
vec3 pointing up |
# ortho(left, right, bottom, top, near, far)
Generates a orthogonal projection matrix with the given bounds
Parameters
Name | Types | Description |
---|---|---|
left | number |
Left bound of the frustum |
right | number |
Right bound of the frustum |
bottom | number |
Bottom bound of the frustum |
top | number |
Top bound of the frustum |
near | number |
Near bound of the frustum |
far | number |
Far bound of the frustum |
# perspective(fovy, aspect, near, far)
Generates a perspective projection matrix with the given bounds. Passing null/undefined/no value for far will generate infinite projection matrix.
Parameters
Name | Types | Description |
---|---|---|
fovy | number |
Vertical field of view in radians |
aspect | number |
Aspect ratio. typically viewport width/height |
near | number |
Near bound of the frustum |
far | number |
Far bound of the frustum, can be null or Infinity |
# rotate(r, axis)
Rotates a mat4 by the given angle around the given axis
Parameters
Name | Types | Description |
---|---|---|
r | Number |
the angle to rotate the matrix by |
axis | vec3 |
the axis to rotate around |
# Symbol.iterator()
Adds iteration to the object, allowing it to be destructured and iterated upon in various useful ways.
# targetTo(eye, center, up)
Generates a matrix that makes something look at something else.
Parameters
Name | Types | Description |
---|---|---|
eye | vec3 |
Position of the viewer |
center | vec3 |
Point the viewer is looking at |
up | vec3 |
vec3 pointing up |
# transform(v)
Transforms the mat4 by a given amount
Parameters
Name | Types | Description |
---|---|---|
v | Vec3 |
The amount to add to the matrixes transformation properties |
# transformTo(v)
Transforms the mat4 to a given position
Parameters
Name | Types | Description |
---|---|---|
v | Vec3 |
The amount to add to the matrixes transformation properties |
# translate(v)
Translates the mat4 to a given position
Parameters
Name | Types | Description |
---|---|---|
v | Vec3 |
The amount to add to the matrixes translation properties |
# ...args(x, y)
The Vector Class constructor
Parameters
Name | Types | Description |
---|---|---|
x | number |
The x coord |
y | number |
The y coord |
# ...args(x, y)
Resets the vector coordinates
Parameters
Name | Types | Description |
---|---|---|
x | number |
Array |
y | number |
The y coord |
# add(vector)
Adds one vector to another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to add to this one |
Returns
Vec2
Returns itself, modified
# addNew(vector)
Clones the vector and adds the vector to it instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to add to this one |
Returns
Vec2
Returns the clone of itself, modified
# addScalar(scalar)
Adds a scalar to the vector, modifying both the x and y
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to add to the vector |
Returns
Vec2
Returns itself, modified
# addScalarNew(scalar)
Clones the vector and adds the scalar to it instead
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to add to the vector |
Returns
Vec2
Returns the clone of itself, modified
# cross(vector)
Calculates the cross product between this and the supplied vector.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector object against which to calculate the cross product |
Returns
number
The cross product of the two vectors
# distance(vector)
Calculates the distance between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to calculate the distance from |
Returns
number
The distance between this and the supplied vector
# distanceX(vector)
Calculates the distance on the X axis between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to calculate the distance from |
Returns
number
The distance, along the x axis, between this and the supplied vector
# distanceY(vector)
Calculated the distance on the Y axis between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to calculate the distance from |
Returns
number
The distance, along the y axis, between this and the supplied vector
# divide(vector)
Divides one vector by another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to divide this by |
Returns
Vec2
Returns itself, modified
# divideNew(vector)
Clones the vector and divides it by the vector instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to divide the clone by |
Returns
Vec2
Returns the clone of itself, modified
# divideScalar(scalar)
Divides the vector by a scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to divide both x and y by |
Returns
Vec2
Returns itself, modified
# divideScalarNew(scalar)
Clones the vector and divides it by the provided scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to divide both x and y by |
Returns
Vec2
Returns the clone of itself, modified
# dot(vector)
Calculates the dot product between this and a supplied vectorT
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector object against which to calculate the dot product |
Returns
number
The dot product of the two vectors
# getAngle(a, b)
Finds the angle between 2 vectors.
Parameters
Name | Types | Description |
---|---|---|
a | vec2 |
the first operand |
b | vec2 |
the second operand |
# interpolate(v)
Iterpolates a provided anonymous value into a vew Vec2
Parameters
Name | Types | Description |
---|---|---|
v | Vec2 |
array |
# lengthSquared()
(getter/setter) The length of the vector presented as a square. If you're using length for comparison, this is quicker.
# lerp(v1, v2, d)
Performs a linear interpolation between two vec2's
Parameters
Name | Types | Description |
---|---|---|
v1 | vec2 |
the first operand |
v2 | vec2 |
the second operand |
d | Number |
interpolation amount in the range of 0 - 1 |
# multiply(vector)
Multiplies one vector by another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to multiply this by |
Returns
Vec2
Returns itself, modified
# multiplyNew(vector)
Clones the vector and multiplies it by the vector instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to multiply the clone by |
Returns
Vec2
Returns the clone of itself, modified
# multiplyScalar(scalar)
Multiplies the vector by a scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to multiply both x and y by |
Returns
Vec2
Returns itself, modified
# multiplyScalarNew(scalar)
Clones the vector and multiplies it by the provided scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to multiply both x and y by |
Returns
Vec2
Returns the clone of itself, modified
# normalise()
Normalises the vector down to a length of 1 unit
Returns
Vec2
Returns itself, modified
# normaliseNew()
Clones the vector and normalises it
Returns
Vec2
Returns a clone of itself, modified
# resetToVector(v)
Resets the vector coordinates to another vector object
Parameters
Name | Types | Description |
---|---|---|
v | Vector |
The vector object to use to reset the coordinates |
# rotate(radian)
Rotates a vecor by a given amount, provided in radians.
Parameters
Name | Types | Description |
---|---|---|
radian | number |
The angle, in radians, to rotate the vector by |
Returns
Vec2
Returns itself, modified
# rotateDeg(degrees)
Rotates a vecor by a given amount, provided in degrees. Converts the degree value to radians and runs the rotaet method.
Parameters
Name | Types | Description |
---|---|---|
degrees | number |
The angle, in degrees, to rotate the vector by |
Returns
Vec2
Returns itself, modified
# rotateDegNew(degrees)
Clones the vector and rotates it by the supplied degree value
Parameters
Name | Types | Description |
---|---|---|
degrees | number |
The angle, in degrees, to rotate the vector by |
Returns
Vec2
Returns the clone of itself, modified
# rotateNew(radian)
Clones the vector and rotates it by the supplied radian value
Parameters
Name | Types | Description |
---|---|---|
radian | number |
The angle, in radians, to rotate the vector by |
Returns
Vec2
Returns the clone of itself, modified
# rotateTo(radian)
Rotates a vector to a specific angle
Parameters
Name | Types | Description |
---|---|---|
radian | number |
The angle, in radians, to rotate the vector to |
Returns
Vec2
Returns itself, modified
# rotateToDeg(degrees)
Rotates a vecor to a given amount, provided in degrees. Converts the degree value to radians and runs the rotateTo method.
Parameters
Name | Types | Description |
---|---|---|
degrees | number |
The angle, in degrees, to rotate the vector to |
Returns
Vec2
Returns itself, modified
# rotateToDegNew(degrees)
Clones the vector and rotates it to the supplied degree value
Parameters
Name | Types | Description |
---|---|---|
degrees | number |
The angle, in degrees, to rotate the vector to |
Returns
Vec2
Returns the clone of itself, modified
# rotateToNew(radian)
Clones the vector and rotates it to the supplied radian value
Parameters
Name | Types | Description |
---|---|---|
radian | number |
The angle, in radians, to rotate the vector to |
Returns
Vec2
Returns the clone of itself, modified
# subtract(vector)
Subtracts one vector from another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to subtract from this one |
Returns
Vec2
Returns itself, modified
# subtractNew(vector)
Clones the vector and subtracts the vector from it instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec2 |
The vector to subtract from this one |
Returns
Vec2
Returns the clone of itself, modified
# subtractScalar(scalar)
Subtracts a scalar from the vector, modifying both the x and y
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to subtract from the vector |
Returns
Vec2
Returns itself, modified
# subtractScalarNew(scalar)
Clones the vector and subtracts the scalar from it instead
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to add to the vector |
Returns
Vec2
Returns the clone of itself, modified
# Symbol.iterator()
Adds iteration to the object, allowing it to be destructured and iterated upon in various useful ways.
# Vec2()
A basic 2D Vector class that provides simple algebraic functionality in the form of 2D Vectors. We use Getters/setters for both principle properties (x & y) as well as virtual properties (rotation, length etc.).
# ...args(x, y, z)
The Vector Class constructor
Parameters
Name | Types | Description |
---|---|---|
x | number |
The x coord |
y | number |
The y coord |
z | number |
The z coord |
# ...args(x, y, z)
Resets the vector coordinates
Parameters
Name | Types | Description |
---|---|---|
x | number |
The x coord |
y | number |
The y coord |
z | number |
The z coord |
# add(vector)
Adds one vector to another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to add to this one |
Returns
Vec3
Returns itself, modified
# addNew(vector)
Clones the vector and adds the vector to it instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to add to this one |
Returns
Vec3
Returns the clone of itself, modified
# addScalar(scalar)
Adds a scalar to the vector, modifying both the x and y
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to add to the vector |
Returns
Vec3
Returns itself, modified
# addScalarNew(scalar)
Clones the vector and adds the scalar to it instead
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to add to the vector |
Returns
Vec3
Returns the clone of itself, modified
# cross(vector)
Calculates the cross product between this and the supplied vector.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector object against which to calculate the cross product |
Returns
Vec3
The cross product of the two vectors
# distance(vector)
Calculates the distance between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to calculate the distance from |
Returns
number
The distance between this and the supplied vector
# distanceX(vector)
Calculates the distance on the X axis between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to calculate the distance from |
Returns
number
The distance, along the x axis, between this and the supplied vector
# distanceY(vector)
Calculated the distance on the Y axis between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to calculate the distance from |
Returns
number
The distance, along the y axis, between this and the supplied vector
# distanceZ(vector)
Calculated the distance on the Z axis between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to calculate the distance from |
Returns
number
The distance, along the y axis, between this and the supplied vector
# divide(vector)
Divides one vector by another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to divide this by |
Returns
Vec3
Returns itself, modified
# divideNew(vector)
Clones the vector and divides it by the vector instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to divide the clone by |
Returns
Vec3
Returns the clone of itself, modified
# divideScalar(scalar)
Divides the vector by a scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to divide both x and y by |
Returns
Vec3
Returns itself, modified
# divideScalarNew(scalar)
Clones the vector and divides it by the provided scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to divide both x and y by |
Returns
Vec3
Returns the clone of itself, modified
# dot(vector)
Calculates the dot product between this and a supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector object against which to calculate the dot product |
Returns
number
The dot product of the two vectors
# interpolate(v)
Iterpolates a provided anonymous value into a vew Vec3
Parameters
Name | Types | Description |
---|---|---|
v | Vec3 |
array |
# lengthSquared()
(getter/setter) The length of the vector presented as a square. If you're using length for comparison, this is quicker.
# lerp(v1, v2, d)
Performs a linear interpolation between two Vec3's
Parameters
Name | Types | Description |
---|---|---|
v1 | Vec3 |
the first operand |
v2 | Vec3 |
the second operand |
d | Number |
interpolation amount in the range of 0 - 1 |
# multiply(vector)
Multiplies one vector by another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to multiply this by |
Returns
Vec3
Returns itself, modified
# multiplyNew(vector)
Clones the vector and multiplies it by the vector instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to multiply the clone by |
Returns
Vec3
Returns the clone of itself, modified
# multiplyScalar(scalar)
Multiplies the vector by a scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to multiply both x and y by |
Returns
Vec3
Returns itself, modified
# multiplyScalarNew(scalar)
Clones the vector and multiplies it by the provided scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to multiply both x and y by |
Returns
Vec3
Returns the clone of itself, modified
# normalise()
Normalises the vector down to a length of 1 unit
Returns
Vec3
Returns itself, modified
# normaliseNew()
Clones the vector and normalises it
Returns
Vec3
Returns a clone of itself, modified
# phi()
(getter/setter) Spherical phi. For using a vec3 as spherical coordinates. Alias of {@link Vector#y y}
# radius()
(getter/setter) Spherical radius. For using a vec3 as spherical coordinates. Alias of {@link Vector#x x}
# resetToVector(v)
Resets the vector coordinates to another vector object
Parameters
Name | Types | Description |
---|---|---|
v | Vec3 |
The vector object to use to reset the coordinates |
# subtract(vector)
Subtracts one vector from another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to subtract from this one |
Returns
Vec3
Returns itself, modified
# subtractNew(vector)
Clones the vector and subtracts the vector from it instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec3 |
The vector to subtract from this one |
Returns
Vec3
Returns the clone of itself, modified
# subtractScalar(scalar)
Subtracts a scalar from the vector, modifying both the x and y
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to subtract from the vector |
Returns
Vec3
Returns itself, modified
# subtractScalarNew(scalar)
Clones the vector and subtracts the scalar from it instead
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to add to the vector |
Returns
Vec3
Returns the clone of itself, modified
# Symbol.iterator()
Adds iteration to the object, allowing it to be destructured and iterated upon in various useful ways.
# theta()
(getter/setter) Spherical theta. For using a vec3 as spherical coordinates. Alias of {@link Vector#z z}
# Vec3()
A basic 3D Vector class that provides simple algebraic functionality in the form of 3D Vectors. We use Getters/setters for both principle properties (x & y) as well as virtual properties (rotation, length etc.).
# ...args(x, y)
The Vector Class constructor
Parameters
Name | Types | Description |
---|---|---|
x | number |
The x coord |
y | number |
The y coord |
# ...args(x, y, z, w)
Resets the vector coordinates
Parameters
Name | Types | Description |
---|---|---|
x | number |
The x coord |
y | number |
The y coord |
z | number |
The z coord |
w | number |
The w coord |
# add(vector)
Adds one vector to another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to add to this one |
Returns
Vec4
Returns itself, modified
# addNew(vector)
Clones the vector and adds the vector to it instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to add to this one |
Returns
Vec4
Returns the clone of itself, modified
# addScalar(scalar)
Adds a scalar to the vector, modifying both the x and y
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to add to the vector |
Returns
Vec4
Returns itself, modified
# addScalarNew(scalar)
Clones the vector and adds the scalar to it instead
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to add to the vector |
Returns
Vec4
Returns the clone of itself, modified
# cross(vector)
Calculates the cross product between this and two other supplied vectors
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector object against which to calculate the cross product |
Returns
Vec4
The cross product of the two vectors
# distance(vector)
Calculates the distance between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to calculate the distance from |
Returns
number
The distance between this and the supplied vector
# distanceW(vector)
Calculated the distance on the W axis between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to calculate the distance from |
Returns
number
The distance, along the y axis, between this and the supplied vector
# distanceX(vector)
Calculates the distance on the X axis between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to calculate the distance from |
Returns
number
The distance, along the x axis, between this and the supplied vector
# distanceY(vector)
Calculated the distance on the Y axis between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to calculate the distance from |
Returns
number
The distance, along the y axis, between this and the supplied vector
# distanceZ(vector)
Calculated the distance on the Z axis between this and the supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to calculate the distance from |
Returns
number
The distance, along the y axis, between this and the supplied vector
# divide(vector)
Divides one vector by another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to divide this by |
Returns
Vec4
Returns itself, modified
# divideNew(vector)
Clones the vector and divides it by the vector instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to divide the clone by |
Returns
Vec4
Returns the clone of itself, modified
# divideScalar(scalar)
Divides the vector by a scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to divide both x and y by |
Returns
Vec4
Returns itself, modified
# divideScalarNew(scalar)
Clones the vector and divides it by the provided scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to divide both x and y by |
Returns
Vec4
Returns the clone of itself, modified
# dot(vector)
Calculates the dot product between this and a supplied vector
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector object against which to calculate the dot product |
Returns
number
The dot product of the two vectors
# interpolate(v)
Iterpolates a provided anonymous value into a vew Vec4
Parameters
Name | Types | Description |
---|---|---|
v | Vec4 |
array |
# lengthSquared()
(getter/setter) The length of the vector presented as a square. If you're using length for comparison, this is quicker.
# lerp(v1, v2, d)
Performs a linear interpolation between two Vec4's
Parameters
Name | Types | Description |
---|---|---|
v1 | Vec4 |
the first operand |
v2 | Vec4 |
the second operand |
d | Number |
interpolation amount in the range of 0 - 1 |
# multiply(vector)
Multiplies one vector by another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to multiply this by |
Returns
Vec4
Returns itself, modified
# multiplyNew(vector)
Clones the vector and multiplies it by the vector instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to multiply the clone by |
Returns
Vec4
Returns the clone of itself, modified
# multiplyScalar(scalar)
Multiplies the vector by a scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to multiply both x and y by |
Returns
Vec4
Returns itself, modified
# multiplyScalarNew(scalar)
Clones the vector and multiplies it by the provided scalar.
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to multiply both x and y by |
Returns
Vec4
Returns the clone of itself, modified
# normalise()
Normalises the vector down to a length of 1 unit
Returns
Vec4
Returns itself, modified
# normaliseNew()
Clones the vector and normalises it
Returns
Vec4
Returns a clone of itself, modified
# resetToVector(v)
Resets the vector coordinates to another vector object
Parameters
Name | Types | Description |
---|---|---|
v | Vec4 |
The vector object to use to reset the coordinates |
# subtract(vector)
Subtracts one vector from another.
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to subtract from this one |
Returns
Vec4
Returns itself, modified
# subtractNew(vector)
Clones the vector and subtracts the vector from it instead
Parameters
Name | Types | Description |
---|---|---|
vector | Vec4 |
The vector to subtract from this one |
Returns
Vec4
Returns the clone of itself, modified
# subtractScalar(scalar)
Subtracts a scalar from the vector, modifying both the x and y
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to subtract from the vector |
Returns
Vec4
Returns itself, modified
# subtractScalarNew(scalar)
Clones the vector and subtracts the scalar from it instead
Parameters
Name | Types | Description |
---|---|---|
scalar | number |
The scalar to add to the vector |
Returns
Vec4
Returns the clone of itself, modified
# Symbol.iterator()
Adds iteration to the object, allowing it to be destructured and iterated upon in various useful ways.
# Vec4()
A basic 3D Vector class that provides simple algebraic functionality in the form of 3D Vectors. We use Getters/setters for both principle properties (x & y) as well as virtual properties (rotation, length etc.).