@mark1russell7/visuals 0.1.0 → 0.2.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/README.md CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  3D stages for data. A stage is one canvas of three.js with a camera that a person moves. The content of the stage is your data.
4
4
 
5
- The package has two entries:
5
+ The package has four entries:
6
6
 
7
- - The entry `.` has the camera maths: views, places, moves, keys and marks. It needs no browser, and it does not need `three`.
7
+ - The entry `.` has the camera maths: views, places, moves, keys and highlights. It needs no browser, and it does not need `three`.
8
+ - The entry `/marks` has the marks that a viewer draws, as plain data. It needs no browser, and it does not need `three`.
8
9
  - The entry `/three` has the stage. It needs the package `three`, version 0.187.0 or later.
10
+ - The entry `/globe` has a content that shows the Earth as a globe, with areas and points on it. It also needs `three`.
9
11
 
10
12
  ## Install
11
13
 
@@ -13,6 +15,8 @@ The package has two entries:
13
15
  npm install @mark1russell7/visuals three
14
16
  ```
15
17
 
18
+ A package that uses only the entries `.` and `/marks` does not install `three`.
19
+
16
20
  ## A stage
17
21
 
18
22
  ```ts
@@ -31,7 +35,7 @@ const content: StageContent<string> = {
31
35
  },
32
36
  has: (record) => record === "box",
33
37
  pick: (ray) => (ray.intersectObject(box).length > 0 ? { record: "box", value: "the box" } : undefined),
