Static ReadonlyDEFAULT_ReadonlydeviceReadonlyqueueReadonlycontextReadonlyformatReadonlydepthReadonlycanvasReadonlyhdrReadonlyenableReadonlyshaderReadonlyxrReadonlymaxReadonlyreversedSee RenderContextOptions.reversedZ. Read by passes/Camera to flip depth.
The camera that subsequent render passes will sample matrices from via
pass.updateCamera(ctx). Set this each frame (per camera, if multi-camera
later) after camera.updateRender(ctx). Null until first set.
Seconds since the first call to update. Updated every frame.
Seconds since the last call to update. Updated every frame.
Total frames rendered since creation. Incremented every frame by update.
Smoothed frames-per-second (EMA with alpha 0.1). Updated every frame by update.
Frames-per-second clamped to an integer. Updated every frame by update.
Backing canvas pixel width (or the XR render-size override when set).
Backing canvas pixel height (or the XR render-size override when set).
Depth value the main camera's depth buffer clears to: the FAR plane. 0 under
reversed-Z (far→0), 1 under standard-Z. Use this for depth attachment
clearValue/depthClearValue so a pass works in either mode.
Returns the swap chain texture for the current frame.
Returns the swap chain texture view for the current frame.
Returns the depth texture for the current frame, or null if depth is not enabled.
Returns the depth texture view for the current frame, or null if depth is not enabled.
Override the reported render size (see _renderSizeOverride); pass
null to revert to the canvas backing-store size. Used by the engine's
WebXR driver per eye.
Maps a standard-Z depth-compare function to the equivalent under the active mode.
Under reversed-Z, "nearer" is a GREATER depth, so 'less'→'greater' and
'less-equal'→'greater-equal'; other functions pass through. Pass the
standard-Z function you'd normally use; the result is what the pipeline should use.
Call each frame to detect canvas resizes and update the backbuffer depth texture accordingly.
Also updates deltaTime, elapsedTime, frameCount, framesPerSecond and fps.
true if a resize was detected and handled, false otherwise.
StaticcreateRequests a WebGPU adapter and device, configures the canvas swap chain and returns a ready-to-use context.
Attempts an HDR (rgba16float + display-p3 + extended tonemapping) swap
chain and falls back to the preferred SDR format if unsupported.
canvas to bind the swap chain to
optional context configuration
initialized render context
StaticcreateBuild a second RenderContext for another canvas that SHARES the GPU device of an existing context, rather than requesting a fresh adapter/device.
WebGPU allows one device to drive multiple canvas contexts, and GPU
resources (buffers, textures) are only usable on the device that created
them — so a picture-in-picture / preview canvas that renders an
already-loaded scene MUST share the primary context's device. Use this for
any secondary view of a scene whose GPU resources live on base.
Reuses base's surface format and HDR flag so the two contexts are
pipeline-compatible (render pipelines are keyed on the surface format).
Creates a GPU shader module from the provided WGSL code.
WGSL shader code
Optionallabel: stringoptional debug label
Optionaldefines: Record<string, string>optional preprocessor defines for shader block imports
GPUShaderModule instance
Registers a shader block for later use in shader modules.
unique identifier for the shader block
WGSL code of the shader block
Removes a previously registered shader block by name.
name of the shader block to remove
Retrieves the WGSL code for a registered shader block by name.
name of the shader block
Optionaldefines: Record<string, string>WGSL code of the shader block, or a placeholder comment if not found
Convenience wrapper around device.createBuffer.
buffer size in bytes
usage flags
Optionallabel: stringoptional debug label
Uploads CPU data into a GPU buffer, handling both ArrayBuffer and typed-array sources.
destination GPU buffer
source bytes to copy
destination byte offset
Pushes a validation error scope used during one-time resource initialization. No-op when error handling is disabled.
Pops the matching init error scope and logs any validation failure.
identifier included in the log message
Pushes a per-frame validation error scope. No-op when error handling is disabled.
Pops the matching per-frame error scope and logs any validation failure.
Pushes nested validation, out-of-memory and internal error scopes around a single render pass. No-op when error handling is disabled.
pass identifier (currently unused; reserved for diagnostics)
Pops the three pass-level error scopes pushed by pushPassErrorScope and logs any captured errors.
pass identifier included in log messages
Convenience method to create a 1x1 cubemap texture with a neutral gray color, used as a fallback when IBL textures fail to load.
Convenience method to create a 1x1 BRDF LUT texture with a neutral value, used as a fallback when IBL textures fail to load.
Owns the WebGPU device, queue and canvas configuration for the renderer.
Acts as the single shared handle to GPU resources, and exposes helpers for buffer creation, swap-chain access and scoped validation error capture.