@mark1russell7/visuals 0.1.1 → 0.2.1
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 +144 -6
- package/build/globe.d.ts +7 -7
- package/build/globe.js +35 -35
- package/build/globe.js.map +1 -1
- package/build/index.d.ts +3 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -2
- package/build/marks.d.ts +192 -0
- package/build/marks.d.ts.map +1 -0
- package/build/marks.js +231 -0
- package/build/marks.js.map +1 -0
- package/build/{motion-BwDDtx3D.js → motion-0tsT6sY4.js} +10 -10
- package/build/motion-0tsT6sY4.js.map +1 -0
- package/build/replay-DvGYPe7T.d.ts +95 -0
- package/build/replay-DvGYPe7T.d.ts.map +1 -0
- package/build/replay-YdWMyFko.js +172 -0
- package/build/replay-YdWMyFko.js.map +1 -0
- package/build/scrubber.d.ts +93 -0
- package/build/scrubber.d.ts.map +1 -0
- package/build/scrubber.js +265 -0
- package/build/scrubber.js.map +1 -0
- package/build/{stage-C9NHD-6Q.d.ts → stage-CtWLSoV-.d.ts} +6 -6
- package/build/{stage-C9NHD-6Q.d.ts.map → stage-CtWLSoV-.d.ts.map} +1 -1
- package/build/{theme-CJ2SAcHX.d.ts → theme-CKXd_emk.d.ts} +12 -12
- package/build/theme-CKXd_emk.d.ts.map +1 -0
- package/build/three.d.ts +1 -1
- package/build/three.js +18 -18
- package/build/three.js.map +1 -1
- package/package.json +20 -5
- package/styles/scrubber.css +289 -0
- package/build/motion-BwDDtx3D.js.map +0 -1
- package/build/theme-CJ2SAcHX.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
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
|
|
5
|
+
The package has five entries and one style sheet:
|
|
6
6
|
|
|
7
|
-
- The entry `.` has the camera maths
|
|
7
|
+
- The entry `.` has the camera maths and the model of a replay. It needs no browser, and it does not need `three`.
|
|
8
|
+
- The entry `/marks` has the marks that a viewer draws, as plain data. It needs no browser, and it does not need `three`.
|
|
8
9
|
- The entry `/three` has the stage. It needs the package `three`, version 0.187.0 or later.
|
|
9
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 `/scrubber` has a control that sets the time of a picture. It needs a browser, and it does not need `three`.
|
|
12
|
+
- The file `/scrubber.css` is the style sheet of the scrubber.
|
|
10
13
|
|
|
11
14
|
## Install
|
|
12
15
|
|
|
@@ -14,6 +17,8 @@ The package has three entries:
|
|
|
14
17
|
npm install @mark1russell7/visuals three
|
|
15
18
|
```
|
|
16
19
|
|
|
20
|
+
A package that uses only the entries `.`, `/marks` and `/scrubber` does not install `three`.
|
|
21
|
+
|
|
17
22
|
## A stage
|
|
18
23
|
|
|
19
24
|
```ts
|
|
@@ -32,7 +37,7 @@ const content: StageContent<string> = {
|
|
|
32
37
|
},
|
|
33
38
|
has: (record) => record === "box",
|
|
34
39
|
pick: (ray) => (ray.intersectObject(box).length > 0 ? { record: "box", value: "the box" } : undefined),
|
|
35
|
-
paint: (_theme,
|
|
40
|
+
paint: (_theme, highlight) => void material.color.set(highlight("box") === 0 ? "#4f7cac" : "#e0a03a"),
|
|
36
41
|
dispose: () => {
|
|
37
42
|
box.geometry.dispose();
|
|
38
43
|
material.dispose();
|
|
@@ -71,11 +76,11 @@ A stage knows nothing about the data. The content gives it these parts:
|
|
|
71
76
|
| `objects` | The three.js objects of the content. |
|
|
72
77
|
| `extent` | The space that the content fills: the point that the camera looks at, and the corners that a view shows. |
|
|
73
78
|
| `pick` | The record that a ray from the camera finds first. |
|
|
74
|
-
| `paint` | The colors of each part, from the theme and the
|
|
79
|
+
| `paint` | The colors of each part, from the theme and the highlight of its record. |
|
|
75
80
|
| `step` | The parts that change with the camera or with the time, before each picture. It is optional. |
|
|
76
81
|
| `dispose` | The release of the memory of the graphics card. |
|
|
77
82
|
|
|
78
|
-
A record has a name. The
|
|
83
|
+
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.
|
|
79
84
|
|
|
80
85
|
## Views
|
|
81
86
|
|
|
@@ -202,6 +207,139 @@ surface.corners.length / 2; // => 43: the corners of the outline with a step of
|
|
|
202
207
|
surface.triangles.length / 3; // => 70
|
|
203
208
|
```
|
|
204
209
|
|
|
210
|
+
## A scrubber
|
|
211
|
+
|
|
212
|
+
The entry `/scrubber` has a control with which a person sets the time of a picture, and replays its changes.
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
import { changeTimes, isLive, replayOf, type Lifetime } from "@mark1russell7/visuals";
|
|
216
|
+
import { createScrubber } from "@mark1russell7/visuals/scrubber";
|
|
217
|
+
import "@mark1russell7/visuals/scrubber.css";
|
|
218
|
+
|
|
219
|
+
// The value of each part of a globe is its lifetime, in hours.
|
|
220
|
+
const lives: readonly Lifetime[] = [{ from: 6, to: 18 }, { from: 12 }];
|
|
221
|
+
|
|
222
|
+
const scrubber = createScrubber(document.body, {
|
|
223
|
+
label: "Time of the picture",
|
|
224
|
+
replay: replayOf({ from: 0, to: 24 }),
|
|
225
|
+
times: changeTimes(lives), // => [6, 12, 18]
|
|
226
|
+
labels: [
|
|
227
|
+
{ at: 0, text: "00:00" },
|
|
228
|
+
{ at: 12, text: "12:00" },
|
|
229
|
+
],
|
|
230
|
+
format: (at) => `${String(Math.floor(at)).padStart(2, "0")}:00`,
|
|
231
|
+
onChange: ({ at }) => {
|
|
232
|
+
globe.show((part) => isLive(part.value, at));
|
|
233
|
+
stage.refresh();
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
- The control has a button for the replay, the text of the time, a slider on an axis and a button for the speed.
|
|
239
|
+
- The axis has a tick at each time of `times`. The ticks of the time that passed have the color of the ink.
|
|
240
|
+
- The slider is an `input` of the type `range`. A pointer, a touch screen, a keyboard and a screen reader use it.
|
|
241
|
+
- The arrow keys go from one change to the next change. The keys `PageUp` and `PageDown` go a tenth of the range.
|
|
242
|
+
- The keys `Home` and `End` go to the ends of the range. The key Space starts and stops the replay.
|
|
243
|
+
- A replay at the end of its range starts again from the start. A replay stops at the end.
|
|
244
|
+
- `onChange` gets each new state. The control knows nothing about the picture, so it works with each stage and each page.
|
|
245
|
+
- `setReplay`, `setTimes` and `setLabels` change the control from the page, for example after new data.
|
|
246
|
+
- The control writes no inline style and no inline script, so it works under a strict content security policy.
|
|
247
|
+
|
|
248
|
+
The style sheet is plain CSS. A bundler takes it from the import. A page with no bundler links to the file of the package.
|
|
249
|
+
The control takes its font and the color of its text from the page.
|
|
250
|
+
|
|
251
|
+
| Variable | What it sets | Default |
|
|
252
|
+
| --- | --- | --- |
|
|
253
|
+
| `--scrubber-ink` | The color of the handle, the ticks of the time that passed, and the button of the replay. | The color of the text |
|
|
254
|
+
| `--scrubber-quiet` | The color of the labels of the axis. | 68% of the color of the text |
|
|
255
|
+
| `--scrubber-line` | The color of the ticks of the time to come, and of the border of the button of the speed. | 45% of the color of the text |
|
|
256
|
+
| `--scrubber-surface` | The color in the ring of the handle. Give it the color behind the control. | `Canvas` |
|
|
257
|
+
| `--scrubber-focus` | The color of the focus ring. | `Highlight` |
|
|
258
|
+
| `--scrubber-time-width` | The width of the text of the time in a control with one row. Thus the axis does not move. | `11rem` |
|
|
259
|
+
|
|
260
|
+
A narrow control has two rows. A control that is 44 rem wide or more has one row. The width is the width of its container.
|
|
261
|
+
|
|
262
|
+
## The replay
|
|
263
|
+
|
|
264
|
+
A replay is a value: a range of time, the time of the picture, the speed, and if the time goes. Each function gives a new value.
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
import { changeIndex, changeTimes, isLive, replayAdvance, replayKey, replayOf, replayPlay } from "@mark1russell7/visuals";
|
|
268
|
+
|
|
269
|
+
const times = changeTimes([{ from: 6, to: 18 }, { from: 12 }]); // => [6, 12, 18]
|
|
270
|
+
isLive({ from: 6, to: 18 }, 18); // => false: a part is not in the picture at its end
|
|
271
|
+
|
|
272
|
+
const replay = replayOf({ from: 0, to: 24 }); // The picture is at the end of the range, and the time does not go.
|
|
273
|
+
const start = replayPlay(replay); // The replay starts again from the start of the range.
|
|
274
|
+
replayAdvance(start, 5000, 20_000).at; // => 6: a quarter of the duration is a quarter of the range
|
|
275
|
+
replayKey("ArrowLeft", replay, times)?.at; // => 18: the last change before the time
|
|
276
|
+
changeIndex(times, 13); // => 2: draw the picture again only when this count changes
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
| Function | What it gives |
|
|
280
|
+
| --- | --- |
|
|
281
|
+
| `isLive` | If a part with a lifetime is in the picture at a time. |
|
|
282
|
+
| `changeTimes`, `spanOfTimes` | The sorted times at which a picture changes, and the range from the first time to the last time. |
|
|
283
|
+
| `changeAfter`, `changeBefore`, `changeIndex` | The next change, the change before, and the count of the changes that are not after a time. |
|
|
284
|
+
| `spanPart`, `spanTime` | The place of a time in a range from 0 to 1, and the time at a place. |
|
|
285
|
+
| `replayOf`, `replaySeek`, `replaySpan` | A replay of a range, a replay at a time, and a replay with a new range. |
|
|
286
|
+
| `replayPlay`, `replayPause`, `replayToggle` | A replay that goes, and a replay that does not go. |
|
|
287
|
+
| `replayAdvance` | The replay after a time of the clock. |
|
|
288
|
+
| `replayNextSpeed`, `replayKey` | The replay with the next speed, and the replay after a key. |
|
|
289
|
+
|
|
290
|
+
A time is a number in a unit that the page chooses. `replaySpan` keeps a picture of the present at the present when the range becomes longer.
|
|
291
|
+
|
|
292
|
+
## The marks
|
|
293
|
+
|
|
294
|
+
A mark is a record that a viewer draws. A mark is plain data with no topic, so each viewer draws the marks of each producer.
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
import { checkMarks, levelShape, shapeRing, type Mark } from "@mark1russell7/visuals/marks";
|
|
298
|
+
|
|
299
|
+
const marks: readonly Mark[] = [
|
|
300
|
+
{
|
|
301
|
+
type: "point",
|
|
302
|
+
record: "outlet-1",
|
|
303
|
+
kind: "outlet",
|
|
304
|
+
level: "near",
|
|
305
|
+
label: "Outlet 1",
|
|
306
|
+
frame: { at: { x: 1, y: 0, z: 0.3 }, out: { x: 0, y: 1, z: 0 } },
|
|
307
|
+
},
|
|
308
|
+
{ type: "meter", record: "circuit-1", kind: "circuit", level: "over", label: "Circuit 1", value: 1900, limit: 1440, unit: "W" },
|
|
309
|
+
];
|
|
310
|
+
|
|
311
|
+
checkMarks(marks); // => []: the list has no fault
|
|
312
|
+
levelShape("near"); // => "triangle"
|
|
313
|
+
shapeRing("triangle").length; // => 3: the corners of the sign, counter-clockwise
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
| Mark | Data | Example |
|
|
317
|
+
| --- | --- | --- |
|
|
318
|
+
| `point` | A frame and a size | An outlet, a tap, a lamp |
|
|
319
|
+
| `run` | A list of frames and a width | A cable, a pipe, a duct |
|
|
320
|
+
| `link` | Two ends, each with a record name and a point | A power line from an outlet to a computer |
|
|
321
|
+
| `field` | A grid of values on a plane, and a scale | Light in lux, sound in decibels, heat |
|
|
322
|
+
| `meter` | A value, a limit and the text of the unit | The load of a circuit against its limit |
|
|
323
|
+
|
|
324
|
+
- Each mark has a record name, a kind, a level and a label. The kind is a word of the producer for the legend and the filter.
|
|
325
|
+
- A frame is a point of a surface and the unit vector out of the surface.
|
|
326
|
+
- The level of a mark is `unknown`, `ok`, `near` or `over`. The producer calculates it, because each topic has its own limits.
|
|
327
|
+
- A mark has no shape and no color. `levelShape` gives each level its shape, and the theme of a viewer gives its color.
|
|
328
|
+
- Thus a person who does not see a color reads the level from the shape: a ring, a disc, a triangle or a square.
|
|
329
|
+
- A viewer draws the marks in the sequence of `levelRank`, so the worst level is always in view.
|
|
330
|
+
- A field has its values row by row, with `null` for a cell with no value. `fieldValue` and `fieldCellCenter` read a cell.
|
|
331
|
+
- A meter has no place. A page draws it in a panel, and a 3D view ignores it.
|
|
332
|
+
- Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.
|
|
333
|
+
|
|
334
|
+
`checkMarks` gives the faults of a list, each with a code, the index of its mark and the part with the fault. It examines the values that the types do not hold:
|
|
335
|
+
|
|
336
|
+
- A number that is not finite, and a direction that is not a unit vector.
|
|
337
|
+
- A size, a width or a cell that is not more than 0.
|
|
338
|
+
- The grid, the values and the scale of a field, and a run with fewer than 2 points.
|
|
339
|
+
- An empty name, an empty label, and a level or a type that is not known.
|
|
340
|
+
|
|
341
|
+
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.
|
|
342
|
+
|
|
205
343
|
## The camera maths
|
|
206
344
|
|
|
207
345
|
The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js use the same functions as the stage.
|
|
@@ -216,7 +354,7 @@ The entry `.` has pure functions. A page with no WebGL 2 and a test in Node.js u
|
|
|
216
354
|
| `clampPlace`, `stageLimits` | A place in the limits of a stage, and the limits from the content. |
|
|
217
355
|
| `reachOf`, `nearDepth` | The radius of the ball that holds the content, and the nearest depth that the camera draws. |
|
|
218
356
|
| `keyAction` | The action of a key. |
|
|
219
|
-
| `
|
|
357
|
+
| `highlightOf`, `isClick` | The highlight of a record, and the difference between a click and a drag. |
|
|
220
358
|
| `approach` | One step of a value to its goal, for a part that changes with time. |
|
|
221
359
|
|
|
222
360
|
The space of a stage has the y axis up. A place has a target, a polar angle from the y axis, an azimuth around it and a distance.
|
package/build/globe.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as StageContent } from "./stage-
|
|
2
|
-
import { S as ViewAngles, d as StageView, t as StageTheme } from "./theme-
|
|
1
|
+
import { i as StageContent } from "./stage-CtWLSoV-.js";
|
|
2
|
+
import { S as ViewAngles, d as StageView, t as StageTheme } from "./theme-CKXd_emk.js";
|
|
3
3
|
import { Raycaster } from "three";
|
|
4
4
|
import { LatLon, Region } from "@mark1russell7/geo";
|
|
5
5
|
import { Point3 } from "@mark1russell7/layout-contract";
|
|
@@ -24,14 +24,14 @@ interface GlobeTheme extends StageTheme {
|
|
|
24
24
|
readonly styles: Readonly<Record<string, GlobeStyle>>;
|
|
25
25
|
/** The style of a kind that `styles` does not have. */
|
|
26
26
|
readonly other: GlobeStyle;
|
|
27
|
-
/** The color of the edge of a record under the pointer, or in the
|
|
27
|
+
/** The color of the edge of a record under the pointer, or in the highlighted list. */
|
|
28
28
|
readonly hovered: string;
|
|
29
29
|
/** The color of the edge of the selected record. */
|
|
30
30
|
readonly selected: string;
|
|
31
31
|
}
|
|
32
32
|
/** An area of a globe: a region of the Earth that belongs to a record. */
|
|
33
33
|
interface GlobeArea<P> {
|
|
34
|
-
/** The name of the record. Two parts with one name are one record: the stage
|
|
34
|
+
/** The name of the record. Two parts with one name are one record: the stage highlights them together. */
|
|
35
35
|
readonly record: string;
|
|
36
36
|
/** The region, with edges that are straight lines in longitude and latitude, as in `@mark1russell7/geo`. */
|
|
37
37
|
readonly region: Region;
|
|
@@ -44,7 +44,7 @@ interface GlobeArea<P> {
|
|
|
44
44
|
}
|
|
45
45
|
/** A point of a globe: a place on the Earth that belongs to a record. The picture shows it as a dot of a constant size. */
|
|
46
46
|
interface GlobePoint<P> {
|
|
47
|
-
/** The name of the record. Two parts with one name are one record: the stage
|
|
47
|
+
/** The name of the record. Two parts with one name are one record: the stage highlights them together. */
|
|
48
48
|
readonly record: string;
|
|
49
49
|
readonly place: LatLon;
|
|
50
50
|
/** The name of the style of the point in the theme. */
|
|
@@ -72,8 +72,8 @@ interface GlobeOptions<P> {
|
|
|
72
72
|
readonly nearest?: number | undefined;
|
|
73
73
|
/** The width of the edge of an area. The default is 1.25. */
|
|
74
74
|
readonly lineWidth?: number | undefined;
|
|
75
|
-
/** The width of the edge of a record with a
|
|
76
|
-
readonly
|
|
75
|
+
/** The width of the edge of a record with a highlight. The default is 2.5. */
|
|
76
|
+
readonly highlightWidth?: number | undefined;
|
|
77
77
|
/** The width of a line of the grid. The default is 1. */
|
|
78
78
|
readonly gridWidth?: number | undefined;
|
|
79
79
|
/** The width of the dot of a point. The default is 9. */
|
package/build/globe.js
CHANGED
|
@@ -557,10 +557,10 @@ function inSight(point, eye, radius) {
|
|
|
557
557
|
// src/globe/content.ts
|
|
558
558
|
/** The smallest height of the layer of the areas above the ball, as a part of the radius. */
|
|
559
559
|
const MIN_LIFT = 5e-4;
|
|
560
|
-
/** The opacity that a
|
|
561
|
-
const
|
|
562
|
-
/** The factor of the width of a point with a
|
|
563
|
-
const
|
|
560
|
+
/** The opacity that a highlight adds to the surface of an area. */
|
|
561
|
+
const HIGHLIGHT_OPACITY = .16;
|
|
562
|
+
/** The factor of the width of a point with a highlight. */
|
|
563
|
+
const HIGHLIGHT_SIZE = 1.35;
|
|
564
564
|
/** The width of the ring around a point, in CSS pixels. */
|
|
565
565
|
const RING_WIDTH = 1.5;
|
|
566
566
|
/** The distance around a point where the pointer finds it, in CSS pixels. */
|
|
@@ -724,7 +724,7 @@ function createGlobe(options = {}) {
|
|
|
724
724
|
shown: true,
|
|
725
725
|
filled: false,
|
|
726
726
|
lined: false,
|
|
727
|
-
|
|
727
|
+
highlight: 0
|
|
728
728
|
});
|
|
729
729
|
surfaces.push(surface);
|
|
730
730
|
cornerTotal += surface.corners.length / 2;
|
|
@@ -781,16 +781,16 @@ function createGlobe(options = {}) {
|
|
|
781
781
|
const edges = new LineSegments2(edgeGeometry, edgeMaterial);
|
|
782
782
|
edges.renderOrder = 3;
|
|
783
783
|
edges.frustumCulled = false;
|
|
784
|
-
const
|
|
785
|
-
linewidth: options.
|
|
784
|
+
const highlightMaterial = new LineMaterial({
|
|
785
|
+
linewidth: options.highlightWidth ?? 2.5,
|
|
786
786
|
vertexColors: true,
|
|
787
787
|
transparent: true,
|
|
788
788
|
depthWrite: false
|
|
789
789
|
});
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
790
|
+
const highlighted = new LineSegments2(new LineSegmentsGeometry(), highlightMaterial);
|
|
791
|
+
highlighted.renderOrder = 5;
|
|
792
|
+
highlighted.frustumCulled = false;
|
|
793
|
+
highlighted.visible = false;
|
|
794
794
|
const pointSize = options.pointSize ?? 9;
|
|
795
795
|
const pointParts = (options.points ?? []).map((point) => ({
|
|
796
796
|
point,
|
|
@@ -798,7 +798,7 @@ function createGlobe(options = {}) {
|
|
|
798
798
|
size: point.size ?? pointSize,
|
|
799
799
|
shown: true,
|
|
800
800
|
filled: false,
|
|
801
|
-
|
|
801
|
+
highlight: 0
|
|
802
802
|
}));
|
|
803
803
|
const pointPositions = new Float32Array(pointParts.length * 3);
|
|
804
804
|
pointParts.forEach((part, index) => pointPositions.set([
|
|
@@ -839,7 +839,7 @@ function createGlobe(options = {}) {
|
|
|
839
839
|
/** The angle of one CSS pixel at the middle of the picture, in radians. */
|
|
840
840
|
let pixelAngle = .001;
|
|
841
841
|
const styleOf = (theme, kind) => theme.styles[kind] ?? theme.other;
|
|
842
|
-
const
|
|
842
|
+
const highlightColor = (theme, highlight) => highlight === 2 ? theme.selected : theme.hovered;
|
|
843
843
|
/** This function writes the colors of an area into the buffers. */
|
|
844
844
|
const paintArea = (part, theme) => {
|
|
845
845
|
const style = styleOf(theme, part.area.kind);
|
|
@@ -848,7 +848,7 @@ function createGlobe(options = {}) {
|
|
|
848
848
|
if (style.fill !== void 0) {
|
|
849
849
|
color.set(style.fill);
|
|
850
850
|
const opacity = Math.min(Math.max(style.opacity ?? 1, 0), 1);
|
|
851
|
-
const alpha = part.
|
|
851
|
+
const alpha = part.highlight === 0 ? opacity : Math.min(opacity + HIGHLIGHT_OPACITY, 1);
|
|
852
852
|
const values = [
|
|
853
853
|
color.r,
|
|
854
854
|
color.g,
|
|
@@ -875,7 +875,7 @@ function createGlobe(options = {}) {
|
|
|
875
875
|
const sync = (theme) => {
|
|
876
876
|
let indexCount = 0;
|
|
877
877
|
let segmentCount = 0;
|
|
878
|
-
let
|
|
878
|
+
let highlightCount = 0;
|
|
879
879
|
for (const part of areaParts) {
|
|
880
880
|
if (!part.shown) continue;
|
|
881
881
|
if (part.filled) {
|
|
@@ -889,7 +889,7 @@ function createGlobe(options = {}) {
|
|
|
889
889
|
edgeColors.array.set(allSegmentColors.subarray(from, to), segmentCount * 6);
|
|
890
890
|
segmentCount += part.segmentCount;
|
|
891
891
|
}
|
|
892
|
-
if (part.
|
|
892
|
+
if (part.highlight !== 0) highlightCount += part.segmentCount;
|
|
893
893
|
}
|
|
894
894
|
fillIndices.needsUpdate = true;
|
|
895
895
|
fillGeometry.setDrawRange(0, indexCount);
|
|
@@ -898,12 +898,12 @@ function createGlobe(options = {}) {
|
|
|
898
898
|
edgeColors.needsUpdate = true;
|
|
899
899
|
edgeGeometry.instanceCount = segmentCount;
|
|
900
900
|
edges.visible = segmentCount > 0;
|
|
901
|
-
const
|
|
902
|
-
const
|
|
901
|
+
const highlightPositions = new Float32Array(highlightCount * 6);
|
|
902
|
+
const highlightColors = new Float32Array(highlightCount * 6);
|
|
903
903
|
let at = 0;
|
|
904
904
|
for (const part of areaParts) {
|
|
905
|
-
if (!part.shown || part.
|
|
906
|
-
color.set(
|
|
905
|
+
if (!part.shown || part.highlight === 0) continue;
|
|
906
|
+
color.set(highlightColor(theme, part.highlight));
|
|
907
907
|
const values = [
|
|
908
908
|
color.r,
|
|
909
909
|
color.g,
|
|
@@ -912,18 +912,18 @@ function createGlobe(options = {}) {
|
|
|
912
912
|
color.g,
|
|
913
913
|
color.b
|
|
914
914
|
];
|
|
915
|
-
|
|
916
|
-
for (let segment = 0; segment < part.segmentCount; segment++)
|
|
915
|
+
highlightPositions.set(allSegments.subarray(part.firstSegment * 6, (part.firstSegment + part.segmentCount) * 6), at * 6);
|
|
916
|
+
for (let segment = 0; segment < part.segmentCount; segment++) highlightColors.set(values, (at + segment) * 6);
|
|
917
917
|
at += part.segmentCount;
|
|
918
918
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
919
|
+
highlighted.geometry.dispose();
|
|
920
|
+
highlighted.geometry = highlightCount > 0 ? segmentGeometry(new InstancedInterleavedBuffer(highlightPositions, 6, 1), new InstancedInterleavedBuffer(highlightColors, 6, 1), highlightCount, bounds) : new LineSegmentsGeometry();
|
|
921
|
+
highlighted.visible = highlightCount > 0;
|
|
922
922
|
pointParts.forEach((part, index) => {
|
|
923
923
|
const style = styleOf(theme, part.point.kind);
|
|
924
924
|
part.filled = style.fill !== void 0;
|
|
925
925
|
const visible = part.shown && style.fill !== void 0;
|
|
926
|
-
pointSizes.array[index] = visible ? part.size * (part.
|
|
926
|
+
pointSizes.array[index] = visible ? part.size * (part.highlight === 0 ? 1 : HIGHLIGHT_SIZE) : 0;
|
|
927
927
|
if (style.fill === void 0) return;
|
|
928
928
|
color.set(style.fill);
|
|
929
929
|
pointFills.array.set([
|
|
@@ -931,7 +931,7 @@ function createGlobe(options = {}) {
|
|
|
931
931
|
color.g,
|
|
932
932
|
color.b
|
|
933
933
|
], index * 3);
|
|
934
|
-
color.set(part.
|
|
934
|
+
color.set(part.highlight === 0 ? style.line ?? style.fill : highlightColor(theme, part.highlight));
|
|
935
935
|
pointRings.array.set([
|
|
936
936
|
color.r,
|
|
937
937
|
color.g,
|
|
@@ -949,7 +949,7 @@ function createGlobe(options = {}) {
|
|
|
949
949
|
fills,
|
|
950
950
|
edges,
|
|
951
951
|
shade,
|
|
952
|
-
|
|
952
|
+
highlighted,
|
|
953
953
|
dots
|
|
954
954
|
],
|
|
955
955
|
extent: {
|
|
@@ -994,7 +994,7 @@ function createGlobe(options = {}) {
|
|
|
994
994
|
};
|
|
995
995
|
}
|
|
996
996
|
},
|
|
997
|
-
paint(theme,
|
|
997
|
+
paint(theme, highlight) {
|
|
998
998
|
const all = theme !== painted;
|
|
999
999
|
painted = theme;
|
|
1000
1000
|
if (all) {
|
|
@@ -1003,12 +1003,12 @@ function createGlobe(options = {}) {
|
|
|
1003
1003
|
shadeColor.value.set(theme.shade);
|
|
1004
1004
|
}
|
|
1005
1005
|
for (const part of areaParts) {
|
|
1006
|
-
const next =
|
|
1007
|
-
if (!all && next === part.
|
|
1008
|
-
part.
|
|
1006
|
+
const next = highlight(part.area.record);
|
|
1007
|
+
if (!all && next === part.highlight) continue;
|
|
1008
|
+
part.highlight = next;
|
|
1009
1009
|
paintArea(part, theme);
|
|
1010
1010
|
}
|
|
1011
|
-
for (const part of pointParts) part.
|
|
1011
|
+
for (const part of pointParts) part.highlight = highlight(part.point.record);
|
|
1012
1012
|
sync(theme);
|
|
1013
1013
|
},
|
|
1014
1014
|
step(frame) {
|
|
@@ -1034,8 +1034,8 @@ function createGlobe(options = {}) {
|
|
|
1034
1034
|
fillMaterial.dispose();
|
|
1035
1035
|
edgeGeometry.dispose();
|
|
1036
1036
|
edgeMaterial.dispose();
|
|
1037
|
-
|
|
1038
|
-
|
|
1037
|
+
highlighted.geometry.dispose();
|
|
1038
|
+
highlightMaterial.dispose();
|
|
1039
1039
|
pointGeometry.dispose();
|
|
1040
1040
|
pointMaterial.dispose();
|
|
1041
1041
|
}
|