objectRadius
Provides a float representing the object's approximate radius (based on its bounding sphere) in world space.
Core Advantages
It allows shader effects to adaptively scale with the object's size without manual uniform management, greatly simplifying the creation of size-aware effects.
Common Uses
Creating size-aware procedural textures to ensure patterns look proportional on objects of different scales.
Dynamically adjusting the thickness of outlines or rim lights to remain visually consistent with the object's size.
Defining the intensity or range of particle emission or vertex displacement effects based on the object's scale.
How to adjust
Adjust the output by changing the target `Object3D`'s `.scale` property or replacing its `.geometry` in JavaScript. Its `.object3d` property can also be set to track a specific object's size.
Code Examples
1// Smoothly map a radius range [0.5, 5.0] to a [0, 1] glow factor
2const glowFactor = smoothstep( 0.5, 5.0, objectRadius() );
3
4// Control the emissive intensity based on this factor
5material.emissiveNode = vec3( 1, 1, 0 ).mul( glowFactor );