@mark1russell7/visuals 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  3D stages for data. A stage is one canvas of three.js with a camera that a person moves. The content of the stage is your data.
4
4
 
5
- The package has six entries and two style sheets:
5
+ The package has seven entries and two style sheets:
6
6
 
7
7
  - The entry `.` has the camera maths and the model of a replay. It needs no browser, and it does not need `three`.
8
8
  - The entry `/marks` has the marks that a viewer draws, as plain data. It needs no browser, and it does not need `three`.
9
9
  - The entry `/three` has the stage. It needs the package `three`, version 0.187.0 or later.
10
10
  - The entry `/globe` has a content that shows the Earth as a globe, with areas and points on it. It also needs `three`.
11
+ - The entry `/markers` has a content that draws the marks on a stage. It also needs `three`.
11
12
  - The entry `/scrubber` has a control that sets the time of a picture. It needs a browser, and it does not need `three`.
12
13
  - The file `/scrubber.css` is the style sheet of the scrubber.
13
14
  - The entry `/labels` has the labels of a stage: a short text next to a point, as an element of the page. It needs a browser.
@@ -86,6 +87,8 @@ A stage knows nothing about the data. The content gives it these parts:
86
87
 
87
88
  `stackContents` makes one content from a list of contents. The first content gives the extent, and a pick asks the last content first.
88
89
 
90
+ A pick can have a `distance` from the start of the ray. The stack then also asks the earlier contents, and the nearest pick is the record. A pick with no distance is above each record of the earlier contents.
91
+
89
92
  A record has a name. The highlight of a record is 0, 1 or 2: no highlight, a record under the pointer, the selected record. `highlight` and `select` set the highlights from the page.
90
93
 
91
94
  ## Views
@@ -405,6 +408,57 @@ shapeRing("triangle").length; // => 3: the corners of the sign, counter-clockwis
405
408
 
406
409
  Use it as a gate in the tests of a producer. A viewer uses it on a list that it did not make. It does not examine the form of a mark, so read a list from JSON through a schema first.
407
410
 
411
+ ## The marks on a stage
412
+
413
+ The entry `/markers` has a content that draws a list of marks. Put it after the content of the solids in `stackContents`.
414
+
415
+ ```ts
416
+ import { fitView } from "@mark1russell7/visuals";
417
+ import { createMarkers, type MarkersTheme } from "@mark1russell7/visuals/markers";
418
+ import { createStage, stackContents } from "@mark1russell7/visuals/three";
419
+
420
+ const theme: MarkersTheme = {
421
+ sky: "#ffffff",
422
+ ground: "#ffffff",
423
+ levels: { unknown: "#55677a", ok: "#1f5fa8", near: "#c9740a", over: "#b81d3a" },
424
+ halo: "#ffffff",
425
+ accent: "#111111",
426
+ field: ["#eef4f1", "#8fcab7", "#1d7f69"],
427
+ };
428
+
429
+ const markers = createMarkers(marks);
430
+ const stage = createStage(box, {
431
+ // The content `room` has the solids. The marks are on top of them.
432
+ content: stackContents([room, markers]),
433
+ theme,
434
+ label: "A room with its marks",
435
+ views: { corner: fitView({ polar: 1, azimuth: 0.7 }) },
436
+ home: "corner",
437
+ onHover: (mark) => console.log(mark?.label),
438
+ });
439
+
440
+ // The legend of a page shows only the marks of some kinds.
441
+ markers.show((mark) => mark.kind !== "cable");
442
+ stage?.refresh();
443
+ ```
444
+
445
+ | Mark | Picture |
446
+ | --- | --- |
447
+ | `point` | A sign with the shape and the color of its level. The sign looks at the camera. |
448
+ | `run` | A round line with its width in the space, and a thin line of the color `halo` around it. |
449
+ | `link` | A dashed line. It is in the picture while its record, or the record of one of its ends, has a highlight. |
450
+ | `field` | A grid of colors on its plane. A cell with no value is clear. |
451
+ | `meter` | No picture, because a meter has no place. |
452
+
453
+ - A point with no `size` has a sign with a radius of `SIGN_RADIUS` pixels at each distance. A size is in the unit of the space.
454
+ - A mark behind a solid stays in the picture with less color. A mark with a highlight stays solid.
455
+ - A sign gets the pick before each solid, also behind a solid. Thus the pointer finds an outlet behind a desk.
456
+ - A run and a field give the distance of their pick, so a solid in front of them gets the pick. A run gets the pick before a field.
457
+ - The theme gives the color of each level, the colors of a field from `min` to `max`, and the color `halo` around a mark.
458
+ - A record with a highlight gets a larger sign, and a line of the color `accent` around it.
459
+ - `signReach` gives the radius of a sign with its line. Give it to the field `clear` of a label.
460
+ - The pick of a field gives the mark. `fieldValue` reads the value of a cell.
461
+
408
462
  ## The camera maths
409
463
 
410
464
  The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js use the same functions as the stage.
