File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed
rust-port/wifi-densepose-rs/crates/wifi-densepose-pointcloud/src Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -122,17 +122,23 @@ async fn index() -> Html<String> {
122122
123123 let pointsMesh = null;
124124
125- // WebSocket
126- const ws = new WebSocket(`ws://${location.host}/ws`);
127- ws.onmessage = (e) => {
128- const data = JSON.parse(e.data);
129- if (data.type === 'pointcloud' && data.splats) {
130- updateSplats(data.splats);
131- document.getElementById('stats').innerHTML =
132- `Points: ${data.points}<br>Splats: ${data.splats.length}<br>FPS: 10`;
125+ // Poll API for updates (no WebSocket needed)
126+ async function fetchCloud() {
127+ try {
128+ const resp = await fetch('/api/splats');
129+ const data = await resp.json();
130+ if (data.splats) {
131+ updateSplats(data.splats);
132+ document.getElementById('stats').innerHTML =
133+ `Splats: ${data.count}<br>Timestamp: ${new Date(data.timestamp).toLocaleTimeString()}`;
134+ }
135+ } catch(e) {
136+ document.getElementById('stats').innerHTML = 'Error: ' + e.message;
133137 }
134- };
135- ws.onopen = () => { document.getElementById('stats').innerHTML = 'Connected'; };
138+ }
139+ fetchCloud();
140+ setInterval(fetchCloud, 1000); // refresh every second
141+ document.getElementById('stats').innerHTML = 'Loading...';
136142
137143 function updateSplats(splats) {
138144 if (pointsMesh) scene.remove(pointsMesh);
You can’t perform that action at this time.
0 commit comments