objectPosition
A vec3 vector representing the object's pivot point in world space. It allows easy access within the shader to the object's overall position, rather than just a point on its surface.
Core Advantages
It greatly simplifies data passing by eliminating the need for manual uniforms. It updates automatically in real-time, serving as the foundation for all dynamic effects that depend on the object's holistic position (like distance-based fading or overall glow).
Common Uses
Object-centric spherical effects: Acts as the sphere's center to calculate distances from surface points, creating energy shields or masks.
Distance-based fading (LOD): Calculates the distance to the camera to control the entire object's opacity.
World-space height gradients: Changes the object's color or material properties based on its world Y-coordinate.
How to adjust
This node has no internal parameters to adjust. Its effect is controlled by changing the object's position in JavaScript (e.g., `mesh.position.y = ...`). The shader effect will react in real-time to the object's new world position. For advanced use, its `.object3d` property can be set dynamically to track another object's position.
Code Examples
1
2// Calculate the distance from the surface point (world space) to the object's center
3const dist = distance( positionWorld, objectPosition() );
4
5// Create a spherical mask with a radius of 5 and a falloff of 1
6const sphereMask = smoothstep( 5.0, 4.0, dist );
7