@mark1russell7/visuals 0.1.1 → 0.2.0

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/build/marks.js ADDED
@@ -0,0 +1,231 @@
1
+ import { addPoints3, cross3, dot3, length3, 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/check.ts
73
+ /**
74
+ * These are the codes of the faults of a mark:
75
+ * - `type`: the type of the mark is not known. A list from a later version of a producer can have a new type.
76
+ * - `level`: the level of the mark is not known.
77
+ * - `name`: a record name or the kind is empty.
78
+ * - `label`: the label is empty, or it has more than one line.
79
+ * - `number`: a number is not finite.
80
+ * - `direction`: a direction is not a unit vector.
81
+ * - `angle`: the column step of a field is not at a right angle to the direction out of its plane.
82
+ * - `size`: a size, a width or a cell is not more than 0.
83
+ * - `grid`: the number of the columns or of the rows of a field is not a whole number of 1 or more.
84
+ * - `values`: a field does not have one value for each cell.
85
+ * - `scale`: the `min` of the scale of a field is not less than its `max`.
86
+ * - `path`: a run has fewer than 2 points.
87
+ */
88
+ const MARK_FAULT_CODES = [
89
+ "type",
90
+ "level",
91
+ "name",
92
+ "label",
93
+ "number",
94
+ "direction",
95
+ "angle",
96
+ "size",
97
+ "grid",
98
+ "values",
99
+ "scale",
100
+ "path"
101
+ ];
102
+ /**
103
+ * The tolerance of a direction. A unit vector has the length 1 with this tolerance.
104
+ * Two directions are at a right angle when their dot product is 0 with this tolerance.
105
+ */
106
+ const DIRECTION_TOLERANCE = 1e-6;
107
+ /**
108
+ * This function gives the faults of a list of marks, in the sequence of the list. A list with no fault gives an empty list.
109
+ * It examines the values that the types do not hold: finite numbers, unit vectors, sizes, the grid of a field and the names.
110
+ * A producer of marks uses it as a gate in its tests, and a viewer uses it on a list that it did not make.
111
+ * It does not examine the form of a mark: read a list from JSON through a schema first.
112
+ */
113
+ function checkMarks(marks) {
114
+ const faults = [];
115
+ marks.forEach((mark, index) => {
116
+ const fault = (code, part, message) => {
117
+ faults.push({
118
+ code,
119
+ index,
120
+ record: mark.record,
121
+ part,
122
+ message
123
+ });
124
+ };
125
+ const finite = (part, value) => {
126
+ if (Number.isFinite(value)) return true;
127
+ fault("number", part, `${part} is not a finite number: ${String(value)}`);
128
+ return false;
129
+ };
130
+ const point = (part, value) => {
131
+ const x = finite(`${part}.x`, value.x);
132
+ const y = finite(`${part}.y`, value.y);
133
+ const z = finite(`${part}.z`, value.z);
134
+ return x && y && z;
135
+ };
136
+ const direction = (part, value) => {
137
+ if (!point(part, value)) return false;
138
+ const length = length3(value);
139
+ if (Math.abs(length - 1) <= 1e-6) return true;
140
+ fault("direction", part, `${part} is not a unit vector: its length is ${String(length)}`);
141
+ return false;
142
+ };
143
+ const frame = (part, value) => {
144
+ const at = point(`${part}.at`, value.at);
145
+ const out = direction(`${part}.out`, value.out);
146
+ return at && out;
147
+ };
148
+ const positive = (part, value) => {
149
+ if (finite(part, value) && value <= 0) fault("size", part, `${part} is not more than 0: ${String(value)}`);
150
+ };
151
+ const count = (part, value) => {
152
+ if (Number.isInteger(value) && value >= 1) return true;
153
+ fault("grid", part, `${part} is not a whole number of 1 or more: ${String(value)}`);
154
+ return false;
155
+ };
156
+ if (mark.record === "") fault("name", "record", "the mark has no record name");
157
+ if (mark.kind === "") fault("name", "kind", "the mark has no kind");
158
+ if (!LEVELS.includes(mark.level)) fault("level", "level", `the level is not known: ${String(mark.level)}`);
159
+ if (mark.label.trim() === "") fault("label", "label", "the mark has no label");
160
+ else if (/[\r\n]/.test(mark.label)) fault("label", "label", "the label has more than one line");
161
+ switch (mark.type) {
162
+ case "point":
163
+ frame("frame", mark.frame);
164
+ if (mark.size !== void 0) positive("size", mark.size);
165
+ break;
166
+ case "run":
167
+ if (mark.path.length < 2) fault("path", "path", `the path has ${String(mark.path.length)} points, and a run needs 2 or more`);
168
+ mark.path.forEach((step, at) => frame(`path[${String(at)}]`, step));
169
+ positive("width", mark.width);
170
+ break;
171
+ case "link":
172
+ for (const [name, end] of [["from", mark.from], ["to", mark.to]]) {
173
+ if (end.record === "") fault("name", `${name}.record`, `the end ${name} has no record name`);
174
+ point(`${name}.at`, end.at);
175
+ }
176
+ break;
177
+ case "field": {
178
+ const hasFrame = frame("frame", mark.frame);
179
+ const hasAcross = direction("across", mark.across);
180
+ if (hasFrame && hasAcross) {
181
+ const dot = dot3(mark.frame.out, mark.across);
182
+ if (Math.abs(dot) > 1e-6) fault("angle", "across", `across is not at a right angle to frame.out: their dot product is ${String(dot)}`);
183
+ }
184
+ positive("cell", mark.cell);
185
+ const hasColumns = count("columns", mark.columns);
186
+ const hasRows = count("rows", mark.rows);
187
+ if (hasColumns && hasRows && mark.values.length !== mark.columns * mark.rows) fault("values", "values", `the field has ${String(mark.values.length)} values, and ${String(mark.columns)} columns of ${String(mark.rows)} rows need ${String(mark.columns * mark.rows)}`);
188
+ const bad = mark.values.flatMap((value, at) => value === null || Number.isFinite(value) ? [] : [at]);
189
+ const first = bad[0];
190
+ if (first !== void 0) fault("number", `values[${String(first)}]`, `${String(bad.length)} of the values are not finite numbers, the first is values[${String(first)}]: ${String(mark.values[first])}`);
191
+ const hasMin = finite("scale.min", mark.scale.min);
192
+ const hasMax = finite("scale.max", mark.scale.max);
193
+ if (hasMin && hasMax && mark.scale.min >= mark.scale.max) fault("scale", "scale", `scale.min is not less than scale.max: ${String(mark.scale.min)} and ${String(mark.scale.max)}`);
194
+ break;
195
+ }
196
+ case "meter":
197
+ finite("value", mark.value);
198
+ finite("limit", mark.limit);
199
+ break;
200
+ default: fault("type", "type", `the type is not known: ${String(mark.type)}`);
201
+ }
202
+ });
203
+ return faults;
204
+ }
205
+ // src/marks/mark.ts
206
+ /** These are the types of a mark. */
207
+ const MARK_TYPES = [
208
+ "point",
209
+ "run",
210
+ "link",
211
+ "field",
212
+ "meter"
213
+ ];
214
+ /** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */
215
+ function fieldRowStep(field) {
216
+ return cross3(field.frame.out, field.across);
217
+ }
218
+ /** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */
219
+ function fieldCellCenter(field, column, row) {
220
+ const across = scalePoint3(field.across, (column + .5) * field.cell);
221
+ const down = scalePoint3(fieldRowStep(field), (row + .5) * field.cell);
222
+ return addPoints3(field.frame.at, addPoints3(across, down));
223
+ }
224
+ /** 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. */
225
+ function fieldValue(field, column, row) {
226
+ if (!Number.isInteger(column) || !Number.isInteger(row) || column < 0 || row < 0 || column >= field.columns || row >= field.rows) return null;
227
+ return field.values[row * field.columns + column] ?? null;
228
+ }
229
+ export { DIRECTION_TOLERANCE, LEVELS, LEVEL_SHAPES, MARK_FAULT_CODES, MARK_TYPES, SHAPE_OUTLINES, checkMarks, fieldCellCenter, fieldRowStep, fieldValue, levelRank, levelShape, shapeRing };
230
+
231
+ //# sourceMappingURL=marks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marks.js","names":[],"sources":["../src/marks/levels.ts","../src/marks/check.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 { dot3, length3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport { LEVELS } from \"./levels.ts\";\nimport type { Frame, Mark } from \"./mark.ts\";\n\n/**\n * These are the codes of the faults of a mark:\n * - `type`: the type of the mark is not known. A list from a later version of a producer can have a new type.\n * - `level`: the level of the mark is not known.\n * - `name`: a record name or the kind is empty.\n * - `label`: the label is empty, or it has more than one line.\n * - `number`: a number is not finite.\n * - `direction`: a direction is not a unit vector.\n * - `angle`: the column step of a field is not at a right angle to the direction out of its plane.\n * - `size`: a size, a width or a cell is not more than 0.\n * - `grid`: the number of the columns or of the rows of a field is not a whole number of 1 or more.\n * - `values`: a field does not have one value for each cell.\n * - `scale`: the `min` of the scale of a field is not less than its `max`.\n * - `path`: a run has fewer than 2 points.\n */\nexport const MARK_FAULT_CODES: readonly [\"type\", \"level\", \"name\", \"label\", \"number\", \"direction\", \"angle\", \"size\", \"grid\", \"values\", \"scale\", \"path\"] = [\n \"type\",\n \"level\",\n \"name\",\n \"label\",\n \"number\",\n \"direction\",\n \"angle\",\n \"size\",\n \"grid\",\n \"values\",\n \"scale\",\n \"path\",\n];\n\n/** A code of a fault of a mark. */\nexport type MarkFaultCode = (typeof MARK_FAULT_CODES)[number];\n\n/** One fault of a mark of a list. */\nexport interface MarkFault {\n readonly code: MarkFaultCode;\n /** The index of the mark in the list. */\n readonly index: number;\n /** The record name of the mark. */\n readonly record: string;\n /** The part of the mark with the fault, for example `path[2].out`. */\n readonly part: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n}\n\n/**\n * The tolerance of a direction. A unit vector has the length 1 with this tolerance.\n * Two directions are at a right angle when their dot product is 0 with this tolerance.\n */\nexport const DIRECTION_TOLERANCE = 1e-6;\n\n/**\n * This function gives the faults of a list of marks, in the sequence of the list. A list with no fault gives an empty list.\n * It examines the values that the types do not hold: finite numbers, unit vectors, sizes, the grid of a field and the names.\n * A producer of marks uses it as a gate in its tests, and a viewer uses it on a list that it did not make.\n * It does not examine the form of a mark: read a list from JSON through a schema first.\n */\nexport function checkMarks(marks: readonly Mark[]): readonly MarkFault[] {\n const faults: MarkFault[] = [];\n marks.forEach((mark, index) => {\n const fault = (code: MarkFaultCode, part: string, message: string): void => {\n faults.push({ code, index, record: mark.record, part, message });\n };\n const finite = (part: string, value: number): boolean => {\n if (Number.isFinite(value)) return true;\n fault(\"number\", part, `${part} is not a finite number: ${String(value)}`);\n return false;\n };\n const point = (part: string, value: Point3): boolean => {\n const x = finite(`${part}.x`, value.x);\n const y = finite(`${part}.y`, value.y);\n const z = finite(`${part}.z`, value.z);\n return x && y && z;\n };\n const direction = (part: string, value: Point3): boolean => {\n if (!point(part, value)) return false;\n const length = length3(value);\n if (Math.abs(length - 1) <= DIRECTION_TOLERANCE) return true;\n fault(\"direction\", part, `${part} is not a unit vector: its length is ${String(length)}`);\n return false;\n };\n const frame = (part: string, value: Frame): boolean => {\n const at = point(`${part}.at`, value.at);\n const out = direction(`${part}.out`, value.out);\n return at && out;\n };\n const positive = (part: string, value: number): void => {\n if (finite(part, value) && value <= 0) fault(\"size\", part, `${part} is not more than 0: ${String(value)}`);\n };\n const count = (part: string, value: number): boolean => {\n if (Number.isInteger(value) && value >= 1) return true;\n fault(\"grid\", part, `${part} is not a whole number of 1 or more: ${String(value)}`);\n return false;\n };\n\n if (mark.record === \"\") fault(\"name\", \"record\", \"the mark has no record name\");\n if (mark.kind === \"\") fault(\"name\", \"kind\", \"the mark has no kind\");\n if (!(LEVELS as readonly string[]).includes(mark.level)) fault(\"level\", \"level\", `the level is not known: ${String(mark.level)}`);\n if (mark.label.trim() === \"\") fault(\"label\", \"label\", \"the mark has no label\");\n else if (/[\\r\\n]/.test(mark.label)) fault(\"label\", \"label\", \"the label has more than one line\");\n\n switch (mark.type) {\n case \"point\":\n frame(\"frame\", mark.frame);\n if (mark.size !== undefined) positive(\"size\", mark.size);\n break;\n case \"run\":\n if (mark.path.length < 2) fault(\"path\", \"path\", `the path has ${String(mark.path.length)} points, and a run needs 2 or more`);\n mark.path.forEach((step, at) => frame(`path[${String(at)}]`, step));\n positive(\"width\", mark.width);\n break;\n case \"link\":\n for (const [name, end] of [\n [\"from\", mark.from],\n [\"to\", mark.to],\n ] as const) {\n if (end.record === \"\") fault(\"name\", `${name}.record`, `the end ${name} has no record name`);\n point(`${name}.at`, end.at);\n }\n break;\n case \"field\": {\n const hasFrame = frame(\"frame\", mark.frame);\n const hasAcross = direction(\"across\", mark.across);\n if (hasFrame && hasAcross) {\n const dot = dot3(mark.frame.out, mark.across);\n if (Math.abs(dot) > DIRECTION_TOLERANCE) fault(\"angle\", \"across\", `across is not at a right angle to frame.out: their dot product is ${String(dot)}`);\n }\n positive(\"cell\", mark.cell);\n const hasColumns = count(\"columns\", mark.columns);\n const hasRows = count(\"rows\", mark.rows);\n if (hasColumns && hasRows && mark.values.length !== mark.columns * mark.rows) {\n fault(\"values\", \"values\", `the field has ${String(mark.values.length)} values, and ${String(mark.columns)} columns of ${String(mark.rows)} rows need ${String(mark.columns * mark.rows)}`);\n }\n // A field can have many cells, so the values give one fault, not one fault for each cell.\n const bad = mark.values.flatMap((value, at) => (value === null || Number.isFinite(value) ? [] : [at]));\n const first = bad[0];\n if (first !== undefined) {\n fault(\"number\", `values[${String(first)}]`, `${String(bad.length)} of the values are not finite numbers, the first is values[${String(first)}]: ${String(mark.values[first])}`);\n }\n const hasMin = finite(\"scale.min\", mark.scale.min);\n const hasMax = finite(\"scale.max\", mark.scale.max);\n if (hasMin && hasMax && mark.scale.min >= mark.scale.max) {\n fault(\"scale\", \"scale\", `scale.min is not less than scale.max: ${String(mark.scale.min)} and ${String(mark.scale.max)}`);\n }\n break;\n }\n case \"meter\":\n finite(\"value\", mark.value);\n finite(\"limit\", mark.limit);\n break;\n default:\n fault(\"type\", \"type\", `the type is not known: ${String((mark as { readonly type: unknown }).type)}`);\n }\n });\n return faults;\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 readonly limit: number;\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,SAA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Y,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"}
@@ -71,17 +71,17 @@ function keyAction(key, now, options) {
71
71
  }
72
72
  }
