@mark1russell7/visuals 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  3D stages for data. A stage is one canvas of three.js with a camera that a person moves. The content of the stage is your data.
4
4
 
5
- The package has five entries and one style sheet:
5
+ The package has six entries and two style sheets:
6
6
 
7
7
  - The entry `.` has the camera maths and the model of a replay. It needs no browser, and it does not need `three`.
8
8
  - The entry `/marks` has the marks that a viewer draws, as plain data. It needs no browser, and it does not need `three`.
@@ -10,6 +10,8 @@ The package has five entries and one style sheet:
10
10
  - The entry `/globe` has a content that shows the Earth as a globe, with areas and points on it. It also needs `three`.
11
11
  - The entry `/scrubber` has a control that sets the time of a picture. It needs a browser, and it does not need `three`.
12
12
  - The file `/scrubber.css` is the style sheet of the scrubber.
13
+ - The entry `/labels` has the labels of a stage: a short text next to a point, as an element of the page. It needs a browser.
14
+ - The file `/labels.css` is the style sheet of the labels.
13
15
 
14
16
  ## Install
15
17
 
@@ -80,6 +82,8 @@ A stage knows nothing about the data. The content gives it these parts:
80
82
  | `step` | The parts that change with the camera or with the time, before each picture. It is optional. |
81
83
  | `dispose` | The release of the memory of the graphics card. |
82
84
 
85
+ `stackContents` makes one content from a list of contents. The first content gives the extent, and a pick asks the last content first.
86
+
83
87
  A record has a name. The highlight of a record is 0, 1 or 2: no highlight, a record under the pointer, the selected record. `highlight` and `select` set the highlights from the page.
84
88
 
85
89
  ## Views
@@ -101,7 +105,9 @@ const near: StageView = (frame) => ({ ...front(frame), distance: 4 });
101
105
 
102
106
  An extent with the field `surface` has a ball around its center, for example a globe. The camera stays out of the ball.
103
107
 
104
- - The turn and the zoom become slower near the surface. So a small region does not go out of the picture with one drag.
108
+ - In a drag, the surface at the middle of the picture follows the pointer, at each height of the camera. So a small region does not go out of the picture with one drag.
109
+ - Near the surface, an arrow key moves the surface by one eighth of the height of the picture.
110
+ - The zoom becomes slower near the surface.
105
111
  - A move between two views changes the height above the surface by a constant factor in each step.
106
112
  - `capView` shows a cap of the ball. A cap of half of the ball shows all of the ball.
107
113
 
@@ -196,6 +202,7 @@ The functions of the globe maths have no state. A test in Node.js uses them:
196
202
  | `regionEdges` | The lines of the outline of a region. A cut on the antimeridian or at a pole gives no line. |
197
203
  | `gridLines` | The meridians and the parallels of a grid. |
198
204
  | `rayBall`, `inSight` | The first point of a ball on a ray, and if a camera sees a point of the ball. |
205
+ | `pointRadius` | The radius of the mark of a point: a half of its dot, and its ring. A label uses it as its `clear`. |
199
206
 
200
207
  ```ts
201
208
  import { globePoint, regionSurface } from "@mark1russell7/visuals/globe";
@@ -207,6 +214,60 @@ surface.corners.length / 2; // => 43: the corners of the outline with a step of
207
214
  surface.triangles.length / 3; // => 70
208
215
  ```
209
216
 
