Vec

namespace Vec
vec3.ts:1

Members

add

add(a: Vec3, b: Vec3) → Vec3
aVec3
Undocumented
bVec3
Undocumented

approxEquals

approxEquals(a: Vec3, b: Vec3, epsilon: number) → boolean
aVec3
Undocumented
bVec3
Undocumented
epsilonnumber
Undocumented

cross

cross(a: Vec3, b: Vec3) → Vec3
aVec3
Undocumented
bVec3
Undocumented

distance

distance(a: Vec3, b: Vec3) → number
aVec3
Undocumented
bVec3
Undocumented

dot

dot(a: Vec3, b: Vec3) → number
aVec3
Undocumented
bVec3
Undocumented

equals

equals(a: Vec3, b: Vec3) → boolean
aVec3
Undocumented
bVec3
Undocumented

format

format(a: Vec3, digits: number) → string
aVec3
Undocumented
digitsnumber
Undocumented

isFinite3

isFinite3(a: Vec3) → boolean
aVec3
Undocumented

length

length(a: Vec3) → number

Uses hypot to keep magnitudes near the double range (a 1e20 m vector squares to 1e40).

aVec3
Undocumented

lengthSquared

lengthSquared(a: Vec3) → number
aVec3
Undocumented

lerp

lerp(a: Vec3, b: Vec3, t: number) → Vec3
aVec3
Undocumented
bVec3
Undocumented
tnumber
Undocumented

mul

mul(a: Vec3, b: Vec3) → Vec3
aVec3
Undocumented
bVec3
Undocumented

negate

negate(a: Vec3) → Vec3
aVec3
Undocumented

normalize

normalize(a: Vec3) → Vec3
aVec3
Undocumented

scale

scale(a: Vec3, s: number) → Vec3
aVec3
Undocumented
snumber
Undocumented

sub

sub(a: Vec3, b: Vec3) → Vec3
aVec3
Undocumented
bVec3
Undocumented

toArray

toArray(a: Vec3) → [number, number, number]
aVec3
Undocumented

toFloat32

toFloat32(a: Vec3) → Vec3

Round each component to float32.

Render coordinates end up in a Float32Array on the GPU, so tests use this to assert that a value actually survives the trip — asserting on doubles would pass for coordinates the renderer cannot represent.

aVec3
Undocumented

UNIT_X

UNIT_X: Vec3

UNIT_Y

UNIT_Y: Vec3

UNIT_Z

UNIT_Z: Vec3

vec3

vec3(x: number, y: number, z: number) → Vec3
xnumber
Undocumented
ynumber
Undocumented
znumber
Undocumented

Vec3

Vec3: unknown

Double-precision 3-vector, in whatever frame the caller is holding.

This is not a universe position — see universeVector.ts for that. A Vec3 is always a displacement or a frame-local coordinate, where double precision is plenty (a 1e6 m local frame has 0.2 nm resolution).

Plain readonly objects rather than a class: they survive structuredClone to a worker, JSON round-trips without a codec, and the engine keeps them in one hidden class as long as the field order below is preserved everywhere.

withLength

withLength(a: Vec3, target: number) → Vec3

Rescale to an exact magnitude. Returns ZERO for a zero-length input.

aVec3
Undocumented
targetnumber
Undocumented

ZERO

ZERO: Vec3

Generated from the source of @inertialref/spatial and its comments. Nothing on this page is written by hand.