34
- paint: (_theme, mark) => void material.color.set(mark("box") === 0 ? "#4f7cac" : "#e0a03a"),
38
+ paint: (_theme, highlight) => void material.color.set(highlight("box") === 0 ? "#4f7cac" : "#e0a03a"),
35
39
  dispose: () => {
36
40
  box.geometry.dispose();
37
41
  material.dispose();
@@ -70,11 +74,11 @@ A stage knows nothing about the data. The content gives it these parts:
70
74
  | `objects` | The three.js objects of the content. |
71
75
  | `extent` | The space that the content fills: the point that the camera looks at, and the corners that a view shows. |
72
76
  | `pick` | The record that a ray from the camera finds first. |
73
- | `paint` | The colors of each part, from the theme and the mark of its record. |
77
+ | `paint` | The colors of each part, from the theme and the highlight of its record. |
74
78
  | `step` | The parts that change with the camera or with the time, before each picture. It is optional. |
75
79
  | `dispose` | The release of the memory of the graphics card. |
76
80
 
77
- A record has a name. The mark of a record is 0, 1 or 2: no mark, a record under the pointer, the selected record. `highlight` and `select` set the marks from the page.
81
+ A record has a name. The highlight of a record is 0, 1 or 2: no highlight, a record under the pointer, the selected record. `highlight` and `select` set the highlights from the page.
78
82
 
79
83
  ## Views
80
84
 
@@ -110,6 +114,148 @@ all({ extent: globe, fieldOfView: 32, aspect: 1.5 }).distance; // => 3.79: the o
110
114
  region({ extent: globe, fieldOfView: 32, aspect: 1.5 }).distance; // => 1.18: a cap of 0.05 radians fills the height
111
115
  ```
112
116
 
117
+ ## A globe
118
+
119
+ The entry `/globe` has a content for a stage that shows the Earth. The picture goes from the whole Earth to one region.
120
+
121
+ ```ts
122
+ import { GLOBE_POLAR, createGlobe, globeView, regionView, type GlobeArea, type GlobeTheme } from "@mark1russell7/visuals/globe";
123
+ import { createStage } from "@mark1russell7/visuals/three";
124
+
125
+ const storm: GlobeArea<string> = {
126
+ record: "storm",
127
+ kind: "warning",
128
+ value: "A storm warning",
129
+ region: {
130
+ type: "Polygon",
131
+ coordinates: [
132
+ [
133
+ [-98, 30],
134
+ [-90, 30],
135
+ [-90, 36],
136
+ [-98, 36],
137
+ [-98, 30],
138
+ ],
139
+ ],
140
+ },
141
+ };
142
+
143
+ const theme: GlobeTheme = {
144
+ sky: "#ffffff",
145
+ ground: "#8a8f98",
146
+ ball: "#0d2236",
147
+ grid: "#24415c",
148
+ shade: "#02060a",
149
+ styles: {
150
+ warning: { fill: "#f0883e", opacity: 0.35, line: "#f0883e" },
151
+ city: { fill: "#ffffff", line: "#0d2236" },
152
+ },
153
+ other: { fill: "#6b7785", opacity: 0.5 },
154
+ hovered: "#ffd866",
155
+ selected: "#ffffff",
156
+ };
157
+
158
+ const globe = createGlobe({
159
+ areas: [storm],
160
+ points: [{ record: "city", kind: "city", value: "A city", place: { lat: 32.8, lon: -96.8 } }],
161
+ });
162
+
163
+ const stage = createStage(document.body, {
164
+ content: globe,
165
+ theme,
166
+ label: "The Earth with one storm warning",
167
+ views: { earth: globeView({ lat: 35, lon: -95 }), storm: regionView([storm.region]) },
168
+ home: "earth",
169
+ polar: GLOBE_POLAR,
170
+ pan: false,
171
+ onSelect: (value) => console.log(value), // => "A storm warning" after a click on the area
172
+ });
173
+ ```
174
+
175
+ - An area is a region of `@mark1russell7/geo`: a `Polygon` or a `MultiPolygon` of GeoJSON. A point is a place with a latitude and a longitude.
176
+ - The surface of an area follows the curve of the Earth. The option `step` sets the largest step of an edge, in degrees.
177
+ - A kind names the style of an area or a point in the theme. A new theme changes each color, and the geometry stays.
178
+ - The pointer finds a point first, then the last area of the list. The pointer ignores a part with `pick: false`.
179
+ - `show` hides each part that a test refuses, for example the records that are not active at a time.
180
+ - `placeAt` gives the place on the Earth under the pointer.
181
+ - The globe uses no map tiles and no service. Give the land to it as an area.
182
+
183
+ The views of a globe:
184
+
185
+ - `globeView(place, degrees)` shows the cap of the Earth around a place. The default shows a half of the Earth.
186
+ - `regionView(regions)` shows each region of a list, from above their middle.
187
+
188
+ The functions of the globe maths have no state. A test in Node.js uses them:
189
+
190
+ | Function | What it gives |
191
+ | --- | --- |
192
+ | `globePoint`, `globePlace` | The point of the globe for a place on the Earth, and the place for a point. |
193
+ | `regionSurface` | The triangles of the surface of a region. No edge is longer than 1.25 steps. |
194
+ | `regionEdges` | The lines of the outline of a region. A cut on the antimeridian or at a pole gives no line. |
195
+ | `gridLines` | The meridians and the parallels of a grid. |
196
+ | `rayBall`, `inSight` | The first point of a ball on a ray, and if a camera sees a point of the ball. |
197
+
198
+ ```ts
199
+ import { globePoint, regionSurface } from "@mark1russell7/visuals/globe";
200
+
201
+ globePoint({ lat: 0, lon: 0 }); // => { x: 0, y: 0, z: 1 }: the axis z goes to latitude 0 and longitude 0, and the axis y to the north pole
202
+
203
+ const surface = regionSurface(storm.region, 2);
204
+ surface.corners.length / 2; // => 43: the corners of the outline with a step of 2 degrees, and the corners in the surface
205
+ surface.triangles.length / 3; // => 70
206
+ ```
207
+
208
+ ## The marks
209
+
210
+ A mark is a record that a viewer draws. A mark is plain data with no topic, so each viewer draws the marks of each producer.
211
+
212
+ ```ts
213
+ import { checkMarks, levelShape, shapeRing, type Mark } from "@mark1russell7/visuals/marks";
214
+
215
+ const marks: readonly Mark[] = [
216
+ {
217
+ type: "point",
218
+ record: "outlet-1",
219
+ kind: "outlet",
220
+ level: "near",
221
+ label: "Outlet 1",
222
+ frame: { at: { x: 1, y: 0, z: 0.3 }, out: { x: 0, y: 1, z: 0 } },
223
+ },
224
+ { type: "meter", record: "circuit-1", kind: "circuit", level: "over", label: "Circuit 1", value: 1900, limit: 1440, unit: "W" },
225
+ ];
226
+
227
+ checkMarks(marks); // => []: the list has no fault
228
+ levelShape("near"); // => "triangle"
229
+ shapeRing("triangle").length; // => 3: the corners of the sign, counter-clockwise
230
+ ```
231
+
232
+ | Mark | Data | Example |
233
+ | --- | --- | --- |
234
+ | `point` | A frame and a size | An outlet, a tap, a lamp |
235
+ | `run` | A list of frames and a width | A cable, a pipe, a duct |
236
+ | `link` | Two ends, each with a record name and a point | A power line from an outlet to a computer |
237
+ | `field` | A grid of values on a plane, and a scale | Light in lux, sound in decibels, heat |
238
+ | `meter` | A value, a limit and the text of the unit | The load of a circuit against its limit |
239
+
240
+ - Each mark has a record name, a kind, a level and a label. The kind is a word of the producer for the legend and the filter.
241
+ - A frame is a point of a surface and the unit vector out of the surface.
242
+ - The level of a mark is `unknown`, `ok`, `near` or `over`. The producer calculates it, because each topic has its own limits.
243
+ - A mark has no shape and no color. `levelShape` gives each level its shape, and the theme of a viewer gives its color.
244
+ - Thus a person who does not see a color reads the level from the shape: a ring, a disc, a triangle or a square.
245
+ - A viewer draws the marks in the sequence of `levelRank`, so the worst level is always in view.
246
+ - A field has its values row by row, with `null` for a cell with no value. `fieldValue` and `fieldCellCenter` read a cell.
247
+ - A meter has no place. A page draws it in a panel, and a 3D view ignores it.
248
+ - Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.
249
+
250
+ `checkMarks` gives the faults of a list, each with a code, the index of its mark and the part with the fault. It examines the values that the types do not hold:
251
+
252
+ - A number that is not finite, and a direction that is not a unit vector.
253
+ - A size, a width or a cell that is not more than 0.
254
+ - The grid, the values and the scale of a field, and a run with fewer than 2 points.
255
+ - An empty name, an empty label, and a level or a type that is not known.
256
+
257
+ Use it as a gate in the tests of a producer. A viewer uses it on a list that it did not make. It does not examine the form of a mark, so read a list from JSON through a schema first.
258
+
113
259
  ## The camera maths
114
260
 
115
261
  The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js use the same functions as the stage.
@@ -120,9 +266,11 @@ The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js u
120
266
  | `fitDistance`, `capDistance` | The distance at which the camera shows points, or a cap of a ball. |
121
267
  | `cameraPosition`, `viewOf` | The position of a camera from its place, and the place from its position. |
122
268
  | `placeBetween`, `moveAt`, `easeInOut` | A place on the way between two places, and the place at a time of a move. |
269
+ | `ballView` | A view that shows points on a ball, from above their middle. |
123
270
  | `clampPlace`, `stageLimits` | A place in the limits of a stage, and the limits from the content. |
271
+ | `reachOf`, `nearDepth` | The radius of the ball that holds the content, and the nearest depth that the camera draws. |
124
272
  | `keyAction` | The action of a key. |
125
- | `markOf`, `isClick` | The mark of a record, and the difference between a click and a drag. |
273
+ | `highlightOf`, `isClick` | The highlight of a record, and the difference between a click and a drag. |
126
274
  | `approach` | One step of a value to its goal, for a part that changes with time. |
127
275
 
128
276
  The space of a stage has the y axis up. A place has a target, a polar angle from the y axis, an azimuth around it and a distance.
@@ -180,6 +180,89 @@ function capView(angles, angle, margin = FIT_MARGIN) {
180
180
  };
181
181
  }
182
182
  /**
183
+ * This function makes a view of points on the ball of the content. The camera is above the middle of the points, and the picture shows each point.
184
+ *
185
+ * The middle is the center of the box of the points. `margin` is the space around the points, as a factor of the height above the ball.
186
+ * A list with no points gives a view of all of the ball from the front. Points with their middle at the center of the ball give the same view.
187
+ */
188
+ function ballView(points, margin = FIT_MARGIN) {
189
+ let found;
190
+ return (frame) => {
191
+ const { center } = frame.extent;
192
+ if (found === void 0 || found.center.x !== center.x || found.center.y !== center.y || found.center.z !== center.z) found = {
193
+ center,
194
+ view: capOf(points, center, margin)
195
+ };
196
+ return found.view(frame);
197
+ };
198
+ }
199
+ /** This function makes the view of the cap of a ball around `center` that holds each point. */
200
+ function capOf(points, center, margin) {
201
+ const low = {
202
+ x: 1e400,
203
+ y: 1e400,
204
+ z: 1e400
205
+ };
206
+ const high = {
207
+ x: -1e400,
208
+ y: -1e400,
209
+ z: -1e400
210
+ };
211
+ for (const point of points) {
212
+ low.x = Math.min(low.x, point.x);
213
+ low.y = Math.min(low.y, point.y);
214
+ low.z = Math.min(low.z, point.z);
215
+ high.x = Math.max(high.x, point.x);
216
+ high.y = Math.max(high.y, point.y);
217
+ high.z = Math.max(high.z, point.z);
218
+ }
219
+ const middle = {
220
+ x: (low.x + high.x) / 2 - center.x,
221
+ y: (low.y + high.y) / 2 - center.y,
222
+ z: (low.z + high.z) / 2 - center.z
223
+ };
224
+ const length = Math.hypot(middle.x, middle.y, middle.z);
225
+ if (!(length > 0) || !Number.isFinite(length)) return capView({
226
+ polar: Math.PI / 2,
227
+ azimuth: 0
228
+ }, Math.PI / 2, margin);
229
+ let angle = 0;
230
+ for (const point of points) {
231
+ const x = point.x - center.x;
232
+ const y = point.y - center.y;
233
+ const z = point.z - center.z;
234
+ const distance = Math.hypot(x, y, z);
235
+ if (!(distance > 0)) continue;
236
+ const cosine = (x * middle.x + y * middle.y + z * middle.z) / (distance * length);
237
+ angle = Math.max(angle, Math.acos(Math.min(Math.max(cosine, -1), 1)));
238
+ }
239
+ const { polar, azimuth } = viewOf(middle, {
240
+ x: 0,
241
+ y: 0,
242
+ z: 0
243
+ });
244
+ return capView({
245
+ polar,
246
+ azimuth
247
+ }, angle, margin);
248
+ }
249
+ /** This function gives the radius of the ball around the center of an extent that holds the ball of the extent and each corner. */
250
+ function reachOf(extent) {
251
+ let reach = surfaceOf(extent);
252
+ for (const corner of extent.corners) reach = Math.max(reach, Math.hypot(corner.x - extent.center.x, corner.y - extent.center.y, corner.z - extent.center.z));
253
+ return reach;
254
+ }
255
+ /**
256
+ * This function gives the nearest depth that a camera draws, from the distance of the camera to the center of the content.
257
+ *
258
+ * A camera far from the content gets a large value. The depths of the content then have more steps, so two surfaces that are near stay apart.
259
+ * The result is not less than the nearest depth of the limits, and it is in front of all the content.
260
+ */
261
+ function nearDepth(limits, extent, distance) {
262
+ const free = (distance - reachOf(extent)) / 8;
263
+ return free > limits.near ? Math.min(free, limits.far / 4) : limits.near;
264
+ }
265
+ /**
183
266
  * This function gives the limits of the camera of a stage for a picture.
184
267
  *
185
268
  * The largest distance of the views is the base. The camera goes out to 3 times this distance, and in to 3 % of the height of that view.
@@ -191,8 +274,7 @@ function stageLimits(frame, views, polar) {
191
274
  let widest = 0;
192
275
  for (const view of views) widest = Math.max(widest, view(frame).distance);
193
276
  if (!(widest > surface)) widest = surface + 1;
194
- let reach = surface;
195
- for (const corner of extent.corners) reach = Math.max(reach, Math.hypot(corner.x - extent.center.x, corner.y - extent.center.y, corner.z - extent.center.z));
277
+ const reach = reachOf(extent);
196
278
  const minDistance = extent.minDistance ?? surface + (widest - surface) * .03;
197
279
  const maxDistance = Math.max(extent.maxDistance ?? surface + (widest - surface) * 3, minDistance);
198
280
  const height = Math.max(minDistance - surface, 1e-6);
@@ -205,134 +287,6 @@ function stageLimits(frame, views, polar) {
205
287
  far: (maxDistance + reach) * 1.5
206
288
  };
207
289
  }
208
- // src/keys.ts
209
- /** The angle of one step of an arrow key, in radians, for a camera far from the surface. */
210
- const KEY_TURN = Math.PI / 24;
211
- /** The factor of the height of a camera above the surface for one step of the key `+`. */
212
- const KEY_ZOOM = .85;
213
- /**
214
- * This function gives the action of a key on a stage, or `undefined` for a key with no action.
215
- *
216
- * The arrow keys turn the camera around the target. The keys `+` and `-` change the height above the surface.
217
- * The keys `Home` and `0` show the home view. Near the surface, a step of an arrow key is smaller.
218
- * The result has no limits: the stage puts the place in its limits.
219
- */
220
- function keyAction(key, now, options) {
221
- const surface = options.surface ?? 0;
222
- const turn = KEY_TURN * speedAt(now.distance, surface);
223
- const zoom = (factor) => ({
224
- ...now,
225
- distance: surface + (now.distance - surface) * factor
226
- });
227
- switch (key) {
228
- case "ArrowLeft": return {
229
- type: "place",
230
- place: {
231
- ...now,
232
- azimuth: now.azimuth - turn
233
- }
234
- };
235
- case "ArrowRight": return {
236
- type: "place",
237
- place: {
238
- ...now,
239
- azimuth: now.azimuth + turn
240
- }
241
- };
242
- case "ArrowUp": return {
243
- type: "place",
244
- place: {
245
- ...now,
246
- polar: now.polar - turn
247
- }
248
- };
249
- case "ArrowDown": return {
250
- type: "place",
251
- place: {
252
- ...now,
253
- polar: now.polar + turn
254
- }
255
- };
256
- case "+":
257
- case "=": return {
258
- type: "place",
259
- place: zoom(KEY_ZOOM)
260
- };
261
- case "-":
262
- case "_": return {
263
- type: "place",
264
- place: zoom(1 / KEY_ZOOM)
265
- };
266
- case "Home":
267
- case "0": return {
268
- type: "view",
269
- view: options.home
270
- };
271
- default: {
272
- const view = key.length === 1 ? options.views?.[key.toLowerCase()] : void 0;
273
- return view === void 0 ? void 0 : {
274
- type: "view",
275
- view
276
- };
277
- }
278
- }
279
- }
280
- // src/marks.ts
281
- /** The marks of a stage with no pointer on it and no selected record. */
282
- const NO_MARKS = {
283
- hovered: void 0,
284
- selected: void 0,
285
- marked: /* @__PURE__ */ new Set()
286
- };
287
- /** This function gives the mark of a record. The selected record has the highest mark. */
288
- function markOf(marks, record) {
289
- if (record === marks.selected) return 2;
290
- return record === marks.hovered || marks.marked.has(record) ? 1 : 0;
291
- }
292
- /** A pointer that moves this distance or less between down and up makes a click, in CSS pixels. */
293
- const CLICK_DISTANCE = 4;
294
- /**
295
- * This function tells if a pointer that went down and up made a click. A pointer that moved more than `limit` made a drag.
296
- * The positions and the limit are in CSS pixels.
297
- */
298
- function isClick(down, up, limit = 4) {
299
- return Math.hypot(up.x - down.x, up.y - down.y) <= limit;
300
- }
301
- // src/motion.ts
302
- /**
303
- * This function gives a part of a move with a slow start and a slow end. `part` goes from 0 to 1.
304
- * The result goes from 0 to 1, and it is 0.5 at the middle.
305
- */
306
- function easeInOut(part) {
307
- const clamped = Math.min(Math.max(part, 0), 1);
308
- return clamped < .5 ? 4 * clamped * clamped * clamped : 1 - (-2 * clamped + 2) ** 3 / 2;
309
- }
310
- /**
311
- * This function gives the place of a camera at the time `now` of a move, in milliseconds.
312
- * A move with no duration is at its end immediately. `surface` is the radius of the ball around the target, or 0 for no ball.
313
- */
314
- function moveAt(move, now, surface = 0) {
315
- const part = move.duration > 0 ? Math.min(Math.max((now - move.start) / move.duration, 0), 1) : 1;
316
- if (part >= 1) return {
317
- place: move.to,
318
- done: true
319
- };
320
- return {
321
- place: placeBetween(move.from, move.to, easeInOut(part), surface),
322
- done: false
323
- };
324
- }
325
- /**
326
- * This function moves a value one step to its goal. Each step goes a constant part of the way that remains.
327
- *
328
- * `seconds` is the time of the step, and `time` is the time in which the value goes most of the way, in seconds.
329
- * A step with no time gives the goal. A value nearer to the goal than `snap` becomes the goal, so the steps have an end.
330
- */
331
- function approach(value, goal, seconds, time, snap = .01) {
332
- if (!(seconds > 0) || !(time > 0)) return goal;
333
- const next = value + (goal - value) * (1 - Math.exp(0 - seconds / time));
334
- return Math.abs(goal - next) < snap ? goal : next;
335
- }
336
- export { viewAxes as C, turnBetween as S, capDistance as _, NO_MARKS as a, placeBetween as b, KEY_TURN as c, FIT_MARGIN as d, capView as f, cameraPosition as g, surfaceOf as h, CLICK_DISTANCE as i, KEY_ZOOM as l, stageLimits as m, easeInOut as n, isClick as o, fitView as p, moveAt as r, markOf as s, approach as t, keyAction as u, clampPlace as v, viewOf as w, speedAt as x, fitDistance as y };
290
+ export { viewOf as _, nearDepth as a, surfaceOf as c, clampPlace as d, fitDistance as f, viewAxes as g, turnBetween as h, fitView as i, cameraPosition as l, speedAt as m, ballView as n, reachOf as o, placeBetween as p, capView as r, stageLimits as s, FIT_MARGIN as t, capDistance as u };
337
291
 
338
- //# sourceMappingURL=motion-Ba4IIfAV.js.map
292
+ //# sourceMappingURL=extent-CALhBZU-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extent-CALhBZU-.js","names":[],"sources":["../src/view.ts","../src/extent.ts"],"sourcesContent":["import type { Point3 } from \"@mark1russell7/layout-contract\";\n\n/**\n * The direction of a view: where the camera is, as seen from the point that it looks at.\n * The space of a stage has the y axis up.\n */\nexport interface ViewAngles {\n /** The angle from the up axis to the camera, in radians. At 0, the camera looks down from above. */\n readonly polar: number;\n /** The angle around the up axis, in radians. At 0, the camera is on the positive z side of the point. */\n readonly azimuth: number;\n}\n\n/** A place of a camera: the point that it looks at, the angles of its view and its distance from the point. */\nexport interface Place extends ViewAngles {\n readonly target: Point3;\n readonly distance: number;\n}\n\n/** The three axes of a camera, as unit vectors in the space of the stage. */\nexport interface ViewAxes {\n /** The vector from the point that the camera looks at to the camera. */\n readonly back: Point3;\n /** The vector to the right side of the picture. */\n readonly right: Point3;\n /** The vector to the top of the picture. */\n readonly up: Point3;\n}\n\n/** The limits of the place of a camera. */\nexport interface PlaceLimits {\n /** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */\n readonly minPolar: number;\n /** The largest polar angle. */\n readonly maxPolar: number;\n /** The smallest distance from the target. */\n readonly minDistance: number;\n /** The largest distance from the target. */\n readonly maxDistance: number;\n}\n\n/** This function gives the axes of the camera of a view. At a polar angle of 0, the top of the picture is the negative z axis. */\nexport function viewAxes(view: ViewAngles): ViewAxes {\n const sinPolar = Math.sin(view.polar);\n const cosPolar = Math.cos(view.polar);\n const sinAzimuth = Math.sin(view.azimuth);\n const cosAzimuth = Math.cos(view.azimuth);\n return {\n back: { x: sinPolar * sinAzimuth, y: cosPolar, z: sinPolar * cosAzimuth },\n right: { x: cosAzimuth, y: 0, z: 0 - sinAzimuth },\n up: { x: 0 - cosPolar * sinAzimuth, y: sinPolar, z: 0 - cosPolar * cosAzimuth },\n };\n}\n\n/** This function gives the dot product of the vector from `origin` to `point` with `axis`. */\nfunction along(point: Point3, origin: Point3, axis: Point3): number {\n return (point.x - origin.x) * axis.x + (point.y - origin.y) * axis.y + (point.z - origin.z) * axis.z;\n}\n\n/**\n * This function gives the smallest distance from `target` at which a camera shows each point.\n *\n * The camera looks at `target` along the direction of `view`. `fov` is the vertical angle of the picture in degrees,\n * and `aspect` is the width of the picture divided by its height.\n * The function gives 0 for no points, and for an angle or an aspect that makes no picture.\n */\nexport function fitDistance(points: readonly Point3[], target: Point3, view: ViewAngles, fov: number, aspect: number): number {\n const tanUp = Math.tan((fov * Math.PI) / 360);\n const tanRight = tanUp * aspect;\n if (!(tanUp > 0) || !(tanRight > 0) || !Number.isFinite(tanRight)) return 0;\n const axes = viewAxes(view);\n let distance = 0;\n for (const point of points) {\n const depth = along(point, target, axes.back);\n const needed = Math.max(Math.abs(along(point, target, axes.right)) / tanRight, Math.abs(along(point, target, axes.up)) / tanUp);\n distance = Math.max(distance, depth + needed);\n }\n return distance;\n}\n\n/**\n * This function gives the smallest distance from the center of a ball at which a camera shows a cap of the ball.\n *\n * The camera looks at the center of the ball, and the center of the cap is on the line to the camera.\n * `radius` is the radius of the ball. `angle` is the angle of the cap at the center of the ball, in radians, from 0 to π / 2.\n * `fov` is the vertical angle of the picture in degrees, and `aspect` is the width of the picture divided by its height.\n * The function gives 0 for an angle or an aspect that makes no picture.\n */\nexport function capDistance(radius: number, angle: number, fov: number, aspect: number): number {\n const tanUp = Math.tan((fov * Math.PI) / 360);\n const tan = Math.min(tanUp, tanUp * aspect);\n if (!(tan > 0) || !Number.isFinite(tan) || !(radius > 0)) return 0;\n const cap = Math.min(Math.max(angle, 0), Math.PI / 2);\n const half = Math.atan(tan);\n // A cap this large has its edge behind the outline of the ball. Then the outline of the ball is the limit.\n if (cap >= Math.PI / 2 - half) return radius / Math.sin(half);\n // The edge of the cap is at the height r sin(a) from the line, and at the depth r cos(a) from the center.\n return radius * Math.cos(cap) + (radius * Math.sin(cap)) / tan;\n}\n\n/** This function gives the position of a camera at a distance from `target`, in the direction of `view`. */\nexport function cameraPosition(target: Point3, view: ViewAngles, distance: number): Point3 {\n const { back } = viewAxes(view);\n return { x: target.x + back.x * distance, y: target.y + back.y * distance, z: target.z + back.z * distance };\n}\n\n/** This function gives the angles of the view from `target` to a camera, and the distance between them. A camera at the target gives the angles 0. */\nexport function viewOf(camera: Point3, target: Point3): ViewAngles & { readonly distance: number } {\n const x = camera.x - target.x;\n const y = camera.y - target.y;\n const z = camera.z - target.z;\n const distance = Math.hypot(x, y, z);\n if (!(distance > 0)) return { polar: 0, azimuth: 0, distance: 0 };\n return { polar: Math.acos(Math.min(Math.max(y / distance, -1), 1)), azimuth: Math.atan2(x, z), distance };\n}\n\n/** This function gives the angle between two azimuths along the shortest way, from −π to π. */\nexport function turnBetween(from: number, to: number): number {\n const full = 2 * Math.PI;\n const turn = (((to - from) % full) + full) % full;\n return turn > Math.PI ? turn - full : turn;\n}\n\n/** This function gives a place in its limits. The target and the azimuth stay as they are. */\nexport function clampPlace(place: Place, limits: PlaceLimits): Place {\n return {\n target: place.target,\n azimuth: place.azimuth,\n polar: Math.min(Math.max(place.polar, limits.minPolar), limits.maxPolar),\n distance: Math.min(Math.max(place.distance, limits.minDistance), limits.maxDistance),\n };\n}\n\n/**\n * This function gives the height of a camera above the surface of a stage, as a part of its distance from the target.\n *\n * `surface` is the radius of the ball around the target that the camera stays out of. A stage with no ball has the value 0.\n * The result is the factor of the turn speed and the zoom speed of a camera: near the surface, a camera moves slowly.\n * The result is 0.02 at least, so a camera on the surface can move away.\n */\nexport function speedAt(distance: number, surface: number): number {\n if (!(distance > 0)) return 1;\n return Math.min(Math.max((distance - surface) / distance, 0.02), 1);\n}\n\n/**\n * This function gives the place at a part of the way between two places. `part` goes from 0 to 1.\n *\n * The azimuth goes along the shortest way. The height above the surface changes by an equal factor for each equal step,\n * so a zoom has one speed in the picture. `surface` is the radius of the ball around the target, or 0 for no ball.\n */\nexport function placeBetween(from: Place, to: Place, part: number, surface: number = 0): Place {\n const between = (a: number, b: number): number => a + (b - a) * part;\n const low = from.distance - surface;\n const high = to.distance - surface;\n const height = low > 0 && high > 0 ? low * (high / low) ** part : between(low, high);\n return {\n target: { x: between(from.target.x, to.target.x), y: between(from.target.y, to.target.y), z: between(from.target.z, to.target.z) },\n polar: between(from.polar, to.polar),\n azimuth: from.azimuth + turnBetween(from.azimuth, to.azimuth) * part,\n distance: surface + height,\n };\n}\n","import type { Point3 } from \"@mark1russell7/layout-contract\";\nimport { capDistance, fitDistance, viewOf, type Place, type PlaceLimits, type ViewAngles } from \"./view.ts\";\n\n/** The space that the content of a stage fills. A view and the limits of the camera come from it. */\nexport interface StageExtent {\n /** The points that a view of all the content shows, for example each corner of each solid. */\n readonly corners: readonly Point3[];\n /** The point that the camera looks at. */\n readonly center: Point3;\n /**\n * The radius of the ball around the center that the camera stays out of, for example the radius of a globe.\n * The default is 0: the content has no ball.\n */\n readonly surface?: number | undefined;\n /** The smallest distance of the camera from the center. The default comes from the views of the stage. */\n readonly minDistance?: number | undefined;\n /** The largest distance of the camera from the center. The default comes from the views of the stage. */\n readonly maxDistance?: number | undefined;\n}\n\n/** The picture that a view is for: the content, and the angle and the shape of the picture. */\nexport interface ViewFrame {\n readonly extent: StageExtent;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n /** The width of the picture divided by its height. */\n readonly aspect: number;\n}\n\n/** A view of a stage: a function that gives the place of the camera for a picture. A new size of the picture gives a new place. */\nexport type StageView = (frame: ViewFrame) => Place;\n\n/** The limits of the camera of a stage: the limits of its place, and the nearest and the farthest depth that it draws. */\nexport interface StageLimits extends PlaceLimits {\n readonly near: number;\n readonly far: number;\n}\n\n/** The space around the content in a view that shows all of it, as a factor of the distance. */\nexport const FIT_MARGIN = 1.06;\n\n/** This function gives the radius of the ball around the center of an extent, or 0 for no ball. */\nexport function surfaceOf(extent: StageExtent): number {\n const surface = extent.surface ?? 0;\n return surface > 0 ? surface : 0;\n}\n\n/**\n * This function makes a view that shows each corner of the content from one direction.\n * `margin` is the space around the content, as a factor of the distance. An extent with no corners gives the distance 1.\n */\nexport function fitView(angles: ViewAngles, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const distance = fitDistance(extent.corners, extent.center, angles, fieldOfView, aspect) * margin;\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: distance > 0 ? distance : 1 };\n };\n}\n\n/**\n * This function makes a view of a part of the ball of the content: a cap around the point of the ball below the camera.\n *\n * `angles` is the direction from the center of the ball to the camera. `angle` is the angle of the cap at the center of the ball, in radians.\n * `margin` is the space around the cap, as a factor of the height above the ball. An extent with no ball gives the distance 1.\n */\nexport function capView(angles: ViewAngles, angle: number, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const surface = surfaceOf(extent);\n const height = Math.max(capDistance(surface, angle, fieldOfView, aspect) - surface, 0);\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: surface > 0 ? surface + height * margin : 1 };\n };\n}\n\n/**\n * This function makes a view of points on the ball of the content. The camera is above the middle of the points, and the picture shows each point.\n *\n * The middle is the center of the box of the points. `margin` is the space around the points, as a factor of the height above the ball.\n * A list with no points gives a view of all of the ball from the front. Points with their middle at the center of the ball give the same view.\n */\nexport function ballView(points: readonly Point3[], margin: number = FIT_MARGIN): StageView {\n let found: { readonly center: Point3; readonly view: StageView } | undefined;\n return (frame) => {\n const { center } = frame.extent;\n // The middle and the cap are the same for each picture of one content. So the function calculates them one time for each center.\n if (found === undefined || found.center.x !== center.x || found.center.y !== center.y || found.center.z !== center.z) {\n found = { center, view: capOf(points, center, margin) };\n }\n return found.view(frame);\n };\n}\n\n/** This function makes the view of the cap of a ball around `center` that holds each point. */\nfunction capOf(points: readonly Point3[], center: Point3, margin: number): StageView {\n const low = { x: Infinity, y: Infinity, z: Infinity };\n const high = { x: -Infinity, y: -Infinity, z: -Infinity };\n for (const point of points) {\n low.x = Math.min(low.x, point.x);\n low.y = Math.min(low.y, point.y);\n low.z = Math.min(low.z, point.z);\n high.x = Math.max(high.x, point.x);\n high.y = Math.max(high.y, point.y);\n high.z = Math.max(high.z, point.z);\n }\n const middle = { x: (low.x + high.x) / 2 - center.x, y: (low.y + high.y) / 2 - center.y, z: (low.z + high.z) / 2 - center.z };\n const length = Math.hypot(middle.x, middle.y, middle.z);\n if (!(length > 0) || !Number.isFinite(length)) return capView({ polar: Math.PI / 2, azimuth: 0 }, Math.PI / 2, margin);\n let angle = 0;\n for (const point of points) {\n const x = point.x - center.x;\n const y = point.y - center.y;\n const z = point.z - center.z;\n const distance = Math.hypot(x, y, z);\n if (!(distance > 0)) continue;\n const cosine = (x * middle.x + y * middle.y + z * middle.z) / (distance * length);\n angle = Math.max(angle, Math.acos(Math.min(Math.max(cosine, -1), 1)));\n }\n const { polar, azimuth } = viewOf(middle, { x: 0, y: 0, z: 0 });\n return capView({ polar, azimuth }, angle, margin);\n}\n\n/** This function gives the radius of the ball around the center of an extent that holds the ball of the extent and each corner. */\nexport function reachOf(extent: StageExtent): number {\n let reach = surfaceOf(extent);\n for (const corner of extent.corners) reach = Math.max(reach, Math.hypot(corner.x - extent.center.x, corner.y - extent.center.y, corner.z - extent.center.z));\n return reach;\n}\n\n/**\n * This function gives the nearest depth that a camera draws, from the distance of the camera to the center of the content.\n *\n * A camera far from the content gets a large value. The depths of the content then have more steps, so two surfaces that are near stay apart.\n * The result is not less than the nearest depth of the limits, and it is in front of all the content.\n */\nexport function nearDepth(limits: StageLimits, extent: StageExtent, distance: number): number {\n const free = (distance - reachOf(extent)) / 8;\n return free > limits.near ? Math.min(free, limits.far / 4) : limits.near;\n}\n\n/**\n * This function gives the limits of the camera of a stage for a picture.\n *\n * The largest distance of the views is the base. The camera goes out to 3 times this distance, and in to 3 % of the height of that view.\n * The extent can give each distance. The nearest depth is small against the height of the nearest camera, and the farthest depth is behind all the content.\n */\nexport function stageLimits(frame: ViewFrame, views: readonly StageView[], polar: { readonly min: number; readonly max: number }): StageLimits {\n const { extent } = frame;\n const surface = surfaceOf(extent);\n let widest = 0;\n for (const view of views) widest = Math.max(widest, view(frame).distance);\n if (!(widest > surface)) widest = surface + 1;\n const reach = reachOf(extent);\n const minDistance = extent.minDistance ?? surface + (widest - surface) * 0.03;\n const maxDistance = Math.max(extent.maxDistance ?? surface + (widest - surface) * 3, minDistance);\n const height = Math.max(minDistance - surface, 1e-6);\n return { minPolar: polar.min, maxPolar: polar.max, minDistance, maxDistance, near: height / 8, far: (maxDistance + reach) * 1.5 };\n}\n"],"mappings":";;AA0CA,SAAgB,SAAS,MAA4B;CACnD,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK;CACpC,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK;CACpC,MAAM,aAAa,KAAK,IAAI,KAAK,OAAO;CACxC,MAAM,aAAa,KAAK,IAAI,KAAK,OAAO;CACxC,OAAO;EACL,MAAM;GAAE,GAAG,WAAW;GAAY,GAAG;GAAU,GAAG,WAAW;EAAW;EACxE,OAAO;GAAE,GAAG;GAAY,GAAG;GAAG,GAAG,IAAI;EAAW;EAChD,IAAI;GAAE,GAAG,IAAI,WAAW;GAAY,GAAG;GAAU,GAAG,IAAI,WAAW;EAAW;CAChF;AACF;;AAGA,SAAS,MAAM,OAAe,QAAgB,MAAsB;CAClE,QAAQ,MAAM,IAAI,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK;AACrG;;;;;;;;AASA,SAAgB,YAAY,QAA2B,QAAgB,MAAkB,KAAa,QAAwB;CAC5H,MAAM,QAAQ,KAAK,IAAK,MAAM,KAAK,KAAM,GAAG;CAC5C,MAAM,WAAW,QAAQ;CACzB,IAAI,EAAE,QAAQ,MAAM,EAAE,WAAW,MAAM,CAAC,OAAO,SAA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