217
+ ## Labels
218
+
219
+ The entry `/labels` has a layer of labels. A label is a short text next to a point of a stage, for example the name of a place.
220
+
221
+ ```ts
222
+ import { globePoint, inSight, pointRadius } from "@mark1russell7/visuals/globe";
223
+ import { createLabels } from "@mark1russell7/visuals/labels";
224
+ import { createStage, stackContents } from "@mark1russell7/visuals/three";
225
+ import "@mark1russell7/visuals/labels.css";
226
+
227
+ const labels = createLabels(box, {
228
+ labels: [{ record: "city", at: globePoint({ lat: 32.8, lon: -96.8 }), text: "Dallas", rank: 1, clear: pointRadius(8) }],
229
+ visible: (point, eye) => inSight(point, eye, 1),
230
+ });
231
+ const stage = createStage(box, { content: stackContents([globe, labels]), theme, label: "The Earth with the name of one city" });
232
+
233
+ labels.show((label) => label.record !== "city"); // The name of the city goes out of the picture.
234
+ stage?.refresh();
235
+ ```
236
+
237
+ - The layer is a content of a stage with no three.js object. `stackContents` shows it with the content that it names.
238
+ - Give the container of the stage `position: relative`. The layer then fills the picture, above the canvas.
239
+ - Each label is an HTML element. So its text is sharp at each size, and it has the font of the page.
240
+ - No text is on a different text, on the mark of a different label, or out of the picture.
241
+ - When two texts have one place, the label of a highlighted record stays. Then the label with the higher `rank` stays.
242
+ - A label tries its sides in this sequence: right, left, above, below. The field `sides` gives a different sequence.
243
+ - Use the side `center` for the name of an area: the middle of the text is then on the point.
244
+ - `clear` is the radius of the mark at the point. The text stays off the mark, at the gap from it.
245
+ - `visible` tells if the camera sees a point. For a globe, `inSight` removes each name on the far side of the Earth.
246
+ - The places are a function of the picture. While the picture does not move, a highlight moves no text.
247
+ - The pointer goes through the layer to the picture. A screen reader ignores the layer, so give the names in the page too.
248
+ - The layer writes no inline style attribute, so it works under a strict content security policy.
249
+
250
+ `placeLabels` is the pure function that gives each text its place. A test in Node.js and a different renderer use the same function.
251
+
252
+ ```ts
253
+ import { placeLabels } from "@mark1russell7/visuals/labels";
254
+
255
+ // Two labels at one point, each with a text of 60 by 16 pixels and a dot with a radius of 5 pixels.
256
+ const label = { x: 100, y: 100, width: 60, height: 16, clear: 5 };
257
+ placeLabels([label, label], { width: 400, height: 300 });
258
+ // => [{ side: "right", box: { x: 109, y: 92, w: 60, h: 16 } }, { side: "left", box: { x: 31, y: 92, w: 60, h: 16 } }]
259
+ ```
260
+
261
+ The style sheet is plain CSS. A label takes its font from the page.
262
+
263
+ | Variable | What it sets | Default |
264
+ | --- | --- | --- |
265
+ | `--labels-ink` | The color of the text. | `CanvasText` |
266
+ | `--labels-halo` | The color around each letter. Give it the color behind the picture. | `Canvas` |
267
+ | `--labels-size` | The size of the text. | `0.8125rem` |
268
+
269
+ Each text has the kind of its label in `data-kind` and its side in `data-side`. A style sheet of the page gives each kind a look.
270
+
210
271
  ## A scrubber
211
272
 
212
273
  The entry `/scrubber` has a control with which a person sets the time of a picture, and replays its changes.
@@ -354,6 +415,8 @@ The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js u
354
415
  | `clampPlace`, `stageLimits` | A place in the limits of a stage, and the limits from the content. |
355
416
  | `reachOf`, `nearDepth` | The radius of the ball that holds the content, and the nearest depth that the camera draws. |
356
417
  | `keyAction` | The action of a key. |
418
+ | `turnAcross`, `speedAt` | The turn that moves the surface of a ball by the height of the picture, and the zoom speed at a height. |
419
+ | `screenPoint` | The point of a picture that shows a point of the world, in CSS pixels. |
357
420
  | `highlightOf`, `isClick` | The highlight of a record, and the difference between a click and a drag. |
358
421
  | `approach` | One step of a value to its goal, for a part that changes with time. |
359
422
 