@@ -0,0 +1,154 @@
1
+ import { a as fitDistance, d as viewOf, r as capDistance } from "./view-BB_EQx3I.js";
2
+ // src/extent.ts
3
+ /** The space around the content in a view that shows all of it, as a factor of the distance. */
4
+ const FIT_MARGIN = 1.06;
5
+ /** This function gives the radius of the ball around the center of an extent, or 0 for no ball. */
6
+ function surfaceOf(extent) {
7
+ const surface = extent.surface ?? 0;
8
+ return surface > 0 ? surface : 0;
9
+ }
10
+ /**
11
+ * This function makes a view that shows each corner of the content from one direction.
12
+ * `margin` is the space around the content, as a factor of the distance. An extent with no corners gives the distance 1.
13
+ */
14
+ function fitView(angles, margin = FIT_MARGIN) {
15
+ return ({ extent, fieldOfView, aspect }) => {
16
+ const distance = fitDistance(extent.corners, extent.center, angles, fieldOfView, aspect) * margin;
17
+ return {
18
+ target: extent.center,
19
+ polar: angles.polar,
20
+ azimuth: angles.azimuth,
21
+ distance: distance > 0 ? distance : 1
22
+ };
23
+ };
24
+ }
25
+ /**
26
+ * 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.
27
+ *
28
+ * `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.
29
+ * `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.
30
+ */
31
+ function capView(angles, angle, margin = FIT_MARGIN) {
32
+ return ({ extent, fieldOfView, aspect }) => {
33
+ const surface = surfaceOf(extent);
34
+ const height = Math.max(capDistance(surface, angle, fieldOfView, aspect) - surface, 0);
35
+ return {
36
+ target: extent.center,
37
+ polar: angles.polar,
38
+ azimuth: angles.azimuth,
39
+ distance: surface > 0 ? surface + height * margin : 1
40
+ };
41
+ };
42
+ }
43
+ /**
44
+ * 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.
45
+ *
46
+ * The middle is the center of the box of the points. The camera is at the smallest distance that shows each point in the width and in the height of the picture.
47
+ * Thus wide points fill a wide picture. `margin` is the space around the points, as a factor of the height above the ball.
48
+ * 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.
49
+ */
50
+ function ballView(points, margin = FIT_MARGIN) {
51
+ let found;
52
+ return (frame) => {
53
+ const { extent } = frame;
54
+ const { center } = extent;
55
+ if (found === void 0 || found.center.x !== center.x || found.center.y !== center.y || found.center.z !== center.z) found = {
56
+ center,
57
+ angles: middleOf(points, center)
58
+ };
59
+ const { angles } = found;
60
+ if (angles === void 0) return capView({
61
+ polar: Math.PI / 2,
62
+ azimuth: 0
63
+ }, Math.PI / 2, margin)(frame);
64
+ const surface = surfaceOf(extent);
65
+ const height = Math.max(fitDistance(points, center, angles, frame.fieldOfView, frame.aspect) - surface, 0);
66
+ return {
67
+ target: center,
68
+ polar: angles.polar,
69
+ azimuth: angles.azimuth,
70
+ distance: surface > 0 ? surface + height * margin : 1
71
+ };
72
+ };
73
+ }
74
+ /** This function gives the direction from `center` to the middle of the box of the points. It gives `undefined` when the middle has no direction. */
75
+ function middleOf(points, center) {
76
+ const low = {
77
+ x: 1e400,
78
+ y: 1e400,
79
+ z: 1e400
80
+ };
81
+ const high = {
82
+ x: -1e400,
83
+ y: -1e400,
84
+ z: -1e400
85
+ };
86
+ for (const point of points) {
87
+ low.x = Math.min(low.x, point.x);
88
+ low.y = Math.min(low.y, point.y);
89
+ low.z = Math.min(low.z, point.z);
90
+ high.x = Math.max(high.x, point.x);
91
+ high.y = Math.max(high.y, point.y);
92
+ high.z = Math.max(high.z, point.z);
93
+ }
94
+ const middle = {
95
+ x: (low.x + high.x) / 2 - center.x,
96
+ y: (low.y + high.y) / 2 - center.y,
97
+ z: (low.z + high.z) / 2 - center.z
98
+ };
99
+ const length = Math.hypot(middle.x, middle.y, middle.z);
100
+ if (!(length > 0) || !Number.isFinite(length)) return void 0;
101
+ const { polar, azimuth } = viewOf(middle, {
102
+ x: 0,
103
+ y: 0,
104
+ z: 0
105
+ });
106
+ return {
107
+ polar,
108
+ azimuth
109
+ };
110
+ }
111
+ /** This function gives the radius of the ball around the center of an extent that holds the ball of the extent and each corner. */
112
+ function reachOf(extent) {
113
+ let reach = surfaceOf(extent);
114
+ 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));
115
+ return reach;
116
+ }
117
+ /**
118
+ * This function gives the nearest depth that a camera draws, from the distance of the camera to the center of the content.
119
+ *
120
+ * 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.
121
+ * The result is not less than the nearest depth of the limits, and it is in front of all the content.
122
+ */
123
+ function nearDepth(limits, extent, distance) {
124
+ const free = (distance - reachOf(extent)) / 8;
125
+ return free > limits.near ? Math.min(free, limits.far / 4) : limits.near;
126
+ }
127
+ /**
128
+ * This function gives the limits of the camera of a stage for a picture.
129
+ *
130
+ * 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.
131
+ * 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.
132
+ */
133
+ function stageLimits(frame, views, polar) {
134
+ const { extent } = frame;
135
+ const surface = surfaceOf(extent);
136
+ let widest = 0;
137
+ for (const view of views) widest = Math.max(widest, view(frame).distance);
138
+ if (!(widest > surface)) widest = surface + 1;
139
+ const reach = reachOf(extent);
140
+ const minDistance = extent.minDistance ?? surface + (widest - surface) * .03;
141
+ const maxDistance = Math.max(extent.maxDistance ?? surface + (widest - surface) * 3, minDistance);
142
+ const height = Math.max(minDistance - surface, 1e-6);
143
+ return {
144
+ minPolar: polar.min,
145
+ maxPolar: polar.max,
146
+ minDistance,
147
+ maxDistance,
148
+ near: height / 8,
149
+ far: (maxDistance + reach) * 1.5
150
+ };
151
+ }
152
+ export { nearDepth as a, surfaceOf as c, fitView as i, ballView as n, reachOf as o, capView as r, stageLimits as s, FIT_MARGIN as t };
153
+
154
+ //# sourceMappingURL=extent-D2SsHJnP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extent-D2SsHJnP.js","names":[],"sources":["../src/extent.ts"],"sourcesContent":["import type { Point3 } from \"@mark1russell7/layout-contract\";\nimport { capDistance, fitDistance, viewOf, type Place, type PlaceLimits, type ViewAngles } from \"./view.ts\";\n\n/** The space that the content of a stage fills. A view and the limits of the camera come from it. */\nexport interface StageExtent {\n /** The points that a view of all the content shows, for example each corner of each solid. */\n readonly corners: readonly Point3[];\n /** The point that the camera looks at. */\n readonly center: Point3;\n /**\n * The radius of the ball around the center that the camera stays out of, for example the radius of a globe.\n * The default is 0: the content has no ball.\n */\n readonly surface?: number | undefined;\n /** The smallest distance of the camera from the center. The default comes from the views of the stage. */\n readonly minDistance?: number | undefined;\n /** The largest distance of the camera from the center. The default comes from the views of the stage. */\n readonly maxDistance?: number | undefined;\n}\n\n/** The picture that a view is for: the content, and the angle and the shape of the picture. */\nexport interface ViewFrame {\n readonly extent: StageExtent;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n /** The width of the picture divided by its height. */\n readonly aspect: number;\n}\n\n/** A view of a stage: a function that gives the place of the camera for a picture. A new size of the picture gives a new place. */\nexport type StageView = (frame: ViewFrame) => Place;\n\n/** The limits of the camera of a stage: the limits of its place, and the nearest and the farthest depth that it draws. */\nexport interface StageLimits extends PlaceLimits {\n readonly near: number;\n readonly far: number;\n}\n\n/** The space around the content in a view that shows all of it, as a factor of the distance. */\nexport const FIT_MARGIN = 1.06;\n\n/** This function gives the radius of the ball around the center of an extent, or 0 for no ball. */\nexport function surfaceOf(extent: StageExtent): number {\n const surface = extent.surface ?? 0;\n return surface > 0 ? surface : 0;\n}\n\n/**\n * This function makes a view that shows each corner of the content from one direction.\n * `margin` is the space around the content, as a factor of the distance. An extent with no corners gives the distance 1.\n */\nexport function fitView(angles: ViewAngles, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const distance = fitDistance(extent.corners, extent.center, angles, fieldOfView, aspect) * margin;\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: distance > 0 ? distance : 1 };\n };\n}\n\n/**\n * This function makes a view of a part of the ball of the content: a cap around the point of the ball below the camera.\n *\n * `angles` is the direction from the center of the ball to the camera. `angle` is the angle of the cap at the center of the ball, in radians.\n * `margin` is the space around the cap, as a factor of the height above the ball. An extent with no ball gives the distance 1.\n */\nexport function capView(angles: ViewAngles, angle: number, margin: number = FIT_MARGIN): StageView {\n return ({ extent, fieldOfView, aspect }) => {\n const surface = surfaceOf(extent);\n const height = Math.max(capDistance(surface, angle, fieldOfView, aspect) - surface, 0);\n return { target: extent.center, polar: angles.polar, azimuth: angles.azimuth, distance: surface > 0 ? surface + height * margin : 1 };\n };\n}\n\n/**\n * This function makes a view of points on the ball of the content. The camera is above the middle of the points, and the picture shows each point.\n *\n * The middle is the center of the box of the points. The camera is at the smallest distance that shows each point in the width and in the height of the picture.\n * Thus wide points fill a wide picture. `margin` is the space around the points, as a factor of the height above the ball.\n * A list with no points gives a view of all of the ball from the front. Points with their middle at the center of the ball give the same view.\n */\nexport function ballView(points: readonly Point3[], margin: number = FIT_MARGIN): StageView {\n let found: { readonly center: Point3; readonly angles: ViewAngles | undefined } | undefined;\n return (frame) => {\n const { extent } = frame;\n const { center } = extent;\n // The middle is the same for each picture of one content. So the function calculates it one time for each center.\n if (found === undefined || found.center.x !== center.x || found.center.y !== center.y || found.center.z !== center.z) {\n found = { center, angles: middleOf(points, center) };\n }\n const { angles } = found;\n if (angles === undefined) return capView({ polar: Math.PI / 2, azimuth: 0 }, Math.PI / 2, margin)(frame);\n const surface = surfaceOf(extent);\n // A point of the ball needs no more distance than the outline of the ball. Thus the camera is not farther than a view of all of the ball.\n const height = Math.max(fitDistance(points, center, angles, frame.fieldOfView, frame.aspect) - surface, 0);\n return { target: center, polar: angles.polar, azimuth: angles.azimuth, distance: surface > 0 ? surface + height * margin : 1 };\n };\n}\n\n/** This function gives the direction from `center` to the middle of the box of the points. It gives `undefined` when the middle has no direction. */\nfunction middleOf(points: readonly Point3[], center: Point3): ViewAngles | undefined {\n const low = { x: Infinity, y: Infinity, z: Infinity };\n const high = { x: -Infinity, y: -Infinity, z: -Infinity };\n for (const point of points) {\n low.x = Math.min(low.x, point.x);\n low.y = Math.min(low.y, point.y);\n low.z = Math.min(low.z, point.z);\n high.x = Math.max(high.x, point.x);\n high.y = Math.max(high.y, point.y);\n high.z = Math.max(high.z, point.z);\n }\n const middle = { x: (low.x + high.x) / 2 - center.x, y: (low.y + high.y) / 2 - center.y, z: (low.z + high.z) / 2 - center.z };\n const length = Math.hypot(middle.x, middle.y, middle.z);\n if (!(length > 0) || !Number.isFinite(length)) return undefined;\n const { polar, azimuth } = viewOf(middle, { x: 0, y: 0, z: 0 });\n return { polar, azimuth };\n}\n\n/** This function gives the radius of the ball around the center of an extent that holds the ball of the extent and each corner. */\nexport function reachOf(extent: StageExtent): number {\n let reach = surfaceOf(extent);\n for (const corner of extent.corners) reach = Math.max(reach, Math.hypot(corner.x - extent.center.x, corner.y - extent.center.y, corner.z - extent.center.z));\n return reach;\n}\n\n/**\n * This function gives the nearest depth that a camera draws, from the distance of the camera to the center of the content.\n *\n * A camera far from the content gets a large value. The depths of the content then have more steps, so two surfaces that are near stay apart.\n * The result is not less than the nearest depth of the limits, and it is in front of all the content.\n */\nexport function nearDepth(limits: StageLimits, extent: StageExtent, distance: number): number {\n const free = (distance - reachOf(extent)) / 8;\n return free > limits.near ? Math.min(free, limits.far / 4) : limits.near;\n}\n\n/**\n * This function gives the limits of the camera of a stage for a picture.\n *\n * The largest distance of the views is the base. The camera goes out to 3 times this distance, and in to 3 % of the height of that view.\n * The extent can give each distance. The nearest depth is small against the height of the nearest camera, and the farthest depth is behind all the content.\n */\nexport function stageLimits(frame: ViewFrame, views: readonly StageView[], polar: { readonly min: number; readonly max: number }): StageLimits {\n const { extent } = frame;\n const surface = surfaceOf(extent);\n let widest = 0;\n for (const view of views) widest = Math.max(widest, view(frame).distance);\n if (!(widest > surface)) widest = surface + 1;\n const reach = reachOf(extent);\n const minDistance = extent.minDistance ?? surface + (widest - surface) * 0.03;\n const maxDistance = Math.max(extent.maxDistance ?? surface + (widest - surface) * 3, minDistance);\n const height = Math.max(minDistance - surface, 1e-6);\n return { minPolar: polar.min, maxPolar: polar.max, minDistance, maxDistance, near: height / 8, far: (maxDistance + reach) * 1.5 };\n}\n"],"mappings":"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"}
package/build/globe.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as StageContent } from "./stage-Bhu1f7Dw.js";
1
+ import { r as StageContent } from "./stage-DmFfah2e.js";
2
2
  import { C as ViewAngles, d as StageView, t as StageTheme } from "./theme-3EGbXXoP.js";
