OptionalcameraOptional camera used when rendering this scene.
Whether to clear the scissored region before rendering.
Whether to clip the GL viewport to the element's bounds.
The DOM element this scene tracks.
Whether to expose element-space coordinate helpers via u_elementSize.
OptionalinitializedThe scene graph root passed to the renderer each frame.
Optionalu_Element dimensions in canvas NDC units (vec2). Only present when
elementSpace: true. Use in a vertex shader to map element-local
coordinates to canvas NDC:
gl_Position = vec4(a_position.xy * u_elementSize + u_origin.zw, a_position.z, 1.0);
Packed origin uniform (vec4):
.xy — element bottom-left in physical pixels, GL canvas space (Y-up)..zw — element centre in canvas NDC [-1, 1].Element size in physical pixels (vec2).
Elapsed time uniform (float). Increments by delta * 0.00005 per frame.
All auto-updated uniforms, ready to spread into a Program's uniforms option.
Whether to lock the GL viewport to the element's bounds.
Whether the element is currently intersecting the viewport.
Disconnects the IntersectionObserver. Call when permanently removing
this scene — either directly or via ScrollRenderer.removeScene.
Converts the element's current bounding rect to GL viewport coordinates.
Canvas height in physical pixels (renderer.dimensions.height * dpr).
Device pixel ratio from the renderer.
GL-space x, y, width, height (all in physical pixels) plus the raw DOMRect.
A single WebGL scene anchored to a DOM element inside a ScrollRenderer.
Each
ScrollScenetracks its element's position viagetBoundingClientRect()every frame and exposes a set of uniforms that are updated automatically:u_timefloatdelta * 0.00005per frame).u_resolutionvec2u_originvec4.xy— element bottom-left in physical pixels, GL canvas space (Y-up). Use withgl_FragCoordfor element-relative fragment math..zw— element centre in canvas NDC [-1, 1]. Use for vertex positioning whenuseViewportisfalse.An
IntersectionObserverautomatically pauses rendering when the element leaves the viewport.Example