@@ -109,13 +109,35 @@ function clampPlace(place, limits) {
109
109
  * This function gives the height of a camera above the surface of a stage, as a part of its distance from the target.
110
110
  *
111
111
  * `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.
112
- * The result is the factor of the turn speed and the zoom speed of a camera: near the surface, a camera moves slowly.
112
+ * The result is the factor of the zoom speed of a camera: near the surface, a camera moves slowly.
113
113
  * The result is 0.02 at least, so a camera on the surface can move away.
114
114
  */
115
115
  function speedAt(distance, surface) {
116
116
  if (!(distance > 0)) return 1;
117
117
  return Math.min(Math.max((distance - surface) / distance, .02), 1);
118
118
  }
119
+ /** The default vertical angle of the picture of a stage, in degrees. */
120
+ const FIELD_OF_VIEW = 32;
121
+ /** The smallest result of `turnAcross`, in radians. A camera on a ball, or in it, can thus turn. */
122
+ const SMALLEST_TURN = 1e-6;
123
+ /**
124
+ * This function gives the turn of a camera around a ball that moves the surface by the height of the picture, in radians.
125
+ *
126
+ * `surface` is the radius of the ball around the target. `fieldOfView` is the vertical angle of the picture, in degrees.
127
+ *
128
+ * The result is exact for the surface at the middle of the picture. Thus that surface follows the pointer in a drag.
129
+ * The ball is round, so a long drag moves that surface by a smaller distance than the pointer.
130
+ * Thus the surface does not go before the pointer.
131
+ *
132
+ * The result is `Infinity` for a stage with no ball, because such a stage has no surface that follows the pointer.
133
+ * A turn about the up axis moves a point between the equator and a pole of the ball by a smaller distance.
134
+ */
135
+ function turnAcross(distance, surface, fieldOfView) {
136
+ const half = fieldOfView * Math.PI / 360;
137
+ if (!(surface > 0) || !(distance > 0) || !(half > 0 && half < Math.PI / 2)) return Number.POSITIVE_INFINITY;
138
+ const shown = 2 * (distance - surface) * Math.tan(half);
139
+ return Math.max(shown / surface, SMALLEST_TURN);
140
+ }
119
141
  /**
120
142
  * This function gives the place at a part of the way between two places. `part` goes from 0 to 1.
121
143
  *
@@ -287,6 +309,6 @@ function stageLimits(frame, views, polar) {
287
309
  far: (maxDistance + reach) * 1.5
288
310
  };
289
311
  }
290
- export { viewOf as _, nearDepth as a, surfaceOf as c, clampPlace as d, fitDistance as f, viewAxes as g, turnBetween as h, fitView as i, cameraPosition as l, speedAt as m, ballView as n, reachOf as o, placeBetween as p, capView as r, stageLimits as s, FIT_MARGIN as t, capDistance as u };
312
+ 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 };
291
313
 
292
- //# sourceMappingURL=extent-CALhBZU-.js.map
314
+ //# sourceMappingURL=extent-BtiN2C8B.js.map
@@ -0,0 +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,QAAgB,MAAsB;CAClE,QAAQ,MAAM,IAAI,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK;AACrG;;;;;;;;AASA,SAAgB,YAAY,QAA2B,QAAgB,MAAkB,KAAa,QAAwB;CAC5H,MAAM,QAAQ,KAAK,IAAK,MAAM,KAAK,KAAM,GAAG;CAC5C,MAAM,WAAW,QAAQ;CACzB,IAAI,EAAE,QAAQ,MAAM,EAAE,WAAW,MAAM,CAAC,OAAO,SAAS,QAAQ,GAAG,OAAO;CAC1E,MAAM,OAAO,SAAS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,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 { i as StageContent } from "./stage-CtWLSoV-.js";
2
- import { S as ViewAngles, d as StageView, t as StageTheme } from "./theme-CKXd_emk.js";
1
+ import { r as StageContent } from "./stage-DQga0pc6.js";
2
+ import { C as ViewAngles, d as StageView, t as StageTheme } from "./theme-DAt9xM0P.js";
3
3
  import { Raycaster } from "three";
4
4
  import { LatLon, Region } from "@mark1russell7/geo";
5
5
  import { Point3 } from "@mark1russell7/layout-contract";
@@ -91,6 +91,11 @@ interface GlobeContent<P> extends StageContent<P, GlobeTheme> {
91
91
  /** This function gives the place on the Earth that a ray from the camera finds. A ray that does not find the Earth gives `undefined`. */
92
92
  placeAt(ray: Raycaster): LatLon | undefined;
93
93
  }
94
+ /**
95
+ * This function gives the radius of the mark of a point of a globe, in CSS pixels. The mark is the dot, and the ring around it.
96
+ * `size` is the width of the dot. Give the result to the field `clear` of a label, so the text stays off the mark.
97
+ */
98
+ export declare function pointRadius(size: number): number;
94
99
  /**
95
100
  * This function makes the content of a stage that shows the Earth as a globe. The center of the globe is the origin of the stage.
96
101
  *
@@ -1 +1 @@
1
- {"version":3,"file":"globe.d.ts","names":[],"sources":["../src/globe/content.ts","../src/globe/mesh.ts","../src/globe/space.ts"],"mappings":";;;;;;UA6BiB;;WAEN;;WAEA;;WAEA;;;UAIM,mBAAmB;;WAEzB;;WAEA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WAEP;;WAEA;;;UAIM,UAAU;;WAEhB;;WAEA,QAAQ;;WAER;;WAEA,OAAO;;WAEP;;;UAIM,WAAW;;WAEjB;WACA,OAAO;;WAEP;;WAEA,OAAO;;WAEP;;WAEA;;;UAIM,aAAa;;WAEnB,iBAAiB,UAAU;;WAE3B,kBAAkB,WAAW;;WAE7B;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM,aAAa,WAAW,aAAa,GAAG;;;;;EAKvD,KAAK,OAAO,MAAM,UAAU,KAAK,WAAW;;EAE5C,QAAQ,KAAK,YAAY;;;;;;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;;;;;wBAQ7E,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-CALhBZU-.js";
1
+ import { n as ballView, r as capView, t as FIT_MARGIN } from "./extent-BtiN2C8B.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";
@@ -563,6 +563,13 @@ const HIGHLIGHT_OPACITY = .16;
563
563
  const HIGHLIGHT_SIZE = 1.35;
564
564
  /** The width of the ring around a point, in CSS pixels. */
565
565
  const RING_WIDTH = 1.5;
566
+ /**
567
+ * This function gives the radius of the mark of a point of a globe, in CSS pixels. The mark is the dot, and the ring around it.
568
+ * `size` is the width of the dot. Give the result to the field `clear` of a label, so the text stays off the mark.
569
+ */
570
+ function pointRadius(size) {
571
+ return size / 2 + RING_WIDTH;
572
+ }
566
573
  /** The distance around a point where the pointer finds it, in CSS pixels. */
567
574
  const PICK_MARGIN = 4;
568
575
  /** The exponent of the shade at the rim. A large value keeps the shade near the rim. */
@@ -1041,6 +1048,6 @@ function createGlobe(options = {}) {
1041
1048
  }
1042
1049
  };
1043
1050
  }
1044
- export { GLOBE_POLAR, MAX_SURFACE_CORNERS, createGlobe, globeAngles, globePlace, globePoint, globeView, gridLines, inSight, rayBall, regionEdges, regionSurface, regionView, surfaceSag };
1051
+ export { GLOBE_POLAR, MAX_SURFACE_CORNERS, createGlobe, globeAngles, globePlace, globePoint, globeView, gridLines, inSight, pointRadius, rayBall, regionEdges, regionSurface, regionView, surfaceSag };
1045
1052
 
1046
1053
  //# sourceMappingURL=globe.js.map