Options
All
• Public
• Public/Protected
• All

# Class Vec3

An immutable 3d vector with x, y and z values.

Used for positions, normals and other 3d entities.

• Vec3

## Constructors

### constructor

• new Vec3(x: number, y: number, z: number): Vec3
• Constructor

## Properties

x: number

The x coordinate of the vector

y: number

The y coordinate of the vector

z: number

The z coordinate of the vector

## Methods

### equals

• Returns true if the vectors are equal

### getLength

• getLength(): number
• Returns the length of the vector (sqrt(x^2 + y^2 + z^2)).

### getLengthSquared

• getLengthSquared(): number
• Returns the squared length of the vector

### getNegated

• getNegated(): Vec3
• Returns a negated version of the vector.

### getNormalized

• getNormalized(): Vec3
• Returns a normalized version of the vector.

### getPointDistance

• getPointDistance(otherPoint: Vec3): number
• Returns the distance between this point and otherPoint

### getPointDistanceSquared

• getPointDistanceSquared(otherPoint: Vec3Like): number
• Returns the squared distance between this point and otherPoint

#### Returns number

• Returns the result of adding the two vectors

### Static cross

• Returns the cross product of the 2 vectors

### Static dot

• Returns the dot product of the 2 vectors

### Static from

• Creates a new Vec3 instance from any object with x, y and z properties.

### Static fromArray

• fromArray(arr: ArrayLike<number>): Vec3
• Creates a new Vec3 instance from the first 3 elements of the given array.

### Static negate

• Returns the negation of the given vector

### Static scale

• Returns the result of scaling the given vector by the given factor

### Static sub

• Returns the result of subtracting vector b from vector a

### Static transformPoint

• Returns a new vector with the given vector transforms as a point.

Transforms the vector as a point by multiplying it with the given matrix. This will both rotate and translate the vector p. Assumes the matrix m doesn't contain any perspective projection.

### Static transformVector

• Returns a new vector with the given vector transforms as a vector.

Transforms the vector as a vector by multiplying it with the given matrix. This will only rotate the vector. The translation part of the matrix will be ignored. Assumes the matrix m doesn't contain any perspective projection.

#### Returns Vec3

Generated using TypeDoc