vec3
Interface representing a 3D vector. A 3D vector is represented by (x, y, z) coordinates, and can represent a point in space, a directional vector, or other types of data with three ordered dimensions. 3D vectors can be multiplied by 4x4 matrices (Mat4) using homogeneous coordinate math, enabling efficient 3D geometry computation. Vec3 objects are created with the ecs.math.vec3 Vec3Factory, or through operations on other Vec3 objects.
Sourceβ
The Vec3Source interface represents any object that has x, y, and z properties and hence can be used as a data source to create a Vec3. In addition, Vec3Source can be used as an argument to Vec3 algorithms, meaning that any object with {x: number, y: number, z: number} properties can be used.
Propertiesβ
Vec3 has the following enumerable properties:
readonly x: number
Access the x component of the vector.
readonly y: number
Access the y component of the vector.
readonly z: number
Access the z component of the vector.
Factoryβ
fromβ
Create a Vec3 from a Vec3, or other object with x, y properties.
ecs.math.vec3.from({x, y}: {x: number, y: number, z: number}}) // -> vec3
oneβ
Create a vec3 where all elements are set to one. This is equivalent to vec3.from({x: 1, y: 1, z: 1})
.
ecs.math.vec3.one() // -> vec3
scaleβ
Create a vec3 with all elements set to the scale value s. This is equivalent to vec3.from({x: s, y: s, z: s})
.
ecs.math.vec3.scale(s: number) // -> vec3
xyzβ
Create a Vec3 from x, y, z values. This is equivalent to vec3.from({x, y, z})
.
ecs.math.vec3.xyz(x: number, y: number, z: number) // -> vec3