Skip to content

Fixes and custom project inspector dogfooding#89

Open
mavimaec wants to merge 1 commit into
mainfrom
mavimaec/fixes
Open

Fixes and custom project inspector dogfooding#89
mavimaec wants to merge 1 commit into
mainfrom
mavimaec/fixes

Conversation

@mavimaec
Copy link
Copy Markdown

@mavimaec mavimaec commented Jun 2, 2026

Fix WebGL viewer-reuse crash, error modal, and ghost-opacity sync; add inspector demo

Several fixes to the WebGL viewer, surfaced while building a reusable-viewer demo, plus the demo itself.

RenderScene/Scene — fix crash when loading into a reused viewer:

  • RenderScene.removeScene recomputed the combined bounding box with reduce((a, b) => a.union(b)) and no guard. A scene whose geometry isn't built yet returns an undefined box (normal mid-load), so the union threw "Cannot read properties of undefined (reading 'union')" on the 2nd+ sequential load. Filter out undefined boxes before the union.
  • Scene.dispose() called clear(), which re-adds the now-empty scene to the renderer, leaving a stale undefined-box scene registered after unload. That accumulation was the source of the undefined box above. dispose() now removes the scene from the renderer after clearing.

WebGL load errors — stop using the Ultra modal:

  • ComponentLoader.onError reported failures with the Ultra serverFileDownloadingError ("VIM Ultra File Error"), misleading on a WebGL viewer and hiding the real cause. Add react-viewers/errors/webglFileError and use it, surfacing the underlying error message.

Ghost opacity — make it actually apply and configurable:

  • The isolation.ghostOpacity StateRef hydrated from localStorage but the ghost material initialized from its own default, and the value was only pushed to the material on change — so a persisted opacity showed in the UI but never reached the material. Push the initial ghostOpacity into the adapter on mount (mirroring showGhost).
  • Add an optional isolation.ghostOpacity to createViewer settings, seeded into the material once before the StateRefs initialize (a persisted slider value still takes precedence).

Demo — add a custom project inspector (src/customInspector.tsx, routed via main.tsx at ?page=inspector):

  • Custom BIM tree (Room > Category > Family > Type > Element) and BIM info panel replacing the built-ins, reusing a single viewer across loads.
  • Room rows visualize the room volume as a self-owned, transparent THREE mesh built from the room's actual geometry and added straight to the render scene (outside the viewer's tracking), since room geometry is opaque-authored and isRoom visibility is owned by the global showRooms flag. Multiple selected rooms are shown at once.

Also bump version to 1.0.0-beta.2.

…d inspector demo

Several fixes to the WebGL viewer, surfaced while building a reusable-viewer
demo, plus the demo itself.

RenderScene/Scene — fix crash when loading into a reused viewer:
- RenderScene.removeScene recomputed the combined bounding box with
  `reduce((a, b) => a.union(b))` and no guard. A scene whose geometry isn't
  built yet returns an undefined box (normal mid-load), so the union threw
  "Cannot read properties of undefined (reading 'union')" on the 2nd+
  sequential load. Filter out undefined boxes before the union.
- Scene.dispose() called clear(), which re-adds the now-empty scene to the
  renderer, leaving a stale undefined-box scene registered after unload. That
  accumulation was the source of the undefined box above. dispose() now removes
  the scene from the renderer after clearing.

WebGL load errors — stop using the Ultra modal:
- ComponentLoader.onError reported failures with the Ultra
  serverFileDownloadingError ("VIM Ultra File Error"), misleading on a WebGL
  viewer and hiding the real cause. Add react-viewers/errors/webglFileError and
  use it, surfacing the underlying error message.

Ghost opacity — make it actually apply and configurable:
- The isolation.ghostOpacity StateRef hydrated from localStorage but the ghost
  material initialized from its own default, and the value was only pushed to
  the material on change — so a persisted opacity showed in the UI but never
  reached the material. Push the initial ghostOpacity into the adapter on mount
  (mirroring showGhost).
- Add an optional isolation.ghostOpacity to createViewer settings, seeded into
  the material once before the StateRefs initialize (a persisted slider value
  still takes precedence).

Demo — add a custom project inspector (src/customInspector.tsx, routed via
main.tsx at ?page=inspector):
- Custom BIM tree (Room > Category > Family > Type > Element) and BIM info
  panel replacing the built-ins, reusing a single viewer across loads.
- Room rows visualize the room volume as a self-owned, transparent THREE mesh
  built from the room's actual geometry and added straight to the render scene
  (outside the viewer's tracking), since room geometry is opaque-authored and
  isRoom visibility is owned by the global showRooms flag. Multiple selected
  rooms are shown at once.

Also bump version to 1.0.0-beta.2.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mavimaec mavimaec requested a review from vim-sroberge as a code owner June 2, 2026 03:04
Copy link
Copy Markdown
Collaborator

@vim-sroberge vim-sroberge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks Martin, great changes. And it's nice with the comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants