@mark1russell7/visuals 0.2.2 → 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
@@ -105,7 +105,9 @@ const near: StageView = (frame) => ({ ...front(frame), distance: 4 });
105
105
 
106
106
  An extent with the field `surface` has a ball around its center, for example a globe. The camera stays out of the ball.
107
107
 
108
- - 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.
109
111
  - A move between two views changes the height above the surface by a constant factor in each step.
110
112
  - `capView` shows a cap of the ball. A cap of half of the ball shows all of the ball.
111
113
 
@@ -413,6 +415,7 @@ The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js u
413
415
  | `clampPlace`, `stageLimits` | A place in the limits of a stage, and the limits from the content. |
414
416
  | `reachOf`, `nearDepth` | The radius of the ball that holds the content, and the nearest depth that the camera draws. |
415
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. |
416
419
  | `screenPoint` | The point of a picture that shows a point of the world, in CSS pixels. |
417
420
  | `highlightOf`, `isClick` | The highlight of a record, and the difference between a click and a drag. |
418
421
  | `approach` | One step of a value to its goal, for a part that changes with time. |
@@ -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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EAAG,GAAG;CAAE,CAAC;CAC9D,OAAO,QAAQ;EAAE;EAAO;CAAQ,GAAG,OAAO,MAAM;AAClD;;AAGA,SAAgB,QAAQ,QAA6B;CACnD,IAAI,QAAQ,UAAU,MAAM;CAC5B,KAAK,MAAM,UAAU,OAAO,SAAS,QAAQ,KAAK,IAAI,OAAO,KAAK,MAAM,OAAO,IAAI,OAAO,OAAO,GAAG,OAAO,IAAI,OAAO,OAAO,GAAG,OAAO,IAAI,OAAO,OAAO,CAAC,CAAC;CAC3J,OAAO;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"}
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";
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";
package/build/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { A as turnBetween, C as ViewAxes, D as fitDistance, E as clampPlace, M as viewOf, O as placeBetween, S as ViewAngles, T as capDistance, _ as reachOf, a as NO_HIGHLIGHTS, b as Place, c as FIT_MARGIN, d as StageView, f as ViewFrame, g as nearDepth, h as fitView, i as Highlights, j as viewAxes, k as speedAt, 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 cameraPosition, x as PlaceLimits, y as surfaceOf } from "./theme-CKXd_emk.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-DAt9xM0P.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
- /** The angle of one step of an arrow key, in radians, for a camera far from the surface. */
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. */
5
5
  export declare const KEY_TURN: number;
6
+ /** 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. */
7
+ export declare const KEY_PART = .125;
6
8
  /** The factor of the height of a camera above the surface for one step of the key `+`. */
7
9
  export declare const KEY_ZOOM = .85;
8
10
  /** What a key does on a stage: it moves the camera to a place, or it shows a view. */
@@ -21,12 +23,15 @@ interface KeyOptions {
21
23
  readonly views?: Readonly<Record<string, string>> | undefined;
22
24
  /** The radius of the ball around the target that the camera stays out of, or 0 for no ball. */
23
25
  readonly surface?: number | undefined;
26
+ /** The vertical angle of the picture, in degrees. The default is `FIELD_OF_VIEW`. */
27
+ readonly fieldOfView?: number | undefined;
24
28
  }
25
29
  /**
26
30
  * This function gives the action of a key on a stage, or `undefined` for a key with no action.
27
31
  *
28
32
  * The arrow keys turn the camera around the target. The keys `+` and `-` change the height above the surface.
29
- * The keys `Home` and `0` show the home view. Near the surface, a step of an arrow key is smaller.
33
+ * The keys `Home` and `0` show the home view.
34
+ * Near a ball, a step of an arrow key moves the surface by the part `KEY_PART` of the height of the picture.
30
35
  * The result has no limits: the stage puts the place in its limits.
31
36
  */
32
37
  export declare function keyAction(key: string, now: Place, options: KeyOptions): KeyAction | undefined;
@@ -72,5 +77,5 @@ export declare function approach(value: number, goal: number, seconds: number, t
72
77
  * - A point to the side of the picture gives a position out of the picture. The function does not remove it.
73
78
  */
74
79
  export declare function screenPoint(point: Point3, view: ArrayLike<number>, projection: ArrayLike<number>, width: number, height: number): Point | undefined;
75
- export { CLICK_DISTANCE, 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, turnBetween, viewAxes, viewOf };
80
+ 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 };
76
81
  //# 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;;KAGD;WAAuB;WAAwB,OAAO;;WAAqB;WAAuB;;;UAG7F;;WAEN;;WAEA,QAAQ,SAAS;;WAEjB;;;;;;;;;wBAUK,UAAU,aAAa,KAAK,OAAO,SAAS,aAAa;;UCzBxD;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"],"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"}
package/build/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as viewOf, a as nearDepth, c as surfaceOf, d as clampPlace, f as fitDistance, g as viewAxes, h as turnBetween, i as fitView, l as cameraPosition, m as speedAt, n as ballView, o as reachOf, p as placeBetween, r as capView, s as stageLimits, t as FIT_MARGIN, u as capDistance } from "./extent-CALhBZU-.js";
2
- import { a as NO_HIGHLIGHTS, c as KEY_TURN, i as CLICK_DISTANCE, l as KEY_ZOOM, n as easeInOut, o as highlightOf, r as moveAt, s as isClick, t as approach, u as keyAction } from "./motion-0tsT6sY4.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-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";
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, FIT_MARGIN, 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, turnBetween, viewAxes, viewOf };
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 };
package/build/labels.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as StageContent } from "./stage-CtWLSoV-.js";
1
+ import { r as StageContent } from "./stage-DQga0pc6.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,19 +1,22 @@
1
- import { m as speedAt, p as placeBetween } from "./extent-CALhBZU-.js";
1
+ import { g as turnAcross, m as placeBetween } from "./extent-BtiN2C8B.js";
2
2
  // src/keys.ts
3
- /** The angle of one step of an arrow key, in radians, for a camera far from the surface. */
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;
5
+ /** 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. */
6
+ const KEY_PART = .125;
5
7
  /** The factor of the height of a camera above the surface for one step of the key `+`. */
6
8
  const KEY_ZOOM = .85;
7
9
  /**
8
10
  * This function gives the action of a key on a stage, or `undefined` for a key with no action.
9
11
  *
10
12
  * The arrow keys turn the camera around the target. The keys `+` and `-` change the height above the surface.
11
- * The keys `Home` and `0` show the home view. Near the surface, a step of an arrow key is smaller.
13
+ * The keys `Home` and `0` show the home view.
14
+ * Near a ball, a step of an arrow key moves the surface by the part `KEY_PART` of the height of the picture.
12
15
  * The result has no limits: the stage puts the place in its limits.
13
16
  */