73
73
  }
74
- // src/marks.ts
75
- /** The marks of a stage with no pointer on it and no selected record. */
76
- const NO_MARKS = {
74
+ // src/highlight.ts
75
+ /** The highlights of a stage with no pointer on it and no selected record. */
76
+ const NO_HIGHLIGHTS = {
77
77
  hovered: void 0,
78
78
  selected: void 0,
79
- marked: /* @__PURE__ */ new Set()
79
+ highlighted: /* @__PURE__ */ new Set()
80
80
  };
81
- /** This function gives the mark of a record. The selected record has the highest mark. */
82
- function markOf(marks, record) {
83
- if (record === marks.selected) return 2;
84
- return record === marks.hovered || marks.marked.has(record) ? 1 : 0;
81
+ /** This function gives the highlight of a record. The selected record has the highest highlight. */
82
+ function highlightOf(highlights, record) {
83
+ if (record === highlights.selected) return 2;
84
+ return record === highlights.hovered || highlights.highlighted.has(record) ? 1 : 0;
85
85
  }
86
86
  /** A pointer that moves this distance or less between down and up makes a click, in CSS pixels. */
87
87
  const CLICK_DISTANCE = 4;
@@ -127,6 +127,6 @@ function approach(value, goal, seconds, time, snap = .01) {
127
127
  const next = value + (goal - value) * (1 - Math.exp(0 - seconds / time));
128
128
  return Math.abs(goal - next) < snap ? goal : next;
129
129
  }
130
- export { NO_MARKS as a, KEY_TURN as c, CLICK_DISTANCE as i, KEY_ZOOM as l, easeInOut as n, isClick as o, moveAt as r, markOf as s, approach as t, keyAction as u };
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 };
131
131
 
132
- //# sourceMappingURL=motion-BwDDtx3D.js.map
132
+ //# sourceMappingURL=motion-0tsT6sY4.js.map
@@ -0,0 +1 @@
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,IA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AM,IAAI,UAAU,UAAU,UAAU,KAAK,KAAK,UAAU,MAAM,IAAI;AACzF;;;;;AAMA,SAAgB,OAAO,MAAY,KAAa,UAAkB,GAAa;CAC7E,MAAM,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,KAAK,SAAS,KAAK,UAAU,CAAC,GAAG,CAAC,IAAI;CAChG,IAAI,QAAQ,GAAG,OAAO;EAAE,OAAO,KAAK;EAAI,MAAM;CAAK;CACnD,OAAO;EAAE,OAAO,aAAa,KAAK,MAAM,KAAK,IAAI,UAAU,IAAI,GAAG,OAAO;EAAG,MAAM;CAAM;AAC1F;;;;;;;AAQA,SAAgB,SAAS,OAAe,MAAc,SAAiB,MAAc,OAAe,KAAc;CAChH,IAAI,EAAE,UAAU,MAAM,EAAE,OAAO,IAAI,OAAO;CAC1C,MAAM,OAAO,SAAS,OAAO,UAAU,IAAI,KAAK,IAAI,IAAI,UAAU,IAAI;CACtE,OAAO,KAAK,IAAI,OAAO,IAAI,IAAI,OAAO,OAAO;AAC/C"}
@@ -1,8 +1,8 @@
1
- import { b as Place, d as StageView, l as StageExtent, r as Mark, t as StageTheme } from "./theme-CJ2SAcHX.js";
1
+ import { b as Place, d as StageView, l as StageExtent, r as Highlight, t as StageTheme } from "./theme-CKXd_emk.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> {
5
- /** The name of the record. The marks of the stage use this name. */
5
+ /** The name of the record. The highlights of the stage use this name. */
6
6
  readonly record: string;
7
7
  /** The value of the record for the page, for example its kind and its source. */
8
8
  readonly value: P;
@@ -35,8 +35,8 @@ interface StageContent<P, T extends StageTheme = StageTheme> {
35
35
  has(record: string): boolean;
36
36
  /** This function gives the record that a ray from the camera finds first, or `undefined` for no record. */
37
37
  pick(ray: Raycaster): StagePick<P> | undefined;
38
- /** This function gives each part its colors, from the theme and the mark of its record. */
39
- paint(theme: T, mark: (record: string) => Mark): void;
38
+ /** This function gives each part its colors, from the theme and the highlight of its record. */
39
+ paint(theme: T, highlight: (record: string) => Highlight): void;
40
40
  /**
41
41
  * This function changes the parts that depend on the camera or on the time, before each picture.
42
42
  * It gives true while a part continues to change. The stage then makes the next picture.
@@ -98,7 +98,7 @@ interface Stage<P, T extends StageTheme = StageTheme> {
98
98
  setView(view: string | StageView, animate?: boolean): void;
99
99
  /** This function gives the place of the camera. */
100
100
  place(): Place;
101
- /** This function marks records by their names, as the pointer does. An empty list removes the marks. */
101
+ /** This function highlights records by their names, as the pointer does. An empty list removes the highlights. */
102
102
  highlight(records: readonly string[]): void;
103
103
  /** This function selects one record by its name, or no record. It does not start `onSelect`. */
104
104
  select(record: string | undefined): void;
@@ -123,4 +123,4 @@ declare const STAGE_LIGHTS: StageLights;
123
123
  */
124
124
  declare function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined;
125
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-C9NHD-6Q.d.ts.map
126
+ //# sourceMappingURL=stage-CtWLSoV-.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stage-C9NHD-6Q.d.ts","names":[],"sources":["../src/stage/stage.ts"],"mappings":";;;UAUiB,UAAU;;WAEhB;;WAEA,OAAO;;;UAID;WACN,QAAQ;;WAER;;;;;WAKA;;WAEA;;WAEA;;;;;;UAOM,aAAa,GAAG,UAAU,aAAa;;WAE7C,kBAAkB;;WAElB,QAAQ;;EAEjB,IAAI;;EAEJ,KAAK,KAAK,YAAY,UAAU;;EAEhC,MAAM,OAAO,GAAG,OAAO,mBAAmB;;;;;EAK1C,MAAM,OAAO;;EAEb;;;UAIe;;WAEN;;WAEA;;WAEA;aAAiB;aAAoB;aAAoB;;;;UAInD,aAAa,GAAG,UAAU,aAAa;;WAE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;EAElC,SAAS;;EAET,UAAU;;EAEV,OAAO;;EAEP;;EAEA;;;cAIW;;cAGA,cAAc;;;;;;;;;;;iBA6BX,YAAY,GAAG,UAAU,aAAa,YAAY,WAAW,aAAa,SAAS,aAAa,GAAG,KAAK,MAAM,GAAG"}
@@ -151,21 +151,21 @@ declare function stageLimits(frame: ViewFrame, views: readonly StageView[], pola
151
151
  readonly min: number;
152
152
  readonly max: number;
153
153
  }): StageLimits;
154
- /** The mark of a record. 0 is no mark. 1 is a record under the pointer or in the marked list. 2 is the selected record. */
155
- type Mark = 0 | 1 | 2;
156
- /** The records of a stage that have a mark. Each record has a name. */
157
- interface Marks {
154
+ /** 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. */
155
+ type Highlight = 0 | 1 | 2;
156
+ /** The records of a stage that have a highlight. Each record has a name. */
157
+ interface Highlights {
158
158
  /** The name of the record under the pointer. */
159
159
  readonly hovered: string | undefined;
160
160
  /** The name of the selected record. */
161
161
  readonly selected: string | undefined;
162
- /** The names of the records that the page marks. */
163
- readonly marked: ReadonlySet<string>;
162
+ /** The names of the records that the page highlights. */
163
+ readonly highlighted: ReadonlySet<string>;
164
164
  }
165
- /** The marks of a stage with no pointer on it and no selected record. */
166
- declare const NO_MARKS: Marks;
167
- /** This function gives the mark of a record. The selected record has the highest mark. */
168
- declare function markOf(marks: Marks, record: string): Mark;
165
+ /** The highlights of a stage with no pointer on it and no selected record. */
166
+ declare const NO_HIGHLIGHTS: Highlights;
167
+ /** This function gives the highlight of a record. The selected record has the highest highlight. */
168
+ declare function highlightOf(highlights: Highlights, record: string): Highlight;
169
169
  /** A pointer that moves this distance or less between down and up makes a click, in CSS pixels. */
170
170
  declare const CLICK_DISTANCE = 4;
171
171
  /**
@@ -189,5 +189,5 @@ interface StageTheme {
189
189
  /** The color of the light from below. */
190
190
  readonly ground: string;
191
191
  }
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_MARKS as a, Place as b, FIT_MARGIN as c, StageView as d, ViewFrame as f, nearDepth as g, fitView as h, Marks as i, viewAxes as j, speedAt as k, StageExtent as l, capView as m, CLICK_DISTANCE as n, isClick as o, ballView as p, Mark as r, markOf as s, StageTheme as t, StageLimits as u, stageLimits as v, cameraPosition as w, PlaceLimits as x, surfaceOf as y };
193
- //# sourceMappingURL=theme-CJ2SAcHX.d.ts.map
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-CKXd_emk.d.ts","names":[],"sources":["../src/view.ts","../src/extent.ts","../src/highlight.ts","../src/theme.ts"],"mappings":";;;;;UAMiB;;WAEN;;WAEA;;;UAIM,cAAc;WACpB,QAAQ;WACR;;;UAIM;;WAEN,MAAM;;WAEN,OAAO;;WAEP,IAAI;;;UAIE;;WAEN;;WAEA;;WAEA;;WAEA;;;iBAIK,SAAS,MAAM,aAAa;;;;;;;;iBAwB5B,YAAY,iBAAiB,UAAU,QAAQ,QAAQ,MAAM,YAAY,aAAa;;;;;;;;;iBAsBtF,YAAY,gBAAgB,eAAe,aAAa;;iBAaxD,eAAe,QAAQ,QAAQ,MAAM,YAAY,mBAAmB;;iBAMpE,OAAO,QAAQ,QAAQ,QAAQ,SAAS;WAAwB;;;iBAUhE,YAAY,cAAc;;iBAO1B,WAAW,OAAO,OAAO,QAAQ,cAAc;;;;;;;;iBAgB/C,QAAQ,kBAAkB;;;;;;;iBAW1B,aAAa,MAAM,OAAO,IAAI,OAAO,cAAc,mBAAsB;;UCnJxE;;WAEN,kBAAkB;;WAElB,QAAQ;;;;;WAKR;;WAEA;;WAEA;;;UAIM;WACN,QAAQ;;WAER;;WAEA;;;KAIC,aAAa,OAAO,cAAc;;UAG7B,oBAAoB;WAC1B;WACA;;;cAIE;;iBAGG,UAAU,QAAQ;;;;;iBASlB,QAAQ,QAAQ,YAAY,kBAA8B;;;;;;;iBAa1D,QAAQ,QAAQ,YAAY,eAAe,kBAA8B;;;;;;;iBAczE,SAAS,iBAAiB,UAAU,kBAA8B;;iBA0ClE,QAAQ,QAAQ;;;;;;;iBAYhB,UAAU,QAAQ,aAAa,QAAQ,aAAa;;;;;;;iBAWpD,YAAY,OAAO,WAAW,gBAAgB,aAAa;WAAkB;WAAsB;IAAgB;;KC9IvH;;UAGK;;WAEN;;WAEA;;WAEA,aAAa;;;cAIX,eAAe;;iBAGZ,YAAY,YAAY,YAAY,iBAAiB;;cAMxD;;;;;iBAMG,QAAQ;WAAiB;WAAoB;GAAa;WAAe;WAAoB;GAAa;;;;;UCzBzG;;WAEN;;WAEA"}
package/build/three.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as StageFrame, c as StagePick, i as StageContent, l as createStage, n as STAGE_LIGHTS, o as StageLights, r as Stage, s as StageOptions, t as FIELD_OF_VIEW } from "./stage-C9NHD-6Q.js";
1
+ import { a as StageFrame, c as StagePick, i as StageContent, 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
2
  export { FIELD_OF_VIEW, STAGE_LIGHTS, type Stage, type StageContent, type StageFrame, type StageLights, type StageOptions, type StagePick, createStage };
package/build/three.js CHANGED
@@ -1,5 +1,5 @@
1
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_MARKS, o as isClick, r as moveAt, s as markOf, u as keyAction } from "./motion-BwDDtx3D.js";
2
+ import { a as NO_HIGHLIGHTS, o as highlightOf, r as moveAt, s as isClick, u as keyAction } from "./motion-0tsT6sY4.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
@@ -84,7 +84,7 @@ function createStage(container, options) {
84
84
  let content = options.content;
85
85
  let theme = options.theme;
86
86
  for (const object of content.objects) world.add(object);
87
- let marks = NO_MARKS;
87
+ let highlights = NO_HIGHLIGHTS;
88
88
  let view = options.home;
89
89
  let move;
90
90
  /** This value is true after a person moved the view. Then a new size of the container does not move the camera. */
@@ -115,8 +115,8 @@ function createStage(container, options) {
115
115
  });
