Adom 3D Viewer
Public Made by Adomby adom
The Babylon 9.5 engine behind every component page's 3D tab on wiki.adom.inc. Versioned ESM bundle with GLB loading, view cube, layers toolbar, ground shadows, and Z-up CAD framing.
Let a GLB declare its own layers via extras.adomLayer
Split out of adom/wiki#60 (@aravk item 4). Filed here rather than on adom/wiki because it is viewer engine work, not wiki work.
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:
extrasmay 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
groupneeds 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.adomLayerprobably wants an optionalhiddenordefaultVisible.
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.