WasmGPU.createControls.navigation().setMode¶
Summary¶
WasmGPU.createControls.navigation().setMode switches interaction behavior between orbit and trackball.
The method synchronizes internal state from the current camera pose before and after the mode change.
Use it to expose runtime mode toggles in UI controls.
Syntax¶
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
mode |
NavigationMode |
Yes | Requested controls mode: "orbit" or "trackball". |
Returns¶
this - Returns the same controls instance.
Type Details¶
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const camera = wgpu.createCamera.perspective({ fov: 50, aspect: canvas.clientWidth / canvas.clientHeight, near: 0.1, far: 1000 });
const controls = wgpu.createControls.navigation(camera, canvas, { mode: "orbit" });
document.getElementById("mode").addEventListener("click", () => {
controls.setMode(controls.mode === "orbit" ? "trackball" : "orbit");
});