WasmGPU.render¶
Summary¶
WasmGPU.render submits one frame using the provided scene and camera. If the engine is not currently running a loop, the frame arena is reset before rendering. Use this for manual render control such as single-frame rendering, custom timing loops, or explicit stepping around UI events.
Syntax¶
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
scene |
Scene |
Yes | Scene contents containing meshes, point clouds, glyph fields, nodelinks, splatfields, latticespaces, and lights used for the frame. |
camera |
Camera |
Yes | Active camera supplying the view and projection transforms for this frame. |
Returns¶
void - Encodes and submits render work for the current frame.
Frame Behavior¶
render()checks the canvas size and device-pixel-ratio-backed render targets, then resizes depth, picking, transmission, and SMAA resources when needed.- It updates the camera aspect ratio, runs transform propagation, writes camera and lighting uniforms, and builds draw lists for meshes, point clouds, glyph fields, nodelinks, splatfields, and latticespaces.
- It applies frustum culling when enabled. If occlusion culling is enabled and a valid previous-frame hierarchy is available, it can further filter eligible opaque meshes, point clouds, glyph fields, nodelinks, and latticespaces for the current render only. Splatfields are excluded from occlusion culling.
- It renders opaque content first. Transmissive
StandardMaterialobjects sample the rendered scene color. Before transparent drawing, each visible splatfield is sorted by camera depth, as are the visible cells of each transparent 3D latticespace. - If
antialiaswas enabled duringWasmGPU.create(...), SMAA runs after the main render passes.
Render-time occlusion filtering is separate from picking and warmup. It is not used to answer picks or to prewarm resources.
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const scene = wgpu.createScene([0.06, 0.07, 0.09]);
const camera = wgpu.createCamera.perspective({ fov: 60, aspect: canvas.width / Math.max(1, canvas.height), near: 0.1, far: 1000 });
camera.transform.setPosition(0, 0, 5);
wgpu.render(scene, camera);