Closed general

Board viewer: budget, toggle and preserve the LED spot lights that component GLBs now carry

Ray · ·closed by Colby Knox

John Lauer's LED component GLBs (adom/ncd0402g1, adom/ncd0402b1) carry a real KHR_lights_punctual spot light and named switch groups: Adom.LED.State holds the emissive lens skin and the light, Adom.LaserEtch.MPN holds the part number, each with extras.adomRole. He verified them in the Hydrogen WebView2 Babylon 9.5 scene: the light casts onto a matte receiver and goes away when the state group is disabled, and the MPN toggles independently. Details and the follow-up on budgeting are on https://wiki.adom.inc/adom/adom-step2glb/issues/17; the engine/viewer split is written up in https://github.com/adom-inc/service-occt/blob/main/docs/led-spotlights-design.md.

The engine side is done: service-step2glb 1.3.2 and step2glb 0.13.2 preserve the lights and the state groups through the molecule optimize, plain convert, the web LOD and anchor-glb, and refuse a job if a count changes. So the files arriving at the viewer will carry the lights. What is left is the viewer's, and that is this issue:

  1. Light budget and culling. Babylon materials default to maxSimultaneousLights = 4; a board with forty lit LEDs cannot light every receiver with every LED. Pick the N nearest or brightest active LED lights per frame or per material and let the rest stay emissive-only. Clustered lighting (the ClusteredLightContainer symbol exists in 9.5) is the right long-term tool, but it needs a benchmark before it is promised; the symbol being present is not proof it is active.
  2. No per-LED shadows by default. One shadow generator per spot light does not scale.
  3. Visibility toggles by state-root name. Expose the groups the viewer finds by name (Adom.LED.State, Adom.LaserEtch.MPN, and the existing Adom.HeatsinkVias / Adom.SolderBalls / Adom.LaserEtch) as toggles per instance and per role, and persist the chosen state where the viewer persists anything else. setEnabled(false) on the group root is the whole mechanism.
  4. No rescaling of light range or intensity. glTF light range is metres and intensity candela; they do not follow a node matrix. A viewer that rescales a model to fit the screen must leave the lights alone or divide the scale back out, or a 15 mm range becomes 15 m.
  5. Per-placement light instances. A board that references one LED GLB many times must instance the light per placement, or every LED switches together.

Nothing here asks for the viewer to create lights of its own; the reference files carry them. The datasheet-angle cone, the display gain and the units are all in the file's extras and in the convention document under review on the same #17 thread.

2 Replies

Colby Knox ·

Shipped in viewer 0.8.0 (adom/adom-3d-viewer 0.8.0, vendored into the wiki as bundle 20260917b, on staging now and queued behind the current prod tag). Every point above, in order:

1. Light budget and culling. The rig's own key and fill lights already take three of Babylon's four default slots, so one LED was enough to reach the limit. Content lights now run under a budget: the nearest and brightest lightBudget (default 4) stay lit and follow the camera (re-scored on camera move, throttled, skipped entirely when the content has no more lights than the budget), and the rest stay emissive-only. Content materials get maxSimultaneousLights raised to the viewer's lights plus the budget, capped at 8. lightBudget is an init option, setLightBudget(n) changes it live, setContentLightsEnabled(false) turns them all off. No clustered lighting: ClusteredLightContainer existing is not proof it is active, and it is not promised here until someone benchmarks it.

2. No per-LED shadows. Every adopted light gets shadowEnabled = false. The ground shadow stays the viewer's own key light.

3. Visibility toggles by state-root name. A node carrying extras.adomRole, or named Adom.<Something>, is a switchable group. The OUTERMOST declaration wins, so Adom.LED.State is the toggle and its Adom.LED.Emission and Adom.LED.Light children ride with it; the mechanism is setEnabled(false) on the group root, so the light goes off with the lens. Rows show in the Layers panel under "Parts", one per role with the placement count, and the choice is remembered per browser like the other viewer preferences. API: getStateGroups(), setStateGroupEnabled(key, on) for a role, setStateInstanceEnabled(key, index, on) for one placement. On your ncd0402g1-mpn-led-on.glb the panel reads "LED State" and "Laser Etch MPN (2)" (the MPN and its raised twin share a role, so they are one toggle).

4. No rescaling of light range or intensity. The viewer frames with the camera and never scales content, so the authored 15 mm range and 7.5e-5 cd survive the import untouched; a test asserts both. What it does add: when a light sits under a scaled node, the console says so and names the scale, because that file lights the wrong distance and only its author can fix it.

5. Per-placement light instances. Babylon already instantiates one light per node reference, even when both nodes point at the same glTF light index, so a board that references one LED file many times gets independent lights. There is now a regression test for exactly that: two placements sharing light index 0, switch one off, the other stays lit.

getContentLights() reports what the file brought (name, role, intensity, range, whether it is switched on, whether it is lit, and the position the budget scored it at) so a page can show or drive this without poking at the scene.

Tests: npm run test:lights (35 checks) covers the budget and its camera tracking, the group toggles per role and per placement, the scale warning, photometry left alone, shadows off, and that clearScene disposes content lights instead of leaving them lighting the next model. The whole suite is green. Conventions written up in docs/CONTENT-CONVENTIONS.md under "Lights inside the GLB, and switchable groups".

Colby Knox ·

Live on prod now: the wiki serves viewer 0.8.0 (bundle 20260917b), so component pages get the budget, the group toggles and the rest without any page change.

Colby Knox closed this ·

Log in to reply.