strata-react 1.3.19 → 1.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +31 -6
  2. package/UPGRADING.md +7 -1
  3. package/dist/{errors-jep2voNI.js → button-KGJI6jQr.js} +3 -95
  4. package/dist/button-KGJI6jQr.js.map +1 -0
  5. package/dist/components/byte-view.d.ts +32 -0
  6. package/dist/components/console.d.ts +34 -0
  7. package/dist/components/disclosure.d.ts +2 -0
  8. package/dist/components/file-intake.d.ts +9 -0
  9. package/dist/components/hotkeys.d.ts +4 -0
  10. package/dist/components/pixel-image.d.ts +29 -0
  11. package/dist/components/shortcut-editor.d.ts +44 -0
  12. package/dist/components/tree.d.ts +4 -2
  13. package/dist/components/workspace.d.ts +22 -2
  14. package/dist/errors-BUvY1Z4d.js +95 -0
  15. package/dist/errors-BUvY1Z4d.js.map +1 -0
  16. package/dist/{field-t4Hoer0d.js → field-BjeE_FeB.js} +6 -101
  17. package/dist/field-BjeE_FeB.js.map +1 -0
  18. package/dist/index.d.ts +8 -3
  19. package/dist/index.js +937 -13
  20. package/dist/index.js.map +1 -1
  21. package/dist/lib/object-url.d.ts +2 -0
  22. package/dist/map.js +3 -2
  23. package/dist/map.js.map +1 -1
  24. package/dist/{microphone-B5ITwm4G.js → microphone-Bo3WaXgD.js} +5 -3
  25. package/dist/{microphone-B5ITwm4G.js.map → microphone-Bo3WaXgD.js.map} +1 -1
  26. package/dist/panorama.js +3 -3
  27. package/dist/scene/camera.d.ts +71 -0
  28. package/dist/scene/index.d.ts +2 -0
  29. package/dist/scene/scene-viewport.d.ts +46 -0
  30. package/dist/scene.js +526 -0
  31. package/dist/scene.js.map +1 -0
  32. package/dist/strata.bare.css +1 -0
  33. package/dist/strata.css +1 -0
  34. package/dist/strata.migrate.css +1 -0
  35. package/dist/testing/index.d.ts +1 -0
  36. package/dist/testing/layout.d.ts +1 -1
  37. package/dist/testing/setup.d.ts +14 -0
  38. package/dist/testing.js +21 -5
  39. package/dist/testing.js.map +1 -1
  40. package/dist/{theme-DXacprlw.js → theme-CxYZkUNk.js} +3 -2
  41. package/dist/{theme-DXacprlw.js.map → theme-CxYZkUNk.js.map} +1 -1
  42. package/dist/tooltip-DhqrDtyu.js +103 -0
  43. package/dist/tooltip-DhqrDtyu.js.map +1 -0
  44. package/dist/{value-controls-DB5l5Qe2.js → value-controls-Dq2-QpvA.js} +8 -4
  45. package/dist/value-controls-Dq2-QpvA.js.map +1 -0
  46. package/package.json +6 -1
  47. package/dist/errors-jep2voNI.js.map +0 -1
  48. package/dist/field-t4Hoer0d.js.map +0 -1
  49. package/dist/value-controls-DB5l5Qe2.js.map +0 -1
