Vector3f

Lore. Vector3f

A class representing 3D float vector.

Constructor

new Vector3f(x, y, z)

Source:
Properties:
Name Type Description
components Float32Array

A typed array storing the components of this vector.

Creates an instance of Vector3f.

Parameters:
Name Type Description
x Number

The x component of the vector.

y Number

The y component of the vector.

z Number

The z component of the vector.

Methods

(static) add(u, v) → {Lore.Vector3f}

Source:

Sums two vectors.

Parameters:
Name Type Description
u Lore.Vector3f

A vector.

v Lore.Vector3f

A vector.

Returns:

The sum of the two vectors.

Type
Lore.Vector3f

(static) cross(u, v) → {Lore.Vector3f}

Source:

Calculates the cross product of two vectors.

Parameters:
Name Type Description
u Lore.Vector3f

A vector.

v Lore.Vector3f

A vector.

Returns:

The cross product of the two vectors.

Type
Lore.Vector3f

(static) divide(u, v) → {Lore.Vector3f}

Source:

Divides a vector by another vector (u / v).

Parameters:
Name Type Description
u Lore.Vector3f

A vector.

v Lore.Vector3f

A vector.

Returns:

The fraction vector.

Type
Lore.Vector3f

(static) divideScalar(v, s) → {Lore.Vector3f}

Source:

Divides a vector by a scalar.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

s Number

A scalar.

Returns:

The vector divided by the scalar.

Type
Lore.Vector3f

(static) dot(u, v) → {Number}

Source:

Calculates the dot product of two vectors.

Parameters:
Name Type Description
u Lore.Vector3f

A vector.

v Lore.Vector3f

A vector.

Returns:

The dot product of the two vectors.

Type
Number

(static) forward() → {Lore.Vector3f}

Source:

Returns the forward vector (0, 0, 1).

Returns:

The forward vector.

Type
Lore.Vector3f

(static) multiply(u, v) → {Lore.Vector3f}

Source:

Multiplies two vectors.

Parameters:
Name Type Description
u Lore.Vector3f

A vector.

v Lore.Vector3f

A vector.

Returns:

The product of the two vectors.

Type
Lore.Vector3f

(static) multiplyScalar(v, s) → {Lore.Vector3f}

Source:

Multiplies a vector with a scalar.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

s Number

A scalar.

Returns:

The vector multiplied by the scalar.

Type
Lore.Vector3f

(static) normalize(v) → {Lore.Vector3f}

Source:

Normalizes a vector.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

The noramlized vector.

Type
Lore.Vector3f

(static) right() → {Lore.Vector3f}

Source:

Returns the right vector (1, 0, 0).

Returns:

The right vector.

Type
Lore.Vector3f

(static) subtract(u, v) → {Lore.Vector3f}

Source:

Subtracts one scalar from another (u - v)

Parameters:
Name Type Description
u Lore.Vector3f

A vector.

v Lore.Vector3f

A vector.

Returns:

The difference between the two vectors.

Type
Lore.Vector3f

(static) up() → {Lore.Vector3f}

Source:

Returns the up vector (0, 1, 0).

Returns:

The up vector.

Type
Lore.Vector3f

add(v) → {Lore.Vector3f}

Source:

Sums the vector with another.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

Returns itself.

Type
Lore.Vector3f

applyProjection(m) → {Lore.Vector3f}

Source:

Applies a projection matrix to the vector.

Parameters:
Name Type Description
m Lore.Matrix4f

A (projection) matrix.

Returns:

Returns itself.

Type
Lore.Vector3f

applyQuaternion(q) → {Lore.Vector3f}

Source:

Applies a quaternion to the vector (usually a rotation).

Parameters:
Name Type Description
q Lore.Quaternion

Quaternion.

Returns:

Returns itself.

Type
Lore.Vector3f

clone() → {Lore.Vector3f}

Source:

Clones this vector.

Returns:

A clone of this vector.

Type
Lore.Vector3f

copyFrom(v) → {Lore.Vector3f}

Source:

Copies the values from another vector

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

Returns itself.

Type
Lore.Vector3f

cross(v) → {Number}

Source:

Calculates the cross product for the vector with another vector.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

The cross product of the two vectors.

Type
Number

distanceTo(v) → {Number}

Source:

Calculates the distance to another vector.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

The distance to the other vector.

Type
Number

distanceToSq(v) → {Number}

Source:

Calculates the square of the distance to another vector.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

