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.
Ground rebuild discards consumer styling (needs a hook, or no dispose)
Split out of adom/wiki#60 (@aravk item 3). Filed here rather than on adom/wiki because it is viewer engine work, not wiki work.
Problem
setGroundVisible(true) does not toggle the ground, it rebuilds it. The ground is created inside frameModel(), sized and positioned from the current content bounds, and each call disposes the existing mesh and constructs a fresh PBRMetallicRoughnessMaterial. Any consumer customization of the ground (material, colour, texture, opacity) is silently discarded, not just on an explicit visibility toggle but on every reframe, which happens on load and on layer changes too.
Ask, in AravK's words
Preserve the ground's material and state across visibility toggles, or expose a ground-style hook.
Why it is two different changes
These are worth separating, because one is easy and one is not:
A style hook is straightforward: a
groundMaterialoption, or anonGroundCreated(mesh)callback fired after each rebuild so a consumer can restyle it. This does not stop the rebuild, it just gives the consumer a reliable moment to reapply. Roughly 15 lines.Genuinely preserving arbitrary consumer state means not disposing at all: keeping the mesh across reframes and updating only its size and position. That is a rework of the ground block in
frameModel, and it needs care around the ground being tied tozUpand to content extent, both of which can change between frames.
Option 1 solves the stated need for most consumers and is cheap. Option 2 is the honest fix and is not.
My inclination is to ship the hook first and see whether anyone actually needs the second, since a callback that fires on every rebuild is a complete answer for restyling, and the rebuild itself exists for a real reason: the ground has to track content bounds.