strata-react 1.3.24 → 1.3.26

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 (253) hide show
  1. package/README.md +1 -1
  2. package/UPGRADING.md +7 -0
  3. package/dist/{api-types/cli.d.ts → api-types-cli.d.ts} +1 -0
  4. package/dist/api-types-cli.js +4 -3
  5. package/dist/api-types-cli.js.map +1 -1
  6. package/dist/{api-types/generate.d.ts → api-types.d.ts} +3 -3
  7. package/dist/api-types.js +3 -1
  8. package/dist/{button-KGJI6jQr.js → button-CYXjU-fs.js} +8 -5
  9. package/dist/button-CYXjU-fs.js.map +1 -0
  10. package/dist/{cursor-DDGBPiTJ.js → cursor-Cwyvgwsw.js} +9 -7
  11. package/dist/cursor-Cwyvgwsw.js.map +1 -0
  12. package/dist/{errors-BUvY1Z4d.js → errors-CmuwcWlb.js} +6 -6
  13. package/dist/{errors-BUvY1Z4d.js.map → errors-CmuwcWlb.js.map} +1 -1
  14. package/dist/{field-BjeE_FeB.js → field-DBCsFIng.js} +27 -23
  15. package/dist/field-DBCsFIng.js.map +1 -0
  16. package/dist/follow-CXQsL86O.js +16 -0
  17. package/dist/follow-CXQsL86O.js.map +1 -0
  18. package/dist/{generate-CjTHKJ39.js → generate-BkWhh4k4.js} +8 -6
  19. package/dist/generate-BkWhh4k4.js.map +1 -0
  20. package/dist/{lib/geo.d.ts → geo-DfKa9JtK.d.ts} +35 -33
  21. package/dist/{hls/index.d.ts → hls.d.ts} +13 -12
  22. package/dist/hls.js +5 -4
  23. package/dist/hls.js.map +1 -1
  24. package/dist/index.d.ts +5300 -140
  25. package/dist/index.js +363 -224
  26. package/dist/index.js.map +1 -1
  27. package/dist/map.d.ts +184 -0
  28. package/dist/map.js +21 -17
  29. package/dist/map.js.map +1 -1
  30. package/dist/media-player-BETa3P7K.d.ts +758 -0
  31. package/dist/{microphone-Bo3WaXgD.js → microphone-76skMt6i.js} +41 -30
  32. package/dist/microphone-76skMt6i.js.map +1 -0
  33. package/dist/microphone-DDOnQHxf.d.ts +237 -0
  34. package/dist/{migrate/cli.d.ts → migrate-cli.d.ts} +1 -0
  35. package/dist/migrate-cli.js +8 -6
  36. package/dist/migrate-cli.js.map +1 -1
  37. package/dist/panorama.d.ts +102 -0
  38. package/dist/panorama.js +54 -109
  39. package/dist/panorama.js.map +1 -1
  40. package/dist/{run-BT2WKzMz.js → run-D_Ic1jE7.js} +23 -16
  41. package/dist/run-D_Ic1jE7.js.map +1 -0
  42. package/dist/scene.d.ts +147 -0
  43. package/dist/scene.js +74 -77
  44. package/dist/scene.js.map +1 -1
  45. package/dist/testing.d.ts +468 -0
  46. package/dist/testing.js +11 -3
  47. package/dist/testing.js.map +1 -1
  48. package/dist/{theme-CxYZkUNk.js → theme-1oOSMj_D.js} +19 -17
  49. package/dist/theme-1oOSMj_D.js.map +1 -0
  50. package/dist/{tooltip-DhqrDtyu.js → tooltip-BosfsWYh.js} +9 -6
  51. package/dist/tooltip-BosfsWYh.js.map +1 -0
  52. package/dist/types-B3TsF0Ey.d.ts +241 -0
  53. package/dist/{value-controls-Dm_EYfZW.js → value-controls-5u7sD_wG.js} +22 -17
  54. package/dist/value-controls-5u7sD_wG.js.map +1 -0
  55. package/dist/viewer-input-3Qa-o35k.js +108 -0
  56. package/dist/viewer-input-3Qa-o35k.js.map +1 -0
  57. package/dist/{visual/cli.d.ts → visual-cli.d.ts} +2 -1
  58. package/dist/visual-cli.js +5 -4
  59. package/dist/visual-cli.js.map +1 -1
  60. package/dist/visual.d.ts +105 -0
  61. package/dist/visual.js +4 -3
  62. package/dist/visual.js.map +1 -1
  63. package/package.json +24 -19
  64. package/dist/api-types/index.d.ts +0 -1
  65. package/dist/button-KGJI6jQr.js.map +0 -1
  66. package/dist/components/active-list.d.ts +0 -46
  67. package/dist/components/alert.d.ts +0 -17
  68. package/dist/components/app-shell.d.ts +0 -32
  69. package/dist/components/async-button.d.ts +0 -48
  70. package/dist/components/auto-recorder.d.ts +0 -67
  71. package/dist/components/book-viewer.d.ts +0 -50
  72. package/dist/components/box-overlay.d.ts +0 -44
  73. package/dist/components/boxed-picture.d.ts +0 -34
  74. package/dist/components/button.d.ts +0 -45
  75. package/dist/components/byte-view.d.ts +0 -32
  76. package/dist/components/checkbox.d.ts +0 -39
  77. package/dist/components/choice-grid.d.ts +0 -42
  78. package/dist/components/commands.d.ts +0 -104
  79. package/dist/components/compare-audio.d.ts +0 -30
  80. package/dist/components/compare-grid.d.ts +0 -24
  81. package/dist/components/compare-parts.d.ts +0 -90
  82. package/dist/components/compare-regions.d.ts +0 -37
  83. package/dist/components/compare-text.d.ts +0 -32
  84. package/dist/components/compare-video-grid.d.ts +0 -52
  85. package/dist/components/compare-video.d.ts +0 -61
  86. package/dist/components/compare.d.ts +0 -90
  87. package/dist/components/composition.d.ts +0 -44
  88. package/dist/components/console.d.ts +0 -34
  89. package/dist/components/conversation.d.ts +0 -83
  90. package/dist/components/cursor.d.ts +0 -44
  91. package/dist/components/data-table.d.ts +0 -89
  92. package/dist/components/data-view.d.ts +0 -66
  93. package/dist/components/density.d.ts +0 -16
  94. package/dist/components/dialog.d.ts +0 -45
  95. package/dist/components/difference.d.ts +0 -19
  96. package/dist/components/disclosure.d.ts +0 -49
  97. package/dist/components/done.d.ts +0 -14
  98. package/dist/components/drag-source.d.ts +0 -29
  99. package/dist/components/field.d.ts +0 -79
  100. package/dist/components/file-intake.d.ts +0 -60
  101. package/dist/components/film-strip.d.ts +0 -35
  102. package/dist/components/folder-picker.d.ts +0 -59
  103. package/dist/components/fullscreen-frame.d.ts +0 -18
  104. package/dist/components/history.d.ts +0 -61
  105. package/dist/components/hotkeys.d.ts +0 -44
  106. package/dist/components/infinite-list.d.ts +0 -77
  107. package/dist/components/inspector.d.ts +0 -66
  108. package/dist/components/job-action.d.ts +0 -30
  109. package/dist/components/job-status.d.ts +0 -55
  110. package/dist/components/jobs-table.d.ts +0 -35
  111. package/dist/components/key-glyphs.d.ts +0 -5
  112. package/dist/components/key-owner.d.ts +0 -11
  113. package/dist/components/lightbox.d.ts +0 -61
  114. package/dist/components/line-chart.d.ts +0 -169
  115. package/dist/components/link-card.d.ts +0 -32
  116. package/dist/components/link.d.ts +0 -54
  117. package/dist/components/markable-text.d.ts +0 -60
  118. package/dist/components/media-contents.d.ts +0 -28
  119. package/dist/components/media-group.d.ts +0 -32
  120. package/dist/components/media-player.d.ts +0 -251
  121. package/dist/components/media-progress.d.ts +0 -17
  122. package/dist/components/media-skip.d.ts +0 -31
  123. package/dist/components/media-spans.d.ts +0 -93
  124. package/dist/components/media.d.ts +0 -133
  125. package/dist/components/meter.d.ts +0 -32
  126. package/dist/components/metric.d.ts +0 -17
  127. package/dist/components/outbox-status.d.ts +0 -10
  128. package/dist/components/page-header.d.ts +0 -14
  129. package/dist/components/pair-vote.d.ts +0 -70
  130. package/dist/components/pause-button.d.ts +0 -7
  131. package/dist/components/pixel-image.d.ts +0 -29
  132. package/dist/components/place-board.d.ts +0 -39
  133. package/dist/components/player-warning.d.ts +0 -24
  134. package/dist/components/popover.d.ts +0 -20
  135. package/dist/components/recorder.d.ts +0 -73
  136. package/dist/components/region-editor.d.ts +0 -67
  137. package/dist/components/save.d.ts +0 -46
  138. package/dist/components/say-again.d.ts +0 -13
  139. package/dist/components/schedule-table.d.ts +0 -24
  140. package/dist/components/secret-field.d.ts +0 -34
  141. package/dist/components/selectable-grid.d.ts +0 -57
  142. package/dist/components/selection.d.ts +0 -104
  143. package/dist/components/sequence-timeline.d.ts +0 -50
  144. package/dist/components/shortcut-editor.d.ts +0 -44
  145. package/dist/components/sortable-list.d.ts +0 -39
  146. package/dist/components/status.d.ts +0 -9
  147. package/dist/components/switch.d.ts +0 -15
  148. package/dist/components/system-panel.d.ts +0 -58
  149. package/dist/components/tabs.d.ts +0 -16
  150. package/dist/components/theme.d.ts +0 -106
  151. package/dist/components/thumbnail.d.ts +0 -50
  152. package/dist/components/tile-grid.d.ts +0 -67
  153. package/dist/components/timeline-player.d.ts +0 -18
  154. package/dist/components/timeline.d.ts +0 -115
  155. package/dist/components/toast.d.ts +0 -36
  156. package/dist/components/toggle.d.ts +0 -51
  157. package/dist/components/toolbar.d.ts +0 -15
  158. package/dist/components/tooltip.d.ts +0 -19
  159. package/dist/components/transcript-view.d.ts +0 -63
  160. package/dist/components/tree.d.ts +0 -74
  161. package/dist/components/undo.d.ts +0 -63
  162. package/dist/components/use-timeline.d.ts +0 -44
  163. package/dist/components/value-controls.d.ts +0 -91
  164. package/dist/components/video-clock.d.ts +0 -68
  165. package/dist/components/view-options.d.ts +0 -105
  166. package/dist/components/viewport.d.ts +0 -85
  167. package/dist/components/virtual-list.d.ts +0 -19
  168. package/dist/components/waveform.d.ts +0 -71
  169. package/dist/components/workflow-steps.d.ts +0 -71
  170. package/dist/components/workspace.d.ts +0 -83
  171. package/dist/cursor-DDGBPiTJ.js.map +0 -1
  172. package/dist/field-BjeE_FeB.js.map +0 -1
  173. package/dist/generate-CjTHKJ39.js.map +0 -1
  174. package/dist/lib/base.d.ts +0 -10
  175. package/dist/lib/book.d.ts +0 -25
  176. package/dist/lib/boxes.d.ts +0 -55
  177. package/dist/lib/breakpoint.d.ts +0 -4
  178. package/dist/lib/choice.d.ts +0 -29
  179. package/dist/lib/chords.d.ts +0 -20
  180. package/dist/lib/client-work.d.ts +0 -24
  181. package/dist/lib/control.d.ts +0 -4
  182. package/dist/lib/dev.d.ts +0 -2
  183. package/dist/lib/errors.d.ts +0 -43
  184. package/dist/lib/file-intake.d.ts +0 -60
  185. package/dist/lib/format.d.ts +0 -243
  186. package/dist/lib/grouped-grid-layout.d.ts +0 -44
  187. package/dist/lib/icon.d.ts +0 -6
  188. package/dist/lib/image-diff.d.ts +0 -30
  189. package/dist/lib/in-view.d.ts +0 -21
  190. package/dist/lib/loudness.d.ts +0 -18
  191. package/dist/lib/marks.d.ts +0 -6
  192. package/dist/lib/microphone.d.ts +0 -24
  193. package/dist/lib/number-input.d.ts +0 -4
  194. package/dist/lib/object-url.d.ts +0 -2
  195. package/dist/lib/overlay.d.ts +0 -1
  196. package/dist/lib/recording.d.ts +0 -16
  197. package/dist/lib/region.d.ts +0 -64
  198. package/dist/lib/rich-text.d.ts +0 -44
  199. package/dist/lib/search-param.d.ts +0 -16
  200. package/dist/lib/segmenter.d.ts +0 -40
  201. package/dist/lib/sequence.d.ts +0 -34
  202. package/dist/lib/speech.d.ts +0 -53
  203. package/dist/lib/text-diff.d.ts +0 -16
  204. package/dist/lib/timeline.d.ts +0 -14
  205. package/dist/lib/transcript.d.ts +0 -53
  206. package/dist/lib/utils.d.ts +0 -4
  207. package/dist/lib/viewport.d.ts +0 -55
  208. package/dist/lib/waveform.d.ts +0 -46
  209. package/dist/map/fan.d.ts +0 -15
  210. package/dist/map/index.d.ts +0 -3
  211. package/dist/map/map-styles.d.ts +0 -2
  212. package/dist/map/markers.d.ts +0 -60
  213. package/dist/map/route-map.d.ts +0 -146
  214. package/dist/microphone-Bo3WaXgD.js.map +0 -1
  215. package/dist/migrate/stock-classes.d.ts +0 -11
  216. package/dist/panorama/gl.d.ts +0 -16
  217. package/dist/panorama/index.d.ts +0 -2
  218. package/dist/panorama/panorama-viewer.d.ts +0 -56
  219. package/dist/panorama/projection.d.ts +0 -45
  220. package/dist/query/api.d.ts +0 -23
  221. package/dist/query/clips.d.ts +0 -48
  222. package/dist/query/index.d.ts +0 -55
  223. package/dist/query/infinite.d.ts +0 -60
  224. package/dist/query/job.d.ts +0 -26
  225. package/dist/query/outbox.d.ts +0 -85
  226. package/dist/query/poll.d.ts +0 -24
  227. package/dist/query/reserve.d.ts +0 -33
  228. package/dist/query/typed-api.d.ts +0 -84
  229. package/dist/query/workflow.d.ts +0 -17
  230. package/dist/run-BT2WKzMz.js.map +0 -1
  231. package/dist/scene/camera.d.ts +0 -74
  232. package/dist/scene/index.d.ts +0 -2
  233. package/dist/scene/scene-viewport.d.ts +0 -48
  234. package/dist/testing/buttons.d.ts +0 -7
  235. package/dist/testing/index.d.ts +0 -161
  236. package/dist/testing/intersection-observer.d.ts +0 -34
  237. package/dist/testing/layout.d.ts +0 -13
  238. package/dist/testing/microphone.d.ts +0 -35
  239. package/dist/testing/setup.d.ts +0 -14
  240. package/dist/testing/speech.d.ts +0 -38
  241. package/dist/testing/storage.d.ts +0 -7
  242. package/dist/theme-CxYZkUNk.js.map +0 -1
  243. package/dist/tooltip-DhqrDtyu.js.map +0 -1
  244. package/dist/value-controls-Dm_EYfZW.js.map +0 -1
  245. package/dist/visual/capture.d.ts +0 -37
  246. package/dist/visual/compare.d.ts +0 -46
  247. package/dist/visual/drop.d.ts +0 -19
  248. package/dist/visual/fonts.d.ts +0 -18
  249. package/dist/visual/index.d.ts +0 -19
  250. package/dist/visual/run.d.ts +0 -22
  251. package/dist/visual/serve.d.ts +0 -13
  252. package/dist/visual/targets.d.ts +0 -17
  253. package/dist/visual/types.d.ts +0 -188