package/dist/scene.js ADDED
@@ -0,0 +1,526 @@
1
+ import { o as useInView, t as Button } from "./button-KGJI6jQr.js";
2
+ import { r as cn } from "./tooltip-DhqrDtyu.js";
3
+ import * as React from "react";
4
+ import { RotateCcw } from "lucide-react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { VisuallyHidden } from "react-aria";
7
+ // src/scene/camera.ts
8
+ var DEFAULT_LIMITS = {
9
+ minDistance: 0,
10
+ maxDistance: Infinity,
11
+ maxPitch: 89
12
+ };
13
+ var rad = (d) => d * Math.PI / 180;
14
+ /** Keeps a camera inside its limits and its yaw in -180 to 180. */
15
+ function clampCamera(c, limits = {}) {
16
+ const { minDistance, maxDistance, maxPitch } = {
17
+ ...DEFAULT_LIMITS,
18
+ ...limits
19
+ };
20
+ const yaw = ((c.yaw + 180) % 360 + 360) % 360 - 180;
21
+ const distance = c.distance === 0 && minDistance === 0 ? 0 : Math.min(Math.max(c.distance, minDistance), maxDistance);
22
+ return {
23
+ target: c.target,
24
+ distance,
25
+ yaw,
26
+ pitch: Math.min(Math.max(c.pitch, -maxPitch), maxPitch)
27
+ };
28
+ }
29
+ var cross = (a, b) => [
30
+ a[1] * b[2] - a[2] * b[1],
31
+ a[2] * b[0] - a[0] * b[2],
32
+ a[0] * b[1] - a[1] * b[0]
33
+ ];
34
+ var dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
35
+ /** The unit vectors a camera looks along, and to its right and up. */
36
+ function basis(c) {
37
+ const y = rad(c.yaw);
38
+ const p = rad(c.pitch);
39
+ const forward = [
40
+ -Math.cos(p) * Math.sin(y),
41
+ Math.sin(p),
42
+ Math.cos(p) * Math.cos(y)
43
+ ];
44
+ const right = [
45
+ -Math.cos(y),
46
+ 0,
47
+ -Math.sin(y)
48
+ ];
49
+ return {
50
+ forward,
51
+ right,
52
+ up: cross(right, forward)
53
+ };
54
+ }
55
+ /** A right-handed perspective projection (OpenGL clip space, depth -1 to 1). `fov` is the vertical field of view in degrees. */
56
+ function perspective(fov, aspect, near, far) {
57
+ const f = 1 / Math.tan(rad(fov) / 2);
58
+ const m = /* @__PURE__ */ new Float32Array(16);
59
+ m[0] = f / aspect;
60
+ m[5] = f;
61
+ m[10] = (far + near) / (near - far);
62
+ m[11] = -1;
63
+ m[14] = 2 * far * near / (near - far);
64
+ return m;
65
+ }
66
+ /** The view matrix of an eye looking along `forward`. */
67
+ function lookAlong(eye, forward, right, up) {
68
+ const m = /* @__PURE__ */ new Float32Array(16);
69
+ m[0] = right[0];
70
+ m[4] = right[1];
71
+ m[8] = right[2];
72
+ m[12] = -dot(right, eye);
73
+ m[1] = up[0];
74
+ m[5] = up[1];
75
+ m[9] = up[2];
76
+ m[13] = -dot(up, eye);
77
+ m[2] = -forward[0];
78
+ m[6] = -forward[1];
79
+ m[10] = -forward[2];
80
+ m[14] = dot(forward, eye);
81
+ m[15] = 1;
82
+ return m;
83
+ }
84
+ /** `a × b` for column-major matrices. */
85
+ function multiply(a, b) {
86
+ const out = /* @__PURE__ */ new Float32Array(16);
87
+ for (let col = 0; col < 4; col++) for (let row = 0; row < 4; row++) {
88
+ let sum = 0;
89
+ for (let k = 0; k < 4; k++) sum += a[k * 4 + row] * b[col * 4 + k];
90
+ out[col * 4 + row] = sum;
91
+ }
92
+ return out;
93
+ }
94
+ /** The frame for a camera in a drawing buffer of `width` by `height`. */
95
+ function frameFor(camera, width, height, { fov = 60, near = .1, far = 1e4, context = 0 } = {}) {
96
+ const { forward, right, up } = basis(camera);
97
+ const eye = [
98
+ camera.target[0] - forward[0] * camera.distance,
99
+ camera.target[1] - forward[1] * camera.distance,
100
+ camera.target[2] - forward[2] * camera.distance
101
+ ];
102
+ const view = lookAlong(eye, forward, right, up);
103
+ const projection = perspective(fov, width / Math.max(1, height), near, far);
104
+ return {
105
+ camera,
106
+ eye,
107
+ forward,
108
+ right,
109
+ up,
110
+ view,
111
+ projection,
112
+ viewProjection: multiply(projection, view),
113
+ width,
114
+ height,
115
+ context
116
+ };
117
+ }
118
+ /** Turns the camera as dragging does: orbit moves the eye round the target; look (fly) turns the head. Pixels in, degrees out at `degreesPerPixel`. */
119
+ function turn(c, dx, dy, mode, degreesPerPixel = .35) {
120
+ const sign = mode === "orbit" ? 1 : -1;
121
+ return {
122
+ ...c,
123
+ yaw: c.yaw + sign * dx * degreesPerPixel,
124
+ pitch: c.pitch - sign * dy * degreesPerPixel
125
+ };
126
+ }
127
+ /** Moves the target in the screen's plane by pixels (a pan): the scene follows the pointer. `heightPx` is the box's height and `fov` the vertical field of view, which give the world size of a pixel at the target's distance. */
128
+ function pan(c, dx, dy, heightPx, fov = 60) {
129
+ const { right, up } = basis(c);
130
+ const perPixel = 2 * Math.max(c.distance, .001) * Math.tan(rad(fov) / 2) / Math.max(1, heightPx);
131
+ const move = (axis) => c.target[axis] - right[axis] * dx * perPixel + up[axis] * dy * perPixel;
132
+ return {
133
+ ...c,
134
+ target: [
135
+ move(0),
136
+ move(1),
137
+ move(2)
138
+ ]
139
+ };
140
+ }
141
+ /** Moves along the look direction (`ahead`), to the right (`side`) and up (`rise`), in world units: a fly camera's walk, or an orbit camera's pan by keys. */
142
+ function walk(c, ahead, side, rise) {
143
+ const { forward, right } = basis(c);
144
+ const to = (axis) => c.target[axis] + forward[axis] * ahead + right[axis] * side + (axis === 1 ? rise : 0);
145
+ return {
146
+ ...c,
147
+ target: [
148
+ to(0),
149
+ to(1),
150
+ to(2)
151
+ ]
152
+ };
153
+ }
154
+ /** Moves the eye toward or away from the target by a factor of the distance (orbit zoom). */
155
+ function dolly(c, factor) {
156
+ return {
157
+ ...c,
158
+ distance: c.distance * factor
159
+ };
160
+ }
161
+ var turnWords = (deg, positive, negative) => Math.abs(deg) < 1 ? "" : `${Math.round(Math.abs(deg))}° ${deg > 0 ? positive : negative}`;
162
+ /** The camera in words, for the viewport's name and its status: "Looking at 0, 2, 0 from 5 away, turned 45° right, 30° above the horizon". */
163
+ function describeCamera(c) {
164
+ const n = (v) => String(Math.round(v * 10) / 10);
165
+ const turned = turnWords(c.yaw, "right", "left");
166
+ const tilted = turnWords(c.pitch, "up", "down");
167
+ const at = `${n(c.target[0])}, ${n(c.target[1])}, ${n(c.target[2])}`;
168
+ const parts = [turned && `turned ${turned}`, tilted && `looking ${tilted}`].filter(Boolean).join(", ");
169
+ return c.distance === 0 ? `At ${at}${parts ? `, ${parts}` : ", looking straight ahead"}` : `Looking at ${at} from ${n(c.distance)} away${parts ? `, ${parts}` : ""}`;
170
+ }
171
+ // src/scene/scene-viewport.tsx
172
+ /** A camera the app holds: `{ target, distance, yaw, pitch }` to start from, and the limits it is kept inside. Give `camera` and `setCamera` to `SceneViewport`. */
173
+ function useOrbitCamera(initial = {}, limits = {}) {
174
+ const home = React.useMemo(() => clampCamera({
175
+ target: initial.target ?? [
176
+ 0,
177
+ 0,
178
+ 0
179
+ ],
180
+ distance: initial.distance ?? 5,
181
+ yaw: initial.yaw ?? 0,
182
+ pitch: initial.pitch ?? 20
183
+ }, limits), []);
184
+ const [camera, set] = React.useState(home);
185
+ const bounds = React.useRef(limits);
186
+ bounds.current = limits;
187
+ return {
188
+ camera,
189
+ setCamera: React.useCallback((next) => set(clampCamera(next, bounds.current)), []),
190
+ home
191
+ };
192
+ }
193
+ var STILL_MS = 600;
194
+ var RESET_MS = 300;
195
+ var reducedMotion = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
196
+ /** A sized, focusable canvas for a 3D scene the app draws: orbit by drag, pan by right drag or Shift, zoom by Ctrl/Cmd+wheel or pinch, keys, a Reset button, a fly mode, a lost context restored, and the camera in words. */
197
+ function SceneViewport({ label, camera, onCameraChange, home, render, mode = "orbit", fov = 60, near = .1, far = 1e4, limits, flySpeed = 5, continuous = false, aspect = "16/9", handle, className }) {
198
+ const first = React.useRef(camera);
199
+ const target = home ?? first.current;
200
+ const live = React.useRef({
201
+ camera,
202
+ onCameraChange,
203
+ render,
204
+ mode,
205
+ fov,
206
+ near,
207
+ far,
208
+ limits,
209
+ flySpeed,
210
+ home: target
211
+ });
212
+ live.current = {
213
+ camera,
214
+ onCameraChange,
215
+ render,
216
+ mode,
217
+ fov,
218
+ near,
219
+ far,
220
+ limits,
221
+ flySpeed,
222
+ home: target
223
+ };
224
+ const change = React.useCallback((next) => {
225
+ live.current.onCameraChange(clampCamera(next, live.current.limits));
226
+ }, []);
227
+ const box = React.useRef(null);
228
+ const canvas = React.useRef(null);
229
+ const [size, setSize] = React.useState({
230
+ width: 0,
231
+ height: 0
232
+ });
233
+ React.useLayoutEffect(() => {
234
+ const el = box.current;
235
+ if (!el) return;
236
+ const read = () => {
237
+ const r = el.getBoundingClientRect();
238
+ setSize((s) => s.width === r.width && s.height === r.height ? s : {
239
+ width: r.width,
240
+ height: r.height
241
+ });
242
+ };
243
+ read();
244
+ if (typeof ResizeObserver === "undefined") return;
245
+ const ro = new ResizeObserver(read);
246
+ ro.observe(el);
247
+ return () => ro.disconnect();
248
+ }, []);
249
+ const { ref: visibleRef, inView } = useInView({ unsupported: true });
250
+ const boxRef = React.useCallback((el) => {
251
+ box.current = el;
252
+ visibleRef(el);
253
+ }, [visibleRef]);
254
+ const gl = React.useRef(null);
255
+ const context = React.useRef(0);
256
+ const [unavailable, setUnavailable] = React.useState(false);
257
+ const frameHandle = React.useRef(0);
258
+ const current = React.useRef({
259
+ size,
260
+ inView,
261
+ continuous
262
+ });
263
+ current.current = {
264
+ size,
265
+ inView,
266
+ continuous
267
+ };
268
+ const paint = React.useCallback(() => {
269
+ frameHandle.current = 0;
270
+ const c = canvas.current;
271
+ const ctx = gl.current;
272
+ const { size: s, inView: visible, continuous: again } = current.current;
273
+ if (!c || !ctx || !visible || s.width === 0 || s.height === 0) return;
274
+ const dpr = Math.min(typeof devicePixelRatio === "number" ? devicePixelRatio : 1, 2);
275
+ const w = Math.max(1, Math.round(s.width * dpr));
276
+ const h = Math.max(1, Math.round(s.height * dpr));
277
+ if (c.width !== w || c.height !== h) {
278
+ c.width = w;
279
+ c.height = h;
280
+ }
281
+ ctx.viewport(0, 0, w, h);
282
+ const l = live.current;
283
+ l.render(ctx, frameFor(l.camera, w, h, {
284
+ fov: l.fov,
285
+ near: l.near,
286
+ far: l.far,
287
+ context: context.current
288
+ }));
289
+ if (again) frameHandle.current = requestAnimationFrame(paint);
290
+ }, []);
291
+ const schedule = React.useCallback(() => {
292
+ if (frameHandle.current === 0) frameHandle.current = requestAnimationFrame(paint);
293
+ }, [paint]);
294
+ React.useImperativeHandle(handle, () => ({
295
+ invalidate: schedule,
296
+ canvas: canvas.current
297
+ }), [schedule]);
298
+ React.useEffect(() => {
299
+ const c = canvas.current;
300
+ if (!c) return;
301
+ const make = () => {
302
+ gl.current = c.getContext("webgl2");
303
+ setUnavailable(gl.current === null);
304
+ if (gl.current) context.current += 1;
305
+ schedule();
306
+ };
307
+ make();
308
+ const lost = (e) => {
309
+ e.preventDefault();
310
+ gl.current = null;
311
+ };
312
+ c.addEventListener("webglcontextlost", lost);
313
+ c.addEventListener("webglcontextrestored", make);
314
+ return () => {
315
+ c.removeEventListener("webglcontextlost", lost);
316
+ c.removeEventListener("webglcontextrestored", make);
317
+ if (frameHandle.current) cancelAnimationFrame(frameHandle.current);
318
+ frameHandle.current = 0;
319
+ };
320
+ }, [schedule]);
321
+ React.useEffect(() => {
322
+ schedule();
323
+ }, [
324
+ schedule,
325
+ camera,
326
+ size.width,
327
+ size.height,
328
+ inView,
329
+ fov,
330
+ near,
331
+ far,
332
+ continuous
333
+ ]);
334
+ const animation = React.useRef(0);
335
+ const reset = () => {
336
+ cancelAnimationFrame(animation.current);
337
+ const from = live.current.camera;
338
+ const to = live.current.home;
339
+ if (reducedMotion()) return change(to);
340
+ const started = performance.now();
341
+ const step = (now) => {
342
+ const t = Math.min(1, (now - started) / RESET_MS);
343
+ const e = 1 - (1 - t) ** 3;
344
+ const mix = (a, b) => a + (b - a) * e;
345
+ const dyaw = ((to.yaw - from.yaw + 180) % 360 + 360) % 360 - 180;
346
+ change({
347
+ target: [
348
+ mix(from.target[0], to.target[0]),
349
+ mix(from.target[1], to.target[1]),
350
+ mix(from.target[2], to.target[2])
351
+ ],
352
+ distance: mix(from.distance, to.distance),
353
+ yaw: from.yaw + dyaw * e,
354
+ pitch: mix(from.pitch, to.pitch)
355
+ });
356
+ if (t < 1) animation.current = requestAnimationFrame(step);
357
+ };
358
+ animation.current = requestAnimationFrame(step);
359
+ };
360
+ React.useEffect(() => () => cancelAnimationFrame(animation.current), []);
361
+ const pointers = React.useRef(/* @__PURE__ */ new Map());
362
+ const pinch = React.useRef(null);
363
+ const onPointerDown = (e) => {
364
+ if (e.target instanceof HTMLButtonElement) return;
365
+ pointers.current.set(e.pointerId, {
366
+ x: e.clientX,
367
+ y: e.clientY
368
+ });
369
+ e.currentTarget.setPointerCapture?.(e.pointerId);
370
+ e.currentTarget.focus({ preventScroll: true });
371
+ cancelAnimationFrame(animation.current);
372
+ if (pointers.current.size === 2) {
373
+ const [a, b] = [...pointers.current.values()];
374
+ pinch.current = Math.hypot(a.x - b.x, a.y - b.y);
375
+ }
376
+ };
377
+ const onPointerMove = (e) => {
378
+ const last = pointers.current.get(e.pointerId);
379
+ if (!last) return;
380
+ const now = {
381
+ x: e.clientX,
382
+ y: e.clientY
383
+ };
384
+ pointers.current.set(e.pointerId, now);
385
+ const l = live.current;
386
+ if (pointers.current.size === 2) {
387
+ const [a, b] = [...pointers.current.values()];
388
+ const d = Math.hypot(a.x - b.x, a.y - b.y);
389
+ if (pinch.current && d > 0 && l.mode === "orbit") change(dolly(l.camera, pinch.current / d));
390
+ pinch.current = d;
391
+ return;
392
+ }
393
+ const dx = now.x - last.x;
394
+ const dy = now.y - last.y;
395
+ const panning = e.shiftKey || (e.buttons & 6) !== 0;
396
+ change(panning ? pan(l.camera, dx, dy, size.height, l.fov) : turn(l.camera, dx, dy, l.mode));
397
+ };
398
+ const onPointerUp = (e) => {
399
+ pointers.current.delete(e.pointerId);
400
+ pinch.current = null;
401
+ };
402
+ React.useEffect(() => {
403
+ const el = box.current;
404
+ if (!el) return;
405
+ const onWheel = (e) => {
406
+ if (!e.ctrlKey && !e.metaKey) return;
407
+ e.preventDefault();
408
+ const l = live.current;
409
+ if (l.mode === "orbit") change(dolly(l.camera, Math.exp(e.deltaY * .0015)));
410
+ else change(walk(l.camera, -e.deltaY * .01 * l.flySpeed, 0, 0));
411
+ };
412
+ el.addEventListener("wheel", onWheel, { passive: false });
413
+ return () => el.removeEventListener("wheel", onWheel);
414
+ }, [change]);
415
+ const held = React.useRef(/* @__PURE__ */ new Set());
416
+ const flyLoop = React.useRef(0);
417
+ const flyKeys = [
418
+ "w",
419
+ "a",
420
+ "s",
421
+ "d",
422
+ "q",
423
+ "e",
424
+ "ArrowUp",
425
+ "ArrowDown",
426
+ "ArrowLeft",
427
+ "ArrowRight"
428
+ ];
429
+ const walkFrom = (keys, seconds, fast) => {
430
+ const l = live.current;
431
+ const k = new Set(keys);
432
+ const stride = l.flySpeed * seconds * (fast ? 3 : 1);
433
+ const axis = (plus, minus) => (plus.some((x) => k.has(x)) ? 1 : 0) - (minus.some((x) => k.has(x)) ? 1 : 0);
434
+ change(walk(l.camera, axis(["w", "ArrowUp"], ["s", "ArrowDown"]) * stride, axis(["d", "ArrowRight"], ["a", "ArrowLeft"]) * stride, axis(["e"], ["q"]) * stride));
435
+ };
436
+ const startFly = (shift) => {
437
+ if (flyLoop.current) return;
438
+ let last = performance.now();
439
+ const tick = (now) => {
440
+ walkFrom(held.current, (now - last) / 1e3, shift);
441
+ last = now;
442
+ flyLoop.current = held.current.size ? requestAnimationFrame(tick) : 0;
443
+ };
444
+ flyLoop.current = requestAnimationFrame(tick);
445
+ };
446
+ React.useEffect(() => () => cancelAnimationFrame(flyLoop.current), []);
447
+ const onKeyDown = (e) => {
448
+ if (e.ctrlKey || e.metaKey || e.altKey) return;
449
+ const l = live.current;
450
+ const key = e.key.length === 1 ? e.key.toLowerCase() : e.key;
451
+ if (key === "0") reset();
452
+ else if (l.mode === "fly" && flyKeys.includes(key)) {
453
+ if (reducedMotion()) walkFrom([key], .2, e.shiftKey);
454
+ else {
455
+ held.current.add(key);
456
+ startFly(e.shiftKey);
457
+ }
458
+ } else if (key === "+" || key === "=") change(l.mode === "orbit" ? dolly(l.camera, .8) : walk(l.camera, l.flySpeed * .5, 0, 0));
459
+ else if (key === "-" || key === "_") change(l.mode === "orbit" ? dolly(l.camera, 1.25) : walk(l.camera, -l.flySpeed * .5, 0, 0));
460
+ else if (l.mode === "orbit" && key.startsWith("Arrow")) {
461
+ const step = e.shiftKey ? 30 : 10;
462
+ const dx = key === "ArrowRight" ? step : key === "ArrowLeft" ? -step : 0;
463
+ const dy = key === "ArrowDown" ? step : key === "ArrowUp" ? -step : 0;
464
+ change(e.shiftKey ? pan(l.camera, -dx, -dy, size.height, l.fov) : turn(l.camera, dx, dy, "orbit"));
465
+ } else return;
466
+ e.preventDefault();
467
+ };
468
+ const onKeyUp = (e) => {
469
+ held.current.delete(e.key.length === 1 ? e.key.toLowerCase() : e.key);
470
+ };
471
+ const words = describeCamera(camera);
472
+ const [said, setSaid] = React.useState("");
473
+ const firstWords = React.useRef(true);
474
+ React.useEffect(() => {
475
+ if (firstWords.current) {
476
+ firstWords.current = false;
477
+ return;
478
+ }
479
+ const t = setTimeout(() => setSaid(words), STILL_MS);
480
+ return () => clearTimeout(t);
481
+ }, [words]);
482
+ return /* @__PURE__ */ jsxs("div", {
483
+ className: cn("grid min-w-0 gap-2", className),
484
+ children: [
485
+ /* @__PURE__ */ jsxs("div", {
486
+ ref: boxRef,
487
+ role: "group",
488
+ "aria-label": label,
489
+ tabIndex: 0,
490
+ onKeyDown,
491
+ onKeyUp,
492
+ onBlur: () => held.current.clear(),
493
+ onPointerDown,
494
+ onPointerMove,
495
+ onPointerUp,
496
+ onPointerCancel: onPointerUp,
497
+ onContextMenu: (e) => e.preventDefault(),
498
+ className: "relative w-full cursor-grab touch-none overflow-hidden rounded-surface bg-surface-sunken select-none active:cursor-grabbing",
499
+ style: { aspectRatio: aspect },
500
+ children: [/* @__PURE__ */ jsx("canvas", {
501
+ ref: canvas,
502
+ role: "img",
503
+ "aria-label": `${label}. ${words}`,
504
+ className: "absolute inset-0 size-full"
505
+ }), !unavailable && /* @__PURE__ */ jsxs(Button, {
506
+ size: "sm",
507
+ variant: "outline",
508
+ onPress: reset,
509
+ className: "absolute top-2 right-2",
510
+ children: [/* @__PURE__ */ jsx(RotateCcw, {}), " Reset view"]
511
+ })]
512
+ }),
513
+ unavailable && /* @__PURE__ */ jsx("p", {
514
+ className: "type-body-sm text-muted-foreground",
515
+ children: "This browser cannot draw the 3D view."
516
+ }),
517
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("span", {
518
+ role: "status",
519
+ children: said
520
+ }) })
521
+ ]
522
+ });
523
+ }
524
+ export { DEFAULT_LIMITS, SceneViewport, basis, clampCamera, describeCamera, dolly, frameFor, lookAlong, multiply, pan, perspective, turn, useOrbitCamera, walk };
525
+
526
+ //# sourceMappingURL=scene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene.js","names":[],"sources":["../src/scene/camera.ts","../src/scene/scene-viewport.tsx"],"sourcesContent":["// The camera maths behind `SceneViewport` (issue #370), with no GL and no React, so it is tested on its\n// own and an app can use it to place things in the same space the viewport draws.\n//\n// One camera type covers both ways of looking. **Orbit**: `target` is the point looked at and `distance`\n// the way back from it; the eye is `target - forward * distance`. **Fly**: `distance` is 0, so the eye is\n// `target` and the person moves it. Angles are degrees: `yaw` turns about the vertical axis (positive turns\n// to the right, 0 looks along +z), `pitch` looks up when positive (0 on the horizon). Y is up, as in most\n// scene formats; an app whose world is Z-up (a Quake 2 map) rotates its world, or its `render`, once.\n// Matrices are column-major `Float32Array(16)`, the order WebGL's `uniformMatrix4fv` takes.\n\n/** Where the eye is and what it looks at. */\nexport type OrbitCamera = {\n /** The point looked at (orbit) or the eye itself (fly, `distance` 0). */\n target: readonly [number, number, number];\n /** How far the eye is from `target`. 0 is a fly camera. */\n distance: number;\n /** Degrees; positive turns right. */\n yaw: number;\n /** Degrees; positive looks up. */\n pitch: number;\n};\n\n/** Everything a draw needs, from a camera and a box. */\nexport type SceneFrame = {\n camera: OrbitCamera;\n /** The eye's place. */\n eye: [number, number, number];\n /** Unit vectors: where the camera looks, its right, and its up. */\n forward: [number, number, number];\n right: [number, number, number];\n up: [number, number, number];\n /** World to eye space. */\n view: Float32Array;\n projection: Float32Array;\n /** `projection × view`: one uniform for the usual vertex shader. */\n viewProjection: Float32Array;\n /** The drawing buffer's size in device pixels; `gl.viewport` is already set to it. */\n width: number;\n height: number;\n /** Counts up each time a GL context is made (the first, and each one restored after a loss): when it changes, recreate buffers, textures and programs. */\n context: number;\n};\n\n/** The limits a camera is held to. */\nexport type CameraLimits = { minDistance: number; maxDistance: number; maxPitch: number };\n\nexport const DEFAULT_LIMITS: CameraLimits = { minDistance: 0, maxDistance: Infinity, maxPitch: 89 };\n\nconst rad = (d: number) => (d * Math.PI) / 180;\n\n/** Keeps a camera inside its limits and its yaw in -180 to 180. */\nexport function clampCamera(c: OrbitCamera, limits: Partial<CameraLimits> = {}): OrbitCamera {\n const { minDistance, maxDistance, maxPitch } = { ...DEFAULT_LIMITS, ...limits };\n const yaw = ((((c.yaw + 180) % 360) + 360) % 360) - 180;\n // A fly camera (distance 0 at the start) stays one: only a camera that is orbiting is held off its target.\n const distance = c.distance === 0 && minDistance === 0 ? 0 : Math.min(Math.max(c.distance, minDistance), maxDistance);\n return { target: c.target, distance, yaw, pitch: Math.min(Math.max(c.pitch, -maxPitch), maxPitch) };\n}\n\ntype Vec3 = [number, number, number];\nconst cross = (a: Vec3, b: Vec3): Vec3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];\nconst dot = (a: Vec3, b: Vec3) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n\n/** The unit vectors a camera looks along, and to its right and up. */\nexport function basis(c: Pick<OrbitCamera, \"yaw\" | \"pitch\">): { forward: Vec3; right: Vec3; up: Vec3 } {\n // A right-handed world (+x right of a camera that looks along -z, as WebGL's maths assumes): looking\n // along +z with +y up, the right hand is -x, so a positive yaw (a turn to the right) swings the look\n // direction toward -x.\n const y = rad(c.yaw);\n const p = rad(c.pitch);\n const forward: Vec3 = [-Math.cos(p) * Math.sin(y), Math.sin(p), Math.cos(p) * Math.cos(y)];\n const right: Vec3 = [-Math.cos(y), 0, -Math.sin(y)];\n return { forward, right, up: cross(right, forward) };\n}\n\n/** A right-handed perspective projection (OpenGL clip space, depth -1 to 1). `fov` is the vertical field of view in degrees. */\nexport function perspective(fov: number, aspect: number, near: number, far: number): Float32Array {\n const f = 1 / Math.tan(rad(fov) / 2);\n const m = new Float32Array(16);\n m[0] = f / aspect;\n m[5] = f;\n m[10] = (far + near) / (near - far);\n m[11] = -1;\n m[14] = (2 * far * near) / (near - far);\n return m;\n}\n\n/** The view matrix of an eye looking along `forward`. */\nexport function lookAlong(eye: Vec3, forward: Vec3, right: Vec3, up: Vec3): Float32Array {\n const m = new Float32Array(16);\n m[0] = right[0]; m[4] = right[1]; m[8] = right[2]; m[12] = -dot(right, eye);\n m[1] = up[0]; m[5] = up[1]; m[9] = up[2]; m[13] = -dot(up, eye);\n m[2] = -forward[0]; m[6] = -forward[1]; m[10] = -forward[2]; m[14] = dot(forward, eye);\n m[15] = 1;\n return m;\n}\n\n/** `a × b` for column-major matrices. */\nexport function multiply(a: Float32Array, b: Float32Array): Float32Array {\n const out = new Float32Array(16);\n for (let col = 0; col < 4; col++)\n for (let row = 0; row < 4; row++) {\n let sum = 0;\n for (let k = 0; k < 4; k++) sum += a[k * 4 + row]! * b[col * 4 + k]!;\n out[col * 4 + row] = sum;\n }\n return out;\n}\n\n/** The frame for a camera in a drawing buffer of `width` by `height`. */\nexport function frameFor(camera: OrbitCamera, width: number, height: number, { fov = 60, near = 0.1, far = 10_000, context = 0 }: { fov?: number; near?: number; far?: number; context?: number } = {}): SceneFrame {\n const { forward, right, up } = basis(camera);\n const eye: Vec3 = [camera.target[0] - forward[0] * camera.distance, camera.target[1] - forward[1] * camera.distance, camera.target[2] - forward[2] * camera.distance];\n const view = lookAlong(eye, forward, right, up);\n const projection = perspective(fov, width / Math.max(1, height), near, far);\n return { camera, eye, forward, right, up, view, projection, viewProjection: multiply(projection, view), width, height, context };\n}\n\n/** Turns the camera as dragging does: orbit moves the eye round the target; look (fly) turns the head. Pixels in, degrees out at `degreesPerPixel`. */\nexport function turn(c: OrbitCamera, dx: number, dy: number, mode: \"orbit\" | \"fly\", degreesPerPixel = 0.35): OrbitCamera {\n // Orbit: the model follows the pointer, so the eye goes the other way. Fly: the picture follows the pointer.\n const sign = mode === \"orbit\" ? 1 : -1;\n return { ...c, yaw: c.yaw + sign * dx * degreesPerPixel, pitch: c.pitch - sign * dy * degreesPerPixel };\n}\n\n/** Moves the target in the screen's plane by pixels (a pan): the scene follows the pointer. `heightPx` is the box's height and `fov` the vertical field of view, which give the world size of a pixel at the target's distance. */\nexport function pan(c: OrbitCamera, dx: number, dy: number, heightPx: number, fov = 60): OrbitCamera {\n const { right, up } = basis(c);\n const perPixel = (2 * Math.max(c.distance, 0.001) * Math.tan(rad(fov) / 2)) / Math.max(1, heightPx);\n const move = (axis: number) => c.target[axis]! - right[axis]! * dx * perPixel + up[axis]! * dy * perPixel;\n return { ...c, target: [move(0), move(1), move(2)] };\n}\n\n/** Moves along the look direction (`ahead`), to the right (`side`) and up (`rise`), in world units: a fly camera's walk, or an orbit camera's pan by keys. */\nexport function walk(c: OrbitCamera, ahead: number, side: number, rise: number): OrbitCamera {\n const { forward, right } = basis(c);\n const to = (axis: number) => c.target[axis]! + forward[axis]! * ahead + right[axis]! * side + (axis === 1 ? rise : 0);\n return { ...c, target: [to(0), to(1), to(2)] };\n}\n\n/** Moves the eye toward or away from the target by a factor of the distance (orbit zoom). */\nexport function dolly(c: OrbitCamera, factor: number): OrbitCamera {\n return { ...c, distance: c.distance * factor };\n}\n\nconst turnWords = (deg: number, positive: string, negative: string) => (Math.abs(deg) < 1 ? \"\" : `${Math.round(Math.abs(deg))}° ${deg > 0 ? positive : negative}`);\n\n/** The camera in words, for the viewport's name and its status: \"Looking at 0, 2, 0 from 5 away, turned 45° right, 30° above the horizon\". */\nexport function describeCamera(c: OrbitCamera): string {\n const n = (v: number) => String(Math.round(v * 10) / 10);\n const turned = turnWords(c.yaw, \"right\", \"left\");\n const tilted = turnWords(c.pitch, \"up\", \"down\");\n const at = `${n(c.target[0])}, ${n(c.target[1])}, ${n(c.target[2])}`;\n const parts = [turned && `turned ${turned}`, tilted && `looking ${tilted}`].filter(Boolean).join(\", \");\n return c.distance === 0 ? `At ${at}${parts ? `, ${parts}` : \", looking straight ahead\"}` : `Looking at ${at} from ${n(c.distance)} away${parts ? `, ${parts}` : \"\"}`;\n}\n","import * as React from \"react\";\nimport { RotateCcw } from \"lucide-react\";\nimport { VisuallyHidden } from \"react-aria\";\nimport { Button } from \"../components/button\";\nimport { useInView } from \"../lib/in-view\";\nimport { cn } from \"../lib/utils\";\nimport { clampCamera, describeCamera, dolly, frameFor, pan, turn, walk, type CameraLimits, type OrbitCamera, type SceneFrame } from \"./camera\";\n\n// A frame for a 3D scene the app draws itself, that a person orbits, pans and zooms (issue #370, from the\n// Quake 2 explorer, which drew maps and models with its own camera code and controls). `PanoramaViewer`\n// is a WebGL view you look around from *inside*; this is the other kind: the app owns the drawing, Strata\n// owns the frame and the input, and everything Strata owns is what each app otherwise rewrites: pointer\n// capture, wheel zoom, keyboard control, a reset, a resize observer, a lost context, and what a screen\n// reader hears. Its own entry (`strata-react/scene`), like `strata-react/panorama`, so an app without 3D\n// ships none of it. No dependency: the camera maths is in `camera.ts`, and the context is the browser's.\n//\n// - **The app draws.** `render(gl, frame)` is called when the camera, the size or `invalidate()` changes\n// something, never on a timer (unless `continuous`, for a scene that moves by itself). `frame` has the\n// matrices and the eye, and the viewport is already set. A context made again after a loss bumps\n// `frame.context`, so the app knows to recreate what lived on the old one.\n// - **The camera is the app's to hold** (`useOrbitCamera`, or `camera` and `onCameraChange` of its own),\n// so a link, a saved view or a \"focus on this\" button just sets it, and the viewport never animates a\n// change it did not make. The one move it animates is Reset (300 ms ease), and not at all under reduced\n// motion.\n// - **Input.** Orbit by drag; pan by right drag, middle drag or Shift+drag; zoom by Ctrl or Cmd with the\n// wheel (which is also what a trackpad pinch sends) and by a two-finger pinch. A plain wheel scrolls the\n// page, as `ViewportFrame` does, since a 3D view in the middle of a page must not trap it. Keyboard, with\n// the frame focused: arrows orbit (Shift pans), `+` and `-` zoom, `0` resets. Touch is one finger to\n// orbit, two to pinch.\n// - **Fly mode** (`mode=\"fly\"`, for a map walkthrough): the same camera with `distance` 0, so it is the eye.\n// Drag looks (the picture follows the pointer), W A S D and the arrows walk and strafe, Q and E go down and\n// up, Shift is faster; keys held move on every frame, and under reduced motion each press is one step.\n// - **Said in words.** The canvas is an `img` named by `label` and the camera (\"Looking at 0, 2, 0 from 5\n// away, turned 45° right\"), always current, and a polite status says it once the camera has been still a\n// moment, never per frame. A Reset button is always there: a keyboard or touch person has no `0` key\n// to find, and a lost camera needs one visible way home.\n// - **No WebGL, no blank box**: a line says so, and the controls are not drawn.\n// React Aria first: there is no 3D part, so the frame is ours; the Reset button is Strata's `Button`\n// (React Aria's), and the camera maths is plain functions with tests.\n\n/** What a `SceneViewport` hands the app to hold: the camera, and ways to move it that obey the limits. */\nexport type OrbitCameraState = {\n camera: OrbitCamera;\n setCamera: (next: OrbitCamera) => void;\n /** Back to the camera the hook started with (the viewport's Reset button does this, animated). */\n home: OrbitCamera;\n};\n\n/** A camera the app holds: `{ target, distance, yaw, pitch }` to start from, and the limits it is kept inside. Give `camera` and `setCamera` to `SceneViewport`. */\nexport function useOrbitCamera(initial: Partial<OrbitCamera> = {}, limits: Partial<CameraLimits> = {}): OrbitCameraState {\n const home = React.useMemo<OrbitCamera>(\n () => clampCamera({ target: initial.target ?? [0, 0, 0], distance: initial.distance ?? 5, yaw: initial.yaw ?? 0, pitch: initial.pitch ?? 20 }, limits),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n const [camera, set] = React.useState<OrbitCamera>(home);\n const bounds = React.useRef(limits);\n bounds.current = limits;\n const setCamera = React.useCallback((next: OrbitCamera) => set(clampCamera(next, bounds.current)), []);\n return { camera, setCamera, home };\n}\n\nexport type SceneViewportProps = {\n /** Names the view: \"Map e1m1\". The camera in words is added to it. Required. */\n label: string;\n /** The camera, from `useOrbitCamera`. */\n camera: OrbitCamera;\n onCameraChange: (camera: OrbitCamera) => void;\n /** Where Reset goes. Default: the camera the viewport first had. */\n home?: OrbitCamera;\n /** Draws the scene. Called when the camera or size changed, or after `invalidate()`; the viewport is set. */\n render: (gl: WebGL2RenderingContext, frame: SceneFrame) => void;\n /** `\"orbit\"` (default) circles a target; `\"fly\"` is the eye itself, for a walkthrough. */\n mode?: \"orbit\" | \"fly\";\n /** The vertical field of view in degrees. Default 60. */\n fov?: number;\n near?: number;\n far?: number;\n /** Closest and furthest an orbit camera may be, and the highest and lowest look in degrees. Defaults 0, none, 89. */\n limits?: Partial<CameraLimits>;\n /** World units a second of fly walking covers. Default 5. */\n flySpeed?: number;\n /** Redraw every frame while on screen, for a scene that moves by itself. Default false: draw on change. */\n continuous?: boolean;\n /** The shape of the box. Default 16/9. */\n aspect?: number | `${number}/${number}`;\n /** A handle for `invalidate()` (a texture finished loading) and the canvas. */\n handle?: React.Ref<SceneViewportHandle>;\n className?: string;\n};\n\n/** What `handle` gives: ask for a redraw, and the canvas. */\nexport type SceneViewportHandle = { invalidate: () => void; canvas: HTMLCanvasElement | null };\n\nconst STILL_MS = 600;\nconst RESET_MS = 300;\nconst reducedMotion = () => typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n/** A sized, focusable canvas for a 3D scene the app draws: orbit by drag, pan by right drag or Shift, zoom by Ctrl/Cmd+wheel or pinch, keys, a Reset button, a fly mode, a lost context restored, and the camera in words. */\nexport function SceneViewport({ label, camera, onCameraChange, home, render, mode = \"orbit\", fov = 60, near = 0.1, far = 10_000, limits, flySpeed = 5, continuous = false, aspect = \"16/9\", handle, className }: SceneViewportProps) {\n const first = React.useRef(camera);\n const target = home ?? first.current;\n const live = React.useRef({ camera, onCameraChange, render, mode, fov, near, far, limits, flySpeed, home: target });\n live.current = { camera, onCameraChange, render, mode, fov, near, far, limits, flySpeed, home: target };\n const change = React.useCallback((next: OrbitCamera) => {\n live.current.onCameraChange(clampCamera(next, live.current.limits));\n }, []);\n\n const box = React.useRef<HTMLDivElement>(null);\n const canvas = React.useRef<HTMLCanvasElement>(null);\n const [size, setSize] = React.useState({ width: 0, height: 0 });\n React.useLayoutEffect(() => {\n const el = box.current;\n if (!el) return;\n const read = () => {\n const r = el.getBoundingClientRect();\n setSize((s) => (s.width === r.width && s.height === r.height ? s : { width: r.width, height: r.height }));\n };\n read();\n if (typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(read);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n // Drawing: only when something changed, and only while on screen.\n const { ref: visibleRef, inView } = useInView({ unsupported: true });\n const boxRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n box.current = el;\n visibleRef(el);\n },\n [visibleRef],\n );\n const gl = React.useRef<WebGL2RenderingContext | null>(null);\n const context = React.useRef(0);\n const [unavailable, setUnavailable] = React.useState(false);\n const frameHandle = React.useRef(0);\n const current = React.useRef({ size, inView, continuous });\n current.current = { size, inView, continuous };\n\n const paint = React.useCallback(() => {\n frameHandle.current = 0;\n const c = canvas.current;\n const ctx = gl.current;\n const { size: s, inView: visible, continuous: again } = current.current;\n if (!c || !ctx || !visible || s.width === 0 || s.height === 0) return;\n const dpr = Math.min(typeof devicePixelRatio === \"number\" ? devicePixelRatio : 1, 2);\n const w = Math.max(1, Math.round(s.width * dpr));\n const h = Math.max(1, Math.round(s.height * dpr));\n if (c.width !== w || c.height !== h) {\n c.width = w;\n c.height = h;\n }\n ctx.viewport(0, 0, w, h);\n const l = live.current;\n l.render(ctx, frameFor(l.camera, w, h, { fov: l.fov, near: l.near, far: l.far, context: context.current }));\n if (again) frameHandle.current = requestAnimationFrame(paint);\n }, []);\n const schedule = React.useCallback(() => {\n if (frameHandle.current === 0) frameHandle.current = requestAnimationFrame(paint);\n }, [paint]);\n React.useImperativeHandle(handle, () => ({ invalidate: schedule, canvas: canvas.current }), [schedule]);\n\n // The context: made once, made again when restored after a loss (the app sees `frame.context` change).\n React.useEffect(() => {\n const c = canvas.current;\n if (!c) return;\n const make = () => {\n gl.current = c.getContext(\"webgl2\") as WebGL2RenderingContext | null;\n setUnavailable(gl.current === null);\n if (gl.current) context.current += 1;\n schedule();\n };\n make();\n const lost = (e: Event) => {\n e.preventDefault();\n gl.current = null;\n };\n c.addEventListener(\"webglcontextlost\", lost);\n c.addEventListener(\"webglcontextrestored\", make);\n return () => {\n c.removeEventListener(\"webglcontextlost\", lost);\n c.removeEventListener(\"webglcontextrestored\", make);\n if (frameHandle.current) cancelAnimationFrame(frameHandle.current);\n frameHandle.current = 0;\n };\n }, [schedule]);\n React.useEffect(() => {\n schedule();\n }, [schedule, camera, size.width, size.height, inView, fov, near, far, continuous]);\n\n // Reset: animated unless the person asked for less motion.\n const animation = React.useRef(0);\n const reset = () => {\n cancelAnimationFrame(animation.current);\n const from = live.current.camera;\n const to = live.current.home;\n if (reducedMotion()) return change(to);\n const started = performance.now();\n const step = (now: number) => {\n const t = Math.min(1, (now - started) / RESET_MS);\n const e = 1 - (1 - t) ** 3;\n const mix = (a: number, b: number) => a + (b - a) * e;\n // The short way round in yaw.\n const dyaw = ((((to.yaw - from.yaw + 180) % 360) + 360) % 360) - 180;\n change({\n target: [mix(from.target[0], to.target[0]), mix(from.target[1], to.target[1]), mix(from.target[2], to.target[2])],\n distance: mix(from.distance, to.distance),\n yaw: from.yaw + dyaw * e,\n pitch: mix(from.pitch, to.pitch),\n });\n if (t < 1) animation.current = requestAnimationFrame(step);\n };\n animation.current = requestAnimationFrame(step);\n };\n React.useEffect(() => () => cancelAnimationFrame(animation.current), []);\n\n // Pointer: drag orbits (or looks), a right drag or Shift pans, two pointers pinch.\n const pointers = React.useRef(new Map<number, { x: number; y: number }>());\n const pinch = React.useRef<number | null>(null);\n const onPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.target instanceof HTMLButtonElement) return;\n pointers.current.set(e.pointerId, { x: e.clientX, y: e.clientY });\n e.currentTarget.setPointerCapture?.(e.pointerId);\n e.currentTarget.focus({ preventScroll: true });\n cancelAnimationFrame(animation.current);\n if (pointers.current.size === 2) {\n const [a, b] = [...pointers.current.values()];\n pinch.current = Math.hypot(a!.x - b!.x, a!.y - b!.y);\n }\n };\n const onPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {\n const last = pointers.current.get(e.pointerId);\n if (!last) return;\n const now = { x: e.clientX, y: e.clientY };\n pointers.current.set(e.pointerId, now);\n const l = live.current;\n if (pointers.current.size === 2) {\n const [a, b] = [...pointers.current.values()];\n const d = Math.hypot(a!.x - b!.x, a!.y - b!.y);\n if (pinch.current && d > 0 && l.mode === \"orbit\") change(dolly(l.camera, pinch.current / d));\n pinch.current = d;\n return;\n }\n const dx = now.x - last.x;\n const dy = now.y - last.y;\n const panning = e.shiftKey || (e.buttons & 6) !== 0; // Shift, or the right or middle button\n change(panning ? pan(l.camera, dx, dy, size.height, l.fov) : turn(l.camera, dx, dy, l.mode));\n };\n const onPointerUp = (e: React.PointerEvent<HTMLDivElement>) => {\n pointers.current.delete(e.pointerId);\n pinch.current = null;\n };\n\n // The wheel zooms only with Ctrl or Cmd (a trackpad pinch sends Ctrl); a plain wheel scrolls the page.\n // Native, because React's wheel listener is passive and the page's own zoom must be refused.\n React.useEffect(() => {\n const el = box.current;\n if (!el) return;\n const onWheel = (e: WheelEvent) => {\n if (!e.ctrlKey && !e.metaKey) return;\n e.preventDefault();\n const l = live.current;\n if (l.mode === \"orbit\") change(dolly(l.camera, Math.exp(e.deltaY * 0.0015)));\n else change(walk(l.camera, -e.deltaY * 0.01 * l.flySpeed, 0, 0));\n };\n el.addEventListener(\"wheel\", onWheel, { passive: false });\n return () => el.removeEventListener(\"wheel\", onWheel);\n }, [change]);\n\n // Keys. Orbit: arrows turn (Shift pans), + and - zoom, 0 resets. Fly: W A S D and arrows walk, Q and E go\n // down and up, held keys move every frame (one step each press under reduced motion).\n const held = React.useRef(new Set<string>());\n const flyLoop = React.useRef(0);\n const flyKeys = [\"w\", \"a\", \"s\", \"d\", \"q\", \"e\", \"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\"];\n const walkFrom = (keys: Iterable<string>, seconds: number, fast: boolean) => {\n const l = live.current;\n const k = new Set(keys);\n const stride = l.flySpeed * seconds * (fast ? 3 : 1);\n const axis = (plus: string[], minus: string[]) => (plus.some((x) => k.has(x)) ? 1 : 0) - (minus.some((x) => k.has(x)) ? 1 : 0);\n change(walk(l.camera, axis([\"w\", \"ArrowUp\"], [\"s\", \"ArrowDown\"]) * stride, axis([\"d\", \"ArrowRight\"], [\"a\", \"ArrowLeft\"]) * stride, axis([\"e\"], [\"q\"]) * stride));\n };\n const startFly = (shift: boolean) => {\n if (flyLoop.current) return;\n let last = performance.now();\n const tick = (now: number) => {\n walkFrom(held.current, (now - last) / 1000, shift);\n last = now;\n flyLoop.current = held.current.size ? requestAnimationFrame(tick) : 0;\n };\n flyLoop.current = requestAnimationFrame(tick);\n };\n React.useEffect(() => () => cancelAnimationFrame(flyLoop.current), []);\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.ctrlKey || e.metaKey || e.altKey) return;\n const l = live.current;\n const key = e.key.length === 1 ? e.key.toLowerCase() : e.key;\n if (key === \"0\") reset();\n else if (l.mode === \"fly\" && flyKeys.includes(key)) {\n if (reducedMotion()) walkFrom([key], 0.2, e.shiftKey);\n else {\n held.current.add(key);\n startFly(e.shiftKey);\n }\n } else if (key === \"+\" || key === \"=\") change(l.mode === \"orbit\" ? dolly(l.camera, 0.8) : walk(l.camera, l.flySpeed * 0.5, 0, 0));\n else if (key === \"-\" || key === \"_\") change(l.mode === \"orbit\" ? dolly(l.camera, 1.25) : walk(l.camera, -l.flySpeed * 0.5, 0, 0));\n else if (l.mode === \"orbit\" && key.startsWith(\"Arrow\")) {\n const step = e.shiftKey ? 30 : 10; // pixels' worth, so keys and the pointer agree\n const dx = key === \"ArrowRight\" ? step : key === \"ArrowLeft\" ? -step : 0;\n const dy = key === \"ArrowDown\" ? step : key === \"ArrowUp\" ? -step : 0;\n change(e.shiftKey ? pan(l.camera, -dx, -dy, size.height, l.fov) : turn(l.camera, dx, dy, \"orbit\"));\n } else return;\n e.preventDefault();\n };\n const onKeyUp = (e: React.KeyboardEvent) => {\n held.current.delete(e.key.length === 1 ? e.key.toLowerCase() : e.key);\n };\n\n // Said in words, politely once the camera has been still for a moment.\n const words = describeCamera(camera);\n const [said, setSaid] = React.useState(\"\");\n const firstWords = React.useRef(true);\n React.useEffect(() => {\n if (firstWords.current) {\n firstWords.current = false;\n return;\n }\n const t = setTimeout(() => setSaid(words), STILL_MS);\n return () => clearTimeout(t);\n }, [words]);\n\n return (\n <div className={cn(\"grid min-w-0 gap-2\", className)}>\n <div\n ref={boxRef}\n role=\"group\"\n aria-label={label}\n tabIndex={0}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onBlur={() => held.current.clear()}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onContextMenu={(e) => e.preventDefault()}\n className=\"relative w-full cursor-grab touch-none overflow-hidden rounded-surface bg-surface-sunken select-none active:cursor-grabbing\"\n style={{ aspectRatio: aspect }}\n >\n <canvas ref={canvas} role=\"img\" aria-label={`${label}. ${words}`} className=\"absolute inset-0 size-full\" />\n {!unavailable && (\n <Button size=\"sm\" variant=\"outline\" onPress={reset} className=\"absolute top-2 right-2\">\n <RotateCcw /> Reset view\n </Button>\n )}\n </div>\n {unavailable && <p className=\"type-body-sm text-muted-foreground\">This browser cannot draw the 3D view.</p>}\n <VisuallyHidden>\n <span role=\"status\">{said}</span>\n </VisuallyHidden>\n </div>\n );\n}\n"],"mappings":";;;;;;;AA8CA,IAAa,iBAA+B;CAAE,aAAa;CAAG,aAAa;CAAU,UAAU;AAAG;AAElG,IAAM,OAAO,MAAe,IAAI,KAAK,KAAM;;AAG3C,SAAgB,YAAY,GAAgB,SAAgC,CAAC,GAAgB;CAC3F,MAAM,EAAE,aAAa,aAAa,aAAa;EAAE,GAAG;EAAgB,GAAG;CAAO;CAC9E,MAAM,QAAU,EAAE,MAAM,OAAO,MAAO,OAAO,MAAO;CAEpD,MAAM,WAAW,EAAE,aAAa,KAAK,gBAAgB,IAAI,IAAI,KAAK,IAAI,KAAK,IAAI,EAAE,UAAU,WAAW,GAAG,WAAW;CACpH,OAAO;EAAE,QAAQ,EAAE;EAAQ;EAAU;EAAK,OAAO,KAAK,IAAI,KAAK,IAAI,EAAE,OAAO,CAAC,QAAQ,GAAG,QAAQ;CAAE;AACpG;AAGA,IAAM,SAAS,GAAS,MAAkB;CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;A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AS,WAAU;IAA8B,CAAA,GACzG,CAAC,eACA,qBAAC,QAAD;KAAQ,MAAK;KAAK,SAAQ;KAAU,SAAS;KAAO,WAAU;KAA9D,UAAA,CACE,oBAAC,WAAD,CAAY,CAAA,GAAC,aACP;IAEP,CAAA,CAAA;;GACJ,eAAe,oBAAC,KAAD;IAAG,WAAU;IAAqC,UAAA;GAAwC,CAAA;GAC1G,oBAAC,gBAAD,EAAA,UACE,oBAAC,QAAD;IAAM,MAAK;IAAU,UAAA;GAAW,CAAA,EAClB,CAAA;EACb;;AAET"}
@@ -200,6 +200,7 @@
200
200
  /* Stacking, once, for every floating thing, so an app never writes a z-index. A bar (the undo
201
201
  bar, toasts) sits above panes and sticky headers; overlays (dialogs, popovers, menus) above
202
202
  bars; a tooltip above everything, since it can name a control inside an overlay. */
