Skip to content

uiLayoutRect

uiLayoutRect(cam, canvas, width, height, previewAspect?): WorldRect

Defined in: camera/uiLayoutRect.ts:88

The world-space box the UI subtree is laid out within (UINode px are world units in this box), for the primary camera.

Scene cameras already bake the canvas design resolution into halfW/halfH, so their box is simply those extents — UINode px map 1:1 to design px and the UI is stable. The editor view instead renders the world at a free zoom with a raw orthoSize (editorCameraInfo passes a null canvas, for predictable navigation), so laying UI out in its zoomed extents would rescale and reflow every element on each zoom. For it, recover the fixed design-resolution box from the canvas: the UI then lays out identically at any zoom, and still scales visually with the scene because it renders through the same zoomed viewProjection. The box stays centered on the editor pan (cameraX/Y), so panning tracks the view as before.

With no canvas (no UI in the scene) the editor falls back to its own extents — there is nothing to lay out, so it doesn’t matter.

CameraExtents

CanvasScale | null

number

number

number = 0

WorldRect