Fix viewer: replace WebSocket with fetch polling
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
parent
c1336c6672
commit
de5dc9a151
|
|
@ -122,17 +122,23 @@ async fn index() -> Html<String> {
|
||||||
|
|
||||||
let pointsMesh = null;
|
let pointsMesh = null;
|
||||||
|
|
||||||
// WebSocket
|
// Poll API for updates (no WebSocket needed)
|
||||||
const ws = new WebSocket(`ws://${location.host}/ws`);
|
async function fetchCloud() {
|
||||||
ws.onmessage = (e) => {
|
try {
|
||||||
const data = JSON.parse(e.data);
|
const resp = await fetch('/api/splats');
|
||||||
if (data.type === 'pointcloud' && data.splats) {
|
const data = await resp.json();
|
||||||
updateSplats(data.splats);
|
if (data.splats) {
|
||||||
document.getElementById('stats').innerHTML =
|
updateSplats(data.splats);
|
||||||
`Points: ${data.points}<br>Splats: ${data.splats.length}<br>FPS: 10`;
|
document.getElementById('stats').innerHTML =
|
||||||
|
`Splats: ${data.count}<br>Timestamp: ${new Date(data.timestamp).toLocaleTimeString()}`;
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
document.getElementById('stats').innerHTML = 'Error: ' + e.message;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
ws.onopen = () => { document.getElementById('stats').innerHTML = 'Connected'; };
|
fetchCloud();
|
||||||
|
setInterval(fetchCloud, 1000); // refresh every second
|
||||||
|
document.getElementById('stats').innerHTML = 'Loading...';
|
||||||
|
|
||||||
function updateSplats(splats) {
|
function updateSplats(splats) {
|
||||||
if (pointsMesh) scene.remove(pointsMesh);
|
if (pointsMesh) scene.remove(pointsMesh);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue