fix: minor stuff

This commit is contained in:
Dan Finch 2026-08-04 11:39:39 +02:00
parent e0585db0e0
commit f86b4ada13
5 changed files with 25 additions and 7 deletions

View file

@ -33,6 +33,8 @@ export namespace Vec3 {
export function normalize(v: Vec3): Vec3 {
const len = length(v)
return len === 0 ? v : scale(v, 1 / len)
// Fresh zero (not the input alias) to keep the namespace-wide no-aliasing
// guarantee even on the degenerate case.
return len === 0 ? { x: 0, y: 0, z: 0 } : scale(v, 1 / len)
}
}