modelViewMatrix
Provides a 4x4 matrix that transforms vertices from model space (local space) to view space (camera space).
Core Advantages
It provides an efficient, pre-calculated transformation matrix (View Matrix * Model Matrix), greatly simplifying lighting, reflection, and other observer-dependent calculations in view space without manual uniform management.
Common Uses
Calculating the view direction, a core input for specular highlights in classic lighting models (e.g., Blinn-Phong).
Providing the correct geometric relationships for environment map reflections and refractions.
Creating billboard effects, where particles or planes always face the camera.
How to adjust
The matrix value of this node is read-only within the shader. It is determined entirely by the combined transformations (position, rotation, scale) of the object and the camera in the scene. To change this matrix, move the object or the camera in your JavaScript code.
Code Examples
1// Transform the vertex from model space to view space using modelViewMatrix
2const positionView = modelViewMatrix.mul( positionLocal );
3
4// Map the view-space xyz coordinates to RGB color for visualization
5material.colorNode = positionView.xyz.normalize().add( 1 ).mul( 0.5 );