14
17
  function keyAction(key, now, options) {
15
18
  const surface = options.surface ?? 0;
16
- const turn = KEY_TURN * speedAt(now.distance, surface);
19
+ const turn = Math.min(KEY_TURN, KEY_PART * turnAcross(now.distance, surface, options.fieldOfView ?? 32));
17
20
  const zoom = (factor) => ({
18
21
  ...now,
19
22
  distance: surface + (now.distance - surface) * factor
@@ -127,6 +130,6 @@ function approach(value, goal, seconds, time, snap = .01) {
127
130
  const next = value + (goal - value) * (1 - Math.exp(0 - seconds / time));
128
131
  return Math.abs(goal - next) < snap ? goal : next;
129
132
  }
130
- export { NO_HIGHLIGHTS as a, KEY_TURN as c, CLICK_DISTANCE as i, KEY_ZOOM as l, easeInOut as n, highlightOf as o, moveAt as r, isClick as s, approach as t, keyAction as u };
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 };
131
134
 
132
- //# sourceMappingURL=motion-0tsT6sY4.js.map
135
+ //# sourceMappingURL=motion-BxV1vOEB.js.map
@@ -0,0 +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;;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;GAAK;EAAE;EACzE,KAAK,WACH,OAAO;GAAE,MAAM;GAAS,OAAO;IAAE,GAAG;IAAK,OAAO,IAAI,QAAQ;GAAK;EAAE;EACrE,KAAK,aACH,OAAO;GAAE,MAAM;GAAS,OAAO;IAAE,GAAG;IAAK,OAAO,IAAI,QAAQ;GAAK;EAAE;EACrE,KAAK;EACL,KAAK,KACH,OAAO;GAAE,MAAM;GAAS,OAAO,KAAK,QAAQ;EAAE;EAChD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;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 { b as Place, d as StageView, l as StageExtent, r as Highlight, t as StageTheme } from "./theme-CKXd_emk.js";
1
+ import { d as StageView, l as StageExtent, r as Highlight, t as StageTheme, x as Place } from "./theme-DAt9xM0P.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> {
@@ -107,8 +107,6 @@ interface Stage<P, T extends StageTheme = StageTheme> {
107
107
  /** This function removes the canvas and releases the memory of the graphics card. It disposes the content. */
108
108
  dispose(): void;
109
109
  }
110
- /** The default vertical angle of the picture, in degrees. */
111
- declare const FIELD_OF_VIEW = 32;
112
110
  /** The default lights: a strong light from above and below, and a light from the front left. */
113
111
  declare const STAGE_LIGHTS: StageLights;
114
112
  /**
@@ -122,5 +120,5 @@ declare const STAGE_LIGHTS: StageLights;
122
120
  * The page then shows a different picture of the same data.
123
121
  */
124
122
  declare function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined;
125
- export { StageFrame as a, StagePick as c, StageContent as i, createStage as l, STAGE_LIGHTS as n, StageLights as o, Stage as r, StageOptions as s, FIELD_OF_VIEW as t };
126
- //# sourceMappingURL=stage-CtWLSoV-.d.ts.map
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
@@ -1 +1 @@
1
- {"version":3,"file":"stage-CtWLSo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EAEb;;;UAIe;;WAEN;;WAEA;;WAEA;aAAiB;aAAoB;aAAoB;;;;UAInD,aAAa,GAAG,UAAU,aAAa;;WAE7C,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"}
@@ -67,10 +67,25 @@ declare function clampPlace(place: Place, limits: PlaceLimits): Place;
67
67
  * This function gives the height of a camera above the surface of a stage, as a part of its distance from the target.
68
68
  *
69
69
  * `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.
70
- * The result is the factor of the turn speed and the zoom speed of a camera: near the surface, a camera moves slowly.
70
+ * The result is the factor of the zoom speed of a camera: near the surface, a camera moves slowly.
71
71
  * The result is 0.02 at least, so a camera on the surface can move away.
72
72
  */
73
73
  declare function speedAt(distance: number, surface: number): number;
74
+ /** The default vertical angle of the picture of a stage, in degrees. */
75
+ declare const FIELD_OF_VIEW = 32;
76
+ /**
77
+ * This function gives the turn of a camera around a ball that moves the surface by the height of the picture, in radians.
78
+ *
79
+ * `surface` is the radius of the ball around the target. `fieldOfView` is the vertical angle of the picture, in degrees.
80
+ *
81
+ * The result is exact for the surface at the middle of the picture. Thus that surface follows the pointer in a drag.
82
+ * The ball is round, so a long drag moves that surface by a smaller distance than the pointer.
83
+ * Thus the surface does not go before the pointer.
84
+ *
85
+ * The result is `Infinity` for a stage with no ball, because such a stage has no surface that follows the pointer.
86
+ * A turn about the up axis moves a point between the equator and a pole of the ball by a smaller distance.
87
+ */
88
+ declare function turnAcross(distance: number, surface: number, fieldOfView: number): number;
74
89
  /**
75
90
  * This function gives the place at a part of the way between two places. `part` goes from 0 to 1.
76
91
  *
@@ -189,5 +204,5 @@ interface StageTheme {
189
204
  /** The color of the light from below. */
190
205
  readonly ground: string;
191
206
  }
192
- export { turnBetween as A, ViewAxes as C, fitDistance as D, clampPlace as E, viewOf as M, placeBetween as O, ViewAngles as S, capDistance as T, reachOf as _, NO_HIGHLIGHTS as a, Place as b, FIT_MARGIN as c, StageView as d, ViewFrame as f, nearDepth as g, fitView as h, Highlights as i, viewAxes as j, speedAt 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, cameraPosition as w, PlaceLimits as x, surfaceOf as y };
193
- //# sourceMappingURL=theme-CKXd_emk.d.ts.map
207
+ 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
@@ -0,0 +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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ent, l as createStage, n as STAGE_LIGHTS, o as StageLights, r as Stage, s as StageOptions, t as FIELD_OF_VIEW } from "./stage-CtWLSoV-.js";
2
- import { t as StageTheme } from "./theme-CKXd_emk.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-DQga0pc6.js";
2
+ import { b as FIELD_OF_VIEW, t as StageTheme } from "./theme-DAt9xM0P.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,10 +1,8 @@
1
- import { _ as viewOf, a as nearDepth, c as surfaceOf, d as clampPlace, l as cameraPosition, m as speedAt, s as stageLimits } from "./extent-CALhBZU-.js";
2
- import { a as NO_HIGHLIGHTS, o as highlightOf, r as moveAt, s as isClick, u as keyAction } from "./motion-0tsT6sY4.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-BtiN2C8B.js";
2
+ import { a as NO_HIGHLIGHTS, d as keyAction, o as highlightOf, r as moveAt, s as isClick } from "./motion-BxV1vOEB.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
6
- /** The default vertical angle of the picture, in degrees. */
7
- const FIELD_OF_VIEW = 32;
8
6
  /** The default lights: a strong light from above and below, and a light from the front left. */
9
7
  const STAGE_LIGHTS = {
10
8
  sky: 2.2,
@@ -17,7 +15,10 @@ const STAGE_LIGHTS = {
17
15
  };
18
16
  /** The time of the move between two views, in milliseconds. */
19
17
  const MOVE_TIME = 380;
20
- /** The turn of the camera for a drag across the height of the picture, as a part of a full turn, far from the surface. */
18
+ /**
19
+ * The largest turn of the camera for a drag across the height of the picture, as a part of a full turn.
20
+ * A camera far from a ball, or with no ball, turns by this part.
21
+ */
21
22
  const TURN_SPEED = .9;
22
23
  /** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */
23
24
  const SMALLEST_POLAR = 5e-4;
@@ -119,11 +120,15 @@ function createStage(container, options) {
119
120
  content.paint(theme, (record) => highlightOf(now, record));
120
121
  invalidate();
121
122
  };
122
- /** This function sets the turn speed and the zoom speed from the height of the camera above the surface. */
123
+ /**
124
+ * This function sets the turn speed and the zoom speed from the height of the camera above the surface.
125
+ * The surface of a ball at the middle of the picture follows the pointer in a drag.
126
+ */
123
127
  const setSpeed = () => {
124
- const speed = speedAt(camera.position.distanceTo(controls.target), surfaceOf(content.extent));
125
- controls.rotateSpeed = TURN_SPEED * speed;
126
- controls.zoomSpeed = speed;
128
+ const distance = camera.position.distanceTo(controls.target);
129
+ const surface = surfaceOf(content.extent);
130
+ controls.rotateSpeed = Math.min(TURN_SPEED, turnAcross(distance, surface, fieldOfView) / (2 * Math.PI));
131
+ controls.zoomSpeed = speedAt(distance, surface);
127
132
  };
128
133
  const placeNow = () => {
129
134
  const target = {
@@ -306,7 +311,8 @@ function createStage(container, options) {
306
311
  const action = keyAction(event.key, placeNow(), {
307
312
  home: options.home,
308
313
  views: options.keys,
309
- surface: surfaceOf(content.extent)
314
+ surface: surfaceOf(content.extent),
315
+ fieldOfView
310
316
  });
311
317
  if (action === void 0) return;
312
318
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"three.js","names":["World"],"sources":["../src/stage/stage.ts","../src/stage/stack.ts"],"sourcesContent":["import { DirectionalLight, HemisphereLight, PerspectiveCamera, Raycaster, Scene as World, Vector2, WebGLRenderer, type Object3D } from \"three\";\nimport { OrbitControls } from \"three/addons/controls/OrbitControls.js\";\nimport { nearDepth, stageLimits, surfaceOf, type StageExtent, type StageLimits, type StageView, type ViewFrame } from \"../extent.ts\";\nimport { keyAction } from \"../keys.ts\";\nimport { isClick, highlightOf, NO_HIGHLIGHTS, type Highlight, type Highlights } from \"../highlight.ts\";\nimport { moveAt, type Move } from \"../motion.ts\";\nimport type { StageTheme } from \"../theme.ts\";\nimport { cameraPosition, clampPlace, speedAt, viewOf, type Place } from \"../view.ts\";\n\n/** The record under the pointer: its name, and the value that the content gives for it. */\nexport interface StagePick<P> {\n /** The name of the record. The highlights of the stage use this name. */\n readonly record: string;\n /** The value of the record for the page, for example its kind and its source. */\n readonly value: P;\n}\n\n/** One picture of a stage, for the step of its content. */\nexport interface StageFrame {\n readonly camera: PerspectiveCamera;\n /** The time since the last picture, in seconds. */\n readonly seconds: number;\n /**\n * This value is true for the first picture of a content, and for a person who asks for less motion.\n * Each change then has no time: the content sets each value to its goal immediately.\n */\n readonly settle: boolean;\n /** The height of the picture, in CSS pixels. */\n readonly height: number;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n}\n\n/**\n * The content of a stage: the three.js objects of one scene, and what the stage asks of them.\n * `P` is the type of the value of a pick, and `T` is the type of the theme.\n */\nexport interface StageContent<P, T extends StageTheme = StageTheme> {\n /** The three.js objects of the content. The stage adds them to its world, and removes them. */\n readonly objects: readonly Object3D[];\n /** The space that the content fills. */\n readonly extent: StageExtent;\n /** This function tells if the content has a record with a name. */\n has(record: string): boolean;\n /** This function gives the record that a ray from the camera finds first, or `undefined` for no record. */\n pick(ray: Raycaster): StagePick<P> | undefined;\n /** This function gives each part its colors, from the theme and the highlight of its record. */\n paint(theme: T, highlight: (record: string) => Highlight): void;\n /**\n * This function changes the parts that depend on the camera or on the time, before each picture.\n * It gives true while a part continues to change. The stage then makes the next picture.\n */\n step?(frame: StageFrame): boolean;\n /** This function releases the memory of the graphics card that the content uses. */\n dispose(): void;\n}\n\n/** The lights of a stage. A content with materials that use no light ignores them. */\nexport interface StageLights {\n /** The strength of the light from above and below. */\n readonly sky: number;\n /** The strength of the light from one direction. */\n readonly sun: number;\n /** The position that the light from one direction comes from. */\n readonly from: { readonly x: number; readonly y: number; readonly z: number };\n}\n\n/** The options of a stage. */\nexport interface StageOptions<P, T extends StageTheme = StageTheme> {\n /** The first content. The stage disposes each content that it gets. */\n readonly content: StageContent<P, T>;\n readonly theme: T;\n /** The name of the picture for a screen reader. */\n readonly label: string;\n /** The views of the stage, each with a name. */\n readonly views: Readonly<Record<string, StageView>>;\n /** The name of the first view. The keys `Home` and `0` show it. */\n readonly home: string;\n /** The name of the view of a key, for example `{ t: \"top\" }`. A letter has no case. */\n readonly keys?: Readonly<Record<string, string>> | undefined;\n /** The vertical angle of the picture, in degrees. A small angle gives the look of a drawing. The default is 32. */\n readonly fieldOfView?: number | undefined;\n /** The smallest and the largest polar angle of the camera, in radians. The default keeps the camera above the plane of the target. */\n readonly polar?: { readonly min?: number | undefined; readonly max?: number | undefined } | undefined;\n /** This value is true if a person can move the target with a drag of the second button. The default is true. */\n readonly pan?: boolean | undefined;\n readonly lights?: StageLights | undefined;\n /** The stage starts this function when the pointer goes to a different record, or to no record. */\n readonly onHover?: ((pick: P | undefined) => void) | undefined;\n /** The stage starts this function when a person selects a record with the pointer, or selects no record. */\n readonly onSelect?: ((pick: P | undefined) => void) | undefined;\n}\n\n/** A stage in a page: one canvas with a camera that a person moves, and one content. */\nexport interface Stage<P, T extends StageTheme = StageTheme> {\n /** The canvas of the stage. It is in the container. */\n readonly canvas: HTMLCanvasElement;\n /** This function shows a different content, and disposes the old content. The view stays if a person moved it. */\n setContent(content: StageContent<P, T>): void;\n /** This function changes the colors. */\n setTheme(theme: T): void;\n /** This function moves the camera to a view: a name of the options, or a view function. `animate` has the default true. */\n setView(view: string | StageView, animate?: boolean): void;\n /** This function gives the place of the camera. */\n place(): Place;\n /** This function highlights records by their names, as the pointer does. An empty list removes the highlights. */\n highlight(records: readonly string[]): void;\n /** This function selects one record by its name, or no record. It does not start `onSelect`. */\n select(record: string | undefined): void;\n /** This function paints the content again and makes a new picture. Use it after a change of the content. */\n refresh(): void;\n /** This function removes the canvas and releases the memory of the graphics card. It disposes the content. */\n dispose(): void;\n}\n\n/** The default vertical angle of the picture, in degrees. */\nexport const FIELD_OF_VIEW = 32;\n\n/** The default lights: a strong light from above and below, and a light from the front left. */\nexport const STAGE_LIGHTS: StageLights = { sky: 2.2, sun: 1.5, from: { x: -10, y: 24, z: 15 } };\n\n/** The time of the move between two views, in milliseconds. */\nconst MOVE_TIME = 380;\n\n/** The turn of the camera for a drag across the height of the picture, as a part of a full turn, far from the surface. */\nconst TURN_SPEED = 0.9;\n\n/** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */\nconst SMALLEST_POLAR = 0.0005;\n\n/** The default largest polar angle: the camera stays above the plane of the target. */\nconst LARGEST_POLAR = Math.PI / 2 - 0.05;\n\n/** This function tells if the person asks for less motion. */\nfunction lessMotion(): boolean {\n return typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n}\n\n/**\n * This function makes a stage in a container of a page. The stage fills the container, so give the container a size.\n *\n * A person turns the content with a drag, and moves nearer with the wheel after a click in the picture.\n * A click selects the record under the pointer. With the keyboard, the arrow keys turn the content, `+` and `-` change the distance,\n * and `Home` shows the first view. The stage makes a picture only after a change.\n *\n * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.\n * The page then shows a different picture of the same data.\n */\nexport function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined {\n const canvas = container.ownerDocument.createElement(\"canvas\");\n const context = canvas.getContext(\"webgl2\", { alpha: true, antialias: true, depth: true, stencil: false, premultipliedAlpha: true, powerPreference: \"default\" });\n if (context === null) return undefined;\n let renderer: WebGLRenderer;\n try {\n renderer = new WebGLRenderer({ canvas, context, alpha: true, antialias: true });\n } catch {\n return undefined;\n }\n renderer.setClearColor(0x000000, 0);\n\n canvas.style.display = \"block\";\n canvas.style.width = \"100%\";\n canvas.style.height = \"100%\";\n canvas.style.cursor = \"grab\";\n canvas.style.touchAction = \"none\";\n canvas.tabIndex = 0;\n canvas.setAttribute(\"role\", \"application\");\n canvas.setAttribute(\"aria-label\", options.label);\n container.append(canvas);\n\n const fieldOfView = options.fieldOfView ?? FIELD_OF_VIEW;\n const polar = { min: options.polar?.min ?? SMALLEST_POLAR, max: options.polar?.max ?? LARGEST_POLAR };\n const lights = options.lights ?? STAGE_LIGHTS;\n const world = new World();\n const sky = new HemisphereLight(\"#ffffff\", \"#ffffff\", lights.sky);\n const sun = new DirectionalLight(\"#ffffff\", lights.sun);\n sun.position.set(lights.from.x, lights.from.y, lights.from.z);\n world.add(sky, sun);\n const camera = new PerspectiveCamera(fieldOfView, 1, 0.05, 1000);\n\n let content = options.content;\n let theme = options.theme;\n for (const object of content.objects) world.add(object);\n\n let highlights: Highlights = NO_HIGHLIGHTS;\n let view: string | StageView = options.home;\n let move: Move | undefined;\n /** This value is true after a person moved the view. Then a new size of the container does not move the camera. */\n let moved = false;\n /** This value is true until the content had a step with no time. */\n let settle = true;\n /** The height of the picture, in CSS pixels. */\n let height = 1;\n let frame = 0;\n let lastTime = 0;\n let disposed = false;\n\n const invalidate = (): void => {\n if (frame === 0 && !disposed) frame = requestAnimationFrame(tick);\n };\n\n const controls = new OrbitControls(camera, canvas);\n controls.enableDamping = !lessMotion();\n controls.dampingFactor = 0.14;\n controls.minPolarAngle = polar.min;\n controls.maxPolarAngle = polar.max;\n controls.rotateSpeed = TURN_SPEED;\n controls.screenSpacePanning = true;\n controls.enablePan = options.pan ?? true;\n // The wheel moves the page until a person uses the picture. Thus the picture does not stop a person who reads down the page.\n controls.enableZoom = false;\n\n const viewFrame = (): ViewFrame => ({ extent: content.extent, fieldOfView, aspect: camera.aspect });\n let limits: StageLimits = stageLimits(viewFrame(), Object.values(options.views), polar);\n\n const paint = (): void => {\n const now = highlights;\n content.paint(theme, (record) => highlightOf(now, record));\n invalidate();\n };\n\n /** This function sets the turn speed and the zoom speed from the height of the camera above the surface. */\n const setSpeed = (): void => {\n const speed = speedAt(camera.position.distanceTo(controls.target), surfaceOf(content.extent));\n controls.rotateSpeed = TURN_SPEED * speed;\n controls.zoomSpeed = speed;\n };\n const placeNow = (): Place => {\n const target = { x: controls.target.x, y: controls.target.y, z: controls.target.z };\n return { target, ...viewOf(camera.position, target) };\n };\n const put = (to: Place): void => {\n const next = clampPlace(to, limits);\n const eye = cameraPosition(next.target, next, next.distance);\n controls.target.set(next.target.x, next.target.y, next.target.z);\n camera.position.set(eye.x, eye.y, eye.z);\n camera.lookAt(controls.target);\n setSpeed();\n };\n /** This function gives the view function of a view, or `undefined` for a name that the options do not have. */\n const viewFunction = (of: string | StageView): StageView | undefined => (typeof of === \"string\" ? options.views[of] : of);\n\n /**\n * This function sets the nearest depth that the camera draws, from the distance of the camera to the content.\n * A camera far from the content then has small steps of depth at the content, so a layer near a surface stays above it.\n */\n const setDepth = (): void => {\n const { center } = content.extent;\n const distance = Math.hypot(camera.position.x - center.x, camera.position.y - center.y, camera.position.z - center.z);\n const near = nearDepth(limits, content.extent, distance);\n if (near === camera.near && limits.far === camera.far) return;\n camera.near = near;\n camera.far = limits.far;\n camera.updateProjectionMatrix();\n };\n /** This function sets the limits of the camera from the content and the shape of the picture. */\n const setLimits = (): void => {\n limits = stageLimits(viewFrame(), Object.values(options.views), polar);\n controls.minDistance = limits.minDistance;\n controls.maxDistance = limits.maxDistance;\n setDepth();\n };\n /**\n * This function stops the turn that continues after a drag. The camera stays where it is.\n * Without it, the camera continues to turn after a move to a view, and the view is not exact.\n */\n const stopDrift = (): void => {\n if (!controls.enableDamping) return;\n const now = placeNow();\n // With no damping, an update of the controls uses all of the turn that remains. The camera then goes back.\n controls.enableDamping = false;\n controls.update();\n controls.enableDamping = true;\n put(now);\n };\n const goTo = (next: string | StageView, animate: boolean): void => {\n const found = viewFunction(next);\n if (found === undefined) return;\n view = next;\n moved = false;\n stopDrift();\n const to = found(viewFrame());\n if (animate && !lessMotion()) {\n move = { from: placeNow(), to, start: performance.now(), duration: MOVE_TIME };\n } else {\n move = undefined;\n put(to);\n }\n invalidate();\n };\n\n /** This function sets the size of the picture from the size of the container. It gives false for a container with no size. */\n const setSize = (): boolean => {\n const width = container.clientWidth;\n const tall = container.clientHeight;\n if (width === 0 || tall === 0) return false;\n height = tall;\n renderer.setPixelRatio(Math.min(globalThis.devicePixelRatio, 2));\n renderer.setSize(width, tall, false);\n camera.aspect = width / tall;\n camera.updateProjectionMatrix();\n return true;\n };\n\n /** This function moves the camera one step of a move between two views. It gives true while the move continues. */\n const stepMove = (now: number): boolean => {\n if (move === undefined) return false;\n const step = moveAt(move, now, surfaceOf(content.extent));\n put(step.place);\n if (step.done) move = undefined;\n return true;\n };\n\n function tick(now: number): void {\n frame = 0;\n if (disposed) return;\n const seconds = lastTime === 0 ? 1 / 60 : Math.min((now - lastTime) / 1000, 0.1);\n let active = stepMove(now);\n setSpeed();\n active = controls.update() || active;\n setDepth();\n const stepped = content.step?.({ camera, seconds, settle: settle || lessMotion(), height, fieldOfView }) ?? false;\n settle = false;\n renderer.render(world, camera);\n active = stepped || active;\n lastTime = active ? now : 0;\n if (active) invalidate();\n }\n\n const raycaster = new Raycaster();\n const pointer = new Vector2();\n /** This function gives the record under a pointer. */\n const pickAt = (event: PointerEvent): StagePick<P> | undefined => {\n const box = canvas.getBoundingClientRect();\n if (box.width === 0 || box.height === 0) return undefined;\n pointer.set(((event.clientX - box.left) / box.width) * 2 - 1, 1 - ((event.clientY - box.top) / box.height) * 2);\n raycaster.setFromCamera(pointer, camera);\n return content.pick(raycaster);\n };\n\n const setHover = (pick: StagePick<P> | undefined): void => {\n const record = pick?.record;\n if (record === highlights.hovered) return;\n highlights = { ...highlights, hovered: record };\n canvas.style.cursor = record === undefined ? \"grab\" : \"pointer\";\n paint();\n options.onHover?.(pick?.value);\n };\n\n const listeners = new AbortController();\n const signal = listeners.signal;\n let down: { readonly id: number; readonly x: number; readonly y: number } | undefined;\n const setInUse = (inUse: boolean): void => {\n controls.enableZoom = inUse;\n };\n canvas.addEventListener(\n \"pointerdown\",\n (event) => {\n setInUse(true);\n canvas.focus({ preventScroll: true });\n down = { id: event.pointerId, x: event.clientX, y: event.clientY };\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointermove\",\n (event) => {\n if (event.buttons === 0 && event.pointerType !== \"touch\") setHover(pickAt(event));\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerup\",\n (event) => {\n const start = down;\n down = undefined;\n if (start === undefined || start.id !== event.pointerId) return;\n if (!isClick(start, { x: event.clientX, y: event.clientY })) return;\n const pick = pickAt(event);\n highlights = { ...highlights, selected: pick?.record };\n paint();\n options.onSelect?.(pick?.value);\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointercancel\",\n () => {\n down = undefined;\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerleave\",\n (event) => {\n setHover(undefined);\n if (event.pointerType === \"mouse\") setInUse(false);\n },\n { signal },\n );\n canvas.addEventListener(\"blur\", () => setInUse(false), { signal });\n canvas.addEventListener(\n \"keydown\",\n (event) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const action = keyAction(event.key, placeNow(), { home: options.home, views: options.keys, surface: surfaceOf(content.extent) });\n if (action === undefined) return;\n event.preventDefault();\n setInUse(true);\n if (action.type === \"view\") {\n goTo(action.view, true);\n return;\n }\n moved = true;\n move = undefined;\n stopDrift();\n put(action.place);\n invalidate();\n },\n { signal },\n );\n canvas.addEventListener(\"webglcontextlost\", (event) => event.preventDefault(), { signal });\n canvas.addEventListener(\"webglcontextrestored\", invalidate, { signal });\n\n controls.addEventListener(\"start\", () => {\n moved = true;\n move = undefined;\n canvas.style.cursor = \"grabbing\";\n invalidate();\n });\n controls.addEventListener(\"end\", () => {\n canvas.style.cursor = highlights.hovered === undefined ? \"grab\" : \"pointer\";\n });\n controls.addEventListener(\"change\", invalidate);\n\n const applyTheme = (): void => {\n sky.color.set(theme.sky);\n sky.groundColor.set(theme.ground);\n paint();\n };\n\n const observer = new ResizeObserver(() => {\n if (disposed || !setSize()) return;\n setLimits();\n if (!moved) goTo(view, false);\n invalidate();\n });\n\n setSize();\n setLimits();\n goTo(options.home, false);\n applyTheme();\n observer.observe(container);\n\n return {\n canvas,\n setContent(next: StageContent<P, T>): void {\n if (disposed || next === content) return;\n for (const object of content.objects) world.remove(object);\n content.dispose();\n content = next;\n for (const object of content.objects) world.add(object);\n const selected = highlights.selected !== undefined && content.has(highlights.selected) ? highlights.selected : undefined;\n highlights = { ...highlights, hovered: undefined, selected };\n settle = true;\n setLimits();\n if (!moved) goTo(view, false);\n paint();\n },\n setTheme(next: T): void {\n theme = next;\n applyTheme();\n },\n setView(next: string | StageView, animate: boolean = true): void {\n goTo(next, animate);\n },\n place: placeNow,\n highlight(records: readonly string[]): void {\n highlights = { ...highlights, highlighted: new Set(records) };\n paint();\n },\n select(record: string | undefined): void {\n highlights = { ...highlights, selected: record };\n paint();\n },\n refresh: paint,\n dispose(): void {\n if (disposed) return;\n disposed = true;\n cancelAnimationFrame(frame);\n observer.disconnect();\n listeners.abort();\n controls.dispose();\n for (const object of content.objects) world.remove(object);\n content.dispose();\n renderer.dispose();\n canvas.remove();\n },\n };\n}\n","import type { StageTheme } from \"../theme.ts\";\nimport type { StageContent, StagePick } from \"./stage.ts\";\n\n/**\n * This function makes one content from a list of contents, for a stage that shows them together.\n * An example is a globe with a layer of labels, or a room with its marks.\n *\n * - The first content gives the extent: the views and the limits of the camera come from it.\n * - The last content is on top. A pick asks the last content first, and it stops at the first record.\n * - A record that two contents have is one record: each of them gets its highlight.\n * - The stage disposes the stack, and the stack disposes each content.\n */\nexport function stackContents<P, T extends StageTheme = StageTheme>(contents: readonly [StageContent<P, T>, ...StageContent<P, T>[]]): StageContent<P, T> {\n const [first] = contents;\n return {\n objects: contents.flatMap((content) => content.objects),\n get extent() {\n return first.extent;\n },\n has: (record) => contents.some((content) => content.has(record)),\n pick(ray): StagePick<P> | undefined {\n for (let at = contents.length - 1; at >= 0; at -= 1) {\n const pick = contents[at]?.pick(ray);\n if (pick !== undefined) return pick;\n }\n return undefined;\n },\n paint(theme, highlight): void {\n for (const content of contents) content.paint(theme, highlight);\n },\n step(frame): boolean {\n let active = false;\n // Each content has its step, also after a content that continues to change.\n for (const content of contents) active = (content.step?.(frame) ?? false) || active;\n return active;\n },\n dispose(): void {\n for (const content of contents) content.dispose();\n },\n };\n}\n"],"mappings":";;;;;;AAoHA,MAAa,gBAAgB;;AAG7B,MAAa,eAA4B;CAAE,KAAK;CAAK,KAAK;CAAK,MAAM;EAAE,GAAG;EAAK,GAAG;EAAI,GAAG;CAAG;AAAE;;AAG9F,MAAM,YAAY;;AAGlB,MAAM,aAAa;;AAGnB,MAAM,iBAAiB;;AAGvB,MAAM,gBAAgB,KAAK,KAAK,IAAI;;AAGpC,SAAS,aAAsB;CAC7B,OAAO,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;AAC5F;;;;;;;;;;;AAYA,SAAgB,YAAkD,WAAwB,SAAsD;CAC9I,MAAM,SAAS,UAAU,cAAc,cAAc,QAAQ;CAC7D,MAAM,UAAU,OAAO,WAAW,UAAU;EAAE,OAAO;EAAM,WAAW;EAAM,OAAO;EAAM,SAAS;EAAO,oBAAoB;EAAM,iBAAiB;CAAU,CAAC;CAC/J,IAAI,YAAY,MAAM,OAAO,KAAA;CAC7B,IAAI;CACJ,IAAI;EACF,WAAW,IAAI,cAAc;GAAE;GAAQ;GAAS,OAAO;GAAM,WAAW;EAAK,CAAC;CAChF,QAAQ;EACN;CACF;CACA,SAAS,cAAc,GAAU,CAAC;CAElC,OAAO,MAAM,UAAU;CACvB,OAAO,MAAM,QAAQ;CACrB,OAAO,MAAM,SAAS;CACtB,OAAO,MAAM,SAAS;CACtB,OAAO,MAAM,cAAc;CAC3B,OAAO,WAAW;CAClB,OAAO,aAAa,QAAQ,aAAa;CACzC,OAAO,aAAa,cAAc,QAAQ,KAAK;CAC/C,UAAU,OAAO,MAAM;CAEvB,MAAM,cAAc,QAAQ,eAAA;CAC5B,MAAM,QAAQ;EAAE,KAAK,QAAQ,OAAO,OAAO;EAAgB,KAAK,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;EACA,SAAS;EACT,UAAgB;GACd,IAAI,UAAU;GACd,WAAW;GACX,qBAAqB,KAAK;GAC1B,SAAS,WAAW;GACpB,UAAU,MAAM;GAChB,SAAS,QAAQ;GACjB,KAAK,MAAM,UAAU,QAAQ,SAAS,MAAM,OAAO,MAAM;GACzD,QAAQ,QAAQ;GAChB,SAAS,QAAQ;GACjB,OAAO,OAAO;EAChB;CACF;AACF;;;;;;;;;;;ACveA,SAAgB,cAAoD,UAAsF;CACxJ,MAAM,CAAC,SAAS;CAChB,OAAO;EACL,SAAS,SAAS,SAAS,YAAY,QAAQ,OAAO;EACtD,IAAI,SAAS;GACX,OAAO,MAAM;EACf;EACA,MAAM,WAAW,SAAS,MAAM,YAAY,QAAQ,IAAI,MAAM,CAAC;EAC/D,KAAK,KAA+B;GAClC,KAAK,IAAI,KAAK,SAAS,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG;IACnD,MAAM,OAAO,SAAS,GAAG,EAAE,KAAK,GAAG;IACnC,IAAI,SAAS,KAAA,GAAW,OAAO;GACjC;EAEF;EACA,MAAM,OAAO,WAAiB;GAC5B,KAAK,MAAM,WAAW,UAAU,QAAQ,MAAM,OAAO,SAAS;EAChE;EACA,KAAK,OAAgB;GACnB,IAAI,SAAS;GAEb,KAAK,MAAM,WAAW,UAAU,UAAU,QAAQ,OAAO,KAAK,KAAK,UAAU;GAC7E,OAAO;EACT;EACA,UAAgB;GACd,KAAK,MAAM,WAAW,UAAU,QAAQ,QAAQ;EAClD;CACF;AACF"}
1
+ {"version":3,"file":"three.js","names":["World"],"sources":["../src/stage/stage.ts","../src/stage/stack.ts"],"sourcesContent":["import { DirectionalLight, HemisphereLight, PerspectiveCamera, Raycaster, Scene as World, Vector2, WebGLRenderer, type Object3D } from \"three\";\nimport { OrbitControls } from \"three/addons/controls/OrbitControls.js\";\nimport { nearDepth, stageLimits, surfaceOf, type StageExtent, type StageLimits, type StageView, type ViewFrame } from \"../extent.ts\";\nimport { keyAction } from \"../keys.ts\";\nimport { isClick, highlightOf, NO_HIGHLIGHTS, type Highlight, type Highlights } from \"../highlight.ts\";\nimport { moveAt, type Move } from \"../motion.ts\";\nimport type { StageTheme } from \"../theme.ts\";\nimport { cameraPosition, clampPlace, FIELD_OF_VIEW, speedAt, turnAcross, viewOf, type Place } from \"../view.ts\";\n\nexport { FIELD_OF_VIEW };\n\n/** The record under the pointer: its name, and the value that the content gives for it. */\nexport interface StagePick<P> {\n /** The name of the record. The highlights of the stage use this name. */\n readonly record: string;\n /** The value of the record for the page, for example its kind and its source. */\n readonly value: P;\n}\n\n/** One picture of a stage, for the step of its content. */\nexport interface StageFrame {\n readonly camera: PerspectiveCamera;\n /** The time since the last picture, in seconds. */\n readonly seconds: number;\n /**\n * This value is true for the first picture of a content, and for a person who asks for less motion.\n * Each change then has no time: the content sets each value to its goal immediately.\n */\n readonly settle: boolean;\n /** The height of the picture, in CSS pixels. */\n readonly height: number;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n}\n\n/**\n * The content of a stage: the three.js objects of one scene, and what the stage asks of them.\n * `P` is the type of the value of a pick, and `T` is the type of the theme.\n */\nexport interface StageContent<P, T extends StageTheme = StageTheme> {\n /** The three.js objects of the content. The stage adds them to its world, and removes them. */\n readonly objects: readonly Object3D[];\n /** The space that the content fills. */\n readonly extent: StageExtent;\n /** This function tells if the content has a record with a name. */\n has(record: string): boolean;\n /** This function gives the record that a ray from the camera finds first, or `undefined` for no record. */\n pick(ray: Raycaster): StagePick<P> | undefined;\n /** This function gives each part its colors, from the theme and the highlight of its record. */\n paint(theme: T, highlight: (record: string) => Highlight): void;\n /**\n * This function changes the parts that depend on the camera or on the time, before each picture.\n * It gives true while a part continues to change. The stage then makes the next picture.\n */\n step?(frame: StageFrame): boolean;\n /** This function releases the memory of the graphics card that the content uses. */\n dispose(): void;\n}\n\n/** The lights of a stage. A content with materials that use no light ignores them. */\nexport interface StageLights {\n /** The strength of the light from above and below. */\n readonly sky: number;\n /** The strength of the light from one direction. */\n readonly sun: number;\n /** The position that the light from one direction comes from. */\n readonly from: { readonly x: number; readonly y: number; readonly z: number };\n}\n\n/** The options of a stage. */\nexport interface StageOptions<P, T extends StageTheme = StageTheme> {\n /** The first content. The stage disposes each content that it gets. */\n readonly content: StageContent<P, T>;\n readonly theme: T;\n /** The name of the picture for a screen reader. */\n readonly label: string;\n /** The views of the stage, each with a name. */\n readonly views: Readonly<Record<string, StageView>>;\n /** The name of the first view. The keys `Home` and `0` show it. */\n readonly home: string;\n /** The name of the view of a key, for example `{ t: \"top\" }`. A letter has no case. */\n readonly keys?: Readonly<Record<string, string>> | undefined;\n /** The vertical angle of the picture, in degrees. A small angle gives the look of a drawing. The default is 32. */\n readonly fieldOfView?: number | undefined;\n /** The smallest and the largest polar angle of the camera, in radians. The default keeps the camera above the plane of the target. */\n readonly polar?: { readonly min?: number | undefined; readonly max?: number | undefined } | undefined;\n /** This value is true if a person can move the target with a drag of the second button. The default is true. */\n readonly pan?: boolean | undefined;\n readonly lights?: StageLights | undefined;\n /** The stage starts this function when the pointer goes to a different record, or to no record. */\n readonly onHover?: ((pick: P | undefined) => void) | undefined;\n /** The stage starts this function when a person selects a record with the pointer, or selects no record. */\n readonly onSelect?: ((pick: P | undefined) => void) | undefined;\n}\n\n/** A stage in a page: one canvas with a camera that a person moves, and one content. */\nexport interface Stage<P, T extends StageTheme = StageTheme> {\n /** The canvas of the stage. It is in the container. */\n readonly canvas: HTMLCanvasElement;\n /** This function shows a different content, and disposes the old content. The view stays if a person moved it. */\n setContent(content: StageContent<P, T>): void;\n /** This function changes the colors. */\n setTheme(theme: T): void;\n /** This function moves the camera to a view: a name of the options, or a view function. `animate` has the default true. */\n setView(view: string | StageView, animate?: boolean): void;\n /** This function gives the place of the camera. */\n place(): Place;\n /** This function highlights records by their names, as the pointer does. An empty list removes the highlights. */\n highlight(records: readonly string[]): void;\n /** This function selects one record by its name, or no record. It does not start `onSelect`. */\n select(record: string | undefined): void;\n /** This function paints the content again and makes a new picture. Use it after a change of the content. */\n refresh(): void;\n /** This function removes the canvas and releases the memory of the graphics card. It disposes the content. */\n dispose(): void;\n}\n\n/** The default lights: a strong light from above and below, and a light from the front left. */\nexport const STAGE_LIGHTS: StageLights = { sky: 2.2, sun: 1.5, from: { x: -10, y: 24, z: 15 } };\n\n/** The time of the move between two views, in milliseconds. */\nconst MOVE_TIME = 380;\n\n/**\n * The largest turn of the camera for a drag across the height of the picture, as a part of a full turn.\n * A camera far from a ball, or with no ball, turns by this part.\n */\nconst TURN_SPEED = 0.9;\n\n/** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */\nconst SMALLEST_POLAR = 0.0005;\n\n/** The default largest polar angle: the camera stays above the plane of the target. */\nconst LARGEST_POLAR = Math.PI / 2 - 0.05;\n\n/** This function tells if the person asks for less motion. */\nfunction lessMotion(): boolean {\n return typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n}\n\n/**\n * This function makes a stage in a container of a page. The stage fills the container, so give the container a size.\n *\n * A person turns the content with a drag, and moves nearer with the wheel after a click in the picture.\n * A click selects the record under the pointer. With the keyboard, the arrow keys turn the content, `+` and `-` change the distance,\n * and `Home` shows the first view. The stage makes a picture only after a change.\n *\n * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.\n * The page then shows a different picture of the same data.\n */\nexport function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined {\n const canvas = container.ownerDocument.createElement(\"canvas\");\n const context = canvas.getContext(\"webgl2\", { alpha: true, antialias: true, depth: true, stencil: false, premultipliedAlpha: true, powerPreference: \"default\" });\n if (context === null) return undefined;\n let renderer: WebGLRenderer;\n try {\n renderer = new WebGLRenderer({ canvas, context, alpha: true, antialias: true });\n } catch {\n return undefined;\n }\n renderer.setClearColor(0x000000, 0);\n\n canvas.style.display = \"block\";\n canvas.style.width = \"100%\";\n canvas.style.height = \"100%\";\n canvas.style.cursor = \"grab\";\n canvas.style.touchAction = \"none\";\n canvas.tabIndex = 0;\n canvas.setAttribute(\"role\", \"application\");\n canvas.setAttribute(\"aria-label\", options.label);\n container.append(canvas);\n\n const fieldOfView = options.fieldOfView ?? FIELD_OF_VIEW;\n const polar = { min: options.polar?.min ?? SMALLEST_POLAR, max: options.polar?.max ?? LARGEST_POLAR };\n const lights = options.lights ?? STAGE_LIGHTS;\n const world = new World();\n const sky = new HemisphereLight(\"#ffffff\", \"#ffffff\", lights.sky);\n const sun = new DirectionalLight(\"#ffffff\", lights.sun);\n sun.position.set(lights.from.x, lights.from.y, lights.from.z);\n world.add(sky, sun);\n const camera = new PerspectiveCamera(fieldOfView, 1, 0.05, 1000);\n\n let content = options.content;\n let theme = options.theme;\n for (const object of content.objects) world.add(object);\n\n let highlights: Highlights = NO_HIGHLIGHTS;\n let view: string | StageView = options.home;\n let move: Move | undefined;\n /** This value is true after a person moved the view. Then a new size of the container does not move the camera. */\n let moved = false;\n /** This value is true until the content had a step with no time. */\n let settle = true;\n /** The height of the picture, in CSS pixels. */\n let height = 1;\n let frame = 0;\n let lastTime = 0;\n let disposed = false;\n\n const invalidate = (): void => {\n if (frame === 0 && !disposed) frame = requestAnimationFrame(tick);\n };\n\n const controls = new OrbitControls(camera, canvas);\n controls.enableDamping = !lessMotion();\n controls.dampingFactor = 0.14;\n controls.minPolarAngle = polar.min;\n controls.maxPolarAngle = polar.max;\n controls.rotateSpeed = TURN_SPEED;\n controls.screenSpacePanning = true;\n controls.enablePan = options.pan ?? true;\n // The wheel moves the page until a person uses the picture. Thus the picture does not stop a person who reads down the page.\n controls.enableZoom = false;\n\n const viewFrame = (): ViewFrame => ({ extent: content.extent, fieldOfView, aspect: camera.aspect });\n let limits: StageLimits = stageLimits(viewFrame(), Object.values(options.views), polar);\n\n const paint = (): void => {\n const now = highlights;\n content.paint(theme, (record) => highlightOf(now, record));\n invalidate();\n };\n\n /**\n * This function sets the turn speed and the zoom speed from the height of the camera above the surface.\n * The surface of a ball at the middle of the picture follows the pointer in a drag.\n */\n const setSpeed = (): void => {\n const distance = camera.position.distanceTo(controls.target);\n const surface = surfaceOf(content.extent);\n // The controls turn the camera by a full turn times the speed for a drag across the height of the picture.\n controls.rotateSpeed = Math.min(TURN_SPEED, turnAcross(distance, surface, fieldOfView) / (2 * Math.PI));\n controls.zoomSpeed = speedAt(distance, surface);\n };\n const placeNow = (): Place => {\n const target = { x: controls.target.x, y: controls.target.y, z: controls.target.z };\n return { target, ...viewOf(camera.position, target) };\n };\n const put = (to: Place): void => {\n const next = clampPlace(to, limits);\n const eye = cameraPosition(next.target, next, next.distance);\n controls.target.set(next.target.x, next.target.y, next.target.z);\n camera.position.set(eye.x, eye.y, eye.z);\n camera.lookAt(controls.target);\n setSpeed();\n };\n /** This function gives the view function of a view, or `undefined` for a name that the options do not have. */\n const viewFunction = (of: string | StageView): StageView | undefined => (typeof of === \"string\" ? options.views[of] : of);\n\n /**\n * This function sets the nearest depth that the camera draws, from the distance of the camera to the content.\n * A camera far from the content then has small steps of depth at the content, so a layer near a surface stays above it.\n */\n const setDepth = (): void => {\n const { center } = content.extent;\n const distance = Math.hypot(camera.position.x - center.x, camera.position.y - center.y, camera.position.z - center.z);\n const near = nearDepth(limits, content.extent, distance);\n if (near === camera.near && limits.far === camera.far) return;\n camera.near = near;\n camera.far = limits.far;\n camera.updateProjectionMatrix();\n };\n /** This function sets the limits of the camera from the content and the shape of the picture. */\n const setLimits = (): void => {\n limits = stageLimits(viewFrame(), Object.values(options.views), polar);\n controls.minDistance = limits.minDistance;\n controls.maxDistance = limits.maxDistance;\n setDepth();\n };\n /**\n * This function stops the turn that continues after a drag. The camera stays where it is.\n * Without it, the camera continues to turn after a move to a view, and the view is not exact.\n */\n const stopDrift = (): void => {\n if (!controls.enableDamping) return;\n const now = placeNow();\n // With no damping, an update of the controls uses all of the turn that remains. The camera then goes back.\n controls.enableDamping = false;\n controls.update();\n controls.enableDamping = true;\n put(now);\n };\n const goTo = (next: string | StageView, animate: boolean): void => {\n const found = viewFunction(next);\n if (found === undefined) return;\n view = next;\n moved = false;\n stopDrift();\n const to = found(viewFrame());\n if (animate && !lessMotion()) {\n move = { from: placeNow(), to, start: performance.now(), duration: MOVE_TIME };\n } else {\n move = undefined;\n put(to);\n }\n invalidate();\n };\n\n /** This function sets the size of the picture from the size of the container. It gives false for a container with no size. */\n const setSize = (): boolean => {\n const width = container.clientWidth;\n const tall = container.clientHeight;\n if (width === 0 || tall === 0) return false;\n height = tall;\n renderer.setPixelRatio(Math.min(globalThis.devicePixelRatio, 2));\n renderer.setSize(width, tall, false);\n camera.aspect = width / tall;\n camera.updateProjectionMatrix();\n return true;\n };\n\n /** This function moves the camera one step of a move between two views. It gives true while the move continues. */\n const stepMove = (now: number): boolean => {\n if (move === undefined) return false;\n const step = moveAt(move, now, surfaceOf(content.extent));\n put(step.place);\n if (step.done) move = undefined;\n return true;\n };\n\n function tick(now: number): void {\n frame = 0;\n if (disposed) return;\n const seconds = lastTime === 0 ? 1 / 60 : Math.min((now - lastTime) / 1000, 0.1);\n let active = stepMove(now);\n setSpeed();\n active = controls.update() || active;\n setDepth();\n const stepped = content.step?.({ camera, seconds, settle: settle || lessMotion(), height, fieldOfView }) ?? false;\n settle = false;\n renderer.render(world, camera);\n active = stepped || active;\n lastTime = active ? now : 0;\n if (active) invalidate();\n }\n\n const raycaster = new Raycaster();\n const pointer = new Vector2();\n /** This function gives the record under a pointer. */\n const pickAt = (event: PointerEvent): StagePick<P> | undefined => {\n const box = canvas.getBoundingClientRect();\n if (box.width === 0 || box.height === 0) return undefined;\n pointer.set(((event.clientX - box.left) / box.width) * 2 - 1, 1 - ((event.clientY - box.top) / box.height) * 2);\n raycaster.setFromCamera(pointer, camera);\n return content.pick(raycaster);\n };\n\n const setHover = (pick: StagePick<P> | undefined): void => {\n const record = pick?.record;\n if (record === highlights.hovered) return;\n highlights = { ...highlights, hovered: record };\n canvas.style.cursor = record === undefined ? \"grab\" : \"pointer\";\n paint();\n options.onHover?.(pick?.value);\n };\n\n const listeners = new AbortController();\n const signal = listeners.signal;\n let down: { readonly id: number; readonly x: number; readonly y: number } | undefined;\n const setInUse = (inUse: boolean): void => {\n controls.enableZoom = inUse;\n };\n canvas.addEventListener(\n \"pointerdown\",\n (event) => {\n setInUse(true);\n canvas.focus({ preventScroll: true });\n down = { id: event.pointerId, x: event.clientX, y: event.clientY };\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointermove\",\n (event) => {\n if (event.buttons === 0 && event.pointerType !== \"touch\") setHover(pickAt(event));\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerup\",\n (event) => {\n const start = down;\n down = undefined;\n if (start === undefined || start.id !== event.pointerId) return;\n if (!isClick(start, { x: event.clientX, y: event.clientY })) return;\n const pick = pickAt(event);\n highlights = { ...highlights, selected: pick?.record };\n paint();\n options.onSelect?.(pick?.value);\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointercancel\",\n () => {\n down = undefined;\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerleave\",\n (event) => {\n setHover(undefined);\n if (event.pointerType === \"mouse\") setInUse(false);\n },\n { signal },\n );\n canvas.addEventListener(\"blur\", () => setInUse(false), { signal });\n canvas.addEventListener(\n \"keydown\",\n (event) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const action = keyAction(event.key, placeNow(), { home: options.home, views: options.keys, surface: surfaceOf(content.extent), fieldOfView });\n if (action === undefined) return;\n event.preventDefault();\n setInUse(true);\n if (action.type === \"view\") {\n goTo(action.view, true);\n return;\n }\n moved = true;\n move = undefined;\n stopDrift();\n put(action.place);\n invalidate();\n },\n { signal },\n );\n canvas.addEventListener(\"webglcontextlost\", (event) => event.preventDefault(), { signal });\n canvas.addEventListener(\"webglcontextrestored\", invalidate, { signal });\n\n controls.addEventListener(\"start\", () => {\n moved = true;\n move = undefined;\n canvas.style.cursor = \"grabbing\";\n invalidate();\n });\n controls.addEventListener(\"end\", () => {\n canvas.style.cursor = highlights.hovered === undefined ? \"grab\" : \"pointer\";\n });\n controls.addEventListener(\"change\", invalidate);\n\n const applyTheme = (): void => {\n sky.color.set(theme.sky);\n sky.groundColor.set(theme.ground);\n paint();\n };\n\n const observer = new ResizeObserver(() => {\n if (disposed || !setSize()) return;\n setLimits();\n if (!moved) goTo(view, false);\n invalidate();\n });\n\n setSize();\n setLimits();\n goTo(options.home, false);\n applyTheme();\n observer.observe(container);\n\n return {\n canvas,\n setContent(next: StageContent<P, T>): void {\n if (disposed || next === content) return;\n for (const object of content.objects) world.remove(object);\n content.dispose();\n content = next;\n for (const object of content.objects) world.add(object);\n const selected = highlights.selected !== undefined && content.has(highlights.selected) ? highlights.selected : undefined;\n highlights = { ...highlights, hovered: undefined, selected };\n settle = true;\n setLimits();\n if (!moved) goTo(view, false);\n paint();\n },\n setTheme(next: T): void {\n theme = next;\n applyTheme();\n },\n setView(next: string | StageView, animate: boolean = true): void {\n goTo(next, animate);\n },\n place: placeNow,\n highlight(records: readonly string[]): void {\n highlights = { ...highlights, highlighted: new Set(records) };\n paint();\n },\n select(record: string | undefined): void {\n highlights = { ...highlights, selected: record };\n paint();\n },\n refresh: paint,\n dispose(): void {\n if (disposed) return;\n disposed = true;\n cancelAnimationFrame(frame);\n observer.disconnect();\n listeners.abort();\n controls.dispose();\n for (const object of content.objects) world.remove(object);\n content.dispose();\n renderer.dispose();\n canvas.remove();\n },\n };\n}\n","import type { StageTheme } from \"../theme.ts\";\nimport type { StageContent, StagePick } from \"./stage.ts\";\n\n/**\n * This function makes one content from a list of contents, for a stage that shows them together.\n * An example is a globe with a layer of labels, or a room with its marks.\n *\n * - The first content gives the extent: the views and the limits of the camera come from it.\n * - The last content is on top. A pick asks the last content first, and it stops at the first record.\n * - A record that two contents have is one record: each of them gets its highlight.\n * - The stage disposes the stack, and the stack disposes each content.\n */\nexport function stackContents<P, T extends StageTheme = StageTheme>(contents: readonly [StageContent<P, T>, ...StageContent<P, T>[]]): StageContent<P, T> {\n const [first] = contents;\n return {\n objects: contents.flatMap((content) => content.objects),\n get extent() {\n return first.extent;\n },\n has: (record) => contents.some((content) => content.has(record)),\n pick(ray): StagePick<P> | undefined {\n for (let at = contents.length - 1; at >= 0; at -= 1) {\n const pick = contents[at]?.pick(ray);\n if (pick !== undefined) return pick;\n }\n return undefined;\n },\n paint(theme, highlight): void {\n for (const content of contents) content.paint(theme, highlight);\n },\n step(frame): boolean {\n let active = false;\n // Each content has its step, also after a content that continues to change.\n for (const content of contents) active = (content.step?.(frame) ?? false) || active;\n return active;\n },\n dispose(): void {\n for (const content of contents) content.dispose();\n },\n };\n}\n"],"mappings":";;;;;;AAsHA,MAAa,eAA4B;CAAE,KAAK;CAAK,KAAK;CAAK,MAAM;EAAE,GAAG;EAAK,GAAG;EAAI,GAAG;CAAG;AAAE;;AAG9F,MAAM,YAAY;;;;;AAMlB,MAAM,aAAa;;AAGnB,MAAM,iBAAiB;;AAGvB,MAAM,gBAAgB,KAAK,KAAK,IAAI;;AAGpC,SAAS,aAAsB;CAC7B,OAAO,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;AAC5F;;;;;;;;;;;AAYA,SAAgB,YAAkD,WAAwB,SAAsD;CAC9I,MAAM,SAAS,UAAU,cAAc,cAAc,QAAQ;CAC7D,MAAM,UAAU,OAAO,WAAW,UAAU;EAAE,OAAO;EAAM,WAAW;EAAM,OAAO;EAAM,SAAS;EAAO,oBAAoB;EAAM,iBAAiB;CAAU,CAAC;CAC/J,IAAI,YAAY,MAAM,OAAO,KAAA;CAC7B,IAAI;CACJ,IAAI;EACF,WAAW,IAAI,cAAc;GAAE;GAAQ;GAAS,OAAO;GAAM,WAAW;EAAK,CAAC;CAChF,QAAQ;EACN;CACF;CACA,SAAS,cAAc,GAAU,CAAC;CAElC,OAAO,MAAM,UAAU;CACvB,OAAO,MAAM,QAAQ;CACrB,OAAO,MAAM,SAAS;CACtB,OAAO,MAAM,SAAS;CACtB,OAAO,MAAM,cAAc;CAC3B,OAAO,WAAW;CAClB,OAAO,aAAa,QAAQ,a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
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/visuals",
4
- "version": "0.2.2",
4
+ "version": "0.2.3",
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": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"extent-CALhBZU-.js","names":[],"sources":["../src/view.ts","../src/extent.ts"],"sourcesContent":["import type { Point3 } from \"@mark1russell7/layout-contract\";\n\n/**\n * The direction of a view: where the camera is, as seen from the point that it looks at.\n * The space of a stage has the y axis up.\n */\nexport interface ViewAngles {\n /** The angle from the up axis to the camera, in radians. At 0, the camera looks down from above. */\n readonly polar: number;\n /** The angle around the up axis, in radians. At 0, the camera is on the positive z side of the point. */\n readonly azimuth: number;\n}\n\n/** A place of a camera: the point that it looks at, the angles of its view and its distance from the point. */\nexport interface Place extends ViewAngles {\n readonly target: Point3;\n readonly distance: number;\n}\n\n/** The three axes of a camera, as unit vectors in the space of the stage. */\nexport interface ViewAxes {\n /** The vector from the point that the camera looks at to the camera. */\n readonly back: Point3;\n /** The vector to the right side of the picture. */\n readonly right: Point3;\n /** The vector to the top of the picture. */\n readonly up: Point3;\n}\n\n/** The limits of the place of a camera. */\nexport interface PlaceLimits {\n /** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */\n readonly minPolar: number;\n /** The largest polar angle. */\n readonly maxPolar: number;\n /** The smallest distance from the target. */\n readonly minDistance: number;\n /** The largest distance from the target. */\n readonly maxDistance: number;\n}\n\n/** This function gives the axes of the camera of a view. At a polar angle of 0, the top of the picture is the negative z axis. */\nexport function viewAxes(view: ViewAngles): ViewAxes {\n const sinPolar = Math.sin(view.polar);\n const cosPolar = Math.cos(view.polar);\n const sinAzimuth = Math.sin(view.azimuth);\n const cosAzimuth = Math.cos(view.azimuth);\n return {\n back: { x: sinPolar * sinAzimuth, y: cosPolar, z: sinPolar * cosAzimuth },\n right: { x: cosAzimuth, y: 0, z: 0 - sinAzimuth },\n up: { x: 0 - cosPolar * sinAzimuth, y: sinPolar, z: 0 - cosPolar * cosAzimuth },\n };\n}\n\n/** This function gives the dot product of the vector from `origin` to `point` with `axis`. */\nfunction along(point: Point3, origin: Point3, axis: Point3): number {\n return (point.x - origin.x) * axis.x + (point.y - origin.y) * axis.y + (point.z - origin.z) * axis.z;\n}\n\n/**\n * This function gives the smallest distance from `target` at which a camera shows each point.\n *\n * The camera looks at `target` along the direction of `view`. `fov` is the vertical angle of the picture in degrees,\n * and `aspect` is the width of the picture divided by its height.\n * The function gives 0 for no points, and for an angle or an aspect that makes no picture.\n */\nexport function fitDistance(points: readonly Point3[], target: Point3, view: ViewAngles, fov: number, aspect: number): number {\n const tanUp = Math.tan((fov * Math.PI) / 360);\n const tanRight = tanUp * aspect;\n if (!(tanUp > 0) || !(tanRight > 0) || !Number.isFinite(tanRight)) return 0;\n const axes = viewAxes(view);\n let distance = 0;\n for (const point of points) {\n const depth = along(point, target, axes.back);\n const needed = Math.max(Math.abs(along(point, target, axes.right)) / tanRight, Math.abs(along(point, target, axes.up)) / tanUp);\n distance = Math.max(distance, depth + needed);\n }\n return distance;\n}\n\n/**\n * This function gives the smallest distance from the center of a ball at which a camera shows a cap of the ball.\n *\n * The camera looks at the center of the ball, and the center of the cap is on the line to the camera.\n * `radius` is the radius of the ball. `angle` is the angle of the cap at the center of the ball, in radians, from 0 to π / 2.\n * `fov` is the vertical angle of the picture in degrees, and `aspect` is the width of the picture divided by its height.\n * The function gives 0 for an angle or an aspect that makes no picture.\n */\nexport function capDistance(radius: number, angle: number, fov: number, aspect: number): number {\n const tanUp = Math.tan((fov * Math.PI) / 360);\n const tan = Math.min(tanUp, tanUp * aspect);\n if (!(tan > 0) || !Number.isFinite(tan) || !(radius > 0)) return 0;\n const cap = Math.min(Math.max(angle, 0), Math.PI / 2);\n const half = Math.atan(tan);\n // A cap this large has its edge behind the outline of the ball. Then the outline of the ball is the limit.\n if (cap >= Math.PI / 2 - half) return radius / Math.sin(half);\n // The edge of the cap is at the height r sin(a) from the line, and at the depth r cos(a) from the center.\n return radius * Math.cos(cap) + (radius * Math.sin(cap)) / tan;\n}\n\n/** This function gives the position of a camera at a distance from `target`, in the direction of `view`. */\nexport function cameraPosition(target: Point3, view: ViewAngles, distance: number): Point3 {\n const { back } = viewAxes(view);\n return { x: target.x + back.x * distance, y: target.y + back.y * distance, z: target.z + back.z * distance };\n}\n\n/** This function gives the angles of the view from `target` to a camera, and the distance between them. A camera at the target gives the angles 0. */\nexport function viewOf(camera: Point3, target: Point3): ViewAngles & { readonly distance: number } {\n const x = camera.x - target.x;\n const y = camera.y - target.y;\n const z = camera.z - target.z;\n const distance = Math.hypot(x, y, z);\n if (!(distance > 0)) return { polar: 0, azimuth: 0, distance: 0 };\n return { polar: Math.acos(Math.min(Math.max(y / distance, -1), 1)), azimuth: Math.atan2(x, z), distance };\n}\n\n/** This function gives the angle between two azimuths along the shortest way, from −π to π. */\nexport function turnBetween(from: number, to: number): number {\n const full = 2 * Math.PI;\n const turn = (((to - from) % full) + full) % full;\n return turn > Math.PI ? turn - full : turn;\n}\n\n/** This function gives a place in its limits. The target and the azimuth stay as they are. */\nexport function clampPlace(place: Place, limits: PlaceLimits): Place {\n return {\n target: place.target,\n azimuth: place.azimuth,\n polar: Math.min(Math.max(place.polar, limits.minPolar), limits.maxPolar),\n distance: Math.min(Math.max(place.distance, limits.minDistance), limits.maxDistance),\n };\n}\n\n/**\n * This function gives the height of a camera above the surface of a stage, as a part of its distance from the target.\n *\n * `surface` is the radius of the ball around the target that the camera stays out of. A stage with no ball has the value 0.\n * The result is the factor of the turn speed and the zoom speed of a camera: near the surface, a camera moves slowly.\n * The result is 0.02 at least, so a camera on the surface can move away.\n */\nexport function speedAt(distance: number, surface: number): number {\n if (!(distance > 0)) return 1;\n return Math.min(Math.max((distance - surface) / distance, 0.02), 1);\n}\n\n/**\n * This function gives the place at a part of the way between two places. `part` goes from 0 to 1.\n *\n * The azimuth goes along the shortest way. The height above the surface changes by an equal factor for each equal step,\n * so a zoom has one speed in the picture. `surface` is the radius of the ball around the target, or 0 for no ball.\n */\nexport function placeBetween(from: Place, to: Place, part: number, surface: number = 0): Place {\n const between = (a: number, b: number): number => a + (b - a) * part;\n const low = from.distance - surface;\n const high = to.distance - surface;\n const height = low > 0 && high > 0 ? low * (high / low) ** part : between(low, high);\n return {\n target: { x: between(from.target.x, to.target.x), y: between(from.target.y, to.target.y), z: between(from.target.z, to.target.z) },\n polar: between(from.polar, to.polar),\n azimuth: from.azimuth + turnBetween(from.azimuth, to.azimuth) * part,\n distance: surface + height,\n };\n}\n","import type { Point3 } from \"@mark1russell7/layout-contract\";\nimport { capDistance, fitDistance, viewOf, type Place, type PlaceLimits, type ViewAngles } from \"./view.ts\";\n\n/** The space that the content of a stage fills. A view and the limits of the camera come from it. */\nexport interface StageExtent {\n /** The points that a view of all the content shows, for example each corner of each solid. */\n readonly corners: readonly Point3[];\n /** The point that the camera looks at. */\n readonly center: Point3;\n /**\n * The radius of the ball around the center that the camera stays out of, for example the radius of a globe.\n * The default is 0: the content has no ball.\n */\n readonly surface?: number | undefined;\n /** The smallest distance of the camera from the center. The default comes from the views of the stage. */\n readonly minDistance?: number | undefined;\n /** The largest distance of the camera from the center. The default comes from the views of the stage. */\n readonly maxDistance?: number | undefined;\n}\n\n/** The picture that a view is for: the content, and the angle and the shape of the picture. */\nexport interface ViewFrame {\n readonly extent: StageExtent;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n /** The width of the picture divided by its height. */\n readonly aspect: number;\n}\n\n/** A view of a stage: a function that gives the place of the camera for a picture. A new size of the picture gives a new place. */\nexport type StageView = (frame: ViewFrame) => Place;\n\n/** The limits of the camera of a stage: the limits of its place, and the nearest and the farthest depth that it draws. */\nexport interface StageLimits extends PlaceLimits {\n readonly near: number;\n readonly far: number;\n}\n\n/** The space around the content in a view that shows all of it, as a factor of the distance. */\nexport const FIT_MARGIN = 1.06;\n\n/** This function gives the radius of the ball around the center of an extent, or 0 for no ball. */\nexport function surfaceOf(extent: StageExtent): number {\n const surface = extent.surface ?? 0;\n return surface > 0 ? surface : 0;\n}\n\n/**\n * This function makes a view that shows each corner of the content from one direction.\n * `margin` is the space around the content, as a factor of the distance. An extent with no corners gives the distance 1.\n */\nexport function fitView(angles: ViewAngles, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const distance = fitDistance(extent.corners, extent.center, angles, fieldOfView, aspect) * margin;\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: distance > 0 ? distance : 1 };\n };\n}\n\n/**\n * This function makes a view of a part of the ball of the content: a cap around the point of the ball below the camera.\n *\n * `angles` is the direction from the center of the ball to the camera. `angle` is the angle of the cap at the center of the ball, in radians.\n * `margin` is the space around the cap, as a factor of the height above the ball. An extent with no ball gives the distance 1.\n */\nexport function capView(angles: ViewAngles, angle: number, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const surface = surfaceOf(extent);\n const height = Math.max(capDistance(surface, angle, fieldOfView, aspect) - surface, 0);\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: surface > 0 ? surface + height * margin : 1 };\n };\n}\n\n/**\n * This function makes a view of points on the ball of the content. The camera is above the middle of the points, and the picture shows each point.\n *\n * The middle is the center of the box of the points. `margin` is the space around the points, as a factor of the height above the ball.\n * A list with no points gives a view of all of the ball from the front. Points with their middle at the center of the ball give the same view.\n */\nexport function ballView(points: readonly Point3[], margin: number = FIT_MARGIN): StageView {\n let found: { readonly center: Point3; readonly view: StageView } | undefined;\n return (frame) => {\n const { center } = frame.extent;\n // The middle and the cap are the same for each picture of one content. So the function calculates them one time for each center.\n if (found === undefined || found.center.x !== center.x || found.center.y !== center.y || found.center.z !== center.z) {\n found = { center, view: capOf(points, center, margin) };\n }\n return found.view(frame);\n };\n}\n\n/** This function makes the view of the cap of a ball around `center` that holds each point. */\nfunction capOf(points: readonly Point3[], center: Point3, margin: number): StageView {\n const low = { x: Infinity, y: Infinity, z: Infinity };\n const high = { x: -Infinity, y: -Infinity, z: -Infinity };\n for (const point of points) {\n low.x = Math.min(low.x, point.x);\n low.y = Math.min(low.y, point.y);\n low.z = Math.min(low.z, point.z);\n high.x = Math.max(high.x, point.x);\n high.y = Math.max(high.y, point.y);\n high.z = Math.max(high.z, point.z);\n }\n const middle = { x: (low.x + high.x) / 2 - center.x, y: (low.y + high.y) / 2 - center.y, z: (low.z + high.z) / 2 - center.z };\n const length = Math.hypot(middle.x, middle.y, middle.z);\n if (!(length > 0) || !Number.isFinite(length)) return capView({ polar: Math.PI / 2, azimuth: 0 }, Math.PI / 2, margin);\n let angle = 0;\n for (const point of points) {\n const x = point.x - center.x;\n const y = point.y - center.y;\n const z = point.z - center.z;\n const distance = Math.hypot(x, y, z);\n if (!(distance > 0)) continue;\n const cosine = (x * middle.x + y * middle.y + z * middle.z) / (distance * length);\n angle = Math.max(angle, Math.acos(Math.min(Math.max(cosine, -1), 1)));\n }\n const { polar, azimuth } = viewOf(middle, { x: 0, y: 0, z: 0 });\n return capView({ polar, azimuth }, angle, margin);\n}\n\n/** This function gives the radius of the ball around the center of an extent that holds the ball of the extent and each corner. */\nexport function reachOf(extent: StageExtent): number {\n let reach = surfaceOf(extent);\n for (const corner of extent.corners) reach = Math.max(reach, Math.hypot(corner.x - extent.center.x, corner.y - extent.center.y, corner.z - extent.center.z));\n return reach;\n}\n\n/**\n * This function gives the nearest depth that a camera draws, from the distance of the camera to the center of the content.\n *\n * A camera far from the content gets a large value. The depths of the content then have more steps, so two surfaces that are near stay apart.\n * The result is not less than the nearest depth of the limits, and it is in front of all the content.\n */\nexport function nearDepth(limits: StageLimits, extent: StageExtent, distance: number): number {\n const free = (distance - reachOf(extent)) / 8;\n return free > limits.near ? Math.min(free, limits.far / 4) : limits.near;\n}\n\n/**\n * This function gives the limits of the camera of a stage for a picture.\n *\n * The largest distance of the views is the base. The camera goes out to 3 times this distance, and in to 3 % of the height of that view.\n * The extent can give each distance. The nearest depth is small against the height of the nearest camera, and the farthest depth is behind all the content.\n */\nexport function stageLimits(frame: ViewFrame, views: readonly StageView[], polar: { readonly min: number; readonly max: number }): StageLimits {\n const { extent } = frame;\n const surface = surfaceOf(extent);\n let widest = 0;\n for (const view of views) widest = Math.max(widest, view(frame).distance);\n if (!(widest > surface)) widest = surface + 1;\n const reach = reachOf(extent);\n const minDistance = extent.minDistance ?? surface + (widest - surface) * 0.03;\n const maxDistance = Math.max(extent.maxDistance ?? surface + (widest - surface) * 3, minDistance);\n const height = Math.max(minDistance - surface, 1e-6);\n return { minPolar: polar.min, maxPolar: polar.max, minDistance, maxDistance, near: height / 8, far: (maxDistance + reach) * 1.5 };\n}\n"],"mappings":";;AA0CA,SAAgB,SAAS,MAA4B;CACnD,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK;CACpC,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK;CACpC,MAAM,aAAa,KAAK,IAAI,KAAK,OAAO;CACxC,MAAM,aAAa,KAAK,IAAI,KAAK,OAAO;CACxC,OAAO;EACL,MAAM;GAAE,GAAG,WAAW;GAAY,GAAG;GAAU,GAAG,WAAW;EAAW;EACxE,OAAO;GAAE,GAAG;GAAY,GAAG;GAAG,GAAG,IAAI;EAAW;EAChD,IAAI;GAAE,GAAG,IAAI,WAAW;GAAY,GAAG;GAAU,GAAG,IAAI,WAAW;EAAW;CAChF;AACF;;AAGA,SAAS,MAAM,OAAe,QAAgB,MAAsB;CAClE,QAAQ,MAAM,IAAI,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK;AACrG;;;;;;;;AASA,SAAgB,YAAY,QAA2B,QAAgB,MAAkB,KAAa,QAAwB;CAC5H,MAAM,QAAQ,KAAK,IAAK,MAAM,KAAK,KAAM,GAAG;CAC5C,MAAM,WAAW,QAAQ;CACzB,IAAI,EAAE,QAAQ,MAA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AO;EAAE,UAAU,MAAM;EAAK,UAAU,MAAM;EAAK;EAAa;EAAa,MAAM,SAAS;EAAG,MAAM,cAAc,SAAS;CAAI;AAClI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"motion-0tsT6sY4.js","names":[],"sources":["../src/keys.ts","../src/highlight.ts","../src/motion.ts"],"sourcesContent":["import { speedAt, type Place } from \"./view.ts\";\n\n/** The angle of one step of an arrow key, in radians, for a camera far from the surface. */\nexport const KEY_TURN: number = Math.PI / 24;\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}\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. Near the surface, a step of an arrow key is smaller.\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 = KEY_TURN * speedAt(now.distance, surface);\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;;;;;;;;AAsBxB,SAAgB,UAAU,KAAa,KAAY,SAA4C;CAC7F,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,OAAO,WAAW,QAAQ,IAAI,UAAU,OAAO;CACrD,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;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