@@ -0,0 +1,147 @@
1
+ import * as React from "react";
2
+ /** Where the eye is and what it looks at. */
3
+ type OrbitCamera = {
4
+ /** The point looked at (orbit) or the eye itself (fly, `distance` 0). */
5
+ target: readonly [number, number, number];
6
+ /** How far the eye is from `target`. 0 is a fly camera. */
7
+ distance: number;
8
+ /** Degrees; positive turns right. */
9
+ yaw: number;
10
+ /** Degrees; positive looks up. */
11
+ pitch: number;
12
+ };
13
+ /** Everything a draw needs, from a camera and a box. */
14
+ type SceneFrame = {
15
+ camera: OrbitCamera;
16
+ /** The eye's place. */
17
+ eye: [number, number, number];
18
+ /** Unit vectors: where the camera looks, its right, and its up. */
19
+ forward: [number, number, number];
20
+ right: [number, number, number];
21
+ up: [number, number, number];
22
+ /** World to eye space. */
23
+ view: Float32Array;
24
+ projection: Float32Array;
25
+ /** `projection × view`: one uniform for the usual vertex shader. */
26
+ viewProjection: Float32Array;
27
+ /** The drawing buffer's size in device pixels; `gl.viewport` is already set to it. */
28
+ width: number;
29
+ height: number;
30
+ /** 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. */
31
+ context: number;
32
+ /** The scene's time in seconds when the viewport was given a `time` (a `useTimeline` clock's; issue #386), else 0: draw the scene as it is at this moment. */
33
+ time: number;
34
+ };
35
+ /** The limits a camera is held to. */
36
+ type CameraLimits = {
37
+ minDistance: number;
38
+ maxDistance: number;
39
+ maxPitch: number;
40
+ };
41
+ export declare const DEFAULT_LIMITS: CameraLimits;
42
+ /** Keeps a camera inside its limits and its yaw in -180 to 180. */
43
+ export declare function clampCamera(c: OrbitCamera, limits?: Partial<CameraLimits>): OrbitCamera;
44
+ type Vec3 = [number, number, number];
45
+ /** The unit vectors a camera looks along, and to its right and up. */
46
+ export declare function basis(c: Pick<OrbitCamera, "yaw" | "pitch">): {
47
+ forward: Vec3;
48
+ right: Vec3;
49
+ up: Vec3;
50
+ };
51
+ /** A right-handed perspective projection (OpenGL clip space, depth -1 to 1). `fov` is the vertical field of view in degrees. */
52
+ export declare function perspective(fov: number, aspect: number, near: number, far: number): Float32Array;
53
+ /** The view matrix of an eye looking along `forward`. */
54
+ export declare function lookAlong(eye: Vec3, forward: Vec3, right: Vec3, up: Vec3): Float32Array;
55
+ /** `a × b` for column-major matrices. */
56
+ export declare function multiply(a: Float32Array, b: Float32Array): Float32Array;
57
+ /** The frame for a camera in a drawing buffer of `width` by `height`. */
58
+ export declare function frameFor(camera: OrbitCamera, width: number, height: number, { fov, near, far, context, time }?: {
59
+ fov?: number;
60
+ near?: number;
61
+ far?: number;
62
+ context?: number;
63
+ time?: number;
64
+ }): SceneFrame;
65
+ /** Turns the camera as dragging does: orbit moves the eye round the target; look (fly) turns the head. Pixels in, degrees out at `degreesPerPixel`. */
66
+ export declare function turn(c: OrbitCamera, dx: number, dy: number, mode: "orbit" | "fly", degreesPerPixel?: number): OrbitCamera;
67
+ /** 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. */
68
+ export declare function pan(c: OrbitCamera, dx: number, dy: number, heightPx: number, fov?: number): OrbitCamera;
69
+ /** 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. */
70
+ export declare function walk(c: OrbitCamera, ahead: number, side: number, rise: number): OrbitCamera;
71
+ /** Moves the eye toward or away from the target by a factor of the distance (orbit zoom). */
72
+ export declare function dolly(c: OrbitCamera, factor: number): OrbitCamera;
73
+ /** 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". */
74
+ export declare function describeCamera(c: OrbitCamera): string;
75
+ /** A view from inside a sphere as `PanoramaViewer` holds it: the same degrees, positive yaw to the right and positive pitch up. */
76
+ type LookView = {
77
+ yaw: number;
78
+ pitch: number;
79
+ fov: number;
80
+ };
81
+ /** The fly camera that sees what a `PanoramaViewer` view sees from `eye`: one view model for looking from a point, in a picture or a scene (issue #386). */
82
+ export declare function cameraFromView(view: Pick<LookView, "yaw" | "pitch">, eye?: readonly [number, number, number]): OrbitCamera;
83
+ /** The panorama view a camera looks along from its eye (an orbit camera looks along its `forward` just the same), with the field of view given. */
84
+ export declare function viewFromCamera(camera: Pick<OrbitCamera, "yaw" | "pitch">, fov: number): LookView;
85
+ /**
86
+ * A camera that follows a moving point (issue #386, "through the player's eyes" in a replay): the eye is at `eye` and looks along the
87
+ * heading the app supplies, plus the person's own `look` on top. With `behind` it is a chase camera instead, that far back along the look.
88
+ */
89
+ export declare function followCamera({ eye, heading, pitch, look, behind, maxPitch }: {
90
+ eye: readonly [number, number, number];
91
+ heading: number;
92
+ pitch?: number;
93
+ look?: {
94
+ yaw?: number;
95
+ pitch?: number;
96
+ };
97
+ behind?: number;
98
+ maxPitch?: number;
99
+ }): OrbitCamera;
100
+ /** What a `SceneViewport` hands the app to hold: the camera, and ways to move it that obey the limits. */
101
+ type OrbitCameraState = {
102
+ camera: OrbitCamera;
103
+ setCamera: (next: OrbitCamera) => void;
104
+ /** Back to the camera the hook started with (the viewport's Reset button does this, animated). */
105
+ home: OrbitCamera;
106
+ };
107
+ /** 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`. */
108
+ export declare function useOrbitCamera(initial?: Partial<OrbitCamera>, limits?: Partial<CameraLimits>): OrbitCameraState;
109
+ type SceneViewportProps = {
110
+ /** Names the view: "Map e1m1". The camera in words is added to it. Required. */
111
+ label: string;
112
+ /** The camera, from `useOrbitCamera`. */
113
+ camera: OrbitCamera;
114
+ onCameraChange: (camera: OrbitCamera) => void;
115
+ /** Where Reset goes. Default: the camera the viewport first had. */
116
+ home?: OrbitCamera;
117
+ /** Draws the scene. Called when the camera or size changed, or after `invalidate()`; the viewport is set. */
118
+ render: (gl: WebGL2RenderingContext, frame: SceneFrame) => void;
119
+ /** `"orbit"` (default) circles a target; `"fly"` is the eye itself, for a walkthrough. */
120
+ mode?: "orbit" | "fly";
121
+ /** The vertical field of view in degrees. Default 60. */
122
+ fov?: number;
123
+ near?: number;
124
+ far?: number;
125
+ /** Closest and furthest an orbit camera may be, and the highest and lowest look in degrees. Defaults 0, none, 89. */
126
+ limits?: Partial<CameraLimits>;
127
+ /** World units a second of fly walking covers. Default 5. */
128
+ flySpeed?: number;
129
+ /** The scene's time in seconds, from a `useTimeline` clock (issue #386): the scene is drawn again when it changes, with `frame.time` set, so a recorded run or a replay scrubs and plays like a video under `TimelinePlayer`. Default: no time. */
130
+ time?: number;
131
+ /** Redraw every frame while on screen, for a scene that moves by itself. Default false: draw on change. */
132
+ continuous?: boolean;
133
+ /** The shape of the box. Default 16/9. */
134
+ aspect?: number | `${number}/${number}`;
135
+ /** A handle for `invalidate()` (a texture finished loading) and the canvas. */
136
+ handle?: React.Ref<SceneViewportHandle>;
137
+ className?: string;
138
+ };
139
+ /** What `handle` gives: ask for a redraw, and the canvas. */
140
+ type SceneViewportHandle = {
141
+ invalidate: () => void;
142
+ canvas: HTMLCanvasElement | null;
143
+ };
144
+ /** 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. */
145
+ export declare function SceneViewport({ label, camera, onCameraChange, home, render, mode, fov, near, far, limits, flySpeed, time, continuous, aspect, handle, className }: SceneViewportProps): React.JSX.Element;
146
+ export type { CameraLimits, LookView, OrbitCamera, OrbitCameraState, SceneFrame, SceneViewportHandle, SceneViewportProps };
147
+ //# sourceMappingURL=scene.d.ts.map
package/dist/scene.js CHANGED
@@ -1,16 +1,19 @@
1
- import { o as useInView, t as Button } from "./button-KGJI6jQr.js";
2
- import { r as cn } from "./tooltip-DhqrDtyu.js";
1
+ import { o as useInView, t as Button } from "./button-CYXjU-fs.js";
2
+ import { n as useViewPointers, r as useWheelZoom, t as useSettledStatus } from "./viewer-input-3Qa-o35k.js";
3
+ import { r as cn } from "./tooltip-BosfsWYh.js";
4
+ import { t as followAim } from "./follow-CXQsL86O.js";
3
5
  import * as React from "react";
