modelWorldMatrix
modelWorldMatrix
Provides a 4x4 matrix (the model matrix) that transforms vertices from local space to world space.
Core Advantages
Common Uses
Implementing world-space texture projection (e.g., tri-planar mapping) to make textures dependent on the object's world position and orientation.
Creating horizontal fog or water surface effects based on a vertex's world height (Y-coordinate).
Obtaining the global positions of objects for physics or interaction calculations within the shader.
How to adjust
The matrix value of this node is read-only within the shader. It is determined entirely by the transform (position, rotation, scale) of the 3D object in the scene. To change this matrix, modify the object's `.position`, `.rotation`, or `.scale` properties in your JavaScript code.
Code Examples
1// Transform local coordinates to world coordinates
2const positionWorld = modelWorldMatrix.mul( positionLocal );
3
4// Mix two colors based on world height (Y-axis) to create a water effect
5const blend = saturate( positionWorld.y.div( 10 ) );
6material.colorNode = mix( waterColor, landColor, blend );