@kineviz/gl 0.7.0 → 0.8.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/CHANGELOG.md +1142 -1
- package/LICENSE +21 -201
- package/NOTICE +9 -1
- package/README.md +1 -1
- package/dist/WebGLForceLayoutController-P6NPZ7WK.mjs +1538 -0
- package/dist/builtins.css +2 -0
- package/dist/builtins.d.mts +61 -0
- package/dist/builtins.d.ts +61 -0
- package/dist/builtins.js +3815 -0
- package/dist/builtins.mjs +2 -0
- package/dist/chunk-4PNV55G2.mjs +394 -0
- package/dist/chunk-67FBXXN6.mjs +2875 -0
- package/dist/chunk-EHGKWZTS.mjs +2 -0
- package/dist/chunk-L6OXJ7GJ.mjs +1245 -0
- package/dist/{chunk-EDTCHJCZ.mjs → chunk-Y34RQAIU.mjs} +2 -2
- package/dist/core-X3TWUvT9.d.ts +934 -0
- package/dist/core-ueqhAojr.d.mts +934 -0
- package/dist/core.css +2 -0
- package/dist/core.d.mts +11 -0
- package/dist/core.d.ts +11 -0
- package/dist/core.js +6187 -0
- package/dist/core.mjs +2 -0
- package/dist/index.css +1 -1
- package/dist/index.d.mts +1217 -19490
- package/dist/index.d.ts +1217 -19490
- package/dist/index.js +5496 -3173
- package/dist/index.mjs +662 -4383
- package/dist/kineviz-gl.css +1 -1
- package/dist/kineviz-gl.umd.js +5180 -3504
- package/dist/layout-gpu.js +42 -42
- package/dist/layout-gpu.mjs +12 -12
- package/dist/registry-BIPi31x_.d.mts +19930 -0
- package/dist/registry-BIPi31x_.d.ts +19930 -0
- package/dist/schemas.js +1 -1
- package/dist/schemas.mjs +1 -1
- package/dist/{webgpu-YXDFF4ZT.mjs → webgpu-SY2OB4QP.mjs} +2 -2
- package/dist/world-rings-6GQ4OWZC.mjs +2 -0
- package/package.json +22 -3
- package/dist/chunk-VTIPA7FV.mjs +0 -2
|
@@ -0,0 +1,934 @@
|
|
|
1
|
+
import { cX as LabelPosition, fE as FontConfig, p as GraphStore, cd as GraphContextValue, fF as MapProjection, cl as GraphThemeConfig, cI as IconAtlasManager, cN as ImageAtlasManager, fG as GlyphAtlasManager, c$ as LayoutControllerInterface, e6 as PositionProvider, cR as InteractionManager, R as RenderEngineApi, ck as GraphRendererProps, c2 as GPUNodeRendererConfig, dL as NodeRendererBackend, c0 as GPUEdgeRendererConfig, bs as EdgeRendererBackend, j as LayerRenderer } from './registry-BIPi31x_.js';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { NodeData } from '@kineviz/graph-core';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TextCloud - Node label rendering using @mapbox/tiny-sdf
|
|
9
|
+
*
|
|
10
|
+
* Uses system fonts with TinySDF for SDF generation — zero network download.
|
|
11
|
+
* Renders all labels in a single draw call via BatchTextRenderer.
|
|
12
|
+
*
|
|
13
|
+
* Backward-compatible API with the original MSDF-based TextCloud.
|
|
14
|
+
*
|
|
15
|
+
* Based on: web/react_views/graph_viz/clouds/TextCloud.js
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* MSDF Font data structure (kept for backward compatibility)
|
|
20
|
+
*/
|
|
21
|
+
interface MSDFFont {
|
|
22
|
+
info: {
|
|
23
|
+
charset: string[];
|
|
24
|
+
face?: string;
|
|
25
|
+
size?: number;
|
|
26
|
+
};
|
|
27
|
+
common: {
|
|
28
|
+
scaleW: number;
|
|
29
|
+
scaleH: number;
|
|
30
|
+
lineHeight?: number;
|
|
31
|
+
base?: number;
|
|
32
|
+
};
|
|
33
|
+
charsMap: Record<string, MSDFGlyph>;
|
|
34
|
+
kerningsMap: Record<string, number>;
|
|
35
|
+
distanceField?: {
|
|
36
|
+
fieldType: string;
|
|
37
|
+
distanceRange: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* MSDF Glyph data (kept for backward compatibility)
|
|
42
|
+
*/
|
|
43
|
+
interface MSDFGlyph {
|
|
44
|
+
id: number;
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
_y?: number;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
xoffset: number;
|
|
51
|
+
yoffset: number;
|
|
52
|
+
xadvance: number;
|
|
53
|
+
page: number;
|
|
54
|
+
chnl: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Buffer-direct text source for large graphs (10K+ nodes).
|
|
58
|
+
* Avoids creating TextItem objects for every node — resolvers are only called
|
|
59
|
+
* for the few hundred nodes that pass frustum + distance culling.
|
|
60
|
+
*/
|
|
61
|
+
interface BufferTextSource {
|
|
62
|
+
/** Interleaved xyz positions (length = nodeCount * 3) */
|
|
63
|
+
positions: Float32Array;
|
|
64
|
+
/** Number of nodes */
|
|
65
|
+
nodeCount: number;
|
|
66
|
+
/** Return label text for a node index, or null to skip */
|
|
67
|
+
textResolver: (index: number) => string | null;
|
|
68
|
+
/** Return node size for a node index. Default: 1 */
|
|
69
|
+
sizeResolver?: (index: number) => number;
|
|
70
|
+
/** Return true if node at index is hidden. Default: false */
|
|
71
|
+
hiddenResolver?: (index: number) => boolean;
|
|
72
|
+
/** Return dim opacity for a node index (focusContext / click dim). Default: 1 */
|
|
73
|
+
opacityResolver?: (index: number) => number;
|
|
74
|
+
/**
|
|
75
|
+
* Return the label footprint of a node index as `[nx, ny, wx, wy]` (see
|
|
76
|
+
* {@link TextItem.extentX}), or null for the built-in node. Default: null.
|
|
77
|
+
*/
|
|
78
|
+
extentResolver?: (index: number) => readonly [number, number, number, number] | null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Text item to render
|
|
82
|
+
*/
|
|
83
|
+
interface TextItem {
|
|
84
|
+
/**
|
|
85
|
+
* Optional stable id for the underlying node/edge this label belongs to.
|
|
86
|
+
* Required for hover-neighbor-highlight to dim individual labels; if absent,
|
|
87
|
+
* the renderer falls back to a positional id (`node-text-N`) which the
|
|
88
|
+
* controller cannot target.
|
|
89
|
+
*/
|
|
90
|
+
id?: string;
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
z: number;
|
|
94
|
+
text: string;
|
|
95
|
+
opacity?: number;
|
|
96
|
+
nodeSize?: number;
|
|
97
|
+
angle?: number;
|
|
98
|
+
quaternion?: THREE.Quaternion;
|
|
99
|
+
/** Per-item text alignment override (e.g. for radial layouts where left/right side labels differ) */
|
|
100
|
+
textAlign?: "left" | "center" | "right";
|
|
101
|
+
/** Line offset index for multi-line captions. 0 = first line, 1 = second, etc. */
|
|
102
|
+
lineIndex?: number;
|
|
103
|
+
/** Total number of lines for this node (used to adjust vertical centering). */
|
|
104
|
+
lineCount?: number;
|
|
105
|
+
/** Per-item scale multiplier for multi-caption line sizing. Default: 1.0 */
|
|
106
|
+
sizeScale?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Half-width / half-height the label must clear, in built-in node radii.
|
|
109
|
+
* Default 1: the built-in node. A layer drawing a 16:9 panel at 6x the node
|
|
110
|
+
* size reports about (6, 3.4), and the label lands under the panel instead
|
|
111
|
+
* of in its middle. Filled by TextLayer from `GraphStore.getNodeLabelExtent`.
|
|
112
|
+
*/
|
|
113
|
+
extentX?: number;
|
|
114
|
+
extentY?: number;
|
|
115
|
+
/** Same, in world units, for world-sized drawings. Default 0. The larger of the two wins. */
|
|
116
|
+
worldExtentX?: number;
|
|
117
|
+
worldExtentY?: number;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Radial placement for a label at (dx, dy) from the centre, given the per-axis
|
|
121
|
+
* gaps from `labelGaps`. The text runs outward along the ray; on the left half
|
|
122
|
+
* it is turned half a turn and right-aligned, so it still reads left to right
|
|
123
|
+
* and still starts at the node and runs away from the centre. A label at the
|
|
124
|
+
* centre itself falls back to plain `right` placement.
|
|
125
|
+
*/
|
|
126
|
+
declare function radialLabelPlacement(dx: number, dy: number, gapX: number, gapY: number): {
|
|
127
|
+
rotation: number;
|
|
128
|
+
offsetX: number;
|
|
129
|
+
textAlign: "left" | "right";
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* TextCloud configuration options
|
|
133
|
+
*/
|
|
134
|
+
interface TextCloudConfig {
|
|
135
|
+
font?: MSDFFont;
|
|
136
|
+
texture?: THREE.Texture;
|
|
137
|
+
scale?: number;
|
|
138
|
+
maxLength?: number;
|
|
139
|
+
position?: LabelPosition;
|
|
140
|
+
color?: string | number;
|
|
141
|
+
lightColor?: string | number;
|
|
142
|
+
darkColor?: string | number;
|
|
143
|
+
autoCaption?: boolean;
|
|
144
|
+
lodDistance?: number;
|
|
145
|
+
fontConfig?: FontConfig;
|
|
146
|
+
isDark?: boolean;
|
|
147
|
+
/** Text scale multiplier. Final scale = nodeWorldRadius * scale * textScale. Default: 1.0 */
|
|
148
|
+
textScale?: number;
|
|
149
|
+
/**
|
|
150
|
+
* @deprecated No longer applied here. Global node size scale is owned by
|
|
151
|
+
* GraphStore (`setGlobalNodeSizeScale`) and pre-multiplied into the
|
|
152
|
+
* `nodeSize` value the caller passes in (sourced from `effectiveSizes`).
|
|
153
|
+
* `setNodeSizeScale()` is preserved as a routing shim to the store.
|
|
154
|
+
*/
|
|
155
|
+
nodeSizeScale?: number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* TextCloud - Renders node labels using TinySDF-based SDF text
|
|
159
|
+
*/
|
|
160
|
+
declare class TextCloud {
|
|
161
|
+
private store;
|
|
162
|
+
private scene;
|
|
163
|
+
private camera;
|
|
164
|
+
private renderer;
|
|
165
|
+
private config;
|
|
166
|
+
private batchRenderer;
|
|
167
|
+
private _visible;
|
|
168
|
+
private _isDarkTheme;
|
|
169
|
+
private _isMapMode;
|
|
170
|
+
private _mapDamping;
|
|
171
|
+
/**
|
|
172
|
+
* Cached upper-bound for on-screen node/text pixel diameter, queried once from the WebGL
|
|
173
|
+
* context's ALIASED_POINT_SIZE_RANGE. Originally the GPU's gl_PointSize cap; after the node
|
|
174
|
+
* quad-billboard migration this no longer constrains node rendering, but the value is still
|
|
175
|
+
* a reasonable hardware-aware ceiling for sizing labels relative to nodes.
|
|
176
|
+
*/
|
|
177
|
+
private _maxPointSize;
|
|
178
|
+
private marginLeft;
|
|
179
|
+
private marginTop;
|
|
180
|
+
private radians;
|
|
181
|
+
private textAlign;
|
|
182
|
+
private verticalAlign;
|
|
183
|
+
/** When true, marginTop is applied to anchorY in world space (not as a rotated local offset) */
|
|
184
|
+
private anchorYOffset;
|
|
185
|
+
/** `position: "radial"` — each label is turned along the ray from the centre. */
|
|
186
|
+
private radial;
|
|
187
|
+
/** Fixed radial centre in scene space; null = the middle of the labelled nodes. */
|
|
188
|
+
private radialCenter;
|
|
189
|
+
constructor(store: GraphStore, scene: THREE.Object3D, camera: THREE.Camera, config?: TextCloudConfig, renderer?: THREE.WebGLRenderer);
|
|
190
|
+
private getTextColor;
|
|
191
|
+
/**
|
|
192
|
+
* Set the label position relative to nodes
|
|
193
|
+
*/
|
|
194
|
+
setLabelPosition(position: LabelPosition): void;
|
|
195
|
+
/**
|
|
196
|
+
* Centre that `"radial"` labels turn around, in scene space. Null (the
|
|
197
|
+
* default) uses the middle of the bounding box of the labelled nodes.
|
|
198
|
+
*/
|
|
199
|
+
setRadialCenter(center: readonly [number, number] | null): void;
|
|
200
|
+
/** Middle of the bounding box of a set of points, or [0, 0] for none. */
|
|
201
|
+
private boxCentre;
|
|
202
|
+
/** Set font (no-op in TinySDF mode — kept for backward compat) */
|
|
203
|
+
setFont(_font: MSDFFont, _texture: THREE.Texture): void;
|
|
204
|
+
setScale(scale: number): void;
|
|
205
|
+
setTextScale(textScale: number): void;
|
|
206
|
+
/**
|
|
207
|
+
* Routes to GraphStore.setGlobalNodeSizeScale() so node visuals, edge
|
|
208
|
+
* arrow back-off, and label sizing all scale in lockstep. Callers feed
|
|
209
|
+
* `nodeSize` from `effectiveSizes` already, so nothing local to multiply.
|
|
210
|
+
*/
|
|
211
|
+
setNodeSizeScale(scale: number): void;
|
|
212
|
+
setMaxLength(length: number): void;
|
|
213
|
+
switchTheme(isDark?: boolean): void;
|
|
214
|
+
setVisible(visible: boolean): void;
|
|
215
|
+
/** Labels follow `map.maxNodeGrowth` (0.75 × it); see BatchTextRenderer.setMapMaxGrowth. */
|
|
216
|
+
setMapMaxGrowth(nodeMaxGrowth: number): void;
|
|
217
|
+
setMapMode(enabled: boolean, sphereRadius?: number, damping?: number): void;
|
|
218
|
+
get visible(): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Update text geometry from text items.
|
|
221
|
+
* Convert TextItem[] (old API) to TextEntry[] (new BatchTextRenderer API).
|
|
222
|
+
*/
|
|
223
|
+
/** Maximum number of labels to render. Prevents GPU overload with large graphs. */
|
|
224
|
+
private _maxVisibleLabels;
|
|
225
|
+
setMaxVisibleLabels(max: number): void;
|
|
226
|
+
/**
|
|
227
|
+
* Hover-neighbor-highlight: mark this id's label glyphs as dimmed (1) or
|
|
228
|
+
* not (0). The id matches the TextEntry.id used in updateTexts — for node
|
|
229
|
+
* labels it's the node id string.
|
|
230
|
+
*/
|
|
231
|
+
setHoverDimById(id: string, value: 0 | 1): void;
|
|
232
|
+
/** Clear hover-dim flag on all label glyphs (hover-leave / disable). */
|
|
233
|
+
clearAllHoverDim(): void;
|
|
234
|
+
/** Forward hover-emphasis uniform writes (u_hoverProgress / u_hoverDimOpacity). */
|
|
235
|
+
setHoverUniform(name: "u_hoverProgress" | "u_hoverDimOpacity", value: number): void;
|
|
236
|
+
/**
|
|
237
|
+
* Cull cache: skips frustum cull + distance sort + glyph re-layout when
|
|
238
|
+
* neither the view nor the items changed since the last updateTexts().
|
|
239
|
+
* All inputs consumed by updateTexts are covered: items via a per-field
|
|
240
|
+
* value snapshot (writeTextItemSignature), everything else via the numeric
|
|
241
|
+
* view signature built in _fillViewSignature().
|
|
242
|
+
*/
|
|
243
|
+
private _cullCache;
|
|
244
|
+
/** Reused buffer for the view signature (no per-frame allocation). */
|
|
245
|
+
private _viewSigValues;
|
|
246
|
+
/**
|
|
247
|
+
* Collect every non-item input of updateTexts() into a flat numeric array:
|
|
248
|
+
* scene/camera/projection matrices, renderer size & pixel ratio, the
|
|
249
|
+
* store's global node size scale, label config and placement state.
|
|
250
|
+
* Epsilon-compared by CullCache (1e-4) so idle-camera frames hit the cache.
|
|
251
|
+
*/
|
|
252
|
+
private _fillViewSignature;
|
|
253
|
+
updateTexts(items: TextItem[]): void;
|
|
254
|
+
/**
|
|
255
|
+
* Buffer-direct culling for large graphs (10K+ nodes).
|
|
256
|
+
*
|
|
257
|
+
* Instead of receiving pre-built TextItem[] (which requires creating 1M objects),
|
|
258
|
+
* this method works directly on the raw Float32Array positions buffer.
|
|
259
|
+
* Text/size resolvers are only called for nodes that pass frustum + distance culling.
|
|
260
|
+
*
|
|
261
|
+
* Same culling math as updateTexts(): frustum → distance LOD → dynamic cap.
|
|
262
|
+
*/
|
|
263
|
+
updateFromBuffer(source: BufferTextSource): void;
|
|
264
|
+
/** Called each frame */
|
|
265
|
+
update(): void;
|
|
266
|
+
dispose(): void;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Factory function to create a TextCloud
|
|
270
|
+
*/
|
|
271
|
+
declare function createTextCloud(store: GraphStore, scene: THREE.Object3D, camera: THREE.Camera, config?: TextCloudConfig, renderer?: THREE.WebGLRenderer): TextCloud;
|
|
272
|
+
|
|
273
|
+
declare const GraphContext: React.Context<GraphContextValue>;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* ViewStateStore — external store for GraphContext's reactive view state
|
|
277
|
+
* (contextValue identity redesign, see
|
|
278
|
+
* notes/specs/2026-06-11-contextvalue-identity-redesign.md).
|
|
279
|
+
*
|
|
280
|
+
* The single source of truth for the reactive view state: consumers
|
|
281
|
+
* subscribe via `useSyncExternalStore`, and the identity-stable context
|
|
282
|
+
* handle's getters read it live. The snapshot is replaced immutably on
|
|
283
|
+
* change (unchanged fields keep reference identity), so per-field reads
|
|
284
|
+
* bail out via `Object.is`. Notification is synchronous; React 18 batching
|
|
285
|
+
* coalesces same-flush patches into one re-render per subscriber.
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
interface GraphViewState {
|
|
289
|
+
isMapMode: boolean;
|
|
290
|
+
mapDamping: number;
|
|
291
|
+
mapSphereRadius: number;
|
|
292
|
+
is3D: boolean;
|
|
293
|
+
effectiveMapProjection: MapProjection;
|
|
294
|
+
theme: GraphThemeConfig;
|
|
295
|
+
textScale: number;
|
|
296
|
+
edgeTextScale: number;
|
|
297
|
+
iconAtlasManager: IconAtlasManager | null;
|
|
298
|
+
imageAtlasManager: ImageAtlasManager | null;
|
|
299
|
+
glyphAtlasManager: GlyphAtlasManager | null;
|
|
300
|
+
layoutController: LayoutControllerInterface | undefined;
|
|
301
|
+
layoutPositionProvider: PositionProvider | undefined;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* graph-context/hooks.ts — the consumer hooks for GraphContext:
|
|
306
|
+
* - `useGraphHandle()` — the identity-stable context handle (never re-renders
|
|
307
|
+
* on view-state changes);
|
|
308
|
+
* - per-field view-state hooks (`useViewStateField` and the named wrappers:
|
|
309
|
+
* `useIsMapMode`, `useMapDamping`, `useTheme`, `useTextScales`,
|
|
310
|
+
* `useAtlasManagers`, `useLayoutController`, …) backed by
|
|
311
|
+
* `useSyncExternalStore` on the ViewStateStore;
|
|
312
|
+
* - compat `useGraph()` (handle + re-render on any view-state change) and
|
|
313
|
+
* the version hooks (`useGraphVersion`, `useGraphIconVersion`) plus the
|
|
314
|
+
* scene/camera/interaction accessors.
|
|
315
|
+
*
|
|
316
|
+
* Must never import from `../GraphContext` (no cycles); the context object
|
|
317
|
+
* comes from `./context` and `GraphContextValue` from `./types`.
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Stable engine handle — identity never changes for the engine's lifetime,
|
|
322
|
+
* and reading it does NOT subscribe to reactive view-state changes.
|
|
323
|
+
* Use for store/scene/camera/renderer/methods-only consumers.
|
|
324
|
+
*/
|
|
325
|
+
declare function useGraphHandle(): GraphContextValue;
|
|
326
|
+
/** Subscribe to a single reactive view-state field. */
|
|
327
|
+
declare function useViewStateField<K extends keyof GraphViewState>(key: K): GraphViewState[K];
|
|
328
|
+
declare function useIsMapMode(): boolean;
|
|
329
|
+
declare function useMapDamping(): number;
|
|
330
|
+
declare function useMapSphereRadius(): number;
|
|
331
|
+
declare function useTheme(): GraphThemeConfig;
|
|
332
|
+
declare function useEffectiveMapProjection(): MapProjection;
|
|
333
|
+
/**
|
|
334
|
+
* NOTE: the returned object is a fresh allocation each render — destructure
|
|
335
|
+
* the fields into effect dep arrays; never depend on the object itself.
|
|
336
|
+
*/
|
|
337
|
+
declare function useTextScales(): {
|
|
338
|
+
textScale: number;
|
|
339
|
+
edgeTextScale: number;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* NOTE: the returned object is a fresh allocation each render — destructure
|
|
343
|
+
* the fields into effect dep arrays; never depend on the object itself.
|
|
344
|
+
*/
|
|
345
|
+
declare function useAtlasManagers(): {
|
|
346
|
+
iconAtlasManager: IconAtlasManager | null;
|
|
347
|
+
imageAtlasManager: ImageAtlasManager | null;
|
|
348
|
+
glyphAtlasManager: GlyphAtlasManager | null;
|
|
349
|
+
};
|
|
350
|
+
declare function useLayoutController(): LayoutControllerInterface | undefined;
|
|
351
|
+
declare function useLayoutPositionProvider(): PositionProvider | undefined;
|
|
352
|
+
/**
|
|
353
|
+
* Compat hook: returns the stable handle AND re-renders on ANY reactive
|
|
354
|
+
* view-state change (subscription keyed on snapshot identity). Prefer
|
|
355
|
+
* useGraphHandle() + per-field hooks in new code.
|
|
356
|
+
*/
|
|
357
|
+
declare function useGraph(): GraphContextValue;
|
|
358
|
+
/**
|
|
359
|
+
* Hook to access the graph store
|
|
360
|
+
* (stable field — reads the handle, no reactive re-renders)
|
|
361
|
+
*/
|
|
362
|
+
declare function useGraphStore(): GraphStore;
|
|
363
|
+
/**
|
|
364
|
+
* Hook that re-renders when store version changes
|
|
365
|
+
*/
|
|
366
|
+
declare function useGraphVersion(): number;
|
|
367
|
+
/**
|
|
368
|
+
* Hook to access the Three.js scene
|
|
369
|
+
* (stable field — reads the handle, no reactive re-renders)
|
|
370
|
+
*/
|
|
371
|
+
declare function useScene(): THREE.Scene;
|
|
372
|
+
/**
|
|
373
|
+
* Hook to access the camera
|
|
374
|
+
* (stable field — reads the handle, no reactive re-renders)
|
|
375
|
+
*/
|
|
376
|
+
declare function useCamera(): THREE.PerspectiveCamera;
|
|
377
|
+
/**
|
|
378
|
+
* Hook to access the cloudScene group
|
|
379
|
+
* Renderers should add objects to cloudScene, not scene directly
|
|
380
|
+
* (stable field — reads the handle, no reactive re-renders)
|
|
381
|
+
*/
|
|
382
|
+
declare function useCloudScene(): THREE.Group;
|
|
383
|
+
/**
|
|
384
|
+
* Hook to access the interaction manager
|
|
385
|
+
* (stable field — reads the handle, no reactive re-renders)
|
|
386
|
+
*/
|
|
387
|
+
declare function useInteraction(): InteractionManager | null;
|
|
388
|
+
/**
|
|
389
|
+
* Hook to access 3D mode state and setter.
|
|
390
|
+
* Re-renders only on `is3D` changes (per-field subscription); the setter is
|
|
391
|
+
* the handle's stable method.
|
|
392
|
+
*/
|
|
393
|
+
declare function useIs3D(): {
|
|
394
|
+
is3D: boolean;
|
|
395
|
+
setIs3D: (is3D: boolean) => void;
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Access the `RenderEngineApi` instance from the nearest `<GraphRenderer>`
|
|
400
|
+
* ancestor. Throws if called outside a GraphRenderer subtree.
|
|
401
|
+
*/
|
|
402
|
+
declare function useRenderEngineApi(): RenderEngineApi;
|
|
403
|
+
/**
|
|
404
|
+
* Same as `useRenderEngineApi` but returns `null` when called outside a
|
|
405
|
+
* `<GraphRenderer>` subtree. Use this in optional overlays that can degrade
|
|
406
|
+
* gracefully when the engine isn't mounted yet.
|
|
407
|
+
*/
|
|
408
|
+
declare function useOptionalRenderEngineApi(): RenderEngineApi | null;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* GraphRenderer - Main container component for graph rendering
|
|
412
|
+
*
|
|
413
|
+
* Sets up Three.js scene, renderer, and camera.
|
|
414
|
+
* Provides context for child components.
|
|
415
|
+
*/
|
|
416
|
+
declare function GraphRenderer({ container: containerProp, className, style, backgroundColor, antialias, pixelRatio, children, store: storeProp, controls: controlsProp, enableControl, drag: dragProp, enableDrag, controlConfig, cameraZ, initialPosition, onReady, apiRef, apiOptions, nodeCloud: nodeCloudRaw, edgeCloud: edgeCloudRaw, node: nodePropRaw, edge: edgePropRaw, caption: captionProp, edgeCaption: edgeCaptionProp, data: dataProp, enableWebGPURenderPath, minimap: minimapPropRaw, map: mapProp, toolbar: toolbarProp, legend: legendProp, locale, layoutController, forceLayout, autoFit: autoFitProp, autoStartLayout, iconFonts, theme, mapProvider, textScale: textScaleProp, edgeTextScale: edgeTextScaleProp, is3D: is3DProp, defaultDim, mapProjection: mapProjectionProp, onThemeChange, onViewChange, clickDim, restoreOnBackgroundClick, onNodeClick, onNodeDoubleClick, onEdgeClick, onEdgeDoubleClick, onBackgroundClick, onNodeContextMenu, onEdgeContextMenu, onBackgroundContextMenu, onNodeHover, onEdgeHover, onNodeDragStart, onNodeDrag, onNodeDragEnd, onDestroy, onError, onDelta, onLayoutStart, onLayoutEnd, onLayoutProgress, onAlgorithmStart, onAlgorithmEnd, onAlgorithmError, onAlgorithmProgress, onHistoryChange, onStyleChange, selection, defaultSelection, onSelectionChange, hidden, defaultHidden, onVisibilityChange, defaultIs3D, onIs3DChange, defaultTheme, defaultViewState, viewState, onViewStateChange, hoveredId, onHoverChange, pinned, defaultPinned, onPinnedChange, }: GraphRendererProps): react_jsx_runtime.JSX.Element;
|
|
417
|
+
|
|
418
|
+
/** GraphCanvas — alias for GraphRenderer (used in new layer system API) */
|
|
419
|
+
declare const GraphCanvas: typeof GraphRenderer;
|
|
420
|
+
type GraphCanvasProps = GraphRendererProps;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* NodeCloud - React component for rendering nodes
|
|
424
|
+
*
|
|
425
|
+
* A-Frame style declarative API:
|
|
426
|
+
* ```tsx
|
|
427
|
+
* <GraphRenderer>
|
|
428
|
+
* <NodeCloud useCircle iconColumns={4} />
|
|
429
|
+
* </GraphRenderer>
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
|
|
433
|
+
interface NodeCloudProps extends Partial<GPUNodeRendererConfig> {
|
|
434
|
+
/** Position provider (for GPU/CPU position sources) */
|
|
435
|
+
positionProvider?: PositionProvider;
|
|
436
|
+
/** Icon atlas texture */
|
|
437
|
+
iconAtlas?: THREE.Texture;
|
|
438
|
+
/** Pin indicator texture */
|
|
439
|
+
pinTexture?: THREE.Texture;
|
|
440
|
+
/** Avatar array texture (WebGL2) */
|
|
441
|
+
avatarTexture?: THREE.Texture;
|
|
442
|
+
/** Override theme for nodes: 'dark' = dark ring style, 'light' = light ring style */
|
|
443
|
+
theme?: 'dark' | 'light';
|
|
444
|
+
/** Default node size for nodes without explicit size. Applied to store.defaultNodeSize. */
|
|
445
|
+
defaultNodeSize?: number;
|
|
446
|
+
/** Callback when renderer is ready */
|
|
447
|
+
onReady?: (renderer: NodeRendererBackend) => void;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* NodeCloud component
|
|
451
|
+
*
|
|
452
|
+
* Renders nodes using GPUNodeRenderer with automatic updates
|
|
453
|
+
* when GraphStore changes.
|
|
454
|
+
*/
|
|
455
|
+
declare function NodeCloud({ positionProvider, iconAtlas, iconColumns, pinTexture, avatarTexture, useCircle, iconMode, iconDisplayMode, hidePin, hideRing, lightMode, theme: themeProp, fixedSize, nodeSizeScale, minPixelSize, primitive, defaultNodeSize, maxNodes, onReady, }: NodeCloudProps): any;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* EdgeCloud - React component for rendering edges
|
|
459
|
+
*
|
|
460
|
+
* A-Frame style declarative API:
|
|
461
|
+
* ```tsx
|
|
462
|
+
* <GraphRenderer>
|
|
463
|
+
* <EdgeCloud showArrows lineWidthScale={1.5} />
|
|
464
|
+
* </GraphRenderer>
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
|
|
468
|
+
interface EdgeCloudProps extends Partial<GPUEdgeRendererConfig> {
|
|
469
|
+
/** Position provider (for GPU/CPU position sources) */
|
|
470
|
+
positionProvider?: PositionProvider;
|
|
471
|
+
/** Show arrow markers at edge endpoints. Default: false */
|
|
472
|
+
showArrows?: boolean;
|
|
473
|
+
/** Callback when renderer is ready */
|
|
474
|
+
onReady?: (renderer: EdgeRendererBackend) => void;
|
|
475
|
+
/** Default edge shape. Default: "straight" */
|
|
476
|
+
edgeShape?: "straight" | "curve" | "radial" | "orthogonal" | "routed" | "family";
|
|
477
|
+
/** Radial routing axis. Default: "auto" */
|
|
478
|
+
radialAxis?: "auto" | "vertical" | "horizontal";
|
|
479
|
+
/** Line width scale factor. Default: 1.0 */
|
|
480
|
+
lineWidthScale?: number;
|
|
481
|
+
/** Whether edges attenuate with distance. Default: false */
|
|
482
|
+
sizeAttenuation?: boolean;
|
|
483
|
+
/** Arrow scale factor. Default: 1.0 */
|
|
484
|
+
arrowScale?: number;
|
|
485
|
+
/** Dash array pattern */
|
|
486
|
+
dashArray?: number;
|
|
487
|
+
/** Dash offset */
|
|
488
|
+
dashOffset?: number;
|
|
489
|
+
/** Dash ratio */
|
|
490
|
+
dashRatio?: number;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* EdgeCloud component
|
|
494
|
+
*
|
|
495
|
+
* Renders edges using GPUEdgeRenderer with automatic updates
|
|
496
|
+
* when GraphStore changes.
|
|
497
|
+
*/
|
|
498
|
+
declare function EdgeCloud({ positionProvider, maxEdges, lineWidthScale, sizeAttenuation, showArrows, arrowScale, nodeSizeScale, dashArray, dashOffset, dashRatio, edgeShape, radialAxis, onReady, }: EdgeCloudProps): any;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* TextLayer - React component for rendering node labels
|
|
502
|
+
*
|
|
503
|
+
* Wraps the imperative TextCloud class as a declarative React component.
|
|
504
|
+
* Labels are positioned relative to nodes and auto-update when the graph changes.
|
|
505
|
+
*
|
|
506
|
+
* ```tsx
|
|
507
|
+
* <GraphRenderer container={containerRef.current}>
|
|
508
|
+
* <NodeCloud useCircle />
|
|
509
|
+
* <EdgeCloud showArrows />
|
|
510
|
+
* {showLabels && <TextLayer position="bottom" maxLength={20} />}
|
|
511
|
+
* </GraphRenderer>
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
|
|
515
|
+
interface TextLayerProps {
|
|
516
|
+
/** Label position relative to node. Default: "right" */
|
|
517
|
+
position?: LabelPosition;
|
|
518
|
+
/** Text scale multiplier. Default: 1.0 */
|
|
519
|
+
scale?: number;
|
|
520
|
+
/** Text scale multiplier. If not provided, uses GraphCanvas.textScale (default: 0.6) */
|
|
521
|
+
textScale?: number;
|
|
522
|
+
/** Maximum text length before truncation. Default: 50 */
|
|
523
|
+
maxLength?: number;
|
|
524
|
+
/** Text color (overrides theme). */
|
|
525
|
+
color?: string | number;
|
|
526
|
+
/** Light theme text color. Default: 0x333333 */
|
|
527
|
+
lightColor?: string | number;
|
|
528
|
+
/** Dark theme text color. Default: 0xffffff */
|
|
529
|
+
darkColor?: string | number;
|
|
530
|
+
/** Auto-caption from node properties. Default: true */
|
|
531
|
+
autoCaption?: boolean;
|
|
532
|
+
/**
|
|
533
|
+
* LOD distance threshold. All labels are hidden once the camera is farther
|
|
534
|
+
* than `5 × lodDistance` world units from the scene origin (not applied in
|
|
535
|
+
* map mode). When unset, nothing is passed and TextCloud's default of 1.0
|
|
536
|
+
* applies, i.e. labels disappear beyond 5 units.
|
|
537
|
+
*/
|
|
538
|
+
lodDistance?: number;
|
|
539
|
+
/** @deprecated Use `theme` prop or GraphCanvas `theme` instead */
|
|
540
|
+
isDark?: boolean;
|
|
541
|
+
/** Override theme for this layer: 'dark' = white text, 'light' = dark text */
|
|
542
|
+
theme?: 'dark' | 'light';
|
|
543
|
+
/** Visibility. Default: true */
|
|
544
|
+
visible?: boolean;
|
|
545
|
+
/** Which node property to display as label (default: caption/name) */
|
|
546
|
+
property?: string;
|
|
547
|
+
/** Multiple properties to display as multi-line captions. Overrides `property` when set. */
|
|
548
|
+
properties?: string[];
|
|
549
|
+
/** Maximum visible labels (dynamic cap). Default: 500 */
|
|
550
|
+
maxVisibleLabels?: number;
|
|
551
|
+
/** Custom text item provider — overrides auto-generated labels */
|
|
552
|
+
getTextItems?: (store: any, positionProvider: PositionProvider | null) => TextItem[];
|
|
553
|
+
/**
|
|
554
|
+
* Centre that `position="radial"` labels turn around: a node id (the
|
|
555
|
+
* centre follows that node, e.g. the root of a radial tree, while it is
|
|
556
|
+
* dragged) or a fixed `[x, y]` in graph space. Default: the middle of the
|
|
557
|
+
* labelled nodes. Ignored for other positions.
|
|
558
|
+
*/
|
|
559
|
+
radialCenter?: string | readonly [number, number];
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* TextLayer component
|
|
563
|
+
*
|
|
564
|
+
* Renders node labels using TinySDF-based SDF text rendering.
|
|
565
|
+
* All labels are drawn in a single draw call via BatchTextRenderer.
|
|
566
|
+
*/
|
|
567
|
+
declare function TextLayer({ position, scale, maxLength, color, lightColor, darkColor, autoCaption, lodDistance, isDark, theme: themeProp, visible, property, properties, maxVisibleLabels, getTextItems, textScale: textScaleProp, radialCenter, }: TextLayerProps): any;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* EdgeTextCloud - Edge label rendering using @mapbox/tiny-sdf
|
|
571
|
+
*
|
|
572
|
+
* Renders relationship names and property values at edge midpoints.
|
|
573
|
+
* Handles curved edges (quadratic bezier), self-loops, and multi-edges.
|
|
574
|
+
* Text auto-rotates to follow edge direction and stays readable (never upside down).
|
|
575
|
+
*
|
|
576
|
+
* Based on: web/react_views/graph_viz/clouds/EdgeTextCloud.js
|
|
577
|
+
*/
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Edge text item with edge-specific positioning data
|
|
581
|
+
*/
|
|
582
|
+
interface EdgeTextItem extends TextItem {
|
|
583
|
+
edgeId?: string;
|
|
584
|
+
sourcePosition?: THREE.Vector3;
|
|
585
|
+
targetPosition?: THREE.Vector3;
|
|
586
|
+
curvature?: number;
|
|
587
|
+
/** Node size hint — used to scale self-loop label offset */
|
|
588
|
+
nodeSize?: number;
|
|
589
|
+
/**
|
|
590
|
+
* The route the edge renderer draws, when it is neither a straight line nor
|
|
591
|
+
* the quadratic curve `curvature` describes (an `orthogonal` edge). The label
|
|
592
|
+
* then sits at half the route's length, turned along the leg it lands on.
|
|
593
|
+
*/
|
|
594
|
+
path?: THREE.Vector3[];
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* EdgeTextCloud configuration options
|
|
598
|
+
*/
|
|
599
|
+
interface EdgeTextCloudConfig extends TextCloudConfig {
|
|
600
|
+
showRelationshipName?: boolean;
|
|
601
|
+
useCurve?: boolean;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* EdgeTextCloud - Renders labels on edges
|
|
605
|
+
*
|
|
606
|
+
* Key features:
|
|
607
|
+
* - Straight edges: text at midpoint
|
|
608
|
+
* - Curved edges: text at bezier curve center (t=0.5)
|
|
609
|
+
* - Multi-edges: each edge gets its own curvature via EdgeClassifier
|
|
610
|
+
* - Self-loops: text positioned above the loop
|
|
611
|
+
* - Text rotation follows edge direction, never upside down
|
|
612
|
+
* - Canvas rotation: text re-orients each frame via camera projection
|
|
613
|
+
*/
|
|
614
|
+
declare class EdgeTextCloud {
|
|
615
|
+
private store;
|
|
616
|
+
private scene;
|
|
617
|
+
private camera;
|
|
618
|
+
private renderer;
|
|
619
|
+
private config;
|
|
620
|
+
private batchRenderer;
|
|
621
|
+
private _visible;
|
|
622
|
+
private _isDarkTheme;
|
|
623
|
+
private _isMapMode;
|
|
624
|
+
private _mapDamping;
|
|
625
|
+
/** Cached GPU pixel-size cap — same clamp as node text. Mirrors the legacy gl_PointSize ceiling. */
|
|
626
|
+
private _maxPointSize;
|
|
627
|
+
constructor(store: GraphStore, scene: THREE.Object3D, camera: THREE.Camera, config?: EdgeTextCloudConfig, renderer?: THREE.WebGLRenderer);
|
|
628
|
+
private getTextColor;
|
|
629
|
+
/**
|
|
630
|
+
* Compute perpendicular to edgeDir matching the main edge vertex shader:
|
|
631
|
+
* ref = abs(dir.z) < 0.99 ? (0,0,1) : (1,0,0)
|
|
632
|
+
* perp = normalize(cross(dir, ref))
|
|
633
|
+
* This keeps curvature offsets in the X-Y plane when edges lie in that plane.
|
|
634
|
+
*/
|
|
635
|
+
private computePerp;
|
|
636
|
+
/**
|
|
637
|
+
* Self-loop offset in local units (above node center).
|
|
638
|
+
* Approximate top-of-loop = nodeWorldRadius*(centerOffsetMult+loopRadiusMult).
|
|
639
|
+
* In local space without nodeSize info, 1.5 world units is a reasonable default.
|
|
640
|
+
*/
|
|
641
|
+
private _selfLoopOffset;
|
|
642
|
+
/** Let callers configure the self-loop label offset */
|
|
643
|
+
setSelfLoopOffset(offset: number): void;
|
|
644
|
+
/**
|
|
645
|
+
* Calculate edge midpoint for label anchor.
|
|
646
|
+
* - Straight: simple midpoint.
|
|
647
|
+
* - Curved: Bezier at t=0.5 with GPU-matching perp direction.
|
|
648
|
+
* - Self-loop: above the node by _selfLoopOffset.
|
|
649
|
+
*/
|
|
650
|
+
calculateEdgeCenter(sourcePos: THREE.Vector3, targetPos: THREE.Vector3, curvature?: number, nodeSize?: number): THREE.Vector3;
|
|
651
|
+
/**
|
|
652
|
+
* Calculate text rotation angle.
|
|
653
|
+
* Self-loop → 0 (horizontal). All others → chord direction in view space.
|
|
654
|
+
*/
|
|
655
|
+
calculateEdgeAngle(sourcePos: THREE.Vector3, targetPos: THREE.Vector3, _curvature?: number): number;
|
|
656
|
+
setFont(_font: MSDFFont, _texture: THREE.Texture): void;
|
|
657
|
+
showRelationshipName(show: boolean): void;
|
|
658
|
+
setUseCurve(useCurve: boolean): void;
|
|
659
|
+
setScale(scale: number): void;
|
|
660
|
+
setMaxLength(length: number): void;
|
|
661
|
+
/**
|
|
662
|
+
* Routes to GraphStore.setGlobalNodeSizeScale() — kept as a back-compat
|
|
663
|
+
* shim. Edge text size flows from `effectiveSizes` via the source node
|
|
664
|
+
* size hint passed in EdgeTextItem.
|
|
665
|
+
*/
|
|
666
|
+
setNodeSizeScale(scale: number): void;
|
|
667
|
+
switchTheme(isDark?: boolean): void;
|
|
668
|
+
setVisible(visible: boolean): void;
|
|
669
|
+
/** Labels follow `map.maxNodeGrowth` (0.75 × it); see BatchTextRenderer.setMapMaxGrowth. */
|
|
670
|
+
setMapMaxGrowth(nodeMaxGrowth: number): void;
|
|
671
|
+
setMapMode(enabled: boolean, sphereRadius?: number, damping?: number): void;
|
|
672
|
+
/**
|
|
673
|
+
* Hover-neighbor-highlight: dim or restore the label glyphs for an edge.
|
|
674
|
+
* `id` is the edge id used in the EdgeTextEntry passed to BatchTextRenderer.
|
|
675
|
+
*/
|
|
676
|
+
setHoverDimById(id: string, value: 0 | 1): void;
|
|
677
|
+
/** Clear hover-dim flag on all edge-label glyphs. */
|
|
678
|
+
clearAllHoverDim(): void;
|
|
679
|
+
/** Forward hover-emphasis uniform writes. */
|
|
680
|
+
setHoverUniform(name: "u_hoverProgress" | "u_hoverDimOpacity", value: number): void;
|
|
681
|
+
get visible(): boolean;
|
|
682
|
+
/**
|
|
683
|
+
* Update edge text labels.
|
|
684
|
+
*
|
|
685
|
+
* For each EdgeTextItem:
|
|
686
|
+
* 1. Calculate position at edge center (straight or bezier curve midpoint)
|
|
687
|
+
* 2. Calculate rotation to follow edge direction (screen-space, never upside down)
|
|
688
|
+
* 3. Center text horizontally on the edge
|
|
689
|
+
*/
|
|
690
|
+
/**
|
|
691
|
+
* Cull cache: skips the per-item bezier/angle math and the glyph re-layout
|
|
692
|
+
* (setEntries) when neither the view nor the items changed since the last
|
|
693
|
+
* updateTexts(). See cullCache.ts and the matching gate in TextCloud.
|
|
694
|
+
*/
|
|
695
|
+
private _cullCache;
|
|
696
|
+
/** Reused buffer for the view signature (no per-frame allocation). */
|
|
697
|
+
private _viewSigValues;
|
|
698
|
+
/** Collect every non-item input of updateTexts() into a flat numeric array. */
|
|
699
|
+
private _fillViewSignature;
|
|
700
|
+
updateTexts(items: EdgeTextItem[]): void;
|
|
701
|
+
/** Called each frame */
|
|
702
|
+
update(): void;
|
|
703
|
+
dispose(): void;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Factory function to create an EdgeTextCloud
|
|
707
|
+
*/
|
|
708
|
+
declare function createEdgeTextCloud(store: GraphStore, scene: THREE.Object3D, camera: THREE.Camera, config?: EdgeTextCloudConfig): EdgeTextCloud;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* EdgeTextLayer - React component for rendering edge labels
|
|
712
|
+
*
|
|
713
|
+
* Wraps the imperative EdgeTextCloud class as a declarative React component.
|
|
714
|
+
* Labels are positioned at edge midpoints (straight, curved, or self-loop).
|
|
715
|
+
*
|
|
716
|
+
* ```tsx
|
|
717
|
+
* <GraphRenderer container={containerRef.current}>
|
|
718
|
+
* <NodeCloud useCircle />
|
|
719
|
+
* <EdgeCloud showArrows />
|
|
720
|
+
* {showEdgeLabels && <EdgeTextLayer />}
|
|
721
|
+
* </GraphRenderer>
|
|
722
|
+
* ```
|
|
723
|
+
*/
|
|
724
|
+
|
|
725
|
+
interface EdgeTextLayerProps {
|
|
726
|
+
/** Text scale. Default: 0.9 */
|
|
727
|
+
scale?: number;
|
|
728
|
+
/** Maximum text length before truncation. Default: 50 */
|
|
729
|
+
maxLength?: number;
|
|
730
|
+
/** Show relationship type name. Default: false */
|
|
731
|
+
showRelationshipName?: boolean;
|
|
732
|
+
/** Use curved text positioning (follows edge curvature). Default: true */
|
|
733
|
+
useCurve?: boolean;
|
|
734
|
+
/** @deprecated Use `theme` prop or GraphCanvas `theme` instead */
|
|
735
|
+
isDark?: boolean;
|
|
736
|
+
/** Override theme for this layer: 'dark' = white text, 'light' = dark text */
|
|
737
|
+
theme?: 'dark' | 'light';
|
|
738
|
+
/** Visibility. Default: true */
|
|
739
|
+
visible?: boolean;
|
|
740
|
+
/** Which edge property to display as label */
|
|
741
|
+
property?: string;
|
|
742
|
+
/** Custom text item provider — overrides auto-generated labels */
|
|
743
|
+
getTextItems?: (store: any, positionProvider: PositionProvider | null) => EdgeTextItem[];
|
|
744
|
+
/** Text scale override. If not provided, uses GraphCanvas.edgeTextScale */
|
|
745
|
+
textScale?: number;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* EdgeTextLayer component
|
|
749
|
+
*
|
|
750
|
+
* Renders edge labels using TinySDF-based SDF text rendering.
|
|
751
|
+
* Handles straight edges, curved multi-edges, and self-loops.
|
|
752
|
+
*/
|
|
753
|
+
declare function EdgeTextLayer({ scale, maxLength, showRelationshipName, useCurve, isDark, theme: themeProp, visible, property, getTextItems, textScale: textScaleProp, }: EdgeTextLayerProps): any;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* useInvalidate - Hook for triggering render invalidation
|
|
757
|
+
*
|
|
758
|
+
* Returns a stable function that marks the scene as needing re-render.
|
|
759
|
+
* Use this in custom layers or components that need to trigger updates.
|
|
760
|
+
*
|
|
761
|
+
* ```tsx
|
|
762
|
+
* function MyCustomLayer() {
|
|
763
|
+
* const invalidate = useInvalidate();
|
|
764
|
+
* useEffect(() => {
|
|
765
|
+
* // ... modify scene
|
|
766
|
+
* invalidate();
|
|
767
|
+
* }, []);
|
|
768
|
+
* return null;
|
|
769
|
+
* }
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
772
|
+
declare function useInvalidate(): () => void;
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* useLayer - Hook for managing custom Three.js layer lifecycle
|
|
776
|
+
*
|
|
777
|
+
* Handles adding/removing Three.js objects to cloudScene with proper cleanup.
|
|
778
|
+
* Use this to create custom layers that integrate with the RenderEngine.
|
|
779
|
+
*
|
|
780
|
+
* ```tsx
|
|
781
|
+
* function HeatmapLayer({ data }) {
|
|
782
|
+
* useLayer({
|
|
783
|
+
* init(cloudScene, store) {
|
|
784
|
+
* const mesh = new THREE.Mesh(...);
|
|
785
|
+
* cloudScene.add(mesh);
|
|
786
|
+
* return mesh; // returned value is passed to update/dispose
|
|
787
|
+
* },
|
|
788
|
+
* update(mesh, store) {
|
|
789
|
+
* // update mesh from store data
|
|
790
|
+
* },
|
|
791
|
+
* dispose(mesh, cloudScene) {
|
|
792
|
+
* cloudScene.remove(mesh);
|
|
793
|
+
* mesh.geometry.dispose();
|
|
794
|
+
* (mesh.material as THREE.Material).dispose();
|
|
795
|
+
* },
|
|
796
|
+
* }, [data]);
|
|
797
|
+
* return null;
|
|
798
|
+
* }
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
|
|
802
|
+
interface LayerOptions<T = any> {
|
|
803
|
+
/**
|
|
804
|
+
* Initialize the layer. Add Three.js objects to cloudScene.
|
|
805
|
+
* Return a handle that will be passed to update() and dispose().
|
|
806
|
+
*/
|
|
807
|
+
init: (cloudScene: THREE.Group, store: GraphStore) => T;
|
|
808
|
+
/**
|
|
809
|
+
* Update the layer when store data changes.
|
|
810
|
+
* Called on every store version change.
|
|
811
|
+
*/
|
|
812
|
+
update?: (handle: T, store: GraphStore) => void;
|
|
813
|
+
/**
|
|
814
|
+
* Dispose the layer. Remove Three.js objects and free resources.
|
|
815
|
+
*/
|
|
816
|
+
dispose: (handle: T, cloudScene: THREE.Group) => void;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* useLayer hook
|
|
820
|
+
*
|
|
821
|
+
* @param options Layer lifecycle callbacks
|
|
822
|
+
* @param deps Additional dependencies that trigger re-initialization
|
|
823
|
+
*/
|
|
824
|
+
declare function useLayer<T = any>(options: LayerOptions<T>, deps?: any[]): void;
|
|
825
|
+
/**
|
|
826
|
+
* useEngineLayer — generic React wrapper for a {@link LayerRenderer}.
|
|
827
|
+
*
|
|
828
|
+
* Mirrors GlobeLayer's lifecycle (construct on mount, register frame +
|
|
829
|
+
* map-mode callbacks, dispose on unmount) but is fully generic over the
|
|
830
|
+
* renderer and its config. A typical layer is now ~5 lines:
|
|
831
|
+
*
|
|
832
|
+
* ```tsx
|
|
833
|
+
* export function MyLayer(props: MyLayerProps) {
|
|
834
|
+
* const config = { ...props };
|
|
835
|
+
* useEngineLayer("my-layer", () => new MyRenderer(), config, [], { frame: true });
|
|
836
|
+
* return null;
|
|
837
|
+
* }
|
|
838
|
+
* ```
|
|
839
|
+
*
|
|
840
|
+
* @param name stable id used for frame / map-mode callback registration
|
|
841
|
+
* @param factory creates the renderer (called once per construct effect)
|
|
842
|
+
* @param config domain-agnostic config; `update()` runs when its identity changes
|
|
843
|
+
* @param deps construct-effect deps (re-creates the renderer when they change)
|
|
844
|
+
* @param opts `{ frame: true }` to register a per-frame tick
|
|
845
|
+
*/
|
|
846
|
+
declare function useEngineLayer<Config, R extends LayerRenderer<Config>>(name: string, factory: () => R, config: Config, deps: unknown[], opts?: {
|
|
847
|
+
frame?: boolean;
|
|
848
|
+
}): void;
|
|
849
|
+
|
|
850
|
+
type UniformValue = number | number[] | THREE.Color | THREE.Vector2 | THREE.Vector3 | THREE.Vector4 | THREE.Texture;
|
|
851
|
+
interface NodeShaderAttribute {
|
|
852
|
+
/** GLSL attribute name; exposed to the fragment shader as varying `v<Name>`. */
|
|
853
|
+
name: string;
|
|
854
|
+
size: 1 | 2 | 3 | 4;
|
|
855
|
+
/** Per-targeted-node value(s). `node` is the engine `NodeData`; `index` is its GPU instance index. */
|
|
856
|
+
value: (node: NodeData, index: number) => number | number[];
|
|
857
|
+
/** Re-evaluate every frame; default false = refill only on membership change. */
|
|
858
|
+
dynamic?: boolean;
|
|
859
|
+
}
|
|
860
|
+
interface NodeShaderLayerSpec {
|
|
861
|
+
/** Full `void main(){…}` (+ helpers). Engine declares the provided varyings/uniforms — do NOT redeclare them. */
|
|
862
|
+
fragmentShader: string;
|
|
863
|
+
sizing?: "screen" | "world";
|
|
864
|
+
sizeFactor?: number;
|
|
865
|
+
size?: (node: NodeData, index: number) => number;
|
|
866
|
+
filter?: (node: NodeData, index: number) => boolean;
|
|
867
|
+
attributes?: NodeShaderAttribute[];
|
|
868
|
+
uniforms?: Record<string, UniformValue>;
|
|
869
|
+
animate?: boolean;
|
|
870
|
+
band?: "underlay" | "overlay" | "top";
|
|
871
|
+
bandOffset?: number;
|
|
872
|
+
followDim?: boolean;
|
|
873
|
+
hideBuiltinNode?: boolean;
|
|
874
|
+
blending?: "additive" | "normal";
|
|
875
|
+
maxNodes?: number;
|
|
876
|
+
/**
|
|
877
|
+
* Make the layer's own quads clickable.
|
|
878
|
+
*
|
|
879
|
+
* The engine's picking pass only rasterises the BUILT-IN node quad, sized
|
|
880
|
+
* from `nodeSize * nodeSizeScale` — it knows nothing about `sizeFactor`. A
|
|
881
|
+
* layer drawing at `sizeFactor: 10` is therefore clickable only on a small
|
|
882
|
+
* patch at the node centre, which is the single most reported surprise about
|
|
883
|
+
* custom layers. Set `hitArea` and the layer registers a second mesh in the
|
|
884
|
+
* engine's node picking scene, sharing this layer's geometry, so the hitbox
|
|
885
|
+
* is exactly the quad it draws.
|
|
886
|
+
*
|
|
887
|
+
* - `"none"` (default) — legacy behaviour, built-in hitbox only.
|
|
888
|
+
* - `"quad"` — the whole billboard, corners included.
|
|
889
|
+
* - `"circle"` — the inscribed circle (matches a round panel).
|
|
890
|
+
* - `"shape"` — exactly where {@link NodeShaderLayerSpec.hitMask} says the
|
|
891
|
+
* layer drew something. Required for any other outline.
|
|
892
|
+
*
|
|
893
|
+
* Clicks resolve to the SAME `NodePickResult` a built-in node click gives, so
|
|
894
|
+
* selection, hover, context menu and drag all follow with no extra wiring.
|
|
895
|
+
*/
|
|
896
|
+
hitArea?: "none" | "quad" | "circle" | "shape";
|
|
897
|
+
/**
|
|
898
|
+
* The clickable region, for `hitArea: "shape"`. `sdf` is a GLSL expression in
|
|
899
|
+
* `vec2 q` (= `vUv - 0.5`, y up) that is negative where the layer drew
|
|
900
|
+
* something; `prelude` is emitted above `main` for any helper it calls.
|
|
901
|
+
*
|
|
902
|
+
* A layer is expected to GENERATE this from the same code that drew the
|
|
903
|
+
* pixels rather than hand-write a second outline — see `buildMediaHitMask`.
|
|
904
|
+
* Any varying the expression names (`vFoo` for attribute `foo`) is forwarded
|
|
905
|
+
* into the pick program automatically; nothing else is, so the pick pass
|
|
906
|
+
* stays as small as the mask needs.
|
|
907
|
+
*/
|
|
908
|
+
hitMask?: {
|
|
909
|
+
prelude?: string;
|
|
910
|
+
sdf: string;
|
|
911
|
+
};
|
|
912
|
+
/**
|
|
913
|
+
* What node labels must keep clear of, so a `<TextLayer>` puts the caption
|
|
914
|
+
* under the panel you see rather than across it, and keeps it there while
|
|
915
|
+
* the node is dragged. Half-width and half-height as fractions of the quad
|
|
916
|
+
* (`[1, 1]` = the whole billboard; a 16:9 picture in it is `[1, 0.5625]`).
|
|
917
|
+
*
|
|
918
|
+
* - `"auto"` (default) — the whole quad when the layer replaces or
|
|
919
|
+
* enlarges the node (`hideBuiltinNode` or a `hitArea`), else nothing.
|
|
920
|
+
* - `"none"` — labels ignore this layer.
|
|
921
|
+
* - `[x, y]` — an explicit footprint, for a drawing smaller than its quad.
|
|
922
|
+
*/
|
|
923
|
+
labelExtent?: "auto" | "none" | readonly [number, number];
|
|
924
|
+
}
|
|
925
|
+
/** Map a runtime uniform value to its GLSL declaration type. Throws on unsupported shapes. */
|
|
926
|
+
declare function uniformGlslType(v: UniformValue): string;
|
|
927
|
+
/** Pure: compose the engine-owned vertex + the preamble-wrapped user fragment. Exported for tests. */
|
|
928
|
+
declare function buildShaderSources(spec: NodeShaderLayerSpec): {
|
|
929
|
+
vertex: string;
|
|
930
|
+
fragment: string;
|
|
931
|
+
};
|
|
932
|
+
declare function createNodeShaderLayer(spec: NodeShaderLayerSpec): LayerRenderer<Record<string, UniformValue>>;
|
|
933
|
+
|
|
934
|
+
export { useTextScales as $, useCloudScene as A, type BufferTextSource as B, useEffectiveMapProjection as C, useEngineLayer as D, EdgeCloud as E, useGraph as F, GraphCanvas as G, useGraphHandle as H, useGraphStore as I, useGraphVersion as J, useInteraction as K, type LayerOptions as L, type MSDFFont as M, NodeCloud as N, useInvalidate as O, useIs3D as P, useIsMapMode as Q, useLayer as R, useLayoutController as S, TextCloud as T, type UniformValue as U, useLayoutPositionProvider as V, useMapDamping as W, useMapSphereRadius as X, useOptionalRenderEngineApi as Y, useRenderEngineApi as Z, useScene as _, type EdgeCloudProps as a, useTheme as a0, useViewStateField as a1, EdgeTextCloud as b, type EdgeTextCloudConfig as c, type EdgeTextItem as d, EdgeTextLayer as e, type EdgeTextLayerProps as f, type GraphCanvasProps as g, GraphContext as h, GraphRenderer as i, type GraphViewState as j, type MSDFGlyph as k, type NodeCloudProps as l, type NodeShaderAttribute as m, type NodeShaderLayerSpec as n, type TextCloudConfig as o, type TextItem as p, TextLayer as q, type TextLayerProps as r, buildShaderSources as s, createEdgeTextCloud as t, createNodeShaderLayer as u, createTextCloud as v, radialLabelPlacement as w, uniformGlslType as x, useAtlasManagers as y, useCamera as z };
|