The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Splat viewer: open upright and framed, turn freely on every device
Adarsh4af53bdb367b
diff --git a/src/components/model3d/model-card.tsx b/src/components/model3d/model-card.tsxindex 3b89b2fa..36268c0d 100644--- a/src/components/model3d/model-card.tsx+++ b/src/components/model3d/model-card.tsx@@ -24,7 +24,7 @@ import { PlaceholderChip } from "@/components/demo-mode";import { NextSteps } from "@/components/nav/next-steps";import { recordableType, recordTurntable } from "./turntable";import { hasWebgl2, SplatViewer, useReducedMotion } from "./splat-viewer";-import { FALLBACK_TEXT, hazeCutoffFor } from "@/lib/av/splat-view";+import { FALLBACK_TEXT, hazeCutoffFor, splatPose } from "@/lib/av/splat-view";import { TurnChips } from "./turn-chips";import { OwnSetupChip, useOwnSetupPress } from "@/components/own-setup";import { useModel3dSetup } from "./own-setups";@@ -320,6 +320,7 @@ export function ModelCard({poster={view.poster}name={name}defaultCutoff={hazeCutoffFor(g.modelId)}+ pose={splatPose(g, view.splat)}label={`the ${label} splat`}autoFocus={focusLook}onUnavailable={(note) => {diff --git a/src/components/model3d/splat-engine.ts b/src/components/model3d/splat-engine.tsindex ccd19c04..e29dafdd 100644--- a/src/components/model3d/splat-engine.ts+++ b/src/components/model3d/splat-engine.ts@@ -3,6 +3,7 @@import { dyno, SparkRenderer, SplatFileType, SplatMesh } from "@sparkjsdev/spark";import * as THREE from "three";import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";+import { homeView, subjectBounds, type SplatBounds, type SplatPose } from "@/lib/av/splat-view";/*** The splat viewer's three.js side (idol-4): Spark (@sparkjsdev/spark 2.3.1, MIT, World Labs) draws the Gaussians@@ -27,6 +28,15 @@ export class SplatEngine {private mesh: SplatMesh | null = null;private cutoff = dyno.dynoFloat(0);private home = { position: new THREE.Vector3(0, 0, 3), target: new THREE.Vector3() };+ /** A sample of the splat's centres and opacities in its own frame, to frame it again after a turn. */+ private sample: { centers: Float32Array; opacities: Float32Array } | null = null;+ private bounds: SplatBounds | null = null;+ /** The yaw the subject faces (splatPose): where the camera starts. */+ private frontYaw = 0;+ /** The stage's size and the bar's height over its foot, in CSS px. */+ private view = { width: 0, height: 0, inset: 0 };+ /** The camera is where Reset view puts it: a resize frames the splat again for the stage's new shape. */+ private atHome = true;private frame = 0;/** Keep drawing until then (performance.now()): Spark builds, sorts and uploads over a few frames after a change. */private until = 0;@@ -39,24 +49,35 @@ export class SplatEngine {if (!this.disposed) this.onContextLost?.();};- /** onContextLost: the browser took the WebGL context away (too many open, a GPU reset) while this was showing. */+ /**+ * onContextLost: the browser took the WebGL context away (too many open, a GPU reset) while this was showing.+ * coarse: a phone or tablet, which draws each Gaussian a little tighter (less overdraw in every frame).+ */constructor(private canvas: HTMLCanvasElement,private onContextLost?: () => void,+ { coarse = false }: { coarse?: boolean } = {},) {canvas.addEventListener("webglcontextlost", this.onLost);this.renderer = new THREE.WebGLRenderer({ canvas, antialias: false, alpha: false, powerPreference: "high-performance" });- this.spark = new SparkRenderer({ renderer: this.renderer, onDirty: () => this.requestRender() });+ this.spark = new SparkRenderer({ renderer: this.renderer, onDirty: () => this.requestRender(), ...(coarse ? { maxStdDev: Math.sqrt(6) } : {}) });this.scene.add(this.spark);this.controls = new OrbitControls(this.camera, canvas);this.controls.enableDamping = true;this.controls.dampingFactor = 0.12;this.controls.zoomToCursor = false;+ // One finger turns it; two pinch to zoom and drag to move it.+ this.controls.touches = { ONE: THREE.TOUCH.ROTATE, TWO: THREE.TOUCH.DOLLY_PAN };this.controls.addEventListener("change", () => this.requestRender());+ this.controls.addEventListener("start", () => void (this.atHome = false));}/** Fetch the file (abortable, its size checked against maxBytes first), then build the splat. */- async load(url: string, format: string, { signal, maxBytes, onProgress }: { signal?: AbortSignal; maxBytes?: number; onProgress?: (p: number) => void } = {}): Promise<SplatLoadInfo> {+ async load(+ url: string,+ format: string,+ { signal, maxBytes, onProgress, pose }: { signal?: AbortSignal; maxBytes?: number; onProgress?: (p: number) => void; pose?: SplatPose } = {},+ ): Promise<SplatLoadInfo> {const bytes = await fetchSplat(url, { signal, maxBytes, onProgress });if (this.disposed || signal?.aborted) throw new DOMException("Aborted", "AbortError");const mesh = await buildSplatMesh(bytes, format, this.cutoff);@@ -64,42 +85,76 @@ export class SplatEngine {mesh.dispose();throw new DOMException("Aborted", "AbortError");}+ // A y-down file (splatPose): half a turn about x stands it upright.+ if (pose?.yDown) mesh.quaternion.set(1, 0, 0, 0);+ this.frontYaw = pose?.frontYaw ?? 0;this.mesh = mesh;+ this.sample = sampleSplats(mesh);this.scene.add(mesh);- this.frameObject(mesh.getBoundingBox(true));+ this.frameSubject();this.requestRender(1500);return { splats: mesh.packedSplats?.numSplats ?? 0, bytes: bytes.byteLength };}- /** Point the camera at the splat from the front, a little above, far enough to see all of it. */- private frameObject(box: THREE.Box3) {- const center = box.isEmpty() ? new THREE.Vector3() : box.getCenter(new THREE.Vector3());- const size = box.isEmpty() ? 2 : Math.max(...box.getSize(new THREE.Vector3()).toArray(), 0.01);- const distance = (size * 0.62) / Math.tan(THREE.MathUtils.degToRad(this.camera.fov / 2));- this.home.target.copy(center);- this.home.position.copy(center).add(new THREE.Vector3(0, size * 0.18, distance));- this.camera.near = Math.max(distance / 200, 0.001);- this.camera.far = distance * 50;- this.camera.updateProjectionMatrix();- this.controls.minDistance = size * 0.25;- this.controls.maxDistance = distance * 6;+ /** Measure the splat as it stands now (its turn included), then look at it from the front. */+ private frameSubject() {+ const mesh = this.mesh;+ if (!mesh) return;+ mesh.updateMatrixWorld(true);+ let bounds: SplatBounds | null = null;+ if (this.sample) {+ const { centers, opacities } = this.sample;+ const world = new Float32Array(centers.length);+ const v = new THREE.Vector3();+ for (let i = 0; i < centers.length; i += 3) {+ v.set(centers[i], centers[i + 1], centers[i + 2]).applyMatrix4(mesh.matrixWorld);+ world[i] = v.x;+ world[i + 1] = v.y;+ world[i + 2] = v.z;+ }+ bounds = subjectBounds(world, opacities);+ }+ if (!bounds) {+ const box = mesh.getBoundingBox(true).applyMatrix4(mesh.matrixWorld);+ bounds = box.isEmpty() ? { min: [-1, -1, -1], max: [1, 1, 1] } : { min: [box.min.x, box.min.y, box.min.z], max: [box.max.x, box.max.y, box.max.z] };+ }+ this.bounds = bounds;+ this.placeHome();this.reset();}+ /** Where Reset view goes for the stage's current shape. */+ private placeHome() {+ if (!this.bounds) return;+ const { height, inset } = this.view;+ // With the bar's offset on, the subject fits the part of the taller frame above the bar.+ const room = this.camera.view?.enabled ? (height - inset) / (height + inset) : 1;+ const view = homeView(this.bounds, this.camera.fov, this.camera.aspect, { frontYaw: this.frontYaw, room });+ this.home.target.fromArray(view.target);+ this.home.position.fromArray(view.position);+ this.camera.near = Math.max(view.distance / 200, 0.001);+ this.camera.far = view.distance * 50;+ this.camera.updateProjectionMatrix();+ this.controls.minDistance = view.size * 0.15;+ this.controls.maxDistance = view.distance * 6;+ }+reset() {this.camera.position.copy(this.home.position);this.controls.target.copy(this.home.target);+ // Without damping for this one update: a glide left over from a drag would carry the camera off home.+ this.controls.enableDamping = false;this.controls.update();+ this.controls.enableDamping = true;+ this.atHome = true;this.requestRender();}- /** Turn the splat over (a file saved y-down shows upside down). */+ /** Turn the splat over (a file saved the other way up shows upside down), and frame it again. */flip() {if (!this.mesh) return;this.mesh.rotateX(Math.PI);- this.mesh.updateMatrixWorld();- const box = this.mesh.getBoundingBox(true).applyMatrix4(this.mesh.matrixWorld);- this.frameObject(box);+ this.frameSubject();}/** Orbit by angles in radians (the arrow keys), around the target. */@@ -109,6 +164,7 @@ export class SplatEngine {s.theta -= azimuth;s.phi = THREE.MathUtils.clamp(s.phi - polar, 0.05, Math.PI - 0.05);this.camera.position.copy(this.controls.target).add(new THREE.Vector3().setFromSpherical(s));+ this.atHome = false;this.controls.update();this.requestRender();}@@ -118,6 +174,7 @@ export class SplatEngine {const offset = this.camera.position.clone().sub(this.controls.target);const d = THREE.MathUtils.clamp(offset.length() * factor, this.controls.minDistance, this.controls.maxDistance);this.camera.position.copy(this.controls.target).add(offset.setLength(d));+ this.atHome = false;this.controls.update();this.requestRender();}@@ -137,15 +194,61 @@ export class SplatEngine {if (!width || !height) return;this.renderer.setPixelRatio(dpr);this.renderer.setSize(width, height, false);- this.camera.aspect = width / height;+ this.view.width = width;+ this.view.height = height;+ this.applyView();+ }++ /**+ * The height (CSS px) the controls bar covers at the stage's foot: the view centres the subject in the space above+ * it, so the bar never sits on the subject at home (it still draws behind the bar, the stage stays whole).+ */+ setBottomInset(px: number) {+ const inset = Math.max(0, Math.round(px));+ if (inset === this.view.inset) return;+ this.view.inset = inset;+ this.applyView();+ }++ /** The projection for the stage and the bar: a taller frame whose top `inset` px are off the stage. */+ private applyView() {+ const { width, height, inset } = this.view;+ if (!width || !height) return;+ // A drag the stage's height turns the splat once round; a small stage (a card on a phone) turns it slower.+ this.controls.rotateSpeed = Math.min(1, Math.max(0.5, height / 520));+ if (inset > 0 && inset < height / 2) {+ this.camera.aspect = width / (height + inset);+ this.camera.setViewOffset(width, height + inset, 0, inset, width, height);+ } else {+ this.camera.aspect = width / height;+ this.camera.clearViewOffset();+ }this.camera.updateProjectionMatrix();+ // Reset view fits the new shape, and a view nobody has moved yet follows it (the stage settling, a phone turning).+ this.placeHome();+ if (this.atHome && this.bounds) this.reset();this.requestRender();}/** The current view as a PNG, at the canvas's own size (rendered and read in the same task). */capture(): Promise<Blob> {+ // The still has no bar over it: the subject at the centre of the whole frame.+ const offset = this.camera.view?.enabled;+ if (offset) {+ this.camera.clearViewOffset();+ this.camera.aspect = this.view.width / this.view.height;+ this.camera.updateProjectionMatrix();+ }this.render();- return new Promise((resolve, reject) => this.canvas.toBlob((b) => (b ? resolve(b) : reject(new Error("Couldn't save the still"))), "image/png"));+ const still = new Promise<Blob>((resolve, reject) => this.canvas.toBlob((b) => (b ? resolve(b) : reject(new Error("Couldn't save the still"))), "image/png"));+ if (offset) {+ const { width, height, inset } = this.view;+ this.camera.aspect = width / (height + inset);+ this.camera.setViewOffset(width, height + inset, 0, inset, width, height);+ this.camera.updateProjectionMatrix();+ this.requestRender();+ }+ return still;}/** Draw on the next frame, and keep drawing for `settleMs` (Spark finishing its work), or while the camera glides. */@@ -182,6 +285,34 @@ export class SplatEngine {}}+/** At most this many Gaussians are measured to frame a splat: enough for its outline, quick on a phone. */+const SAMPLE_MAX = 65_536;++/** Every k-th Gaussian's centre and opacity, in the splat's own frame (at most SAMPLE_MAX of them). */+function sampleSplats(mesh: SplatMesh): { centers: Float32Array; opacities: Float32Array } | null {+ const splats = mesh.packedSplats;+ const total = splats?.numSplats ?? 0;+ if (!splats || !total) return null;+ const step = Math.max(1, Math.ceil(total / SAMPLE_MAX));+ const n = Math.ceil(total / step);+ const centers = new Float32Array(n * 3);+ const opacities = new Float32Array(n);+ let k = 0;+ try {+ splats.forEachSplat((i, center, _scales, _quaternion, opacity) => {+ if (i % step || k >= n) return;+ centers[k * 3] = center.x;+ centers[k * 3 + 1] = center.y;+ centers[k * 3 + 2] = center.z;+ opacities[k] = opacity;+ k++;+ });+ } catch {+ return null;+ }+ return k ? { centers: centers.subarray(0, k * 3), opacities: opacities.subarray(0, k) } : null;+}+/** Fetch a splat file (abortable; refused past maxBytes, by its length or as it streams). */export async function fetchSplat(url: string, { signal, maxBytes, onProgress }: { signal?: AbortSignal; maxBytes?: number; onProgress?: (p: number) => void } = {}): Promise<Uint8Array> {const res = await fetch(url, { signal });diff --git a/src/components/model3d/splat-viewer.tsx b/src/components/model3d/splat-viewer.tsxindex 85f4764c..273c1548 100644--- a/src/components/model3d/splat-viewer.tsx+++ b/src/components/model3d/splat-viewer.tsx@@ -9,7 +9,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popoverimport { Slider } from "@/components/ui/slider";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { uploadFile, useViewer } from "@/lib/api";-import { backgroundColor, FALLBACK_TEXT, HAZE_MAX, HAZE_STEP, SPLAT_BACKGROUNDS, SPLAT_MAX_BYTES, stillFileName, type SplatBackground } from "@/lib/av/splat-view";+import { backgroundColor, DOUBLE_TAP, FALLBACK_TEXT, HAZE_MAX, HAZE_STEP, SPLAT_BACKGROUNDS, SPLAT_MAX_BYTES, stillFileName, type SplatBackground, type SplatPose } from "@/lib/av/splat-view";import { toastError } from "@/lib/refusals";import { cn } from "@/lib/utils";import type { SplatEngine } from "./splat-engine";@@ -45,15 +45,36 @@ export function hasWebgl2(): boolean {return webgl2;}-const isCoarse = () => typeof window !== "undefined" && window.matchMedia("(pointer: coarse)").matches;+const COARSE = "(pointer: coarse)";+const isCoarse = () => typeof window !== "undefined" && window.matchMedia(COARSE).matches;++/** Whether the main pointer is a finger (false until hydrated). */+function useCoarsePointer(): boolean {+ return useSyncExternalStore(+ (cb) => {+ const mq = window.matchMedia(COARSE);+ mq.addEventListener("change", cb);+ return () => mq.removeEventListener("change", cb);+ },+ isCoarse,+ () => false,+ );+}++/** The device pixel ratio the splat draws at: up to 2 on a computer, 1.5 on a phone (each pixel costs on a small GPU). */+const pixelRatio = (coarse: boolean) => Math.min(window.devicePixelRatio || 1, coarse ? 1.5 : 2);++/** A stage under this size (a phone, a short landscape screen) keeps the bar to one row and the haze slider in a popover. */+const COMPACT = { width: 600, height: 460 };type Status = "loading" | "ready" | "too-big" | "error";/**- * Look around a Gaussian splat (.spz / .ply / .ksplat): drag to turn it, pinch or scroll to zoom, the arrow keys and- * + / − from the keyboard, Reset view, a light / grey / dark background, "Hide faint haze" (an opacity cut-off) and- * "Save a still" to the Library. The renderer (Spark on three.js) loads only when this mounts; the poster shows- * until the splat is drawn, and a file the device can't take leaves the poster with a note.+ * Look around a Gaussian splat (.spz / .ply / .ksplat): drag to turn it, pinch or scroll to zoom, two fingers (or a+ * right drag) to move it, a double tap to reset, the arrow keys and + / − from the keyboard, Reset view, a light /+ * grey / dark background, "Hide faint haze" (an opacity cut-off) and "Save a still" to the Library. The renderer+ * (Spark on three.js) loads only when this mounts; the poster shows until the splat is drawn, and a file the device+ * can't take leaves the poster with a note.*/export function SplatViewer({url,@@ -61,6 +82,7 @@ export function SplatViewer({poster,name,defaultCutoff,+ pose,tone = "card",label = "the splat",autoFocus = false,@@ -71,6 +93,8 @@ export function SplatViewer({poster?: string;name: string;defaultCutoff: number;+ /** How the file stands (splatPose): the viewer stands it upright and starts in front of it. */+ pose?: SplatPose;/** "card": compact controls on a result card; "panel": the full-screen viewer's dark stage. */tone?: "card" | "panel";label?: string;@@ -79,6 +103,7 @@ export function SplatViewer({onUnavailable?: (reason: string) => void;}) {const [canvas, setCanvas] = useState<HTMLCanvasElement | null>(null);+ const rootRef = useRef<HTMLDivElement>(null);const stageRef = useRef<HTMLDivElement>(null);const engineRef = useRef<SplatEngine | null>(null);const [status, setStatus] = useState<Status>("loading");@@ -87,6 +112,8 @@ export function SplatViewer({const { resolvedTheme } = useTheme();const [background, setBackground] = useState<SplatBackground>(() => (tone === "panel" ? "dark" : resolvedTheme === "dark" ? "dark" : "light"));const [saving, setSaving] = useState(false);+ const [compact, setCompact] = useState(false);+ const coarse = useCoarsePointer();// "Save a still" waits until who is viewing is known: a guest can't save (the upload would be refused).const viewer = useViewer().data;const canSave = !!viewer && !(viewer.publicSignup && !viewer.signedIn);@@ -94,6 +121,8 @@ export function SplatViewer({const onUnavailableRef = useRef(onUnavailable);useEffect(() => void (onUnavailableRef.current = onUnavailable));const cutoffRef = useRef(cutoff);+ const yDown = pose?.yDown ?? false;+ const frontYaw = pose?.frontYaw ?? 0;const backgroundRef = useRef(background);// Load Spark and the file (again for another file).@@ -105,19 +134,23 @@ export function SplatViewer({import("./splat-engine").then(async ({ SplatEngine, SplatTooBigError }) => {if (ctl.signal.aborted) return;- eng = new SplatEngine(canvas, () => {- // The browser took the WebGL context back (too many open, or the GPU reset): show the fallback.- if (ctl.signal.aborted) return;- setStatus("error");- onUnavailableRef.current?.("The 3D view stopped here. Open it again, or download the file to look around it in a splat viewer.");- });+ eng = new SplatEngine(+ canvas,+ () => {+ // The browser took the WebGL context back (too many open, or the GPU reset): show the fallback.+ if (ctl.signal.aborted) return;+ setStatus("error");+ onUnavailableRef.current?.("The 3D view stopped here. Open it again, or download the file to look around it in a splat viewer.");+ },+ { coarse },+ );engineRef.current = eng;const el = stageRef.current;- if (el) eng.resize(el.clientWidth, el.clientHeight, Math.min(window.devicePixelRatio || 1, coarse ? 1.5 : 2));+ if (el) eng.resize(el.clientWidth, el.clientHeight, pixelRatio(coarse));eng.setBackground(backgroundColor(backgroundRef.current));eng.setCutoff(cutoffRef.current);try {- await eng.load(url, format, { signal: ctl.signal, maxBytes: coarse ? SPLAT_MAX_BYTES.coarse : SPLAT_MAX_BYTES.fine, onProgress: setProgress });+ await eng.load(url, format, { signal: ctl.signal, maxBytes: coarse ? SPLAT_MAX_BYTES.coarse : SPLAT_MAX_BYTES.fine, onProgress: setProgress, pose: { yDown, frontYaw } });if (!ctl.signal.aborted) setStatus("ready");} catch (e) {if (ctl.signal.aborted) return;@@ -137,15 +170,48 @@ export function SplatViewer({eng?.dispose();engineRef.current = null;};- }, [canvas, url, format]);+ }, [canvas, url, format, yDown, frontYaw]);useEffect(() => {const el = stageRef.current;if (!el) return;- const coarse = isCoarse();- const ro = new ResizeObserver(() => engineRef.current?.resize(el.clientWidth, el.clientHeight, Math.min(window.devicePixelRatio || 1, coarse ? 1.5 : 2)));+ const ro = new ResizeObserver(() => {+ const w = el.clientWidth;+ const h = el.clientHeight;+ if (w && h) setCompact(w < COMPACT.width || h < COMPACT.height);+ engineRef.current?.resize(w, h, pixelRatio(isCoarse()));+ });+ ro.observe(el);+ return () => ro.disconnect();+ }, []);++ // The bar over the stage's foot: the view centres the subject in the space above it.+ const [bar, setBar] = useState<HTMLDivElement | null>(null);+ useEffect(() => {+ const el = stageRef.current;+ if (!el || !bar) {+ engineRef.current?.setBottomInset(0);+ return;+ }+ // Offsets, not client rects: the dialog's opening scale would skew a rect.+ const measure = () => engineRef.current?.setBottomInset(el.clientHeight - bar.offsetTop + 6);+ const ro = new ResizeObserver(measure);+ ro.observe(bar);ro.observe(el);+ measure();return () => ro.disconnect();+ }, [bar]);++ // iOS Safari zooms the page on a pinch even where touch-action is none: its own gesture events stop that here.+ useEffect(() => {+ const el = rootRef.current;+ if (!el) return;+ const stop = (e: Event) => e.preventDefault();+ const names = ["gesturestart", "gesturechange", "gestureend"];+ for (const n of names) el.addEventListener(n, stop, { passive: false });+ return () => {+ for (const n of names) el.removeEventListener(n, stop);+ };}, []);useEffect(() => {@@ -156,9 +222,9 @@ export function SplatViewer({backgroundRef.current = background;engineRef.current?.setBackground(backgroundColor(background));}, [background]);- // The stage takes ArrowLeft / ArrowRight only once the user has reached for it (tabbed to it, pressed on it, used- // one of its keys, or chose to open it). A dialog that focuses it by itself on opening leaves those two keys to- // the page, so the full-screen viewer keeps browsing the results.+ // The viewer takes ArrowLeft / ArrowRight only once the user has reached for it (tabbed to it, pressed on it or its+ // bar, used one of its keys, or chose to open it). A dialog that focuses it by itself on opening leaves those two+ // keys to the page, so the full-screen viewer keeps browsing the results until then.const engaged = useRef(false);const tabbed = useRef(false);useEffect(() => {@@ -180,7 +246,9 @@ export function SplatViewer({const ready = status === "ready";const onKey = (e: React.KeyboardEvent) => {const eng = engineRef.current;- if (!eng || !ready || e.altKey || e.metaKey || e.ctrlKey) return;+ if (!eng || !ready || e.altKey || e.metaKey || e.ctrlKey || e.defaultPrevented) return;+ // The haze slider takes its own arrow keys.+ if ((e.target as HTMLElement).closest?.("[role=slider],input,textarea")) return;const step = Math.PI / 12;const act: Record<string, () => void> = {ArrowLeft: () => eng.orbit(-step, 0),@@ -201,6 +269,27 @@ export function SplatViewer({fn();};+ // A double tap (or double click) on the stage resets the view; a drag in between doesn't count.+ const tap = useRef<{ down?: { x: number; y: number; t: number }; last?: { x: number; y: number; t: number } }>({});+ const onStagePointerDown = (e: React.PointerEvent) => {+ engaged.current = true;+ tap.current.down = e.isPrimary ? { x: e.clientX, y: e.clientY, t: e.timeStamp } : undefined;+ };+ const onStagePointerUp = (e: React.PointerEvent) => {+ const d = tap.current.down;+ tap.current.down = undefined;+ if (!d || !e.isPrimary || e.timeStamp - d.t > DOUBLE_TAP.tapMs || Math.hypot(e.clientX - d.x, e.clientY - d.y) > DOUBLE_TAP.tapPx) {+ tap.current.last = undefined;+ return;+ }+ const last = tap.current.last;+ const now = { x: e.clientX, y: e.clientY, t: e.timeStamp };+ if (last && now.t - last.t < DOUBLE_TAP.ms && Math.hypot(now.x - last.x, now.y - last.y) < DOUBLE_TAP.px) {+ tap.current.last = undefined;+ engineRef.current?.reset();+ } else tap.current.last = now;+ };+const saveStill = async () => {const eng = engineRef.current;if (!eng) return;@@ -217,8 +306,11 @@ export function SplatViewer({};const panel = tone === "panel";+ // The full-screen viewer shows the haze slider in its bar where there's room; a card, a phone or a short stage+ // keeps the bar to one row with the slider in a popover, so the bar covers as little of the splat as it can.+ const inlineHaze = panel && !compact && !coarse;const haze = (- <div className={cn("flex items-center gap-2", panel ? "w-56" : "w-full")}>+ <div className={cn("flex items-center gap-2", inlineHaze ? "w-56" : "w-full")}><label id={`${helpId}-haze`} className="shrink-0 text-[12px] font-medium">Hide faint haze</label>@@ -238,8 +330,21 @@ export function SplatViewer({);return (- // Touches stay here: a drag that turns the splat isn't a swipe to the next result (the studio viewer's).- <div className="relative size-full overflow-hidden" style={{ background: backgroundColor(background) }} onTouchStart={(e) => e.stopPropagation()} onTouchEnd={(e) => e.stopPropagation()}>+ // Touches stay here: a drag that turns the splat isn't a swipe to the next result (the studio viewer's), and+ // overscroll-none keeps a drag at its edge from pulling the page (pull to refresh, the back swipe).+ <div+ ref={rootRef}+ className="relative size-full touch-none overflow-hidden overscroll-none select-none"+ style={{ background: backgroundColor(background), WebkitTouchCallout: "none" }}+ onTouchStart={(e) => e.stopPropagation()}+ onTouchMove={(e) => e.stopPropagation()}+ onTouchEnd={(e) => e.stopPropagation()}+ onKeyDown={onKey}+ onPointerDown={() => void (engaged.current = true)}+ onBlur={(e) => {+ if (!e.currentTarget.contains(e.relatedTarget as Node | null)) engaged.current = false;+ }}+ ><divref={stageRef}tabIndex={0}@@ -248,15 +353,16 @@ export function SplatViewer({aria-label={`Look around ${label}`}aria-describedby={helpId}aria-busy={!ready}- onKeyDown={onKey}onFocus={() => void (engaged.current ||= tabbed.current)}- onBlur={() => void (engaged.current = false)}- onPointerDown={() => void (engaged.current = true)}- className="absolute inset-0 touch-none outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset"+ onPointerDown={onStagePointerDown}+ onPointerUp={onStagePointerUp}+ onPointerCancel={() => (tap.current = {})}+ onContextMenu={(e) => e.preventDefault()}+ className="absolute inset-0 cursor-grab touch-none outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset active:cursor-grabbing">- <canvas ref={setCanvas} className={cn("size-full transition-opacity", ready ? "opacity-100" : "opacity-0")} />+ <canvas ref={setCanvas} className={cn("block size-full touch-none transition-opacity", ready ? "opacity-100" : "opacity-0")} /><p id={helpId} className="sr-only">- Drag to turn it, pinch or scroll to zoom. From the keyboard: the arrow keys turn it, plus and minus zoom, 0 resets the view.+ Drag to turn it, pinch or scroll to zoom, drag with two fingers or the right button to move it, double-tap to reset. From the keyboard: the arrow keys turn it, plus and minus zoom, 0 resets the view.</p></div>{!ready && (@@ -274,20 +380,22 @@ export function SplatViewer({)}{ready && (<div+ ref={setBar}role="toolbar"aria-label="3D view"className={cn(- "absolute inset-x-2 bottom-2 flex flex-wrap items-center justify-center gap-1 rounded-2xl px-1.5 py-1 shadow-soft backdrop-blur sm:inset-x-auto sm:left-1/2 sm:-translate-x-1/2",+ "absolute bottom-2 left-1/2 flex max-w-[calc(100%-1rem)] -translate-x-1/2 items-center justify-center gap-1 rounded-2xl px-1.5 py-1 shadow-soft backdrop-blur pointer-coarse:gap-0",+ inlineHaze ? "flex-wrap" : "flex-nowrap",panel ? "bg-black/55 text-white" : "bg-background/85 text-foreground",)}><IconButton text="Reset view" panel={panel} onClick={() => engineRef.current?.reset()}>- <RotateCcw className="size-3.5" />+ <RotateCcw className="size-3.5 pointer-coarse:size-4" /></IconButton><IconButton text="Turn it over" panel={panel} onClick={() => engineRef.current?.flip()}>- <FlipVertical2 className="size-3.5" />+ <FlipVertical2 className="size-3.5 pointer-coarse:size-4" /></IconButton>- <div role="radiogroup" aria-label="Background" className="flex items-center gap-1 px-1">+ <div role="radiogroup" aria-label="Background" className="flex items-center gap-1 px-1 pointer-coarse:gap-0 pointer-coarse:px-0">{SPLAT_BACKGROUNDS.map((b) => (<buttonkey={b.id}@@ -297,20 +405,34 @@ export function SplatViewer({aria-label={`${b.label} background`}title={`${b.label} background`}onClick={() => setBackground(b.id)}- className={cn("size-5 rounded-full border border-black/20 transition dark:border-white/30", background === b.id && "ring-2 ring-primary ring-offset-1 ring-offset-transparent")}- style={{ background: b.color }}- />+ className="group grid size-5 shrink-0 place-items-center rounded-full outline-none pointer-coarse:size-11"+ >+ <span+ aria-hidden+ className={cn(+ "size-5 rounded-full border border-black/20 transition group-focus-visible:ring-2 group-focus-visible:ring-ring dark:border-white/30",+ background === b.id && "ring-2 ring-primary ring-offset-1 ring-offset-transparent",+ )}+ style={{ background: b.color }}+ />+ </button>))}</div>- {panel ? (+ {inlineHaze ? (<div className="px-1">{haze}</div>) : (<Popover><Tooltip><TooltipTrigger asChild><PopoverTrigger asChild>- <Button type="button" size="icon" variant="ghost" aria-label="Hide faint haze" className={cn("size-7 rounded-full", cutoff > 0 && "text-primary")}>- <SlidersHorizontal className="size-3.5" />+ <Button+ type="button"+ size="icon"+ variant="ghost"+ aria-label="Hide faint haze"+ className={cn("size-7 shrink-0 rounded-full pointer-coarse:size-11", panel && "text-white hover:bg-white/15 hover:text-white", cutoff > 0 && "text-primary")}+ >+ <SlidersHorizontal className="size-3.5 pointer-coarse:size-4" /></Button></PopoverTrigger></TooltipTrigger>@@ -324,7 +446,7 @@ export function SplatViewer({)}{canSave && (<IconButton text={saving ? "Saving the still…" : "Save a still"} panel={panel} onClick={() => void saveStill()} disabled={saving}>- {saving ? <Loader2 className="size-3.5 animate-spin" /> : <Camera className="size-3.5" />}+ {saving ? <Loader2 className="size-3.5 animate-spin pointer-coarse:size-4" /> : <Camera className="size-3.5 pointer-coarse:size-4" />}</IconButton>)}</div>@@ -337,7 +459,15 @@ function IconButton({ text, panel, onClick, disabled, children }: { text: stringreturn (<Tooltip><TooltipTrigger asChild>- <Button type="button" size="icon" variant="ghost" aria-label={text} onClick={onClick} disabled={disabled} className={cn("size-7 rounded-full", panel && "text-white hover:bg-white/15 hover:text-white")}>+ <Button+ type="button"+ size="icon"+ variant="ghost"+ aria-label={text}+ onClick={onClick}+ disabled={disabled}+ className={cn("size-7 shrink-0 rounded-full pointer-coarse:size-11", panel && "text-white hover:bg-white/15 hover:text-white")}+ >{children}</Button></TooltipTrigger>diff --git a/src/components/studio/result-media.tsx b/src/components/studio/result-media.tsxindex fd0b7a87..54605526 100644--- a/src/components/studio/result-media.tsx+++ b/src/components/studio/result-media.tsx@@ -5,7 +5,7 @@ import { createElement, useEffect, useState } from "react";import { loadModelViewer, useViewerSrc, viewerLook } from "@/components/model3d/model-viewer";import { hasWebgl2, SplatViewer, useReducedMotion } from "@/components/model3d/splat-viewer";import { useHydrated } from "@/lib/api";-import { FALLBACK_TEXT, hazeCutoffFor, splatFallback } from "@/lib/av/splat-view";+import { FALLBACK_TEXT, hazeCutoffFor, splatFallback, splatPose } from "@/lib/av/splat-view";import { TurnChips } from "@/components/model3d/turn-chips";import { FORMAT_INFO } from "@/lib/av/formats";import { firstFrameSrc, FRONT_YAW, splatFormatOf, turnOrbit, viewerGlb } from "@/lib/av/model3d";@@ -283,7 +283,7 @@ function SplatPanel({ output, format, poster, video, g }: { output: OutputFile;return (<div className="flex size-full flex-col"><div className="relative min-h-0 flex-1 overflow-hidden md:rounded-lg">- <SplatViewer url={output.url} format={format} poster={picture} name={name} defaultCutoff={hazeCutoffFor(g.modelId)} tone="panel" label={g.request.prompt || "the splat"} autoFocus={asked} onUnavailable={setNote} />+ <SplatViewer url={output.url} format={format} poster={picture} name={name} defaultCutoff={hazeCutoffFor(g.modelId)} pose={splatPose(g, output)} tone="panel" label={g.request.prompt || "the splat"} autoFocus={asked} onUnavailable={setNote} /></div><div className="flex shrink-0 justify-center pt-2">{download}</div></div>diff --git a/src/lib/av/splat-view.ts b/src/lib/av/splat-view.tsindex 7b1a85a6..f3a20f1b 100644--- a/src/lib/av/splat-view.ts+++ b/src/lib/av/splat-view.ts@@ -65,3 +65,86 @@ export const FALLBACK_TEXT: Record<SplatFallback, string> = {/** The file name a still is saved under: the model's name, then "still". */export const stillFileName = (name: string) => `${name.replace(/[^\w .-]+/g, "").trim() || "splat"} still.png`;++/** How a splat file stands: whether it is stored y-down, and the yaw (degrees, from +z towards +x) its front faces. */+export interface SplatPose {+ yDown: boolean;+ frontYaw: number;+}++/**+ * How a run's splat stands. ComfyUI's graphs (Idol 3D, TripoSplat: the core TripoSplat decoder, then SplatToFile3D)+ * save the 3DGS frame as it is, y down and z forward (comfy_extras/nodes_gaussian_splat.py, `_camera_basis`), so in+ * three.js (y up) the subject stands on its head. The viewer turns such a file half a turn about x, (x, y, z) to+ * (x, -y, -z), which stands it upright; the decoder then has the subject's front facing +x (yaw 90: the Idol pack's+ * preview camera, and FRONT_YAW for meshes made from the same splats), so the camera starts there. Cloud `.ply`+ * files and the demo splats (scripts/gen-demo-splat.mjs) are y-up with their front to +z, and open as they are.+ */+export function splatPose(g: { provider?: string | null } | null | undefined, file?: { url?: string; meta?: Record<string, unknown> }): SplatPose {+ const demo = file?.meta?.demo === true || !!file?.url?.startsWith("sample:");+ return g?.provider === "comfyui" && !demo ? { yDown: true, frontYaw: 90 } : { yDown: false, frontYaw: 0 };+}++export type Vec3 = [number, number, number];+export interface SplatBounds {+ min: Vec3;+ max: Vec3;+}++/**+ * The subject's box from the Gaussians' centres (x, y, z triples): on each axis, from the `trim` to the 1 - `trim`+ * quantile of the ones at least `minOpacity` opaque (all of them where too few are), so faint haze and a few+ * stray floaters don't shrink the subject in the frame or move the point it turns around. Null for no Gaussians.+ */+export function subjectBounds(centers: ArrayLike<number>, opacities: ArrayLike<number>, { minOpacity = 0.1, trim = 0.005 } = {}): SplatBounds | null {+ const n = Math.min(Math.floor(centers.length / 3), opacities.length);+ if (!n) return null;+ let keep: number[] = [];+ for (let i = 0; i < n; i++) if (opacities[i] >= minOpacity) keep.push(i);+ if (keep.length < Math.max(8, n * 0.02)) keep = Array.from({ length: n }, (_, i) => i);+ const min: Vec3 = [0, 0, 0];+ const max: Vec3 = [0, 0, 0];+ const values = new Float64Array(keep.length);+ for (let axis = 0; axis < 3; axis++) {+ keep.forEach((i, k) => (values[k] = centers[i * 3 + axis]));+ values.sort();+ const at = (q: number) => values[Math.min(values.length - 1, Math.max(0, Math.round(q * (values.length - 1))))];+ min[axis] = at(trim);+ max[axis] = at(1 - trim);+ }+ return { min, max };+}++/** The home view's elevation: a little above straight on, so the subject reads upright with a hint of its top. */+export const HOME_ELEVATION_DEG = 6;++/**+ * Where the viewer's camera starts (and Reset view returns): in front of the subject (at `frontYaw` degrees from +z+ * towards +x), a little above, at the distance where it fills `fill` of the frame both ways (`aspect` is the frame's+ * width / height, `fovDeg` the camera's vertical field of view, `room` the share of the frame's height it may take:+ * under 1 where the controls bar covers the stage's foot). Its turning point is the box's centre.+ */+export function homeView(+ b: SplatBounds,+ fovDeg: number,+ aspect: number,+ { frontYaw = 0, fill = 0.9, room = 1 }: { frontYaw?: number; fill?: number; room?: number } = {},+): { target: Vec3; position: Vec3; distance: number; size: number } {+ const size: Vec3 = [0, 1, 2].map((k) => Math.max(b.max[k] - b.min[k], 1e-3)) as Vec3;+ const target = [0, 1, 2].map((k) => (b.min[k] + b.max[k]) / 2) as Vec3;+ const yaw = (frontYaw * Math.PI) / 180;+ const [c, s] = [Math.abs(Math.cos(yaw)), Math.abs(Math.sin(yaw))];+ // The box as the camera sees it: its width across the view and its depth along it.+ const width = c * size[0] + s * size[2];+ const depth = s * size[0] + c * size[2];+ const tanV = Math.tan(((fovDeg / 2) * Math.PI) / 180);+ const tanH = tanV * (aspect > 0 && Number.isFinite(aspect) ? aspect : 1);+ const distance = Math.max(size[1] / 2 / (tanV * Math.min(Math.max(room, 0.1), 1)), width / 2 / tanH) / fill + depth / 2;+ const e = (HOME_ELEVATION_DEG * Math.PI) / 180;+ const flat = distance * Math.cos(e);+ const position: Vec3 = [target[0] + flat * Math.sin(yaw), target[1] + distance * Math.sin(e), target[2] + flat * Math.cos(yaw)];+ return { target, position, distance, size: Math.max(...size) };+}++/** Two taps (or clicks) within this many ms and px of each other: a double tap, which resets the view. */+export const DOUBLE_TAP = { ms: 320, px: 24, tapMs: 260, tapPx: 10 } as const;diff --git a/tests/e2e/splat-viewer.mjs b/tests/e2e/splat-viewer.mjsindex cf453b11..8bff07ce 100644--- a/tests/e2e/splat-viewer.mjs+++ b/tests/e2e/splat-viewer.mjs@@ -205,7 +205,13 @@ for (const phone of [false, true]) {await page.keyboard.press("Enter");const dialog = page.getByRole("dialog");await dialog.getByRole("toolbar", { name: "3D view" }).waitFor({ timeout: 60_000 });- assert.equal(await dialog.getByRole("slider", { name: "Hide faint haze" }).count(), 1, `${tag}: the panel's haze slider`);+ // The haze slider sits in the bar on a computer, and behind its button on a phone (the bar stays one row).+ if (phone) {+ assert.equal(await dialog.getByRole("slider", { name: "Hide faint haze" }).count(), 0, `${tag}: the phone's bar keeps to one row`);+ await dialog.getByRole("button", { name: "Hide faint haze" }).click();+ await page.getByRole("slider", { name: "Hide faint haze" }).waitFor({ timeout: 5000 });+ await page.keyboard.press("Escape");+ } else assert.equal(await dialog.getByRole("slider", { name: "Hide faint haze" }).count(), 1, `${tag}: the panel's haze slider`);await until(() => drawn(dialog.getByRole("application").locator("canvas")), `${tag}: the panel's splat drawn`, 30_000);assert.ok((await dialog.getByRole("link", { name: /^\.(spz|ply)$/ }).count()) >= 1, `${tag}: the panel's download`);await noSideScroll(page, `${tag} library viewer`);diff --git a/tests/splat-view.test.ts b/tests/splat-view.test.tsindex 242e462e..809b07b7 100644--- a/tests/splat-view.test.ts+++ b/tests/splat-view.test.ts@@ -3,7 +3,7 @@ import path from "node:path";import zlib from "node:zlib";import { describe, expect, it } from "vitest";import { IDOL_MODELS, model3dView, splatFormatOf } from "@/lib/av/model3d";-import { FALLBACK_TEXT, hazeCutoffFor, SPLAT_MAX_BYTES, splatFallback, splatTooBig, stillFileName, viewerFor } from "@/lib/av/splat-view";+import { FALLBACK_TEXT, HOME_ELEVATION_DEG, hazeCutoffFor, homeView, SPLAT_MAX_BYTES, splatFallback, splatPose, splatTooBig, stillFileName, subjectBounds, viewerFor } from "@/lib/av/splat-view";/*** Looking around splats (idol-4): which viewer a 3D output opens in, the haze cut-off each model starts with, when@@ -148,3 +148,105 @@ describe("the viewer leaves the page as it found it", () => {expect(viewer).toMatch(/if \(!engaged\.current && \(e\.key === "ArrowLeft" \|\| e\.key === "ArrowRight"\)\) return;/);});});++describe("how a splat stands and where the camera starts", () => {+ /**+ * A standing figure as ComfyUI's TripoSplat decoder saves it (Idol 3D): the 3DGS frame, y down, so the head is at+ * -y and the feet at +y, its front towards +x once stood up. Solid body Gaussians plus faint haze and a few floaters.+ */+ function comfyFigure() {+ const centers: number[] = [];+ const opacities: number[] = [];+ let seed = 7;+ const rand = () => ((seed = (seed * 16807) % 2147483647) / 2147483647) * 2 - 1;+ for (let i = 0; i < 4000; i++) {+ const y = -0.5 + (i / 3999) * 1; // head (-0.5) to feet (+0.5)+ centers.push(rand() * 0.12, y, rand() * 0.1);+ opacities.push(0.9);+ }+ for (let i = 0; i < 4000; i++) {+ centers.push(rand() * 0.3, rand() * 0.6, rand() * 0.3);+ opacities.push(0.02); // haze+ }+ for (let i = 0; i < 10; i++) {+ centers.push(3 + i, -4, 5); // floaters far off+ opacities.push(0.5);+ }+ return { centers, opacities };+ }+ /** The viewer's half turn about x for a y-down file: (x, y, z) to (x, -y, -z). */+ const turn = (c: number[]) => c.map((v, i) => (i % 3 === 0 ? v : -v));++ it("a ComfyUI splat (Idol 3D on your GPU or ours) is y-down and faces +x; cloud, demo and other files stand as they are", () => {+ expect(splatPose({ provider: "comfyui" }, { url: "/api/files/outputs/2026-11-07/a.spz", meta: { role: "splat", format: "spz" } })).toEqual({ yDown: true, frontYaw: 90 });+ expect(splatPose({ provider: "fal" }, { url: "https://fal.test/splat.ply" })).toEqual({ yDown: false, frontYaw: 0 });+ // Demo mode's splats are y-up wherever they show (scripts/gen-demo-splat.mjs).+ expect(splatPose({ provider: "mock" }, { url: "sample:demo-splat.spz", meta: { demo: true } })).toEqual({ yDown: false, frontYaw: 0 });+ expect(splatPose({ provider: "comfyui" }, { url: "sample:demo-splat.spz" })).toEqual({ yDown: false, frontYaw: 0 });+ expect(splatPose(undefined)).toEqual({ yDown: false, frontYaw: 0 });+ });++ it("the half turn stands the figure upright: its head ends up at the top", () => {+ const { centers, opacities } = comfyFigure();+ const head = (c: number[]) => c[1]; // the first Gaussian is the top of the head+ expect(head(centers)).toBeLessThan(0); // as saved: upside down in three.js (y up)+ const upright = turn(centers);+ expect(head(upright)).toBeGreaterThan(0);+ const b = subjectBounds(upright, opacities)!;+ expect(b.max[1]).toBeGreaterThan(0.45);+ expect(b.min[1]).toBeLessThan(-0.45);+ });++ it("the subject's box leaves out faint haze and stray floaters, so the figure isn't small in the middle", () => {+ const { centers, opacities } = comfyFigure();+ const b = subjectBounds(turn(centers), opacities)!;+ for (let k = 0; k < 3; k++) {+ expect(b.max[k] - b.min[k]).toBeLessThan(1.1);+ expect(Math.abs((b.max[k] + b.min[k]) / 2)).toBeLessThan(0.05);+ }+ // Without the opacity filter the floaters stretch it.+ const all = subjectBounds(turn(centers), opacities, { minOpacity: 0, trim: 0 })!;+ expect(all.max[0]).toBeGreaterThan(10);+ expect(subjectBounds([], [])).toBeNull();+ });++ it("home is in front of the subject, a little above, turning about its centre, filling the stage", () => {+ const b = { min: [-0.15, -0.5, -0.12] as [number, number, number], max: [0.15, 0.5, 0.12] as [number, number, number] };+ const fov = 40;+ const tan = Math.tan((fov / 2) * (Math.PI / 180));+ for (const aspect of [1440 / 900, 390 / 747, 844 / 300]) {+ const v = homeView(b, fov, aspect, { frontYaw: 90 });+ expect(v.target).toEqual([0, 0, 0]);+ const [dx, dy, dz] = v.position.map((p, i) => p - v.target[i]);+ // Faces +x (the decoder's front), barely above: no view from overhead.+ expect(dx).toBeGreaterThan(0);+ expect(Math.abs(dz)).toBeLessThan(1e-9);+ expect(dy / v.distance).toBeCloseTo(Math.sin((HOME_ELEVATION_DEG * Math.PI) / 180), 6);+ // The 1.0-tall figure takes 90% of the stage's height (its near face at distance - depth / 2).+ const near = v.distance - 0.15;+ expect(1 / (2 * near * tan)).toBeCloseTo(0.9, 2);+ }+ // A wide subject on a phone's tall stage fits its width instead.+ const wide = { min: [-1, -0.2, -0.2] as [number, number, number], max: [1, 0.2, 0.2] as [number, number, number] };+ const phone = homeView(wide, fov, 390 / 747);+ expect(2 / (2 * (phone.distance - 0.2) * tan * (390 / 747))).toBeCloseTo(0.9, 2);+ // The controls bar over the stage's foot: the subject keeps to the space above it.+ expect(homeView(b, fov, 1.5, { room: 0.8 }).distance).toBeGreaterThan(homeView(b, fov, 1.5).distance);+ });++ it("every viewer of a result passes how its file stands", () => {+ for (const f of ["src/components/studio/result-media.tsx", "src/components/model3d/model-card.tsx"]) {+ const text = fs.readFileSync(path.join(process.cwd(), f), "utf8");+ for (const tag of text.match(/<SplatViewer[\s\S]*?\/>/g) ?? []) expect(tag, f).toMatch(/pose=\{splatPose\(g, /);+ }+ });++ it("on a phone the stage keeps every touch: no page scroll, pull to refresh, back swipe or page zoom", () => {+ const viewer = fs.readFileSync(path.join(process.cwd(), "src/components/model3d/splat-viewer.tsx"), "utf8");+ expect(viewer).toMatch(/touch-none overflow-hidden overscroll-none/);+ expect(viewer).toMatch(/"gesturestart", "gesturechange", "gestureend"/);+ expect(viewer).toMatch(/onTouchMove=\{\(e\) => e\.stopPropagation\(\)\}/);+ // 44 px targets for a finger.+ expect(viewer.match(/pointer-coarse:size-11/g)?.length).toBeGreaterThanOrEqual(3);+ });+});