3
3
  import { Raycaster } from "three";
4
4
  import { LatLon, Region } from "@mark1russell7/geo";
package/build/globe.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ballView, r as capView, t as FIT_MARGIN } from "./extent-DC0qrxC5.js";
1
+ import { n as ballView, r as capView, t as FIT_MARGIN } from "./extent-D2SsHJnP.js";
2
2
  import { BufferAttribute, BufferGeometry, Color, FrontSide, Group, 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.js CHANGED
@@ -1,7 +1,8 @@
1
- import { _ as turnBetween, a as nearDepth, c as surfaceOf, d as capDistance, f as clampPlace, g as turnAcross, h as speedAt, i as fitView, l as FIELD_OF_VIEW, m as placeBetween, n as ballView, o as reachOf, p as fitDistance, r as capView, s as stageLimits, t as FIT_MARGIN, u as cameraPosition, v as viewAxes, y as viewOf } from "./extent-DC0qrxC5.js";
2
- import { a as NO_HIGHLIGHTS, c as KEY_PART, d as keyAction, i as CLICK_DISTANCE, l as KEY_TURN, n as easeInOut, o as highlightOf, r as moveAt, s as isClick, t as approach, u as KEY_ZOOM } from "./motion-dvvkaDwv.js";
1
+ import { a as nearDepth, c as surfaceOf, i as fitView, n as ballView, o as reachOf, r as capView, s as stageLimits, t as FIT_MARGIN } from "./extent-D2SsHJnP.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-BvRKIWAC.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
+ import { a as fitDistance, c as turnAcross, d as viewOf, i as clampPlace, l as turnBetween, n as cameraPosition, o as placeBetween, r as capDistance, s as speedAt, t as FIELD_OF_VIEW, u as viewAxes } from "./view-BB_EQx3I.js";
5
6
  // src/support.ts
6
7
  /**
7
8
  * This function tells if a browser can show a stage. A stage needs WebGL 2.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/support.ts"],"sourcesContent":["/**\n * This function tells if a browser can show a stage. A stage needs WebGL 2.\n *\n * A page uses it before it loads the entry `/three`. Thus a browser with no WebGL 2 shows a different picture, and it does not load `three`.\n * The function asks a canvas that is not in the page for a context, and it releases the context at once.\n * `page` is the document of the page. The default is the document of the browser. With no document, the function gives false.\n *\n * A stage can give `undefined` after this function gave true, so the page keeps its different picture ready.\n */\nexport function stageSupported(page: Document | undefined = globalThis.document): boolean {\n if (page === undefined) return false;\n try {\n const context = page.createElement(\"canvas\").getContext(\"webgl2\");\n if (context === null) return false;\n // A browser keeps only some contexts. So the function gives this one back.\n context.getExtension(\"WEBGL_lose_context\")?.loseContext();\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,SAAgB,eAAe,OAA6B,WAAW,UAAmB;CACxF,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,IAAI;EACF,MAAM,UAAU,KAAK,cAAc,QAAQ,CAAC,CAAC,WAAW,QAAQ;EAChE,IAAI,YAAY,MAAM,OAAO;EAE7B,QAAQ,aAAa,oBAAoB,CAAC,EAAE,YAAY;EACxD,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/support.ts"],"sourcesContent":["/**\n * This function tells if a browser can show a stage. A stage needs WebGL 2.\n *\n * A page uses it before it loads the entry `/three`. Thus a browser with no WebGL 2 shows a different picture, and it does not load `three`.\n * The function asks a canvas that is not in the page for a context, and it releases the context at once.\n * `page` is the document of the page. The default is the document of the browser. With no document, the function gives false.\n *\n * A stage can give `undefined` after this function gave true, so the page keeps its different picture ready.\n */\nexport function stageSupported(page: Document | undefined = globalThis.document): boolean {\n if (page === undefined) return false;\n try {\n const context = page.createElement(\"canvas\").getContext(\"webgl2\");\n if (context === null) return false;\n // A browser keeps only some contexts. So the function gives this one back.\n context.getExtension(\"WEBGL_lose_context\")?.loseContext();\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA,SAAgB,eAAe,OAA6B,WAAW,UAAmB;CACxF,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,IAAI;EACF,MAAM,UAAU,KAAK,cAAc,QAAQ,CAAC,CAAC,WAAW,QAAQ;EAChE,IAAI,YAAY,MAAM,OAAO;EAE7B,QAAQ,aAAa,oBAAoB,CAAC,EAAE,YAAY;EACxD,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF"}
package/build/labels.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as StageContent } from "./stage-Bhu1f7Dw.js";
1
+ import { r as StageContent } from "./stage-DmFfah2e.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.
@@ -0,0 +1,98 @@
1
+ import { addPoints3, cross3, scalePoint3 } from "@mark1russell7/layout-contract";
2
+ // src/marks/levels.ts
3
+ /** These are the levels of a mark, from the lowest to the highest. */
4
+ const LEVELS = [
5
+ "unknown",
6
+ "ok",
7
+ "near",
8
+ "over"
9
+ ];
10
+ /**
11
+ * This function gives the rank of a level: 0 for `unknown` and 3 for `over`.
12
+ * A viewer draws the marks in the sequence of their ranks, so the worst level is always in view.
13
+ */
14
+ function levelRank(level) {
15
+ return LEVELS.indexOf(level);
16
+ }
17
+ /** These are the shapes of the sign of a level. */
18
+ const LEVEL_SHAPES = [
19
+ "ring",
20
+ "disc",
21
+ "triangle",
22
+ "square"
23
+ ];
24
+ /**
25
+ * This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.
26
+ * The level `unknown` has a ring, and so has a record with no level.
27
+ */
28
+ function levelShape(level) {
29
+ return level === "ok" ? "disc" : level === "near" ? "triangle" : level === "over" ? "square" : "ring";
30
+ }
31
+ /**
32
+ * The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.
33
+ * A triangle and a square with the radius of the disc look small, so they are larger.
34
+ */
35
+ const SHAPE_OUTLINES = {
36
+ ring: {
37
+ radius: 1,
38
+ sides: 40,
39
+ start: 0,
40
+ hole: .52
41
+ },
42
+ disc: {
43
+ radius: 1,
44
+ sides: 40,
45
+ start: 0,
46
+ hole: 0
47
+ },
48
+ triangle: {
49
+ radius: 1.3,
50
+ sides: 3,
51
+ start: Math.PI / 2,
52
+ hole: 0
53
+ },
54
+ square: {
55
+ radius: 1.25,
56
+ sides: 4,
57
+ start: Math.PI / 4,
58
+ hole: 0
59
+ }
60
+ };
61
+ /**
62
+ * This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.
63
+ * The center of the sign is the origin, and `radius` is the radius of a disc.
64
+ */
65
+ function shapeRing(shape, radius = 1) {
66
+ const outline = SHAPE_OUTLINES[shape];
67
+ return Array.from({ length: outline.sides }, (_, index) => {
68
+ const angle = outline.start + index * 2 * Math.PI / outline.sides;
69
+ return [radius * outline.radius * Math.cos(angle), radius * outline.radius * Math.sin(angle)];
70
+ });
71
+ }
72
+ // src/marks/mark.ts
73
+ /** These are the types of a mark. */
74
+ const MARK_TYPES = [
75
+ "point",
76
+ "run",
77
+ "link",
78
+ "field",
79
+ "meter"
80
+ ];
81
+ /** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */
82
+ function fieldRowStep(field) {
83
+ return cross3(field.frame.out, field.across);
84
+ }
85
+ /** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */
86
+ function fieldCellCenter(field, column, row) {
87
+ const across = scalePoint3(field.across, (column + .5) * field.cell);
88
+ const down = scalePoint3(fieldRowStep(field), (row + .5) * field.cell);
89
+ return addPoints3(field.frame.at, addPoints3(across, down));
90
+ }
91
+ /** This function gives the value of a cell of a field. A cell with no value gives `null`, and so does a cell that is not in the grid. */
92
+ function fieldValue(field, column, row) {
93
+ if (!Number.isInteger(column) || !Number.isInteger(row) || column < 0 || row < 0 || column >= field.columns || row >= field.rows) return null;
94
+ return field.values[row * field.columns + column] ?? null;
95
+ }
96
+ export { LEVELS as a, levelRank as c, fieldValue as i, levelShape as l, fieldCellCenter as n, LEVEL_SHAPES as o, fieldRowStep as r, SHAPE_OUTLINES as s, MARK_TYPES as t, shapeRing as u };
97
+
98
+ //# sourceMappingURL=mark-AZ5AuAIJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mark-AZ5AuAIJ.js","names":[],"sources":["../src/marks/levels.ts","../src/marks/mark.ts"],"sourcesContent":["import type { Ring } from \"@mark1russell7/layout-contract\";\n\n/** These are the levels of a mark, from the lowest to the highest. */\nexport const LEVELS: readonly [\"unknown\", \"ok\", \"near\", \"over\"] = [\"unknown\", \"ok\", \"near\", \"over\"];\n\n/**\n * A level of a mark, in the scale of limits. `ok` is below a limit, `near` is near it and `over` is above it.\n * A mark with no known value has `unknown`. The producer of a mark calculates the level, because each topic has its own limits.\n */\nexport type Level = (typeof LEVELS)[number];\n\n/**\n * This function gives the rank of a level: 0 for `unknown` and 3 for `over`.\n * A viewer draws the marks in the sequence of their ranks, so the worst level is always in view.\n */\nexport function levelRank(level: Level): number {\n return LEVELS.indexOf(level);\n}\n\n/** These are the shapes of the sign of a level. */\nexport const LEVEL_SHAPES: readonly [\"ring\", \"disc\", \"triangle\", \"square\"] = [\"ring\", \"disc\", \"triangle\", \"square\"];\n\n/** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */\nexport type LevelShape = (typeof LEVEL_SHAPES)[number];\n\n/**\n * This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.\n * The level `unknown` has a ring, and so has a record with no level.\n */\nexport function levelShape(level: Level | undefined): LevelShape {\n return level === \"ok\" ? \"disc\" : level === \"near\" ? \"triangle\" : level === \"over\" ? \"square\" : \"ring\";\n}\n\n/** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */\nexport interface ShapeOutline {\n /** The radius of the circle through the corners, for a disc with the radius 1. */\n readonly radius: number;\n /** The number of the sides. */\n readonly sides: number;\n /** The angle of the first corner, in radians, counter-clockwise from the x axis. */\n readonly start: number;\n /** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */\n readonly hole: number;\n}\n\n/**\n * The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.\n * A triangle and a square with the radius of the disc look small, so they are larger.\n */\nexport const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>> = {\n ring: { radius: 1, sides: 40, start: 0, hole: 0.52 },\n disc: { radius: 1, sides: 40, start: 0, hole: 0 },\n triangle: { radius: 1.3, sides: 3, start: Math.PI / 2, hole: 0 },\n square: { radius: 1.25, sides: 4, start: Math.PI / 4, hole: 0 },\n};\n\n/**\n * This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.\n * The center of the sign is the origin, and `radius` is the radius of a disc.\n */\nexport function shapeRing(shape: LevelShape, radius: number = 1): Ring {\n const outline = SHAPE_OUTLINES[shape];\n return Array.from({ length: outline.sides }, (_, index): readonly [number, number] => {\n const angle = outline.start + (index * 2 * Math.PI) / outline.sides;\n return [radius * outline.radius * Math.cos(angle), radius * outline.radius * Math.sin(angle)];\n });\n}\n","import { addPoints3, cross3, scalePoint3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport type { Level } from \"./levels.ts\";\n\n/** A point of a surface, and the direction out of the surface. */\nexport interface Frame {\n /** The point. */\n readonly at: Point3;\n /** The unit vector out of the surface at the point. */\n readonly out: Point3;\n}\n\n/** These are the types of a mark. */\nexport const MARK_TYPES: readonly [\"point\", \"run\", \"link\", \"field\", \"meter\"] = [\"point\", \"run\", \"link\", \"field\", \"meter\"];\n\n/** A type of a mark. */\nexport type MarkType = (typeof MARK_TYPES)[number];\n\n/**\n * The parts that each mark has. A mark has no shape and no color.\n * A viewer gets the shape from the level, and the color from the level and its theme. Thus a mark does not use color alone.\n */\nexport interface MarkBase {\n /** The name of the record of the mark. The pointer and the selection of a viewer use this name. */\n readonly record: string;\n /** A word of the producer for the legend and the filter, for example `outlet`. */\n readonly kind: string;\n /** The level of the mark. The producer calculates it. */\n readonly level: Level;\n /** One line of text: the name of the mark for a person and for a screen reader. */\n readonly label: string;\n}\n\n/** A mark at one point of a surface, for example an outlet, a tap or a lamp. */\nexport interface PointMark extends MarkBase {\n readonly type: \"point\";\n /** The point, and the direction out of its surface. */\n readonly frame: Frame;\n /** The width of the sign, in the unit of the space. A mark with no size gets the default size of the viewer. */\n readonly size?: number | undefined;\n}\n\n/** A mark along a path on surfaces, for example a cable, a pipe or a duct. */\nexport interface RunMark extends MarkBase {\n readonly type: \"run\";\n /** The points of the path, in sequence. Each point has its own direction, so a run can go across surfaces. A path has 2 or more points. */\n readonly path: readonly Frame[];\n /** The width of the run, in the unit of the space. */\n readonly width: number;\n}\n\n/** One end of a link. */\nexport interface LinkEnd {\n /** The name of the record at this end. A viewer shows the link when the record of one end is selected or under the pointer. */\n readonly record: string;\n /** The point of this end. */\n readonly at: Point3;\n}\n\n/** A mark between two records, for example a power line from an outlet to a computer. */\nexport interface LinkMark extends MarkBase {\n readonly type: \"link\";\n readonly from: LinkEnd;\n readonly to: LinkEnd;\n}\n\n/** The scale of the values of a field. The theme of a viewer gives the colors from `min` to `max`. */\nexport interface FieldScale {\n /** The value of the first color. It is less than `max`. */\n readonly min: number;\n /** The value of the last color. */\n readonly max: number;\n /** The text of the unit of the values, for example `lx`. */\n readonly unit: string;\n}\n\n/** A grid of values on a plane, for example the light on a floor or the heat of a wall. */\nexport interface FieldMark extends MarkBase {\n readonly type: \"field\";\n /** The corner of the first cell, and the direction out of the plane. */\n readonly frame: Frame;\n /** The unit vector of a column step, in the plane. The step of a row is the cross product of `frame.out` and `across`. */\n readonly across: Point3;\n /** The length of a side of a cell, in the unit of the space. */\n readonly cell: number;\n /** The number of the columns. */\n readonly columns: number;\n /** The number of the rows. */\n readonly rows: number;\n /**\n * The values, row by row. The value of the column `c` and the row `r` has the index `r * columns + c`.\n * A cell with no value has `null`, because JSON has no NaN.\n */\n readonly values: readonly (number | null)[];\n readonly scale: FieldScale;\n}\n\n/**\n * A value against a limit, for example the load of a circuit. A meter has no place.\n * A page draws it in a panel, and a 3D view ignores it.\n */\nexport interface MeterMark extends MarkBase {\n readonly type: \"meter\";\n readonly value: number;\n /**\n * The limit of the value. A meter with no limit has no `limit`, for example a circuit with a known load and no known breaker.\n * A page shows only the value and the unit of that meter. A limit of 0 is a real limit, so it is not a sign for no limit.\n */\n readonly limit?: number | undefined;\n /** The text of the unit of the value and of the limit, for example `W`. */\n readonly unit: string;\n}\n\n/**\n * A record that a viewer draws. A mark is plain data with no topic, so it goes through JSON with no change.\n * Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.\n */\nexport type Mark = PointMark | RunMark | LinkMark | FieldMark | MeterMark;\n\n/** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */\nexport function fieldRowStep(field: FieldMark): Point3 {\n return cross3(field.frame.out, field.across);\n}\n\n/** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */\nexport function fieldCellCenter(field: FieldMark, column: number, row: number): Point3 {\n const across = scalePoint3(field.across, (column + 0.5) * field.cell);\n const down = scalePoint3(fieldRowStep(field), (row + 0.5) * field.cell);\n return addPoints3(field.frame.at, addPoints3(across, down));\n}\n\n/** This function gives the value of a cell of a field. A cell with no value gives `null`, and so does a cell that is not in the grid. */\nexport function fieldValue(field: FieldMark, column: number, row: number): number | null {\n if (!Number.isInteger(column) || !Number.isInteger(row) || column < 0 || row < 0 || column >= field.columns || row >= field.rows) return null;\n return field.values[row * field.columns + column] ?? null;\n}\n"],"mappings":";;;AAGA,MAAa,SAAqD;CAAC;CAAW;CAAM;CAAQ;AAAM;;;;;AAYlG,SAAgB,UAAU,OAAsB;CAC9C,OAAO,OAAO,QAAQ,KAAK;AAC7B;;AAGA,MAAa,eAAgE;CAAC;CAAQ;CAAQ;CAAY;AAAQ;;;;;AASlH,SAAgB,WAAW,OAAsC;CAC/D,OAAO,UAAU,OAAO,SAAS,UAAU,SAAS,aAAa,UAAU,SAAS,WAAW;AACjG;;;;;AAkBA,MAAa,iBAA6D;CACxE,MAAM;EAAE,QAAQ;EAAG,OAAO;EAAI,OAAO;EAAG,MAAM;CAAK;CACnD,MAAM;EAAE,QAAQ;EAAG,OAAO;EAAI,OAAO;EAAG,MAAM;CAAE;CAChD,UAAU;EAAE,QAAQ;EAAK,OAAO;EAAG,OAAO,KAAK,KAAK;EAAG,MAAM;CAAE;CAC/D,QAAQ;EAAE,QAAQ;EAAM,OAAO;EAAG,OAAO,KAAK,KAAK;EAAG,MAAM;CAAE;AAChE;;;;;AAMA,SAAgB,UAAU,OAAmB,SAAiB,GAAS;CACrE,MAAM,UAAU,eAAe;CAC/B,OAAO,MAAM,KAAK,EAAE,QAAQ,QAAQ,MAAM,IAAI,GAAG,UAAqC;EACpF,MAAM,QAAQ,QAAQ,QAAS,QAAQ,IAAI,KAAK,KAAM,QAAQ;EAC9D,OAAO,CAAC,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,GAAG,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,CAAC;CAC9F,CAAC;AACH;;;ACtDA,MAAa,aAAkE;CAAC;CAAS;CAAO;CAAQ;CAAS;AAAO;;AA2GxH,SAAgB,aAAa,OAA0B;CACrD,OAAO,OAAO,MAAM,MAAM,KAAK,MAAM,MAAM;AAC7C;;AAGA,SAAgB,gBAAgB,OAAkB,QAAgB,KAAqB;CACrF,MAAM,SAAS,YAAY,MAAM,SAAS,SAAS,MAAO,MAAM,IAAI;CACpE,MAAM,OAAO,YAAY,aAAa,KAAK,IAAI,MAAM,MAAO,MAAM,IAAI;CACtE,OAAO,WAAW,MAAM,MAAM,IAAI,WAAW,QAAQ,IAAI,CAAC;AAC5D;;AAGA,SAAgB,WAAW,OAAkB,QAAgB,KAA4B;CACvF,IAAI,CAAC,OAAO,UAAU,MAAM,KAAK,CAAC,OAAO,UAAU,GAAG,KAAK,SAAS,KAAK,MAAM,KAAK,UAAU,MAAM,WAAW,OAAO,MAAM,MAAM,OAAO;CACzI,OAAO,MAAM,OAAO,MAAM,MAAM,UAAU,WAAW;AACvD"}
@@ -0,0 +1,154 @@
1
+ import { Point3, Ring } from "@mark1russell7/layout-contract";
2
+ /** These are the levels of a mark, from the lowest to the highest. */
3
+ declare const LEVELS: readonly ["unknown", "ok", "near", "over"];
4
+ /**
5
+ * A level of a mark, in the scale of limits. `ok` is below a limit, `near` is near it and `over` is above it.
6
+ * A mark with no known value has `unknown`. The producer of a mark calculates the level, because each topic has its own limits.
7
+ */
8
+ type Level = (typeof LEVELS)[number];
9
+ /**
10
+ * This function gives the rank of a level: 0 for `unknown` and 3 for `over`.
11
+ * A viewer draws the marks in the sequence of their ranks, so the worst level is always in view.
12
+ */
13
+ declare function levelRank(level: Level): number;
14
+ /** These are the shapes of the sign of a level. */
15
+ declare const LEVEL_SHAPES: readonly ["ring", "disc", "triangle", "square"];
16
+ /** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */
17
+ type LevelShape = (typeof LEVEL_SHAPES)[number];
18
+ /**
19
+ * This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.
20
+ * The level `unknown` has a ring, and so has a record with no level.
21
+ */
22
+ declare function levelShape(level: Level | undefined): LevelShape;
23
+ /** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */
24
+ interface ShapeOutline {
25
+ /** The radius of the circle through the corners, for a disc with the radius 1. */
26
+ readonly radius: number;
27
+ /** The number of the sides. */
28
+ readonly sides: number;
29
+ /** The angle of the first corner, in radians, counter-clockwise from the x axis. */
30
+ readonly start: number;
31
+ /** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */
32
+ readonly hole: number;
33
+ }
34
+ /**
35
+ * The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.
36
+ * A triangle and a square with the radius of the disc look small, so they are larger.
37
+ */
38
+ declare const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>>;
39
+ /**
40
+ * This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.
41
+ * The center of the sign is the origin, and `radius` is the radius of a disc.
42
+ */
43
+ declare function shapeRing(shape: LevelShape, radius?: number): Ring;
44
+ /** A point of a surface, and the direction out of the surface. */
45
+ interface Frame {
46
+ /** The point. */
47
+ readonly at: Point3;
48
+ /** The unit vector out of the surface at the point. */
49
+ readonly out: Point3;
50
+ }
51
+ /** These are the types of a mark. */
52
+ declare const MARK_TYPES: readonly ["point", "run", "link", "field", "meter"];
53
+ /** A type of a mark. */
54
+ type MarkType = (typeof MARK_TYPES)[number];
55
+ /**
56
+ * The parts that each mark has. A mark has no shape and no color.
57
+ * A viewer gets the shape from the level, and the color from the level and its theme. Thus a mark does not use color alone.
58
+ */
59
+ interface MarkBase {
60
+ /** The name of the record of the mark. The pointer and the selection of a viewer use this name. */
61
+ readonly record: string;
62
+ /** A word of the producer for the legend and the filter, for example `outlet`. */
63
+ readonly kind: string;
64
+ /** The level of the mark. The producer calculates it. */
65
+ readonly level: Level;
66
+ /** One line of text: the name of the mark for a person and for a screen reader. */
67
+ readonly label: string;
68
+ }
69
+ /** A mark at one point of a surface, for example an outlet, a tap or a lamp. */
70
+ interface PointMark extends MarkBase {
71
+ readonly type: "point";
72
+ /** The point, and the direction out of its surface. */
73
+ readonly frame: Frame;
74
+ /** The width of the sign, in the unit of the space. A mark with no size gets the default size of the viewer. */
75
+ readonly size?: number | undefined;
76
+ }
77
+ /** A mark along a path on surfaces, for example a cable, a pipe or a duct. */
78
+ interface RunMark extends MarkBase {
79
+ readonly type: "run";
80
+ /** The points of the path, in sequence. Each point has its own direction, so a run can go across surfaces. A path has 2 or more points. */
81
+ readonly path: readonly Frame[];
82
+ /** The width of the run, in the unit of the space. */
83
+ readonly width: number;
84
+ }
85
+ /** One end of a link. */
86
+ interface LinkEnd {
87
+ /** The name of the record at this end. A viewer shows the link when the record of one end is selected or under the pointer. */
88
+ readonly record: string;
89
+ /** The point of this end. */
90
+ readonly at: Point3;
91
+ }
92
+ /** A mark between two records, for example a power line from an outlet to a computer. */
93
+ interface LinkMark extends MarkBase {
94
+ readonly type: "link";
95
+ readonly from: LinkEnd;
96
+ readonly to: LinkEnd;
97
+ }
98
+ /** The scale of the values of a field. The theme of a viewer gives the colors from `min` to `max`. */
99
+ interface FieldScale {
100
+ /** The value of the first color. It is less than `max`. */
101
+ readonly min: number;
102
+ /** The value of the last color. */
103
+ readonly max: number;
104
+ /** The text of the unit of the values, for example `lx`. */
105
+ readonly unit: string;
106
+ }
107
+ /** A grid of values on a plane, for example the light on a floor or the heat of a wall. */
108
+ interface FieldMark extends MarkBase {
109
+ readonly type: "field";
110
+ /** The corner of the first cell, and the direction out of the plane. */
111
+ readonly frame: Frame;
112
+ /** The unit vector of a column step, in the plane. The step of a row is the cross product of `frame.out` and `across`. */
113
+ readonly across: Point3;
114
+ /** The length of a side of a cell, in the unit of the space. */
115
+ readonly cell: number;
116
+ /** The number of the columns. */
117
+ readonly columns: number;
118
+ /** The number of the rows. */
119
+ readonly rows: number;
120
+ /**
121
+ * The values, row by row. The value of the column `c` and the row `r` has the index `r * columns + c`.
122
+ * A cell with no value has `null`, because JSON has no NaN.
123
+ */
124
+ readonly values: readonly (number | null)[];
125
+ readonly scale: FieldScale;
126
+ }
127
+ /**
128
+ * A value against a limit, for example the load of a circuit. A meter has no place.
129
+ * A page draws it in a panel, and a 3D view ignores it.
130
+ */
131
+ interface MeterMark extends MarkBase {
132
+ readonly type: "meter";
133
+ readonly value: number;
134
+ /**
135
+ * The limit of the value. A meter with no limit has no `limit`, for example a circuit with a known load and no known breaker.
136
+ * A page shows only the value and the unit of that meter. A limit of 0 is a real limit, so it is not a sign for no limit.
137
+ */
138
+ readonly limit?: number | undefined;
139
+ /** The text of the unit of the value and of the limit, for example `W`. */
140
+ readonly unit: string;
141
+ }
142
+ /**
143
+ * A record that a viewer draws. A mark is plain data with no topic, so it goes through JSON with no change.
144
+ * Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.
145
+ */
146
+ type Mark = PointMark | RunMark | LinkMark | FieldMark | MeterMark;
147
+ /** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */
148
+ declare function fieldRowStep(field: FieldMark): Point3;
149
+ /** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */
150
+ declare function fieldCellCenter(field: FieldMark, column: number, row: number): Point3;
151
+ /** This function gives the value of a cell of a field. A cell with no value gives `null`, and so does a cell that is not in the grid. */
152
+ declare function fieldValue(field: FieldMark, column: number, row: number): number | null;
153
+ export { levelShape as C, levelRank as S, LEVEL_SHAPES as _, LinkMark as a, SHAPE_OUTLINES as b, MarkBase as c, PointMark as d, RunMark as f, LEVELS as g, fieldValue as h, LinkEnd as i, MarkType as l, fieldRowStep as m, FieldScale as n, MARK_TYPES as o, fieldCellCenter as p, Frame as r, Mark as s, FieldMark as t, MeterMark as u, Level as v, shapeRing as w, ShapeOutline as x, LevelShape as y };
154
+ //# sourceMappingURL=mark-D8AdQYAS.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mark-D8AdQYAS.d.ts","names":[],"sources":["../src/marks/levels.ts","../src/marks/mark.ts"],"mappings":";;cAGa;;;;;KAMD,gBAAgB;;;;;iBAMZ,UAAU,OAAO;;cAKpB;;KAGD,qBAAqB;;;;;iBAMjB,WAAW,OAAO,oBAAoB;;UAKrC;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;cAOE,gBAAgB,SAAS,OAAO,YAAY;;;;;iBAWzC,UAAU,OAAO,YAAY,kBAAqB;;UCxDjD;;WAEN,IAAI;;WAEJ,KAAK;;;cAIH;;KAGD,mBAAmB;;;;;UAMd;;WAEN;;WAEA;;WAEA,OAAO;;WAEP;;;UAIM,kBAAkB;WACxB;;WAEA,OAAO;;WAEP;;;UAIM,gBAAgB;WACtB;;WAEA,eAAe;;WAEf;;;UAIM;;WAEN;;WAEA,IAAI;;;UAIE,iBAAiB;WACvB;WACA,MAAM;WACN,IAAI;;;UAIE;;WAEN;;WAEA;;WAEA;;;UAIM,kBAAkB;WACxB;;WAEA,OAAO;;WAEP,QAAQ;;WAER;;WAEA;;WAEA;;;;;WAKA;WACA,OAAO;;;;;;UAOD,kBAAkB;WACxB;WACA;;;;;WAKA;;WAEA;;;;;;KAOC,OAAO,YAAY,UAAU,WAAW,YAAY;;iBAGhD,aAAa,OAAO,YAAY;;iBAKhC,gBAAgB,OAAO,WAAW,gBAAgB,cAAc;;iBAOhE,WAAW,OAAO,WAAW,gBAAgB"}