Skip to content

OverlaySystem.bindControls

Summary

OverlaySystem.bindControls wires camera-change and interaction-state signals from navigation controls into overlay invalidation. Passing null detaches existing bindings. This keeps overlay layers synchronized during user navigation without manual update calls.

Syntax

OverlaySystem.bindControls(controls: NavigationControls | null | undefined): OverlaySystem
const result = overlay.bindControls(controls);

Parameters

Name Type Required Description
controls NavigationControls \| null \| undefined Yes Controls instance to subscribe to, or null/undefined to unbind.

Returns

OverlaySystem - The same overlay system instance after rebinding.

Type Details

type NavigationControls = {
    onChange?: (listener: () => void) => (() => void);
    onInteractionState?: (listener: (active: boolean) => void) => (() => void);
};

Example

const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);

const camera = wgpu.createCamera.perspective({ aspect: canvas.clientWidth / canvas.clientHeight });
const controls = wgpu.createControls.orbit(camera, canvas, { enableDamping: true });
const overlay = wgpu.createOverlay.system({ camera });
overlay.bindControls(controls);

See Also