Optionalx: numberOptionaly: numberOptionalz: numberOptionalw: numberOptionalonOptional change hook invoked at the end of every mutator. Engine-internal: owners install it, user code normally leaves it unset. It is intentionally not copied by Vector4.copy or Vector4.clone.
Allocates a new vector with the same components. The clone has no change hook. This is the only allocating method on the type (§7b).
Copies the components of v into this vector. The change hook is not copied.
Component-wise approximate equality: true when every component differs by
at most epsilon (absolute tolerance).
Optionalepsilon: numberEuclidean length over all four components.
Squared length. Preferred over Vector4.length for comparisons.
Moves this vector toward target by the factor t, mutating this vector.
t = 0 leaves it unchanged, t = 1 makes it equal to target. Values
outside [0, 1] extrapolate; no clamping is applied.
Scales this vector to unit length.
Zero-length behaviour (defined here): normalizing a zero-length vector
leaves it at (0, 0, 0, 0) rather than producing NaN or throwing — there
is no meaningful direction to pick, and poisoning a hot path with NaN is
worse than a no-op. The change hook still fires.
Range behaviour — the guard below tests the squared length, so three
ranges leave this vector non-unit and none of them reports an error
(measured from a consumer seat, dogfood cycle 10); Vector3.normalize
documents the same three with numbers:
0 (components below
about 1.57e-162) takes the zero-length branch, so the vector is left
unchanged and non-unit.1.3407807929942597e+154 squares
to Infinity, so the reciprocal is 0 and every component becomes 0.NaN in that slot and
0 in the others; a NaN component leaves the vector untouched,
because NaN > 0 is false.Multiplies every component by the scalar s.
Sets all four components.
Mutable four-component vector (§7b) — homogeneous coordinates, plane equations, RGBA channels, and shader uniforms.
Allocation policy (§7b, plan D7): instance methods that produce a "this-shaped" result mutate in place and return
this; only Vector4.clone allocates. Scalar queries (dot,lengthSq,length) andequalsApproxnever allocate and never mutate. All four components —wincluded — participate in every operation; there is no perspective divide here.Change notification (plan D3): every mutator invokes Vector4.onChanged after writing. Direct field writes (
v.x = 1) bypass the hook by design.