Skip to content

Camera and Viewport

Marc Flerackers edited this page Jun 9, 2024 · 5 revisions

Camera

The camera component marks the mode as a potential camera for a viewport.

add([
  camera("camera-name")
])

This will use the node's global transform as the camera transform.

Viewport

A viewport renders what a camera sees. The center of the camera is rendered in the center of the viewport. Cameras can be switched by simply assigning a new one to the viewport.

const vp = add([
  viewport("camera-name", width, height)
])

vp.camera = "second camera"

When null is assigned as camera (the default), The default camera is used.

When a mask is active, the viewport's framebuffer will be drawn masked.

The viewport does not use the active post effect since it is attached to a node, not global. To achieve a post effect on the viewport only, use a shader component on the viewport node.

A custom viewport's contents is not rendered when rendering the tree, it's rendering is deferred. First all the custom viewports' contents is rendered in framebuffers, then those framebuffers are rendered in the main viewport. So you can't recurse. When rendering a viewport different from the main viewport, all viewports are seen as not visible.

Clone this wiki locally