Skip to content

createCamera#destroy

Summary

createCamera#destroy disposes the transform owned by a perspective or orthographic camera. Stop rendering with the camera and detach or retarget any controls first.

Syntax

Camera.destroy(): void
readonly Camera.destroyed: boolean
camera.destroy();

Notes

After destruction, camera.destroyed is true, and operations that access its transform, such as reading its view matrix, throw. Camera controls have their own lifetime.

Example

const camera = wgpu.createCamera.perspective();
camera.setWorldPosition(0, 0, 5);
// Render with the camera before cleanup.
camera.destroy();
console.log(camera.destroyed); // true

See Also