203
+ @utility image-pixelated { image-rendering: pixelated; }
203
204
  @utility layer-bar { z-index: 50; }
204
205
  @utility layer-overlay { z-index: 60; }
205
206
  @utility layer-tip { z-index: 70; }
package/dist/strata.css CHANGED
@@ -195,6 +195,7 @@
195
195
  /* Stacking, once, for every floating thing, so an app never writes a z-index. A bar (the undo
196
196
  bar, toasts) sits above panes and sticky headers; overlays (dialogs, popovers, menus) above
197
197
  bars; a tooltip above everything, since it can name a control inside an overlay. */
198
+ @utility image-pixelated { image-rendering: pixelated; }
198
199
  @utility layer-bar { z-index: 50; }
199
200
  @utility layer-overlay { z-index: 60; }
200
201
  @utility layer-tip { z-index: 70; }
@@ -191,6 +191,7 @@
191
191
  /* Stacking, once, for every floating thing, so an app never writes a z-index. A bar (the undo
192
192
  bar, toasts) sits above panes and sticky headers; overlays (dialogs, popovers, menus) above
193
193
  bars; a tooltip above everything, since it can name a control inside an overlay. */
194
+ @utility image-pixelated { image-rendering: pixelated; }
194
195
  @utility layer-bar { z-index: 50; }
