objectWorldMatrix
Provides the 4x4 world matrix of an object, used to transform points and vectors from its local space to world space.
Core Advantages
It provides the foundational matrix for all local-to-world transformations, enabling advanced custom effects like SDF raymarching or decal projection, and allows tracking the transform of any specific object.
Common Uses
Manually transforming custom local-space points (like virtual attachment points) to world space.
Providing the basis for inverse transformations required in techniques like SDF raymarching or decal projection.
Enabling cross-object spatial calculations by allowing one object's shader to use another's world matrix.
How to adjust
Adjusted by changing the target `Object3D`'s transform properties (`.position`, `.rotation`, `.scale`) in JavaScript. Can also be changed by setting its `.object3d` property to track a different object's matrix.
Code Examples
1// Define a custom point in the object's local space
2const localTopCenter = vec4( 0, 0.5, 0, 1 );
3
4// Manually transform the local point to world space
5const worldTopCenterPos = objectWorldMatrix().mul( localTopCenter );
6
7// Use the resulting world position to drive an effect
8material.colorNode = vec3( worldTopCenterPos.y.smoothstep( -2, 2 ) );