An immutable-by-convention 3D vector with full operator overloading.
var a = new Vector3(1, 2, 3);
var b = a + new Vector3(0, 0, 1);
var away = (b - a).normalized() * 5.0;
Every method is inline, and the underlying type is a bare structure, so
none of this survives into the generated Lua as a wrapper object — the
arithmetic compiles down to direct field reads on plain tables.
Values coming back from natives can be adopted directly:
var coords:Vector3 = cast Natives.entity.getEntityCoords(ped, true);
and values going into natives are passed component-wise (v.x, v.y, v.z),
which every native signature in this library accepts.
Static variables
staticread onlylengthSquared:Float
Squared length. Prefer this over length when only comparing distances.
Static methods
staticinlineclampLength(this:Vector3Data, max:Float):Vector3
Clamps the vector's length to at most max, keeping its direction.
staticinlinedistance2d(this:Vector3Data, rhs:Vector3):Float
Distance ignoring height — the right choice for "is the player near this spot" checks.
staticinlinefromHeading(degrees:Float):Vector3
Builds a heading-aligned unit vector, using the same convention as the game's entity headings: 0° faces north (+Y), increasing clockwise.
staticinlinefromNative(value:Dynamic):Vector3
Adopts a value returned by a native (a Lua vector3, or any table with
x/y/z) as a Vector3. Returns null for a null input, which is
what natives hand back when the entity or query had no result.
staticinlinemul(this:Vector3Data, rhs:Vector3):Vector3
Component-wise product (Hadamard), not dot or cross.
staticinlinenearlyEquals(this:Vector3Data, rhs:Vector3, epsilon:Float = 0.001):Bool
Compares component-wise within epsilon, for tolerating float drift.
staticinlinenormalized(this:Vector3Data):Vector3
Unit-length copy. A zero vector is returned unchanged rather than producing NaNs.
staticinlinetoHeading(this:Vector3Data):Float
The game heading (degrees, 0 = north, clockwise) this vector points in. The Z component is ignored.
staticinlinetoNative(this:Vector3Data):Dynamic
A real Lua vector3, for the rare native or resource export that demands one.