normalize
Converts a vector of any length into a unit vector (length of 1) while preserving its original direction.
Core Advantages
Ensures the mathematical correctness of directional calculations like lighting by providing a pure, standardized representation of direction, preventing errors from varying vector lengths and correcting normals distorted by non-uniform scaling.
Common Uses
Lighting calculations (normal, lightDir, viewDir)
Calculating pure direction vectors from position differences
Calculating reflection and refraction vectors
How to adjust
Its effect is deterministic; adjustment lies in *whether* to use it. Applying it to a position difference vector removes distance information, turning a point light effect into a directional one. Creatively used on a color vector, it dramatically boosts brightness for a neon-like visual.
Code Examples
1// Extract a pure light direction from a position difference vector
2const lightDirection = normalize( lightPosition.sub( positionWorld ) );