modelWorldMatrixInverse
A mat4 matrix that performs the inverse transformation of `modelWorldMatrix`, converting coordinates from world space back into the object's own local space.
Core Advantages
It enables seamless world-to-local coordinate mapping, essential for effects like decals or world-space force fields. It simplifies shader logic by allowing calculations in the object's local space. The expensive matrix inversion is handled automatically and efficiently on the CPU, avoiding per-vertex GPU calculations.
Common Uses
Decal Projection: To transform the decal projector's world-space properties into the object's local space for correct mapping.
Localized World-Space Force Fields: To convert a force field's world position into local space to easily calculate its effect on vertices.
Relative Position Measurement: To find the position of a world-space point (e.g., a player) relative to the object's local coordinate system.
How to adjust
This node is read-only; its value is determined by the object's transform in the scene. To 'adjust' it, you modify the object's position, rotation, or scale in JavaScript. For example, moving the object with `mesh.position.x = 10` updates the inverse matrix to include a translation of -10, changing how world-space coordinates map to its local space.
Code Examples
1
2// 1. Transform a world-space origin (worldOrigin) into the object's local space
3const localSpaceOrigin = modelWorldMatrixInverse.mul( worldOrigin );
4
5// 2. Calculate the distance from the surface vertex (in local space) to this transformed origin
6const dist = distance( positionLocal, localSpaceOrigin );
7