195
196
  @utility layer-overlay { z-index: 60; }
196
197
  @utility layer-tip { z-index: 70; }
@@ -13,6 +13,7 @@ import { Microphone } from '../lib/microphone';
13
13
  */
14
14
  import * as React from "react";
15
15
  export { installLayoutShims, type LayoutBox } from './layout';
16
+ export { setupStrataTests, type StrataTestSetup } from './setup';
16
17
  export { installStorageShim, memoryStorage } from './storage';
17
18
  export { installFakeSpeech, type FakeSpeech, type Spoken } from './speech';
18
19
  export { fakeMicrophone, speechScript, type FakeMicrophoneOptions, type FakeSpeechStretch } from './microphone';
@@ -8,6 +8,6 @@ export interface LayoutBox {
8
8
  /**
9
9
  * Give jsdom a fixed box for every element (`getBoundingClientRect`, `offset*`, `client*`) and a
10
10
  * ResizeObserver that reports it on observe, so measuring components render, and an in-memory `localStorage` and `sessionStorage` where the runtime's throw (Node 25+). Defaults to 640×280.
11
- * Call once in a Vitest setup file; returns a function that puts the originals back.
11
+ * Call once in a Vitest setup file (or let `setupStrataTests` do it); does nothing, and returns a no-op, where there is no DOM (a node-environment test); returns a function that puts the originals back.
12
12
  */
13
13
  export declare function installLayoutShims({ width, height }?: Partial<LayoutBox>): () => void;