wifi-densepose/ui/services
rUv 5d544126ee
fix(ui): unbreak viz.html — OrbitControls importmap, WS URL, toast NPE (#760) (#773)
* fix(ui): unbreak viz.html — OrbitControls importmap, WS URL, toast NPE (#760)

Three independent bugs were stacking to make ui/viz.html unusable from `main`:

1. Three.js r160 removed `examples/js/OrbitControls.js`, so the script-tag
   load 404'd and `new THREE.OrbitControls(...)` threw. Switch to an
   importmap that pulls the ES module build, then re-expose
   `window.THREE` and `THREE.OrbitControls` so the existing component
   modules (scene.js, body-model.js, …) keep working without a wider
   refactor.

2. The WebSocket client was hardcoded to `ws://localhost:8000/ws/pose`,
   but the sensing-server listens on `--ws-port` (8765 default, 3001 in
   the Docker image) at `/ws/sensing`. Reuse the existing
   `buildSensingWsUrl()` helper from `sensing.service.js` so port
   pairings are handled centrally, and add a `?ws=…` query-string
   override for non-standard setups. The websocket-client.js default is
   also updated to derive from `window.location` instead of the dead
   `:8000/ws/pose` literal.

3. `ToastManager.show()` called `this.container.appendChild(...)` even
   when `init()` had never been called, throwing a TypeError that
   killed the rest of page initialization. Auto-init the container
   lazily on first show (patch from issue reporter).

Closes #760.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(ui): single module script + mutable THREE — OrbitControls validated

Browser validation against the previous commit caught two stacked issues:

1. `import * as THREE from 'three'` returns a frozen Module Namespace
   Object — assignment `THREE.OrbitControls = OrbitControls` silently
   no-ops, so the global never gets the OrbitControls reference.

2. Two separate `<script type="module">` blocks (one installing the
   THREE global, one consuming it via Scene) are independently
   async-resolved. The second can finish dependency loading first and
   call `new THREE.OrbitControls(...)` before the first script has run.

Fixed by spreading the namespace into a plain mutable object and merging
all initialization into a single module script with `await import()` for
component modules. Order is now strictly: import THREE → install
window.THREE → import components → run init().

Validated via agent-browser: page logs `[VIZ] Initialization complete`,
WebSocket targets the correct `ws://127.0.0.1:3001/ws/sensing` endpoint
(derived from buildSensingWsUrl), toast lazy-init confirmed via eval.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-23 10:48:04 -04:00
..
api.service.js feat: Rust sensing server with full DensePose-compatible API 2026-02-28 21:29:45 -05:00
data-processor.js feat: Add Three.js visualization entry point and data processor 2026-02-28 06:29:28 +00:00
health.service.js feat: Sensing-only UI mode with Gaussian splat visualization and Rust migration ADR 2026-02-28 14:37:29 -05:00
model.service.js fix: WebSocket race condition, data source indicators, auto-start pose detection (#96) 2026-03-02 13:47:49 -05:00
pose.service.js fix: WebSocket race condition, data source indicators, auto-start pose detection (#96) 2026-03-02 13:47:49 -05:00
sensing.service.js fix(ui): map sensing websocket port for docker (#572) 2026-05-17 17:32:13 -04:00
stream.service.js Add comprehensive CSS styles for UI components and dark mode support 2025-06-07 13:28:02 +00:00
training.service.js fix: WebSocket race condition, data source indicators, auto-start pose detection (#96) 2026-03-02 13:47:49 -05:00
websocket-client.js fix(ui): unbreak viz.html — OrbitControls importmap, WS URL, toast NPE (#760) (#773) 2026-05-23 10:48:04 -04:00
websocket.service.js fix(ui): map sensing websocket port for docker (#572) 2026-05-17 17:32:13 -04:00