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 onscene.userData.ecsPostprocessingComposer: anEffectComposerfrom the WebGL backend, a TSLRenderPipelinefromwebgpuBackend, or any object with arender()method. - When a chain is active: resizing it to the current renderer element dimensions (if it has
setSize) and calling itsrender()instead of the default render path. - Invoking an optional
afterRendercallback after every frame (used by editor overlays or custom render hooks).
Behavior notes
- Composer precedence: the system checks
scene.userData.ecsPostprocessingComposerActiveeach frame. Iftrue, the chain inscene.userData.ecsPostprocessingComposerrenders the frame; otherwise the standardrenderer.render()path is used. This coupling withPostprocessingSyncSystemmeans both systems must be present for postprocessing to work. - Dynamic resize: before calling
composer.render(), the system readsrenderer.domElement.clientWidth/Height(clamped to≥ 1) and the renderer's pixel ratio. It callscomposer.setPixelRatio/composer.setSizeonly when one of them changed or the composer was rebuilt, and only when the chain has those methods. A WebGPURenderPipelinehas neither: it reads the renderer's size every frame. - WebGPU start-up:
WebGPURenderer.render()throws untilawait renderer.init()has resolved. Whilerenderer.initializedisfalsethe system skips the frame (andafterRender) and warns once. - Ordering:
RenderSystemmust be registered last inWorld.setup. All scene mutations (transform sync, visibility, etc.) must have already run.
API reference
- Source:
core/systems/RenderSystem.ts

