@mark1russell7/visuals 0.0.0-stage → 0.1.0

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.
package/build/three.js ADDED
@@ -0,0 +1,397 @@
1
+ import { a as NO_MARKS, g as cameraPosition, h as surfaceOf, m as stageLimits, o as isClick, r as moveAt, s as markOf, u as keyAction, v as clampPlace, w as viewOf, x as speedAt } from "./motion-Ba4IIfAV.js";
2
+ import { DirectionalLight, HemisphereLight, PerspectiveCamera, Raycaster, Scene, Vector2, WebGLRenderer } from "three";
3
+ import { OrbitControls } from "three/addons/controls/OrbitControls.js";
4
+ // src/stage/stage.ts
5
+ /** The default vertical angle of the picture, in degrees. */
6
+ const FIELD_OF_VIEW = 32;
7
+ /** The default lights: a strong light from above and below, and a light from the front left. */
8
+ const STAGE_LIGHTS = {
9
+ sky: 2.2,
10
+ sun: 1.5,
11
+ from: {
12
+ x: -10,
13
+ y: 24,
14
+ z: 15
15
+ }
16
+ };
17
+ /** The time of the move between two views, in milliseconds. */
18
+ const MOVE_TIME = 380;
19
+ /** The turn of the camera for a drag across the height of the picture, as a part of a full turn, far from the surface. */
20
+ const TURN_SPEED = .9;
21
+ /** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */
22
+ const SMALLEST_POLAR = 5e-4;
23
+ /** The default largest polar angle: the camera stays above the plane of the target. */
24
+ const LARGEST_POLAR = Math.PI / 2 - .05;
25
+ /** This function tells if the person asks for less motion. */
26
+ function lessMotion() {
27
+ return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
28
+ }
29
+ /**
30
+ * This function makes a stage in a container of a page. The stage fills the container, so give the container a size.
31
+ *
32
+ * A person turns the content with a drag, and moves nearer with the wheel after a click in the picture.
33
+ * A click selects the record under the pointer. With the keyboard, the arrow keys turn the content, `+` and `-` change the distance,
34
+ * and `Home` shows the first view. The stage makes a picture only after a change.
35
+ *
36
+ * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.
37
+ * The page then shows a different picture of the same data.
38
+ */
39
+ function createStage(container, options) {
40
+ const canvas = container.ownerDocument.createElement("canvas");
41
+ const context = canvas.getContext("webgl2", {
42
+ alpha: true,
43
+ antialias: true,
44
+ depth: true,
45
+ stencil: false,
46
+ premultipliedAlpha: true,
47
+ powerPreference: "default"
48
+ });
49
+ if (context === null) return void 0;
50
+ let renderer;
51
+ try {
52
+ renderer = new WebGLRenderer({
53
+ canvas,
54
+ context,
55
+ alpha: true,
56
+ antialias: true
57
+ });
58
+ } catch {
59
+ return;
60
+ }
61
+ renderer.setClearColor(0, 0);
62
+ canvas.style.display = "block";
63
+ canvas.style.width = "100%";
64
+ canvas.style.height = "100%";
65
+ canvas.style.cursor = "grab";
66
+ canvas.style.touchAction = "none";
67
+ canvas.tabIndex = 0;
68
+ canvas.setAttribute("role", "application");
69
+ canvas.setAttribute("aria-label", options.label);
70
+ container.append(canvas);
71
+ const fieldOfView = options.fieldOfView ?? 32;
72
+ const polar = {
73
+ min: options.polar?.min ?? SMALLEST_POLAR,
74
+ max: options.polar?.max ?? LARGEST_POLAR
75
+ };
76
+ const lights = options.lights ?? STAGE_LIGHTS;
77
+ const world = new Scene();
78
+ const sky = new HemisphereLight("#ffffff", "#ffffff", lights.sky);
79
+ const sun = new DirectionalLight("#ffffff", lights.sun);
80
+ sun.position.set(lights.from.x, lights.from.y, lights.from.z);
81
+ world.add(sky, sun);
82
+ const camera = new PerspectiveCamera(fieldOfView, 1, .05, 1e3);
83
+ let content = options.content;
84
+ let theme = options.theme;
85
+ for (const object of content.objects) world.add(object);
86
+ let marks = NO_MARKS;
87
+ let view = options.home;
88
+ let move;
89
+ /** This value is true after a person moved the view. Then a new size of the container does not move the camera. */
90
+ let moved = false;
91
+ /** This value is true until the content had a step with no time. */
92
+ let settle = true;
93
+ /** The height of the picture, in CSS pixels. */
94
+ let height = 1;
95
+ let frame = 0;
96
+ let lastTime = 0;
97
+ let disposed = false;
98
+ const invalidate = () => {
99
+ if (frame === 0 && !disposed) frame = requestAnimationFrame(tick);
100
+ };
101
+ const controls = new OrbitControls(camera, canvas);
102
+ controls.enableDamping = !lessMotion();
103
+ controls.dampingFactor = .14;
104
+ controls.minPolarAngle = polar.min;
105
+ controls.maxPolarAngle = polar.max;
106
+ controls.rotateSpeed = TURN_SPEED;
107
+ controls.screenSpacePanning = true;
108
+ controls.enablePan = options.pan ?? true;
109
+ controls.enableZoom = false;
110
+ const viewFrame = () => ({
111
+ extent: content.extent,
112
+ fieldOfView,
113
+ aspect: camera.aspect
114
+ });
115
+ let limits = stageLimits(viewFrame(), Object.values(options.views), polar);
116
+ const paint = () => {
117
+ const now = marks;
118
+ content.paint(theme, (record) => markOf(now, record));
119
+ invalidate();
120
+ };
121
+ /** This function sets the turn speed and the zoom speed from the height of the camera above the surface. */
122
+ const setSpeed = () => {
123
+ const speed = speedAt(camera.position.distanceTo(controls.target), surfaceOf(content.extent));
124
+ controls.rotateSpeed = TURN_SPEED * speed;
125
+ controls.zoomSpeed = speed;
126
+ };
127
+ const placeNow = () => {
128
+ const target = {
129
+ x: controls.target.x,
130
+ y: controls.target.y,
131
+ z: controls.target.z
132
+ };
133
+ return {
134
+ target,
135
+ ...viewOf(camera.position, target)
136
+ };
137
+ };
138
+ const put = (to) => {
139
+ const next = clampPlace(to, limits);
140
+ const eye = cameraPosition(next.target, next, next.distance);
141
+ controls.target.set(next.target.x, next.target.y, next.target.z);
142
+ camera.position.set(eye.x, eye.y, eye.z);
143
+ camera.lookAt(controls.target);
144
+ setSpeed();
145
+ };
146
+ /** This function gives the view function of a view, or `undefined` for a name that the options do not have. */
147
+ const viewFunction = (of) => typeof of === "string" ? options.views[of] : of;
148
+ /** This function sets the limits of the camera from the content and the shape of the picture. */
149
+ const setLimits = () => {
150
+ limits = stageLimits(viewFrame(), Object.values(options.views), polar);
151
+ controls.minDistance = limits.minDistance;
152
+ controls.maxDistance = limits.maxDistance;
153
+ camera.near = limits.near;
154
+ camera.far = limits.far;
155
+ camera.updateProjectionMatrix();
156
+ };
157
+ /**
158
+ * This function stops the turn that continues after a drag. The camera stays where it is.
159
+ * Without it, the camera continues to turn after a move to a view, and the view is not exact.
160
+ */
161
+ const stopDrift = () => {
162
+ if (!controls.enableDamping) return;
163
+ const now = placeNow();
164
+ controls.enableDamping = false;
165
+ controls.update();
166
+ controls.enableDamping = true;
167
+ put(now);
168
+ };
169
+ const goTo = (next, animate) => {
170
+ const found = viewFunction(next);
171
+ if (found === void 0) return;
172
+ view = next;
173
+ moved = false;
174
+ stopDrift();
175
+ const to = found(viewFrame());
176
+ if (animate && !lessMotion()) move = {
177
+ from: placeNow(),
178
+ to,
179
+ start: performance.now(),
180
+ duration: MOVE_TIME
181
+ };
182
+ else {
183
+ move = void 0;
184
+ put(to);
185
+ }
186
+ invalidate();
187
+ };
188
+ /** This function sets the size of the picture from the size of the container. It gives false for a container with no size. */
189
+ const setSize = () => {
190
+ const width = container.clientWidth;
191
+ const tall = container.clientHeight;
192
+ if (width === 0 || tall === 0) return false;
193
+ height = tall;
194
+ renderer.setPixelRatio(Math.min(globalThis.devicePixelRatio, 2));
195
+ renderer.setSize(width, tall, false);
196
+ camera.aspect = width / tall;
197
+ camera.updateProjectionMatrix();
198
+ return true;
199
+ };
200
+ /** This function moves the camera one step of a move between two views. It gives true while the move continues. */
201
+ const stepMove = (now) => {
202
+ if (move === void 0) return false;
203
+ const step = moveAt(move, now, surfaceOf(content.extent));
204
+ put(step.place);
205
+ if (step.done) move = void 0;
206
+ return true;
207
+ };
208
+ function tick(now) {
209
+ frame = 0;
210
+ if (disposed) return;
211
+ const seconds = lastTime === 0 ? 1 / 60 : Math.min((now - lastTime) / 1e3, .1);
212
+ let active = stepMove(now);
213
+ setSpeed();
214
+ active = controls.update() || active;
215
+ const stepped = content.step?.({
216
+ camera,
217
+ seconds,
218
+ settle: settle || lessMotion(),
219
+ height,
220
+ fieldOfView
221
+ }) ?? false;
222
+ settle = false;
223
+ renderer.render(world, camera);
224
+ active = stepped || active;
225
+ lastTime = active ? now : 0;
226
+ if (active) invalidate();
227
+ }
228
+ const raycaster = new Raycaster();
229
+ const pointer = new Vector2();
230
+ /** This function gives the record under a pointer. */
231
+ const pickAt = (event) => {
232
+ const box = canvas.getBoundingClientRect();
233
+ if (box.width === 0 || box.height === 0) return void 0;
234
+ pointer.set((event.clientX - box.left) / box.width * 2 - 1, 1 - (event.clientY - box.top) / box.height * 2);
235
+ raycaster.setFromCamera(pointer, camera);
236
+ return content.pick(raycaster);
237
+ };
238
+ const setHover = (pick) => {
239
+ const record = pick?.record;
240
+ if (record === marks.hovered) return;
241
+ marks = {
242
+ ...marks,
243
+ hovered: record
244
+ };
245
+ canvas.style.cursor = record === void 0 ? "grab" : "pointer";
246
+ paint();
247
+ options.onHover?.(pick?.value);
248
+ };
249
+ const listeners = new AbortController();
250
+ const signal = listeners.signal;
251
+ let down;
252
+ const setInUse = (inUse) => {
253
+ controls.enableZoom = inUse;
254
+ };
255
+ canvas.addEventListener("pointerdown", (event) => {
256
+ setInUse(true);
257
+ canvas.focus({ preventScroll: true });
258
+ down = {
259
+ id: event.pointerId,
260
+ x: event.clientX,
261
+ y: event.clientY
262
+ };
263
+ }, { signal });
264
+ canvas.addEventListener("pointermove", (event) => {
265
+ if (event.buttons === 0 && event.pointerType !== "touch") setHover(pickAt(event));
266
+ }, { signal });
267
+ canvas.addEventListener("pointerup", (event) => {
268
+ const start = down;
269
+ down = void 0;
270
+ if (start === void 0 || start.id !== event.pointerId) return;
271
+ if (!isClick(start, {
272
+ x: event.clientX,
273
+ y: event.clientY
274
+ })) return;
275
+ const pick = pickAt(event);
276
+ marks = {
277
+ ...marks,
278
+ selected: pick?.record
279
+ };
280
+ paint();
281
+ options.onSelect?.(pick?.value);
282
+ }, { signal });
283
+ canvas.addEventListener("pointercancel", () => {
284
+ down = void 0;
285
+ }, { signal });
286
+ canvas.addEventListener("pointerleave", (event) => {
287
+ setHover(void 0);
288
+ if (event.pointerType === "mouse") setInUse(false);
289
+ }, { signal });
290
+ canvas.addEventListener("blur", () => setInUse(false), { signal });
291
+ canvas.addEventListener("keydown", (event) => {
292
+ if (event.altKey || event.ctrlKey || event.metaKey) return;
293
+ const action = keyAction(event.key, placeNow(), {
294
+ home: options.home,
295
+ views: options.keys,
296
+ surface: surfaceOf(content.extent)
297
+ });
298
+ if (action === void 0) return;
299
+ event.preventDefault();
300
+ setInUse(true);
301
+ if (action.type === "view") {
302
+ goTo(action.view, true);
303
+ return;
304
+ }
305
+ moved = true;
306
+ move = void 0;
307
+ stopDrift();
308
+ put(action.place);
309
+ invalidate();
310
+ }, { signal });
311
+ canvas.addEventListener("webglcontextlost", (event) => event.preventDefault(), { signal });
312
+ canvas.addEventListener("webglcontextrestored", invalidate, { signal });
313
+ controls.addEventListener("start", () => {
314
+ moved = true;
315
+ move = void 0;
316
+ canvas.style.cursor = "grabbing";
317
+ invalidate();
318
+ });
319
+ controls.addEventListener("end", () => {
320
+ canvas.style.cursor = marks.hovered === void 0 ? "grab" : "pointer";
321
+ });
322
+ controls.addEventListener("change", invalidate);
323
+ const applyTheme = () => {
324
+ sky.color.set(theme.sky);
325
+ sky.groundColor.set(theme.ground);
326
+ paint();
327
+ };
328
+ const observer = new ResizeObserver(() => {
329
+ if (disposed || !setSize()) return;
330
+ setLimits();
331
+ if (!moved) goTo(view, false);
332
+ invalidate();
333
+ });
334
+ setSize();
335
+ setLimits();
336
+ goTo(options.home, false);
337
+ applyTheme();
338
+ observer.observe(container);
339
+ return {
340
+ canvas,
341
+ setContent(next) {
342
+ if (disposed || next === content) return;
343
+ for (const object of content.objects) world.remove(object);
344
+ content.dispose();
345
+ content = next;
346
+ for (const object of content.objects) world.add(object);
347
+ const selected = marks.selected !== void 0 && content.has(marks.selected) ? marks.selected : void 0;
348
+ marks = {
349
+ ...marks,
350
+ hovered: void 0,
351
+ selected
352
+ };
353
+ settle = true;
354
+ setLimits();
355
+ if (!moved) goTo(view, false);
356
+ paint();
357
+ },
358
+ setTheme(next) {
359
+ theme = next;
360
+ applyTheme();
361
+ },
362
+ setView(next, animate = true) {
363
+ goTo(next, animate);
364
+ },
365
+ place: placeNow,
366
+ highlight(records) {
367
+ marks = {
368
+ ...marks,
369
+ marked: new Set(records)
370
+ };
371
+ paint();
372
+ },
373
+ select(record) {
374
+ marks = {
375
+ ...marks,
376
+ selected: record
377
+ };
378
+ paint();
379
+ },
380
+ refresh: paint,
381
+ dispose() {
382
+ if (disposed) return;
383
+ disposed = true;
384
+ cancelAnimationFrame(frame);
385
+ observer.disconnect();
386
+ listeners.abort();
387
+ controls.dispose();
388
+ for (const object of content.objects) world.remove(object);
389
+ content.dispose();
390
+ renderer.dispose();
391
+ canvas.remove();
392
+ }
393
+ };
394
+ }
395
+ export { FIELD_OF_VIEW, STAGE_LIGHTS, createStage };
396
+
397
+ //# sourceMappingURL=three.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"three.js","names":["World"],"sources":["../src/stage/stage.ts"],"sourcesContent":["import { DirectionalLight, HemisphereLight, PerspectiveCamera, Raycaster, Scene as World, Vector2, WebGLRenderer, type Object3D } from \"three\";\nimport { OrbitControls } from \"three/addons/controls/OrbitControls.js\";\nimport { stageLimits, surfaceOf, type StageExtent, type StageLimits, type StageView, type ViewFrame } from \"../extent.ts\";\nimport { keyAction } from \"../keys.ts\";\nimport { isClick, markOf, NO_MARKS, type Mark, type Marks } from \"../marks.ts\";\nimport { moveAt, type Move } from \"../motion.ts\";\nimport type { StageTheme } from \"../theme.ts\";\nimport { cameraPosition, clampPlace, speedAt, viewOf, type Place } from \"../view.ts\";\n\n/** The record under the pointer: its name, and the value that the content gives for it. */\nexport interface StagePick<P> {\n /** The name of the record. The marks of the stage use this name. */\n readonly record: string;\n /** The value of the record for the page, for example its kind and its source. */\n readonly value: P;\n}\n\n/** One picture of a stage, for the step of its content. */\nexport interface StageFrame {\n readonly camera: PerspectiveCamera;\n /** The time since the last picture, in seconds. */\n readonly seconds: number;\n /**\n * This value is true for the first picture of a content, and for a person who asks for less motion.\n * Each change then has no time: the content sets each value to its goal immediately.\n */\n readonly settle: boolean;\n /** The height of the picture, in CSS pixels. */\n readonly height: number;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n}\n\n/**\n * The content of a stage: the three.js objects of one scene, and what the stage asks of them.\n * `P` is the type of the value of a pick, and `T` is the type of the theme.\n */\nexport interface StageContent<P, T extends StageTheme = StageTheme> {\n /** The three.js objects of the content. The stage adds them to its world, and removes them. */\n readonly objects: readonly Object3D[];\n /** The space that the content fills. */\n readonly extent: StageExtent;\n /** This function tells if the content has a record with a name. */\n has(record: string): boolean;\n /** This function gives the record that a ray from the camera finds first, or `undefined` for no record. */\n pick(ray: Raycaster): StagePick<P> | undefined;\n /** This function gives each part its colors, from the theme and the mark of its record. */\n paint(theme: T, mark: (record: string) => Mark): void;\n /**\n * This function changes the parts that depend on the camera or on the time, before each picture.\n * It gives true while a part continues to change. The stage then makes the next picture.\n */\n step?(frame: StageFrame): boolean;\n /** This function releases the memory of the graphics card that the content uses. */\n dispose(): void;\n}\n\n/** The lights of a stage. A content with materials that use no light ignores them. */\nexport interface StageLights {\n /** The strength of the light from above and below. */\n readonly sky: number;\n /** The strength of the light from one direction. */\n readonly sun: number;\n /** The position that the light from one direction comes from. */\n readonly from: { readonly x: number; readonly y: number; readonly z: number };\n}\n\n/** The options of a stage. */\nexport interface StageOptions<P, T extends StageTheme = StageTheme> {\n /** The first content. The stage disposes each content that it gets. */\n readonly content: StageContent<P, T>;\n readonly theme: T;\n /** The name of the picture for a screen reader. */\n readonly label: string;\n /** The views of the stage, each with a name. */\n readonly views: Readonly<Record<string, StageView>>;\n /** The name of the first view. The keys `Home` and `0` show it. */\n readonly home: string;\n /** The name of the view of a key, for example `{ t: \"top\" }`. A letter has no case. */\n readonly keys?: Readonly<Record<string, string>> | undefined;\n /** The vertical angle of the picture, in degrees. A small angle gives the look of a drawing. The default is 32. */\n readonly fieldOfView?: number | undefined;\n /** The smallest and the largest polar angle of the camera, in radians. The default keeps the camera above the plane of the target. */\n readonly polar?: { readonly min?: number | undefined; readonly max?: number | undefined } | undefined;\n /** This value is true if a person can move the target with a drag of the second button. The default is true. */\n readonly pan?: boolean | undefined;\n readonly lights?: StageLights | undefined;\n /** The stage starts this function when the pointer goes to a different record, or to no record. */\n readonly onHover?: ((pick: P | undefined) => void) | undefined;\n /** The stage starts this function when a person selects a record with the pointer, or selects no record. */\n readonly onSelect?: ((pick: P | undefined) => void) | undefined;\n}\n\n/** A stage in a page: one canvas with a camera that a person moves, and one content. */\nexport interface Stage<P, T extends StageTheme = StageTheme> {\n /** The canvas of the stage. It is in the container. */\n readonly canvas: HTMLCanvasElement;\n /** This function shows a different content, and disposes the old content. The view stays if a person moved it. */\n setContent(content: StageContent<P, T>): void;\n /** This function changes the colors. */\n setTheme(theme: T): void;\n /** This function moves the camera to a view: a name of the options, or a view function. `animate` has the default true. */\n setView(view: string | StageView, animate?: boolean): void;\n /** This function gives the place of the camera. */\n place(): Place;\n /** This function marks records by their names, as the pointer does. An empty list removes the marks. */\n highlight(records: readonly string[]): void;\n /** This function selects one record by its name, or no record. It does not start `onSelect`. */\n select(record: string | undefined): void;\n /** This function paints the content again and makes a new picture. Use it after a change of the content. */\n refresh(): void;\n /** This function removes the canvas and releases the memory of the graphics card. It disposes the content. */\n dispose(): void;\n}\n\n/** The default vertical angle of the picture, in degrees. */\nexport const FIELD_OF_VIEW = 32;\n\n/** The default lights: a strong light from above and below, and a light from the front left. */\nexport const STAGE_LIGHTS: StageLights = { sky: 2.2, sun: 1.5, from: { x: -10, y: 24, z: 15 } };\n\n/** The time of the move between two views, in milliseconds. */\nconst MOVE_TIME = 380;\n\n/** The turn of the camera for a drag across the height of the picture, as a part of a full turn, far from the surface. */\nconst TURN_SPEED = 0.9;\n\n/** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */\nconst SMALLEST_POLAR = 0.0005;\n\n/** The default largest polar angle: the camera stays above the plane of the target. */\nconst LARGEST_POLAR = Math.PI / 2 - 0.05;\n\n/** This function tells if the person asks for less motion. */\nfunction lessMotion(): boolean {\n return typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n}\n\n/**\n * This function makes a stage in a container of a page. The stage fills the container, so give the container a size.\n *\n * A person turns the content with a drag, and moves nearer with the wheel after a click in the picture.\n * A click selects the record under the pointer. With the keyboard, the arrow keys turn the content, `+` and `-` change the distance,\n * and `Home` shows the first view. The stage makes a picture only after a change.\n *\n * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.\n * The page then shows a different picture of the same data.\n */\nexport function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined {\n const canvas = container.ownerDocument.createElement(\"canvas\");\n const context = canvas.getContext(\"webgl2\", { alpha: true, antialias: true, depth: true, stencil: false, premultipliedAlpha: true, powerPreference: \"default\" });\n if (context === null) return undefined;\n let renderer: WebGLRenderer;\n try {\n renderer = new WebGLRenderer({ canvas, context, alpha: true, antialias: true });\n } catch {\n return undefined;\n }\n renderer.setClearColor(0x000000, 0);\n\n canvas.style.display = \"block\";\n canvas.style.width = \"100%\";\n canvas.style.height = \"100%\";\n canvas.style.cursor = \"grab\";\n canvas.style.touchAction = \"none\";\n canvas.tabIndex = 0;\n canvas.setAttribute(\"role\", \"application\");\n canvas.setAttribute(\"aria-label\", options.label);\n container.append(canvas);\n\n const fieldOfView = options.fieldOfView ?? FIELD_OF_VIEW;\n const polar = { min: options.polar?.min ?? SMALLEST_POLAR, max: options.polar?.max ?? LARGEST_POLAR };\n const lights = options.lights ?? STAGE_LIGHTS;\n const world = new World();\n const sky = new HemisphereLight(\"#ffffff\", \"#ffffff\", lights.sky);\n const sun = new DirectionalLight(\"#ffffff\", lights.sun);\n sun.position.set(lights.from.x, lights.from.y, lights.from.z);\n world.add(sky, sun);\n const camera = new PerspectiveCamera(fieldOfView, 1, 0.05, 1000);\n\n let content = options.content;\n let theme = options.theme;\n for (const object of content.objects) world.add(object);\n\n let marks: Marks = NO_MARKS;\n let view: string | StageView = options.home;\n let move: Move | undefined;\n /** This value is true after a person moved the view. Then a new size of the container does not move the camera. */\n let moved = false;\n /** This value is true until the content had a step with no time. */\n let settle = true;\n /** The height of the picture, in CSS pixels. */\n let height = 1;\n let frame = 0;\n let lastTime = 0;\n let disposed = false;\n\n const invalidate = (): void => {\n if (frame === 0 && !disposed) frame = requestAnimationFrame(tick);\n };\n\n const controls = new OrbitControls(camera, canvas);\n controls.enableDamping = !lessMotion();\n controls.dampingFactor = 0.14;\n controls.minPolarAngle = polar.min;\n controls.maxPolarAngle = polar.max;\n controls.rotateSpeed = TURN_SPEED;\n controls.screenSpacePanning = true;\n controls.enablePan = options.pan ?? true;\n // The wheel moves the page until a person uses the picture. Thus the picture does not stop a person who reads down the page.\n controls.enableZoom = false;\n\n const viewFrame = (): ViewFrame => ({ extent: content.extent, fieldOfView, aspect: camera.aspect });\n let limits: StageLimits = stageLimits(viewFrame(), Object.values(options.views), polar);\n\n const paint = (): void => {\n const now = marks;\n content.paint(theme, (record) => markOf(now, record));\n invalidate();\n };\n\n /** This function sets the turn speed and the zoom speed from the height of the camera above the surface. */\n const setSpeed = (): void => {\n const speed = speedAt(camera.position.distanceTo(controls.target), surfaceOf(content.extent));\n controls.rotateSpeed = TURN_SPEED * speed;\n controls.zoomSpeed = speed;\n };\n const placeNow = (): Place => {\n const target = { x: controls.target.x, y: controls.target.y, z: controls.target.z };\n return { target, ...viewOf(camera.position, target) };\n };\n const put = (to: Place): void => {\n const next = clampPlace(to, limits);\n const eye = cameraPosition(next.target, next, next.distance);\n controls.target.set(next.target.x, next.target.y, next.target.z);\n camera.position.set(eye.x, eye.y, eye.z);\n camera.lookAt(controls.target);\n setSpeed();\n };\n /** This function gives the view function of a view, or `undefined` for a name that the options do not have. */\n const viewFunction = (of: string | StageView): StageView | undefined => (typeof of === \"string\" ? options.views[of] : of);\n\n /** This function sets the limits of the camera from the content and the shape of the picture. */\n const setLimits = (): void => {\n limits = stageLimits(viewFrame(), Object.values(options.views), polar);\n controls.minDistance = limits.minDistance;\n controls.maxDistance = limits.maxDistance;\n camera.near = limits.near;\n camera.far = limits.far;\n camera.updateProjectionMatrix();\n };\n /**\n * This function stops the turn that continues after a drag. The camera stays where it is.\n * Without it, the camera continues to turn after a move to a view, and the view is not exact.\n */\n const stopDrift = (): void => {\n if (!controls.enableDamping) return;\n const now = placeNow();\n // With no damping, an update of the controls uses all of the turn that remains. The camera then goes back.\n controls.enableDamping = false;\n controls.update();\n controls.enableDamping = true;\n put(now);\n };\n const goTo = (next: string | StageView, animate: boolean): void => {\n const found = viewFunction(next);\n if (found === undefined) return;\n view = next;\n moved = false;\n stopDrift();\n const to = found(viewFrame());\n if (animate && !lessMotion()) {\n move = { from: placeNow(), to, start: performance.now(), duration: MOVE_TIME };\n } else {\n move = undefined;\n put(to);\n }\n invalidate();\n };\n\n /** This function sets the size of the picture from the size of the container. It gives false for a container with no size. */\n const setSize = (): boolean => {\n const width = container.clientWidth;\n const tall = container.clientHeight;\n if (width === 0 || tall === 0) return false;\n height = tall;\n renderer.setPixelRatio(Math.min(globalThis.devicePixelRatio, 2));\n renderer.setSize(width, tall, false);\n camera.aspect = width / tall;\n camera.updateProjectionMatrix();\n return true;\n };\n\n /** This function moves the camera one step of a move between two views. It gives true while the move continues. */\n const stepMove = (now: number): boolean => {\n if (move === undefined) return false;\n const step = moveAt(move, now, surfaceOf(content.extent));\n put(step.place);\n if (step.done) move = undefined;\n return true;\n };\n\n function tick(now: number): void {\n frame = 0;\n if (disposed) return;\n const seconds = lastTime === 0 ? 1 / 60 : Math.min((now - lastTime) / 1000, 0.1);\n let active = stepMove(now);\n setSpeed();\n active = controls.update() || active;\n const stepped = content.step?.({ camera, seconds, settle: settle || lessMotion(), height, fieldOfView }) ?? false;\n settle = false;\n renderer.render(world, camera);\n active = stepped || active;\n lastTime = active ? now : 0;\n if (active) invalidate();\n }\n\n const raycaster = new Raycaster();\n const pointer = new Vector2();\n /** This function gives the record under a pointer. */\n const pickAt = (event: PointerEvent): StagePick<P> | undefined => {\n const box = canvas.getBoundingClientRect();\n if (box.width === 0 || box.height === 0) return undefined;\n pointer.set(((event.clientX - box.left) / box.width) * 2 - 1, 1 - ((event.clientY - box.top) / box.height) * 2);\n raycaster.setFromCamera(pointer, camera);\n return content.pick(raycaster);\n };\n\n const setHover = (pick: StagePick<P> | undefined): void => {\n const record = pick?.record;\n if (record === marks.hovered) return;\n marks = { ...marks, hovered: record };\n canvas.style.cursor = record === undefined ? \"grab\" : \"pointer\";\n paint();\n options.onHover?.(pick?.value);\n };\n\n const listeners = new AbortController();\n const signal = listeners.signal;\n let down: { readonly id: number; readonly x: number; readonly y: number } | undefined;\n const setInUse = (inUse: boolean): void => {\n controls.enableZoom = inUse;\n };\n canvas.addEventListener(\n \"pointerdown\",\n (event) => {\n setInUse(true);\n canvas.focus({ preventScroll: true });\n down = { id: event.pointerId, x: event.clientX, y: event.clientY };\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointermove\",\n (event) => {\n if (event.buttons === 0 && event.pointerType !== \"touch\") setHover(pickAt(event));\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerup\",\n (event) => {\n const start = down;\n down = undefined;\n if (start === undefined || start.id !== event.pointerId) return;\n if (!isClick(start, { x: event.clientX, y: event.clientY })) return;\n const pick = pickAt(event);\n marks = { ...marks, selected: pick?.record };\n paint();\n options.onSelect?.(pick?.value);\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointercancel\",\n () => {\n down = undefined;\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerleave\",\n (event) => {\n setHover(undefined);\n if (event.pointerType === \"mouse\") setInUse(false);\n },\n { signal },\n );\n canvas.addEventListener(\"blur\", () => setInUse(false), { signal });\n canvas.addEventListener(\n \"keydown\",\n (event) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const action = keyAction(event.key, placeNow(), { home: options.home, views: options.keys, surface: surfaceOf(content.extent) });\n if (action === undefined) return;\n event.preventDefault();\n setInUse(true);\n if (action.type === \"view\") {\n goTo(action.view, true);\n return;\n }\n moved = true;\n move = undefined;\n stopDrift();\n put(action.place);\n invalidate();\n },\n { signal },\n );\n canvas.addEventListener(\"webglcontextlost\", (event) => event.preventDefault(), { signal });\n canvas.addEventListener(\"webglcontextrestored\", invalidate, { signal });\n\n controls.addEventListener(\"start\", () => {\n moved = true;\n move = undefined;\n canvas.style.cursor = \"grabbing\";\n invalidate();\n });\n controls.addEventListener(\"end\", () => {\n canvas.style.cursor = marks.hovered === undefined ? \"grab\" : \"pointer\";\n });\n controls.addEventListener(\"change\", invalidate);\n\n const applyTheme = (): void => {\n sky.color.set(theme.sky);\n sky.groundColor.set(theme.ground);\n paint();\n };\n\n const observer = new ResizeObserver(() => {\n if (disposed || !setSize()) return;\n setLimits();\n if (!moved) goTo(view, false);\n invalidate();\n });\n\n setSize();\n setLimits();\n goTo(options.home, false);\n applyTheme();\n observer.observe(container);\n\n return {\n canvas,\n setContent(next: StageContent<P, T>): void {\n if (disposed || next === content) return;\n for (const object of content.objects) world.remove(object);\n content.dispose();\n content = next;\n for (const object of content.objects) world.add(object);\n const selected = marks.selected !== undefined && content.has(marks.selected) ? marks.selected : undefined;\n marks = { ...marks, hovered: undefined, selected };\n settle = true;\n setLimits();\n if (!moved) goTo(view, false);\n paint();\n },\n setTheme(next: T): void {\n theme = next;\n applyTheme();\n },\n setView(next: string | StageView, animate: boolean = true): void {\n goTo(next, animate);\n },\n place: placeNow,\n highlight(records: readonly string[]): void {\n marks = { ...marks, marked: new Set(records) };\n paint();\n },\n select(record: string | undefined): void {\n marks = { ...marks, selected: record };\n paint();\n },\n refresh: paint,\n dispose(): void {\n if (disposed) return;\n disposed = true;\n cancelAnimationFrame(frame);\n observer.disconnect();\n listeners.abort();\n controls.dispose();\n for (const object of content.objects) world.remove(object);\n content.dispose();\n renderer.dispose();\n canvas.remove();\n },\n };\n}\n"],"mappings":";;;;;AAoHA,MAAa,gBAAgB;;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AAO;EACL;EACA,WAAW,MAAgC;GACzC,IAAI,YAAY,SAAS,SAAS;GAClC,KAAK,MAAM,UAAU,QAAQ,SAAS,MAAM,OAAO,MAAM;GACzD,QAAQ,QAAQ;GAChB,UAAU;GACV,KAAK,MAAM,UAAU,QAAQ,SAAS,MAAM,IAAI,MAAM;GACtD,MAAM,WAAW,MAAM,aAAa,KAAA,KAAa,QAAQ,IAAI,MAAM,QAAQ,IAAI,MAAM,WAAW,KAAA;GAChG,QAAQ;IAAE,GAAG;IAAO,SAAS,KAAA;IAAW;GAAS;GACjD,SAAS;GACT,UAAU;GACV,IAAI,CAAC,OAAO,KAAK,MAAM,KAAK;GAC5B,MAAM;EACR;EACA,SAAS,MAAe;GACtB,QAAQ;GACR,WAAW;EACb;EACA,QAAQ,MAA0B,UAAmB,MAAY;GAC/D,KAAK,MAAM,OAAO;EACpB;EACA,OAAO;EACP,UAAU,SAAkC;GAC1C,QAAQ;IAAE,GAAG;IAAO,QAAQ,IAAI,IAAI,OAAO;GAAE;GAC7C,MAAM;EACR;EACA,OAAO,QAAkC;GACvC,QAAQ;IAAE,GAAG;IAAO,UAAU;GAAO;GACrC,MAAM;EACR;EACA,SAAS;EACT,UAAgB;GACd,IAAI,UAAU;GACd,WAAW;GACX,qBAAqB,KAAK;GAC1B,SAAS,WAAW;GACpB,UAAU,MAAM;GAChB,SAAS,QAAQ;GACjB,KAAK,MAAM,UAAU,QAAQ,SAAS,MAAM,OAAO,MAAM;GACzD,QAAQ,QAAQ;GAChB,SAAS,QAAQ;GACjB,OAAO,OAAO;EAChB;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,80 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package",
2
3
  "name": "@mark1russell7/visuals",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