The square of the distance to the other vector.

Type
Number

divide(v) → {Lore.Vector3f}

Source:

Divides the vector by another vector.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

Returns itself.

Type
Lore.Vector3f

divideScalar(s) → {Lore.Vector3f}

Source:

Divides the vector by a scalar.

Parameters:
Name Type Description
s Number

A scalar.

Returns:

Returns itself.

Type
Lore.Vector3f

dot(v) → {Number}

Source:

Calculates the dot product for the vector with another vector.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

The dot product of the two vectors.

Type
Number

equals(v) → {Boolean}

Source:

Compares the components of the vector to those of another.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

A vector indicating whether or not the two vectors are equal.

Type
Boolean

getX() → {Number}

Source:

Gets the x component of this vector.

Returns:

The x component of this vector.

Type
Number

getY() → {Number}

Source:

Gets the y component of this vector.

Returns:

The y component of this vector.

Type
Number

getZ() → {Number}

Source:

Gets the z component of this vector.

Returns:

The z component of this vector.

Type
Number

length() → {Number}

Source:

The length / magnitude of the vector.

Returns:

The length / magnitude of the vector.

Type
Number

lengthSq() → {Number}

Source:

Get the square of the length / magnitude of the vector.

Returns:

The square of length / magnitude of the vector.

Type
Number

multiply(v) → {Lore.Vector3f}

Source:

Multiply the vector with another vector.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

Returns itself.

Type
Lore.Vector3f

multiplyScalar(s) → {Lore.Vector3f}

Source:

Multiplies this vector with a scalar.

Parameters:
Name Type Description
s Number

A scalar.

Returns:

Returns itself.

Type
Lore.Vector3f

normalize() → {Lore.Vector3f}

Source:

Normalizes the vector.

Returns:

Returns itself.

Type
Lore.Vector3f

project(camera) → {Lore.Vector3f}

Source:

Projects the vector from world space into camera space.

Parameters:
Name Type Description
camera Lore.CameraBase

A camera instance.

Returns:

The vector in camera space.

Type
Lore.Vector3f

set(x, y, z) → {Lore.Vector3f}

Source:

Sets the x, y and z components of this vector.

Parameters:
Name Type Description
x Number

The x component of the vector.

y Number

The y component of the vector.

z Number

The z component of the vector.

Returns:

Returns itself.

Type
Lore.Vector3f

setFromSphericalCoords(s) → {Lore.Vector3f}

Source:

Sets this vector from spherical coordinates.

Parameters:
Name Type Description
s Lore.SphericalCoordinates

A spherical coordinates object.

Returns:

Returns itself.

Type
Lore.Vector3f

setLength(length) → {Lore.Vector3f}

Source:

Set the length / magnitude of the vector.

Parameters:
Name Type Description
length Number

The length / magnitude to set the vector to.

Returns:

Returns itself.

Type
Lore.Vector3f

setX(x) → {Lore.Vector3f}

Source:

Sets the x component of this vector.

Parameters:
Name Type Description
x Number

The value to which the x component of this vectors will be set.

Returns:

Returns itself.

Type
Lore.Vector3f

setY(y) → {Lore.Vector3f}

Source:

Sets the y component of this vector.

Parameters:
Name Type Description
y Number

The value to which the y component of this vectors will be set.

Returns:

Returns itself.

Type
Lore.Vector3f

setZ(z) → {Lore.Vector3f}

Source:

Sets the z component of this vector.

Parameters:
Name Type Description
z Number

The value to which the z component of this vectors will be set.

Returns:

Returns itself.

Type
Lore.Vector3f

subtract(v) → {Lore.Vector3f}

Source:

Substracts a vector from this one.

Parameters:
Name Type Description
v Lore.Vector3f

A vector.

Returns:

Returns itself.

Type
Lore.Vector3f

toDirection(m) → {Lore.Vector3f}

Source:

Rotates the vector into the direction defined by the rotational component of a matrix.

Parameters:
Name Type Description
m Lore.Matrix4f

A matrix.

Returns:

Returns itself.

Type
Lore.Vector3f

toString() → {String}

Source:

Returns a string representation of the vector.

Returns:

A string representation of the vector.

Type
String

unproject(camera) → {Lore.Vector3f}

Source:

Projects the vector from camera space into world space.

Parameters:
Name Type Description
camera Lore.CameraBase

A camera instance.

Returns:

The vector in world space.

Type
Lore.Vector3f