frameGroup
A globally shared data container that holds uniform data constant for a single render frame (e.g., time, camera position), updated automatically by the renderer once per frame.
Core Advantages
Its core advantage is efficiency and automation. Through an 'update once, use everywhere' model, it avoids redundant CPU updates and GPU communications for each material. Developers simply use nodes like `time()` or `cameraPosition` to automatically get the latest global data.
Common Uses
Providing a unified `time()` node to synchronize multiple animations in a scene (e.g., water, flags).
In environment-aware shading like the Fresnel effect, providing `cameraPosition` to calculate the view direction.
For post-processing effects (e.g., pixelation), providing `renderer.resolution` to get the screen dimensions.
In procedural effects (e.g., fire), using `time()` as a random seed to create dynamically evolving patterns.
How to adjust
This node is managed automatically by the renderer and cannot be adjusted directly. Its effects are observed by changing the scene state. For example, when moving the camera, the `cameraPosition` value updates, causing dependent effects like Fresnel (rim lighting) to react to the view change in real-time.
Code Examples
1
2// cameraPosition, from frameGroup, is used to calculate the Fresnel effect
3const viewDir = cameraPosition.sub( positionWorld ).normalize();
4const fresnel = viewDir.dot( normalWorld ).oneMinus();
5