116
116
  let limits = stageLimits(viewFrame(), Object.values(options.views), polar);
117
117
  const paint = () => {
118
- const now = marks;
119
- content.paint(theme, (record) => markOf(now, record));
118
+ const now = highlights;
119
+ content.paint(theme, (record) => highlightOf(now, record));
120
120
  invalidate();
121
121
  };
122
122
  /** This function sets the turn speed and the zoom speed from the height of the camera above the surface. */
@@ -250,9 +250,9 @@ function createStage(container, options) {
250
250
  };
251
251
  const setHover = (pick) => {
252
252
  const record = pick?.record;
253
- if (record === marks.hovered) return;
254
- marks = {
255
- ...marks,
253
+ if (record === highlights.hovered) return;
254
+ highlights = {
255
+ ...highlights,
256
256
  hovered: record
257
257
  };
258
258
  canvas.style.cursor = record === void 0 ? "grab" : "pointer";
@@ -286,8 +286,8 @@ function createStage(container, options) {
286
286
  y: event.clientY
287
287
  })) return;
288
288
  const pick = pickAt(event);
289
- marks = {
290
- ...marks,
289
+ highlights = {
290
+ ...highlights,
291
291
  selected: pick?.record
292
292
  };
293
293
  paint();
@@ -330,7 +330,7 @@ function createStage(container, options) {
330
330
  invalidate();
331
331
  });
