@mark1russell7/visuals 0.2.3 → 0.2.4

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
@@ -59,6 +59,8 @@ const stage = createStage(document.body, {
59
59
 
60
60
  `createStage` gives `undefined` for a browser with no WebGL 2. It does not throw. Then show a different picture of the same data.
61
61
 
62
+ `stageSupported` of the entry `.` tells if the browser has WebGL 2. Use it before a dynamic `import()` of the module that makes the stage. Then a browser with no WebGL 2 does not load `three`.
63
+
62
64
  ## What a stage does
63
65
 
64
66
  - A drag turns the content. The wheel changes the distance after a click in the picture, so the page scrolls until then.
@@ -191,7 +193,7 @@ const stage = createStage(document.body, {
191
193
  The views of a globe:
192
194
 
193
195
  - `globeView(place, degrees)` shows the cap of the Earth around a place. The default shows a half of the Earth.
194
- - `regionView(regions)` shows each region of a list, from above their middle.
196
+ - `regionView(regions)` shows each region of a list, from above their middle. The regions fill the width or the height of the picture.
195
197
 
196
198
  The functions of the globe maths have no state. A test in Node.js uses them:
197
199
 
@@ -411,7 +413,7 @@ The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js u
411
413
  | `fitDistance`, `capDistance` | The distance at which the camera shows points, or a cap of a ball. |
412
414
  | `cameraPosition`, `viewOf` | The position of a camera from its place, and the place from its position. |
413
415
  | `placeBetween`, `moveAt`, `easeInOut` | A place on the way between two places, and the place at a time of a move. |
414
- | `ballView` | A view that shows points on a ball, from above their middle. |
416
+ | `ballView` | A view that shows points on a ball, from above their middle. The points fill the width or the height of the picture. |
415
417
  | `clampPlace`, `stageLimits` | A place in the limits of a stage, and the limits from the content. |
416
418
  | `reachOf`, `nearDepth` | The radius of the ball that holds the content, and the nearest depth that the camera draws. |
417
419
  | `keyAction` | The action of a key. |
@@ -419,6 +421,7 @@ The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js u
419
421
  | `screenPoint` | The point of a picture that shows a point of the world, in CSS pixels. |
420
422
  | `highlightOf`, `isClick` | The highlight of a record, and the difference between a click and a drag. |
421
423
  | `approach` | One step of a value to its goal, for a part that changes with time. |
424
+ | `stageSupported` | True when the browser can show a stage. It gives false in Node.js. |
422
425
 
423
426
  The space of a stage has the y axis up. A place has a target, a polar angle from the y axis, an azimuth around it and a distance.
424
427
 
@@ -204,22 +204,36 @@ function capView(angles, angle, margin = FIT_MARGIN) {
204
204
  /**
205
205
  * This function makes a view of points on the ball of the content. The camera is above the middle of the points, and the picture shows each point.
206
206
  *
207
- * The middle is the center of the box of the points. `margin` is the space around the points, as a factor of the height above the ball.
207
+ * The middle is the center of the box of the points. The camera is at the smallest distance that shows each point in the width and in the height of the picture.
208
+ * Thus wide points fill a wide picture. `margin` is the space around the points, as a factor of the height above the ball.
208
209
  * A list with no points gives a view of all of the ball from the front. Points with their middle at the center of the ball give the same view.
209
210
  */
210
211
  function ballView(points, margin = FIT_MARGIN) {
211
212
  let found;
212
213
  return (frame) => {
213
- const { center } = frame.extent;
214
+ const { extent } = frame;
215
+ const { center } = extent;
214
216
  if (found === void 0 || found.center.x !== center.x || found.center.y !== center.y || found.center.z !== center.z) found = {
215
217
  center,
216
- view: capOf(points, center, margin)
218
+ angles: middleOf(points, center)
219
+ };
220
+ const { angles } = found;
221
+ if (angles === void 0) return capView({
222
+ polar: Math.PI / 2,
223
+ azimuth: 0
224
+ }, Math.PI / 2, margin)(frame);
225
+ const surface = surfaceOf(extent);
226
+ const height = Math.max(fitDistance(points, center, angles, frame.fieldOfView, frame.aspect) - surface, 0);
227
+ return {
228
+ target: center,
229
+ polar: angles.polar,
230
+ azimuth: angles.azimuth,
231
+ distance: surface > 0 ? surface + height * margin : 1
217
232
  };
218
- return found.view(frame);
219
233
  };
220
234
  }
221
- /** This function makes the view of the cap of a ball around `center` that holds each point. */
222
- function capOf(points, center, margin) {
235
+ /** This function gives the direction from `center` to the middle of the box of the points. It gives `undefined` when the middle has no direction. */
236
+ function middleOf(points, center) {
223
237
  const low = {
224
238
  x: 1e400,
225
239
  y: 1e400,
@@ -244,29 +258,16 @@ function capOf(points, center, margin) {
244
258
  z: (low.z + high.z) / 2 - center.z
245
259
  };
246
260
  const length = Math.hypot(middle.x, middle.y, middle.z);
247
- if (!(length > 0) || !Number.isFinite(length)) return capView({
248
- polar: Math.PI / 2,
249
- azimuth: 0
250
- }, Math.PI / 2, margin);
251
- let angle = 0;
252
- for (const point of points) {
253
- const x = point.x - center.x;
254
- const y = point.y - center.y;
255
- const z = point.z - center.z;
256
- const distance = Math.hypot(x, y, z);
257
- if (!(distance > 0)) continue;
258
- const cosine = (x * middle.x + y * middle.y + z * middle.z) / (distance * length);
259
- angle = Math.max(angle, Math.acos(Math.min(Math.max(cosine, -1), 1)));
260
- }
261
+ if (!(length > 0) || !Number.isFinite(length)) return void 0;
261
262
  const { polar, azimuth } = viewOf(middle, {
262
263
  x: 0,
263
264
  y: 0,
264
265
  z: 0
265
266
  });
266
- return capView({
267
+ return {
267
268
  polar,
268
269
  azimuth
269
- }, angle, margin);
270
+ };
270
271
  }
271
272
  /** This function gives the radius of the ball around the center of an extent that holds the ball of the extent and each corner. */
272
273
  function reachOf(extent) {
@@ -311,4 +312,4 @@ function stageLimits(frame, views, polar) {
311
312
  }
312
313
  export { turnBetween as _, nearDepth as a, surfaceOf as c, capDistance as d, clampPlace as f, turnAcross as g, speedAt as h, fitView as i, FIELD_OF_VIEW as l, placeBetween as m, ballView as n, reachOf as o, fitDistance as p, capView as r, stageLimits as s, FIT_MARGIN as t, cameraPosition as u, viewAxes as v, viewOf as y };
313
314
 
314
- //# sourceMappingURL=extent-BtiN2C8B.js.map
315
+ //# sourceMappingURL=extent-DC0qrxC5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extent-BtiN2C8B.js","names":[],"sources":["../src/view.ts","../src/extent.ts"],"sourcesContent":["import type { Point3 } from \"@mark1russell7/layout-contract\";\n\n/**\n * The direction of a view: where the camera is, as seen from the point that it looks at.\n * The space of a stage has the y axis up.\n */\nexport interface ViewAngles {\n /** The angle from the up axis to the camera, in radians. At 0, the camera looks down from above. */\n readonly polar: number;\n /** The angle around the up axis, in radians. At 0, the camera is on the positive z side of the point. */\n readonly azimuth: number;\n}\n\n/** A place of a camera: the point that it looks at, the angles of its view and its distance from the point. */\nexport interface Place extends ViewAngles {\n readonly target: Point3;\n readonly distance: number;\n}\n\n/** The three axes of a camera, as unit vectors in the space of the stage. */\nexport interface ViewAxes {\n /** The vector from the point that the camera looks at to the camera. */\n readonly back: Point3;\n /** The vector to the right side of the picture. */\n readonly right: Point3;\n /** The vector to the top of the picture. */\n readonly up: Point3;\n}\n\n/** The limits of the place of a camera. */\nexport interface PlaceLimits {\n /** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */\n readonly minPolar: number;\n /** The largest polar angle. */\n readonly maxPolar: number;\n /** The smallest distance from the target. */\n readonly minDistance: number;\n /** The largest distance from the target. */\n readonly maxDistance: number;\n}\n\n/** This function gives the axes of the camera of a view. At a polar angle of 0, the top of the picture is the negative z axis. */\nexport function viewAxes(view: ViewAngles): ViewAxes {\n const sinPolar = Math.sin(view.polar);\n const cosPolar = Math.cos(view.polar);\n const sinAzimuth = Math.sin(view.azimuth);\n const cosAzimuth = Math.cos(view.azimuth);\n return {\n back: { x: sinPolar * sinAzimuth, y: cosPolar, z: sinPolar * cosAzimuth },\n right: { x: cosAzimuth, y: 0, z: 0 - sinAzimuth },\n up: { x: 0 - cosPolar * sinAzimuth, y: sinPolar, z: 0 - cosPolar * cosAzimuth },\n };\n}\n\n/** This function gives the dot product of the vector from `origin` to `point` with `axis`. */\nfunction along(point: Point3, origin: Point3, axis: Point3): number {\n return (point.x - origin.x) * axis.x + (point.y - origin.y) * axis.y + (point.z - origin.z) * axis.z;\n}\n\n/**\n * This function gives the smallest distance from `target` at which a camera shows each point.\n *\n * The camera looks at `target` along the direction of `view`. `fov` is the vertical angle of the picture in degrees,\n * and `aspect` is the width of the picture divided by its height.\n * The function gives 0 for no points, and for an angle or an aspect that makes no picture.\n */\nexport function fitDistance(points: readonly Point3[], target: Point3, view: ViewAngles, fov: number, aspect: number): number {\n const tanUp = Math.tan((fov * Math.PI) / 360);\n const tanRight = tanUp * aspect;\n if (!(tanUp > 0) || !(tanRight > 0) || !Number.isFinite(tanRight)) return 0;\n const axes = viewAxes(view);\n let distance = 0;\n for (const point of points) {\n const depth = along(point, target, axes.back);\n const needed = Math.max(Math.abs(along(point, target, axes.right)) / tanRight, Math.abs(along(point, target, axes.up)) / tanUp);\n distance = Math.max(distance, depth + needed);\n }\n return distance;\n}\n\n/**\n * This function gives the smallest distance from the center of a ball at which a camera shows a cap of the ball.\n *\n * The camera looks at the center of the ball, and the center of the cap is on the line to the camera.\n * `radius` is the radius of the ball. `angle` is the angle of the cap at the center of the ball, in radians, from 0 to π / 2.\n * `fov` is the vertical angle of the picture in degrees, and `aspect` is the width of the picture divided by its height.\n * The function gives 0 for an angle or an aspect that makes no picture.\n */\nexport function capDistance(radius: number, angle: number, fov: number, aspect: number): number {\n const tanUp = Math.tan((fov * Math.PI) / 360);\n const tan = Math.min(tanUp, tanUp * aspect);\n if (!(tan > 0) || !Number.isFinite(tan) || !(radius > 0)) return 0;\n const cap = Math.min(Math.max(angle, 0), Math.PI / 2);\n const half = Math.atan(tan);\n // A cap this large has its edge behind the outline of the ball. Then the outline of the ball is the limit.\n if (cap >= Math.PI / 2 - half) return radius / Math.sin(half);\n // The edge of the cap is at the height r sin(a) from the line, and at the depth r cos(a) from the center.\n return radius * Math.cos(cap) + (radius * Math.sin(cap)) / tan;\n}\n\n/** This function gives the position of a camera at a distance from `target`, in the direction of `view`. */\nexport function cameraPosition(target: Point3, view: ViewAngles, distance: number): Point3 {\n const { back } = viewAxes(view);\n return { x: target.x + back.x * distance, y: target.y + back.y * distance, z: target.z + back.z * distance };\n}\n\n/** This function gives the angles of the view from `target` to a camera, and the distance between them. A camera at the target gives the angles 0. */\nexport function viewOf(camera: Point3, target: Point3): ViewAngles & { readonly distance: number } {\n const x = camera.x - target.x;\n const y = camera.y - target.y;\n const z = camera.z - target.z;\n const distance = Math.hypot(x, y, z);\n if (!(distance > 0)) return { polar: 0, azimuth: 0, distance: 0 };\n return { polar: Math.acos(Math.min(Math.max(y / distance, -1), 1)), azimuth: Math.atan2(x, z), distance };\n}\n\n/** This function gives the angle between two azimuths along the shortest way, from −π to π. */\nexport function turnBetween(from: number, to: number): number {\n const full = 2 * Math.PI;\n const turn = (((to - from) % full) + full) % full;\n return turn > Math.PI ? turn - full : turn;\n}\n\n/** This function gives a place in its limits. The target and the azimuth stay as they are. */\nexport function clampPlace(place: Place, limits: PlaceLimits): Place {\n return {\n target: place.target,\n azimuth: place.azimuth,\n polar: Math.min(Math.max(place.polar, limits.minPolar), limits.maxPolar),\n distance: Math.min(Math.max(place.distance, limits.minDistance), limits.maxDistance),\n };\n}\n\n/**\n * This function gives the height of a camera above the surface of a stage, as a part of its distance from the target.\n *\n * `surface` is the radius of the ball around the target that the camera stays out of. A stage with no ball has the value 0.\n * The result is the factor of the zoom speed of a camera: near the surface, a camera moves slowly.\n * The result is 0.02 at least, so a camera on the surface can move away.\n */\nexport function speedAt(distance: number, surface: number): number {\n if (!(distance > 0)) return 1;\n return Math.min(Math.max((distance - surface) / distance, 0.02), 1);\n}\n\n/** The default vertical angle of the picture of a stage, in degrees. */\nexport const FIELD_OF_VIEW = 32;\n\n/** The smallest result of `turnAcross`, in radians. A camera on a ball, or in it, can thus turn. */\nconst SMALLEST_TURN = 1e-6;\n\n/**\n * This function gives the turn of a camera around a ball that moves the surface by the height of the picture, in radians.\n *\n * `surface` is the radius of the ball around the target. `fieldOfView` is the vertical angle of the picture, in degrees.\n *\n * The result is exact for the surface at the middle of the picture. Thus that surface follows the pointer in a drag.\n * The ball is round, so a long drag moves that surface by a smaller distance than the pointer.\n * Thus the surface does not go before the pointer.\n *\n * The result is `Infinity` for a stage with no ball, because such a stage has no surface that follows the pointer.\n * A turn about the up axis moves a point between the equator and a pole of the ball by a smaller distance.\n */\nexport function turnAcross(distance: number, surface: number, fieldOfView: number): number {\n const half = (fieldOfView * Math.PI) / 360;\n if (!(surface > 0) || !(distance > 0) || !(half > 0 && half < Math.PI / 2)) return Number.POSITIVE_INFINITY;\n // The surface at the middle of the picture is at the distance `distance - surface` from the camera.\n // There, the height of the picture shows this length of the surface. The turn is that length as an angle of the ball.\n const shown = 2 * (distance - surface) * Math.tan(half);\n return Math.max(shown / surface, SMALLEST_TURN);\n}\n\n/**\n * This function gives the place at a part of the way between two places. `part` goes from 0 to 1.\n *\n * The azimuth goes along the shortest way. The height above the surface changes by an equal factor for each equal step,\n * so a zoom has one speed in the picture. `surface` is the radius of the ball around the target, or 0 for no ball.\n */\nexport function placeBetween(from: Place, to: Place, part: number, surface: number = 0): Place {\n const between = (a: number, b: number): number => a + (b - a) * part;\n const low = from.distance - surface;\n const high = to.distance - surface;\n const height = low > 0 && high > 0 ? low * (high / low) ** part : between(low, high);\n return {\n target: { x: between(from.target.x, to.target.x), y: between(from.target.y, to.target.y), z: between(from.target.z, to.target.z) },\n polar: between(from.polar, to.polar),\n azimuth: from.azimuth + turnBetween(from.azimuth, to.azimuth) * part,\n distance: surface + height,\n };\n}\n","import type { Point3 } from \"@mark1russell7/layout-contract\";\nimport { capDistance, fitDistance, viewOf, type Place, type PlaceLimits, type ViewAngles } from \"./view.ts\";\n\n/** The space that the content of a stage fills. A view and the limits of the camera come from it. */\nexport interface StageExtent {\n /** The points that a view of all the content shows, for example each corner of each solid. */\n readonly corners: readonly Point3[];\n /** The point that the camera looks at. */\n readonly center: Point3;\n /**\n * The radius of the ball around the center that the camera stays out of, for example the radius of a globe.\n * The default is 0: the content has no ball.\n */\n readonly surface?: number | undefined;\n /** The smallest distance of the camera from the center. The default comes from the views of the stage. */\n readonly minDistance?: number | undefined;\n /** The largest distance of the camera from the center. The default comes from the views of the stage. */\n readonly maxDistance?: number | undefined;\n}\n\n/** The picture that a view is for: the content, and the angle and the shape of the picture. */\nexport interface ViewFrame {\n readonly extent: StageExtent;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n /** The width of the picture divided by its height. */\n readonly aspect: number;\n}\n\n/** A view of a stage: a function that gives the place of the camera for a picture. A new size of the picture gives a new place. */\nexport type StageView = (frame: ViewFrame) => Place;\n\n/** The limits of the camera of a stage: the limits of its place, and the nearest and the farthest depth that it draws. */\nexport interface StageLimits extends PlaceLimits {\n readonly near: number;\n readonly far: number;\n}\n\n/** The space around the content in a view that shows all of it, as a factor of the distance. */\nexport const FIT_MARGIN = 1.06;\n\n/** This function gives the radius of the ball around the center of an extent, or 0 for no ball. */\nexport function surfaceOf(extent: StageExtent): number {\n const surface = extent.surface ?? 0;\n return surface > 0 ? surface : 0;\n}\n\n/**\n * This function makes a view that shows each corner of the content from one direction.\n * `margin` is the space around the content, as a factor of the distance. An extent with no corners gives the distance 1.\n */\nexport function fitView(angles: ViewAngles, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const distance = fitDistance(extent.corners, extent.center, angles, fieldOfView, aspect) * margin;\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: distance > 0 ? distance : 1 };\n };\n}\n\n/**\n * This function makes a view of a part of the ball of the content: a cap around the point of the ball below the camera.\n *\n * `angles` is the direction from the center of the ball to the camera. `angle` is the angle of the cap at the center of the ball, in radians.\n * `margin` is the space around the cap, as a factor of the height above the ball. An extent with no ball gives the distance 1.\n */\nexport function capView(angles: ViewAngles, angle: number, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const surface = surfaceOf(extent);\n const height = Math.max(capDistance(surface, angle, fieldOfView, aspect) - surface, 0);\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: surface > 0 ? surface + height * margin : 1 };\n };\n}\n\n/**\n * This function makes a view of points on the ball of the content. The camera is above the middle of the points, and the picture shows each point.\n *\n * The middle is the center of the box of the points. `margin` is the space around the points, as a factor of the height above the ball.\n * A list with no points gives a view of all of the ball from the front. Points with their middle at the center of the ball give the same view.\n */\nexport function ballView(points: readonly Point3[], margin: number = FIT_MARGIN): StageView {\n let found: { readonly center: Point3; readonly view: StageView } | undefined;\n return (frame) => {\n const { center } = frame.extent;\n // The middle and the cap are the same for each picture of one content. So the function calculates them one time for each center.\n if (found === undefined || found.center.x !== center.x || found.center.y !== center.y || found.center.z !== center.z) {\n found = { center, view: capOf(points, center, margin) };\n }\n return found.view(frame);\n };\n}\n\n/** This function makes the view of the cap of a ball around `center` that holds each point. */\nfunction capOf(points: readonly Point3[], center: Point3, margin: number): StageView {\n const low = { x: Infinity, y: Infinity, z: Infinity };\n const high = { x: -Infinity, y: -Infinity, z: -Infinity };\n for (const point of points) {\n low.x = Math.min(low.x, point.x);\n low.y = Math.min(low.y, point.y);\n low.z = Math.min(low.z, point.z);\n high.x = Math.max(high.x, point.x);\n high.y = Math.max(high.y, point.y);\n high.z = Math.max(high.z, point.z);\n }\n const middle = { x: (low.x + high.x) / 2 - center.x, y: (low.y + high.y) / 2 - center.y, z: (low.z + high.z) / 2 - center.z };\n const length = Math.hypot(middle.x, middle.y, middle.z);\n if (!(length > 0) || !Number.isFinite(length)) return capView({ polar: Math.PI / 2, azimuth: 0 }, Math.PI / 2, margin);\n let angle = 0;\n for (const point of points) {\n const x = point.x - center.x;\n const y = point.y - center.y;\n const z = point.z - center.z;\n const distance = Math.hypot(x, y, z);\n if (!(distance > 0)) continue;\n const cosine = (x * middle.x + y * middle.y + z * middle.z) / (distance * length);\n angle = Math.max(angle, Math.acos(Math.min(Math.max(cosine, -1), 1)));\n }\n const { polar, azimuth } = viewOf(middle, { x: 0, y: 0, z: 0 });\n return capView({ polar, azimuth }, angle, margin);\n}\n\n/** This function gives the radius of the ball around the center of an extent that holds the ball of the extent and each corner. */\nexport function reachOf(extent: StageExtent): number {\n let reach = surfaceOf(extent);\n for (const corner of extent.corners) reach = Math.max(reach, Math.hypot(corner.x - extent.center.x, corner.y - extent.center.y, corner.z - extent.center.z));\n return reach;\n}\n\n/**\n * This function gives the nearest depth that a camera draws, from the distance of the camera to the center of the content.\n *\n * A camera far from the content gets a large value. The depths of the content then have more steps, so two surfaces that are near stay apart.\n * The result is not less than the nearest depth of the limits, and it is in front of all the content.\n */\nexport function nearDepth(limits: StageLimits, extent: StageExtent, distance: number): number {\n const free = (distance - reachOf(extent)) / 8;\n return free > limits.near ? Math.min(free, limits.far / 4) : limits.near;\n}\n\n/**\n * This function gives the limits of the camera of a stage for a picture.\n *\n * The largest distance of the views is the base. The camera goes out to 3 times this distance, and in to 3 % of the height of that view.\n * The extent can give each distance. The nearest depth is small against the height of the nearest camera, and the farthest depth is behind all the content.\n */\nexport function stageLimits(frame: ViewFrame, views: readonly StageView[], polar: { readonly min: number; readonly max: number }): StageLimits {\n const { extent } = frame;\n const surface = surfaceOf(extent);\n let widest = 0;\n for (const view of views) widest = Math.max(widest, view(frame).distance);\n if (!(widest > surface)) widest = surface + 1;\n const reach = reachOf(extent);\n const minDistance = extent.minDistance ?? surface + (widest - surface) * 0.03;\n const maxDistance = Math.max(extent.maxDistance ?? surface + (widest - surface) * 3, minDistance);\n const height = Math.max(minDistance - surface, 1e-6);\n return { minPolar: polar.min, maxPolar: polar.max, minDistance, maxDistance, near: height / 8, far: (maxDistance + reach) * 1.5 };\n}\n"],"mappings":";;AA0CA,SAAgB,SAAS,MAA4B;CACnD,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK;CACpC,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK;CACpC,MAAM,aAAa,KAAK,IAAI,KAAK,OAAO;CACxC,MAAM,aAAa,KAAK,IAAI,KAAK,OAAO;CACxC,OAAO;EACL,MAAM;GAAE,GAAG,WAAW;GAAY,GAAG;GAAU,GAAG,WAAW;EAAW;EACxE,OAAO;GAAE,GAAG;GAAY,GAAG;GAAG,GAAG,IAAI;EAAW;EAChD,IAAI;GAAE,GAAG,IAAI,WAAW;GAAY,GAAG;GAAU,GAAG,IAAI,WAAW;EAAW;CAChF;AACF;;AAGA,SAAS,MAAM,OAAe,QAA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AO;AACT;;;;;;;AAQA,SAAgB,UAAU,QAAqB,QAAqB,UAA0B;CAC5F,MAAM,QAAQ,WAAW,QAAQ,MAAM,KAAK;CAC5C,OAAO,OAAO,OAAO,OAAO,KAAK,IAAI,MAAM,OAAO,MAAM,CAAC,IAAI,OAAO;AACtE;;;;;;;AAQA,SAAgB,YAAY,OAAkB,OAA6B,OAAoE;CAC7I,MAAM,EAAE,WAAW;CACnB,MAAM,UAAU,UAAU,MAAM;CAChC,IAAI,SAAS;CACb,KAAK,MAAM,QAAQ,OAAO,SAAS,KAAK,IAAI,QAAQ,KAAK,KAAK,CAAC,CAAC,QAAQ;CACxE,IAAI,EAAE,SAAS,UAAU,SAAS,UAAU;CAC5C,MAAM,QAAQ,QAAQ,MAAM;CAC5B,MAAM,cAAc,OAAO,eAAe,WAAW,SAAS,WAAW;CACzE,MAAM,cAAc,KAAK,IAAI,OAAO,eAAe,WAAW,SAAS,WAAW,GAAG,WAAW;CAChG,MAAM,SAAS,KAAK,IAAI,cAAc,SAAS,IAAI;CACnD,OAAO;EAAE,UAAU,MAAM;EAAK,UAAU,MAAM;EAAK;EAAa;EAAa,MAAM,SAAS;EAAG,MAAM,cAAc,SAAS;CAAI;AAClI"}
1
+ {"version":3,"file":"extent-DC0qrxC5.js","names":[],"sources":["../src/view.ts","../src/extent.ts"],"sourcesContent":["import type { Point3 } from \"@mark1russell7/layout-contract\";\n\n/**\n * The direction of a view: where the camera is, as seen from the point that it looks at.\n * The space of a stage has the y axis up.\n */\nexport interface ViewAngles {\n /** The angle from the up axis to the camera, in radians. At 0, the camera looks down from above. */\n readonly polar: number;\n /** The angle around the up axis, in radians. At 0, the camera is on the positive z side of the point. */\n readonly azimuth: number;\n}\n\n/** A place of a camera: the point that it looks at, the angles of its view and its distance from the point. */\nexport interface Place extends ViewAngles {\n readonly target: Point3;\n readonly distance: number;\n}\n\n/** The three axes of a camera, as unit vectors in the space of the stage. */\nexport interface ViewAxes {\n /** The vector from the point that the camera looks at to the camera. */\n readonly back: Point3;\n /** The vector to the right side of the picture. */\n readonly right: Point3;\n /** The vector to the top of the picture. */\n readonly up: Point3;\n}\n\n/** The limits of the place of a camera. */\nexport interface PlaceLimits {\n /** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */\n readonly minPolar: number;\n /** The largest polar angle. */\n readonly maxPolar: number;\n /** The smallest distance from the target. */\n readonly minDistance: number;\n /** The largest distance from the target. */\n readonly maxDistance: number;\n}\n\n/** This function gives the axes of the camera of a view. At a polar angle of 0, the top of the picture is the negative z axis. */\nexport function viewAxes(view: ViewAngles): ViewAxes {\n const sinPolar = Math.sin(view.polar);\n const cosPolar = Math.cos(view.polar);\n const sinAzimuth = Math.sin(view.azimuth);\n const cosAzimuth = Math.cos(view.azimuth);\n return {\n back: { x: sinPolar * sinAzimuth, y: cosPolar, z: sinPolar * cosAzimuth },\n right: { x: cosAzimuth, y: 0, z: 0 - sinAzimuth },\n up: { x: 0 - cosPolar * sinAzimuth, y: sinPolar, z: 0 - cosPolar * cosAzimuth },\n };\n}\n\n/** This function gives the dot product of the vector from `origin` to `point` with `axis`. */\nfunction along(point: Point3, origin: Point3, axis: Point3): number {\n return (point.x - origin.x) * axis.x + (point.y - origin.y) * axis.y + (point.z - origin.z) * axis.z;\n}\n\n/**\n * This function gives the smallest distance from `target` at which a camera shows each point.\n *\n * The camera looks at `target` along the direction of `view`. `fov` is the vertical angle of the picture in degrees,\n * and `aspect` is the width of the picture divided by its height.\n * The function gives 0 for no points, and for an angle or an aspect that makes no picture.\n */\nexport function fitDistance(points: readonly Point3[], target: Point3, view: ViewAngles, fov: number, aspect: number): number {\n const tanUp = Math.tan((fov * Math.PI) / 360);\n const tanRight = tanUp * aspect;\n if (!(tanUp > 0) || !(tanRight > 0) || !Number.isFinite(tanRight)) return 0;\n const axes = viewAxes(view);\n let distance = 0;\n for (const point of points) {\n const depth = along(point, target, axes.back);\n const needed = Math.max(Math.abs(along(point, target, axes.right)) / tanRight, Math.abs(along(point, target, axes.up)) / tanUp);\n distance = Math.max(distance, depth + needed);\n }\n return distance;\n}\n\n/**\n * This function gives the smallest distance from the center of a ball at which a camera shows a cap of the ball.\n *\n * The camera looks at the center of the ball, and the center of the cap is on the line to the camera.\n * `radius` is the radius of the ball. `angle` is the angle of the cap at the center of the ball, in radians, from 0 to π / 2.\n * `fov` is the vertical angle of the picture in degrees, and `aspect` is the width of the picture divided by its height.\n * The function gives 0 for an angle or an aspect that makes no picture.\n */\nexport function capDistance(radius: number, angle: number, fov: number, aspect: number): number {\n const tanUp = Math.tan((fov * Math.PI) / 360);\n const tan = Math.min(tanUp, tanUp * aspect);\n if (!(tan > 0) || !Number.isFinite(tan) || !(radius > 0)) return 0;\n const cap = Math.min(Math.max(angle, 0), Math.PI / 2);\n const half = Math.atan(tan);\n // A cap this large has its edge behind the outline of the ball. Then the outline of the ball is the limit.\n if (cap >= Math.PI / 2 - half) return radius / Math.sin(half);\n // The edge of the cap is at the height r sin(a) from the line, and at the depth r cos(a) from the center.\n return radius * Math.cos(cap) + (radius * Math.sin(cap)) / tan;\n}\n\n/** This function gives the position of a camera at a distance from `target`, in the direction of `view`. */\nexport function cameraPosition(target: Point3, view: ViewAngles, distance: number): Point3 {\n const { back } = viewAxes(view);\n return { x: target.x + back.x * distance, y: target.y + back.y * distance, z: target.z + back.z * distance };\n}\n\n/** This function gives the angles of the view from `target` to a camera, and the distance between them. A camera at the target gives the angles 0. */\nexport function viewOf(camera: Point3, target: Point3): ViewAngles & { readonly distance: number } {\n const x = camera.x - target.x;\n const y = camera.y - target.y;\n const z = camera.z - target.z;\n const distance = Math.hypot(x, y, z);\n if (!(distance > 0)) return { polar: 0, azimuth: 0, distance: 0 };\n return { polar: Math.acos(Math.min(Math.max(y / distance, -1), 1)), azimuth: Math.atan2(x, z), distance };\n}\n\n/** This function gives the angle between two azimuths along the shortest way, from −π to π. */\nexport function turnBetween(from: number, to: number): number {\n const full = 2 * Math.PI;\n const turn = (((to - from) % full) + full) % full;\n return turn > Math.PI ? turn - full : turn;\n}\n\n/** This function gives a place in its limits. The target and the azimuth stay as they are. */\nexport function clampPlace(place: Place, limits: PlaceLimits): Place {\n return {\n target: place.target,\n azimuth: place.azimuth,\n polar: Math.min(Math.max(place.polar, limits.minPolar), limits.maxPolar),\n distance: Math.min(Math.max(place.distance, limits.minDistance), limits.maxDistance),\n };\n}\n\n/**\n * This function gives the height of a camera above the surface of a stage, as a part of its distance from the target.\n *\n * `surface` is the radius of the ball around the target that the camera stays out of. A stage with no ball has the value 0.\n * The result is the factor of the zoom speed of a camera: near the surface, a camera moves slowly.\n * The result is 0.02 at least, so a camera on the surface can move away.\n */\nexport function speedAt(distance: number, surface: number): number {\n if (!(distance > 0)) return 1;\n return Math.min(Math.max((distance - surface) / distance, 0.02), 1);\n}\n\n/** The default vertical angle of the picture of a stage, in degrees. */\nexport const FIELD_OF_VIEW = 32;\n\n/** The smallest result of `turnAcross`, in radians. A camera on a ball, or in it, can thus turn. */\nconst SMALLEST_TURN = 1e-6;\n\n/**\n * This function gives the turn of a camera around a ball that moves the surface by the height of the picture, in radians.\n *\n * `surface` is the radius of the ball around the target. `fieldOfView` is the vertical angle of the picture, in degrees.\n *\n * The result is exact for the surface at the middle of the picture. Thus that surface follows the pointer in a drag.\n * The ball is round, so a long drag moves that surface by a smaller distance than the pointer.\n * Thus the surface does not go before the pointer.\n *\n * The result is `Infinity` for a stage with no ball, because such a stage has no surface that follows the pointer.\n * A turn about the up axis moves a point between the equator and a pole of the ball by a smaller distance.\n */\nexport function turnAcross(distance: number, surface: number, fieldOfView: number): number {\n const half = (fieldOfView * Math.PI) / 360;\n if (!(surface > 0) || !(distance > 0) || !(half > 0 && half < Math.PI / 2)) return Number.POSITIVE_INFINITY;\n // The surface at the middle of the picture is at the distance `distance - surface` from the camera.\n // There, the height of the picture shows this length of the surface. The turn is that length as an angle of the ball.\n const shown = 2 * (distance - surface) * Math.tan(half);\n return Math.max(shown / surface, SMALLEST_TURN);\n}\n\n/**\n * This function gives the place at a part of the way between two places. `part` goes from 0 to 1.\n *\n * The azimuth goes along the shortest way. The height above the surface changes by an equal factor for each equal step,\n * so a zoom has one speed in the picture. `surface` is the radius of the ball around the target, or 0 for no ball.\n */\nexport function placeBetween(from: Place, to: Place, part: number, surface: number = 0): Place {\n const between = (a: number, b: number): number => a + (b - a) * part;\n const low = from.distance - surface;\n const high = to.distance - surface;\n const height = low > 0 && high > 0 ? low * (high / low) ** part : between(low, high);\n return {\n target: { x: between(from.target.x, to.target.x), y: between(from.target.y, to.target.y), z: between(from.target.z, to.target.z) },\n polar: between(from.polar, to.polar),\n azimuth: from.azimuth + turnBetween(from.azimuth, to.azimuth) * part,\n distance: surface + height,\n };\n}\n","import type { Point3 } from \"@mark1russell7/layout-contract\";\nimport { capDistance, fitDistance, viewOf, type Place, type PlaceLimits, type ViewAngles } from \"./view.ts\";\n\n/** The space that the content of a stage fills. A view and the limits of the camera come from it. */\nexport interface StageExtent {\n /** The points that a view of all the content shows, for example each corner of each solid. */\n readonly corners: readonly Point3[];\n /** The point that the camera looks at. */\n readonly center: Point3;\n /**\n * The radius of the ball around the center that the camera stays out of, for example the radius of a globe.\n * The default is 0: the content has no ball.\n */\n readonly surface?: number | undefined;\n /** The smallest distance of the camera from the center. The default comes from the views of the stage. */\n readonly minDistance?: number | undefined;\n /** The largest distance of the camera from the center. The default comes from the views of the stage. */\n readonly maxDistance?: number | undefined;\n}\n\n/** The picture that a view is for: the content, and the angle and the shape of the picture. */\nexport interface ViewFrame {\n readonly extent: StageExtent;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n /** The width of the picture divided by its height. */\n readonly aspect: number;\n}\n\n/** A view of a stage: a function that gives the place of the camera for a picture. A new size of the picture gives a new place. */\nexport type StageView = (frame: ViewFrame) => Place;\n\n/** The limits of the camera of a stage: the limits of its place, and the nearest and the farthest depth that it draws. */\nexport interface StageLimits extends PlaceLimits {\n readonly near: number;\n readonly far: number;\n}\n\n/** The space around the content in a view that shows all of it, as a factor of the distance. */\nexport const FIT_MARGIN = 1.06;\n\n/** This function gives the radius of the ball around the center of an extent, or 0 for no ball. */\nexport function surfaceOf(extent: StageExtent): number {\n const surface = extent.surface ?? 0;\n return surface > 0 ? surface : 0;\n}\n\n/**\n * This function makes a view that shows each corner of the content from one direction.\n * `margin` is the space around the content, as a factor of the distance. An extent with no corners gives the distance 1.\n */\nexport function fitView(angles: ViewAngles, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const distance = fitDistance(extent.corners, extent.center, angles, fieldOfView, aspect) * margin;\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: distance > 0 ? distance : 1 };\n };\n}\n\n/**\n * This function makes a view of a part of the ball of the content: a cap around the point of the ball below the camera.\n *\n * `angles` is the direction from the center of the ball to the camera. `angle` is the angle of the cap at the center of the ball, in radians.\n * `margin` is the space around the cap, as a factor of the height above the ball. An extent with no ball gives the distance 1.\n */\nexport function capView(angles: ViewAngles, angle: number, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const surface = surfaceOf(extent);\n const height = Math.max(capDistance(surface, angle, fieldOfView, aspect) - surface, 0);\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: surface > 0 ? surface + height * margin : 1 };\n };\n}\n\n/**\n * This function makes a view of points on the ball of the content. The camera is above the middle of the points, and the picture shows each point.\n *\n * The middle is the center of the box of the points. The camera is at the smallest distance that shows each point in the width and in the height of the picture.\n * Thus wide points fill a wide picture. `margin` is the space around the points, as a factor of the height above the ball.\n * A list with no points gives a view of all of the ball from the front. Points with their middle at the center of the ball give the same view.\n */\nexport function ballView(points: readonly Point3[], margin: number = FIT_MARGIN): StageView {\n let found: { readonly center: Point3; readonly angles: ViewAngles | undefined } | undefined;\n return (frame) => {\n const { extent } = frame;\n const { center } = extent;\n // The middle is the same for each picture of one content. So the function calculates it one time for each center.\n if (found === undefined || found.center.x !== center.x || found.center.y !== center.y || found.center.z !== center.z) {\n found = { center, angles: middleOf(points, center) };\n }\n const { angles } = found;\n if (angles === undefined) return capView({ polar: Math.PI / 2, azimuth: 0 }, Math.PI / 2, margin)(frame);\n const surface = surfaceOf(extent);\n // A point of the ball needs no more distance than the outline of the ball. Thus the camera is not farther than a view of all of the ball.\n const height = Math.max(fitDistance(points, center, angles, frame.fieldOfView, frame.aspect) - surface, 0);\n return { target: center, polar: angles.polar, azimuth: angles.azimuth, distance: surface > 0 ? surface + height * margin : 1 };\n };\n}\n\n/** This function gives the direction from `center` to the middle of the box of the points. It gives `undefined` when the middle has no direction. */\nfunction middleOf(points: readonly Point3[], center: Point3): ViewAngles | undefined {\n const low = { x: Infinity, y: Infinity, z: Infinity };\n const high = { x: -Infinity, y: -Infinity, z: -Infinity };\n for (const point of points) {\n low.x = Math.min(low.x, point.x);\n low.y = Math.min(low.y, point.y);\n low.z = Math.min(low.z, point.z);\n high.x = Math.max(high.x, point.x);\n high.y = Math.max(high.y, point.y);\n high.z = Math.max(high.z, point.z);\n }\n const middle = { x: (low.x + high.x) / 2 - center.x, y: (low.y + high.y) / 2 - center.y, z: (low.z + high.z) / 2 - center.z };\n const length = Math.hypot(middle.x, middle.y, middle.z);\n if (!(length > 0) || !Number.isFinite(length)) return undefined;\n const { polar, azimuth } = viewOf(middle, { x: 0, y: 0, z: 0 });\n return { polar, azimuth };\n}\n\n/** This function gives the radius of the ball around the center of an extent that holds the ball of the extent and each corner. */\nexport function reachOf(extent: StageExtent): number {\n let reach = surfaceOf(extent);\n for (const corner of extent.corners) reach = Math.max(reach, Math.hypot(corner.x - extent.center.x, corner.y - extent.center.y, corner.z - extent.center.z));\n return reach;\n}\n\n/**\n * This function gives the nearest depth that a camera draws, from the distance of the camera to the center of the content.\n *\n * A camera far from the content gets a large value. The depths of the content then have more steps, so two surfaces that are near stay apart.\n * The result is not less than the nearest depth of the limits, and it is in front of all the content.\n */\nexport function nearDepth(limits: StageLimits, extent: StageExtent, distance: number): number {\n const free = (distance - reachOf(extent)) / 8;\n return free > limits.near ? Math.min(free, limits.far / 4) : limits.near;\n}\n\n/**\n * This function gives the limits of the camera of a stage for a picture.\n *\n * The largest distance of the views is the base. The camera goes out to 3 times this distance, and in to 3 % of the height of that view.\n * The extent can give each distance. The nearest depth is small against the height of the nearest camera, and the farthest depth is behind all the content.\n */\nexport function stageLimits(frame: ViewFrame, views: readonly StageView[], polar: { readonly min: number; readonly max: number }): StageLimits {\n const { extent } = frame;\n const surface = surfaceOf(extent);\n let widest = 0;\n for (const view of views) widest = Math.max(widest, view(frame).distance);\n if (!(widest > surface)) widest = surface + 1;\n const reach = reachOf(extent);\n const minDistance = extent.minDistance ?? surface + (widest - surface) * 0.03;\n const maxDistance = Math.max(extent.maxDistance ?? surface + (widest - surface) * 3, minDistance);\n const height = Math.max(minDistance - surface, 1e-6);\n return { minPolar: polar.min, maxPolar: polar.max, minDistance, maxDistance, near: height / 8, far: (maxDistance + reach) * 1.5 };\n}\n"],"mappings":";;AA0CA,SAAgB,SAAS,MAA4B;CACnD,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK;CACpC,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK;CACpC,MAAM,aAAa,KAAK,IAAI,KAAK,OAAO;CACxC,MAAM,aAAa,KAAK,IAAI,KAAK,OAAO;CACxC,OAAO;EACL,MAAM;GAAE,GAAG,WAAW;GAAY,GAAG;GAAU,GAAG,WAAW;EAAW;EACxE,OAAO;GAAE,GAAG;GAAY,GAAG;GAAG,GAAG,IAAI;EAAW;EAChD,IAAI;GAAE,GAAG,IAAI,WAAW;GAAY,GAAG;GAAU,GAAG,IAAI,WAAW;EAAW;CAChF;AACF;;AAGA,SAAS,MAAM,OAAe,QAAgB,MAAsB;CAClE,QAAQ,MAAM,IAAI,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK;AACrG;;;;;;;;AASA,SAAgB,YAAY,QAA2B,QAAgB,MAAkB,KAAa,QAA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S,KAAK,IAAI,QAAQ,KAAK,KAAK,CAAC,CAAC,QAAQ;CACxE,IAAI,EAAE,SAAS,UAAU,SAAS,UAAU;CAC5C,MAAM,QAAQ,QAAQ,MAAM;CAC5B,MAAM,cAAc,OAAO,eAAe,WAAW,SAAS,WAAW;CACzE,MAAM,cAAc,KAAK,IAAI,OAAO,eAAe,WAAW,SAAS,WAAW,GAAG,WAAW;CAChG,MAAM,SAAS,KAAK,IAAI,cAAc,SAAS,IAAI;CACnD,OAAO;EAAE,UAAU,MAAM;EAAK,UAAU,MAAM;EAAK;EAAa;EAAa,MAAM,SAAS;EAAG,MAAM,cAAc,SAAS;CAAI;AAClI"}
package/build/globe.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as StageContent } from "./stage-DQga0pc6.js";
2
- import { C as ViewAngles, d as StageView, t as StageTheme } from "./theme-DAt9xM0P.js";
1
+ import { r as StageContent } from "./stage-Bhu1f7Dw.js";
2
+ import { C as ViewAngles, d as StageView, t as StageTheme } from "./theme-3EGbXXoP.js";
3
3
  import { Raycaster } from "three";
4
4
  import { LatLon, Region } from "@mark1russell7/geo";
5
5
  import { Point3 } from "@mark1russell7/layout-contract";
@@ -179,6 +179,7 @@ export declare function globeAngles(place: LatLon): ViewAngles;
179
179
  export declare function globeView(place: LatLon, degrees?: number, margin?: number): StageView;
180
180
  /**
181
181
  * This function makes a view that shows each region of a list. The camera is above the middle of the regions.
182
+ * The regions fill the width or the height of the picture, so a wide region is large in a wide picture.
182
183
  * 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.
183
184
  */
184
185
  export declare function regionView(regions: readonly Region[], margin?: number): StageView;
@@ -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,eAA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;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;;;;;;wBAmBX,YAAY;;;;;;;wBA6IZ,YAAY,GAAG,UAAS,aAAa,KAAU,aAAa;;;;;UChR3D;;WAEN,SAAS;;WAET,WAAW;;;qBAIT;;;;;wBA0CG,WAAW;;;;;;;;;;;;;wBAyOX,cAAc,QAAQ,QAAQ,cAAc,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;;;;;;wBAS7E,WAAW,kBAAkB,UAAU,kBAA8B;;;;;;wBAiBrE,QAAQ,QAAQ,QAAQ,WAAW,QAAQ,iBAAiB;;;;;wBAe5D,QAAQ,OAAO,QAAQ,KAAK,QAAQ"}
package/build/globe.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ballView, r as capView, t as FIT_MARGIN } from "./extent-BtiN2C8B.js";
1
+ import { n as ballView, r as capView, t as FIT_MARGIN } from "./extent-DC0qrxC5.js";
2
2
  import { BufferAttribute, BufferGeometry, Color, FrontSide, InstancedInterleavedBuffer, InterleavedBufferAttribute, Mesh, MeshBasicMaterial, Points, ShaderMaterial, ShapeUtils, Sphere, SphereGeometry, Vector2, Vector3 } from "three";
3
3
  import { densify, fromUnitVector, pointLocator, toUnitVector } from "@mark1russell7/geo";
4
4
  import { LineMaterial } from "three/addons/lines/LineMaterial.js";
@@ -513,6 +513,7 @@ function globeView(place, degrees = 90, margin = FIT_MARGIN) {
513
513
  }
514
514
  /**
515
515
  * This function makes a view that shows each region of a list. The camera is above the middle of the regions.
516
+ * The regions fill the width or the height of the picture, so a wide region is large in a wide picture.
516
517
  * 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.
517
518
  */
518
519
  function regionView(regions, margin = FIT_MARGIN) {
@@ -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/**\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,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KAAK;GAClC;GACA,KAAK,MAAM,QAAQ,WAAW;IAC5B,MAAM,OAAO,UAAU,KAAK,KAAK,MAAM;IACvC,IAAI,CAAC,OAAO,SAAS,KAAK,WAAW;IACrC,KAAK,YAAY;IACjB,UAAU,MAAM,KAAK;GACvB;GACA,KAAK,MAAM,QAAQ,YAAY,KAAK,YAAY,UAAU,KAAK,MAAM,MAAM;GAC3E,KAAK,KAAK;EACZ;EACA,KAAK,OAA4B;GAC/B,aAAc,IAAI,KAAK,IAAK,MAAM,cAAc,KAAK,KAAM,GAAG,IAAK,KAAK,IAAI,MAAM,QAAQ,CAAC;GAC3F,OAAO;EACT;EACA,KAAK,MAAY;GACf,KAAK,MAAM,QAAQ,WAAW,KAAK,QAAQ,KAAK,KAAK,IAAI;GACzD,KAAK,MAAM,QAAQ,YAAY,KAAK,QAAQ,KAAK,KAAK,KAAK;GAC3D,IAAI,YAAY,KAAA,GAAW,KAAK,OAAO;EACzC;EACA,QAAQ,KAAyB;GAC/B,MAAM,MAAM,QAAQ,IAAI,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 * The regions fill the width or the height of the picture, so a wide region is large in a wide picture.\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,Y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AA,GAAW,KAAK,OAAO;EACzC;EACA,QAAQ,KAAyB;GAC/B,MAAM,MAAM,QAAQ,IAAI,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"}
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as speedAt, C as ViewAngles, D as clampPlace, E as capDistance, M as turnBetween, N as viewAxes, O as fitDistance, P as viewOf, S as PlaceLimits, T as cameraPosition, _ as reachOf, a as NO_HIGHLIGHTS, b as FIELD_OF_VIEW, c as FIT_MARGIN, d as StageView, f as ViewFrame, g as nearDepth, h as fitView, i as Highlights, j as turnAcross, k as placeBetween, l as StageExtent, m as capView, n as CLICK_DISTANCE, o as highlightOf, p as ballView, r as Highlight, s as isClick, t as StageTheme, u as StageLimits, v as stageLimits, w as ViewAxes, x as Place, y as surfaceOf } from "./theme-DAt9xM0P.js";
1
+ import { A as speedAt, C as ViewAngles, D as clampPlace, E as capDistance, M as turnBetween, N as viewAxes, O as fitDistance, P as viewOf, S as PlaceLimits, T as cameraPosition, _ as reachOf, a as NO_HIGHLIGHTS, b as FIELD_OF_VIEW, c as FIT_MARGIN, d as StageView, f as ViewFrame, g as nearDepth, h as fitView, i as Highlights, j as turnAcross, k as placeBetween, l as StageExtent, m as capView, n as CLICK_DISTANCE, o as highlightOf, p as ballView, r as Highlight, s as isClick, t as StageTheme, u as StageLimits, v as stageLimits, w as ViewAxes, x as Place, y as surfaceOf } from "./theme-3EGbXXoP.js";
2
2
  import { C as spanPart, S as spanOfTimes, _ as replayPause, a as REPLAY_STEP, b as replaySpan, c as changeAfter, d as changeTimes, f as isLive, g as replayOf, h as replayNextSpeed, i as REPLAY_SPEEDS, l as changeBefore, m as replayKey, n as REPLAY_DURATION, o as Replay, p as replayAdvance, r as REPLAY_PAGE, s as TimeSpan, t as Lifetime, u as changeIndex, v as replayPlay, w as spanTime, x as replayToggle, y as replaySeek } from "./replay-DvGYPe7T.js";
3
3
  import { Point, Point3 } from "@mark1russell7/layout-contract";
4
4
  /** The largest angle of one step of an arrow key, in radians. A camera far from a ball, or with no ball, turns by this angle. */
@@ -77,5 +77,15 @@ export declare function approach(value: number, goal: number, seconds: number, t
77
77
  * - A point to the side of the picture gives a position out of the picture. The function does not remove it.
78
78
  */
79
79
  export declare function screenPoint(point: Point3, view: ArrayLike<number>, projection: ArrayLike<number>, width: number, height: number): Point | undefined;
80
+ /**
81
+ * This function tells if a browser can show a stage. A stage needs WebGL 2.
82
+ *
83
+ * A page uses it before it loads the entry `/three`. Thus a browser with no WebGL 2 shows a different picture, and it does not load `three`.
84
+ * The function asks a canvas that is not in the page for a context, and it releases the context at once.
85
+ * `page` is the document of the page. The default is the document of the browser. With no document, the function gives false.
86
+ *
87
+ * A stage can give `undefined` after this function gave true, so the page keeps its different picture ready.
88
+ */
89
+ export declare function stageSupported(page?: Document | undefined): boolean;
80
90
  export { CLICK_DISTANCE, FIELD_OF_VIEW, FIT_MARGIN, type Highlight, type Highlights, type KeyAction, type KeyOptions, type Lifetime, type Move, type MoveStep, NO_HIGHLIGHTS, type Place, type PlaceLimits, REPLAY_DURATION, REPLAY_PAGE, REPLAY_SPEEDS, REPLAY_STEP, type Replay, type StageExtent, type StageLimits, type StageTheme, type StageView, type TimeSpan, type ViewAngles, type ViewAxes, type ViewFrame, ballView, cameraPosition, capDistance, capView, changeAfter, changeBefore, changeIndex, changeTimes, clampPlace, fitDistance, fitView, highlightOf, isClick, isLive, nearDepth, placeBetween, reachOf, replayAdvance, replayKey, replayNextSpeed, replayOf, replayPause, replayPlay, replaySeek, replaySpan, replayToggle, spanOfTimes, spanPart, spanTime, speedAt, stageLimits, surfaceOf, turnAcross, turnBetween, viewAxes, viewOf };
81
91
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/keys.ts","../src/motion.ts","../src/screen.ts"],"mappings":";;;;qBAGa;;qBAGA;;qBAGA;;KAGD;WAAuB;WAAwB,OAAO;;WAAqB;WAAuB;;;UAG7F;;WAEN;;WAEA,QAAQ,SAAS;;WAEjB;;WAEA;;;;;;;;;;wBAWK,UAAU,aAAa,KAAK,OAAO,SAAS,aAAa;;UC/BxD;WACN,MAAM;WACN,IAAI;;WAEJ;;WAEA;;;UAIM;WACN,OAAO;;WAEP;;;;;;wBAOK,UAAU;;;;;wBASV,OAAO,MAAM,MAAM,aAAa,mBAAsB;;;;;;;wBAYtD,SAAS,eAAe,cAAc,iBAAiB,cAAc;;;;;;;;;;wBC5BrE,YAAY,OAAO,QAAQ,MAAM,mBAAmB,YAAY,mBAAmB,eAAe,iBAAiB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/keys.ts","../src/motion.ts","../src/screen.ts","../src/support.ts"],"mappings":";;;;qBAGa;;qBAGA;;qBAGA;;KAGD;WAAuB;WAAwB,OAAO;;WAAqB;WAAuB;;;UAG7F;;WAEN;;WAEA,QAAQ,SAAS;;WAEjB;;WAEA;;;;;;;;;;wBAWK,UAAU,aAAa,KAAK,OAAO,SAAS,aAAa;;UC/BxD;WACN,MAAM;WACN,IAAI;;WAEJ;;WAEA;;;UAIM;WACN,OAAO;;WAEP;;;;;;wBAOK,UAAU;;;;;wBASV,OAAO,MAAM,MAAM,aAAa,mBAAsB;;;;;;;wBAYtD,SAAS,eAAe,cAAc,iBAAiB,cAAc;;;;;;;;;;wBC5BrE,YAAY,OAAO,QAAQ,MAAM,mBAAmB,YAAY,mBAAmB,eAAe,iBAAiB;;;;;;;;;;wBCPnH,eAAe,OAAM"}
package/build/index.js CHANGED
@@ -1,5 +1,28 @@
1
- import { _ as turnBetween, a as nearDepth, c as surfaceOf, d as capDistance, f as clampPlace, g as turnAcross, h as speedAt, i as fitView, l as FIELD_OF_VIEW, m as placeBetween, n as ballView, o as reachOf, p as fitDistance, r as capView, s as stageLimits, t as FIT_MARGIN, u as cameraPosition, v as viewAxes, y as viewOf } from "./extent-BtiN2C8B.js";
2
- import { a as NO_HIGHLIGHTS, c as KEY_PART, d as keyAction, i as CLICK_DISTANCE, l as KEY_TURN, n as easeInOut, o as highlightOf, r as moveAt, s as isClick, t as approach, u as KEY_ZOOM } from "./motion-BxV1vOEB.js";
1
+ import { _ as turnBetween, a as nearDepth, c as surfaceOf, d as capDistance, f as clampPlace, g as turnAcross, h as speedAt, i as fitView, l as FIELD_OF_VIEW, m as placeBetween, n as ballView, o as reachOf, p as fitDistance, r as capView, s as stageLimits, t as FIT_MARGIN, u as cameraPosition, v as viewAxes, y as viewOf } from "./extent-DC0qrxC5.js";
2
+ import { a as NO_HIGHLIGHTS, c as KEY_PART, d as keyAction, i as CLICK_DISTANCE, l as KEY_TURN, n as easeInOut, o as highlightOf, r as moveAt, s as isClick, t as approach, u as KEY_ZOOM } from "./motion-dvvkaDwv.js";
3
3
  import { _ as replaySpan, a as changeAfter, b as spanPart, c as changeTimes, d as replayKey, f as replayNextSpeed, g as replaySeek, h as replayPlay, i as REPLAY_STEP, l as isLive, m as replayPause, n as REPLAY_PAGE, o as changeBefore, p as replayOf, r as REPLAY_SPEEDS, s as changeIndex, t as REPLAY_DURATION, u as replayAdvance, v as replayToggle, x as spanTime, y as spanOfTimes } from "./replay-YdWMyFko.js";
4
4
  import { t as screenPoint } from "./screen-DeOx4_90.js";
5
- export { CLICK_DISTANCE, FIELD_OF_VIEW, FIT_MARGIN, KEY_PART, KEY_TURN, KEY_ZOOM, NO_HIGHLIGHTS, REPLAY_DURATION, REPLAY_PAGE, REPLAY_SPEEDS, REPLAY_STEP, approach, ballView, cameraPosition, capDistance, capView, changeAfter, changeBefore, changeIndex, changeTimes, clampPlace, easeInOut, fitDistance, fitView, highlightOf, isClick, isLive, keyAction, moveAt, nearDepth, placeBetween, reachOf, replayAdvance, replayKey, replayNextSpeed, replayOf, replayPause, replayPlay, replaySeek, replaySpan, replayToggle, screenPoint, spanOfTimes, spanPart, spanTime, speedAt, stageLimits, surfaceOf, turnAcross, turnBetween, viewAxes, viewOf };
5
+ // src/support.ts
6
+ /**
7
+ * This function tells if a browser can show a stage. A stage needs WebGL 2.
8
+ *
9
+ * A page uses it before it loads the entry `/three`. Thus a browser with no WebGL 2 shows a different picture, and it does not load `three`.
10
+ * The function asks a canvas that is not in the page for a context, and it releases the context at once.
11
+ * `page` is the document of the page. The default is the document of the browser. With no document, the function gives false.
12
+ *
13
+ * A stage can give `undefined` after this function gave true, so the page keeps its different picture ready.
14
+ */
15
+ function stageSupported(page = globalThis.document) {
16
+ if (page === void 0) return false;
17
+ try {
18
+ const context = page.createElement("canvas").getContext("webgl2");
19
+ if (context === null) return false;
20
+ context.getExtension("WEBGL_lose_context")?.loseContext();
21
+ return true;
22
+ } catch {
23
+ return false;
24
+ }
25
+ }
26
+ export { CLICK_DISTANCE, FIELD_OF_VIEW, FIT_MARGIN, KEY_PART, KEY_TURN, KEY_ZOOM, NO_HIGHLIGHTS, REPLAY_DURATION, REPLAY_PAGE, REPLAY_SPEEDS, REPLAY_STEP, approach, ballView, cameraPosition, capDistance, capView, changeAfter, changeBefore, changeIndex, changeTimes, clampPlace, easeInOut, fitDistance, fitView, highlightOf, isClick, isLive, keyAction, moveAt, nearDepth, placeBetween, reachOf, replayAdvance, replayKey, replayNextSpeed, replayOf, replayPause, replayPlay, replaySeek, replaySpan, replayToggle, screenPoint, spanOfTimes, spanPart, spanTime, speedAt, stageLimits, stageSupported, surfaceOf, turnAcross, turnBetween, viewAxes, viewOf };
27
+
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/support.ts"],"sourcesContent":["/**\n * This function tells if a browser can show a stage. A stage needs WebGL 2.\n *\n * A page uses it before it loads the entry `/three`. Thus a browser with no WebGL 2 shows a different picture, and it does not load `three`.\n * The function asks a canvas that is not in the page for a context, and it releases the context at once.\n * `page` is the document of the page. The default is the document of the browser. With no document, the function gives false.\n *\n * A stage can give `undefined` after this function gave true, so the page keeps its different picture ready.\n */\nexport function stageSupported(page: Document | undefined = globalThis.document): boolean {\n if (page === undefined) return false;\n try {\n const context = page.createElement(\"canvas\").getContext(\"webgl2\");\n if (context === null) return false;\n // A browser keeps only some contexts. So the function gives this one back.\n context.getExtension(\"WEBGL_lose_context\")?.loseContext();\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,SAAgB,eAAe,OAA6B,WAAW,UAAmB;CACxF,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,IAAI;EACF,MAAM,UAAU,KAAK,cAAc,QAAQ,CAAC,CAAC,WAAW,QAAQ;EAChE,IAAI,YAAY,MAAM,OAAO;EAE7B,QAAQ,aAAa,oBAAoB,CAAC,EAAE,YAAY;EACxD,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF"}
package/build/labels.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as StageContent } from "./stage-DQga0pc6.js";
1
+ import { r as StageContent } from "./stage-Bhu1f7Dw.js";
2
2
  import { Point3, Rect } from "@mark1russell7/layout-contract";
3
3
  /**
4
4
  * The side of an anchor that the text of a label is on.
@@ -1,4 +1,4 @@
1
- import { g as turnAcross, m as placeBetween } from "./extent-BtiN2C8B.js";
1
+ import { g as turnAcross, m as placeBetween } from "./extent-DC0qrxC5.js";
2
2
  // src/keys.ts
3
3
  /** The largest angle of one step of an arrow key, in radians. A camera far from a ball, or with no ball, turns by this angle. */
4
4
  const KEY_TURN = Math.PI / 24;
@@ -132,4 +132,4 @@ function approach(value, goal, seconds, time, snap = .01) {
132
132
  }
133
133
  export { NO_HIGHLIGHTS as a, KEY_PART as c, keyAction as d, CLICK_DISTANCE as i, KEY_TURN as l, easeInOut as n, highlightOf as o, moveAt as r, isClick as s, approach as t, KEY_ZOOM as u };
134
134
 
135
- //# sourceMappingURL=motion-BxV1vOEB.js.map
135
+ //# sourceMappingURL=motion-dvvkaDwv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"motion-BxV1vOEB.js","names":[],"sources":["../src/keys.ts","../src/highlight.ts","../src/motion.ts"],"sourcesContent":["import { FIELD_OF_VIEW, turnAcross, type Place } from \"./view.ts\";\n\n/** The largest angle of one step of an arrow key, in radians. A camera far from a ball, or with no ball, turns by this angle. */\nexport const KEY_TURN: number = Math.PI / 24;\n\n/** The part of the height of the picture by which one step of an arrow key moves the surface of a ball, near the ball. */\nexport const KEY_PART = 0.125;\n\n/** The factor of the height of a camera above the surface for one step of the key `+`. */\nexport const KEY_ZOOM = 0.85;\n\n/** What a key does on a stage: it moves the camera to a place, or it shows a view. */\nexport type KeyAction = { readonly type: \"place\"; readonly place: Place } | { readonly type: \"view\"; readonly view: string };\n\n/** The keys of a stage. */\nexport interface KeyOptions {\n /** The name of the view of the keys `Home` and `0`. */\n readonly home: string;\n /** The name of the view of each other key, for example `{ t: \"top\" }`. A letter has no case. */\n readonly views?: Readonly<Record<string, string>> | undefined;\n /** The radius of the ball around the target that the camera stays out of, or 0 for no ball. */\n readonly surface?: number | undefined;\n /** The vertical angle of the picture, in degrees. The default is `FIELD_OF_VIEW`. */\n readonly fieldOfView?: number | undefined;\n}\n\n/**\n * This function gives the action of a key on a stage, or `undefined` for a key with no action.\n *\n * The arrow keys turn the camera around the target. The keys `+` and `-` change the height above the surface.\n * The keys `Home` and `0` show the home view.\n * Near a ball, a step of an arrow key moves the surface by the part `KEY_PART` of the height of the picture.\n * The result has no limits: the stage puts the place in its limits.\n */\nexport function keyAction(key: string, now: Place, options: KeyOptions): KeyAction | undefined {\n const surface = options.surface ?? 0;\n const turn = Math.min(KEY_TURN, KEY_PART * turnAcross(now.distance, surface, options.fieldOfView ?? FIELD_OF_VIEW));\n const zoom = (factor: number): Place => ({ ...now, distance: surface + (now.distance - surface) * factor });\n switch (key) {\n case \"ArrowLeft\":\n return { type: \"place\", place: { ...now, azimuth: now.azimuth - turn } };\n case \"ArrowRight\":\n return { type: \"place\", place: { ...now, azimuth: now.azimuth + turn } };\n case \"ArrowUp\":\n return { type: \"place\", place: { ...now, polar: now.polar - turn } };\n case \"ArrowDown\":\n return { type: \"place\", place: { ...now, polar: now.polar + turn } };\n case \"+\":\n case \"=\":\n return { type: \"place\", place: zoom(KEY_ZOOM) };\n case \"-\":\n case \"_\":\n return { type: \"place\", place: zoom(1 / KEY_ZOOM) };\n case \"Home\":\n case \"0\":\n return { type: \"view\", view: options.home };\n default: {\n const view = key.length === 1 ? options.views?.[key.toLowerCase()] : undefined;\n return view === undefined ? undefined : { type: \"view\", view };\n }\n }\n}\n","/** The highlight of a record. 0 is no highlight. 1 is a record under the pointer or in the highlighted list. 2 is the selected record. */\nexport type Highlight = 0 | 1 | 2;\n\n/** The records of a stage that have a highlight. Each record has a name. */\nexport interface Highlights {\n /** The name of the record under the pointer. */\n readonly hovered: string | undefined;\n /** The name of the selected record. */\n readonly selected: string | undefined;\n /** The names of the records that the page highlights. */\n readonly highlighted: ReadonlySet<string>;\n}\n\n/** The highlights of a stage with no pointer on it and no selected record. */\nexport const NO_HIGHLIGHTS: Highlights = { hovered: undefined, selected: undefined, highlighted: new Set() };\n\n/** This function gives the highlight of a record. The selected record has the highest highlight. */\nexport function highlightOf(highlights: Highlights, record: string): Highlight {\n if (record === highlights.selected) return 2;\n return record === highlights.hovered || highlights.highlighted.has(record) ? 1 : 0;\n}\n\n/** A pointer that moves this distance or less between down and up makes a click, in CSS pixels. */\nexport const CLICK_DISTANCE = 4;\n\n/**\n * This function tells if a pointer that went down and up made a click. A pointer that moved more than `limit` made a drag.\n * The positions and the limit are in CSS pixels.\n */\nexport function isClick(down: { readonly x: number; readonly y: number }, up: { readonly x: number; readonly y: number }, limit: number = CLICK_DISTANCE): boolean {\n return Math.hypot(up.x - down.x, up.y - down.y) <= limit;\n}\n","import { placeBetween, type Place } from \"./view.ts\";\n\n/** A move of a camera from one place to a different place. */\nexport interface Move {\n readonly from: Place;\n readonly to: Place;\n /** The time of the start of the move, in milliseconds. */\n readonly start: number;\n /** The time that the move takes, in milliseconds. */\n readonly duration: number;\n}\n\n/** The place of a camera at one time of a move. */\nexport interface MoveStep {\n readonly place: Place;\n /** This value is true at the end of the move, and after it. */\n readonly done: boolean;\n}\n\n/**\n * This function gives a part of a move with a slow start and a slow end. `part` goes from 0 to 1.\n * The result goes from 0 to 1, and it is 0.5 at the middle.\n */\nexport function easeInOut(part: number): number {\n const clamped = Math.min(Math.max(part, 0), 1);\n return clamped < 0.5 ? 4 * clamped * clamped * clamped : 1 - (-2 * clamped + 2) ** 3 / 2;\n}\n\n/**\n * This function gives the place of a camera at the time `now` of a move, in milliseconds.\n * A move with no duration is at its end immediately. `surface` is the radius of the ball around the target, or 0 for no ball.\n */\nexport function moveAt(move: Move, now: number, surface: number = 0): MoveStep {\n const part = move.duration > 0 ? Math.min(Math.max((now - move.start) / move.duration, 0), 1) : 1;\n if (part >= 1) return { place: move.to, done: true };\n return { place: placeBetween(move.from, move.to, easeInOut(part), surface), done: false };\n}\n\n/**\n * This function moves a value one step to its goal. Each step goes a constant part of the way that remains.\n *\n * `seconds` is the time of the step, and `time` is the time in which the value goes most of the way, in seconds.\n * A step with no time gives the goal. A value nearer to the goal than `snap` becomes the goal, so the steps have an end.\n */\nexport function approach(value: number, goal: number, seconds: number, time: number, snap: number = 0.01): number {\n if (!(seconds > 0) || !(time > 0)) return goal;\n const next = value + (goal - value) * (1 - Math.exp(0 - seconds / time));\n return Math.abs(goal - next) < snap ? goal : next;\n}\n"],"mappings":";;;AAGA,MAAa,WAAmB,KAAK,KAAK;;AAG1C,MAAa,WAAW;;AA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AU,OAAO;CAC3C,OAAO,WAAW,WAAW,WAAW,WAAW,YAAY,IAAI,MAAM,IAAI,IAAI;AACnF;;AAGA,MAAa,iBAAiB;;;;;AAM9B,SAAgB,QAAQ,MAAkD,IAAgD,QAAA,GAAyC;CACjK,OAAO,KAAK,MAAM,GAAG,IAAI,KAAK,GAAG,GAAG,IAAI,KAAK,CAAC,KAAK;AACrD;;;;;;ACRA,SAAgB,UAAU,MAAsB;CAC9C,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,GAAG,CAAC;CAC7C,OAAO,UAAU,KAAM,IAAI,UAAU,UAAU,UAAU,KAAK,KAAK,UAAU,MAAM,IAAI;AACzF;;;;;AAMA,SAAgB,OAAO,MAAY,KAAa,UAAkB,GAAa;CAC7E,MAAM,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,KAAK,SAAS,KAAK,UAAU,CAAC,GAAG,CAAC,IAAI;CAChG,IAAI,QAAQ,GAAG,OAAO;EAAE,OAAO,KAAK;EAAI,MAAM;CAAK;CACnD,OAAO;EAAE,OAAO,aAAa,KAAK,MAAM,KAAK,IAAI,UAAU,IAAI,GAAG,OAAO;EAAG,MAAM;CAAM;AAC1F;;;;;;;AAQA,SAAgB,SAAS,OAAe,MAAc,SAAiB,MAAc,OAAe,KAAc;CAChH,IAAI,EAAE,UAAU,MAAM,EAAE,OAAO,IAAI,OAAO;CAC1C,MAAM,OAAO,SAAS,OAAO,UAAU,IAAI,KAAK,IAAI,IAAI,UAAU,IAAI;CACtE,OAAO,KAAK,IAAI,OAAO,IAAI,IAAI,OAAO,OAAO;AAC/C"}
1
+ {"version":3,"file":"motion-dvvkaDwv.js","names":[],"sources":["../src/keys.ts","../src/highlight.ts","../src/motion.ts"],"sourcesContent":["import { FIELD_OF_VIEW, turnAcross, type Place } from \"./view.ts\";\n\n/** The largest angle of one step of an arrow key, in radians. A camera far from a ball, or with no ball, turns by this angle. */\nexport const KEY_TURN: number = Math.PI / 24;\n\n/** The part of the height of the picture by which one step of an arrow key moves the surface of a ball, near the ball. */\nexport const KEY_PART = 0.125;\n\n/** The factor of the height of a camera above the surface for one step of the key `+`. */\nexport const KEY_ZOOM = 0.85;\n\n/** What a key does on a stage: it moves the camera to a place, or it shows a view. */\nexport type KeyAction = { readonly type: \"place\"; readonly place: Place } | { readonly type: \"view\"; readonly view: string };\n\n/** The keys of a stage. */\nexport interface KeyOptions {\n /** The name of the view of the keys `Home` and `0`. */\n readonly home: string;\n /** The name of the view of each other key, for example `{ t: \"top\" }`. A letter has no case. */\n readonly views?: Readonly<Record<string, string>> | undefined;\n /** The radius of the ball around the target that the camera stays out of, or 0 for no ball. */\n readonly surface?: number | undefined;\n /** The vertical angle of the picture, in degrees. The default is `FIELD_OF_VIEW`. */\n readonly fieldOfView?: number | undefined;\n}\n\n/**\n * This function gives the action of a key on a stage, or `undefined` for a key with no action.\n *\n * The arrow keys turn the camera around the target. The keys `+` and `-` change the height above the surface.\n * The keys `Home` and `0` show the home view.\n * Near a ball, a step of an arrow key moves the surface by the part `KEY_PART` of the height of the picture.\n * The result has no limits: the stage puts the place in its limits.\n */\nexport function keyAction(key: string, now: Place, options: KeyOptions): KeyAction | undefined {\n const surface = options.surface ?? 0;\n const turn = Math.min(KEY_TURN, KEY_PART * turnAcross(now.distance, surface, options.fieldOfView ?? FIELD_OF_VIEW));\n const zoom = (factor: number): Place => ({ ...now, distance: surface + (now.distance - surface) * factor });\n switch (key) {\n case \"ArrowLeft\":\n return { type: \"place\", place: { ...now, azimuth: now.azimuth - turn } };\n case \"ArrowRight\":\n return { type: \"place\", place: { ...now, azimuth: now.azimuth + turn } };\n case \"ArrowUp\":\n return { type: \"place\", place: { ...now, polar: now.polar - turn } };\n case \"ArrowDown\":\n return { type: \"place\", place: { ...now, polar: now.polar + turn } };\n case \"+\":\n case \"=\":\n return { type: \"place\", place: zoom(KEY_ZOOM) };\n case \"-\":\n case \"_\":\n return { type: \"place\", place: zoom(1 / KEY_ZOOM) };\n case \"Home\":\n case \"0\":\n return { type: \"view\", view: options.home };\n default: {\n const view = key.length === 1 ? options.views?.[key.toLowerCase()] : undefined;\n return view === undefined ? undefined : { type: \"view\", view };\n }\n }\n}\n","/** The highlight of a record. 0 is no highlight. 1 is a record under the pointer or in the highlighted list. 2 is the selected record. */\nexport type Highlight = 0 | 1 | 2;\n\n/** The records of a stage that have a highlight. Each record has a name. */\nexport interface Highlights {\n /** The name of the record under the pointer. */\n readonly hovered: string | undefined;\n /** The name of the selected record. */\n readonly selected: string | undefined;\n /** The names of the records that the page highlights. */\n readonly highlighted: ReadonlySet<string>;\n}\n\n/** The highlights of a stage with no pointer on it and no selected record. */\nexport const NO_HIGHLIGHTS: Highlights = { hovered: undefined, selected: undefined, highlighted: new Set() };\n\n/** This function gives the highlight of a record. The selected record has the highest highlight. */\nexport function highlightOf(highlights: Highlights, record: string): Highlight {\n if (record === highlights.selected) return 2;\n return record === highlights.hovered || highlights.highlighted.has(record) ? 1 : 0;\n}\n\n/** A pointer that moves this distance or less between down and up makes a click, in CSS pixels. */\nexport const CLICK_DISTANCE = 4;\n\n/**\n * This function tells if a pointer that went down and up made a click. A pointer that moved more than `limit` made a drag.\n * The positions and the limit are in CSS pixels.\n */\nexport function isClick(down: { readonly x: number; readonly y: number }, up: { readonly x: number; readonly y: number }, limit: number = CLICK_DISTANCE): boolean {\n return Math.hypot(up.x - down.x, up.y - down.y) <= limit;\n}\n","import { placeBetween, type Place } from \"./view.ts\";\n\n/** A move of a camera from one place to a different place. */\nexport interface Move {\n readonly from: Place;\n readonly to: Place;\n /** The time of the start of the move, in milliseconds. */\n readonly start: number;\n /** The time that the move takes, in milliseconds. */\n readonly duration: number;\n}\n\n/** The place of a camera at one time of a move. */\nexport interface MoveStep {\n readonly place: Place;\n /** This value is true at the end of the move, and after it. */\n readonly done: boolean;\n}\n\n/**\n * This function gives a part of a move with a slow start and a slow end. `part` goes from 0 to 1.\n * The result goes from 0 to 1, and it is 0.5 at the middle.\n */\nexport function easeInOut(part: number): number {\n const clamped = Math.min(Math.max(part, 0), 1);\n return clamped < 0.5 ? 4 * clamped * clamped * clamped : 1 - (-2 * clamped + 2) ** 3 / 2;\n}\n\n/**\n * This function gives the place of a camera at the time `now` of a move, in milliseconds.\n * A move with no duration is at its end immediately. `surface` is the radius of the ball around the target, or 0 for no ball.\n */\nexport function moveAt(move: Move, now: number, surface: number = 0): MoveStep {\n const part = move.duration > 0 ? Math.min(Math.max((now - move.start) / move.duration, 0), 1) : 1;\n if (part >= 1) return { place: move.to, done: true };\n return { place: placeBetween(move.from, move.to, easeInOut(part), surface), done: false };\n}\n\n/**\n * This function moves a value one step to its goal. Each step goes a constant part of the way that remains.\n *\n * `seconds` is the time of the step, and `time` is the time in which the value goes most of the way, in seconds.\n * A step with no time gives the goal. A value nearer to the goal than `snap` becomes the goal, so the steps have an end.\n */\nexport function approach(value: number, goal: number, seconds: number, time: number, snap: number = 0.01): number {\n if (!(seconds > 0) || !(time > 0)) return goal;\n const next = value + (goal - value) * (1 - Math.exp(0 - seconds / time));\n return Math.abs(goal - next) < snap ? goal : next;\n}\n"],"mappings":";;;AAGA,MAAa,WAAmB,KAAK,KAAK;;AAG1C,MAAa,WAAW;;AAGxB,MAAa,WAAW;;;;;;;;;AAyBxB,SAAgB,UAAU,KAAa,KAAY,SAA4C;CAC7F,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,OAAO,KAAK,IAAI,UAAU,WAAW,WAAW,IAAI,UAAU,SAAS,QAAQ,eAAA,EAA4B,CAAC;CAClH,MAAM,QAAQ,YAA2B;EAAE,GAAG;EAAK,UAAU,WAAW,IAAI,WAAW,WAAW;CAAO;CACzG,QAAQ,KAAR;EACE,KAAK,aACH,OAAO;GAAE,MAAM;GAAS,OAAO;IAAE,GAAG;IAAK,SAAS,IAAI,UAAU;GAAK;EAAE;EACzE,KAAK,cACH,OAAO;GAAE,MAAM;GAAS,OAAO;IAAE,GAAG;IAAK,SAAS,IAAI,UAAU;GAA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AAa;CAC7E,MAAM,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,KAAK,SAAS,KAAK,UAAU,CAAC,GAAG,CAAC,IAAI;CAChG,IAAI,QAAQ,GAAG,OAAO;EAAE,OAAO,KAAK;EAAI,MAAM;CAAK;CACnD,OAAO;EAAE,OAAO,aAAa,KAAK,MAAM,KAAK,IAAI,UAAU,IAAI,GAAG,OAAO;EAAG,MAAM;CAAM;AAC1F;;;;;;;AAQA,SAAgB,SAAS,OAAe,MAAc,SAAiB,MAAc,OAAe,KAAc;CAChH,IAAI,EAAE,UAAU,MAAM,EAAE,OAAO,IAAI,OAAO;CAC1C,MAAM,OAAO,SAAS,OAAO,UAAU,IAAI,KAAK,IAAI,IAAI,UAAU,IAAI;CACtE,OAAO,KAAK,IAAI,OAAO,IAAI,IAAI,OAAO,OAAO;AAC/C"}
@@ -1,4 +1,4 @@
1
- import { d as StageView, l as StageExtent, r as Highlight, t as StageTheme, x as Place } from "./theme-DAt9xM0P.js";
1
+ import { d as StageView, l as StageExtent, r as Highlight, t as StageTheme, x as Place } from "./theme-3EGbXXoP.js";
2
2
  import { Object3D, PerspectiveCamera, Raycaster } from "three";
3
3
  /** The record under the pointer: its name, and the value that the content gives for it. */
4
4
  interface StagePick<P> {
@@ -121,4 +121,4 @@ declare const STAGE_LIGHTS: StageLights;
121
121
  */
122
122
  declare function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined;
123
123
  export { StageLights as a, createStage as c, StageFrame as i, Stage as n, StageOptions as o, StageContent as r, StagePick as s, STAGE_LIGHTS as t };
124
- //# sourceMappingURL=stage-DQga0pc6.d.ts.map
124
+ //# sourceMappingURL=stage-Bhu1f7Dw.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stage-DQga0pc6.d.ts","names":[],"sources":["../src/stage/stage.ts"],"mappings":";;;UAYiB,UAAU;;WAEhB;;WAEA,OAAO;;;UAID;WACN,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7C,SAAS,aAAa,GAAG;WACzB,OAAO;;WAEP;;WAEA,OAAO,SAAS,eAAe;;WAE/B;;WAEA,OAAO,SAAS;;WAEhB;;WAEA;aAAmB;aAAmC;;;WAEtD;WACA,SAAS;;WAET,YAAY,MAAM;;WAElB,aAAa,MAAM;;;UAIb,MAAM,GAAG,UAAU,aAAa;;WAEtC,QAAQ;;EAEjB,WAAW,SAAS,aAAa,GAAG;;EAEpC,SAAS,OAAO;;EAEhB,QAAQ,eAAe,WAAW;;EAElC,SAAS;;EAET,UAAU;;EAEV,OAAO;;EAEP;;EAEA;;;cAIW,cAAc;;;;;;;;;;;iBAgCX,YAAY,GAAG,UAAU,aAAa,YAAY,WAAW,aAAa,SAAS,aAAa,GAAG,KAAK,MAAM,GAAG"}
@@ -143,7 +143,8 @@ declare function capView(angles: ViewAngles, angle: number, margin?: number): St
143
143
  /**
144
144
  * This function makes a view of points on the ball of the content. The camera is above the middle of the points, and the picture shows each point.
145
145
  *
146
- * The middle is the center of the box of the points. `margin` is the space around the points, as a factor of the height above the ball.
146
+ * The middle is the center of the box of the points. The camera is at the smallest distance that shows each point in the width and in the height of the picture.
147
+ * Thus wide points fill a wide picture. `margin` is the space around the points, as a factor of the height above the ball.
147
148
  * A list with no points gives a view of all of the ball from the front. Points with their middle at the center of the ball give the same view.
148
149
  */
149
150
  declare function ballView(points: readonly Point3[], margin?: number): StageView;
@@ -205,4 +206,4 @@ interface StageTheme {
205
206
  readonly ground: string;
206
207
  }
207
208
  export { speedAt as A, ViewAngles as C, clampPlace as D, capDistance as E, turnBetween as M, viewAxes as N, fitDistance as O, viewOf as P, PlaceLimits as S, cameraPosition as T, reachOf as _, NO_HIGHLIGHTS as a, FIELD_OF_VIEW as b, FIT_MARGIN as c, StageView as d, ViewFrame as f, nearDepth as g, fitView as h, Highlights as i, turnAcross as j, placeBetween as k, StageExtent as l, capView as m, CLICK_DISTANCE as n, highlightOf as o, ballView as p, Highlight as r, isClick as s, StageTheme as t, StageLimits as u, stageLimits as v, ViewAxes as w, Place as x, surfaceOf as y };
208
- //# sourceMappingURL=theme-DAt9xM0P.d.ts.map
209
+ //# sourceMappingURL=theme-3EGbXXoP.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme-DAt9xM0P.d.ts","names":[],"sources":["../src/view.ts","../src/extent.ts","../src/highlight.ts","../src/theme.ts"],"mappings":";;;;;UAMiB;;WAEN;;WAEA;;;UAIM,cAAc;WACpB,QAAQ;WACR;;;UAIM;;WAEN,MAAM;;WAEN,OAAO;;WAEP,IAAI;;;UAIE;;WAEN;;WAEA;;WAEA;;WAEA;;;iBAIK,SAAS,MAAM,aAAa;;;;;;;;iBAwB5B,YAAY,iBAAiB,UAAU,QAAQ,QAAQ,MAAM,YAAY,aAAa;;;;;;;;;iBAsBtF,YAAY,gBAAgB,eAAe,aAAa;;iBAaxD,eAAe,QAAQ,QAAQ,MAAM,YAAY,mBAAmB;;iBAMpE,OAAO,QAAQ,QAAQ,QAAQ,SAAS;WAAwB;;;iBAUhE,YAAY,cAAc;;iBAO1B,WAAW,OAAO,OAAO,QAAQ,cAAc;;;;;;;;iBAgB/C,QAAQ,kBAAkB;;cAM7B;;;;;;;;;;;;;iBAiBG,WAAW,kBAAkB,iBAAiB;;;;;;;iBAe9C,aAAa,MAAM,OAAO,IAAI,OAAO,cAAc,mBAAsB;;UC9KxE;;WAEN,kBAAkB;;WAElB,QAAQ;;;;;WAKR;;WAEA;;WAEA;;;UAIM;WACN,QAAQ;;WAER;;WAEA;;;KAIC,aAAa,OAAO,cAAc;;UAG7B,oBAAoB;WAC1B;WACA;;;cAIE;;iBAGG,UAAU,QAAQ;;;;;iBASlB,QAAQ,QAAQ,YAAY,kBAA8B;;;;;;;iBAa1D,QAAQ,QAAQ,YAAY,eAAe,kBAA8B;;;;;;;iBAczE,SAAS,iBAAiB,UAAU,kBAA8B;;iBA0ClE,QAAQ,QAAQ;;;;;;;iBAYhB,UAAU,QAAQ,aAAa,QAAQ,aAAa;;;;;;;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;;;;;;;iBAezE,SAAS,iBAAiB,UAAU,kBAA8B;;iBAsClE,QAAQ,QAAQ;;;;;;;iBAYhB,UAAU,QAAQ,aAAa,QAAQ,aAAa;;;;;;;iBAWpD,YAAY,OAAO,WAAW,gBAAgB,aAAa;WAAkB;WAAsB;IAAgB;;KC3IvH;;UAGK;;WAEN;;WAEA;;WAEA,aAAa;;;cAIX,eAAe;;iBAGZ,YAAY,YAAY,YAAY,iBAAiB;;cAMxD;;;;;iBAMG,QAAQ;WAAiB;WAAoB;GAAa;WAAe;WAAoB;GAAa;;;;;UCzBzG;;WAEN;;WAEA"}
package/build/three.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as StageLights, c as createStage, i as StageFrame, n as Stage, o as StageOptions, r as StageContent, s as StagePick, t as STAGE_LIGHTS } from "./stage-DQga0pc6.js";
2
- import { b as FIELD_OF_VIEW, t as StageTheme } from "./theme-DAt9xM0P.js";
1
+ import { a as StageLights, c as createStage, i as StageFrame, n as Stage, o as StageOptions, r as StageContent, s as StagePick, t as STAGE_LIGHTS } from "./stage-Bhu1f7Dw.js";
2
+ import { b as FIELD_OF_VIEW, t as StageTheme } from "./theme-3EGbXXoP.js";
3
3
  /**
4
4
  * This function makes one content from a list of contents, for a stage that shows them together.
5
5
  * An example is a globe with a layer of labels, or a room with its marks.
package/build/three.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as nearDepth, c as surfaceOf, f as clampPlace, g as turnAcross, h as speedAt, l as FIELD_OF_VIEW, s as stageLimits, u as cameraPosition, y as viewOf } from "./extent-BtiN2C8B.js";
2
- import { a as NO_HIGHLIGHTS, d as keyAction, o as highlightOf, r as moveAt, s as isClick } from "./motion-BxV1vOEB.js";
1
+ import { a as nearDepth, c as surfaceOf, f as clampPlace, g as turnAcross, h as speedAt, l as FIELD_OF_VIEW, s as stageLimits, u as cameraPosition, y as viewOf } from "./extent-DC0qrxC5.js";
2
+ import { a as NO_HIGHLIGHTS, d as keyAction, o as highlightOf, r as moveAt, s as isClick } from "./motion-dvvkaDwv.js";
3
3
  import { DirectionalLight, HemisphereLight, PerspectiveCamera, Raycaster, Scene, Vector2, WebGLRenderer } from "three";
4
4
  import { OrbitControls } from "three/addons/controls/OrbitControls.js";
5
5
  // src/stage/stage.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/visuals",
4
- "version": "0.2.3",
4
+ "version": "0.2.4",
5
5
  "description": "3D stages for data on three.js: a camera that a person moves, views by name, picking, highlights and themes, a globe of the Earth, and the shared marks of the viewers as data.",
6
6
  "license": "MIT",
7
7
  "repository": {