@mark1russell7/visuals 0.2.0 → 0.2.2

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,12 +2,16 @@
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 four entries:
5
+ The package has six entries and two style sheets:
6
6
 
7
- - The entry `.` has the camera maths: views, places, moves, keys and highlights. It needs no browser, and it does not need `three`.
7
+ - The entry `.` has the camera maths and the model of a replay. It needs no browser, and it does not need `three`.
8
8
  - The entry `/marks` has the marks that a viewer draws, as plain data. It needs no browser, and it does not need `three`.
9
9
  - The entry `/three` has the stage. It needs the package `three`, version 0.187.0 or later.
10
10
  - The entry `/globe` has a content that shows the Earth as a globe, with areas and points on it. It also needs `three`.
11
+ - The entry `/scrubber` has a control that sets the time of a picture. It needs a browser, and it does not need `three`.
12
+ - The file `/scrubber.css` is the style sheet of the scrubber.
13
+ - The entry `/labels` has the labels of a stage: a short text next to a point, as an element of the page. It needs a browser.
14
+ - The file `/labels.css` is the style sheet of the labels.
11
15
 
12
16
  ## Install
13
17
 
@@ -15,7 +19,7 @@ The package has four entries:
15
19
  npm install @mark1russell7/visuals three
16
20
  ```
17
21
 
18
- A package that uses only the entries `.` and `/marks` does not install `three`.
22
+ A package that uses only the entries `.`, `/marks` and `/scrubber` does not install `three`.
19
23
 
20
24
  ## A stage
21
25
 
@@ -78,6 +82,8 @@ A stage knows nothing about the data. The content gives it these parts:
78
82
  | `step` | The parts that change with the camera or with the time, before each picture. It is optional. |
79
83
  | `dispose` | The release of the memory of the graphics card. |
80
84
 
85
+ `stackContents` makes one content from a list of contents. The first content gives the extent, and a pick asks the last content first.
86
+
81
87
  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.
82
88
 
83
89
  ## Views
@@ -194,6 +200,7 @@ The functions of the globe maths have no state. A test in Node.js uses them:
194
200
  | `regionEdges` | The lines of the outline of a region. A cut on the antimeridian or at a pole gives no line. |
195
201
  | `gridLines` | The meridians and the parallels of a grid. |
196
202
  | `rayBall`, `inSight` | The first point of a ball on a ray, and if a camera sees a point of the ball. |
203
+ | `pointRadius` | The radius of the mark of a point: a half of its dot, and its ring. A label uses it as its `clear`. |
197
204
 
198
205
  ```ts
199
206
  import { globePoint, regionSurface } from "@mark1russell7/visuals/globe";
@@ -205,6 +212,142 @@ surface.corners.length / 2; // => 43: the corners of the outline with a step of
205
212
  surface.triangles.length / 3; // => 70
