Skip to content

RenderSystem ​

The final system in the update loop. Submits the frame to the renderer (WebGLRenderer or WebGPURenderer), delegating to the post-processing chain when one is active.

Overview ​

RenderSystem runs last in the world update loop and is responsible for:

  • Calling renderer.render(scene, camera) to produce the final frame.
  • Detecting whether PostprocessingSyncSystem (or a script) has placed an active chain on scene.userData.ecsPostprocessingComposer: an EffectComposer from the WebGL backend, a TSL RenderPipeline from webgpuBackend, or any object with a render() method.
  • When a chain is active: resizing it to the current renderer element dimensions (if it has setSize) and calling its render() instead of the default render path.
  • Invoking an optional afterRender callback after every frame (used by editor overlays or custom render hooks).

Behavior notes ​

  • Composer precedence: the system checks scene.userData.ecsPostprocessingComposerActive each frame. If true, the chain in scene.userData.ecsPostprocessingComposer renders the frame; otherwise the standard renderer.render() path is used. This coupling with PostprocessingSyncSystem means both systems must be present for postprocessing to work.
  • Dynamic resize: before calling composer.render(), the system reads renderer.domElement.clientWidth/Height (clamped to ≥ 1) and the renderer's pixel ratio. It calls composer.setPixelRatio / composer.setSize only when one of them changed or the composer was rebuilt, and only when the chain has those methods. A WebGPU RenderPipeline has neither: it reads the renderer's size every frame.
  • WebGPU start-up: WebGPURenderer.render() throws until await renderer.init() has resolved. While renderer.initialized is false the system skips the frame (and afterRender) and warns once.
  • Ordering: RenderSystem must be registered last in World.setup. All scene mutations (transform sync, visibility, etc.) must have already run.

API reference ​