@cosmos.gl/deck-layers 3.5.0 → 3.5.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 +136 -69
- package/dist/cosmos-graph-layer.d.ts +230 -123
- package/dist/index.d.ts +6 -6
- package/dist/index.js +329 -592
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/blend-parameters.d.ts +0 -23
- package/dist/cosmos-links-layer-uniforms.d.ts +0 -20
- package/dist/cosmos-links-layer.d.ts +0 -68
- package/dist/cosmos-points-layer-uniforms.d.ts +0 -18
- package/dist/cosmos-points-layer.d.ts +0 -52
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Layer, Accessor, BinaryAttribute, Color, DefaultProps, GetPickingInfoParams, LayerContext, LayerProps, PickingInfo, UpdateParameters } from '@deck.gl/core';
|
|
2
|
+
import { Graph, GraphConfig } from '@cosmos.gl/graph';
|
|
3
3
|
/**
|
|
4
4
|
* Binary styling channels for binary points, keyed by the accessor each one
|
|
5
|
-
* replaces
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* replaces. Colors are RGBA per point, 4 values each: a `Uint8Array` in
|
|
6
|
+
* 0..255 (deck's convention) is converted, a `Float32Array` is cosmos's own
|
|
7
|
+
* 0..1 and is handed over as it is. Sizes are one value per point, handed
|
|
8
|
+
* over as they are. Values are read tightly packed; `offset` and `stride` are
|
|
9
|
+
* not honoured.
|
|
8
10
|
*/
|
|
9
11
|
export type CosmosPointAttributes = {
|
|
10
12
|
getPointColor?: BinaryAttribute;
|
|
11
13
|
getPointSize?: BinaryAttribute;
|
|
12
14
|
};
|
|
13
15
|
/**
|
|
14
|
-
* Points input: an array to run accessors over
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Points input: an array to run accessors over, or the cosmos-native binary
|
|
17
|
+
* form — a point count plus optional `[x0, y0, x1, y1, …]` initial positions
|
|
18
|
+
* and binary styling channels. Points without given positions are seeded
|
|
19
|
+
* randomly inside the simulation space.
|
|
18
20
|
*/
|
|
19
21
|
export type CosmosGraphPoints<PointDataT> = readonly PointDataT[] | {
|
|
20
22
|
length: number;
|
|
@@ -23,8 +25,8 @@ export type CosmosGraphPoints<PointDataT> = readonly PointDataT[] | {
|
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
27
|
* Binary styling channels for binary links, keyed by the accessor each one
|
|
26
|
-
* replaces
|
|
27
|
-
*
|
|
28
|
+
* replaces, with the same conventions as `CosmosPointAttributes`: colors a
|
|
29
|
+
* `Uint8Array` in 0..255 or a `Float32Array` in 0..1, widths one per link.
|
|
28
30
|
*/
|
|
29
31
|
export type CosmosLinkAttributes = {
|
|
30
32
|
getLinkColor?: BinaryAttribute;
|
|
@@ -34,15 +36,68 @@ export type CosmosLinkAttributes = {
|
|
|
34
36
|
* Links input: an array to run accessors over, the cosmos-native
|
|
35
37
|
* `[source0, target0, source1, target1, …]` array of point indices, or that
|
|
36
38
|
* array as `pairs` with binary styling channels beside it. An array link whose
|
|
37
|
-
* source or target does not resolve to a point is dropped
|
|
38
|
-
*
|
|
39
|
-
*
|
|
39
|
+
* source or target does not resolve to a point is dropped, with one warning
|
|
40
|
+
* per data change; a pair that names no point is skipped by the engine and
|
|
41
|
+
* keeps its index.
|
|
40
42
|
*/
|
|
41
43
|
export type CosmosGraphLinks<LinkDataT> = readonly LinkDataT[] | Float32Array | {
|
|
42
44
|
pairs: Float32Array;
|
|
43
45
|
attributes?: CosmosLinkAttributes;
|
|
44
46
|
};
|
|
45
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The cosmos.gl config keys deck owns in this embedding — the canvas, the view
|
|
49
|
+
* and its zoom, the frame loop, the pointer and its callbacks. The layer strips
|
|
50
|
+
* them from `config`: deck's view state, controller, event callbacks and
|
|
51
|
+
* `useDevicePixels` are the way to those things.
|
|
52
|
+
*/
|
|
53
|
+
export declare const DECK_OWNED_CONFIG_KEYS: readonly ["enableRenderLoop", "backgroundColor", "pixelRatio", "showFPSMonitor", "attribution", "hoveredPointCursor", "hoveredLinkCursor", "initialZoomLevel", "enableZoom", "enableSimulationDuringZoom", "enableDrag", "fitViewOnInit", "fitViewDelay", "fitViewPadding", "fitViewDuration", "fitViewByPointsInRect", "fitViewByPointIndices", "simulationRepulsionFromMouse", "enableRightClickRepulsion", "onClick", "onPointClick", "onLinkClick", "onBackgroundClick", "onContextMenu", "onPointContextMenu", "onLinkContextMenu", "onBackgroundContextMenu", "onMouseMove", "onPointMouseOver", "onPointMouseOut", "onLinkMouseOver", "onLinkMouseOut", "onZoomStart", "onZoom", "onZoomEnd", "onDragStart", "onDrag", "onDragEnd"];
|
|
54
|
+
/**
|
|
55
|
+
* cosmos.gl's configuration as the layer takes it: every key of `GraphConfig`
|
|
56
|
+
* except the ones deck owns (`DECK_OWNED_CONFIG_KEYS`). Rendering keys work as
|
|
57
|
+
* in cosmos.gl, because cosmos.gl does the rendering. The transition keys have
|
|
58
|
+
* no effect: a headless `Graph` applies data changes at once.
|
|
59
|
+
*/
|
|
60
|
+
export type CosmosGraphLayerConfig = Omit<GraphConfig, (typeof DECK_OWNED_CONFIG_KEYS)[number]>;
|
|
61
|
+
/**
|
|
62
|
+
* What `onGraphDataLoaded` reports: the graph, what the load replaced, and how
|
|
63
|
+
* your data maps to the graph's point and link indices. Per-point and per-link
|
|
64
|
+
* arrays you hand the graph (`setLinkStrength`, `setPointShapes`,
|
|
65
|
+
* `setPointClusters`, …) follow those indices. `links` and `pointIndexById`
|
|
66
|
+
* are the layer's own state: read or copy them, never mutate them.
|
|
67
|
+
*/
|
|
68
|
+
export type CosmosGraphDataLoadedInfo<LinkDataT = unknown> = {
|
|
69
|
+
/** The graph the data was loaded into: layer-created or provided. */
|
|
70
|
+
graph: Graph;
|
|
71
|
+
/**
|
|
72
|
+
* The point positions were replaced, and with them possibly the point count.
|
|
73
|
+
* Per-point arrays sent before this load may no longer line up.
|
|
74
|
+
*/
|
|
75
|
+
pointsLoaded: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The links were replaced. Per-link arrays sent before this load may no longer
|
|
78
|
+
* line up: the engine reuses the last one it was sent whenever its length
|
|
79
|
+
* matches the new link count, in the old order.
|
|
80
|
+
*/
|
|
81
|
+
linksLoaded: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Point `i` is always entry `i` of `points` (or pair `i` of `initialPositions`).
|
|
84
|
+
* With array points and `getPointId`, this maps each id to its index; a repeated
|
|
85
|
+
* id maps to its last point. Otherwise `null`.
|
|
86
|
+
*/
|
|
87
|
+
pointIndexById: ReadonlyMap<string | number, number> | null;
|
|
88
|
+
/**
|
|
89
|
+
* Array links: the links the graph holds, in its order — link `i` is
|
|
90
|
+
* `info.links[i]`. Links whose endpoints name no point are not among them, so
|
|
91
|
+
* an index into your `links` array can differ. Binary links, or no `links`
|
|
92
|
+
* prop: `null`, and link `i` is pair `i` of your pair array.
|
|
93
|
+
*/
|
|
94
|
+
links: readonly LinkDataT[] | null;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Picking info from a CosmosGraphLayer: which kind of element was hit, with `index`
|
|
98
|
+
* counting within that kind (point `i` or link `i`), and `object` the original record
|
|
99
|
+
* for array data.
|
|
100
|
+
*/
|
|
46
101
|
export type CosmosGraphPickingInfo = PickingInfo & {
|
|
47
102
|
elementType?: 'point' | 'link';
|
|
48
103
|
};
|
|
@@ -50,9 +105,9 @@ export type CosmosGraphLayerProps<PointDataT = unknown, LinkDataT = unknown> = C
|
|
|
50
105
|
type CosmosGraphLayerOwnProps<PointDataT, LinkDataT> = {
|
|
51
106
|
/**
|
|
52
107
|
* One entry per point — an array of your objects, or `{ length, initialPositions?, attributes? }`.
|
|
53
|
-
* The layer loads them, with `links
|
|
54
|
-
*
|
|
55
|
-
*
|
|
108
|
+
* The layer loads them, with `links` and the styling accessors, into the graph. Omit it to
|
|
109
|
+
* draw the data the graph already holds instead: the layer then writes nothing into the
|
|
110
|
+
* graph, styling accessors included — the mode for an application-loaded `graph`.
|
|
56
111
|
*/
|
|
57
112
|
points?: CosmosGraphPoints<PointDataT> | null;
|
|
58
113
|
/** One entry per link — an array of your objects, or a flat point-index pair array. Ignored without `points`. */
|
|
@@ -62,23 +117,24 @@ type CosmosGraphLayerOwnProps<PointDataT, LinkDataT> = {
|
|
|
62
117
|
* accessors may return ids instead of point indices.
|
|
63
118
|
*/
|
|
64
119
|
getPointId?: Accessor<PointDataT, string | number> | null;
|
|
65
|
-
/** Initial `[x, y]` position accessor for array points; points it leaves undefined are seeded randomly. */
|
|
66
|
-
getPointPosition?: Accessor<PointDataT, readonly [number, number] | null | undefined> | null;
|
|
67
120
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
121
|
+
* Initial `[x, y]` position accessor for array points, in cosmos space
|
|
122
|
+
* coordinates; points it leaves undefined are seeded randomly.
|
|
70
123
|
*/
|
|
71
|
-
|
|
124
|
+
getPointPosition?: Accessor<PointDataT, readonly [number, number] | null | undefined> | null;
|
|
72
125
|
/**
|
|
73
|
-
* Point
|
|
74
|
-
*
|
|
126
|
+
* Point size accessor, in cosmos.gl's units: pixels at zoom 1, scaled with the view
|
|
127
|
+
* when `config.scalePointsOnZoom` is on, times `config.pointSizeScale`. `0` hides the point.
|
|
128
|
+
* Unset, every point draws `config.pointDefaultSize`.
|
|
129
|
+
* @default null
|
|
75
130
|
*/
|
|
76
|
-
|
|
131
|
+
getPointSize?: Accessor<PointDataT, number> | null;
|
|
77
132
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
133
|
+
* Point RGBA color accessor, channels in 0..255 (deck's convention; converted for cosmos).
|
|
134
|
+
* Unset, every point draws `config.pointDefaultColor`.
|
|
135
|
+
* @default null
|
|
80
136
|
*/
|
|
81
|
-
|
|
137
|
+
getPointColor?: Accessor<PointDataT, Color> | null;
|
|
82
138
|
/**
|
|
83
139
|
* Source accessor for array links: a point index, or a point id when
|
|
84
140
|
* `getPointId` is set.
|
|
@@ -92,30 +148,27 @@ type CosmosGraphLayerOwnProps<PointDataT, LinkDataT> = {
|
|
|
92
148
|
*/
|
|
93
149
|
getLinkTarget?: Accessor<LinkDataT, string | number>;
|
|
94
150
|
/**
|
|
95
|
-
* Link RGBA color accessor, channels in 0..255.
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
getLinkColor?: Accessor<LinkDataT, Color>;
|
|
99
|
-
/**
|
|
100
|
-
* Link width accessor, in `linkWidthUnits`.
|
|
101
|
-
* @default 1
|
|
151
|
+
* Link RGBA color accessor, channels in 0..255. Unset, every link draws
|
|
152
|
+
* `config.linkDefaultColor`.
|
|
153
|
+
* @default null
|
|
102
154
|
*/
|
|
103
|
-
|
|
155
|
+
getLinkColor?: Accessor<LinkDataT, Color> | null;
|
|
104
156
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
157
|
+
* Link width accessor, in cosmos.gl's units (see `config.scaleLinksOnZoom`, `config.linkWidthScale`).
|
|
158
|
+
* Unset, every link draws `config.linkDefaultWidth`.
|
|
159
|
+
* @default null
|
|
107
160
|
*/
|
|
108
|
-
|
|
161
|
+
getLinkWidth?: Accessor<LinkDataT, number> | null;
|
|
109
162
|
/**
|
|
110
|
-
* Lets pointer drags grab a point: pinned on drag start, moved with the
|
|
111
|
-
*
|
|
112
|
-
*
|
|
163
|
+
* Lets pointer drags grab a point: pinned on drag start, moved with the pointer,
|
|
164
|
+
* released per `unpinOnDragEnd`. View panning is suppressed while a point is
|
|
165
|
+
* grabbed. Needs `pickable`.
|
|
113
166
|
* @default false
|
|
114
167
|
*/
|
|
115
168
|
enablePointDrag?: boolean;
|
|
116
169
|
/**
|
|
117
|
-
* Simulation alpha to restart with when a drag starts, so the graph
|
|
118
|
-
*
|
|
170
|
+
* Simulation alpha to restart with when a drag starts, so the graph responds
|
|
171
|
+
* to the moving point; `null` leaves the simulation untouched.
|
|
119
172
|
* @default 0.1
|
|
120
173
|
*/
|
|
121
174
|
dragReheatAlpha?: number | null;
|
|
@@ -131,130 +184,184 @@ type CosmosGraphLayerOwnProps<PointDataT, LinkDataT> = {
|
|
|
131
184
|
/** Called when a point drag ends. */
|
|
132
185
|
onPointDragEnd?: ((info: CosmosGraphPickingInfo) => void) | null;
|
|
133
186
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
187
|
+
* cosmos.gl's configuration — forces, space size, rendering options such as
|
|
188
|
+
* `curvedLinks`, `pointDefaultShape`, `linkDefaultArrows`, the simulation
|
|
189
|
+
* callbacks — passed to the layer-created `Graph`. A key left out goes back
|
|
190
|
+
* to the engine default. Ignored when `graph` is provided.
|
|
191
|
+
*/
|
|
192
|
+
config?: CosmosGraphLayerConfig;
|
|
193
|
+
/**
|
|
194
|
+
* An application-owned headless `Graph` to draw instead of creating one:
|
|
195
|
+
* `new Graph(null, config, devicePromise)` with the device from deck's
|
|
136
196
|
* `onDeviceInitialized`. The layer steps it while it runs (`pause()` it to
|
|
137
197
|
* take over stepping, then `deck.redraw()` after each manual `step()`) and
|
|
138
|
-
*
|
|
139
|
-
* `
|
|
140
|
-
*
|
|
198
|
+
* draws it; it never configures or destroys it — `config` and
|
|
199
|
+
* `onGraphCreated` apply only to a layer-created graph, and teardown is the
|
|
200
|
+
* application's, before `deck.finalize()`.
|
|
141
201
|
*
|
|
142
|
-
* `points` decides who loads the data. Given, the layer loads `points
|
|
143
|
-
* `links` into the
|
|
144
|
-
* it held. Omitted, the layer draws the
|
|
145
|
-
*
|
|
146
|
-
* however many draw it — as long as at most one of them loads data.
|
|
202
|
+
* `points` decides who loads the data. Given, the layer loads `points`,
|
|
203
|
+
* `links` and the styling accessors into the graph once the device check has
|
|
204
|
+
* passed, over whatever it held. Omitted, the layer draws the graph's own
|
|
205
|
+
* data and writes nothing. Several layers may draw one graph — it steps once
|
|
206
|
+
* per frame however many draw it — as long as at most one of them loads data.
|
|
147
207
|
*/
|
|
148
|
-
|
|
208
|
+
graph?: Graph | null;
|
|
149
209
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
210
|
+
* Called once with the layer-created `Graph` — the whole cosmos.gl API for
|
|
211
|
+
* what the props do not cover: pause, pin, reheat, shapes, clusters, trackers,
|
|
212
|
+
* sparse position writes. Not called for a provided `graph`.
|
|
153
213
|
*/
|
|
154
|
-
|
|
214
|
+
onGraphCreated?: ((graph: Graph) => void) | null;
|
|
155
215
|
/**
|
|
156
|
-
* Called
|
|
157
|
-
*
|
|
158
|
-
*
|
|
216
|
+
* Called after each load of `points` or `links` into the graph, once the
|
|
217
|
+
* graph holds the new data — and, with both load flags `false`, when only the
|
|
218
|
+
* id map changed. Use it to send what lines up with the graph's indices —
|
|
219
|
+
* link strengths, shapes, arrows, clusters, pins — again after a reload:
|
|
220
|
+
* `info.pointIndexById` and `info.links` map your data to those indices.
|
|
221
|
+
* Not called when the layer draws a graph's own data (no `points`).
|
|
222
|
+
*
|
|
223
|
+
* The first call comes when the graph is ready (and again after a `graph`
|
|
224
|
+
* swap), later ones during deck's layer update. Calls on `info.graph` are
|
|
225
|
+
* fine in either; defer anything that changes layer props. A throw goes to
|
|
226
|
+
* deck's `onError`, and the load stands.
|
|
159
227
|
*/
|
|
160
|
-
|
|
228
|
+
onGraphDataLoaded?: ((info: CosmosGraphDataLoadedInfo<LinkDataT>) => void) | null;
|
|
161
229
|
};
|
|
162
230
|
/** The slice of a deck gesture event the drag handlers need. */
|
|
163
231
|
type DragGestureEvent = {
|
|
164
232
|
stopImmediatePropagation?: () => void;
|
|
165
233
|
};
|
|
166
|
-
/** The endpoint channels of the links sublayer, read straight from the cosmos pair array. */
|
|
167
|
-
type LinkEndpointAttributes = {
|
|
168
|
-
getLinkSource: BinaryAttribute;
|
|
169
|
-
getLinkTarget: BinaryAttribute;
|
|
170
|
-
};
|
|
171
|
-
type BinaryLinksData = {
|
|
172
|
-
length: number;
|
|
173
|
-
attributes: LinkEndpointAttributes & CosmosLinkAttributes;
|
|
174
|
-
};
|
|
175
234
|
/**
|
|
176
|
-
* The cosmos.gl graph layer: give it points and links, and
|
|
177
|
-
*
|
|
178
|
-
* application's, via `
|
|
179
|
-
*
|
|
180
|
-
* animation frame from deck's shared timeline while it runs
|
|
181
|
-
* when it settles
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* `
|
|
185
|
-
*
|
|
235
|
+
* The cosmos.gl graph layer: give it points and links, and cosmos.gl lays them
|
|
236
|
+
* out and draws them under deck's camera. The layer creates a headless `Graph`
|
|
237
|
+
* on deck's device (or draws the application's, via `graph`), loads the data —
|
|
238
|
+
* or, without `points`, leaves the graph's own data alone — advances the
|
|
239
|
+
* simulation once per animation frame from deck's shared timeline while it runs
|
|
240
|
+
* (deck goes idle when it settles), hands deck's view to cosmos.gl before each
|
|
241
|
+
* draw and records cosmos.gl's own point and link draws into deck's render
|
|
242
|
+
* pass. Everything cosmos.gl renders is available through `config` and the
|
|
243
|
+
* `Graph` handle: shapes, arrows, dashes, curves, greyout, rings.
|
|
244
|
+
*
|
|
245
|
+
* The view: cosmos.gl's is a uniform scale plus a translation with y up, so
|
|
246
|
+
* the layer draws under an `OrthographicView({ flipY: false })` or a map view
|
|
247
|
+
* at pitch 0 and bearing 0, with `modelMatrix` placing the space in the world.
|
|
248
|
+
* A rotated, pitched or y-down view is reported once and not drawn.
|
|
249
|
+
*
|
|
250
|
+
* Picking is deck's: in deck's pick pass cosmos.gl draws its picking colors
|
|
251
|
+
* (an index per point and per link, hard-edged), so `pickable` gives hover and
|
|
252
|
+
* click with `info.elementType`, `info.index` and, for array data, `info.object`.
|
|
253
|
+
* `autoHighlight` lights the hovered point or link with cosmos.gl's own hover
|
|
254
|
+
* ring and hovered-link width (`config.hoveredPointRingColor`,
|
|
255
|
+
* `config.hoveredLinkWidthIncrease`, `config.hoveredLinkColor`) and leaves focus
|
|
256
|
+
* to the application; `highlightColor` is not used.
|
|
257
|
+
* `enablePointDrag` grabs a point and moves it, on a map as well.
|
|
186
258
|
*/
|
|
187
|
-
export declare class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown> extends
|
|
259
|
+
export declare class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown> extends Layer<Required<CosmosGraphLayerOwnProps<PointDataT, LinkDataT>>> {
|
|
188
260
|
static layerName: string;
|
|
189
261
|
static defaultProps: DefaultProps<CosmosGraphLayerProps<unknown, unknown>>;
|
|
190
262
|
state: {
|
|
191
|
-
|
|
192
|
-
/** The `
|
|
193
|
-
|
|
263
|
+
graph?: Graph;
|
|
264
|
+
/** The `graph` prop this state was built from; `null` when the layer created its own. */
|
|
265
|
+
providedGraph: Graph | null;
|
|
194
266
|
isReady: boolean;
|
|
195
|
-
/** `points` changed before the
|
|
267
|
+
/** `points` changed before the graph was ready: load them once it is. */
|
|
196
268
|
isIngestPending: boolean;
|
|
197
269
|
pointCount: number;
|
|
198
|
-
|
|
199
|
-
length: number;
|
|
200
|
-
attributes?: CosmosPointAttributes;
|
|
201
|
-
};
|
|
202
|
-
linksData: readonly LinkDataT[] | BinaryLinksData | null;
|
|
203
|
-
/** Array links only: the resolved `[source, target]` point-index pairs, one per entry of `linksData`. */
|
|
204
|
-
linkIndices: Float32Array | null;
|
|
270
|
+
linkCount: number;
|
|
205
271
|
/**
|
|
206
|
-
* Load mode: what the
|
|
207
|
-
*
|
|
272
|
+
* Load mode: what the graph holds, so a channel reloads only when its own input
|
|
273
|
+
* changes and a restyle leaves the layout alone. `loadedPositions` is the
|
|
208
274
|
* `initialPositions` array, `SEEDED`, or the points array; `loadedPairs` the pair
|
|
209
|
-
* array sent last; `idToIndex` the id map of the loaded points
|
|
275
|
+
* array sent last; `idToIndex` the id map of the loaded points; `keptLinks` the
|
|
276
|
+
* array links the graph holds, in its order.
|
|
210
277
|
*/
|
|
211
278
|
hasLoaded: boolean;
|
|
212
279
|
loadedPositions?: unknown;
|
|
213
280
|
loadedPairs?: Float32Array | null;
|
|
214
281
|
idToIndex?: Map<string | number, number> | null;
|
|
215
|
-
|
|
216
|
-
|
|
282
|
+
keptLinks: readonly LinkDataT[] | null;
|
|
283
|
+
/** The view was found unsupported and said so; said once. */
|
|
284
|
+
viewWarned?: boolean;
|
|
285
|
+
linksWarned?: boolean;
|
|
217
286
|
draggedPointIndex: number | null;
|
|
287
|
+
/**
|
|
288
|
+
* This layer's last auto-highlight write was a hover. Several layers may draw one
|
|
289
|
+
* graph, and the hover lives on the graph: only the layer holding it clears it.
|
|
290
|
+
*/
|
|
291
|
+
holdsHover: boolean;
|
|
218
292
|
animationHandle?: number;
|
|
219
293
|
};
|
|
220
294
|
get isLoaded(): boolean;
|
|
221
295
|
initializeState(): void;
|
|
222
296
|
updateState(params: UpdateParameters<this>): void;
|
|
223
|
-
|
|
297
|
+
draw(opts: {
|
|
298
|
+
shaderModuleProps?: {
|
|
299
|
+
picking?: {
|
|
300
|
+
isActive?: number | boolean;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
parameters?: {
|
|
304
|
+
blendColor?: number[];
|
|
305
|
+
};
|
|
306
|
+
}): void;
|
|
307
|
+
getPickingInfo({ info }: GetPickingInfoParams): CosmosGraphPickingInfo;
|
|
224
308
|
onDragStart(info: PickingInfo, event: DragGestureEvent): boolean;
|
|
225
309
|
onDrag(info: PickingInfo, event: DragGestureEvent): boolean;
|
|
226
310
|
onDragEnd(info: PickingInfo, event: DragGestureEvent): boolean;
|
|
227
|
-
|
|
228
|
-
/** The whole simulation space; lets deck's viewport helpers frame the graph. */
|
|
311
|
+
/** The whole simulation space, in space coordinates; lets deck's viewport helpers frame the graph. */
|
|
229
312
|
getBounds(): [number[], number[]] | null;
|
|
230
313
|
finalizeState(context: LayerContext): void;
|
|
314
|
+
/** No deck attributes: cosmos.gl holds every channel and draws them itself. */
|
|
315
|
+
protected _getAttributeManager(): null;
|
|
231
316
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
317
|
+
* deck's auto-highlight, through cosmos.gl's own hover emphasis: the hovered point
|
|
318
|
+
* gets the hover ring, the hovered link the hovered-link width and color. It is the
|
|
319
|
+
* graph's host hover, so the graph's config — focus included — stays the
|
|
320
|
+
* application's. deck's picking module has no model of ours to tint, so
|
|
321
|
+
* `highlightColor` does not apply.
|
|
235
322
|
*/
|
|
236
323
|
protected _updateAutoHighlight(info: PickingInfo): void;
|
|
237
|
-
/**
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
324
|
+
/**
|
|
325
|
+
* The pointer in space coordinates, through the view of the viewport the pointer
|
|
326
|
+
* is in — the same derivation `draw` hands cosmos, inverted — under a map as well
|
|
327
|
+
* as an orthographic view. Not through the view cosmos holds: that is whichever
|
|
328
|
+
* viewport drew the graph last, a thumbnail's as easily as the one being dragged
|
|
329
|
+
* in. Pixels are relative to that viewport. Where the view cannot be derived the
|
|
330
|
+
* point stays where it is.
|
|
331
|
+
*/
|
|
332
|
+
private _dragPosition;
|
|
333
|
+
/** Adopts the provided graph, or creates a headless one on deck's device when `provided` is `null`. */
|
|
334
|
+
private _attachGraph;
|
|
335
|
+
/**
|
|
336
|
+
* Destroys a layer-created graph; a provided one is left to the application, without
|
|
337
|
+
* the hover this layer put on it. deck sends no leave to a layer it removes.
|
|
338
|
+
*/
|
|
339
|
+
private _releaseGraph;
|
|
340
|
+
/** The graph's space size — authoritative for a provided graph too. */
|
|
242
341
|
private _spaceSize;
|
|
243
|
-
private _onTimelineTick;
|
|
244
342
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* tick, so it only compares until something differs.
|
|
343
|
+
* The config for a layer-created graph: the prop without the keys deck owns,
|
|
344
|
+
* and the pixel ratio deck's canvas draws at, so cosmos sizes pixels alike.
|
|
248
345
|
*/
|
|
249
|
-
private
|
|
250
|
-
|
|
346
|
+
private _graphConfig;
|
|
347
|
+
/** deck's device pixels per CSS pixel, as its canvas context reports them. */
|
|
348
|
+
private _pixelRatio;
|
|
349
|
+
/**
|
|
350
|
+
* cosmos's view for a deck viewport: a uniform scale `k` (pixels per space
|
|
351
|
+
* unit) and a translation, per `setViewTransform`'s space → screen formula,
|
|
352
|
+
* inverted. Three anchors through deck's projection — the space origin, its
|
|
353
|
+
* x axis, its y axis — give the scale and tell whether the view is one cosmos
|
|
354
|
+
* can draw: unrotated, unpitched, y up. The space origin's pixel is returned
|
|
355
|
+
* too, for mapping the other way.
|
|
356
|
+
*/
|
|
357
|
+
private _viewTransform;
|
|
358
|
+
private _onTimelineTick;
|
|
251
359
|
/**
|
|
252
|
-
* Load mode: puts the layer's `points
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* re-resolves array links without touching the positions.
|
|
360
|
+
* Load mode: puts the layer's `points`, `links` and styles into the graph.
|
|
361
|
+
* Each channel is sent only when its own input changed — a restyle leaves the
|
|
362
|
+
* layout alone, a changed id map re-resolves array links without touching the
|
|
363
|
+
* positions.
|
|
257
364
|
*/
|
|
258
|
-
private
|
|
365
|
+
private _load;
|
|
259
366
|
}
|
|
260
367
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A deck.gl layer that
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* A deck.gl layer that runs and draws a cosmos.gl graph. The simulation runs
|
|
3
|
+
* on deck.gl's own luma.gl device, and cosmos.gl's own renderer draws it into
|
|
4
|
+
* deck's render pass under deck's camera — positions never leave the GPU, and
|
|
5
|
+
* every cosmos.gl rendering option is available through `config`. Picking is
|
|
6
|
+
* deck's: cosmos.gl draws its picking colors in deck's pick pass.
|
|
7
7
|
*/
|
|
8
|
-
export { CosmosGraphLayer, type CosmosGraphLayerProps, type CosmosGraphPoints, type CosmosPointAttributes, type CosmosGraphLinks, type CosmosLinkAttributes, type CosmosGraphPickingInfo, } from './cosmos-graph-layer';
|
|
8
|
+
export { CosmosGraphLayer, DECK_OWNED_CONFIG_KEYS, type CosmosGraphLayerProps, type CosmosGraphLayerConfig, type CosmosGraphPoints, type CosmosPointAttributes, type CosmosGraphLinks, type CosmosLinkAttributes, type CosmosGraphDataLoadedInfo, type CosmosGraphPickingInfo, } from './cosmos-graph-layer';
|