mirror of
https://github.com/ruvnet/RuView
synced 2026-08-10 20:31:42 +00:00
feat(pointcloud): integrate ESP32 CSI as optional data stream from hosted viewer
The hosted GitHub Pages viewer can now act as a thin client for a locally-running ruview-pointcloud serve instance — flip a button, the ESP32's CSI fusion (camera depth + WiFi CSI + mmWave) renders inside the same Three.js scene that previously only showed the face mesh demo. No clone, no rebuild, no toolchain on the visitor's side. Server (stream.rs): - Add tower_http::cors::CorsLayer with a deliberate allowlist: https://ruvnet.github.io, http://localhost:*, http://127.0.0.1:*, and 'null' (for file:// origins). Anything else is denied — not a wildcard CORS. Modern browsers (Chrome 94+, Firefox 116+, Safari 16.4+) treat 127.0.0.1 as a "potentially trustworthy" origin so HTTPS Pages → HTTP loopback is permitted. The new layer wraps the existing /api/cloud, /api/splats, /api/status, /health routes. - Cargo.toml: pull in workspace tower-http (cors feature already on). Viewer: - New "📡 Connect ESP32…" CTA bottom-right. Clicking prompts for a ruview-pointcloud serve URL (default http://127.0.0.1:9880), persists the last-used value in localStorage, and reloads with ?backend=<url> so the existing remote-mode fetch path takes over. When already connected the button toggles to "disconnect" and reloads back to the demo. - Reuses the existing transport selector — no new code path to maintain. The face mesh / synthetic demo render path is unaffected; this is purely an additive UI affordance over the ?backend= query. Docs: - ADR-094 §2.3 expanded with the local-ESP32 workflow and the CORS posture rationale. - Workflow README documents ?backend=http://127.0.0.1:9880 as the intended local-ESP32 path. Tests: cargo test -p wifi-densepose-pointcloud → 15/15 passed. Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
#cam-cta { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); padding: 10px 18px; background: #e8a634; color: #0a0a0a; border: none; border-radius: 4px; font-family: monospace; font-size: 14px; font-weight: bold; cursor: pointer; z-index: 10; }
|
||||
#cam-cta:hover { background: #ffc04d; }
|
||||
#cam-cta.hidden { display: none; }
|
||||
#esp-cta { position: absolute; bottom: 16px; right: 16px; padding: 8px 14px; background: transparent; color: #e8a634; border: 1px solid #e8a634; border-radius: 4px; font-family: monospace; font-size: 12px; cursor: pointer; z-index: 10; }
|
||||
#esp-cta:hover { background: rgba(232, 166, 52, 0.12); }
|
||||
#esp-cta.connected { background: #4f4; color: #0a0a0a; border-color: #4f4; }
|
||||
.live { color: #4f4; } .demo { color: #f44; }
|
||||
.face { color: #4cf; }
|
||||
.section { margin-top: 6px; padding-top: 6px; border-top: 1px solid #333; }
|
||||
@@ -32,6 +35,7 @@
|
||||
<div id="stats">Loading...</div>
|
||||
</div>
|
||||
<button id="cam-cta">▶ Project Subject — render your face into the Vault</button>
|
||||
<button id="esp-cta" title="Stream live CSI from a local ruview-pointcloud serve instance (e.g. http://127.0.0.1:9880)">📡 Connect ESP32…</button>
|
||||
<script>
|
||||
var scene = new THREE.Scene();
|
||||
scene.background = new THREE.Color(0x0a0a0a);
|
||||
@@ -600,6 +604,42 @@
|
||||
});
|
||||
})();
|
||||
|
||||
// Wire the ESP32 backend CTA: prompts for a ruview-pointcloud serve URL,
|
||||
// persists last-used value in localStorage, and reloads with the
|
||||
// ?backend=<url> query so the existing remote-mode path takes over.
|
||||
// Disconnect by clicking again when already connected.
|
||||
(function wireEspCta() {
|
||||
var btn = document.getElementById("esp-cta");
|
||||
if (!btn) return;
|
||||
var connected = backendArg.startsWith("http");
|
||||
if (connected) {
|
||||
btn.classList.add("connected");
|
||||
btn.textContent = "📡 ESP32 connected · disconnect";
|
||||
}
|
||||
btn.addEventListener("click", function() {
|
||||
if (connected) {
|
||||
// Strip ?backend= from current URL and reload — return to demo.
|
||||
var u = new URL(window.location.href);
|
||||
u.searchParams.delete("backend");
|
||||
window.location.href = u.toString();
|
||||
return;
|
||||
}
|
||||
var stored;
|
||||
try { stored = localStorage.getItem("ruview.backendUrl"); } catch (_) { stored = null; }
|
||||
var def = stored || "http://127.0.0.1:9880";
|
||||
var url = window.prompt(
|
||||
"Enter the ruview-pointcloud serve URL (run `ruview-pointcloud serve` locally with your ESP32 streaming CSI to UDP port 3333):",
|
||||
def
|
||||
);
|
||||
if (!url) return;
|
||||
url = url.replace(/\/+$/, "");
|
||||
try { localStorage.setItem("ruview.backendUrl", url); } catch (_) {}
|
||||
var u2 = new URL(window.location.href);
|
||||
u2.searchParams.set("backend", url);
|
||||
window.location.href = u2.toString();
|
||||
});
|
||||
})();
|
||||
|
||||
fetchCloud();
|
||||
setInterval(fetchCloud, 100); // 10 Hz — denser updates so face mesh feels live and the spiral animates smoothly
|
||||
|
||||
|
||||
Reference in New Issue
Block a user