4
+ "version": "0.1.0",
5
+ "description": "3D stages for data on three.js: a camera that a person moves, views by name, picking, marks and themes.",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mark1russell7/visuals.git",
10
+ "directory": "packages/visuals"
11
+ },
12
+ "homepage": "https://mark1russell7.github.io/visuals/",
13
+ "bugs": {
14
+ "url": "https://github.com/mark1russell7/visuals/issues"
15
+ },
16
+ "keywords": [
17
+ "3d",
18
+ "three",
19
+ "viewer",
20
+ "camera",
21
+ "orbit",
22
+ "picking",
23
+ "globe",
24
+ "webgl"
25
+ ],
26
+ "type": "module",
27
+ "sideEffects": false,
28
+ "main": "./build/index.js",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./build/index.d.ts",
32
+ "import": "./build/index.js",
33
+ "default": "./build/index.js"
34
+ },
35
+ "./three": {
36
+ "types": "./build/three.d.ts",
37
+ "import": "./build/three.js",
38
+ "default": "./build/three.js"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
42
+ "files": [
43
+ "build"
44
+ ],
45
+ "dependencies": {
46
+ "@mark1russell7/layout-contract": "^0.10.2"
47
+ },
48
+ "peerDependencies": {
49
+ "three": ">=0.187.0"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "three": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "devDependencies": {
57
+ "@mark1russell7/cue": "^2.0.0",
58
+ "@types/node": "^26.6.5",
59
+ "@types/three": "^0.187.0",
60
+ "@vitest/coverage-v8": "^5.0.3",
61
+ "fast-check": "^4.10.2",
62
+ "three": "^0.187.0",
63
+ "tsdown": "^0.23.1",
64
+ "typescript": "^7.0.2",
65
+ "vitest": "^5.0.3"
66
+ },
67
+ "engines": {
68
+ "node": ">=22"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public"
72
+ },
73
+ "scripts": {
74
+ "build": "tsdown",
75
+ "test": "vitest run",
76
+ "test:watch": "vitest",
77
+ "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.test.json"
78
+ },
79
+ "types": "./build/index.d.ts"
6
80
  }