4
6
  import { RotateCcw } from "lucide-react";
5
7
  import { jsx, jsxs } from "react/jsx-runtime";
6
8
  import { VisuallyHidden } from "react-aria";
9
+
7
10
  // src/scene/camera.ts
8
- var DEFAULT_LIMITS = {
11
+ const DEFAULT_LIMITS = {
9
12
  minDistance: 0,
10
13
  maxDistance: Infinity,
11
14
  maxPitch: 89
12
15
  };
13
- var rad = (d) => d * Math.PI / 180;
16
+ const rad = (d) => d * Math.PI / 180;
14
17
  /** Keeps a camera inside its limits and its yaw in -180 to 180. */
15
18
  function clampCamera(c, limits = {}) {
16
19
  const { minDistance, maxDistance, maxPitch } = {
@@ -26,12 +29,12 @@ function clampCamera(c, limits = {}) {
26
29
  pitch: Math.min(Math.max(c.pitch, -maxPitch), maxPitch)
27
30
  };
28
31
  }
29
- var cross = (a, b) => [
32
+ const cross = (a, b) => [
30
33
  a[1] * b[2] - a[2] * b[1],
31
34
  a[2] * b[0] - a[0] * b[2],
32
35
  a[0] * b[1] - a[1] * b[0]
33
36
  ];
34
- var dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
37
+ const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
35
38
  /** The unit vectors a camera looks along, and to its right and up. */
36
39
  function basis(c) {
37
40
  const y = rad(c.yaw);
@@ -159,7 +162,7 @@ function dolly(c, factor) {
159
162
  distance: c.distance * factor
160
163
  };
161
164
  }
162
- var turnWords = (deg, positive, negative) => Math.abs(deg) < 1 ? "" : `${Math.round(Math.abs(deg))}° ${deg > 0 ? positive : negative}`;
165
+ const turnWords = (deg, positive, negative) => Math.abs(deg) < 1 ? "" : `${Math.round(Math.abs(deg))}° ${deg > 0 ? positive : negative}`;
163
166
  /** 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". */
164
167
  function describeCamera(c) {
165
168
  const n = (v) => String(Math.round(v * 10) / 10);
@@ -169,6 +172,44 @@ function describeCamera(c) {
169
172
  const parts = [turned && `turned ${turned}`, tilted && `looking ${tilted}`].filter(Boolean).join(", ");
170
173
  return c.distance === 0 ? `At ${at}${parts ? `, ${parts}` : ", looking straight ahead"}` : `Looking at ${at} from ${n(c.distance)} away${parts ? `, ${parts}` : ""}`;
171
174
  }
175
+ /** The fly camera that sees what a `PanoramaViewer` view sees from `eye`: one view model for looking from a point, in a picture or a scene (issue #386). */
176
+ function cameraFromView(view, eye = [
177
+ 0,
178
+ 0,
179
+ 0
180
+ ]) {
181
+ return {
182
+ target: eye,
183
+ distance: 0,
184
+ yaw: view.yaw,
185
+ pitch: view.pitch
186
+ };
187
+ }
188
+ /** The panorama view a camera looks along from its eye (an orbit camera looks along its `forward` just the same), with the field of view given. */
189
+ function viewFromCamera(camera, fov) {
190
+ return {
191
+ yaw: camera.yaw,
192
+ pitch: camera.pitch,
193
+ fov
194
+ };
195
+ }
196
+ /**
197
+ * A camera that follows a moving point (issue #386, "through the player's eyes" in a replay): the eye is at `eye` and looks along the
198
+ * heading the app supplies, plus the person's own `look` on top. With `behind` it is a chase camera instead, that far back along the look.
199
+ */
200
+ function followCamera({ eye, heading, pitch = 0, look, behind = 0, maxPitch = 89 }) {
201
+ return {
202
+ target: eye,
203
+ distance: Math.max(0, behind),
204
+ ...followAim({
205
+ heading,
206
+ pitch,
207
+ look,
208
+ maxPitch
209
+ })
210
+ };
211
+ }
212
+
172
213
  // src/scene/scene-viewport.tsx
173
214
  /** 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`. */
174
215
  function useOrbitCamera(initial = {}, limits = {}) {
@@ -191,9 +232,9 @@ function useOrbitCamera(initial = {}, limits = {}) {
191
232
  home
192
233
  };
193
234
  }
194
- var STILL_MS = 600;
195
- var RESET_MS = 300;
196
- var reducedMotion = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
235
+ const STILL_MS = 600;
236
+ const RESET_MS = 300;
237
+ const reducedMotion = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
197
238
  /** 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. */
198
239
  function SceneViewport({ label, camera, onCameraChange, home, render, mode = "orbit", fov = 60, near = .1, far = 1e4, limits, flySpeed = 5, time = 0, continuous = false, aspect = "16/9", handle, className }) {
199
240
  const first = React.useRef(camera);
@@ -363,60 +404,25 @@ function SceneViewport({ label, camera, onCameraChange, home, render, mode = "or
363
404
  animation.current = requestAnimationFrame(step);
364
405
  };
365
406
  React.useEffect(() => () => cancelAnimationFrame(animation.current), []);
366
- const pointers = React.useRef(/* @__PURE__ */ new Map());
367
- const pinch = React.useRef(null);
368
- const onPointerDown = (e) => {
369
- if (e.target instanceof HTMLButtonElement) return;
370
- pointers.current.set(e.pointerId, {
371
- x: e.clientX,
372
- y: e.clientY
373
- });
374
- e.currentTarget.setPointerCapture?.(e.pointerId);
375
- e.currentTarget.focus({ preventScroll: true });
376
- cancelAnimationFrame(animation.current);
377
- if (pointers.current.size === 2) {
378
- const [a, b] = [...pointers.current.values()];
379
- pinch.current = Math.hypot(a.x - b.x, a.y - b.y);
407
+ const pointers = useViewPointers({
408
+ threshold: 0,
409
+ ignore: (e) => e.target instanceof HTMLButtonElement,
410
+ onDown: () => cancelAnimationFrame(animation.current),
411
+ onPinch: (ratio) => {
412
+ const l = live.current;
413
+ if (l.mode === "orbit") change(dolly(l.camera, ratio));
414
+ },
415
+ onDrag: (dx, dy, e) => {
416
+ const l = live.current;
417
+ const panning = e.shiftKey || (e.buttons & 6) !== 0;
418
+ change(panning ? pan(l.camera, dx, dy, size.height, l.fov) : turn(l.camera, dx, dy, l.mode));
380
419
  }
381
- };
382
- const onPointerMove = (e) => {
383
- const last = pointers.current.get(e.pointerId);
384
- if (!last) return;
385
- const now = {
386
- x: e.clientX,
387
- y: e.clientY
388
- };
389
- pointers.current.set(e.pointerId, now);
420
+ });
421
+ useWheelZoom(box, (factor, e) => {
390
422
  const l = live.current;
391
- if (pointers.current.size === 2) {
392
- const [a, b] = [...pointers.current.values()];
393
- const d = Math.hypot(a.x - b.x, a.y - b.y);
394
- if (pinch.current && d > 0 && l.mode === "orbit") change(dolly(l.camera, pinch.current / d));
395
- pinch.current = d;
396
- return;
397
- }
398
- const dx = now.x - last.x;
399
- const dy = now.y - last.y;
400
- const panning = e.shiftKey || (e.buttons & 6) !== 0;
401
- change(panning ? pan(l.camera, dx, dy, size.height, l.fov) : turn(l.camera, dx, dy, l.mode));
402
- };
403
- const onPointerUp = (e) => {
404
- pointers.current.delete(e.pointerId);
405
- pinch.current = null;
406
- };
407
- React.useEffect(() => {
408
- const el = box.current;
409
- if (!el) return;
410
- const onWheel = (e) => {
411
- if (!e.ctrlKey && !e.metaKey) return;
412
- e.preventDefault();
413
- const l = live.current;
414
- if (l.mode === "orbit") change(dolly(l.camera, Math.exp(e.deltaY * .0015)));
415
- else change(walk(l.camera, -e.deltaY * .01 * l.flySpeed, 0, 0));
416
- };
417
- el.addEventListener("wheel", onWheel, { passive: false });
418
- return () => el.removeEventListener("wheel", onWheel);
419
- }, [change]);
423
+ if (l.mode === "orbit") change(dolly(l.camera, factor));
424
+ else change(walk(l.camera, -e.deltaY * .01 * l.flySpeed, 0, 0));
425
+ }, { when: (e) => e.ctrlKey || e.metaKey });
420
426
  const held = React.useRef(/* @__PURE__ */ new Set());
421
427
  const flyLoop = React.useRef(0);
422
428
  const flyKeys = [
@@ -474,16 +480,7 @@ function SceneViewport({ label, camera, onCameraChange, home, render, mode = "or
474
480
  held.current.delete(e.key.length === 1 ? e.key.toLowerCase() : e.key);
475
481
  };
476
482
  const words = describeCamera(camera);
477
- const [said, setSaid] = React.useState("");
478
- const firstWords = React.useRef(true);
479
- React.useEffect(() => {
480
- if (firstWords.current) {
481
- firstWords.current = false;
482
- return;
483
- }
484
- const t = setTimeout(() => setSaid(words), STILL_MS);
485
- return () => clearTimeout(t);
486
- }, [words]);
483
+ const said = useSettledStatus(words, STILL_MS);
487
484
  return /* @__PURE__ */ jsxs("div", {
488
485
  className: cn("grid min-w-0 gap-2", className),
489
486
  children: [
@@ -495,10 +492,10 @@ function SceneViewport({ label, camera, onCameraChange, home, render, mode = "or
495
492
  onKeyDown,
496
493
  onKeyUp,
497
494
  onBlur: () => held.current.clear(),
498
- onPointerDown,
499
- onPointerMove,
500
- onPointerUp,
501
- onPointerCancel: onPointerUp,
495
+ onPointerDown: pointers.onPointerDown,
496
+ onPointerMove: pointers.onPointerMove,
497
+ onPointerUp: pointers.onPointerUp,
498
+ onPointerCancel: pointers.onPointerCancel,
502
499
  onContextMenu: (e) => e.preventDefault(),
503
500
  className: "relative w-full cursor-grab touch-none overflow-hidden rounded-surface bg-surface-sunken select-none active:cursor-grabbing",
504
501
  style: { aspectRatio: aspect },
@@ -526,6 +523,6 @@ function SceneViewport({ label, camera, onCameraChange, home, render, mode = "or
526
523
  ]
527
524
  });
528
525
  }
529
- export { DEFAULT_LIMITS, SceneViewport, basis, clampCamera, describeCamera, dolly, frameFor, lookAlong, multiply, pan, perspective, turn, useOrbitCamera, walk };
530
526
 
527
+ export { DEFAULT_LIMITS, SceneViewport, basis, cameraFromView, clampCamera, describeCamera, dolly, followCamera, frameFor, lookAlong, multiply, pan, perspective, turn, useOrbitCamera, viewFromCamera, walk };
531
528
  //# sourceMappingURL=scene.js.map
package/dist/scene.js.map CHANGED
@@ -1 +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 /** The scene's time in seconds when the viewport was given a `time` (a `useTimeline` clock's; issue #386), else 0: draw the scene as it is at this moment. */\n time: 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, time = 0 }: { fov?: number; near?: number; far?: number; context?: number; time?: 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, time };\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 /** The scene's time in seconds, from a `useTimeline` clock (issue #386): the scene is drawn again when it changes, with `frame.time` set, so a recorded run or a replay scrubs and plays like a video under `TimelinePlayer`. Default: no time. */\n time?: 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, time = 0, 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, time });\n live.current = { camera, onCameraChange, render, mode, fov, near, far, limits, flySpeed, home: target, time };\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, time: l.time }));\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, time]);\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":";;;;;;;AAgDA,IAAa,iBAA+B;CAAE,aAAa;CAAG,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AAE,IAAI,WAAW,IAAI,EAAE,IAAI,YAAY,IAAI,EAAE,GAAG;CACtE;CAGA,MAAM,QAAQ,eAAe,MAAM;CACnC,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,EAAE;CACzC,MAAM,aAAa,MAAM,OAAO,IAAI;CACpC,MAAM,gBAAgB;EACpB,IAAI,WAAW,SAAS;GACtB,WAAW,UAAU;GACrB;EACF;EACA,MAAM,IAAI,iBAAiB,QAAQ,KAAK,GAAG,QAAQ;EACnD,aAAa,aAAa,CAAC;CAC7B,GAAG,CAAC,KAAK,CAAC;CAEV,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,sBAAsB,SAAS;EAAlD,UAAA;GACE,qBAAC,OAAD;IACE,KAAK;IACL,MAAK;IACL,cAAY;IACZ,UAAU;IACC;IACF;IACT,cAAc,KAAK,QAAQ,MAAM;IAClB;IACA;IACF;IACb,iBAAiB;IACjB,gBAAgB,MAAM,EAAE,eAAe;IACvC,WAAU;IACV,OAAO,EAAE,aAAa,OAAO;IAd/B,UAAA,CAgBE,oBAAC,UAAD;KAAQ,KAAK;KAAQ,MAAK;KAAM,cAAY,GAAG,MAAM,IAAI;KAAS,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"}
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\nimport { followAim } from \"../lib/follow\";\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 /** The scene's time in seconds when the viewport was given a `time` (a `useTimeline` clock's; issue #386), else 0: draw the scene as it is at this moment. */\n time: 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 => [\n a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0],\n];\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];\n m[4] = right[1];\n m[8] = right[2];\n m[12] = -dot(right, eye);\n m[1] = up[0];\n m[5] = up[1];\n m[9] = up[2];\n m[13] = -dot(up, eye);\n m[2] = -forward[0];\n m[6] = -forward[1];\n m[10] = -forward[2];\n 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(\n camera: OrbitCamera,\n width: number,\n height: number,\n {\n fov = 60,\n near = 0.1,\n far = 10_000,\n context = 0,\n time = 0,\n }: { fov?: number; near?: number; far?: number; context?: number; time?: number } = {},\n): SceneFrame {\n const { forward, right, up } = basis(camera);\n const eye: Vec3 = [\n camera.target[0] - forward[0] * camera.distance,\n camera.target[1] - forward[1] * camera.distance,\n camera.target[2] - forward[2] * camera.distance,\n ];\n const view = lookAlong(eye, forward, right, up);\n const projection = perspective(fov, width / Math.max(1, height), near, far);\n return {\n camera,\n eye,\n forward,\n right,\n up,\n view,\n projection,\n viewProjection: multiply(projection, view),\n width,\n height,\n context,\n time,\n };\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(\n c: OrbitCamera,\n dx: number,\n dy: number,\n mode: \"orbit\" | \"fly\",\n degreesPerPixel = 0.35,\n): 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) =>\n 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\n ? `At ${at}${parts ? `, ${parts}` : \", looking straight ahead\"}`\n : `Looking at ${at} from ${n(c.distance)} away${parts ? `, ${parts}` : \"\"}`;\n}\n\n/** A view from inside a sphere as `PanoramaViewer` holds it: the same degrees, positive yaw to the right and positive pitch up. */\nexport type LookView = { yaw: number; pitch: number; fov: number };\n\n/** The fly camera that sees what a `PanoramaViewer` view sees from `eye`: one view model for looking from a point, in a picture or a scene (issue #386). */\nexport function cameraFromView(\n view: Pick<LookView, \"yaw\" | \"pitch\">,\n eye: readonly [number, number, number] = [0, 0, 0],\n): OrbitCamera {\n return { target: eye, distance: 0, yaw: view.yaw, pitch: view.pitch };\n}\n\n/** The panorama view a camera looks along from its eye (an orbit camera looks along its `forward` just the same), with the field of view given. */\nexport function viewFromCamera(camera: Pick<OrbitCamera, \"yaw\" | \"pitch\">, fov: number): LookView {\n return { yaw: camera.yaw, pitch: camera.pitch, fov };\n}\n\n/**\n * A camera that follows a moving point (issue #386, \"through the player's eyes\" in a replay): the eye is at `eye` and looks along the\n * heading the app supplies, plus the person's own `look` on top. With `behind` it is a chase camera instead, that far back along the look.\n */\nexport function followCamera({\n eye,\n heading,\n pitch = 0,\n look,\n behind = 0,\n maxPitch = 89,\n}: {\n eye: readonly [number, number, number];\n heading: number;\n pitch?: number;\n look?: { yaw?: number; pitch?: number };\n behind?: number;\n maxPitch?: number;\n}): OrbitCamera {\n return { target: eye, distance: Math.max(0, behind), ...followAim({ heading, pitch, look, maxPitch }) };\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 { useSettledStatus, useViewPointers, useWheelZoom } from \"../lib/viewer-input\";\nimport { cn } from \"../lib/utils\";\nimport {\n clampCamera,\n describeCamera,\n dolly,\n frameFor,\n pan,\n turn,\n walk,\n type CameraLimits,\n type OrbitCamera,\n type SceneFrame,\n} 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(\n initial: Partial<OrbitCamera> = {},\n limits: Partial<CameraLimits> = {},\n): OrbitCameraState {\n const home = React.useMemo<OrbitCamera>(\n () =>\n clampCamera(\n {\n target: initial.target ?? [0, 0, 0],\n distance: initial.distance ?? 5,\n yaw: initial.yaw ?? 0,\n pitch: initial.pitch ?? 20,\n },\n limits,\n ),\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 /** The scene's time in seconds, from a `useTimeline` clock (issue #386): the scene is drawn again when it changes, with `frame.time` set, so a recorded run or a replay scrubs and plays like a video under `TimelinePlayer`. Default: no time. */\n time?: 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({\n label,\n camera,\n onCameraChange,\n home,\n render,\n mode = \"orbit\",\n fov = 60,\n near = 0.1,\n far = 10_000,\n limits,\n flySpeed = 5,\n time = 0,\n continuous = false,\n aspect = \"16/9\",\n handle,\n className,\n}: SceneViewportProps) {\n const first = React.useRef(camera);\n const target = home ?? first.current;\n const live = React.useRef({\n camera,\n onCameraChange,\n render,\n mode,\n fov,\n near,\n far,\n limits,\n flySpeed,\n home: target,\n time,\n });\n live.current = { camera, onCameraChange, render, mode, fov, near, far, limits, flySpeed, home: target, time };\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(\n ctx,\n frameFor(l.camera, w, h, { fov: l.fov, near: l.near, far: l.far, context: context.current, time: l.time }),\n );\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, time]);\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: [\n mix(from.target[0], to.target[0]),\n mix(from.target[1], to.target[1]),\n mix(from.target[2], to.target[2]),\n ],\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 (`useViewPointers`).\n const pointers = useViewPointers({\n threshold: 0,\n ignore: (e) => e.target instanceof HTMLButtonElement,\n onDown: () => cancelAnimationFrame(animation.current),\n onPinch: (ratio) => {\n const l = live.current;\n if (l.mode === \"orbit\") change(dolly(l.camera, ratio));\n },\n onDrag: (dx, dy, e) => {\n const l = live.current;\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 });\n\n // The wheel zooms only with Ctrl or Cmd (a trackpad pinch sends Ctrl); a plain wheel scrolls the page.\n useWheelZoom(\n box,\n (factor, e) => {\n const l = live.current;\n if (l.mode === \"orbit\") change(dolly(l.camera, factor));\n else change(walk(l.camera, -e.deltaY * 0.01 * l.flySpeed, 0, 0));\n },\n { when: (e) => e.ctrlKey || e.metaKey },\n );\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[]) =>\n (plus.some((x) => k.has(x)) ? 1 : 0) - (minus.some((x) => k.has(x)) ? 1 : 0);\n change(\n walk(\n l.camera,\n axis([\"w\", \"ArrowUp\"], [\"s\", \"ArrowDown\"]) * stride,\n axis([\"d\", \"ArrowRight\"], [\"a\", \"ArrowLeft\"]) * stride,\n axis([\"e\"], [\"q\"]) * stride,\n ),\n );\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 === \"=\")\n change(l.mode === \"orbit\" ? dolly(l.camera, 0.8) : walk(l.camera, l.flySpeed * 0.5, 0, 0));\n else if (key === \"-\" || key === \"_\")\n 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 = useSettledStatus(words, STILL_MS);\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={pointers.onPointerDown}\n onPointerMove={pointers.onPointerMove}\n onPointerUp={pointers.onPointerUp}\n onPointerCancel={pointers.onPointerCancel}\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":";;;;;;;;;;AAkDA,MAAa,iBAA+B;CAAE,aAAa;CAAG,aAAa;CAAU,UAAU;AAAG;AAElG,MAAM,OAAO,MAAe,IAAI,KAA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