206
213
  ```
207
214
 
215
+ ## Labels
216
+
217
+ The entry `/labels` has a layer of labels. A label is a short text next to a point of a stage, for example the name of a place.
218
+
219
+ ```ts
220
+ import { globePoint, inSight, pointRadius } from "@mark1russell7/visuals/globe";
221
+ import { createLabels } from "@mark1russell7/visuals/labels";
222
+ import { createStage, stackContents } from "@mark1russell7/visuals/three";
223
+ import "@mark1russell7/visuals/labels.css";
224
+
225
+ const labels = createLabels(box, {
226
+ labels: [{ record: "city", at: globePoint({ lat: 32.8, lon: -96.8 }), text: "Dallas", rank: 1, clear: pointRadius(8) }],
227
+ visible: (point, eye) => inSight(point, eye, 1),
228
+ });
229
+ const stage = createStage(box, { content: stackContents([globe, labels]), theme, label: "The Earth with the name of one city" });
230
+
231
+ labels.show((label) => label.record !== "city"); // The name of the city goes out of the picture.
232
+ stage?.refresh();
233
+ ```
234
+
235
+ - The layer is a content of a stage with no three.js object. `stackContents` shows it with the content that it names.
236
+ - Give the container of the stage `position: relative`. The layer then fills the picture, above the canvas.
237
+ - Each label is an HTML element. So its text is sharp at each size, and it has the font of the page.
238
+ - No text is on a different text, on the mark of a different label, or out of the picture.
239
+ - When two texts have one place, the label of a highlighted record stays. Then the label with the higher `rank` stays.
240
+ - A label tries its sides in this sequence: right, left, above, below. The field `sides` gives a different sequence.
241
+ - Use the side `center` for the name of an area: the middle of the text is then on the point.
242
+ - `clear` is the radius of the mark at the point. The text stays off the mark, at the gap from it.
243
+ - `visible` tells if the camera sees a point. For a globe, `inSight` removes each name on the far side of the Earth.
244
+ - The places are a function of the picture. While the picture does not move, a highlight moves no text.
245
+ - The pointer goes through the layer to the picture. A screen reader ignores the layer, so give the names in the page too.
246
+ - The layer writes no inline style attribute, so it works under a strict content security policy.
247
+
248
+ `placeLabels` is the pure function that gives each text its place. A test in Node.js and a different renderer use the same function.
249
+
250
+ ```ts
251
+ import { placeLabels } from "@mark1russell7/visuals/labels";
252
+
253
+ // Two labels at one point, each with a text of 60 by 16 pixels and a dot with a radius of 5 pixels.
254
+ const label = { x: 100, y: 100, width: 60, height: 16, clear: 5 };
255
+ placeLabels([label, label], { width: 400, height: 300 });
256
+ // => [{ side: "right", box: { x: 109, y: 92, w: 60, h: 16 } }, { side: "left", box: { x: 31, y: 92, w: 60, h: 16 } }]
257
+ ```
258
+
259
+ The style sheet is plain CSS. A label takes its font from the page.
260
+
261
+ | Variable | What it sets | Default |
262
+ | --- | --- | --- |
263
+ | `--labels-ink` | The color of the text. | `CanvasText` |
264
+ | `--labels-halo` | The color around each letter. Give it the color behind the picture. | `Canvas` |
265
+ | `--labels-size` | The size of the text. | `0.8125rem` |
266
+
267
+ Each text has the kind of its label in `data-kind` and its side in `data-side`. A style sheet of the page gives each kind a look.
268
+
269
+ ## A scrubber
270
+
271
+ The entry `/scrubber` has a control with which a person sets the time of a picture, and replays its changes.
272
+
273
+ ```ts
274
+ import { changeTimes, isLive, replayOf, type Lifetime } from "@mark1russell7/visuals";
275
+ import { createScrubber } from "@mark1russell7/visuals/scrubber";
276
+ import "@mark1russell7/visuals/scrubber.css";
277
+
278
+ // The value of each part of a globe is its lifetime, in hours.
279
+ const lives: readonly Lifetime[] = [{ from: 6, to: 18 }, { from: 12 }];
280
+
281
+ const scrubber = createScrubber(document.body, {
282
+ label: "Time of the picture",
283
+ replay: replayOf({ from: 0, to: 24 }),
284
+ times: changeTimes(lives), // => [6, 12, 18]
285
+ labels: [
286
+ { at: 0, text: "00:00" },
287
+ { at: 12, text: "12:00" },
288
+ ],
289
+ format: (at) => `${String(Math.floor(at)).padStart(2, "0")}:00`,
290
+ onChange: ({ at }) => {
291
+ globe.show((part) => isLive(part.value, at));
292
+ stage.refresh();
293
+ },
294
+ });
295
+ ```
296
+
297
+ - The control has a button for the replay, the text of the time, a slider on an axis and a button for the speed.
298
+ - The axis has a tick at each time of `times`. The ticks of the time that passed have the color of the ink.
299
+ - The slider is an `input` of the type `range`. A pointer, a touch screen, a keyboard and a screen reader use it.
300
+ - The arrow keys go from one change to the next change. The keys `PageUp` and `PageDown` go a tenth of the range.
301
+ - The keys `Home` and `End` go to the ends of the range. The key Space starts and stops the replay.
302
+ - A replay at the end of its range starts again from the start. A replay stops at the end.
303
+ - `onChange` gets each new state. The control knows nothing about the picture, so it works with each stage and each page.
304
+ - `setReplay`, `setTimes` and `setLabels` change the control from the page, for example after new data.
305
+ - The control writes no inline style and no inline script, so it works under a strict content security policy.
306
+
307
+ The style sheet is plain CSS. A bundler takes it from the import. A page with no bundler links to the file of the package.
308
+ The control takes its font and the color of its text from the page.
309
+
310
+ | Variable | What it sets | Default |
311
+ | --- | --- | --- |
312
+ | `--scrubber-ink` | The color of the handle, the ticks of the time that passed, and the button of the replay. | The color of the text |
313
+ | `--scrubber-quiet` | The color of the labels of the axis. | 68% of the color of the text |
314
+ | `--scrubber-line` | The color of the ticks of the time to come, and of the border of the button of the speed. | 45% of the color of the text |
315
+ | `--scrubber-surface` | The color in the ring of the handle. Give it the color behind the control. | `Canvas` |
316
+ | `--scrubber-focus` | The color of the focus ring. | `Highlight` |
317
+ | `--scrubber-time-width` | The width of the text of the time in a control with one row. Thus the axis does not move. | `11rem` |
318
+
319
+ A narrow control has two rows. A control that is 44 rem wide or more has one row. The width is the width of its container.
320
+
321
+ ## The replay
322
+
323
+ A replay is a value: a range of time, the time of the picture, the speed, and if the time goes. Each function gives a new value.
324
+
325
+ ```ts
326
+ import { changeIndex, changeTimes, isLive, replayAdvance, replayKey, replayOf, replayPlay } from "@mark1russell7/visuals";
327
+
328
+ const times = changeTimes([{ from: 6, to: 18 }, { from: 12 }]); // => [6, 12, 18]
329
+ isLive({ from: 6, to: 18 }, 18); // => false: a part is not in the picture at its end
330
+
331
+ const replay = replayOf({ from: 0, to: 24 }); // The picture is at the end of the range, and the time does not go.
332
+ const start = replayPlay(replay); // The replay starts again from the start of the range.
333
+ replayAdvance(start, 5000, 20_000).at; // => 6: a quarter of the duration is a quarter of the range
334
+ replayKey("ArrowLeft", replay, times)?.at; // => 18: the last change before the time
335
+ changeIndex(times, 13); // => 2: draw the picture again only when this count changes
336
+ ```
337
+
338
+ | Function | What it gives |
339
+ | --- | --- |
340
+ | `isLive` | If a part with a lifetime is in the picture at a time. |
341
+ | `changeTimes`, `spanOfTimes` | The sorted times at which a picture changes, and the range from the first time to the last time. |
342
+ | `changeAfter`, `changeBefore`, `changeIndex` | The next change, the change before, and the count of the changes that are not after a time. |
343
+ | `spanPart`, `spanTime` | The place of a time in a range from 0 to 1, and the time at a place. |
344
+ | `replayOf`, `replaySeek`, `replaySpan` | A replay of a range, a replay at a time, and a replay with a new range. |
345
+ | `replayPlay`, `replayPause`, `replayToggle` | A replay that goes, and a replay that does not go. |
346
+ | `replayAdvance` | The replay after a time of the clock. |
347
+ | `replayNextSpeed`, `replayKey` | The replay with the next speed, and the replay after a key. |
348
+
349
+ A time is a number in a unit that the page chooses. `replaySpan` keeps a picture of the present at the present when the range becomes longer.
350
+
208
351
  ## The marks
209
352
 
210
353
  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.
@@ -270,6 +413,7 @@ The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js u
270
413
  | `clampPlace`, `stageLimits` | A place in the limits of a stage, and the limits from the content. |
271
414
  | `reachOf`, `nearDepth` | The radius of the ball that holds the content, and the nearest depth that the camera draws. |
272
415
  | `keyAction` | The action of a key. |
416
+ | `screenPoint` | The point of a picture that shows a point of the world, in CSS pixels. |
273
417
  | `highlightOf`, `isClick` | The highlight of a record, and the difference between a click and a drag. |
274
418
  | `approach` | One step of a value to its goal, for a part that changes with time. |
275
419
 
package/build/globe.d.ts CHANGED
@@ -91,6 +91,11 @@ interface GlobeContent<P> extends StageContent<P, GlobeTheme> {
91
91
  /** This function gives the place on the Earth that a ray from the camera finds. A ray that does not find the Earth gives `undefined`. */
92
92
  placeAt(ray: Raycaster): LatLon | undefined;
93
93
  }
94
+ /**
95
+ * This function gives the radius of the mark of a point of a globe, in CSS pixels. The mark is the dot, and the ring around it.
96
+ * `size` is the width of the dot. Give the result to the field `clear` of a label, so the text stays off the mark.
97
+ */
98
+ export declare function pointRadius(size: number): number;
94
99
  /**
95
100
  * This function makes the content of a stage that shows the Earth as a globe. The center of the globe is the origin of the stage.
96
101
  *
@@ -1 +1 @@
1
- {"version":3,"file":"globe.d.ts","names":[],"sources":["../src/globe/content.ts","../src/globe/mesh.ts","../src/globe/space.ts"],"mappings":";;;;;;UA6BiB;;WAEN;;WAEA;;WAEA;;;UAIM,mBAAmB;;WAEzB;;WAEA;;WAEA;;WAEA,QAAQ,SAAS,eAAe;;WAEhC,OAAO;;WAEP;;WAEA;;;UAIM,UAAU;;WAEhB;;WAEA,QAAQ;;WAER;;WAEA,OAAO;;WAEP;;;UAIM,WAAW;;WAEjB;WACA,OAAO;;WAEP;;WAEA,OAAO;;WAEP;;WAEA;;;UAIM,aAAa;;WAEnB,iBAAiB,UAAU;;WAE3B,kBAAkB,WAAW;;WAE7B;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM,aAAa,WAAW,aAAa,GAAG;;;;;EAKvD,KAAK,OAAO,MAAM,UAAU,KAAK,WAAW;;EAE5C,QAAQ,KAAK,YAAY;;;;;;;;wBAwJX,YAAY,GAAG,UAAS,aAAa,KAAU,aAAa;;;;;UCxQ3D;;WAEN,SAAS;;WAET,WAAW;;;qBAIT;;;;;wBA0CG,WAAW;;;;;;;;;;;;;w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,sBAA2C;;;;;;;;wBA6GvF,YAAY,QAAQ,QAAQ,eAAe;;;;;;;wBA4E3C,UAAU,iBAAiB,eAAe;;;;;qBCld7C;WAAwB;WAAsB;;;;;;;;wBAU3C,WAAW,OAAO,QAAQ,kBAAqB;;;;;wBAS/C,WAAW,OAAO,SAAS;;wBAO3B,YAAY,OAAO,SAAS;;;;;;;wBAU5B,UAAU,OAAO,QAAQ,kBAAsB,kBAA8B;;;;;wBAQ7E,WAAW,kBAAkB,UAAU,kBAA8B;;;;;;wBAiBrE,QAAQ,QAAQ,QAAQ,WAAW,QAAQ,iBAAiB;;;;;wBAe5D,QAAQ,OAAO,QAAQ,KAAK,QAAQ"}
package/build/globe.js CHANGED
@@ -563,6 +563,13 @@ const HIGHLIGHT_OPACITY = .16;
563
563
  const HIGHLIGHT_SIZE = 1.35;
564
564
  /** The width of the ring around a point, in CSS pixels. */
565
565
  const RING_WIDTH = 1.5;
566
+ /**
567
+ * This function gives the radius of the mark of a point of a globe, in CSS pixels. The mark is the dot, and the ring around it.
568
+ * `size` is the width of the dot. Give the result to the field `clear` of a label, so the text stays off the mark.
569
+ */
570
+ function pointRadius(size) {
571
+ return size / 2 + RING_WIDTH;
572
+ }
566
573
  /** The distance around a point where the pointer finds it, in CSS pixels. */
567
574
  const PICK_MARGIN = 4;
568
575
  /** The exponent of the shade at the rim. A large value keeps the shade near the rim. */
@@ -1041,6 +1048,6 @@ function createGlobe(options = {}) {
1041
1048
  }
1042
1049
  };
1043
1050
  }
1044
- export { GLOBE_POLAR, MAX_SURFACE_CORNERS, createGlobe, globeAngles, globePlace, globePoint, globeView, gridLines, inSight, rayBall, regionEdges, regionSurface, regionView, surfaceSag };
1051
+ export { GLOBE_POLAR, MAX_SURFACE_CORNERS, createGlobe, globeAngles, globePlace, globePoint, globeView, gridLines, inSight, pointRadius, rayBall, regionEdges, regionSurface, regionView, surfaceSag };
1045
1052
 
1046
1053
  //# sourceMappingURL=globe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"globe.js","names":["RADIANS"],"sources":["../src/globe/mesh.ts","../src/globe/space.ts","../src/globe/content.ts"],"sourcesContent":["import { densify, type Position, type Region } from \"@mark1russell7/geo\";\nimport { ShapeUtils, Vector2 } from \"three\";\n\n/**\n * The surface of a region as triangles. The region and the triangles are in the plane of longitude and latitude,\n * as the polygon tests of `@mark1russell7/geo` are. So a triangle does not go across the antimeridian.\n */\nexport interface RegionSurface {\n /** The longitude and the latitude of each corner, in degrees: two numbers for each corner. */\n readonly corners: Float64Array;\n /** The three corners of each triangle, as indices of corners. Each triangle is counterclockwise in the plane, with east on the right and north up. */\n readonly triangles: Uint32Array;\n}\n\n/** The largest count of corners of the surface of one region. A smaller step gives more corners. */\nexport const MAX_SURFACE_CORNERS = 2_000_000;\n\n/**\n * The longest edge in a surface, as a factor of the step. An edge of the outline is not longer than the step.\n * An edge in the surface can be longer by this factor, so the count of the passes has a small limit.\n */\nconst LONG_EDGE = 1.25;\n\n/**\n * The smallest length of a degree of longitude in the size of an edge, as a part of a degree at the equator.\n * Near a pole, a degree of longitude is short, and an edge can go across many of them. This limit keeps such an edge to 5 steps of longitude.\n * A straight edge on the Earth is not a straight line in longitude and latitude. The two are far apart for an edge across many degrees.\n */\nconst MIN_WIDTH = 0.25;\n\n/** The largest count of passes that divide the long edges. Each pass makes the longest edge shorter by almost a half. */\nconst MAX_PASSES = 48;\n\n/** The factor of the first corner in the key of an edge. A key is an exact integer for each pair of corners below this count. */\nconst KEY = 2 ** 26;\n\n/** The largest distance of a corner from an edge that it is on, as a part of the length of the edge. */\nconst ON_EDGE = 1e-12;\n\n/** The largest distance of a longitude from 180 degrees, or of a latitude from 90 degrees, that is on the antimeridian or on a pole. */\nconst ON_LINE = 1e-9;\n\nconst RADIANS = Math.PI / 180;\n\n/** This function gives one number of a list. The index is always in the list, so the default 0 has no use. */\nfunction at(list: ArrayLike<number>, index: number): number {\n return list[index] ?? 0;\n}\n\nfunction edgeKey(a: number, b: number): number {\n return a < b ? a * KEY + b : b * KEY + a;\n}\n\n/**\n * This function gives the height of the flat triangles of a surface below a ball of radius 1, at most.\n * A layer at this height above a ball does not go into the ball. `step` is the step of the surface, in degrees.\n */\nexport function surfaceSag(step: number): number {\n // A triangle with no edge longer than `a` on a ball is below the ball by 1 - cos(a / sqrt 3) at most.\n // An edge with a step of `s` in longitude and in latitude has the length s * sqrt 2 at most.\n return 1 - Math.cos((step * RADIANS * LONG_EDGE * Math.SQRT2) / Math.sqrt(3));\n}\n\n/** This function gives the points of a ring, each one time. A point is different from the point before it, and the last point is different from the first point. */\nfunction openRing(ring: readonly Position[]): Vector2[] {\n const points: Vector2[] = [];\n for (const position of ring) {\n const last = points[points.length - 1];\n if (last === undefined || last.x !== position[0] || last.y !== position[1]) points.push(new Vector2(position[0], position[1]));\n }\n const first = points[0];\n while (points.length > 1 && first !== undefined && points[points.length - 1]?.equals(first) === true) points.pop();\n return points;\n}\n\n/**\n * This function gives the size of an edge for the division of a surface, in degrees. The size is the larger of its steps in latitude and in longitude.\n * A step of longitude is as long as it is on the Earth, at the end of the edge that is nearer to the equator.\n */\nfunction edgeSize(lon: readonly number[], lat: readonly number[], a: number, b: number): number {\n const latA = at(lat, a);\n const latB = at(lat, b);\n const wide = Math.abs(at(lon, a) - at(lon, b)) * Math.max(Math.cos(Math.min(Math.abs(latA), Math.abs(latB)) * RADIANS), MIN_WIDTH);\n return Math.max(Math.abs(latA - latB), wide);\n}\n\n/** This function gives, for each edge of a list of faces, a face that has it. An edge of an outline has only one face. */\nfunction ownersOf(faces: readonly (readonly number[])[]): Map<number, number> {\n const owner = new Map<number, number>();\n faces.forEach((face, index) => {\n for (let side = 0; side < face.length; side++) owner.set(edgeKey(at(face, side), at(face, (side + 1) % face.length)), index);\n });\n return owner;\n}\n\n/**\n * This function divides the face with the edge from `a` to `b` at each corner of `run`. The corners of `run` are on the edge, in the sequence from `a` to `b`.\n * Each new face has the third corner of the face, and the direction of the face. An edge with no face changes nothing.\n */\nfunction divideAt(faces: number[][], owner: Map<number, number>, a: number, b: number, run: readonly number[]): void {\n const index = owner.get(edgeKey(a, b));\n const face = index === undefined ? undefined : faces[index];\n const c = face?.find((corner) => corner !== a && corner !== b);\n if (index === undefined || face === undefined || c === undefined || run.length === 0) return;\n const forward = face[(face.indexOf(a) + 1) % 3] === b;\n const chain = [a, ...run, b];\n for (let piece = 0; piece + 1 < chain.length; piece++) {\n const from = at(chain, piece);\n const to = at(chain, piece + 1);\n const place = piece === 0 ? index : faces.length;\n faces[place] = forward ? [from, to, c] : [to, from, c];\n owner.set(edgeKey(from, to), place);\n if (piece === 0) owner.set(edgeKey(a, c), place);\n if (piece === chain.length - 2) owner.set(edgeKey(b, c), place);\n }\n}\n\n/**\n * This function gives the corners that are on the edge from `u` to `v`, between its ends, in the sequence from `u` to `v`.\n * `byLon` has each corner, from the smallest longitude to the largest.\n */\nfunction cornersOn(points: readonly Vector2[], byLon: readonly number[], u: number, v: number): number[] {\n const from = points[u];\n const to = points[v];\n if (from === undefined || to === undefined) return [];\n const dx = to.x - from.x;\n const dy = to.y - from.y;\n const square = dx * dx + dy * dy;\n if (!(square > 0)) return [];\n const slack = Math.sqrt(square) * ON_EDGE;\n const low = Math.min(from.x, to.x) - slack;\n const high = Math.max(from.x, to.x) + slack;\n let first = 0;\n let end = byLon.length;\n while (first < end) {\n const middle = (first + end) >> 1;\n if ((points[at(byLon, middle)]?.x ?? Infinity) < low) first = middle + 1;\n else end = middle;\n }\n const found: { readonly corner: number; readonly part: number }[] = [];\n for (let index = first; index < byLon.length; index++) {\n const corner = at(byLon, index);\n const point = points[corner];\n if (point === undefined || point.x > high) break;\n if (corner === u || corner === v) continue;\n const px = point.x - from.x;\n const py = point.y - from.y;\n const part = (px * dx + py * dy) / square;\n if (part > 0 && part < 1 && Math.abs(px * dy - py * dx) <= square * ON_EDGE) found.push({ corner, part });\n }\n return found.sort((one, other) => one.part - other.part).map(({ corner }) => corner);\n}\n\n/**\n * This function divides a polygon into triangles. Each ring has no point two times in sequence. The faces have indices of the points of the rings, as one list.\n *\n * The division ignores a corner on the straight line between its two neighbors. A face then has an edge with a corner on it,\n * and the face on the other side of that corner has a different edge. The function divides such a face at each corner on its edge,\n * so two faces with a common border have a common edge.\n */\nfunction facesOf(rings: readonly (readonly Vector2[])[]): number[][] {\n const [outer = [], ...holes] = rings;\n const faces = ShapeUtils.triangulateShape(\n [...outer],\n holes.map((hole) => [...hole]),\n );\n const points = rings.flat();\n const ringOf: number[] = [];\n const spotOf: number[] = [];\n rings.forEach((ring, index) => {\n for (let spot = 0; spot < ring.length; spot++) {\n ringOf.push(index);\n spotOf.push(spot);\n }\n });\n const owner = new Map<number, number>();\n const counts = new Map<number, number>();\n faces.forEach((face, index) => {\n for (let side = 0; side < face.length; side++) {\n const key = edgeKey(at(face, side), at(face, (side + 1) % face.length));\n owner.set(key, index);\n counts.set(key, (counts.get(key) ?? 0) + 1);\n }\n });\n let byLon: number[] | undefined;\n for (const [key, count] of counts) {\n if (count !== 1) continue;\n const u = Math.floor(key / KEY);\n const v = key % KEY;\n const ring = at(ringOf, u);\n const gap = Math.abs(at(spotOf, u) - at(spotOf, v));\n // An edge between two neighbors of a ring is an edge of the outline. It has only one face, and no corner on it.\n if (ring === at(ringOf, v) && (gap === 1 || gap === (rings[ring]?.length ?? 0) - 1)) continue;\n byLon ??= points.map((_, index) => index).sort((one, other) => (points[one]?.x ?? 0) - (points[other]?.x ?? 0));\n divideAt(faces, owner, u, v, cornersOn(points, byLon, u, v));\n }\n return faces;\n}\n\n/**\n * This function gives the place of each point of a ring in the same ring with more points on its edges.\n * It gives `undefined` for a ring whose points are not in the other ring, in the same sequence.\n */\nfunction placesIn(dense: readonly Vector2[], own: readonly Vector2[]): number[] | undefined {\n const places: number[] = [];\n let index = 0;\n for (const point of own) {\n while (index < dense.length && dense[index]?.equals(point) !== true) index++;\n if (index >= dense.length) return undefined;\n places.push(index);\n index += 1;\n }\n return places;\n}\n\n/**\n * This function divides each triangle that has a long edge, at the middle of each long edge. It gives the new triangles,\n * or `undefined` when no edge is long. Two triangles with one edge get the same middle, so the surface has no hole.\n */\nfunction dividePass(triangles: readonly number[], lon: number[], lat: number[], limit: number, middles: Map<number, number>): number[] | undefined {\n const next: number[] = [];\n let divided = false;\n const middle = (a: number, b: number): number => {\n const key = edgeKey(a, b);\n const found = middles.get(key);\n if (found !== undefined) return found;\n lon.push((at(lon, a) + at(lon, b)) / 2);\n lat.push((at(lat, a) + at(lat, b)) / 2);\n middles.set(key, lon.length - 1);\n return lon.length - 1;\n };\n for (let index = 0; index < triangles.length; index += 3) {\n const a = at(triangles, index);\n const b = at(triangles, index + 1);\n const c = at(triangles, index + 2);\n const ab = edgeSize(lon, lat, a, b) > limit;\n const bc = edgeSize(lon, lat, b, c) > limit;\n const ca = edgeSize(lon, lat, c, a) > limit;\n const count = Number(ab) + Number(bc) + Number(ca);\n if (count === 0) {\n next.push(a, b, c);\n continue;\n }\n divided = true;\n if (count === 3) {\n const mab = middle(a, b);\n const mbc = middle(b, c);\n const mca = middle(c, a);\n next.push(a, mab, mca, mab, b, mbc, mca, mbc, c, mab, mbc, mca);\n continue;\n }\n // The corners turn to `p`, `q` and `r`. With one long edge, it is from `p` to `q`. With two long edges, the short edge is from `r` to `p`.\n let p = a;\n let q = b;\n let r = c;\n if (count === 1 ? bc : !ab) {\n p = b;\n q = c;\n r = a;\n } else if (count === 1 ? ca : !bc) {\n p = c;\n q = a;\n r = b;\n }\n const mpq = middle(p, q);\n if (count === 1) {\n next.push(p, mpq, r, mpq, q, r);\n continue;\n }\n const mqr = middle(q, r);\n next.push(mpq, q, mqr);\n // The part with four corners gets the shorter of its two diagonals.\n if (edgeSize(lon, lat, p, mqr) <= edgeSize(lon, lat, mpq, r)) next.push(p, mpq, mqr, p, mqr, r);\n else next.push(p, mpq, r, mpq, mqr, r);\n }\n return divided ? next : undefined;\n}\n\n/**\n * This function divides the surface of a region into triangles that follow the curve of the Earth.\n *\n * `step` is the largest step of an edge of the outline in longitude or latitude, in degrees. The outline is the outline of `densify` with this step:\n * each edge of the outline of the surface is an edge of that outline. So a line through the points of `densify` is exactly on the outline of the surface.\n * An edge in the surface is not longer than 1.25 steps. A step of longitude is as long as it is on the Earth at that latitude, and a quarter of a step at least.\n *\n * A straight edge in the plane is a curve on the Earth. So a flat triangle on a globe is not exactly the triangle in the plane.\n * The difference is small for a small step. It is largest near a pole.\n *\n * The function throws a `GeoError` for a region or a step that is not correct, and a `RangeError` for a surface with too many corners.\n */\nexport function regionSurface(region: Region, step: number, maxCorners: number = MAX_SURFACE_CORNERS): RegionSurface {\n const dense = densify(region, step);\n const ownPolygons = region.type === \"Polygon\" ? [region.coordinates] : region.coordinates;\n const densePolygons = dense.type === \"Polygon\" ? [dense.coordinates] : dense.coordinates;\n const lon: number[] = [];\n const lat: number[] = [];\n let triangles: number[] = [];\n ownPolygons.forEach((polygon, polygonIndex) => {\n // The division into triangles gets the corners of the region only. The corners that `densify` adds are on straight lines, and the division ignores some of them.\n const own: Vector2[][] = [];\n const more: Vector2[][] = [];\n const spots: number[][] = [];\n for (let index = 0; index < polygon.length; index++) {\n const ring = openRing(polygon[index] ?? []);\n if (ring.length < 3) {\n // A polygon whose outer ring has no area has no surface. Its holes are in the outer ring, so they have no surface also.\n if (index === 0) return;\n continue;\n }\n const added = openRing(densePolygons[polygonIndex]?.[index] ?? []);\n const places = placesIn(added, ring);\n own.push(ring);\n more.push(places === undefined ? ring : added);\n spots.push(places ?? ring.map((_, spot) => spot));\n }\n const base = lon.length;\n /** The corner of the surface for each corner of the region, as an index from `base`. */\n const cornerOf: number[] = [];\n const starts: number[] = [];\n more.forEach((ring, index) => {\n const start = lon.length - base;\n starts.push(start);\n for (const spot of spots[index] ?? []) cornerOf.push(start + spot);\n for (const point of ring) {\n lon.push(point.x);\n lat.push(point.y);\n }\n });\n if (lon.length > maxCorners) throw tooManyCorners(maxCorners);\n const faces = facesOf(own).map((face) => face.map((corner) => at(cornerOf, corner)));\n // Each edge of the outline gets the corners that `densify` added to it.\n const owner = ownersOf(faces);\n more.forEach((ring, index) => {\n const places = spots[index] ?? [];\n const start = at(starts, index);\n places.forEach((place, spot) => {\n const next = at(places, (spot + 1) % places.length);\n const run: number[] = [];\n for (let between = (place + 1) % ring.length; between !== next; between = (between + 1) % ring.length) run.push(start + between);\n divideAt(faces, owner, start + place, start + next, run);\n });\n });\n // East is on the right of a person who looks at the Earth from outside with north up. So a counterclockwise triangle in the plane has its front outside.\n // The faces of one polygon have one direction. Their sum tells it, also for a face with almost no area.\n const turnOf = ([a = 0, b = 0, c = 0]: readonly number[]): number =>\n (at(lon, base + b) - at(lon, base + a)) * (at(lat, base + c) - at(lat, base + a)) - (at(lon, base + c) - at(lon, base + a)) * (at(lat, base + b) - at(lat, base + a));\n let turn = 0;\n for (const face of faces) turn += turnOf(face);\n for (const [a = 0, b = 0, c = 0] of faces) {\n if (turn >= 0) triangles.push(base + a, base + b, base + c);\n else triangles.push(base + a, base + c, base + b);\n }\n });\n const limit = step * LONG_EDGE;\n const middles = new Map<number, number>();\n for (let pass = 0; ; pass++) {\n const next = dividePass(triangles, lon, lat, limit, middles);\n if (next === undefined) break;\n triangles = next;\n if (lon.length > maxCorners) throw tooManyCorners(maxCorners);\n if (pass >= MAX_PASSES) throw new RangeError(`The surface of the region has edges longer than ${limit} degrees after ${MAX_PASSES} passes.`);\n }\n const corners = new Float64Array(lon.length * 2);\n for (let index = 0; index < lon.length; index++) {\n corners[index * 2] = at(lon, index);\n corners[index * 2 + 1] = at(lat, index);\n }\n return { corners, triangles: Uint32Array.from(triangles) };\n}\n\nfunction tooManyCorners(maxCorners: number): RangeError {\n return new RangeError(`The surface of the region has more than ${maxCorners} corners. Use a larger step.`);\n}\n\n/** A range of latitudes of an edge on the antimeridian. */\ninterface Cut {\n readonly low: number;\n readonly high: number;\n}\n\n/** This function gives 1 for a longitude of 180 degrees east, -1 for 180 degrees west, and 0 for each other longitude. */\nfunction sideOf(position: Position): number {\n if (Math.abs(position[0] - 180) <= ON_LINE) return 1;\n return Math.abs(position[0] + 180) <= ON_LINE ? -1 : 0;\n}\n\n/** This function gives 1 for the north pole, -1 for the south pole, and 0 for each other latitude. */\nfunction poleOf(position: Position): number {\n if (position[1] >= 90 - ON_LINE) return 1;\n return position[1] <= -90 + ON_LINE ? -1 : 0;\n}\n\n/**\n * This function gives the edges of a region as lines, for the outline that a person sees. Each line is a list of longitudes and latitudes, in degrees:\n * two numbers for each point.\n *\n * `step` is the largest step of a line in longitude or latitude, in degrees. The points are the points of `densify`, so they are corners of `regionSurface`.\n * An edge that is only a cut gets no line. A cut is an edge along a pole, or an edge on the antimeridian with an edge of the region on its other side.\n */\nexport function regionEdges(region: Region, step: number): Float64Array[] {\n const polygons = region.type === \"Polygon\" ? [region.coordinates] : region.coordinates;\n const east: Cut[] = [];\n const west: Cut[] = [];\n for (const polygon of polygons) {\n for (const ring of polygon) {\n for (let index = 0; index + 1 < ring.length; index++) {\n const from = ring[index];\n const to = ring[index + 1];\n if (from === undefined || to === undefined) continue;\n const side = sideOf(from);\n if (side === 0 || side !== sideOf(to)) continue;\n (side > 0 ? east : west).push({ low: Math.min(from[1], to[1]), high: Math.max(from[1], to[1]) });\n }\n }\n }\n const isCut = (from: Position, to: Position): boolean => {\n const pole = poleOf(from);\n if (pole !== 0 && pole === poleOf(to)) return true;\n const side = sideOf(from);\n if (side === 0 || side !== sideOf(to)) return false;\n const low = Math.min(from[1], to[1]);\n const high = Math.max(from[1], to[1]);\n return (side > 0 ? west : east).some((cut) => Math.min(cut.high, high) > Math.max(cut.low, low));\n };\n const lines: Float64Array[] = [];\n const add = (run: readonly Position[]): void => {\n if (run.length < 2) return;\n const dense = densify({ type: \"LineString\", coordinates: [...run] }, step).coordinates;\n const line = new Float64Array(dense.length * 2);\n dense.forEach((position, index) => {\n line[index * 2] = position[0];\n line[index * 2 + 1] = position[1];\n });\n lines.push(line);\n };\n for (const polygon of polygons) {\n for (const ring of polygon) {\n const count = ring.length - 1;\n if (count < 1) continue;\n const cut: boolean[] = [];\n for (let index = 0; index < count; index++) {\n const from = ring[index];\n const to = ring[index + 1];\n cut.push(from === undefined || to === undefined || isCut(from, to));\n }\n const first = cut.indexOf(true);\n if (first < 0) {\n add(ring);\n continue;\n }\n // The walk starts after a cut and goes one time around the ring. So it ends at that cut, and each run of edges is complete.\n let run: Position[] = [];\n for (let steps = 1; steps <= count; steps++) {\n const edge = (first + steps) % count;\n const from = ring[edge];\n const to = ring[edge + 1];\n if (cut[edge] === true || from === undefined || to === undefined) {\n add(run);\n run = [];\n continue;\n }\n if (run.length === 0) run.push(from);\n run.push(to);\n }\n }\n }\n return lines;\n}\n\n/**\n * This function gives the lines of a grid of meridians and parallels. Each line is a list of longitudes and latitudes, in degrees: two numbers for each point.\n *\n * `spacing` is the angle between two lines, in degrees, and `step` is the largest step of a line. A spacing of 0 or less gives no lines.\n * The meridians at each 90 degrees go to the poles. The other meridians stop one spacing before each pole, so the poles stay clear.\n */\nexport function gridLines(spacing: number, step: number): Float64Array[] {\n if (!(spacing > 0) || !(step > 0) || !Number.isFinite(spacing)) return [];\n const lines: Float64Array[] = [];\n const add = (fromLon: number, fromLat: number, toLon: number, toLat: number): void => {\n const parts = Math.max(Math.ceil(Math.max(Math.abs(toLon - fromLon), Math.abs(toLat - fromLat)) / step), 1);\n const line = new Float64Array((parts + 1) * 2);\n for (let part = 0; part <= parts; part++) {\n line[part * 2] = fromLon + ((toLon - fromLon) * part) / parts;\n line[part * 2 + 1] = fromLat + ((toLat - fromLat) * part) / parts;\n }\n lines.push(line);\n };\n const top = (Math.ceil(90 / spacing) - 1) * spacing;\n for (let index = 0; index * spacing < 360 - ON_LINE; index++) {\n const lon = -180 + index * spacing;\n const quarter = Math.abs(lon / 90 - Math.round(lon / 90)) <= ON_LINE;\n const end = quarter ? 90 : top;\n if (end > 0) add(lon, -end, lon, end);\n }\n for (let lat = -top; lat <= top + ON_LINE; lat += spacing) add(-180, lat, 180, lat);\n return lines;\n}\n","import { fromUnitVector, toUnitVector, type LatLon, type Region } from \"@mark1russell7/geo\";\nimport type { Point3 } from \"@mark1russell7/layout-contract\";\nimport { ballView, capView, FIT_MARGIN, type StageView } from \"../extent.ts\";\nimport type { ViewAngles } from \"../view.ts\";\n\n/**\n * The polar limits of the camera of a globe: the camera goes above each pole.\n * Give this value to the option `polar` of a stage. Set the option `pan` to false, so the camera turns around the center of the Earth.\n */\nexport const GLOBE_POLAR: { readonly min: number; readonly max: number } = { min: 0.01, max: Math.PI - 0.01 };\n\nconst RADIANS = Math.PI / 180;\n\n/**\n * This function gives the point of a globe for a place on the Earth. The center of the globe is the origin of the stage.\n *\n * The axis `y` of the stage goes to the north pole. The axis `z` goes to latitude 0 and longitude 0, and the axis `x` goes to latitude 0 and longitude 90 east.\n * `radius` is the distance of the point from the center. The default is 1.\n */\nexport function globePoint(place: LatLon, radius: number = 1): Point3 {\n const unit = toUnitVector(place);\n return { x: unit.y * radius, y: unit.z * radius, z: unit.x * radius };\n}\n\n/**\n * This function gives the place on the Earth in the direction of a point of the stage, as seen from the center of the globe.\n * The center of the globe has no direction, so it gives `undefined`.\n */\nexport function globePlace(point: Point3): LatLon | undefined {\n if (point.x === 0 && point.y === 0 && point.z === 0) return undefined;\n if (!Number.isFinite(point.x) || !Number.isFinite(point.y) || !Number.isFinite(point.z)) return undefined;\n return fromUnitVector({ x: point.z, y: point.x, z: point.y });\n}\n\n/** This function gives the direction of a camera that is above a place on the Earth. */\nexport function globeAngles(place: LatLon): ViewAngles {\n return { polar: Math.PI / 2 - place.lat * RADIANS, azimuth: place.lon * RADIANS };\n}\n\n/**\n * This function makes a view from above a place on the Earth. The picture shows the cap of the Earth around the place.\n *\n * `degrees` is the angle of the cap at the center of the Earth. It is the distance from the place to the edge of the cap, in degrees of a great circle.\n * The default is 90: the picture shows a half of the Earth. `margin` is the space around the cap, as a factor of the height above the surface.\n */\nexport function globeView(place: LatLon, degrees: number = 90, margin: number = FIT_MARGIN): StageView {\n return capView(globeAngles(place), Math.min(Math.max(degrees, 0), 90) * RADIANS, margin);\n}\n\n/**\n * This function makes a view that shows each region of a list. The camera is above the middle of the regions.\n * A list with no regions gives a view of a half of the Earth. `margin` is the space around the regions, as a factor of the height above the surface.\n */\nexport function regionView(regions: readonly Region[], margin: number = FIT_MARGIN): StageView {\n const points: Point3[] = [];\n for (const region of regions) {\n const polygons = region.type === \"Polygon\" ? [region.coordinates] : region.coordinates;\n for (const polygon of polygons) {\n // The first ring of a polygon is its outer edge. A hole is in it, so the holes add no extent.\n for (const position of polygon[0] ?? []) points.push(globePoint({ lat: position[1], lon: position[0] }));\n }\n }\n return ballView(points, margin);\n}\n\n/**\n * This function gives the first point of a ball that a ray finds. The center of the ball is the origin of the stage.\n *\n * `direction` has the length 1. A ray that does not find the ball gives `undefined`, and a ray that starts in the ball also gives `undefined`.\n */\nexport function rayBall(origin: Point3, direction: Point3, radius: number): Point3 | undefined {\n const along = origin.x * direction.x + origin.y * direction.y + origin.z * direction.z;\n const outside = origin.x * origin.x + origin.y * origin.y + origin.z * origin.z - radius * radius;\n if (!(outside > 0)) return undefined;\n const root = along * along - outside;\n if (!(root >= 0)) return undefined;\n const distance = -along - Math.sqrt(root);\n if (!(distance >= 0)) return undefined;\n return { x: origin.x + direction.x * distance, y: origin.y + direction.y * distance, z: origin.z + direction.z * distance };\n}\n\n/**\n * This function tells if a camera at `eye` sees a point of the surface of a ball. The center of the ball is the origin of the stage.\n * A point on the far side of the ball gives false.\n */\nexport function inSight(point: Point3, eye: Point3, radius: number): boolean {\n const length = Math.hypot(point.x, point.y, point.z);\n if (!(length > 0)) return false;\n return (point.x * eye.x + point.y * eye.y + point.z * eye.z) / length > radius;\n}\n","import { pointLocator, type LatLon, type PointLocator, type Region } from \"@mark1russell7/geo\";\nimport type { Point3 } from \"@mark1russell7/layout-contract\";\nimport {\n BufferAttribute,\n BufferGeometry,\n Color,\n FrontSide,\n InstancedInterleavedBuffer,\n InterleavedBufferAttribute,\n Mesh,\n MeshBasicMaterial,\n Points,\n ShaderMaterial,\n Sphere,\n SphereGeometry,\n Vector3,\n type Object3D,\n type Raycaster,\n} from \"three\";\nimport { LineMaterial } from \"three/addons/lines/LineMaterial.js\";\nimport { LineSegments2 } from \"three/addons/lines/LineSegments2.js\";\nimport { LineSegmentsGeometry } from \"three/addons/lines/LineSegmentsGeometry.js\";\nimport type { Highlight } from \"../highlight.ts\";\nimport type { StageContent, StageFrame, StagePick } from \"../stage/stage.ts\";\nimport type { StageTheme } from \"../theme.ts\";\nimport { gridLines, regionEdges, regionSurface, surfaceSag } from \"./mesh.ts\";\nimport { globePlace, globePoint, inSight, rayBall } from \"./space.ts\";\n\n/** The look of the areas and the points of one kind. Each color is a CSS hex color. */\nexport interface GlobeStyle {\n /** The color of the surface of an area, or of a point. An area with no color has no surface, and a point with no color is not in the picture. */\n readonly fill?: string | undefined;\n /** The part of the light that the surface of an area stops, from 0 to 1. The default is 1. */\n readonly opacity?: number | undefined;\n /** The color of the edge of an area, or of the ring around a point. An area with no color has no edge. */\n readonly line?: string | undefined;\n}\n\n/** The colors of a globe. Each color is a CSS hex color. */\nexport interface GlobeTheme extends StageTheme {\n /** The color of the Earth where it has no area, for example the sea. */\n readonly ball: string;\n /** The color of the meridians and the parallels. */\n readonly grid: string;\n /** The color of the shade at the rim of the Earth. */\n readonly shade: string;\n /** The style of each kind of area or point, by the name of the kind. */\n readonly styles: Readonly<Record<string, GlobeStyle>>;\n /** The style of a kind that `styles` does not have. */\n readonly other: GlobeStyle;\n /** The color of the edge of a record under the pointer, or in the highlighted list. */\n readonly hovered: string;\n /** The color of the edge of the selected record. */\n readonly selected: string;\n}\n\n/** An area of a globe: a region of the Earth that belongs to a record. */\nexport interface GlobeArea<P> {\n /** The name of the record. Two parts with one name are one record: the stage highlights them together. */\n readonly record: string;\n /** The region, with edges that are straight lines in longitude and latitude, as in `@mark1russell7/geo`. */\n readonly region: Region;\n /** The name of the style of the area in the theme. */\n readonly kind: string;\n /** The value that a pick of the area gives to the page. */\n readonly value: P;\n /** This value is false for an area that the pointer does not find. The default is true. */\n readonly pick?: boolean | undefined;\n}\n\n/** A point of a globe: a place on the Earth that belongs to a record. The picture shows it as a dot of a constant size. */\nexport interface GlobePoint<P> {\n /** The name of the record. Two parts with one name are one record: the stage highlights them together. */\n readonly record: string;\n readonly place: LatLon;\n /** The name of the style of the point in the theme. */\n readonly kind: string;\n /** The value that a pick of the point gives to the page. */\n readonly value: P;\n /** The width of the dot, in CSS pixels. The default is the option `pointSize` of the globe. */\n readonly size?: number | undefined;\n /** This value is false for a point that the pointer does not find. The default is true. */\n readonly pick?: boolean | undefined;\n}\n\n/** The options of a globe. Each width is in CSS pixels. */\nexport interface GlobeOptions<P> {\n /** The areas, in the sequence of the picture: a later area is above an earlier area, and the pointer finds it first. */\n readonly areas?: readonly GlobeArea<P>[] | undefined;\n /** The points. Each point is above each area. */\n readonly points?: readonly GlobePoint<P>[] | undefined;\n /** The radius of the globe, in the units of the stage. The default is 1. */\n readonly radius?: number | undefined;\n /** The largest step of an edge in longitude or latitude, in degrees. A smaller step follows the curve of the Earth better. The default is 1. */\n readonly step?: number | undefined;\n /** The angle between two lines of the grid, in degrees. The value 0 gives no grid. The default is 15. */\n readonly grid?: number | undefined;\n /** The smallest height of the camera above the surface, as a part of the radius. The default is 0.005. */\n readonly nearest?: number | undefined;\n /** The width of the edge of an area. The default is 1.25. */\n readonly lineWidth?: number | undefined;\n /** The width of the edge of a record with a highlight. The default is 2.5. */\n readonly highlightWidth?: number | undefined;\n /** The width of a line of the grid. The default is 1. */\n readonly gridWidth?: number | undefined;\n /** The width of the dot of a point. The default is 9. */\n readonly pointSize?: number | undefined;\n /** The strength of the shade at the rim of the Earth, from 0 to 1. The default is 0.4. */\n readonly shade?: number | undefined;\n}\n\n/** The content of a stage that shows the Earth as a globe, with areas and points on it. */\nexport interface GlobeContent<P> extends StageContent<P, GlobeTheme> {\n /**\n * This function shows only the areas and the points that a test accepts. A part that the picture does not show gets no pick.\n * Start `refresh` of the stage after it. A test that accepts each part shows all of them again.\n */\n show(test: (part: GlobeArea<P> | GlobePoint<P>) => boolean): void;\n /** This function gives the place on the Earth that a ray from the camera finds. A ray that does not find the Earth gives `undefined`. */\n placeAt(ray: Raycaster): LatLon | undefined;\n}\n\n/** The smallest height of the layer of the areas above the ball, as a part of the radius. */\nconst MIN_LIFT = 0.0005;\n\n/** The opacity that a highlight adds to the surface of an area. */\nconst HIGHLIGHT_OPACITY = 0.16;\n\n/** The factor of the width of a point with a highlight. */\nconst HIGHLIGHT_SIZE = 1.35;\n\n/** The width of the ring around a point, in CSS pixels. */\nconst RING_WIDTH = 1.5;\n\n/** The distance around a point where the pointer finds it, in CSS pixels. */\nconst PICK_MARGIN = 4;\n\n/** The exponent of the shade at the rim. A large value keeps the shade near the rim. */\nconst SHADE_POWER = 2.6;\n\nconst BALL_SEGMENTS = 128;\n\nconst SHADE_VERTEX = `\nvarying vec3 vNormal;\nvarying vec3 vToEye;\nvoid main() {\n vec4 inView = modelViewMatrix * vec4(position, 1.0);\n vNormal = normalMatrix * normal;\n vToEye = -inView.xyz;\n gl_Position = projectionMatrix * inView;\n}`;\n\nconst SHADE_FRAGMENT = `\nuniform vec3 shade;\nuniform float strength;\nuniform float power;\nvarying vec3 vNormal;\nvarying vec3 vToEye;\nvoid main() {\n float facing = clamp(dot(normalize(vNormal), normalize(vToEye)), 0.0, 1.0);\n gl_FragColor = vec4(shade, strength * pow(1.0 - facing, power));\n #include <colorspace_fragment>\n}`;\n\nconst POINT_VERTEX = `\nuniform float pixelRatio;\nuniform float ringWidth;\nattribute vec3 fill;\nattribute vec3 ring;\nattribute float size;\nvarying vec3 vFill;\nvarying vec3 vRing;\nvarying float vFade;\nvarying float vInner;\nvoid main() {\n vec4 inWorld = modelMatrix * vec4(position, 1.0);\n vec3 up = normalize(inWorld.xyz - modelMatrix[3].xyz);\n float facing = dot(up, normalize(cameraPosition - inWorld.xyz));\n vFill = fill;\n vRing = ring;\n vFade = smoothstep(0.0, 0.1, facing);\n vInner = size / (size + 2.0 * ringWidth);\n gl_PointSize = (size + 2.0 * ringWidth) * pixelRatio;\n gl_Position = projectionMatrix * viewMatrix * inWorld;\n // A point on the far side of the Earth, and a point that the picture does not show, goes out of the picture.\n if (facing <= 0.0 || size <= 0.0) gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n}`;\n\nconst POINT_FRAGMENT = `\nvarying vec3 vFill;\nvarying vec3 vRing;\nvarying float vFade;\nvarying float vInner;\nvoid main() {\n float distance = length(gl_PointCoord * 2.0 - 1.0);\n float soft = fwidth(distance);\n float dot = 1.0 - smoothstep(1.0 - soft, 1.0, distance);\n float middle = 1.0 - smoothstep(vInner - soft, vInner, distance);\n gl_FragColor = vec4(mix(vRing, vFill, middle), dot * vFade);\n if (gl_FragColor.a <= 0.0) discard;\n #include <colorspace_fragment>\n}`;\n\n/** An area with the place of its data in the buffers of the globe. */\ninterface AreaPart<P> {\n readonly area: GlobeArea<P>;\n readonly locate: PointLocator | undefined;\n readonly firstCorner: number;\n readonly cornerCount: number;\n readonly firstIndex: number;\n readonly indexCount: number;\n readonly firstSegment: number;\n readonly segmentCount: number;\n shown: boolean;\n filled: boolean;\n lined: boolean;\n highlight: Highlight;\n}\n\n/** A point with its place on the globe. */\ninterface PointPart<P> {\n readonly point: GlobePoint<P>;\n readonly at: Point3;\n readonly size: number;\n shown: boolean;\n filled: boolean;\n highlight: Highlight;\n}\n\n/** This function gives the text of a thrown value. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** This function writes the points of lines into a list of segments on a ball: six numbers for each segment. It gives the count of the segments. */\nfunction addSegments(lines: readonly Float64Array[], radius: number, to: number[]): number {\n let count = 0;\n for (const line of lines) {\n let from: Point3 | undefined;\n for (let index = 0; index + 1 < line.length; index += 2) {\n const next = globePoint({ lat: line[index + 1] ?? 0, lon: line[index] ?? 0 }, radius);\n if (from !== undefined) {\n to.push(from.x, from.y, from.z, next.x, next.y, next.z);\n count += 1;\n }\n from = next;\n }\n }\n return count;\n}\n\n/** This function makes the geometry of thick line segments from a buffer of positions and a buffer of colors: six numbers for each segment. */\nfunction segmentGeometry(positions: InstancedInterleavedBuffer, colors: InstancedInterleavedBuffer | undefined, count: number, bounds: Sphere): LineSegmentsGeometry {\n const geometry = new LineSegmentsGeometry();\n geometry.setAttribute(\"instanceStart\", new InterleavedBufferAttribute(positions, 3, 0));\n geometry.setAttribute(\"instanceEnd\", new InterleavedBufferAttribute(positions, 3, 3));\n if (colors !== undefined) {\n geometry.setAttribute(\"instanceColorStart\", new InterleavedBufferAttribute(colors, 3, 0));\n geometry.setAttribute(\"instanceColorEnd\", new InterleavedBufferAttribute(colors, 3, 3));\n }\n geometry.instanceCount = count;\n geometry.boundingSphere = bounds;\n return geometry;\n}\n\n/**\n * This function makes the content of a stage that shows the Earth as a globe. The center of the globe is the origin of the stage.\n *\n * The materials use no light, so each color in the picture is the color of the theme. Use `GLOBE_POLAR` and no pan in the options of the stage.\n * The function throws an `Error` with the name of the record for an area that is not correct. Its cause is the error of `@mark1russell7/geo`.\n */\nexport function createGlobe<P>(options: GlobeOptions<P> = {}): GlobeContent<P> {\n const radius = options.radius ?? 1;\n const step = options.step ?? 1;\n const layer = radius * (1 + Math.max(MIN_LIFT, surfaceSag(step) * 2));\n const bounds = new Sphere(new Vector3(0, 0, 0), layer);\n const color = new Color();\n\n // The ball, and the shade at its rim.\n const ballGeometry = new SphereGeometry(radius, BALL_SEGMENTS, BALL_SEGMENTS / 2);\n const ballMaterial = new MeshBasicMaterial();\n const ball = new Mesh(ballGeometry, ballMaterial);\n const shadeColor = { value: new Color() };\n const shadeMaterial = new ShaderMaterial({\n uniforms: { shade: shadeColor, strength: { value: Math.min(Math.max(options.shade ?? 0.4, 0), 1) }, power: { value: SHADE_POWER } },\n vertexShader: SHADE_VERTEX,\n fragmentShader: SHADE_FRAGMENT,\n transparent: true,\n depthTest: false,\n depthWrite: false,\n side: FrontSide,\n });\n const shade = new Mesh(ballGeometry, shadeMaterial);\n shade.renderOrder = 4;\n\n // The grid.\n const gridList: number[] = [];\n const gridCount = addSegments(gridLines(options.grid ?? 15, step), layer, gridList);\n const gridMaterial = new LineMaterial({ linewidth: options.gridWidth ?? 1, transparent: true, depthWrite: false });\n const grid = new LineSegments2(segmentGeometry(new InstancedInterleavedBuffer(Float32Array.from(gridList), 6, 1), undefined, gridCount, bounds), gridMaterial);\n grid.renderOrder = 1;\n grid.visible = gridCount > 0;\n grid.frustumCulled = false;\n\n // The areas: one surface and one list of segments for all of them.\n const surfaces: { readonly corners: Float64Array; readonly triangles: Uint32Array }[] = [];\n const segmentList: number[] = [];\n const areaParts: AreaPart<P>[] = [];\n let cornerTotal = 0;\n let indexTotal = 0;\n let segmentTotal = 0;\n for (const area of options.areas ?? []) {\n try {\n const surface = regionSurface(area.region, step);\n const segmentCount = addSegments(regionEdges(area.region, step), layer, segmentList);\n areaParts.push({\n area,\n locate: area.pick === false ? undefined : pointLocator(area.region),\n firstCorner: cornerTotal,\n cornerCount: surface.corners.length / 2,\n firstIndex: indexTotal,\n indexCount: surface.triangles.length,\n firstSegment: segmentTotal,\n segmentCount,\n shown: true,\n filled: false,\n lined: false,\n highlight: 0,\n });\n surfaces.push(surface);\n cornerTotal += surface.corners.length / 2;\n indexTotal += surface.triangles.length;\n segmentTotal += segmentCount;\n } catch (error) {\n throw new Error(`The area of the record ${area.record} is not correct: ${messageOf(error)}`, { cause: error });\n }\n }\n const fillPositions = new Float32Array(cornerTotal * 3);\n const allIndices = new Uint32Array(indexTotal);\n surfaces.forEach((surface, index) => {\n const part = areaParts[index];\n if (part === undefined) return;\n for (let corner = 0; corner < part.cornerCount; corner++) {\n const point = globePoint({ lat: surface.corners[corner * 2 + 1] ?? 0, lon: surface.corners[corner * 2] ?? 0 }, layer);\n fillPositions.set([point.x, point.y, point.z], (part.firstCorner + corner) * 3);\n }\n for (let at = 0; at < part.indexCount; at++) allIndices[part.firstIndex + at] = (surface.triangles[at] ?? 0) + part.firstCorner;\n });\n const fillColors = new BufferAttribute(new Float32Array(cornerTotal * 4), 4);\n const fillIndices = new BufferAttribute(new Uint32Array(indexTotal), 1);\n const fillGeometry = new BufferGeometry();\n fillGeometry.setAttribute(\"position\", new BufferAttribute(fillPositions, 3));\n fillGeometry.setAttribute(\"color\", fillColors);\n fillGeometry.setIndex(fillIndices);\n fillGeometry.boundingSphere = bounds;\n const fillMaterial = new MeshBasicMaterial({ vertexColors: true, transparent: true, depthWrite: false, side: FrontSide });\n const fills = new Mesh(fillGeometry, fillMaterial);\n fills.renderOrder = 2;\n fills.frustumCulled = false;\n\n // The edges of the areas. The picture draws the segments at the start of the buffers, so the segments of the shown areas are there.\n const allSegments = Float32Array.from(segmentList);\n const allSegmentColors = new Float32Array(allSegments.length);\n const edgePositions = new InstancedInterleavedBuffer(new Float32Array(allSegments.length), 6, 1);\n const edgeColors = new InstancedInterleavedBuffer(new Float32Array(allSegments.length), 6, 1);\n const edgeGeometry = segmentGeometry(edgePositions, edgeColors, 0, bounds);\n const edgeMaterial = new LineMaterial({ linewidth: options.lineWidth ?? 1.25, vertexColors: true, transparent: true, depthWrite: false });\n const edges = new LineSegments2(edgeGeometry, edgeMaterial);\n edges.renderOrder = 3;\n edges.frustumCulled = false;\n\n // The edges of the records with a highlight, above the other edges.\n const highlightMaterial = new LineMaterial({ linewidth: options.highlightWidth ?? 2.5, vertexColors: true, transparent: true, depthWrite: false });\n const highlighted = new LineSegments2(new LineSegmentsGeometry(), highlightMaterial);\n highlighted.renderOrder = 5;\n highlighted.frustumCulled = false;\n highlighted.visible = false;\n\n // The points.\n const pointSize = options.pointSize ?? 9;\n const pointParts: PointPart<P>[] = (options.points ?? []).map((point) => ({\n point,\n at: globePoint(point.place, layer),\n size: point.size ?? pointSize,\n shown: true,\n filled: false,\n highlight: 0,\n }));\n const pointPositions = new Float32Array(pointParts.length * 3);\n pointParts.forEach((part, index) => pointPositions.set([part.at.x, part.at.y, part.at.z], index * 3));\n const pointFills = new BufferAttribute(new Float32Array(pointParts.length * 3), 3);\n const pointRings = new BufferAttribute(new Float32Array(pointParts.length * 3), 3);\n const pointSizes = new BufferAttribute(new Float32Array(pointParts.length), 1);\n const pointGeometry = new BufferGeometry();\n pointGeometry.setAttribute(\"position\", new BufferAttribute(pointPositions, 3));\n pointGeometry.setAttribute(\"fill\", pointFills);\n pointGeometry.setAttribute(\"ring\", pointRings);\n pointGeometry.setAttribute(\"size\", pointSizes);\n pointGeometry.boundingSphere = bounds;\n const pixelRatio = { value: 1 };\n const pointMaterial = new ShaderMaterial({\n uniforms: { pixelRatio, ringWidth: { value: RING_WIDTH } },\n vertexShader: POINT_VERTEX,\n fragmentShader: POINT_FRAGMENT,\n transparent: true,\n depthTest: false,\n depthWrite: false,\n });\n const dots = new Points(pointGeometry, pointMaterial);\n dots.renderOrder = 6;\n dots.frustumCulled = false;\n dots.visible = pointParts.length > 0;\n // The size of a dot is in CSS pixels, and the picture can have more than one pixel for each CSS pixel.\n dots.onBeforeRender = (renderer): void => {\n pixelRatio.value = renderer.getPixelRatio();\n };\n\n const records = new Set<string>([...areaParts.map((part) => part.area.record), ...pointParts.map((part) => part.point.record)]);\n let painted: GlobeTheme | undefined;\n /** The angle of one CSS pixel at the middle of the picture, in radians. */\n let pixelAngle = 0.001;\n\n const styleOf = (theme: GlobeTheme, kind: string): GlobeStyle => theme.styles[kind] ?? theme.other;\n const highlightColor = (theme: GlobeTheme, highlight: Highlight): string => (highlight === 2 ? theme.selected : theme.hovered);\n\n /** This function writes the colors of an area into the buffers. */\n const paintArea = (part: AreaPart<P>, theme: GlobeTheme): void => {\n const style = styleOf(theme, part.area.kind);\n part.filled = style.fill !== undefined;\n part.lined = style.line !== undefined;\n if (style.fill !== undefined) {\n color.set(style.fill);\n const opacity = Math.min(Math.max(style.opacity ?? 1, 0), 1);\n const alpha = part.highlight === 0 ? opacity : Math.min(opacity + HIGHLIGHT_OPACITY, 1);\n const values = [color.r, color.g, color.b, alpha];\n for (let corner = 0; corner < part.cornerCount; corner++) fillColors.array.set(values, (part.firstCorner + corner) * 4);\n fillColors.needsUpdate = true;\n }\n if (style.line !== undefined) {\n color.set(style.line);\n const values = [color.r, color.g, color.b, color.r, color.g, color.b];\n for (let segment = 0; segment < part.segmentCount; segment++) allSegmentColors.set(values, (part.firstSegment + segment) * 6);\n }\n };\n\n /** This function puts the data of the shown parts at the start of the buffers that the picture draws. */\n const sync = (theme: GlobeTheme): void => {\n let indexCount = 0;\n let segmentCount = 0;\n let highlightCount = 0;\n for (const part of areaParts) {\n if (!part.shown) continue;\n if (part.filled) {\n fillIndices.array.set(allIndices.subarray(part.firstIndex, part.firstIndex + part.indexCount), indexCount);\n indexCount += part.indexCount;\n }\n if (part.lined) {\n const from = part.firstSegment * 6;\n const to = from + part.segmentCount * 6;\n edgePositions.array.set(allSegments.subarray(from, to), segmentCount * 6);\n edgeColors.array.set(allSegmentColors.subarray(from, to), segmentCount * 6);\n segmentCount += part.segmentCount;\n }\n if (part.highlight !== 0) highlightCount += part.segmentCount;\n }\n fillIndices.needsUpdate = true;\n fillGeometry.setDrawRange(0, indexCount);\n fills.visible = indexCount > 0;\n edgePositions.needsUpdate = true;\n edgeColors.needsUpdate = true;\n edgeGeometry.instanceCount = segmentCount;\n edges.visible = segmentCount > 0;\n\n // The edges of the records with a highlight get a new geometry. They are few, and a record changes its highlight only on an act of a person.\n const highlightPositions = new Float32Array(highlightCount * 6);\n const highlightColors = new Float32Array(highlightCount * 6);\n let at = 0;\n for (const part of areaParts) {\n if (!part.shown || part.highlight === 0) continue;\n color.set(highlightColor(theme, part.highlight));\n const values = [color.r, color.g, color.b, color.r, color.g, color.b];\n highlightPositions.set(allSegments.subarray(part.firstSegment * 6, (part.firstSegment + part.segmentCount) * 6), at * 6);\n for (let segment = 0; segment < part.segmentCount; segment++) highlightColors.set(values, (at + segment) * 6);\n at += part.segmentCount;\n }\n highlighted.geometry.dispose();\n highlighted.geometry =\n highlightCount > 0 ? segmentGeometry(new InstancedInterleavedBuffer(highlightPositions, 6, 1), new InstancedInterleavedBuffer(highlightColors, 6, 1), highlightCount, bounds) : new LineSegmentsGeometry();\n highlighted.visible = highlightCount > 0;\n\n pointParts.forEach((part, index) => {\n const style = styleOf(theme, part.point.kind);\n part.filled = style.fill !== undefined;\n const visible = part.shown && style.fill !== undefined;\n pointSizes.array[index] = visible ? part.size * (part.highlight === 0 ? 1 : HIGHLIGHT_SIZE) : 0;\n if (style.fill === undefined) return;\n color.set(style.fill);\n pointFills.array.set([color.r, color.g, color.b], index * 3);\n color.set(part.highlight === 0 ? (style.line ?? style.fill) : highlightColor(theme, part.highlight));\n pointRings.array.set([color.r, color.g, color.b], index * 3);\n });\n pointSizes.needsUpdate = true;\n pointFills.needsUpdate = true;\n pointRings.needsUpdate = true;\n };\n\n return {\n objects: [ball, grid, fills, edges, shade, highlighted, dots] satisfies Object3D[],\n extent: { center: { x: 0, y: 0, z: 0 }, corners: [], surface: radius, minDistance: radius * (1 + Math.max(options.nearest ?? 0.005, 1e-6)) },\n has: (record) => records.has(record),\n pick(ray): StagePick<P> | undefined {\n const { origin, direction } = ray.ray;\n let found: PointPart<P> | undefined;\n let nearest = Infinity;\n for (const part of pointParts) {\n if (!part.shown || !part.filled || part.point.pick === false || !inSight(part.at, origin, radius)) continue;\n const x = part.at.x - origin.x;\n const y = part.at.y - origin.y;\n const z = part.at.z - origin.z;\n const cosine = (x * direction.x + y * direction.y + z * direction.z) / Math.hypot(x, y, z);\n const angle = Math.acos(Math.min(Math.max(cosine, -1), 1));\n if (angle > (part.size / 2 + PICK_MARGIN) * pixelAngle || angle >= nearest) continue;\n found = part;\n nearest = angle;\n }\n if (found !== undefined) return { record: found.point.record, value: found.point.value };\n const hit = rayBall(origin, direction, radius);\n const place = hit === undefined ? undefined : globePlace(hit);\n if (place === undefined) return undefined;\n for (let index = areaParts.length - 1; index >= 0; index--) {\n const part = areaParts[index];\n if (part === undefined || !part.shown || part.locate === undefined || !(part.filled || part.lined)) continue;\n if (part.locate(place) !== \"outside\") return { record: part.area.record, value: part.area.value };\n }\n return undefined;\n },\n paint(theme, highlight): void {\n const all = theme !== painted;\n painted = theme;\n if (all) {\n ballMaterial.color.set(theme.ball);\n gridMaterial.color.set(theme.grid);\n shadeColor.value.set(theme.shade);\n }\n for (const part of areaParts) {\n const next = highlight(part.area.record);\n if (!all && next === part.highlight) continue;\n part.highlight = next;\n paintArea(part, theme);\n }\n for (const part of pointParts) part.highlight = highlight(part.point.record);\n sync(theme);\n },\n step(frame: StageFrame): boolean {\n pixelAngle = (2 * Math.tan((frame.fieldOfView * Math.PI) / 360)) / Math.max(frame.height, 1);\n return false;\n },\n show(test): void {\n for (const part of areaParts) part.shown = test(part.area);\n for (const part of pointParts) part.shown = test(part.point);\n if (painted !== undefined) sync(painted);\n },\n placeAt(ray): LatLon | undefined {\n const hit = rayBall(ray.ray.origin, ray.ray.direction, radius);\n return hit === undefined ? undefined : globePlace(hit);\n },\n dispose(): void {\n ballGeometry.dispose();\n ballMaterial.dispose();\n shadeMaterial.dispose();\n grid.geometry.dispose();\n gridMaterial.dispose();\n fillGeometry.dispose();\n fillMaterial.dispose();\n edgeGeometry.dispose();\n edgeMaterial.dispose();\n highlighted.geometry.dispose();\n highlightMaterial.dispose();\n pointGeometry.dispose();\n pointMaterial.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;AAeA,MAAa,sBAAsB;;;;;AAMnC,MAAM,YAAY;;;;;;AAOlB,MAAM,YAAY;;AAGlB,MAAM,aAAa;;AAGnB,MAAM,MAAM,KAAK;;AAGjB,MAAM,UAAU;;AAGhB,MAAM,UAAU;AAEhB,MAAMA,YAAU,KAAK,KAAK;;AAG1B,SAAS,GAAG,MAAyB,OAAuB;CAC1D,OAAO,KAAK,UAAU;AACxB;AAEA,SAAS,QAAQ,GAAW,GAAmB;CAC7C,OAAO,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,MAAM;AACzC;;;;;AAMA,SAAgB,WAAW,MAAsB;CAG/C,OAAO,IAAI,KAAK,IAAK,OAAOA,YAAU,YAAY,KAAK,Q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AAI,IAAI,QAAQ,IAAI,IAAI,WAAW,MAAM;GAC7D,OAAO,QAAQ,KAAA,IAAY,KAAA,IAAY,WAAW,GAAG;EACvD;EACA,UAAgB;GACd,aAAa,QAAQ;GACrB,aAAa,QAAQ;GACrB,cAAc,QAAQ;GACtB,KAAK,SAAS,QAAQ;GACtB,aAAa,QAAQ;GACrB,aAAa,QAAQ;GACrB,aAAa,QAAQ;GACrB,aAAa,QAAQ;GACrB,aAAa,QAAQ;GACrB,YAAY,SAAS,QAAQ;GAC7B,kBAAkB,QAAQ;GAC1B,cAAc,QAAQ;GACtB,cAAc,QAAQ;EACxB;CACF;AACF"}
1
+ {"version":3,"file":"globe.js","names":["RADIANS"],"sources":["../src/globe/mesh.ts","../src/globe/space.ts","../src/globe/content.ts"],"sourcesContent":["import { densify, type Position, type Region } from \"@mark1russell7/geo\";\nimport { ShapeUtils, Vector2 } from \"three\";\n\n/**\n * The surface of a region as triangles. The region and the triangles are in the plane of longitude and latitude,\n * as the polygon tests of `@mark1russell7/geo` are. So a triangle does not go across the antimeridian.\n */\nexport interface RegionSurface {\n /** The longitude and the latitude of each corner, in degrees: two numbers for each corner. */\n readonly corners: Float64Array;\n /** The three corners of each triangle, as indices of corners. Each triangle is counterclockwise in the plane, with east on the right and north up. */\n readonly triangles: Uint32Array;\n}\n\n/** The largest count of corners of the surface of one region. A smaller step gives more corners. */\nexport const MAX_SURFACE_CORNERS = 2_000_000;\n\n/**\n * The longest edge in a surface, as a factor of the step. An edge of the outline is not longer than the step.\n * An edge in the surface can be longer by this factor, so the count of the passes has a small limit.\n */\nconst LONG_EDGE = 1.25;\n\n/**\n * The smallest length of a degree of longitude in the size of an edge, as a part of a degree at the equator.\n * Near a pole, a degree of longitude is short, and an edge can go across many of them. This limit keeps such an edge to 5 steps of longitude.\n * A straight edge on the Earth is not a straight line in longitude and latitude. The two are far apart for an edge across many degrees.\n */\nconst MIN_WIDTH = 0.25;\n\n/** The largest count of passes that divide the long edges. Each pass makes the longest edge shorter by almost a half. */\nconst MAX_PASSES = 48;\n\n/** The factor of the first corner in the key of an edge. A key is an exact integer for each pair of corners below this count. */\nconst KEY = 2 ** 26;\n\n/** The largest distance of a corner from an edge that it is on, as a part of the length of the edge. */\nconst ON_EDGE = 1e-12;\n\n/** The largest distance of a longitude from 180 degrees, or of a latitude from 90 degrees, that is on the antimeridian or on a pole. */\nconst ON_LINE = 1e-9;\n\nconst RADIANS = Math.PI / 180;\n\n/** This function gives one number of a list. The index is always in the list, so the default 0 has no use. */\nfunction at(list: ArrayLike<number>, index: number): number {\n return list[index] ?? 0;\n}\n\nfunction edgeKey(a: number, b: number): number {\n return a < b ? a * KEY + b : b * KEY + a;\n}\n\n/**\n * This function gives the height of the flat triangles of a surface below a ball of radius 1, at most.\n * A layer at this height above a ball does not go into the ball. `step` is the step of the surface, in degrees.\n */\nexport function surfaceSag(step: number): number {\n // A triangle with no edge longer than `a` on a ball is below the ball by 1 - cos(a / sqrt 3) at most.\n // An edge with a step of `s` in longitude and in latitude has the length s * sqrt 2 at most.\n return 1 - Math.cos((step * RADIANS * LONG_EDGE * Math.SQRT2) / Math.sqrt(3));\n}\n\n/** This function gives the points of a ring, each one time. A point is different from the point before it, and the last point is different from the first point. */\nfunction openRing(ring: readonly Position[]): Vector2[] {\n const points: Vector2[] = [];\n for (const position of ring) {\n const last = points[points.length - 1];\n if (last === undefined || last.x !== position[0] || last.y !== position[1]) points.push(new Vector2(position[0], position[1]));\n }\n const first = points[0];\n while (points.length > 1 && first !== undefined && points[points.length - 1]?.equals(first) === true) points.pop();\n return points;\n}\n\n/**\n * This function gives the size of an edge for the division of a surface, in degrees. The size is the larger of its steps in latitude and in longitude.\n * A step of longitude is as long as it is on the Earth, at the end of the edge that is nearer to the equator.\n */\nfunction edgeSize(lon: readonly number[], lat: readonly number[], a: number, b: number): number {\n const latA = at(lat, a);\n const latB = at(lat, b);\n const wide = Math.abs(at(lon, a) - at(lon, b)) * Math.max(Math.cos(Math.min(Math.abs(latA), Math.abs(latB)) * RADIANS), MIN_WIDTH);\n return Math.max(Math.abs(latA - latB), wide);\n}\n\n/** This function gives, for each edge of a list of faces, a face that has it. An edge of an outline has only one face. */\nfunction ownersOf(faces: readonly (readonly number[])[]): Map<number, number> {\n const owner = new Map<number, number>();\n faces.forEach((face, index) => {\n for (let side = 0; side < face.length; side++) owner.set(edgeKey(at(face, side), at(face, (side + 1) % face.length)), index);\n });\n return owner;\n}\n\n/**\n * This function divides the face with the edge from `a` to `b` at each corner of `run`. The corners of `run` are on the edge, in the sequence from `a` to `b`.\n * Each new face has the third corner of the face, and the direction of the face. An edge with no face changes nothing.\n */\nfunction divideAt(faces: number[][], owner: Map<number, number>, a: number, b: number, run: readonly number[]): void {\n const index = owner.get(edgeKey(a, b));\n const face = index === undefined ? undefined : faces[index];\n const c = face?.find((corner) => corner !== a && corner !== b);\n if (index === undefined || face === undefined || c === undefined || run.length === 0) return;\n const forward = face[(face.indexOf(a) + 1) % 3] === b;\n const chain = [a, ...run, b];\n for (let piece = 0; piece + 1 < chain.length; piece++) {\n const from = at(chain, piece);\n const to = at(chain, piece + 1);\n const place = piece === 0 ? index : faces.length;\n faces[place] = forward ? [from, to, c] : [to, from, c];\n owner.set(edgeKey(from, to), place);\n if (piece === 0) owner.set(edgeKey(a, c), place);\n if (piece === chain.length - 2) owner.set(edgeKey(b, c), place);\n }\n}\n\n/**\n * This function gives the corners that are on the edge from `u` to `v`, between its ends, in the sequence from `u` to `v`.\n * `byLon` has each corner, from the smallest longitude to the largest.\n */\nfunction cornersOn(points: readonly Vector2[], byLon: readonly number[], u: number, v: number): number[] {\n const from = points[u];\n const to = points[v];\n if (from === undefined || to === undefined) return [];\n const dx = to.x - from.x;\n const dy = to.y - from.y;\n const square = dx * dx + dy * dy;\n if (!(square > 0)) return [];\n const slack = Math.sqrt(square) * ON_EDGE;\n const low = Math.min(from.x, to.x) - slack;\n const high = Math.max(from.x, to.x) + slack;\n let first = 0;\n let end = byLon.length;\n while (first < end) {\n const middle = (first + end) >> 1;\n if ((points[at(byLon, middle)]?.x ?? Infinity) < low) first = middle + 1;\n else end = middle;\n }\n const found: { readonly corner: number; readonly part: number }[] = [];\n for (let index = first; index < byLon.length; index++) {\n const corner = at(byLon, index);\n const point = points[corner];\n if (point === undefined || point.x > high) break;\n if (corner === u || corner === v) continue;\n const px = point.x - from.x;\n const py = point.y - from.y;\n const part = (px * dx + py * dy) / square;\n if (part > 0 && part < 1 && Math.abs(px * dy - py * dx) <= square * ON_EDGE) found.push({ corner, part });\n }\n return found.sort((one, other) => one.part - other.part).map(({ corner }) => corner);\n}\n\n/**\n * This function divides a polygon into triangles. Each ring has no point two times in sequence. The faces have indices of the points of the rings, as one list.\n *\n * The division ignores a corner on the straight line between its two neighbors. A face then has an edge with a corner on it,\n * and the face on the other side of that corner has a different edge. The function divides such a face at each corner on its edge,\n * so two faces with a common border have a common edge.\n */\nfunction facesOf(rings: readonly (readonly Vector2[])[]): number[][] {\n const [outer = [], ...holes] = rings;\n const faces = ShapeUtils.triangulateShape(\n [...outer],\n holes.map((hole) => [...hole]),\n );\n const points = rings.flat();\n const ringOf: number[] = [];\n const spotOf: number[] = [];\n rings.forEach((ring, index) => {\n for (let spot = 0; spot < ring.length; spot++) {\n ringOf.push(index);\n spotOf.push(spot);\n }\n });\n const owner = new Map<number, number>();\n const counts = new Map<number, number>();\n faces.forEach((face, index) => {\n for (let side = 0; side < face.length; side++) {\n const key = edgeKey(at(face, side), at(face, (side + 1) % face.length));\n owner.set(key, index);\n counts.set(key, (counts.get(key) ?? 0) + 1);\n }\n });\n let byLon: number[] | undefined;\n for (const [key, count] of counts) {\n if (count !== 1) continue;\n const u = Math.floor(key / KEY);\n const v = key % KEY;\n const ring = at(ringOf, u);\n const gap = Math.abs(at(spotOf, u) - at(spotOf, v));\n // An edge between two neighbors of a ring is an edge of the outline. It has only one face, and no corner on it.\n if (ring === at(ringOf, v) && (gap === 1 || gap === (rings[ring]?.length ?? 0) - 1)) continue;\n byLon ??= points.map((_, index) => index).sort((one, other) => (points[one]?.x ?? 0) - (points[other]?.x ?? 0));\n divideAt(faces, owner, u, v, cornersOn(points, byLon, u, v));\n }\n return faces;\n}\n\n/**\n * This function gives the place of each point of a ring in the same ring with more points on its edges.\n * It gives `undefined` for a ring whose points are not in the other ring, in the same sequence.\n */\nfunction placesIn(dense: readonly Vector2[], own: readonly Vector2[]): number[] | undefined {\n const places: number[] = [];\n let index = 0;\n for (const point of own) {\n while (index < dense.length && dense[index]?.equals(point) !== true) index++;\n if (index >= dense.length) return undefined;\n places.push(index);\n index += 1;\n }\n return places;\n}\n\n/**\n * This function divides each triangle that has a long edge, at the middle of each long edge. It gives the new triangles,\n * or `undefined` when no edge is long. Two triangles with one edge get the same middle, so the surface has no hole.\n */\nfunction dividePass(triangles: readonly number[], lon: number[], lat: number[], limit: number, middles: Map<number, number>): number[] | undefined {\n const next: number[] = [];\n let divided = false;\n const middle = (a: number, b: number): number => {\n const key = edgeKey(a, b);\n const found = middles.get(key);\n if (found !== undefined) return found;\n lon.push((at(lon, a) + at(lon, b)) / 2);\n lat.push((at(lat, a) + at(lat, b)) / 2);\n middles.set(key, lon.length - 1);\n return lon.length - 1;\n };\n for (let index = 0; index < triangles.length; index += 3) {\n const a = at(triangles, index);\n const b = at(triangles, index + 1);\n const c = at(triangles, index + 2);\n const ab = edgeSize(lon, lat, a, b) > limit;\n const bc = edgeSize(lon, lat, b, c) > limit;\n const ca = edgeSize(lon, lat, c, a) > limit;\n const count = Number(ab) + Number(bc) + Number(ca);\n if (count === 0) {\n next.push(a, b, c);\n continue;\n }\n divided = true;\n if (count === 3) {\n const mab = middle(a, b);\n const mbc = middle(b, c);\n const mca = middle(c, a);\n next.push(a, mab, mca, mab, b, mbc, mca, mbc, c, mab, mbc, mca);\n continue;\n }\n // The corners turn to `p`, `q` and `r`. With one long edge, it is from `p` to `q`. With two long edges, the short edge is from `r` to `p`.\n let p = a;\n let q = b;\n let r = c;\n if (count === 1 ? bc : !ab) {\n p = b;\n q = c;\n r = a;\n } else if (count === 1 ? ca : !bc) {\n p = c;\n q = a;\n r = b;\n }\n const mpq = middle(p, q);\n if (count === 1) {\n next.push(p, mpq, r, mpq, q, r);\n continue;\n }\n const mqr = middle(q, r);\n next.push(mpq, q, mqr);\n // The part with four corners gets the shorter of its two diagonals.\n if (edgeSize(lon, lat, p, mqr) <= edgeSize(lon, lat, mpq, r)) next.push(p, mpq, mqr, p, mqr, r);\n else next.push(p, mpq, r, mpq, mqr, r);\n }\n return divided ? next : undefined;\n}\n\n/**\n * This function divides the surface of a region into triangles that follow the curve of the Earth.\n *\n * `step` is the largest step of an edge of the outline in longitude or latitude, in degrees. The outline is the outline of `densify` with this step:\n * each edge of the outline of the surface is an edge of that outline. So a line through the points of `densify` is exactly on the outline of the surface.\n * An edge in the surface is not longer than 1.25 steps. A step of longitude is as long as it is on the Earth at that latitude, and a quarter of a step at least.\n *\n * A straight edge in the plane is a curve on the Earth. So a flat triangle on a globe is not exactly the triangle in the plane.\n * The difference is small for a small step. It is largest near a pole.\n *\n * The function throws a `GeoError` for a region or a step that is not correct, and a `RangeError` for a surface with too many corners.\n */\nexport function regionSurface(region: Region, step: number, maxCorners: number = MAX_SURFACE_CORNERS): RegionSurface {\n const dense = densify(region, step);\n const ownPolygons = region.type === \"Polygon\" ? [region.coordinates] : region.coordinates;\n const densePolygons = dense.type === \"Polygon\" ? [dense.coordinates] : dense.coordinates;\n const lon: number[] = [];\n const lat: number[] = [];\n let triangles: number[] = [];\n ownPolygons.forEach((polygon, polygonIndex) => {\n // The division into triangles gets the corners of the region only. The corners that `densify` adds are on straight lines, and the division ignores some of them.\n const own: Vector2[][] = [];\n const more: Vector2[][] = [];\n const spots: number[][] = [];\n for (let index = 0; index < polygon.length; index++) {\n const ring = openRing(polygon[index] ?? []);\n if (ring.length < 3) {\n // A polygon whose outer ring has no area has no surface. Its holes are in the outer ring, so they have no surface also.\n if (index === 0) return;\n continue;\n }\n const added = openRing(densePolygons[polygonIndex]?.[index] ?? []);\n const places = placesIn(added, ring);\n own.push(ring);\n more.push(places === undefined ? ring : added);\n spots.push(places ?? ring.map((_, spot) => spot));\n }\n const base = lon.length;\n /** The corner of the surface for each corner of the region, as an index from `base`. */\n const cornerOf: number[] = [];\n const starts: number[] = [];\n more.forEach((ring, index) => {\n const start = lon.length - base;\n starts.push(start);\n for (const spot of spots[index] ?? []) cornerOf.push(start + spot);\n for (const point of ring) {\n lon.push(point.x);\n lat.push(point.y);\n }\n });\n if (lon.length > maxCorners) throw tooManyCorners(maxCorners);\n const faces = facesOf(own).map((face) => face.map((corner) => at(cornerOf, corner)));\n // Each edge of the outline gets the corners that `densify` added to it.\n const owner = ownersOf(faces);\n more.forEach((ring, index) => {\n const places = spots[index] ?? [];\n const start = at(starts, index);\n places.forEach((place, spot) => {\n const next = at(places, (spot + 1) % places.length);\n const run: number[] = [];\n for (let between = (place + 1) % ring.length; between !== next; between = (between + 1) % ring.length) run.push(start + between);\n divideAt(faces, owner, start + place, start + next, run);\n });\n });\n // East is on the right of a person who looks at the Earth from outside with north up. So a counterclockwise triangle in the plane has its front outside.\n // The faces of one polygon have one direction. Their sum tells it, also for a face with almost no area.\n const turnOf = ([a = 0, b = 0, c = 0]: readonly number[]): number =>\n (at(lon, base + b) - at(lon, base + a)) * (at(lat, base + c) - at(lat, base + a)) - (at(lon, base + c) - at(lon, base + a)) * (at(lat, base + b) - at(lat, base + a));\n let turn = 0;\n for (const face of faces) turn += turnOf(face);\n for (const [a = 0, b = 0, c = 0] of faces) {\n if (turn >= 0) triangles.push(base + a, base + b, base + c);\n else triangles.push(base + a, base + c, base + b);\n }\n });\n const limit = step * LONG_EDGE;\n const middles = new Map<number, number>();\n for (let pass = 0; ; pass++) {\n const next = dividePass(triangles, lon, lat, limit, middles);\n if (next === undefined) break;\n triangles = next;\n if (lon.length > maxCorners) throw tooManyCorners(maxCorners);\n if (pass >= MAX_PASSES) throw new RangeError(`The surface of the region has edges longer than ${limit} degrees after ${MAX_PASSES} passes.`);\n }\n const corners = new Float64Array(lon.length * 2);\n for (let index = 0; index < lon.length; index++) {\n corners[index * 2] = at(lon, index);\n corners[index * 2 + 1] = at(lat, index);\n }\n return { corners, triangles: Uint32Array.from(triangles) };\n}\n\nfunction tooManyCorners(maxCorners: number): RangeError {\n return new RangeError(`The surface of the region has more than ${maxCorners} corners. Use a larger step.`);\n}\n\n/** A range of latitudes of an edge on the antimeridian. */\ninterface Cut {\n readonly low: number;\n readonly high: number;\n}\n\n/** This function gives 1 for a longitude of 180 degrees east, -1 for 180 degrees west, and 0 for each other longitude. */\nfunction sideOf(position: Position): number {\n if (Math.abs(position[0] - 180) <= ON_LINE) return 1;\n return Math.abs(position[0] + 180) <= ON_LINE ? -1 : 0;\n}\n\n/** This function gives 1 for the north pole, -1 for the south pole, and 0 for each other latitude. */\nfunction poleOf(position: Position): number {\n if (position[1] >= 90 - ON_LINE) return 1;\n return position[1] <= -90 + ON_LINE ? -1 : 0;\n}\n\n/**\n * This function gives the edges of a region as lines, for the outline that a person sees. Each line is a list of longitudes and latitudes, in degrees:\n * two numbers for each point.\n *\n * `step` is the largest step of a line in longitude or latitude, in degrees. The points are the points of `densify`, so they are corners of `regionSurface`.\n * An edge that is only a cut gets no line. A cut is an edge along a pole, or an edge on the antimeridian with an edge of the region on its other side.\n */\nexport function regionEdges(region: Region, step: number): Float64Array[] {\n const polygons = region.type === \"Polygon\" ? [region.coordinates] : region.coordinates;\n const east: Cut[] = [];\n const west: Cut[] = [];\n for (const polygon of polygons) {\n for (const ring of polygon) {\n for (let index = 0; index + 1 < ring.length; index++) {\n const from = ring[index];\n const to = ring[index + 1];\n if (from === undefined || to === undefined) continue;\n const side = sideOf(from);\n if (side === 0 || side !== sideOf(to)) continue;\n (side > 0 ? east : west).push({ low: Math.min(from[1], to[1]), high: Math.max(from[1], to[1]) });\n }\n }\n }\n const isCut = (from: Position, to: Position): boolean => {\n const pole = poleOf(from);\n if (pole !== 0 && pole === poleOf(to)) return true;\n const side = sideOf(from);\n if (side === 0 || side !== sideOf(to)) return false;\n const low = Math.min(from[1], to[1]);\n const high = Math.max(from[1], to[1]);\n return (side > 0 ? west : east).some((cut) => Math.min(cut.high, high) > Math.max(cut.low, low));\n };\n const lines: Float64Array[] = [];\n const add = (run: readonly Position[]): void => {\n if (run.length < 2) return;\n const dense = densify({ type: \"LineString\", coordinates: [...run] }, step).coordinates;\n const line = new Float64Array(dense.length * 2);\n dense.forEach((position, index) => {\n line[index * 2] = position[0];\n line[index * 2 + 1] = position[1];\n });\n lines.push(line);\n };\n for (const polygon of polygons) {\n for (const ring of polygon) {\n const count = ring.length - 1;\n if (count < 1) continue;\n const cut: boolean[] = [];\n for (let index = 0; index < count; index++) {\n const from = ring[index];\n const to = ring[index + 1];\n cut.push(from === undefined || to === undefined || isCut(from, to));\n }\n const first = cut.indexOf(true);\n if (first < 0) {\n add(ring);\n continue;\n }\n // The walk starts after a cut and goes one time around the ring. So it ends at that cut, and each run of edges is complete.\n let run: Position[] = [];\n for (let steps = 1; steps <= count; steps++) {\n const edge = (first + steps) % count;\n const from = ring[edge];\n const to = ring[edge + 1];\n if (cut[edge] === true || from === undefined || to === undefined) {\n add(run);\n run = [];\n continue;\n }\n if (run.length === 0) run.push(from);\n run.push(to);\n }\n }\n }\n return lines;\n}\n\n/**\n * This function gives the lines of a grid of meridians and parallels. Each line is a list of longitudes and latitudes, in degrees: two numbers for each point.\n *\n * `spacing` is the angle between two lines, in degrees, and `step` is the largest step of a line. A spacing of 0 or less gives no lines.\n * The meridians at each 90 degrees go to the poles. The other meridians stop one spacing before each pole, so the poles stay clear.\n */\nexport function gridLines(spacing: number, step: number): Float64Array[] {\n if (!(spacing > 0) || !(step > 0) || !Number.isFinite(spacing)) return [];\n const lines: Float64Array[] = [];\n const add = (fromLon: number, fromLat: number, toLon: number, toLat: number): void => {\n const parts = Math.max(Math.ceil(Math.max(Math.abs(toLon - fromLon), Math.abs(toLat - fromLat)) / step), 1);\n const line = new Float64Array((parts + 1) * 2);\n for (let part = 0; part <= parts; part++) {\n line[part * 2] = fromLon + ((toLon - fromLon) * part) / parts;\n line[part * 2 + 1] = fromLat + ((toLat - fromLat) * part) / parts;\n }\n lines.push(line);\n };\n const top = (Math.ceil(90 / spacing) - 1) * spacing;\n for (let index = 0; index * spacing < 360 - ON_LINE; index++) {\n const lon = -180 + index * spacing;\n const quarter = Math.abs(lon / 90 - Math.round(lon / 90)) <= ON_LINE;\n const end = quarter ? 90 : top;\n if (end > 0) add(lon, -end, lon, end);\n }\n for (let lat = -top; lat <= top + ON_LINE; lat += spacing) add(-180, lat, 180, lat);\n return lines;\n}\n","import { fromUnitVector, toUnitVector, type LatLon, type Region } from \"@mark1russell7/geo\";\nimport type { Point3 } from \"@mark1russell7/layout-contract\";\nimport { ballView, capView, FIT_MARGIN, type StageView } from \"../extent.ts\";\nimport type { ViewAngles } from \"../view.ts\";\n\n/**\n * The polar limits of the camera of a globe: the camera goes above each pole.\n * Give this value to the option `polar` of a stage. Set the option `pan` to false, so the camera turns around the center of the Earth.\n */\nexport const GLOBE_POLAR: { readonly min: number; readonly max: number } = { min: 0.01, max: Math.PI - 0.01 };\n\nconst RADIANS = Math.PI / 180;\n\n/**\n * This function gives the point of a globe for a place on the Earth. The center of the globe is the origin of the stage.\n *\n * The axis `y` of the stage goes to the north pole. The axis `z` goes to latitude 0 and longitude 0, and the axis `x` goes to latitude 0 and longitude 90 east.\n * `radius` is the distance of the point from the center. The default is 1.\n */\nexport function globePoint(place: LatLon, radius: number = 1): Point3 {\n const unit = toUnitVector(place);\n return { x: unit.y * radius, y: unit.z * radius, z: unit.x * radius };\n}\n\n/**\n * This function gives the place on the Earth in the direction of a point of the stage, as seen from the center of the globe.\n * The center of the globe has no direction, so it gives `undefined`.\n */\nexport function globePlace(point: Point3): LatLon | undefined {\n if (point.x === 0 && point.y === 0 && point.z === 0) return undefined;\n if (!Number.isFinite(point.x) || !Number.isFinite(point.y) || !Number.isFinite(point.z)) return undefined;\n return fromUnitVector({ x: point.z, y: point.x, z: point.y });\n}\n\n/** This function gives the direction of a camera that is above a place on the Earth. */\nexport function globeAngles(place: LatLon): ViewAngles {\n return { polar: Math.PI / 2 - place.lat * RADIANS, azimuth: place.lon * RADIANS };\n}\n\n/**\n * This function makes a view from above a place on the Earth. The picture shows the cap of the Earth around the place.\n *\n * `degrees` is the angle of the cap at the center of the Earth. It is the distance from the place to the edge of the cap, in degrees of a great circle.\n * The default is 90: the picture shows a half of the Earth. `margin` is the space around the cap, as a factor of the height above the surface.\n */\nexport function globeView(place: LatLon, degrees: number = 90, margin: number = FIT_MARGIN): StageView {\n return capView(globeAngles(place), Math.min(Math.max(degrees, 0), 90) * RADIANS, margin);\n}\n\n/**\n * This function makes a view that shows each region of a list. The camera is above the middle of the regions.\n * A list with no regions gives a view of a half of the Earth. `margin` is the space around the regions, as a factor of the height above the surface.\n */\nexport function regionView(regions: readonly Region[], margin: number = FIT_MARGIN): StageView {\n const points: Point3[] = [];\n for (const region of regions) {\n const polygons = region.type === \"Polygon\" ? [region.coordinates] : region.coordinates;\n for (const polygon of polygons) {\n // The first ring of a polygon is its outer edge. A hole is in it, so the holes add no extent.\n for (const position of polygon[0] ?? []) points.push(globePoint({ lat: position[1], lon: position[0] }));\n }\n }\n return ballView(points, margin);\n}\n\n/**\n * This function gives the first point of a ball that a ray finds. The center of the ball is the origin of the stage.\n *\n * `direction` has the length 1. A ray that does not find the ball gives `undefined`, and a ray that starts in the ball also gives `undefined`.\n */\nexport function rayBall(origin: Point3, direction: Point3, radius: number): Point3 | undefined {\n const along = origin.x * direction.x + origin.y * direction.y + origin.z * direction.z;\n const outside = origin.x * origin.x + origin.y * origin.y + origin.z * origin.z - radius * radius;\n if (!(outside > 0)) return undefined;\n const root = along * along - outside;\n if (!(root >= 0)) return undefined;\n const distance = -along - Math.sqrt(root);\n if (!(distance >= 0)) return undefined;\n return { x: origin.x + direction.x * distance, y: origin.y + direction.y * distance, z: origin.z + direction.z * distance };\n}\n\n/**\n * This function tells if a camera at `eye` sees a point of the surface of a ball. The center of the ball is the origin of the stage.\n * A point on the far side of the ball gives false.\n */\nexport function inSight(point: Point3, eye: Point3, radius: number): boolean {\n const length = Math.hypot(point.x, point.y, point.z);\n if (!(length > 0)) return false;\n return (point.x * eye.x + point.y * eye.y + point.z * eye.z) / length > radius;\n}\n","import { pointLocator, type LatLon, type PointLocator, type Region } from \"@mark1russell7/geo\";\nimport type { Point3 } from \"@mark1russell7/layout-contract\";\nimport {\n BufferAttribute,\n BufferGeometry,\n Color,\n FrontSide,\n InstancedInterleavedBuffer,\n InterleavedBufferAttribute,\n Mesh,\n MeshBasicMaterial,\n Points,\n ShaderMaterial,\n Sphere,\n SphereGeometry,\n Vector3,\n type Object3D,\n type Raycaster,\n} from \"three\";\nimport { LineMaterial } from \"three/addons/lines/LineMaterial.js\";\nimport { LineSegments2 } from \"three/addons/lines/LineSegments2.js\";\nimport { LineSegmentsGeometry } from \"three/addons/lines/LineSegmentsGeometry.js\";\nimport type { Highlight } from \"../highlight.ts\";\nimport type { StageContent, StageFrame, StagePick } from \"../stage/stage.ts\";\nimport type { StageTheme } from \"../theme.ts\";\nimport { gridLines, regionEdges, regionSurface, surfaceSag } from \"./mesh.ts\";\nimport { globePlace, globePoint, inSight, rayBall } from \"./space.ts\";\n\n/** The look of the areas and the points of one kind. Each color is a CSS hex color. */\nexport interface GlobeStyle {\n /** The color of the surface of an area, or of a point. An area with no color has no surface, and a point with no color is not in the picture. */\n readonly fill?: string | undefined;\n /** The part of the light that the surface of an area stops, from 0 to 1. The default is 1. */\n readonly opacity?: number | undefined;\n /** The color of the edge of an area, or of the ring around a point. An area with no color has no edge. */\n readonly line?: string | undefined;\n}\n\n/** The colors of a globe. Each color is a CSS hex color. */\nexport interface GlobeTheme extends StageTheme {\n /** The color of the Earth where it has no area, for example the sea. */\n readonly ball: string;\n /** The color of the meridians and the parallels. */\n readonly grid: string;\n /** The color of the shade at the rim of the Earth. */\n readonly shade: string;\n /** The style of each kind of area or point, by the name of the kind. */\n readonly styles: Readonly<Record<string, GlobeStyle>>;\n /** The style of a kind that `styles` does not have. */\n readonly other: GlobeStyle;\n /** The color of the edge of a record under the pointer, or in the highlighted list. */\n readonly hovered: string;\n /** The color of the edge of the selected record. */\n readonly selected: string;\n}\n\n/** An area of a globe: a region of the Earth that belongs to a record. */\nexport interface GlobeArea<P> {\n /** The name of the record. Two parts with one name are one record: the stage highlights them together. */\n readonly record: string;\n /** The region, with edges that are straight lines in longitude and latitude, as in `@mark1russell7/geo`. */\n readonly region: Region;\n /** The name of the style of the area in the theme. */\n readonly kind: string;\n /** The value that a pick of the area gives to the page. */\n readonly value: P;\n /** This value is false for an area that the pointer does not find. The default is true. */\n readonly pick?: boolean | undefined;\n}\n\n/** A point of a globe: a place on the Earth that belongs to a record. The picture shows it as a dot of a constant size. */\nexport interface GlobePoint<P> {\n /** The name of the record. Two parts with one name are one record: the stage highlights them together. */\n readonly record: string;\n readonly place: LatLon;\n /** The name of the style of the point in the theme. */\n readonly kind: string;\n /** The value that a pick of the point gives to the page. */\n readonly value: P;\n /** The width of the dot, in CSS pixels. The default is the option `pointSize` of the globe. */\n readonly size?: number | undefined;\n /** This value is false for a point that the pointer does not find. The default is true. */\n readonly pick?: boolean | undefined;\n}\n\n/** The options of a globe. Each width is in CSS pixels. */\nexport interface GlobeOptions<P> {\n /** The areas, in the sequence of the picture: a later area is above an earlier area, and the pointer finds it first. */\n readonly areas?: readonly GlobeArea<P>[] | undefined;\n /** The points. Each point is above each area. */\n readonly points?: readonly GlobePoint<P>[] | undefined;\n /** The radius of the globe, in the units of the stage. The default is 1. */\n readonly radius?: number | undefined;\n /** The largest step of an edge in longitude or latitude, in degrees. A smaller step follows the curve of the Earth better. The default is 1. */\n readonly step?: number | undefined;\n /** The angle between two lines of the grid, in degrees. The value 0 gives no grid. The default is 15. */\n readonly grid?: number | undefined;\n /** The smallest height of the camera above the surface, as a part of the radius. The default is 0.005. */\n readonly nearest?: number | undefined;\n /** The width of the edge of an area. The default is 1.25. */\n readonly lineWidth?: number | undefined;\n /** The width of the edge of a record with a highlight. The default is 2.5. */\n readonly highlightWidth?: number | undefined;\n /** The width of a line of the grid. The default is 1. */\n readonly gridWidth?: number | undefined;\n /** The width of the dot of a point. The default is 9. */\n readonly pointSize?: number | undefined;\n /** The strength of the shade at the rim of the Earth, from 0 to 1. The default is 0.4. */\n readonly shade?: number | undefined;\n}\n\n/** The content of a stage that shows the Earth as a globe, with areas and points on it. */\nexport interface GlobeContent<P> extends StageContent<P, GlobeTheme> {\n /**\n * This function shows only the areas and the points that a test accepts. A part that the picture does not show gets no pick.\n * Start `refresh` of the stage after it. A test that accepts each part shows all of them again.\n */\n show(test: (part: GlobeArea<P> | GlobePoint<P>) => boolean): void;\n /** This function gives the place on the Earth that a ray from the camera finds. A ray that does not find the Earth gives `undefined`. */\n placeAt(ray: Raycaster): LatLon | undefined;\n}\n\n/** The smallest height of the layer of the areas above the ball, as a part of the radius. */\nconst MIN_LIFT = 0.0005;\n\n/** The opacity that a highlight adds to the surface of an area. */\nconst HIGHLIGHT_OPACITY = 0.16;\n\n/** The factor of the width of a point with a highlight. */\nconst HIGHLIGHT_SIZE = 1.35;\n\n/** The width of the ring around a point, in CSS pixels. */\nconst RING_WIDTH = 1.5;\n\n/**\n * This function gives the radius of the mark of a point of a globe, in CSS pixels. The mark is the dot, and the ring around it.\n * `size` is the width of the dot. Give the result to the field `clear` of a label, so the text stays off the mark.\n */\nexport function pointRadius(size: number): number {\n return size / 2 + RING_WIDTH;\n}\n\n/** The distance around a point where the pointer finds it, in CSS pixels. */\nconst PICK_MARGIN = 4;\n\n/** The exponent of the shade at the rim. A large value keeps the shade near the rim. */\nconst SHADE_POWER = 2.6;\n\nconst BALL_SEGMENTS = 128;\n\nconst SHADE_VERTEX = `\nvarying vec3 vNormal;\nvarying vec3 vToEye;\nvoid main() {\n vec4 inView = modelViewMatrix * vec4(position, 1.0);\n vNormal = normalMatrix * normal;\n vToEye = -inView.xyz;\n gl_Position = projectionMatrix * inView;\n}`;\n\nconst SHADE_FRAGMENT = `\nuniform vec3 shade;\nuniform float strength;\nuniform float power;\nvarying vec3 vNormal;\nvarying vec3 vToEye;\nvoid main() {\n float facing = clamp(dot(normalize(vNormal), normalize(vToEye)), 0.0, 1.0);\n gl_FragColor = vec4(shade, strength * pow(1.0 - facing, power));\n #include <colorspace_fragment>\n}`;\n\nconst POINT_VERTEX = `\nuniform float pixelRatio;\nuniform float ringWidth;\nattribute vec3 fill;\nattribute vec3 ring;\nattribute float size;\nvarying vec3 vFill;\nvarying vec3 vRing;\nvarying float vFade;\nvarying float vInner;\nvoid main() {\n vec4 inWorld = modelMatrix * vec4(position, 1.0);\n vec3 up = normalize(inWorld.xyz - modelMatrix[3].xyz);\n float facing = dot(up, normalize(cameraPosition - inWorld.xyz));\n vFill = fill;\n vRing = ring;\n vFade = smoothstep(0.0, 0.1, facing);\n vInner = size / (size + 2.0 * ringWidth);\n gl_PointSize = (size + 2.0 * ringWidth) * pixelRatio;\n gl_Position = projectionMatrix * viewMatrix * inWorld;\n // A point on the far side of the Earth, and a point that the picture does not show, goes out of the picture.\n if (facing <= 0.0 || size <= 0.0) gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n}`;\n\nconst POINT_FRAGMENT = `\nvarying vec3 vFill;\nvarying vec3 vRing;\nvarying float vFade;\nvarying float vInner;\nvoid main() {\n float distance = length(gl_PointCoord * 2.0 - 1.0);\n float soft = fwidth(distance);\n float dot = 1.0 - smoothstep(1.0 - soft, 1.0, distance);\n float middle = 1.0 - smoothstep(vInner - soft, vInner, distance);\n gl_FragColor = vec4(mix(vRing, vFill, middle), dot * vFade);\n if (gl_FragColor.a <= 0.0) discard;\n #include <colorspace_fragment>\n}`;\n\n/** An area with the place of its data in the buffers of the globe. */\ninterface AreaPart<P> {\n readonly area: GlobeArea<P>;\n readonly locate: PointLocator | undefined;\n readonly firstCorner: number;\n readonly cornerCount: number;\n readonly firstIndex: number;\n readonly indexCount: number;\n readonly firstSegment: number;\n readonly segmentCount: number;\n shown: boolean;\n filled: boolean;\n lined: boolean;\n highlight: Highlight;\n}\n\n/** A point with its place on the globe. */\ninterface PointPart<P> {\n readonly point: GlobePoint<P>;\n readonly at: Point3;\n readonly size: number;\n shown: boolean;\n filled: boolean;\n highlight: Highlight;\n}\n\n/** This function gives the text of a thrown value. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** This function writes the points of lines into a list of segments on a ball: six numbers for each segment. It gives the count of the segments. */\nfunction addSegments(lines: readonly Float64Array[], radius: number, to: number[]): number {\n let count = 0;\n for (const line of lines) {\n let from: Point3 | undefined;\n for (let index = 0; index + 1 < line.length; index += 2) {\n const next = globePoint({ lat: line[index + 1] ?? 0, lon: line[index] ?? 0 }, radius);\n if (from !== undefined) {\n to.push(from.x, from.y, from.z, next.x, next.y, next.z);\n count += 1;\n }\n from = next;\n }\n }\n return count;\n}\n\n/** This function makes the geometry of thick line segments from a buffer of positions and a buffer of colors: six numbers for each segment. */\nfunction segmentGeometry(positions: InstancedInterleavedBuffer, colors: InstancedInterleavedBuffer | undefined, count: number, bounds: Sphere): LineSegmentsGeometry {\n const geometry = new LineSegmentsGeometry();\n geometry.setAttribute(\"instanceStart\", new InterleavedBufferAttribute(positions, 3, 0));\n geometry.setAttribute(\"instanceEnd\", new InterleavedBufferAttribute(positions, 3, 3));\n if (colors !== undefined) {\n geometry.setAttribute(\"instanceColorStart\", new InterleavedBufferAttribute(colors, 3, 0));\n geometry.setAttribute(\"instanceColorEnd\", new InterleavedBufferAttribute(colors, 3, 3));\n }\n geometry.instanceCount = count;\n geometry.boundingSphere = bounds;\n return geometry;\n}\n\n/**\n * This function makes the content of a stage that shows the Earth as a globe. The center of the globe is the origin of the stage.\n *\n * The materials use no light, so each color in the picture is the color of the theme. Use `GLOBE_POLAR` and no pan in the options of the stage.\n * The function throws an `Error` with the name of the record for an area that is not correct. Its cause is the error of `@mark1russell7/geo`.\n */\nexport function createGlobe<P>(options: GlobeOptions<P> = {}): GlobeContent<P> {\n const radius = options.radius ?? 1;\n const step = options.step ?? 1;\n const layer = radius * (1 + Math.max(MIN_LIFT, surfaceSag(step) * 2));\n const bounds = new Sphere(new Vector3(0, 0, 0), layer);\n const color = new Color();\n\n // The ball, and the shade at its rim.\n const ballGeometry = new SphereGeometry(radius, BALL_SEGMENTS, BALL_SEGMENTS / 2);\n const ballMaterial = new MeshBasicMaterial();\n const ball = new Mesh(ballGeometry, ballMaterial);\n const shadeColor = { value: new Color() };\n const shadeMaterial = new ShaderMaterial({\n uniforms: { shade: shadeColor, strength: { value: Math.min(Math.max(options.shade ?? 0.4, 0), 1) }, power: { value: SHADE_POWER } },\n vertexShader: SHADE_VERTEX,\n fragmentShader: SHADE_FRAGMENT,\n transparent: true,\n depthTest: false,\n depthWrite: false,\n side: FrontSide,\n });\n const shade = new Mesh(ballGeometry, shadeMaterial);\n shade.renderOrder = 4;\n\n // The grid.\n const gridList: number[] = [];\n const gridCount = addSegments(gridLines(options.grid ?? 15, step), layer, gridList);\n const gridMaterial = new LineMaterial({ linewidth: options.gridWidth ?? 1, transparent: true, depthWrite: false });\n const grid = new LineSegments2(segmentGeometry(new InstancedInterleavedBuffer(Float32Array.from(gridList), 6, 1), undefined, gridCount, bounds), gridMaterial);\n grid.renderOrder = 1;\n grid.visible = gridCount > 0;\n grid.frustumCulled = false;\n\n // The areas: one surface and one list of segments for all of them.\n const surfaces: { readonly corners: Float64Array; readonly triangles: Uint32Array }[] = [];\n const segmentList: number[] = [];\n const areaParts: AreaPart<P>[] = [];\n let cornerTotal = 0;\n let indexTotal = 0;\n let segmentTotal = 0;\n for (const area of options.areas ?? []) {\n try {\n const surface = regionSurface(area.region, step);\n const segmentCount = addSegments(regionEdges(area.region, step), layer, segmentList);\n areaParts.push({\n area,\n locate: area.pick === false ? undefined : pointLocator(area.region),\n firstCorner: cornerTotal,\n cornerCount: surface.corners.length / 2,\n firstIndex: indexTotal,\n indexCount: surface.triangles.length,\n firstSegment: segmentTotal,\n segmentCount,\n shown: true,\n filled: false,\n lined: false,\n highlight: 0,\n });\n surfaces.push(surface);\n cornerTotal += surface.corners.length / 2;\n indexTotal += surface.triangles.length;\n segmentTotal += segmentCount;\n } catch (error) {\n throw new Error(`The area of the record ${area.record} is not correct: ${messageOf(error)}`, { cause: error });\n }\n }\n const fillPositions = new Float32Array(cornerTotal * 3);\n const allIndices = new Uint32Array(indexTotal);\n surfaces.forEach((surface, index) => {\n const part = areaParts[index];\n if (part === undefined) return;\n for (let corner = 0; corner < part.cornerCount; corner++) {\n const point = globePoint({ lat: surface.corners[corner * 2 + 1] ?? 0, lon: surface.corners[corner * 2] ?? 0 }, layer);\n fillPositions.set([point.x, point.y, point.z], (part.firstCorner + corner) * 3);\n }\n for (let at = 0; at < part.indexCount; at++) allIndices[part.firstIndex + at] = (surface.triangles[at] ?? 0) + part.firstCorner;\n });\n const fillColors = new BufferAttribute(new Float32Array(cornerTotal * 4), 4);\n const fillIndices = new BufferAttribute(new Uint32Array(indexTotal), 1);\n const fillGeometry = new BufferGeometry();\n fillGeometry.setAttribute(\"position\", new BufferAttribute(fillPositions, 3));\n fillGeometry.setAttribute(\"color\", fillColors);\n fillGeometry.setIndex(fillIndices);\n fillGeometry.boundingSphere = bounds;\n const fillMaterial = new MeshBasicMaterial({ vertexColors: true, transparent: true, depthWrite: false, side: FrontSide });\n const fills = new Mesh(fillGeometry, fillMaterial);\n fills.renderOrder = 2;\n fills.frustumCulled = false;\n\n // The edges of the areas. The picture draws the segments at the start of the buffers, so the segments of the shown areas are there.\n const allSegments = Float32Array.from(segmentList);\n const allSegmentColors = new Float32Array(allSegments.length);\n const edgePositions = new InstancedInterleavedBuffer(new Float32Array(allSegments.length), 6, 1);\n const edgeColors = new InstancedInterleavedBuffer(new Float32Array(allSegments.length), 6, 1);\n const edgeGeometry = segmentGeometry(edgePositions, edgeColors, 0, bounds);\n const edgeMaterial = new LineMaterial({ linewidth: options.lineWidth ?? 1.25, vertexColors: true, transparent: true, depthWrite: false });\n const edges = new LineSegments2(edgeGeometry, edgeMaterial);\n edges.renderOrder = 3;\n edges.frustumCulled = false;\n\n // The edges of the records with a highlight, above the other edges.\n const highlightMaterial = new LineMaterial({ linewidth: options.highlightWidth ?? 2.5, vertexColors: true, transparent: true, depthWrite: false });\n const highlighted = new LineSegments2(new LineSegmentsGeometry(), highlightMaterial);\n highlighted.renderOrder = 5;\n highlighted.frustumCulled = false;\n highlighted.visible = false;\n\n // The points.\n const pointSize = options.pointSize ?? 9;\n const pointParts: PointPart<P>[] = (options.points ?? []).map((point) => ({\n point,\n at: globePoint(point.place, layer),\n size: point.size ?? pointSize,\n shown: true,\n filled: false,\n highlight: 0,\n }));\n const pointPositions = new Float32Array(pointParts.length * 3);\n pointParts.forEach((part, index) => pointPositions.set([part.at.x, part.at.y, part.at.z], index * 3));\n const pointFills = new BufferAttribute(new Float32Array(pointParts.length * 3), 3);\n const pointRings = new BufferAttribute(new Float32Array(pointParts.length * 3), 3);\n const pointSizes = new BufferAttribute(new Float32Array(pointParts.length), 1);\n const pointGeometry = new BufferGeometry();\n pointGeometry.setAttribute(\"position\", new BufferAttribute(pointPositions, 3));\n pointGeometry.setAttribute(\"fill\", pointFills);\n pointGeometry.setAttribute(\"ring\", pointRings);\n pointGeometry.setAttribute(\"size\", pointSizes);\n pointGeometry.boundingSphere = bounds;\n const pixelRatio = { value: 1 };\n const pointMaterial = new ShaderMaterial({\n uniforms: { pixelRatio, ringWidth: { value: RING_WIDTH } },\n vertexShader: POINT_VERTEX,\n fragmentShader: POINT_FRAGMENT,\n transparent: true,\n depthTest: false,\n depthWrite: false,\n });\n const dots = new Points(pointGeometry, pointMaterial);\n dots.renderOrder = 6;\n dots.frustumCulled = false;\n dots.visible = pointParts.length > 0;\n // The size of a dot is in CSS pixels, and the picture can have more than one pixel for each CSS pixel.\n dots.onBeforeRender = (renderer): void => {\n pixelRatio.value = renderer.getPixelRatio();\n };\n\n const records = new Set<string>([...areaParts.map((part) => part.area.record), ...pointParts.map((part) => part.point.record)]);\n let painted: GlobeTheme | undefined;\n /** The angle of one CSS pixel at the middle of the picture, in radians. */\n let pixelAngle = 0.001;\n\n const styleOf = (theme: GlobeTheme, kind: string): GlobeStyle => theme.styles[kind] ?? theme.other;\n const highlightColor = (theme: GlobeTheme, highlight: Highlight): string => (highlight === 2 ? theme.selected : theme.hovered);\n\n /** This function writes the colors of an area into the buffers. */\n const paintArea = (part: AreaPart<P>, theme: GlobeTheme): void => {\n const style = styleOf(theme, part.area.kind);\n part.filled = style.fill !== undefined;\n part.lined = style.line !== undefined;\n if (style.fill !== undefined) {\n color.set(style.fill);\n const opacity = Math.min(Math.max(style.opacity ?? 1, 0), 1);\n const alpha = part.highlight === 0 ? opacity : Math.min(opacity + HIGHLIGHT_OPACITY, 1);\n const values = [color.r, color.g, color.b, alpha];\n for (let corner = 0; corner < part.cornerCount; corner++) fillColors.array.set(values, (part.firstCorner + corner) * 4);\n fillColors.needsUpdate = true;\n }\n if (style.line !== undefined) {\n color.set(style.line);\n const values = [color.r, color.g, color.b, color.r, color.g, color.b];\n for (let segment = 0; segment < part.segmentCount; segment++) allSegmentColors.set(values, (part.firstSegment + segment) * 6);\n }\n };\n\n /** This function puts the data of the shown parts at the start of the buffers that the picture draws. */\n const sync = (theme: GlobeTheme): void => {\n let indexCount = 0;\n let segmentCount = 0;\n let highlightCount = 0;\n for (const part of areaParts) {\n if (!part.shown) continue;\n if (part.filled) {\n fillIndices.array.set(allIndices.subarray(part.firstIndex, part.firstIndex + part.indexCount), indexCount);\n indexCount += part.indexCount;\n }\n if (part.lined) {\n const from = part.firstSegment * 6;\n const to = from + part.segmentCount * 6;\n edgePositions.array.set(allSegments.subarray(from, to), segmentCount * 6);\n edgeColors.array.set(allSegmentColors.subarray(from, to), segmentCount * 6);\n segmentCount += part.segmentCount;\n }\n if (part.highlight !== 0) highlightCount += part.segmentCount;\n }\n fillIndices.needsUpdate = true;\n fillGeometry.setDrawRange(0, indexCount);\n fills.visible = indexCount > 0;\n edgePositions.needsUpdate = true;\n edgeColors.needsUpdate = true;\n edgeGeometry.instanceCount = segmentCount;\n edges.visible = segmentCount > 0;\n\n // The edges of the records with a highlight get a new geometry. They are few, and a record changes its highlight only on an act of a person.\n const highlightPositions = new Float32Array(highlightCount * 6);\n const highlightColors = new Float32Array(highlightCount * 6);\n let at = 0;\n for (const part of areaParts) {\n if (!part.shown || part.highlight === 0) continue;\n color.set(highlightColor(theme, part.highlight));\n const values = [color.r, color.g, color.b, color.r, color.g, color.b];\n highlightPositions.set(allSegments.subarray(part.firstSegment * 6, (part.firstSegment + part.segmentCount) * 6), at * 6);\n for (let segment = 0; segment < part.segmentCount; segment++) highlightColors.set(values, (at + segment) * 6);\n at += part.segmentCount;\n }\n highlighted.geometry.dispose();\n highlighted.geometry =\n highlightCount > 0 ? segmentGeometry(new InstancedInterleavedBuffer(highlightPositions, 6, 1), new InstancedInterleavedBuffer(highlightColors, 6, 1), highlightCount, bounds) : new LineSegmentsGeometry();\n highlighted.visible = highlightCount > 0;\n\n pointParts.forEach((part, index) => {\n const style = styleOf(theme, part.point.kind);\n part.filled = style.fill !== undefined;\n const visible = part.shown && style.fill !== undefined;\n pointSizes.array[index] = visible ? part.size * (part.highlight === 0 ? 1 : HIGHLIGHT_SIZE) : 0;\n if (style.fill === undefined) return;\n color.set(style.fill);\n pointFills.array.set([color.r, color.g, color.b], index * 3);\n color.set(part.highlight === 0 ? (style.line ?? style.fill) : highlightColor(theme, part.highlight));\n pointRings.array.set([color.r, color.g, color.b], index * 3);\n });\n pointSizes.needsUpdate = true;\n pointFills.needsUpdate = true;\n pointRings.needsUpdate = true;\n };\n\n return {\n objects: [ball, grid, fills, edges, shade, highlighted, dots] satisfies Object3D[],\n extent: { center: { x: 0, y: 0, z: 0 }, corners: [], surface: radius, minDistance: radius * (1 + Math.max(options.nearest ?? 0.005, 1e-6)) },\n has: (record) => records.has(record),\n pick(ray): StagePick<P> | undefined {\n const { origin, direction } = ray.ray;\n let found: PointPart<P> | undefined;\n let nearest = Infinity;\n for (const part of pointParts) {\n if (!part.shown || !part.filled || part.point.pick === false || !inSight(part.at, origin, radius)) continue;\n const x = part.at.x - origin.x;\n const y = part.at.y - origin.y;\n const z = part.at.z - origin.z;\n const cosine = (x * direction.x + y * direction.y + z * direction.z) / Math.hypot(x, y, z);\n const angle = Math.acos(Math.min(Math.max(cosine, -1), 1));\n if (angle > (part.size / 2 + PICK_MARGIN) * pixelAngle || angle >= nearest) continue;\n found = part;\n nearest = angle;\n }\n if (found !== undefined) return { record: found.point.record, value: found.point.value };\n const hit = rayBall(origin, direction, radius);\n const place = hit === undefined ? undefined : globePlace(hit);\n if (place === undefined) return undefined;\n for (let index = areaParts.length - 1; index >= 0; index--) {\n const part = areaParts[index];\n if (part === undefined || !part.shown || part.locate === undefined || !(part.filled || part.lined)) continue;\n if (part.locate(place) !== \"outside\") return { record: part.area.record, value: part.area.value };\n }\n return undefined;\n },\n paint(theme, highlight): void {\n const all = theme !== painted;\n painted = theme;\n if (all) {\n ballMaterial.color.set(theme.ball);\n gridMaterial.color.set(theme.grid);\n shadeColor.value.set(theme.shade);\n }\n for (const part of areaParts) {\n const next = highlight(part.area.record);\n if (!all && next === part.highlight) continue;\n part.highlight = next;\n paintArea(part, theme);\n }\n for (const part of pointParts) part.highlight = highlight(part.point.record);\n sync(theme);\n },\n step(frame: StageFrame): boolean {\n pixelAngle = (2 * Math.tan((frame.fieldOfView * Math.PI) / 360)) / Math.max(frame.height, 1);\n return false;\n },\n show(test): void {\n for (const part of areaParts) part.shown = test(part.area);\n for (const part of pointParts) part.shown = test(part.point);\n if (painted !== undefined) sync(painted);\n },\n placeAt(ray): LatLon | undefined {\n const hit = rayBall(ray.ray.origin, ray.ray.direction, radius);\n return hit === undefined ? undefined : globePlace(hit);\n },\n dispose(): void {\n ballGeometry.dispose();\n ballMaterial.dispose();\n shadeMaterial.dispose();\n grid.geometry.dispose();\n gridMaterial.dispose();\n fillGeometry.dispose();\n fillMaterial.dispose();\n edgeGeometry.dispose();\n edgeMaterial.dispose();\n highlighted.geometry.dispose();\n highlightMaterial.dispose();\n pointGeometry.dispose();\n pointMaterial.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;AAeA,MAAa,sBAAsB;;;;;AAMnC,MAAM,YAAY;;;;;;AAOlB,MAAM,YAAY;;AAGlB,MAAM,aAAa;;AAGnB,MAAM,MAAM,KAAK;;AAGjB,MAAM,UAAU;;AAGhB,MAAM,UAAU;AAEhB,MAAMA,YAAU,KAAK,KAAK;;AAG1B,SAAS,GAAG,MAAyB,OAAuB;CAC1D,OAAO,KAAK,UAAU;AACxB;AAEA,SAAS,QAAQ,GAAW,GAAmB;CAC7C,OAAO,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,MAAM;AACzC;;;;;AAMA,SAAgB,WAAW,MAAsB;CAG/C,OAAO,IAAI,KAAK,IAAK,OAAOA,YAAU,YAAY,KAAK,QAAS,KAAK,KAAK,CAAC,CAAC;AAC9E;;AAGA,SAAS,SAAS,MAAsC;CACtD,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,YAAY,MAAM;EAC3B,MAAM,OAAO,OAAO,OAAO,SAAS;EACpC,IAAI,SAAS,KAAA,KAAa,KAAK,MAAM,SAAS,MAAM,KAAK,MAAM,SAAS,IAAI,OAAO,KAAK,IAAI,QAAQ,SAAS,IAAI,SAAS,EAAE,CAAC;CAC/H;CACA,MAAM,QAAQ,OAAO;CACrB,OAAO,OAAO,SAAS,KAAK,UAAU,KAAA,KAAa,OAAO,OAAO,SAAS,EAAE,EAAE,OAAO,KAAK,MAAM,MAAM,OAAO,IAAI;CACjH,OAAO;AACT;;;;;AAMA,SAAS,SAAS,KAAwB,KAAwB,GAAW,GAAmB;CAC9F,MAAM,OAAO,GAAG,KAAK,CAAC;CACtB,MAAM,OAAO,GAAG,KAAK,CAAC;CACtB,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,KAAK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