Spaces:
Sleeping
Sleeping
Add kiosk mode with a capture cooldown
Browse filesEnable with ?kiosk=1, optionally ?cooldown=<seconds> (default 180).
After a successful reconstruction the capture controls lock behind a
countdown while the viewer and downloads stay live, then reset for the
next guest. The deadline persists across reloads, staff can shift-click
the countdown to skip it, and kiosk mode hides the example gallery and
project links.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D6bpRHzVDHz3ASLNfRi5TC
- src/demo/server_frontend/app.js +136 -20
- src/demo/server_frontend/index.html +11 -3
- src/demo/server_frontend/styles.css +34 -0
- tests/test_kiosk_frontend.py +44 -0
src/demo/server_frontend/app.js
CHANGED
|
@@ -29,6 +29,8 @@ const zOffset = document.getElementById("zOffset");
|
|
| 29 |
const zOffsetValue = document.getElementById("zOffsetValue");
|
| 30 |
const plyDownload = document.getElementById("plyDownload");
|
| 31 |
const htmlDownload = document.getElementById("htmlDownload");
|
|
|
|
|
|
|
| 32 |
const examplesGrid = document.getElementById("examplesGrid");
|
| 33 |
const exampleCount = document.getElementById("exampleCount");
|
| 34 |
const themeToggle = document.getElementById("themeToggle");
|
|
@@ -50,8 +52,26 @@ const cameraFormats = {
|
|
| 50 |
portrait: { width: 1152, height: 1536 },
|
| 51 |
};
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
const colorScheme = window.matchMedia("(prefers-color-scheme: dark)");
|
| 54 |
-
const requestedTheme =
|
| 55 |
const followsSystemTheme = requestedTheme !== "dark" && requestedTheme !== "light";
|
| 56 |
|
| 57 |
function applyTheme(theme) {
|
|
@@ -106,16 +126,94 @@ function setDownload(link, url, label) {
|
|
| 106 |
}
|
| 107 |
}
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
function setRunning(value) {
|
| 110 |
running = value;
|
| 111 |
if (value) stopCamera();
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
reconstructButton.textContent = value ? "Reconstructing..." : "Reconstruct scene";
|
| 116 |
-
examplesGrid.toggleAttribute("inert",
|
| 117 |
-
bakeZOffset.disabled =
|
| 118 |
-
zOffset.disabled =
|
| 119 |
}
|
| 120 |
|
| 121 |
function sendViewerControl(action, detail = {}) {
|
|
@@ -144,7 +242,7 @@ function selectFile(file, fromCamera = false) {
|
|
| 144 |
imagePreview.hidden = false;
|
| 145 |
chooseImageButton.hidden = true;
|
| 146 |
cameraButton.textContent = fromCamera ? "Retake photo" : "Use camera";
|
| 147 |
-
reconstructButton.disabled = !client;
|
| 148 |
}
|
| 149 |
|
| 150 |
function stopCamera() {
|
|
@@ -160,8 +258,8 @@ function stopCamera() {
|
|
| 160 |
cameraActions.hidden = true;
|
| 161 |
imagePreview.hidden = !selectedFile;
|
| 162 |
chooseImageButton.hidden = Boolean(selectedFile);
|
| 163 |
-
cameraButton.disabled =
|
| 164 |
-
reconstructButton.disabled =
|
| 165 |
}
|
| 166 |
|
| 167 |
function selectedCameraFormat() {
|
|
@@ -281,7 +379,7 @@ async function switchCamera() {
|
|
| 281 |
}
|
| 282 |
|
| 283 |
async function startCamera() {
|
| 284 |
-
if (
|
| 285 |
if (!navigator.mediaDevices?.getUserMedia) {
|
| 286 |
showToast("Camera access is not supported by this browser.", true);
|
| 287 |
return;
|
|
@@ -341,7 +439,7 @@ async function startCamera() {
|
|
| 341 |
true,
|
| 342 |
);
|
| 343 |
} finally {
|
| 344 |
-
cameraButton.disabled =
|
| 345 |
cameraSelect.disabled = running || cameraSelect.options.length < 3;
|
| 346 |
}
|
| 347 |
}
|
|
@@ -426,10 +524,10 @@ async function capturePhoto() {
|
|
| 426 |
imageInput.addEventListener("change", () => selectFile(imageInput.files?.[0]));
|
| 427 |
chooseImageButton.addEventListener("click", () => imageInput.click());
|
| 428 |
imagePreview.addEventListener("click", () => {
|
| 429 |
-
if (!
|
| 430 |
});
|
| 431 |
imagePreview.addEventListener("keydown", (event) => {
|
| 432 |
-
if (!
|
| 433 |
event.preventDefault();
|
| 434 |
imageInput.click();
|
| 435 |
}
|
|
@@ -446,7 +544,14 @@ cameraDistance.addEventListener("input", () => {
|
|
| 446 |
});
|
| 447 |
resetViewButton.addEventListener("click", () => resetViewerControls(true));
|
| 448 |
bakeZOffset.addEventListener("change", () => {
|
| 449 |
-
zOffset.disabled =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
});
|
| 451 |
zOffset.addEventListener("input", () => {
|
| 452 |
zOffsetValue.value = Number(zOffset.value).toFixed(2);
|
|
@@ -468,7 +573,7 @@ navigator.mediaDevices?.addEventListener?.("devicechange", () => {
|
|
| 468 |
for (const eventName of ["dragenter", "dragover"]) {
|
| 469 |
uploadSurface.addEventListener(eventName, (event) => {
|
| 470 |
event.preventDefault();
|
| 471 |
-
if (!
|
| 472 |
});
|
| 473 |
}
|
| 474 |
|
|
@@ -480,7 +585,7 @@ for (const eventName of ["dragleave", "drop"]) {
|
|
| 480 |
}
|
| 481 |
|
| 482 |
uploadSurface.addEventListener("drop", (event) => {
|
| 483 |
-
if (!
|
| 484 |
stopCamera();
|
| 485 |
selectFile(event.dataTransfer?.files?.[0]);
|
| 486 |
}
|
|
@@ -518,7 +623,7 @@ async function loadExamples() {
|
|
| 518 |
image.loading = "lazy";
|
| 519 |
button.append(image);
|
| 520 |
button.addEventListener("click", async () => {
|
| 521 |
-
if (
|
| 522 |
try {
|
| 523 |
const sourceResponse = await fetch(example.source_url);
|
| 524 |
if (!sourceResponse.ok) throw new Error("Could not load the selected example.");
|
|
@@ -534,7 +639,8 @@ async function loadExamples() {
|
|
| 534 |
}
|
| 535 |
|
| 536 |
async function runPipeline() {
|
| 537 |
-
if (!selectedFile || !client ||
|
|
|
|
| 538 |
setRunning(true);
|
| 539 |
cameraDistance.disabled = true;
|
| 540 |
resetViewButton.disabled = true;
|
|
@@ -567,6 +673,7 @@ async function runPipeline() {
|
|
| 567 |
if (!viewer?.url) throw new Error("The viewer export returned no file.");
|
| 568 |
setViewerState("loading", "Initializing 3D viewer", "Loading scene data and waiting for the first rendered frame");
|
| 569 |
viewerFrame.src = `${viewer.url}?v=${Date.now()}`;
|
|
|
|
| 570 |
|
| 571 |
try {
|
| 572 |
const html = resultValue(
|
|
@@ -583,6 +690,7 @@ async function runPipeline() {
|
|
| 583 |
setViewerState("error", "Reconstruction stopped", errorMessage(error));
|
| 584 |
showToast(errorMessage(error), true);
|
| 585 |
} finally {
|
|
|
|
| 586 |
setRunning(false);
|
| 587 |
}
|
| 588 |
}
|
|
@@ -592,7 +700,7 @@ reconstructButton.addEventListener("click", runPipeline);
|
|
| 592 |
async function connect() {
|
| 593 |
try {
|
| 594 |
client = await Client.connect(window.location.origin);
|
| 595 |
-
reconstructButton.disabled = !selectedFile;
|
| 596 |
const template = resultValue(await client.predict("/viewer_template", {}));
|
| 597 |
if (template?.url) viewerPreloader.src = template.url;
|
| 598 |
} catch (error) {
|
|
@@ -602,6 +710,14 @@ async function connect() {
|
|
| 602 |
}
|
| 603 |
}
|
| 604 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 605 |
await Promise.allSettled([
|
| 606 |
loadExamples().catch((error) => {
|
| 607 |
console.error(error);
|
|
|
|
| 29 |
const zOffsetValue = document.getElementById("zOffsetValue");
|
| 30 |
const plyDownload = document.getElementById("plyDownload");
|
| 31 |
const htmlDownload = document.getElementById("htmlDownload");
|
| 32 |
+
const kioskCooldown = document.getElementById("kioskCooldown");
|
| 33 |
+
const kioskCooldownTime = document.getElementById("kioskCooldownTime");
|
| 34 |
const examplesGrid = document.getElementById("examplesGrid");
|
| 35 |
const exampleCount = document.getElementById("exampleCount");
|
| 36 |
const themeToggle = document.getElementById("themeToggle");
|
|
|
|
| 52 |
portrait: { width: 1152, height: 1536 },
|
| 53 |
};
|
| 54 |
|
| 55 |
+
const KIOSK_COOLDOWN_DEFAULT_SECONDS = 180;
|
| 56 |
+
const KIOSK_COOLDOWN_MAX_SECONDS = 3600;
|
| 57 |
+
const KIOSK_COOLDOWN_STORAGE_KEY = "infinisplat:kiosk-cooldown-until";
|
| 58 |
+
const KIOSK_ENABLED_VALUES = new Set(["1", "true", "yes", "on"]);
|
| 59 |
+
const urlParams = new URLSearchParams(window.location.search);
|
| 60 |
+
const kioskMode = KIOSK_ENABLED_VALUES.has((urlParams.get("kiosk") || "").toLowerCase());
|
| 61 |
+
let cooldownUntil = 0;
|
| 62 |
+
let cooldownTotalMs = 0;
|
| 63 |
+
let cooldownTicker = null;
|
| 64 |
+
|
| 65 |
+
function resolveCooldownSeconds(value) {
|
| 66 |
+
const parsed = Number.parseInt(value ?? "", 10);
|
| 67 |
+
if (!Number.isFinite(parsed) || parsed < 0) return KIOSK_COOLDOWN_DEFAULT_SECONDS;
|
| 68 |
+
return Math.min(parsed, KIOSK_COOLDOWN_MAX_SECONDS);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
const kioskCooldownMs = resolveCooldownSeconds(urlParams.get("cooldown")) * 1000;
|
| 72 |
+
|
| 73 |
const colorScheme = window.matchMedia("(prefers-color-scheme: dark)");
|
| 74 |
+
const requestedTheme = urlParams.get("__theme");
|
| 75 |
const followsSystemTheme = requestedTheme !== "dark" && requestedTheme !== "light";
|
| 76 |
|
| 77 |
function applyTheme(theme) {
|
|
|
|
| 126 |
}
|
| 127 |
}
|
| 128 |
|
| 129 |
+
function cooldownRemainingMs() {
|
| 130 |
+
return Math.max(0, cooldownUntil - Date.now());
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
function inputsLocked() {
|
| 134 |
+
return running || cooldownRemainingMs() > 0;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
function formatCountdown(remainingMs) {
|
| 138 |
+
const seconds = Math.ceil(remainingMs / 1000);
|
| 139 |
+
return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
function storedCooldownDeadline() {
|
| 143 |
+
try {
|
| 144 |
+
return Number.parseInt(window.localStorage.getItem(KIOSK_COOLDOWN_STORAGE_KEY) ?? "", 10);
|
| 145 |
+
} catch (error) {
|
| 146 |
+
console.warn("The kiosk cooldown could not be read from storage.", error);
|
| 147 |
+
return Number.NaN;
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
function storeCooldownDeadline(deadline) {
|
| 152 |
+
try {
|
| 153 |
+
if (deadline) window.localStorage.setItem(KIOSK_COOLDOWN_STORAGE_KEY, String(deadline));
|
| 154 |
+
else window.localStorage.removeItem(KIOSK_COOLDOWN_STORAGE_KEY);
|
| 155 |
+
} catch (error) {
|
| 156 |
+
console.warn("The kiosk cooldown could not be persisted.", error);
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
function renderCooldown() {
|
| 161 |
+
const remaining = cooldownRemainingMs();
|
| 162 |
+
if (remaining <= 0) {
|
| 163 |
+
endCooldown();
|
| 164 |
+
return;
|
| 165 |
+
}
|
| 166 |
+
kioskCooldown.hidden = false;
|
| 167 |
+
kioskCooldown.style.setProperty("--cooldown-progress", String(Math.min(1, remaining / cooldownTotalMs)));
|
| 168 |
+
kioskCooldownTime.textContent = formatCountdown(remaining);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
function beginCooldown(durationMs = kioskCooldownMs, deadline = Date.now() + durationMs) {
|
| 172 |
+
if (!kioskMode || durationMs <= 0) return;
|
| 173 |
+
cooldownUntil = deadline;
|
| 174 |
+
cooldownTotalMs = Math.max(durationMs, 1);
|
| 175 |
+
storeCooldownDeadline(deadline);
|
| 176 |
+
window.clearInterval(cooldownTicker);
|
| 177 |
+
cooldownTicker = window.setInterval(renderCooldown, 250);
|
| 178 |
+
renderCooldown();
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
function endCooldown() {
|
| 182 |
+
window.clearInterval(cooldownTicker);
|
| 183 |
+
cooldownTicker = null;
|
| 184 |
+
cooldownUntil = 0;
|
| 185 |
+
cooldownTotalMs = 0;
|
| 186 |
+
storeCooldownDeadline(0);
|
| 187 |
+
kioskCooldown.hidden = true;
|
| 188 |
+
kioskCooldown.style.removeProperty("--cooldown-progress");
|
| 189 |
+
clearSelection();
|
| 190 |
+
setRunning(running);
|
| 191 |
+
showToast("Ready for the next photo.");
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
function clearSelection() {
|
| 195 |
+
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
| 196 |
+
previewUrl = null;
|
| 197 |
+
selectedFile = null;
|
| 198 |
+
imageInput.value = "";
|
| 199 |
+
imagePreview.removeAttribute("src");
|
| 200 |
+
imagePreview.hidden = true;
|
| 201 |
+
chooseImageButton.hidden = false;
|
| 202 |
+
cameraButton.textContent = "Use camera";
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
function setRunning(value) {
|
| 206 |
running = value;
|
| 207 |
if (value) stopCamera();
|
| 208 |
+
const locked = inputsLocked();
|
| 209 |
+
imageInput.disabled = locked;
|
| 210 |
+
chooseImageButton.disabled = locked;
|
| 211 |
+
cameraButton.disabled = locked || !navigator.mediaDevices?.getUserMedia;
|
| 212 |
+
reconstructButton.disabled = locked || !selectedFile || !client;
|
| 213 |
reconstructButton.textContent = value ? "Reconstructing..." : "Reconstruct scene";
|
| 214 |
+
examplesGrid.toggleAttribute("inert", locked);
|
| 215 |
+
bakeZOffset.disabled = locked;
|
| 216 |
+
zOffset.disabled = locked || !bakeZOffset.checked;
|
| 217 |
}
|
| 218 |
|
| 219 |
function sendViewerControl(action, detail = {}) {
|
|
|
|
| 242 |
imagePreview.hidden = false;
|
| 243 |
chooseImageButton.hidden = true;
|
| 244 |
cameraButton.textContent = fromCamera ? "Retake photo" : "Use camera";
|
| 245 |
+
reconstructButton.disabled = !client || inputsLocked();
|
| 246 |
}
|
| 247 |
|
| 248 |
function stopCamera() {
|
|
|
|
| 258 |
cameraActions.hidden = true;
|
| 259 |
imagePreview.hidden = !selectedFile;
|
| 260 |
chooseImageButton.hidden = Boolean(selectedFile);
|
| 261 |
+
cameraButton.disabled = inputsLocked() || !navigator.mediaDevices?.getUserMedia;
|
| 262 |
+
reconstructButton.disabled = inputsLocked() || !selectedFile || !client;
|
| 263 |
}
|
| 264 |
|
| 265 |
function selectedCameraFormat() {
|
|
|
|
| 379 |
}
|
| 380 |
|
| 381 |
async function startCamera() {
|
| 382 |
+
if (inputsLocked() || cameraStream) return;
|
| 383 |
if (!navigator.mediaDevices?.getUserMedia) {
|
| 384 |
showToast("Camera access is not supported by this browser.", true);
|
| 385 |
return;
|
|
|
|
| 439 |
true,
|
| 440 |
);
|
| 441 |
} finally {
|
| 442 |
+
cameraButton.disabled = inputsLocked() || Boolean(cameraStream);
|
| 443 |
cameraSelect.disabled = running || cameraSelect.options.length < 3;
|
| 444 |
}
|
| 445 |
}
|
|
|
|
| 524 |
imageInput.addEventListener("change", () => selectFile(imageInput.files?.[0]));
|
| 525 |
chooseImageButton.addEventListener("click", () => imageInput.click());
|
| 526 |
imagePreview.addEventListener("click", () => {
|
| 527 |
+
if (!inputsLocked()) imageInput.click();
|
| 528 |
});
|
| 529 |
imagePreview.addEventListener("keydown", (event) => {
|
| 530 |
+
if (!inputsLocked() && (event.key === "Enter" || event.key === " ")) {
|
| 531 |
event.preventDefault();
|
| 532 |
imageInput.click();
|
| 533 |
}
|
|
|
|
| 544 |
});
|
| 545 |
resetViewButton.addEventListener("click", () => resetViewerControls(true));
|
| 546 |
bakeZOffset.addEventListener("change", () => {
|
| 547 |
+
zOffset.disabled = inputsLocked() || !bakeZOffset.checked;
|
| 548 |
+
});
|
| 549 |
+
kioskCooldown.addEventListener("click", (event) => {
|
| 550 |
+
if (!event.shiftKey) {
|
| 551 |
+
showToast("Hold shift and click to start the next photo early.");
|
| 552 |
+
return;
|
| 553 |
+
}
|
| 554 |
+
endCooldown();
|
| 555 |
});
|
| 556 |
zOffset.addEventListener("input", () => {
|
| 557 |
zOffsetValue.value = Number(zOffset.value).toFixed(2);
|
|
|
|
| 573 |
for (const eventName of ["dragenter", "dragover"]) {
|
| 574 |
uploadSurface.addEventListener(eventName, (event) => {
|
| 575 |
event.preventDefault();
|
| 576 |
+
if (!inputsLocked()) uploadSurface.classList.add("dragover");
|
| 577 |
});
|
| 578 |
}
|
| 579 |
|
|
|
|
| 585 |
}
|
| 586 |
|
| 587 |
uploadSurface.addEventListener("drop", (event) => {
|
| 588 |
+
if (!inputsLocked()) {
|
| 589 |
stopCamera();
|
| 590 |
selectFile(event.dataTransfer?.files?.[0]);
|
| 591 |
}
|
|
|
|
| 623 |
image.loading = "lazy";
|
| 624 |
button.append(image);
|
| 625 |
button.addEventListener("click", async () => {
|
| 626 |
+
if (inputsLocked()) return;
|
| 627 |
try {
|
| 628 |
const sourceResponse = await fetch(example.source_url);
|
| 629 |
if (!sourceResponse.ok) throw new Error("Could not load the selected example.");
|
|
|
|
| 639 |
}
|
| 640 |
|
| 641 |
async function runPipeline() {
|
| 642 |
+
if (!selectedFile || !client || inputsLocked()) return;
|
| 643 |
+
let reconstructed = false;
|
| 644 |
setRunning(true);
|
| 645 |
cameraDistance.disabled = true;
|
| 646 |
resetViewButton.disabled = true;
|
|
|
|
| 673 |
if (!viewer?.url) throw new Error("The viewer export returned no file.");
|
| 674 |
setViewerState("loading", "Initializing 3D viewer", "Loading scene data and waiting for the first rendered frame");
|
| 675 |
viewerFrame.src = `${viewer.url}?v=${Date.now()}`;
|
| 676 |
+
reconstructed = true;
|
| 677 |
|
| 678 |
try {
|
| 679 |
const html = resultValue(
|
|
|
|
| 690 |
setViewerState("error", "Reconstruction stopped", errorMessage(error));
|
| 691 |
showToast(errorMessage(error), true);
|
| 692 |
} finally {
|
| 693 |
+
if (reconstructed) beginCooldown();
|
| 694 |
setRunning(false);
|
| 695 |
}
|
| 696 |
}
|
|
|
|
| 700 |
async function connect() {
|
| 701 |
try {
|
| 702 |
client = await Client.connect(window.location.origin);
|
| 703 |
+
reconstructButton.disabled = !selectedFile || inputsLocked();
|
| 704 |
const template = resultValue(await client.predict("/viewer_template", {}));
|
| 705 |
if (template?.url) viewerPreloader.src = template.url;
|
| 706 |
} catch (error) {
|
|
|
|
| 710 |
}
|
| 711 |
}
|
| 712 |
|
| 713 |
+
if (kioskMode) {
|
| 714 |
+
const deadline = storedCooldownDeadline();
|
| 715 |
+
if (Number.isFinite(deadline) && deadline > Date.now()) {
|
| 716 |
+
beginCooldown(kioskCooldownMs || deadline - Date.now(), deadline);
|
| 717 |
+
setRunning(false);
|
| 718 |
+
}
|
| 719 |
+
}
|
| 720 |
+
|
| 721 |
await Promise.allSettled([
|
| 722 |
loadExamples().catch((error) => {
|
| 723 |
console.error(error);
|
src/demo/server_frontend/index.html
CHANGED
|
@@ -6,14 +6,18 @@
|
|
| 6 |
<meta name="color-scheme" content="light dark">
|
| 7 |
<title>InfiniSplat</title>
|
| 8 |
<script>
|
| 9 |
-
const
|
|
|
|
| 10 |
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
| 11 |
document.documentElement.dataset.theme =
|
| 12 |
requestedTheme === "dark" || requestedTheme === "light"
|
| 13 |
? requestedTheme
|
| 14 |
: (prefersDark ? "dark" : "light");
|
|
|
|
|
|
|
|
|
|
| 15 |
</script>
|
| 16 |
-
<link rel="stylesheet" href="/infinisplat/assets/styles.css?v=
|
| 17 |
</head>
|
| 18 |
<body>
|
| 19 |
<main class="app-shell">
|
|
@@ -82,6 +86,10 @@
|
|
| 82 |
<button class="camera-button" id="cameraButton" type="button">Use camera</button>
|
| 83 |
<button id="reconstructButton" type="button" disabled>Reconstruct scene</button>
|
| 84 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
</article>
|
| 86 |
|
| 87 |
<article class="tool-panel viewer-panel">
|
|
@@ -133,6 +141,6 @@
|
|
| 133 |
</main>
|
| 134 |
|
| 135 |
<div class="toast" id="toast" role="status" aria-live="polite"></div>
|
| 136 |
-
<script type="module" src="/infinisplat/assets/app.js?v=
|
| 137 |
</body>
|
| 138 |
</html>
|
|
|
|
| 6 |
<meta name="color-scheme" content="light dark">
|
| 7 |
<title>InfiniSplat</title>
|
| 8 |
<script>
|
| 9 |
+
const bootParams = new URLSearchParams(window.location.search);
|
| 10 |
+
const requestedTheme = bootParams.get("__theme");
|
| 11 |
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
| 12 |
document.documentElement.dataset.theme =
|
| 13 |
requestedTheme === "dark" || requestedTheme === "light"
|
| 14 |
? requestedTheme
|
| 15 |
: (prefersDark ? "dark" : "light");
|
| 16 |
+
if (["1", "true", "yes", "on"].includes((bootParams.get("kiosk") || "").toLowerCase())) {
|
| 17 |
+
document.documentElement.dataset.kiosk = "on";
|
| 18 |
+
}
|
| 19 |
</script>
|
| 20 |
+
<link rel="stylesheet" href="/infinisplat/assets/styles.css?v=9">
|
| 21 |
</head>
|
| 22 |
<body>
|
| 23 |
<main class="app-shell">
|
|
|
|
| 86 |
<button class="camera-button" id="cameraButton" type="button">Use camera</button>
|
| 87 |
<button id="reconstructButton" type="button" disabled>Reconstruct scene</button>
|
| 88 |
</div>
|
| 89 |
+
<button class="kiosk-cooldown" id="kioskCooldown" type="button" hidden>
|
| 90 |
+
<span>Next photo in <strong id="kioskCooldownTime">0:00</strong></span>
|
| 91 |
+
<small>Explore and download your scene. Staff: shift-click to start the next photo now.</small>
|
| 92 |
+
</button>
|
| 93 |
</article>
|
| 94 |
|
| 95 |
<article class="tool-panel viewer-panel">
|
|
|
|
| 141 |
</main>
|
| 142 |
|
| 143 |
<div class="toast" id="toast" role="status" aria-live="polite"></div>
|
| 144 |
+
<script type="module" src="/infinisplat/assets/app.js?v=11"></script>
|
| 145 |
</body>
|
| 146 |
</html>
|
src/demo/server_frontend/styles.css
CHANGED
|
@@ -493,6 +493,39 @@ button, input { font: inherit; }
|
|
| 493 |
|
| 494 |
#reconstructButton:disabled { cursor: not-allowed; opacity: 0.55; }
|
| 495 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 496 |
.viewer-shell {
|
| 497 |
position: relative;
|
| 498 |
width: 100%;
|
|
@@ -727,6 +760,7 @@ button, input { font: inherit; }
|
|
| 727 |
.source-panel .panel-heading p { margin-left: 8px; }
|
| 728 |
.panel-content { padding: 9px; }
|
| 729 |
.source-actions, .download-bar, .viewer-tools { padding: 0 9px 9px; }
|
|
|
|
| 730 |
.viewer-tool-row { grid-template-columns: 1fr 44px auto; }
|
| 731 |
.viewer-tool-row > label:first-child { grid-column: 1 / -1; }
|
| 732 |
.export-z-row { grid-template-columns: minmax(0, 1fr) 44px; }
|
|
|
|
| 493 |
|
| 494 |
#reconstructButton:disabled { cursor: not-allowed; opacity: 0.55; }
|
| 495 |
|
| 496 |
+
.kiosk-cooldown {
|
| 497 |
+
display: block;
|
| 498 |
+
width: calc(100% - 24px);
|
| 499 |
+
margin: 0 12px 12px;
|
| 500 |
+
padding: 12px 14px;
|
| 501 |
+
border: 1px solid var(--ready-border);
|
| 502 |
+
border-radius: 6px;
|
| 503 |
+
background-color: var(--ready-bg);
|
| 504 |
+
background-image: linear-gradient(
|
| 505 |
+
to right,
|
| 506 |
+
var(--ready-hover) calc(var(--cooldown-progress, 0) * 100%),
|
| 507 |
+
transparent calc(var(--cooldown-progress, 0) * 100%)
|
| 508 |
+
);
|
| 509 |
+
color: var(--ready-text);
|
| 510 |
+
text-align: center;
|
| 511 |
+
cursor: default;
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
.kiosk-cooldown strong {
|
| 515 |
+
font-size: 1.15em;
|
| 516 |
+
font-variant-numeric: tabular-nums;
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
.kiosk-cooldown small {
|
| 520 |
+
display: block;
|
| 521 |
+
margin-top: 4px;
|
| 522 |
+
color: var(--muted);
|
| 523 |
+
font-size: 12px;
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
:root[data-kiosk="on"] .examples-section,
|
| 527 |
+
:root[data-kiosk="on"] .project-links { display: none; }
|
| 528 |
+
|
| 529 |
.viewer-shell {
|
| 530 |
position: relative;
|
| 531 |
width: 100%;
|
|
|
|
| 760 |
.source-panel .panel-heading p { margin-left: 8px; }
|
| 761 |
.panel-content { padding: 9px; }
|
| 762 |
.source-actions, .download-bar, .viewer-tools { padding: 0 9px 9px; }
|
| 763 |
+
.kiosk-cooldown { width: calc(100% - 18px); margin: 0 9px 9px; }
|
| 764 |
.viewer-tool-row { grid-template-columns: 1fr 44px auto; }
|
| 765 |
.viewer-tool-row > label:first-child { grid-column: 1 / -1; }
|
| 766 |
.export-z-row { grid-template-columns: minmax(0, 1fr) 44px; }
|
tests/test_kiosk_frontend.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
REPO_ROOT = Path(__file__).resolve().parents[1]
|
| 5 |
+
FRONTEND_ROOT = REPO_ROOT / "src/demo/server_frontend"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def test_custom_frontend_exposes_kiosk_cooldown_controls() -> None:
|
| 9 |
+
markup = (FRONTEND_ROOT / "index.html").read_text()
|
| 10 |
+
|
| 11 |
+
assert 'id="kioskCooldown"' in markup
|
| 12 |
+
assert 'id="kioskCooldownTime"' in markup
|
| 13 |
+
assert 'bootParams.get("kiosk")' in markup
|
| 14 |
+
assert 'document.documentElement.dataset.kiosk = "on"' in markup
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def test_kiosk_cooldown_locks_capture_until_the_timer_expires() -> None:
|
| 18 |
+
script = (FRONTEND_ROOT / "app.js").read_text()
|
| 19 |
+
|
| 20 |
+
assert "const KIOSK_COOLDOWN_DEFAULT_SECONDS = 180;" in script
|
| 21 |
+
assert "const KIOSK_COOLDOWN_MAX_SECONDS = 3600;" in script
|
| 22 |
+
assert 'urlParams.get("cooldown")' in script
|
| 23 |
+
assert "return running || cooldownRemainingMs() > 0;" in script
|
| 24 |
+
assert "if (reconstructed) beginCooldown();" in script
|
| 25 |
+
assert "if (inputsLocked() || cameraStream) return;" in script
|
| 26 |
+
assert "if (!selectedFile || !client || inputsLocked()) return;" in script
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def test_kiosk_cooldown_survives_reload_and_allows_staff_override() -> None:
|
| 30 |
+
script = (FRONTEND_ROOT / "app.js").read_text()
|
| 31 |
+
|
| 32 |
+
assert 'const KIOSK_COOLDOWN_STORAGE_KEY = "infinisplat:kiosk-cooldown-until";' in script
|
| 33 |
+
assert "window.localStorage.setItem(KIOSK_COOLDOWN_STORAGE_KEY, String(deadline))" in script
|
| 34 |
+
assert "if (Number.isFinite(deadline) && deadline > Date.now())" in script
|
| 35 |
+
assert "if (!event.shiftKey) {" in script
|
| 36 |
+
assert "clearSelection();" in script
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def test_kiosk_stylesheet_hides_distractions_and_draws_the_countdown() -> None:
|
| 40 |
+
styles = (FRONTEND_ROOT / "styles.css").read_text()
|
| 41 |
+
|
| 42 |
+
assert ".kiosk-cooldown {" in styles
|
| 43 |
+
assert "var(--cooldown-progress, 0)" in styles
|
| 44 |
+
assert ':root[data-kiosk="on"] .examples-section,' in styles
|