Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

SceneProxy

The scene's coarse volumetric stand-in, as part of the scene.

Add it and the proxy is built over whatever the scene holds while the scene runs, then kept current: each tick walks a slice of the scene, and when a whole walk finds the geometry it covers has moved far enough to move a voxel, it rebuilds the field. A crate pushed across a floor is in the field within one interval plus the walk and the refresh; a scene standing still costs the walk and nothing else, and a tick's share of a frame is bounded however many entities the scene holds.

A build yields while the GPU hands the scene's geometry back, so it runs in a task of its own, and a task the tick starts from editorUpdate is not resumed: in edit mode the tick stands tracking down after a few attempts and says so in sceneProxy.trackingStats().lastError and in the log. The field is built and followed while the scene runs.

local id = entity.spawn("scene_proxy").id
entity(id).component.add("SceneProxy", { resolution = 64, interval = 0.25 })
fieldeffect
resolutionVoxels along each axis. Memory is res³ × 40 bytes and is fixed by this alone. 0 releases the grid and keeps the rest authored.
intervalSeconds between maintenance ticks — how stale the field is allowed to get.
motionHow far geometry must move before the field is rebuilt, in voxels.
refitWhether geometry leaving the built extent rebuilds the grid around the scene's new size.

Reading the field is @builtin::systems.sceneProxy.sceneProxy — sceneProxy.sampleAt from a script, scene_proxy.shaderModule from a shader.

Each of these is a claim on one grid: several may stand in a scene, the settings in force are those of the one added or edited most recently, and the grid is released when the last of them goes.