Builtin Library
README.md
debug_frustum
The "frustum" provider for @builtin::modules.debugViz: appends one cyan
wireframe frustum per scene Camera into the shared debug-visualization batch,
every edit-mode tick.
debugViz.registerProvider("frustum", require("@builtin::modules.debug_frustum").tick)
DebugViz.component registers this provider automatically — attach it to one
entity to draw every enabled camera's view frustum alongside whatever other
providers are registered.
How it works
tick(emit) queries every entity carrying a Camera and, for each enabled one,
builds its 8 near/far corners in the camera's local space:
- half-height at a given distance is
tan(fov / 2) * distance; half-width ishalf-height * aspect. - the camera looks down its local -Z axis
(
entity(id).transform.forwardis documented as "local -Z axis in world space"), so the near/far planes sit at localz = -near/z = -far. - each corner is
position + forward * dist + right * (±halfWidth) + up * (±halfHeight), using the entity's world position and world-space forward/right/up axes — no separate quaternion math needed.
Camera has no aspect field, so the aspect ratio is read live from
getViewportSize() (the window's real aspect, matching what the viewport
camera sees), falling back to a 16:9 default if the viewport size isn't
readable. The 12 edges (4 near, 4 far, 4 connecting) are appended via
emit.line.
API
debug_frustum.tick(emit)— append one wireframe frustum per enabled scene camera into the shared batch.