UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

21 lines (15 loc) 328 B
import { vec3 } from "gl-matrix"; /** * * @param {vec3} out * @param {vec3} input */ export function NormalizeSafe(out, input) { const len = vec3.length(input); if (len !== 0) { const m = 1 / len; vec3.scale(out, input, m) } else { vec3.copy(out, input); } }