fix: minor stuff
This commit is contained in:
parent
e0585db0e0
commit
f86b4ada13
5 changed files with 25 additions and 7 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue