-
fix(ui): unbreak viz.html — OrbitControls importmap, WS URL, toast NPE (#760) (#773)
发布于
2026-05-23 14:48:04 +00:00 - 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:-
Three.js r160 removed
examples/js/OrbitControls.js, so the script-tag
load 404'd andnew THREE.OrbitControls(...)threw. Switch to an
importmap that pulls the ES module build, then re-expose
window.THREEandTHREE.OrbitControlsso the existing component
modules (scene.js, body-model.js, …) keep working without a wider
refactor. -
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 fromsensing.service.jsso 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 fromwindow.locationinstead of the dead
:8000/ws/poseliteral. -
ToastManager.show()calledthis.container.appendChild(...)even
wheninit()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:
-
import * as THREE from 'three'returns a frozen Module Namespace
Object — assignmentTHREE.OrbitControls = OrbitControlssilently
no-ops, so the global never gets the OrbitControls reference. -
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
callnew 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 withawait 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 correctws://127.0.0.1:3001/ws/sensingendpoint
(derived from buildSensingWsUrl), toast lazy-init confirmed via eval.Co-Authored-By: claude-flow ruv@ruv.net
下载附件