Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

debug_wireframe

The "wireframe" provider for @builtin::modules.debugViz: draws one green line per unique triangle edge of every scene mesh, every edit-mode tick.

debugViz.registerProvider("wireframe", require("@builtin::modules.debug_wireframe").tick)

DebugViz.component registers this provider automatically — attach it to one entity to draw the triangle-edge wireframe over every mesh in the scene alongside whatever other providers are registered.

How it works

A mesh's local-space geometry is static per guid, so tick builds each guid's wireframe once:

  1. asset.resolve(guid, "mesh"):load() — the mesh's CPU-resident geometry.
  2. :encode() — the resident geometry as ZMSH bytes.
  3. renderer.mesh.decode(zmsh) — back to { positions, indices }.
  4. Dedup every triangle's 3 edges by the sorted vertex-index pair.
  5. Pack each unique vertex once and lay the packed vertices out two per edge as a line-list blob.

Every tick, each mesh entity hands its guid's blob to emit.shape(entityId, guid, bytes, vertexCount). The core uploads a blob once under its guid and draws it once per entity through that entity's own world transform, so a mesh that moves, rotates, or scales updates its wireframe with no work in this module, and a scene's wireframe costs one GPU buffer per distinct mesh however many entities share it.

A tick reads every mesh guid in one entity.batchRead and compares nothing else per entity. Building a guid's wireframe is spread over ticks by a per-tick time budget, so a scene holding many distinct meshes fills in over a few frames rather than stalling one.

A mesh whose triangle count exceeds the provider's cap is skipped (logged once), and a guid with no asset-backed .mesh (a runtime mesh built via renderer.mesh.create) is skipped silently.

API

  • debug_wireframe.tick(emit) — draw the wireframe of every Mesh in the scene.