Closed general

3D viewer: let a GLB declare its own layers via extras.adomLayer

Colby Knox · 2mo ago ·closed by Colby Knox

Split out of adom/wiki#60 (@aravk item 4), which is closing with the cheap items done. This one is real design work and deserves its own thread.

Problem

The 3D viewer's Layers panel is driven by a hardcoded key list (ThreeDViewer.svelte, LAYER_ORDER plus LAYER_LABELS): fr4_board, pad_top, solder_top, silk, barrel, pin1_marker and friends. A GLB whose meshes follow that naming convention gets a layers panel; anything else gets nothing.

That works for the PCB pipeline, which is what it was built for. It does not work for any other kind of model. AravK's downstream Static / Pick-and-Place viewer had to layer its own vocabulary on top as host-page code, because there is no way for a GLB to declare what its own layers are.

Ask

A generic mechanism, so any GLB can carry its own layer vocabulary:

extras.adomLayer = { key, label, group }

read from glTF extras during traversal, the same way extras.tooltip already is.

Why it is not a small change

  • Traversal: extras may sit on the mesh or an ancestor node, since Babylon splits multi-material primitives into child meshes. The tooltip code already walks up to five ancestors for this reason, and layer detection needs the same treatment.
  • Grouping and ordering: the current panel gets its order from the hardcoded array. Declared layers have no inherent order, so group needs to define sectioning and something has to define ordering within a group. Declaration order is the obvious default but needs deciding.
  • Back-compat: the 12 convention keys must keep working unchanged, including the default-off behaviour for solder and paste layers. Simplest shape is that the convention becomes a built-in vocabulary expressed in the same mechanism, rather than a parallel code path.
  • Panel UI: today it is a flat list with a hide-under-two-layers rule. Groups mean sections, and an arbitrary vocabulary means labels that were never length-checked.
  • Defaults: the convention hardcodes which layers start hidden. A declared layer needs a way to say that, so extras.adomLayer probably wants an optional hidden or defaultVisible.

Prior art in the codebase

docs/CONTENT-CONVENTIONS.md documents the naming convention. extras.tooltip is the working example of reading glTF extras through the ancestor chain, and is the model to copy.

1 Reply

Colby Knox · 2mo ago

Moved to adom/adom-3d-viewer#2. Viewer engine issues belong on the viewer's own page; adom/wiki is for wiki-specific work.

Log in to reply.