332
332
  controls.addEventListener("end", () => {
333
- canvas.style.cursor = marks.hovered === void 0 ? "grab" : "pointer";
333
+ canvas.style.cursor = highlights.hovered === void 0 ? "grab" : "pointer";
334
334
  });
335
335
  controls.addEventListener("change", invalidate);
336
336
  const applyTheme = () => {
@@ -357,9 +357,9 @@ function createStage(container, options) {
357
357
  content.dispose();
358
358
  content = next;
359
359
  for (const object of content.objects) world.add(object);
360
- const selected = marks.selected !== void 0 && content.has(marks.selected) ? marks.selected : void 0;
361
- marks = {
362
- ...marks,
360
+ const selected = highlights.selected !== void 0 && content.has(highlights.selected) ? highlights.selected : void 0;
361
+ highlights = {
362
+ ...highlights,
363
363
  hovered: void 0,
364
364
  selected
365
365
  };
@@ -377,15 +377,15 @@ function createStage(container, options) {
377
377
  },
378
378
  place: placeNow,
379
379
  highlight(records) {
380
- marks = {
381
- ...marks,
382
- marked: new Set(records)
380
+ highlights = {
381
+ ...highlights,
382
+ highlighted: new Set(records)
383
383
  };
384
384
  paint();
385
385
  },
386
386
  select(record) {
387
- marks = {
388
- ...marks,
387
+ highlights = {
388
+ ...highlights,
389
389
  selected: record
390
390
  };
391
391
  paint();