@fusefactory/fuse-three-forcegraph 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1478 -1467
- package/dist/index.mjs +4183 -4212
- package/package.json +40 -47
- package/index.ts +0 -34
package/dist/index.d.mts
CHANGED
|
@@ -1,1468 +1,1479 @@
|
|
|
1
|
-
import CameraControls from "camera-controls";
|
|
2
|
-
import * as THREE from "three";
|
|
3
|
-
|
|
4
|
-
//#region types/iCameraMode.d.ts
|
|
5
|
-
declare enum CameraMode {
|
|
6
|
-
Orbit = "orbit",
|
|
7
|
-
Map = "map"
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region rendering/CameraController.d.ts
|
|
11
|
-
interface CameraConfig {
|
|
12
|
-
fov?: number;
|
|
13
|
-
aspect?: number;
|
|
14
|
-
near?: number;
|
|
15
|
-
far?: number;
|
|
16
|
-
position?: THREE.Vector3;
|
|
17
|
-
target?: THREE.Vector3;
|
|
18
|
-
minDistance?: number;
|
|
19
|
-
maxDistance?: number;
|
|
20
|
-
}
|
|
21
|
-
interface ControlsConfig {
|
|
22
|
-
smoothTime?: number;
|
|
23
|
-
dollyToCursor?: boolean;
|
|
24
|
-
infinityDolly?: boolean;
|
|
25
|
-
enableZoom?: boolean;
|
|
26
|
-
enableRotation?: boolean;
|
|
27
|
-
enablePan?: boolean;
|
|
28
|
-
minDistance?: number;
|
|
29
|
-
maxDistance?: number;
|
|
30
|
-
maxPolarAngle?: number;
|
|
31
|
-
minPolarAngle?: number;
|
|
32
|
-
minAzimuthAngle?: number;
|
|
33
|
-
maxAzimuthAngle?: number;
|
|
34
|
-
}
|
|
35
|
-
declare class CameraController {
|
|
36
|
-
camera: THREE.PerspectiveCamera;
|
|
37
|
-
controls: CameraControls;
|
|
38
|
-
private sceneBounds;
|
|
39
|
-
private autorotateEnabled;
|
|
40
|
-
private autorotateSpeed;
|
|
41
|
-
private userIsActive;
|
|
42
|
-
constructor(domelement: HTMLElement, config?: CameraConfig);
|
|
43
|
-
private setupDefaultControls;
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
setMode(mode: CameraMode): void;
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setBoundary(box: THREE.Box3): void;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
update(delta: number): boolean;
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
setAutorotate(enabled: boolean, speed?: number): void;
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
setUserIsActive(isActive: boolean): void;
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
configureControls(config: ControlsConfig): void;
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
resize(width: number, height: number): void;
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
setLookAt(position: THREE.Vector3, target: THREE.Vector3, enableTransition?: boolean): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
reset(enableTransition?: boolean): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
setEnabled(enabled: boolean): void;
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
getTarget(out?: THREE.Vector3): THREE.Vector3;
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
dispose(): void;
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
clearBounds(): void;
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
getSceneBounds(): THREE.Box3 | null;
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
updateBounds(box: THREE.Box3): void;
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
setOptions(options: {
|
|
110
|
-
controls?: ControlsConfig;
|
|
111
|
-
autoRotate?: boolean;
|
|
112
|
-
autoRotateSpeed?: number;
|
|
113
|
-
}): void;
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region types/iGraphLink.d.ts
|
|
117
|
-
interface GraphLink {
|
|
118
|
-
source: string;
|
|
119
|
-
target: string;
|
|
120
|
-
}
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region types/iGraphNode.d.ts
|
|
123
|
-
interface GraphNode {
|
|
124
|
-
id: string;
|
|
125
|
-
label?: string;
|
|
126
|
-
description?: string;
|
|
127
|
-
thumbnailUrl?: string;
|
|
128
|
-
category?: string;
|
|
129
|
-
x?: number;
|
|
130
|
-
y?: number;
|
|
131
|
-
z?: number;
|
|
132
|
-
fx?: number;
|
|
133
|
-
fy?: number;
|
|
134
|
-
fz?: number;
|
|
135
|
-
state?: NodeState;
|
|
136
|
-
metadata?: any;
|
|
137
|
-
}
|
|
138
|
-
declare enum NodeState {
|
|
139
|
-
Hidden = 0,
|
|
140
|
-
// = 0 not rendered
|
|
141
|
-
Passive = 1,
|
|
142
|
-
// = 1 rendered, not influencing simulation,
|
|
143
|
-
Fixed = 2,
|
|
144
|
-
// = 2 rendered, influencing simulation, but not moving
|
|
145
|
-
Active = 3
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region types/iGraphData.d.ts
|
|
149
|
-
interface GraphData {
|
|
150
|
-
nodes: GraphNode[];
|
|
151
|
-
links: GraphLink[];
|
|
152
|
-
metadata?: any;
|
|
153
|
-
}
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region types/iForceConfig.d.ts
|
|
156
|
-
interface ForceConfig {
|
|
157
|
-
collisionStrength: number;
|
|
158
|
-
collisionRadius: number;
|
|
159
|
-
collisionMaxDistance: number;
|
|
160
|
-
enableCollision: boolean;
|
|
161
|
-
manyBodyStrength: number;
|
|
162
|
-
manyBodyMinDistance: number;
|
|
163
|
-
manyBodyMaxDistance: number;
|
|
164
|
-
enableManyBody: boolean;
|
|
165
|
-
springStrength: number;
|
|
166
|
-
springLength: number;
|
|
167
|
-
springDamping: number;
|
|
168
|
-
maxLinks: number;
|
|
169
|
-
enableLinks: boolean;
|
|
170
|
-
gravity: number;
|
|
171
|
-
enableGravity: boolean;
|
|
172
|
-
attractorStrength: number;
|
|
173
|
-
enableAttractors: boolean;
|
|
174
|
-
elasticStrength: number;
|
|
175
|
-
enableElastic: boolean;
|
|
176
|
-
dragStrength: number;
|
|
177
|
-
damping: number;
|
|
178
|
-
alpha: number;
|
|
179
|
-
alphaDecay: number;
|
|
180
|
-
deltaTime: number;
|
|
181
|
-
spaceSize: number;
|
|
182
|
-
is3D: boolean;
|
|
183
|
-
}
|
|
184
|
-
//#endregion
|
|
185
|
-
//#region types/iGraphPreset.d.ts
|
|
186
|
-
interface GraphPreset {
|
|
187
|
-
name: string;
|
|
188
|
-
force?: Partial<ForceConfig>;
|
|
189
|
-
camera?: {
|
|
190
|
-
mode?: CameraMode;
|
|
191
|
-
position?: {
|
|
192
|
-
x: number;
|
|
193
|
-
y: number;
|
|
194
|
-
z: number;
|
|
195
|
-
};
|
|
196
|
-
target?: {
|
|
197
|
-
x: number;
|
|
198
|
-
y: number;
|
|
199
|
-
z: number;
|
|
200
|
-
};
|
|
201
|
-
zoom?: number;
|
|
202
|
-
transitionDuration?: number;
|
|
203
|
-
minDistance?: number;
|
|
204
|
-
maxDistance?: number;
|
|
205
|
-
boundary?: {
|
|
206
|
-
min: {
|
|
207
|
-
x: number;
|
|
208
|
-
y: number;
|
|
209
|
-
z: number;
|
|
210
|
-
};
|
|
211
|
-
max: {
|
|
212
|
-
x: number;
|
|
213
|
-
y: number;
|
|
214
|
-
z: number;
|
|
215
|
-
};
|
|
216
|
-
} | null;
|
|
217
|
-
};
|
|
218
|
-
nodes?: {
|
|
219
|
-
state?: (node: GraphNode) => NodeState;
|
|
220
|
-
};
|
|
221
|
-
links?: {
|
|
222
|
-
opacity?: number;
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
//#endregion
|
|
226
|
-
//#region ui/Tooltips.d.ts
|
|
227
|
-
/**
|
|
228
|
-
* Renderer function type for custom tooltip rendering
|
|
229
|
-
* Can mount React, Vue, or any other framework component
|
|
230
|
-
*/
|
|
231
|
-
type TooltipRenderer = (container: HTMLElement, node: GraphNode, type: 'preview' | 'full', x: number, y: number) => void | (() => void);
|
|
232
|
-
/**
|
|
233
|
-
* Cursor handler for custom cursor behavior
|
|
234
|
-
*/
|
|
235
|
-
type CursorHandler = (canvas: HTMLCanvasElement | null, state: 'default' | 'pointer' | 'grab') => void;
|
|
236
|
-
interface TooltipConfig {
|
|
237
|
-
/** Custom renderer for tooltips (React, Vue, etc.) */
|
|
238
|
-
renderer?: TooltipRenderer;
|
|
239
|
-
/** Custom cursor handler */
|
|
240
|
-
cursorHandler?: CursorHandler;
|
|
241
|
-
}
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region core/EventEmitter.d.ts
|
|
244
|
-
declare class EventEmitter {
|
|
245
|
-
private listeners;
|
|
246
|
-
protected listenerCount(event: string): number;
|
|
247
|
-
on(event: string, listener: Function): () => void;
|
|
248
|
-
off(event: string, listener: Function): void;
|
|
249
|
-
emit(event: string, ...args: any[]): void;
|
|
250
|
-
}
|
|
251
|
-
//#endregion
|
|
252
|
-
//#region controls/InputProcessor.d.ts
|
|
253
|
-
/**
|
|
254
|
-
* Manages pointer/mouse input and emits interaction events
|
|
255
|
-
* Uses GPU picking for efficient node detection
|
|
256
|
-
*/
|
|
257
|
-
declare class InputProcessor extends EventEmitter {
|
|
258
|
-
private pickFn;
|
|
259
|
-
private canvas;
|
|
260
|
-
private viewport;
|
|
261
|
-
private readonly CLICK_THRESHOLD;
|
|
262
|
-
private readonly HOVER_TO_POP_MS;
|
|
263
|
-
private pointer;
|
|
264
|
-
private canvasPointer;
|
|
265
|
-
private isPointerDown;
|
|
266
|
-
private isDragging;
|
|
267
|
-
private mouseDownTime;
|
|
268
|
-
private draggedIndex;
|
|
269
|
-
private currentHoverIndex;
|
|
270
|
-
private hoverStartTime;
|
|
271
|
-
private hoverProgress;
|
|
272
|
-
private hasPopped;
|
|
273
|
-
private lastClientX;
|
|
274
|
-
private lastClientY;
|
|
275
|
-
constructor(pickFn: (x: number, y: number) => number, // Injected
|
|
276
|
-
canvas: HTMLCanvasElement, viewport: {
|
|
277
|
-
width: number;
|
|
278
|
-
height: number;
|
|
279
|
-
});
|
|
280
|
-
private setupEventListeners;
|
|
281
|
-
private handlePointerMove;
|
|
282
|
-
private handlePointerDown;
|
|
283
|
-
private handlePointerUp;
|
|
284
|
-
private handlePointerLeave;
|
|
285
|
-
private updateHover;
|
|
286
|
-
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
update(): void;
|
|
291
|
-
private updatePointer;
|
|
292
|
-
/**
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
resize(width: number, height: number): void;
|
|
296
|
-
dispose(): void;
|
|
297
|
-
}
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region controls/handlers/HoverHandler.d.ts
|
|
300
|
-
declare class HoverHandler extends EventEmitter {
|
|
301
|
-
private getNodeByIndex;
|
|
302
|
-
constructor(getNodeByIndex: (index: number) => GraphNode | null);
|
|
303
|
-
private handleHoverStart;
|
|
304
|
-
private handleHover;
|
|
305
|
-
private handlePop;
|
|
306
|
-
private handleHoverEnd;
|
|
307
|
-
dispose(): void;
|
|
308
|
-
}
|
|
309
|
-
//#endregion
|
|
310
|
-
//#region controls/handlers/ClickHandler.d.ts
|
|
311
|
-
declare class ClickHandler extends EventEmitter {
|
|
312
|
-
private getNodeByIndex;
|
|
313
|
-
constructor(getNodeByIndex: (index: number) => GraphNode | null);
|
|
314
|
-
private handleClick;
|
|
315
|
-
dispose(): void;
|
|
316
|
-
}
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region textures/SimulationBuffers.d.ts
|
|
319
|
-
/**
|
|
320
|
-
* Manages dynamic render targets updated by force simulation
|
|
321
|
-
* Uses ping-pong technique for GPU computation
|
|
322
|
-
* Buffers are created lazily when data is initialized
|
|
323
|
-
*/
|
|
324
|
-
declare class SimulationBuffers {
|
|
325
|
-
private renderer;
|
|
326
|
-
private textureSize;
|
|
327
|
-
private positionBuffers;
|
|
328
|
-
private velocityBuffers;
|
|
329
|
-
private isInitialized;
|
|
330
|
-
constructor(renderer: THREE.WebGLRenderer);
|
|
331
|
-
/**
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
isReady(): boolean;
|
|
335
|
-
/**
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
init(pointsCount: number, initialPositions?: Float32Array): void;
|
|
339
|
-
/**
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
resize(pointsCount: number, preserveData?: boolean): void;
|
|
343
|
-
private calculateTextureSize;
|
|
344
|
-
private createDynamicBuffer;
|
|
345
|
-
/**
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
setInitialPositions(positionArray: Float32Array): void;
|
|
349
|
-
/**
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
updateCurrentPositions(positionArray: Float32Array): void;
|
|
353
|
-
/**
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
setOriginalPositions(positionArray: Float32Array): void;
|
|
357
|
-
/**
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
initVelocities(): void;
|
|
361
|
-
/**
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
swapPositions(): void;
|
|
365
|
-
/**
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
swapVelocities(): void;
|
|
369
|
-
/**
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
resetPositions(): void;
|
|
373
|
-
/**
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
readPositions(): Float32Array;
|
|
378
|
-
getCurrentPositionTarget(): THREE.WebGLRenderTarget | null;
|
|
379
|
-
getPreviousPositionTarget(): THREE.WebGLRenderTarget | null;
|
|
380
|
-
getCurrentPositionTexture(): THREE.Texture<unknown>;
|
|
381
|
-
getPreviousPositionTexture(): THREE.Texture | null;
|
|
382
|
-
getOriginalPositionTexture(): THREE.Texture | null;
|
|
383
|
-
getCurrentVelocityTarget(): THREE.WebGLRenderTarget | null;
|
|
384
|
-
getPreviousVelocityTarget(): THREE.WebGLRenderTarget | null;
|
|
385
|
-
getCurrentVelocityTexture(): THREE.Texture | null;
|
|
386
|
-
getPreviousVelocityTexture(): THREE.Texture | null;
|
|
387
|
-
getTextureSize(): number;
|
|
388
|
-
private arrayToTextureData;
|
|
389
|
-
private createDataTexture;
|
|
390
|
-
private copyTextureToBuffer;
|
|
391
|
-
private copyBufferToBuffer;
|
|
392
|
-
dispose(): void;
|
|
393
|
-
}
|
|
394
|
-
//#endregion
|
|
395
|
-
//#region types/iAttractor.d.ts
|
|
396
|
-
/**
|
|
397
|
-
* Simple 3D vector type
|
|
398
|
-
*/
|
|
399
|
-
interface Vec3 {
|
|
400
|
-
x: number;
|
|
401
|
-
y: number;
|
|
402
|
-
z: number;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Attractor - A point in space that attracts nodes of specific groups
|
|
406
|
-
*/
|
|
407
|
-
interface Attractor {
|
|
408
|
-
/** Unique identifier */
|
|
409
|
-
id: string;
|
|
410
|
-
/** Position in world space */
|
|
411
|
-
position: Vec3;
|
|
412
|
-
/** Radius of attraction (default: 0.0) - nodes within this radius are not pulled further */
|
|
413
|
-
radius?: number;
|
|
414
|
-
/** Groups of nodes attracted to this attractor (empty = attracts all) */
|
|
415
|
-
groups: string[];
|
|
416
|
-
/** Strength of attraction (default: 1.0) */
|
|
417
|
-
strength?: number;
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Resolved attractor with defaults applied
|
|
421
|
-
*/
|
|
422
|
-
interface ResolvedAttractor {
|
|
423
|
-
id: string;
|
|
424
|
-
position: Vec3;
|
|
425
|
-
groups: string[];
|
|
426
|
-
strength: number;
|
|
427
|
-
radius: number;
|
|
428
|
-
}
|
|
429
|
-
//#endregion
|
|
430
|
-
//#region textures/StaticAssets.d.ts
|
|
431
|
-
/**
|
|
432
|
-
* Manages read-only GPU textures created at initialization
|
|
433
|
-
* These never change during simulation (except for mode changes)
|
|
434
|
-
*
|
|
435
|
-
* Node data: radii, colors
|
|
436
|
-
* Link data: source/target indices, properties
|
|
437
|
-
*/
|
|
438
|
-
declare class StaticAssets {
|
|
439
|
-
private nodeRadiiTexture;
|
|
440
|
-
private nodeColorsTexture;
|
|
441
|
-
private linkIndicesTexture;
|
|
442
|
-
private linkPropertiesTexture;
|
|
443
|
-
private nodeLinkMapTexture;
|
|
444
|
-
private nodeTextureSize;
|
|
445
|
-
private linkTextureSize;
|
|
446
|
-
constructor();
|
|
447
|
-
/**
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
setNodeRadii(radii: Float32Array, textureSize: number): void;
|
|
451
|
-
/**
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
setNodeColors(colors: Float32Array, textureSize: number): void;
|
|
455
|
-
/**
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
setLinkIndices(linkIndices: Float32Array, textureSize: number): void;
|
|
460
|
-
/**
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
setLinkProperties(linkProperties: Float32Array, textureSize: number): void;
|
|
464
|
-
setNodeLinkMap(linkMap: Float32Array, textureSize: number): void;
|
|
465
|
-
/**
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
private createTexture;
|
|
469
|
-
getNodeRadiiTexture(): THREE.DataTexture | null;
|
|
470
|
-
getNodeColorsTexture(): THREE.DataTexture | null;
|
|
471
|
-
getLinkIndicesTexture(): THREE.DataTexture | null;
|
|
472
|
-
getLinkPropertiesTexture(): THREE.DataTexture | null;
|
|
473
|
-
getLinkMapTexture(): THREE.DataTexture | null;
|
|
474
|
-
getNodeTextureSize(): number;
|
|
475
|
-
getLinkTextureSize(): number;
|
|
476
|
-
/**
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
hasNodeAssets(): boolean;
|
|
480
|
-
hasLinkAssets(): boolean;
|
|
481
|
-
/**
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
dispose(): void;
|
|
485
|
-
}
|
|
486
|
-
declare const staticAssets: StaticAssets;
|
|
487
|
-
//#endregion
|
|
488
|
-
//#region simulation/BasePass.d.ts
|
|
489
|
-
interface PassContext {
|
|
490
|
-
scene: THREE.Scene;
|
|
491
|
-
camera: THREE.Camera;
|
|
492
|
-
quad: THREE.BufferGeometry;
|
|
493
|
-
simBuffers: SimulationBuffers;
|
|
494
|
-
assets: StaticAssets;
|
|
495
|
-
renderer: THREE.WebGLRenderer;
|
|
496
|
-
config: ForceConfig;
|
|
497
|
-
textureSize: number;
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Base class for GPU force simulation passes
|
|
501
|
-
* Each pass operates on simulation buffers and can read from static assets
|
|
502
|
-
*/
|
|
503
|
-
declare abstract class BasePass {
|
|
504
|
-
protected material: THREE.ShaderMaterial | null;
|
|
505
|
-
protected enabled: boolean;
|
|
506
|
-
/**
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
abstract getName(): string;
|
|
510
|
-
/**
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
abstract initMaterial(context: PassContext): void;
|
|
514
|
-
/**
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
abstract updateUniforms(context: PassContext): void;
|
|
518
|
-
/**
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
execute(context: PassContext): void;
|
|
522
|
-
/**
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
protected render(context: PassContext): void;
|
|
526
|
-
/**
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
protected createMaterial(vertexShader: string, fragmentShader: string, uniforms: {
|
|
530
|
-
[uniform: string]: THREE.IUniform;
|
|
531
|
-
}): THREE.ShaderMaterial;
|
|
532
|
-
/**
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
protected setUniform(name: string, value: unknown): void;
|
|
536
|
-
/**
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
setEnabled(enabled: boolean): void;
|
|
540
|
-
/**
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
isEnabled(): boolean;
|
|
544
|
-
/**
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
getMaterial(): THREE.ShaderMaterial | null;
|
|
548
|
-
/**
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
dispose(): void;
|
|
552
|
-
}
|
|
553
|
-
//#endregion
|
|
554
|
-
//#region simulation/passes/AttractorPass.d.ts
|
|
555
|
-
/**
|
|
556
|
-
* Attractor force pass - attracts nodes to attractor points based on group membership
|
|
557
|
-
*
|
|
558
|
-
* Usage:
|
|
559
|
-
* attractorPass.setAttractors([
|
|
560
|
-
* { id: 'center', position: { x: 0, y: 0, z: 0 }, categories: ['root'] }, // categories acts as groups
|
|
561
|
-
* { id: 'left', position: { x: -100, y: 0, z: 0 }, categories: ['artwork', 'series'] }
|
|
562
|
-
* ])
|
|
563
|
-
*/
|
|
564
|
-
declare class AttractorPass extends BasePass {
|
|
565
|
-
private attractors;
|
|
566
|
-
private groupMap;
|
|
567
|
-
private attractorsTexture;
|
|
568
|
-
private attractorGroupsTexture;
|
|
569
|
-
private attractorParamsTexture;
|
|
570
|
-
private nodeGroupsTexture;
|
|
571
|
-
getName(): string;
|
|
572
|
-
initMaterial(context: PassContext): void;
|
|
573
|
-
updateUniforms(context: PassContext): void;
|
|
574
|
-
/**
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
setAttractors(attractors: Attractor[]): void;
|
|
578
|
-
/**
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
addAttractor(attractor: Attractor): void;
|
|
582
|
-
/**
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
removeAttractor(id: string): void;
|
|
586
|
-
/**
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
updateAttractorPosition(id: string, position: Vec3): void;
|
|
590
|
-
/**
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
getAttractors(): ResolvedAttractor[];
|
|
594
|
-
/**
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
setNodeGroups(groups: string[][], textureSize: number): void;
|
|
599
|
-
/**
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
getGroupMap(): Map<string, number>;
|
|
603
|
-
private createAttractorTextures;
|
|
604
|
-
private updateAttractorTextures;
|
|
605
|
-
dispose(): void;
|
|
606
|
-
}
|
|
607
|
-
//#endregion
|
|
608
|
-
//#region simulation/ForceSimulation.d.ts
|
|
609
|
-
/**
|
|
610
|
-
* ForceSimulation - GPU-based force simulation
|
|
611
|
-
*
|
|
612
|
-
* Simple architecture:
|
|
613
|
-
* - Single shared config object (ForceConfig)
|
|
614
|
-
* - All passes read directly from config via PassContext
|
|
615
|
-
* - Enable flags control which passes execute
|
|
616
|
-
* - No manual syncing required
|
|
617
|
-
*/
|
|
618
|
-
declare class ForceSimulation {
|
|
619
|
-
private renderer;
|
|
620
|
-
private simulationBuffers;
|
|
621
|
-
private computeScene;
|
|
622
|
-
private computeCamera;
|
|
623
|
-
private computeQuad;
|
|
624
|
-
private velocityCarryPass;
|
|
625
|
-
private collisionPass;
|
|
626
|
-
private manyBodyPass;
|
|
627
|
-
private gravityPass;
|
|
628
|
-
private linkPass;
|
|
629
|
-
private elasticPass;
|
|
630
|
-
private attractorPass;
|
|
631
|
-
private dragPass;
|
|
632
|
-
private integratePass;
|
|
633
|
-
private forcePasses;
|
|
634
|
-
readonly config: ForceConfig;
|
|
635
|
-
private isInitialized;
|
|
636
|
-
private iterationCount;
|
|
637
|
-
constructor(renderer: THREE.WebGLRenderer);
|
|
638
|
-
private createComputeQuad;
|
|
639
|
-
/**
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
initialize(simulationBuffers: SimulationBuffers): void;
|
|
643
|
-
private createContext;
|
|
644
|
-
/**
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
private shouldExecutePass;
|
|
648
|
-
/**
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
step(deltaTime?: number): void;
|
|
652
|
-
/**
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
getConfig(): ForceConfig;
|
|
657
|
-
/**
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
reheat(amt?: number): void;
|
|
661
|
-
startDrag(index: number, targetWorldPos: THREE.Vector3): void;
|
|
662
|
-
updateDrag(targetWorldPos: THREE.Vector3): void;
|
|
663
|
-
endDrag(): void;
|
|
664
|
-
/**
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
setAttractors(attractors: Attractor[]): void;
|
|
669
|
-
/**
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
addAttractor(attractor: Attractor): void;
|
|
673
|
-
/**
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
removeAttractor(id: string): void;
|
|
677
|
-
/**
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
updateAttractorPosition(id: string, position: Vec3): void;
|
|
681
|
-
/**
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
getAttractors(): Attractor[];
|
|
685
|
-
/**
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
setNodeGroups(groups: (string | string[])[]): void;
|
|
690
|
-
setNodeGroupsFromData<T>(data: T[], accessor: (item: T, index: number) => string | string[] | undefined): void;
|
|
691
|
-
/**
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
getAttractorPass(): AttractorPass;
|
|
695
|
-
getAlpha(): number;
|
|
696
|
-
getIterationCount(): number;
|
|
697
|
-
reset(): void;
|
|
698
|
-
dispose(): void;
|
|
699
|
-
}
|
|
700
|
-
//#endregion
|
|
701
|
-
//#region controls/handlers/DragHandler.d.ts
|
|
702
|
-
declare class DragHandler extends EventEmitter {
|
|
703
|
-
private getNodeByIndex;
|
|
704
|
-
private cameraController?;
|
|
705
|
-
private forceSimulation?;
|
|
706
|
-
private viewport?;
|
|
707
|
-
private isDragging;
|
|
708
|
-
private raycaster;
|
|
709
|
-
private dragPlane;
|
|
710
|
-
private pointer;
|
|
711
|
-
constructor(getNodeByIndex: (index: number) => GraphNode | null, cameraController?: CameraController, forceSimulation?: ForceSimulation, viewport?: {
|
|
712
|
-
width: number;
|
|
713
|
-
height: number;
|
|
714
|
-
});
|
|
715
|
-
/**
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
private setupDragPlane;
|
|
719
|
-
private handleDragStart;
|
|
720
|
-
private handleDrag;
|
|
721
|
-
private handleDragEnd;
|
|
722
|
-
/**
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
private screenToWorld;
|
|
726
|
-
/**
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
resize(width: number, height: number): void;
|
|
730
|
-
dispose(): void;
|
|
731
|
-
}
|
|
732
|
-
//#endregion
|
|
733
|
-
//#region textures/PickBuffer.d.ts
|
|
734
|
-
/**
|
|
735
|
-
* Manages GPU picking buffer for mouse interaction
|
|
736
|
-
* Separate from simulation buffers as it has different lifecycle
|
|
737
|
-
*/
|
|
738
|
-
declare class PickBuffer {
|
|
739
|
-
private renderer;
|
|
740
|
-
private pickTarget;
|
|
741
|
-
constructor(renderer: THREE.WebGLRenderer);
|
|
742
|
-
/**
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
resize(width: number, height: number): void;
|
|
746
|
-
private createPickBuffer;
|
|
747
|
-
/**
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
readIdAt(x: number, y: number): number;
|
|
751
|
-
/**
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
render(scene: THREE.Scene, camera: THREE.Camera): void;
|
|
755
|
-
getTarget(): THREE.WebGLRenderTarget | null;
|
|
756
|
-
dispose(): void;
|
|
757
|
-
}
|
|
758
|
-
//#endregion
|
|
759
|
-
//#region rendering/links/LinksRenderer.d.ts
|
|
760
|
-
/**
|
|
761
|
-
* LinksRenderer - Renders links as line segments
|
|
762
|
-
* Uses shared SimulationBuffers for node positions
|
|
763
|
-
* Manages link-specific opacity and highlighting
|
|
764
|
-
*/
|
|
765
|
-
declare class LinksRenderer {
|
|
766
|
-
private scene;
|
|
767
|
-
private renderer;
|
|
768
|
-
private lines;
|
|
769
|
-
private links;
|
|
770
|
-
private nodeIndexMap;
|
|
771
|
-
private linkIndexMap;
|
|
772
|
-
private interpolationSteps;
|
|
773
|
-
params: {
|
|
774
|
-
noiseStrength: number;
|
|
775
|
-
defaultAlpha: number;
|
|
776
|
-
highlightAlpha: number;
|
|
777
|
-
dimmedAlpha: number;
|
|
778
|
-
is2D: boolean;
|
|
779
|
-
};
|
|
780
|
-
private linkOpacity;
|
|
781
|
-
private simulationBuffers;
|
|
782
|
-
constructor(scene: THREE.Scene, renderer: THREE.WebGLRenderer);
|
|
783
|
-
/**
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
create(links: GraphLink[], nodes: GraphNode[], simulationBuffers: SimulationBuffers): void;
|
|
788
|
-
/**
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
setPositionTexture(positionTexture: THREE.Texture): void;
|
|
793
|
-
/**
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
update(time: number): void;
|
|
797
|
-
/**
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
updateOpacity(): void;
|
|
801
|
-
/**
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
highlightConnectedLinks(nodeId: string, step?: number): void;
|
|
805
|
-
/**
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
clearHighlights(step?: number): void;
|
|
809
|
-
/**
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
setNoiseStrength(strength: number): void;
|
|
813
|
-
/**
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
setAlphaParams(params: {
|
|
817
|
-
defaultAlpha?: number;
|
|
818
|
-
highlightAlpha?: number;
|
|
819
|
-
dimmedAlpha?: number;
|
|
820
|
-
}): void;
|
|
821
|
-
/**
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
setOptions(options: LinkOptions): void;
|
|
825
|
-
/**
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
refreshUniforms(): void;
|
|
829
|
-
/**
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
resize(width: number, height: number): void;
|
|
833
|
-
/**
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
setVisible(visible: boolean): void;
|
|
837
|
-
/**
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
isVisible(): boolean;
|
|
841
|
-
/**
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
dispose(): void;
|
|
845
|
-
/**
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
private buildNodeMapping;
|
|
849
|
-
/**
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
private createLinkGeometry;
|
|
853
|
-
/**
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
private buildLinkTextures;
|
|
860
|
-
/**
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
private createRenderMaterial;
|
|
864
|
-
}
|
|
865
|
-
interface LinkOptions {
|
|
866
|
-
visible?: boolean;
|
|
867
|
-
noiseStrength?: number;
|
|
868
|
-
alpha?: {
|
|
869
|
-
default?: number;
|
|
870
|
-
highlight?: number;
|
|
871
|
-
dimmed?: number;
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
//#endregion
|
|
875
|
-
//#region rendering/nodes/NodesRenderer.d.ts
|
|
876
|
-
declare class NodesRenderer {
|
|
877
|
-
private scene;
|
|
878
|
-
private renderer;
|
|
879
|
-
private points;
|
|
880
|
-
private pickMaterial;
|
|
881
|
-
private nodeIndexMap;
|
|
882
|
-
private idArray;
|
|
883
|
-
private nodeOpacity;
|
|
884
|
-
private targets;
|
|
885
|
-
params: {
|
|
886
|
-
defaultAlpha: number;
|
|
887
|
-
highlightAlpha: number;
|
|
888
|
-
dimmedAlpha: number;
|
|
889
|
-
};
|
|
890
|
-
private simulationBuffers;
|
|
891
|
-
private pickBuffer;
|
|
892
|
-
constructor(scene: THREE.Scene, renderer: THREE.WebGLRenderer);
|
|
893
|
-
create(nodes: GraphNode[], simulationBuffers: SimulationBuffers, pickBuffer: PickBuffer): void;
|
|
894
|
-
setPositionTexture(positionTexture: THREE.Texture): void;
|
|
895
|
-
pick(pixelX: number, pixelY: number, camera: THREE.Camera): number;
|
|
896
|
-
highlight(nodeIds: string[], step?: number): void;
|
|
897
|
-
clearHighlights(step?: number): void;
|
|
898
|
-
/**
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
updateOpacity(): void;
|
|
902
|
-
resize(width: number, height: number): void;
|
|
903
|
-
dispose(): void;
|
|
904
|
-
private buildNodeMapping;
|
|
905
|
-
/**
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
private createNodeData;
|
|
910
|
-
private createGeometry;
|
|
911
|
-
private createRenderMaterial;
|
|
912
|
-
private createPickMaterial;
|
|
913
|
-
}
|
|
914
|
-
//#endregion
|
|
915
|
-
//#region rendering/GraphScene.d.ts
|
|
916
|
-
/**
|
|
917
|
-
* GraphScene - Manages the 3D scene, camera, and renderers
|
|
918
|
-
* Responsibilities:
|
|
919
|
-
* - Scene setup and lifecycle
|
|
920
|
-
* - Node and link rendering
|
|
921
|
-
* - Camera control
|
|
922
|
-
* - Tooltip management
|
|
923
|
-
* - Mode application (visual changes)
|
|
924
|
-
*/
|
|
925
|
-
declare class GraphScene {
|
|
926
|
-
readonly scene: THREE.Scene;
|
|
927
|
-
readonly renderer: THREE.WebGLRenderer;
|
|
928
|
-
readonly camera: CameraController;
|
|
929
|
-
private nodeRenderer;
|
|
930
|
-
private clock;
|
|
931
|
-
private linkRenderer;
|
|
932
|
-
constructor(canvas: HTMLCanvasElement, cameraConfig?: CameraConfig);
|
|
933
|
-
/**
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
create(nodes: GraphNode[], links: GraphLink[], simulationBuffers: SimulationBuffers, pickBuffer: PickBuffer, groupOrder?: string[]): void;
|
|
937
|
-
/**
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
applyMode(mode: string, options?: {
|
|
941
|
-
transitionDuration?: number;
|
|
942
|
-
cameraTransitionDuration?: number;
|
|
943
|
-
}): void;
|
|
944
|
-
/**
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
updatePositions(positionTexture: THREE.Texture): void;
|
|
948
|
-
/**
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
update(elapsedTime: number): void;
|
|
952
|
-
/**
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
pick(pixelX: number, pixelY: number): number;
|
|
956
|
-
/**
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
render(): void;
|
|
960
|
-
/**
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
resize(width: number, height: number): void;
|
|
964
|
-
/**
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
dispose(): void;
|
|
968
|
-
private applyDefaultMode;
|
|
969
|
-
getCamera(): CameraController;
|
|
970
|
-
getNodeRenderer(): NodesRenderer | null;
|
|
971
|
-
getLinkRenderer(): LinksRenderer | null;
|
|
972
|
-
}
|
|
973
|
-
//#endregion
|
|
974
|
-
//#region ui/TooltipManager.d.ts
|
|
975
|
-
declare class TooltipManager {
|
|
976
|
-
private container;
|
|
977
|
-
private canvas;
|
|
978
|
-
private mainTooltip;
|
|
979
|
-
private previewTooltip;
|
|
980
|
-
private chainTooltips;
|
|
981
|
-
private config;
|
|
982
|
-
private closeButton;
|
|
983
|
-
private onCloseCallback?;
|
|
984
|
-
constructor(container: HTMLElement, canvas: HTMLCanvasElement, config?: TooltipConfig);
|
|
985
|
-
/**
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
showGrabIcon(x: number, y: number, progress: number): void;
|
|
989
|
-
hideGrabIcon(): void;
|
|
990
|
-
/**
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
showPreview(node: GraphNode, x: number, y: number): void;
|
|
994
|
-
hidePreview(): void;
|
|
995
|
-
/**
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
showFull(node: GraphNode, x: number, y: number): void;
|
|
999
|
-
hideFull(): void;
|
|
1000
|
-
/**
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
setOnCloseCallback(callback: () => void): void;
|
|
1004
|
-
/**
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
private addCloseButton;
|
|
1008
|
-
/**
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
private removeCloseButton;
|
|
1012
|
-
/**
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
hideAll(): void;
|
|
1016
|
-
/**
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
private generatePreviewContent;
|
|
1020
|
-
/**
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
private generateFullContent;
|
|
1024
|
-
private escapeHtml;
|
|
1025
|
-
showMainTooltip(content: string, x: number, y: number): void;
|
|
1026
|
-
hideMainTooltip(): void;
|
|
1027
|
-
showChainTooltip(nodeId: string, content: string, x: number, y: number): void;
|
|
1028
|
-
hideChainTooltips(): void;
|
|
1029
|
-
updateMainTooltipPos(x: number, y: number): void;
|
|
1030
|
-
dispose(): void;
|
|
1031
|
-
}
|
|
1032
|
-
//#endregion
|
|
1033
|
-
//#region controls/InteractionManager.d.ts
|
|
1034
|
-
declare class InteractionManager {
|
|
1035
|
-
private graphScene?;
|
|
1036
|
-
private getConnectedNodeIds?;
|
|
1037
|
-
private pointerInput;
|
|
1038
|
-
private hoverHandler;
|
|
1039
|
-
private clickHandler;
|
|
1040
|
-
private dragHandler;
|
|
1041
|
-
tooltipManager: TooltipManager;
|
|
1042
|
-
private isDragging;
|
|
1043
|
-
isTooltipSticky: boolean;
|
|
1044
|
-
stickyNodeId: string | null;
|
|
1045
|
-
searchHighlightIds: string[];
|
|
1046
|
-
constructor(pickFunction: (x: number, y: number) => number, canvas: HTMLCanvasElement, viewport: {
|
|
1047
|
-
width: number;
|
|
1048
|
-
height: number;
|
|
1049
|
-
}, getNodeByIndex: (index: number) => GraphNode | null, cameraController?: CameraController, forceSimulation?: ForceSimulation, tooltipConfig?: TooltipConfig, graphScene?: GraphScene, getConnectedNodeIds?: (nodeId: string) => string[]);
|
|
1050
|
-
private wireEvents;
|
|
1051
|
-
private wireTooltipEvents;
|
|
1052
|
-
/**
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
private wireVisualFeedbackEvents;
|
|
1057
|
-
getPointerInput(): InputProcessor;
|
|
1058
|
-
getHoverHandler(): HoverHandler;
|
|
1059
|
-
getClickHandler(): ClickHandler;
|
|
1060
|
-
getDragHandler(): DragHandler;
|
|
1061
|
-
getTooltipManager(): TooltipManager;
|
|
1062
|
-
isTooltipStickyOpen(): boolean;
|
|
1063
|
-
/**
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
resize(width: number, height: number): void;
|
|
1067
|
-
cleanup(): void;
|
|
1068
|
-
dispose(): void;
|
|
1069
|
-
}
|
|
1070
|
-
//#endregion
|
|
1071
|
-
//#region core/Clock.d.ts
|
|
1072
|
-
/**
|
|
1073
|
-
* Clock - Unified timing for the force graph package
|
|
1074
|
-
*/
|
|
1075
|
-
declare class Clock {
|
|
1076
|
-
private previousTime;
|
|
1077
|
-
private elapsedTime;
|
|
1078
|
-
private deltaTime;
|
|
1079
|
-
private isRunning;
|
|
1080
|
-
private maxDeltaTime;
|
|
1081
|
-
constructor();
|
|
1082
|
-
/**
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
start(): void;
|
|
1086
|
-
/**
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
stop(): void;
|
|
1090
|
-
/**
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
update(): number;
|
|
1095
|
-
/**
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
getDeltaTime(): number;
|
|
1099
|
-
/**
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
getElapsedTime(): number;
|
|
1103
|
-
/**
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
getIsRunning(): boolean;
|
|
1107
|
-
}
|
|
1108
|
-
//#endregion
|
|
1109
|
-
//#region core/GraphStore.d.ts
|
|
1110
|
-
/**
|
|
1111
|
-
* GraphStore - Central data management
|
|
1112
|
-
* Responsibilities:
|
|
1113
|
-
* - Store raw graph data (nodes, links)
|
|
1114
|
-
* - Node/Link CRUD operations
|
|
1115
|
-
* - ID mapping and lookups
|
|
1116
|
-
* - Data validation
|
|
1117
|
-
* - Change notifications
|
|
1118
|
-
*/
|
|
1119
|
-
declare class GraphStore {
|
|
1120
|
-
private nodes;
|
|
1121
|
-
private links;
|
|
1122
|
-
private nodeArray;
|
|
1123
|
-
private linkArray;
|
|
1124
|
-
private nodeIdToIndex;
|
|
1125
|
-
private linkIdToIndex;
|
|
1126
|
-
private nodeToLinks;
|
|
1127
|
-
constructor();
|
|
1128
|
-
/**
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
setData(data: GraphData): void;
|
|
1132
|
-
/**
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
addNodes(nodes: GraphNode[]): void;
|
|
1136
|
-
/**
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
removeNodes(nodeIds: string[]): void;
|
|
1140
|
-
/**
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
addLinks(links: GraphLink[]): void;
|
|
1144
|
-
/**
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
removeLinks(linkIds: string[]): void;
|
|
1148
|
-
/**
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
getNodes(): GraphNode[];
|
|
1152
|
-
/**
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
getLinks(): GraphLink[];
|
|
1156
|
-
/**
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
getConnectedNodeIds(nodeId: string): string[];
|
|
1160
|
-
/**
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
getNodeById(id: string): GraphNode | null;
|
|
1164
|
-
/**
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
getNodeByIndex(index: number): GraphNode | null;
|
|
1168
|
-
/**
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
getNodeIndex(id: string): number;
|
|
1172
|
-
/**
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
getLinkById(id: string): GraphLink | null;
|
|
1176
|
-
/**
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
getNodeLinks(nodeId: string): GraphLink[];
|
|
1180
|
-
/**
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
getNodeCount(): number;
|
|
1184
|
-
/**
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
getLinkCount(): number;
|
|
1188
|
-
/**
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
clear(): void;
|
|
1192
|
-
private getLinkId;
|
|
1193
|
-
private addLinkConnectivity;
|
|
1194
|
-
private removeLinkConnectivity;
|
|
1195
|
-
private rebuildNodeArrays;
|
|
1196
|
-
private rebuildLinkArrays;
|
|
1197
|
-
}
|
|
1198
|
-
//#endregion
|
|
1199
|
-
//#region core/Engine.d.ts
|
|
1200
|
-
interface EngineOptions {
|
|
1201
|
-
width?: number;
|
|
1202
|
-
height?: number;
|
|
1203
|
-
backgroundColor?: string;
|
|
1204
|
-
tooltipConfig?: TooltipConfig;
|
|
1205
|
-
groupOrder?: string[];
|
|
1206
|
-
}
|
|
1207
|
-
/**
|
|
1208
|
-
* Engine - Main orchestrator
|
|
1209
|
-
* Responsibilities:
|
|
1210
|
-
* - Owns all shared buffers (StaticAssets, SimulationBuffers, PickBuffer)
|
|
1211
|
-
* - Coordinates GraphStore, GraphScene, ForceSimulation
|
|
1212
|
-
* - Manages render loop
|
|
1213
|
-
* - Handles user interaction
|
|
1214
|
-
*/
|
|
1215
|
-
declare class Engine {
|
|
1216
|
-
readonly canvas: HTMLCanvasElement;
|
|
1217
|
-
readonly graphStore: GraphStore;
|
|
1218
|
-
private graphScene;
|
|
1219
|
-
private forceSimulation;
|
|
1220
|
-
interactionManager: InteractionManager;
|
|
1221
|
-
private clock;
|
|
1222
|
-
private simulationBuffers;
|
|
1223
|
-
private pickBuffer;
|
|
1224
|
-
private animationFrameId;
|
|
1225
|
-
private isRunning;
|
|
1226
|
-
private boundResizeHandler;
|
|
1227
|
-
private groupOrder?;
|
|
1228
|
-
constructor(canvas: HTMLCanvasElement, options?: EngineOptions);
|
|
1229
|
-
/**
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
private handleWindowResize;
|
|
1233
|
-
/**
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
setData(data: GraphData): void;
|
|
1237
|
-
/**
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
updateNodeStates(callback: (node: GraphNode) => NodeState): void;
|
|
1242
|
-
/**
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
reheat(alpha?: number): void;
|
|
1246
|
-
/**
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
setAlphaDecay(decay: number): void;
|
|
1250
|
-
/**
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
getAlpha(): number;
|
|
1254
|
-
/**Apply a preset to the graph
|
|
1255
|
-
|
|
1256
|
-
applyPreset(preset: GraphPreset): void;
|
|
1257
|
-
/**
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
start(): void;
|
|
1262
|
-
/**
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
stop(): void;
|
|
1266
|
-
/**
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
private animate;
|
|
1270
|
-
/**
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
pickNode(x: number, y: number): string | null;
|
|
1274
|
-
/**
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
getNodeById(id: string): GraphNode | null;
|
|
1278
|
-
/**
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
highlightNodes(nodeIds: string[]): void;
|
|
1282
|
-
/**
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
clearHighlights(): void;
|
|
1286
|
-
/**
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
getNodePosition(nodeId: string): THREE.Vector3 | null;
|
|
1290
|
-
/**
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
*/
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
*
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1
|
+
import CameraControls from "camera-controls";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
|
|
4
|
+
//#region types/iCameraMode.d.ts
|
|
5
|
+
declare enum CameraMode {
|
|
6
|
+
Orbit = "orbit",
|
|
7
|
+
Map = "map"
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region rendering/CameraController.d.ts
|
|
11
|
+
interface CameraConfig {
|
|
12
|
+
fov?: number;
|
|
13
|
+
aspect?: number;
|
|
14
|
+
near?: number;
|
|
15
|
+
far?: number;
|
|
16
|
+
position?: THREE.Vector3;
|
|
17
|
+
target?: THREE.Vector3;
|
|
18
|
+
minDistance?: number;
|
|
19
|
+
maxDistance?: number;
|
|
20
|
+
}
|
|
21
|
+
interface ControlsConfig {
|
|
22
|
+
smoothTime?: number;
|
|
23
|
+
dollyToCursor?: boolean;
|
|
24
|
+
infinityDolly?: boolean;
|
|
25
|
+
enableZoom?: boolean;
|
|
26
|
+
enableRotation?: boolean;
|
|
27
|
+
enablePan?: boolean;
|
|
28
|
+
minDistance?: number;
|
|
29
|
+
maxDistance?: number;
|
|
30
|
+
maxPolarAngle?: number;
|
|
31
|
+
minPolarAngle?: number;
|
|
32
|
+
minAzimuthAngle?: number;
|
|
33
|
+
maxAzimuthAngle?: number;
|
|
34
|
+
}
|
|
35
|
+
declare class CameraController {
|
|
36
|
+
camera: THREE.PerspectiveCamera;
|
|
37
|
+
controls: CameraControls;
|
|
38
|
+
private sceneBounds;
|
|
39
|
+
private autorotateEnabled;
|
|
40
|
+
private autorotateSpeed;
|
|
41
|
+
private userIsActive;
|
|
42
|
+
constructor(domelement: HTMLElement, config?: CameraConfig);
|
|
43
|
+
private setupDefaultControls;
|
|
44
|
+
/**
|
|
45
|
+
* Set camera control mode
|
|
46
|
+
*/
|
|
47
|
+
setMode(mode: CameraMode): void;
|
|
48
|
+
/**
|
|
49
|
+
* Set camera boundary
|
|
50
|
+
*/
|
|
51
|
+
setBoundary(box: THREE.Box3): void;
|
|
52
|
+
/**
|
|
53
|
+
* Update camera controls (should be called in render loop)
|
|
54
|
+
* Only autorotate if enabled and user is inactive
|
|
55
|
+
*/
|
|
56
|
+
update(delta: number): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Set autorotate enabled/disabled
|
|
59
|
+
*/
|
|
60
|
+
setAutorotate(enabled: boolean, speed?: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* Set user activity state
|
|
63
|
+
*/
|
|
64
|
+
setUserIsActive(isActive: boolean): void;
|
|
65
|
+
/**
|
|
66
|
+
* Configure camera controls
|
|
67
|
+
*/
|
|
68
|
+
configureControls(config: ControlsConfig): void;
|
|
69
|
+
/**
|
|
70
|
+
* Resize camera when window resizes
|
|
71
|
+
*/
|
|
72
|
+
resize(width: number, height: number): void;
|
|
73
|
+
/**
|
|
74
|
+
* Animate camera to look at a specific target from a specific position
|
|
75
|
+
*/
|
|
76
|
+
setLookAt(position: THREE.Vector3, target: THREE.Vector3, enableTransition?: boolean): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Reset camera to default position
|
|
79
|
+
*/
|
|
80
|
+
reset(enableTransition?: boolean): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Enable/disable controls
|
|
83
|
+
*/
|
|
84
|
+
setEnabled(enabled: boolean): void;
|
|
85
|
+
/**
|
|
86
|
+
* Get current camera target (look-at point)
|
|
87
|
+
*/
|
|
88
|
+
getTarget(out?: THREE.Vector3): THREE.Vector3;
|
|
89
|
+
/**
|
|
90
|
+
* Dispose camera manager and clean up
|
|
91
|
+
*/
|
|
92
|
+
dispose(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Clear camera bounds (remove boundary restrictions)
|
|
95
|
+
*/
|
|
96
|
+
clearBounds(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Get current scene bounds
|
|
99
|
+
*/
|
|
100
|
+
getSceneBounds(): THREE.Box3 | null;
|
|
101
|
+
/**
|
|
102
|
+
* Update scene bounds used by the camera manager.
|
|
103
|
+
* Stores the bounds for future use (e.g. constraining controls).
|
|
104
|
+
*/
|
|
105
|
+
updateBounds(box: THREE.Box3): void;
|
|
106
|
+
/**
|
|
107
|
+
* Unified configuration method
|
|
108
|
+
*/
|
|
109
|
+
setOptions(options: {
|
|
110
|
+
controls?: ControlsConfig;
|
|
111
|
+
autoRotate?: boolean;
|
|
112
|
+
autoRotateSpeed?: number;
|
|
113
|
+
}): void;
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region types/iGraphLink.d.ts
|
|
117
|
+
interface GraphLink {
|
|
118
|
+
source: string;
|
|
119
|
+
target: string;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region types/iGraphNode.d.ts
|
|
123
|
+
interface GraphNode {
|
|
124
|
+
id: string;
|
|
125
|
+
label?: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
thumbnailUrl?: string;
|
|
128
|
+
category?: string;
|
|
129
|
+
x?: number;
|
|
130
|
+
y?: number;
|
|
131
|
+
z?: number;
|
|
132
|
+
fx?: number;
|
|
133
|
+
fy?: number;
|
|
134
|
+
fz?: number;
|
|
135
|
+
state?: NodeState;
|
|
136
|
+
metadata?: any;
|
|
137
|
+
}
|
|
138
|
+
declare enum NodeState {
|
|
139
|
+
Hidden = 0,
|
|
140
|
+
// = 0 not rendered
|
|
141
|
+
Passive = 1,
|
|
142
|
+
// = 1 rendered, not influencing simulation,
|
|
143
|
+
Fixed = 2,
|
|
144
|
+
// = 2 rendered, influencing simulation, but not moving
|
|
145
|
+
Active = 3
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region types/iGraphData.d.ts
|
|
149
|
+
interface GraphData {
|
|
150
|
+
nodes: GraphNode[];
|
|
151
|
+
links: GraphLink[];
|
|
152
|
+
metadata?: any;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region types/iForceConfig.d.ts
|
|
156
|
+
interface ForceConfig {
|
|
157
|
+
collisionStrength: number;
|
|
158
|
+
collisionRadius: number;
|
|
159
|
+
collisionMaxDistance: number;
|
|
160
|
+
enableCollision: boolean;
|
|
161
|
+
manyBodyStrength: number;
|
|
162
|
+
manyBodyMinDistance: number;
|
|
163
|
+
manyBodyMaxDistance: number;
|
|
164
|
+
enableManyBody: boolean;
|
|
165
|
+
springStrength: number;
|
|
166
|
+
springLength: number;
|
|
167
|
+
springDamping: number;
|
|
168
|
+
maxLinks: number;
|
|
169
|
+
enableLinks: boolean;
|
|
170
|
+
gravity: number;
|
|
171
|
+
enableGravity: boolean;
|
|
172
|
+
attractorStrength: number;
|
|
173
|
+
enableAttractors: boolean;
|
|
174
|
+
elasticStrength: number;
|
|
175
|
+
enableElastic: boolean;
|
|
176
|
+
dragStrength: number;
|
|
177
|
+
damping: number;
|
|
178
|
+
alpha: number;
|
|
179
|
+
alphaDecay: number;
|
|
180
|
+
deltaTime: number;
|
|
181
|
+
spaceSize: number;
|
|
182
|
+
is3D: boolean;
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region types/iGraphPreset.d.ts
|
|
186
|
+
interface GraphPreset {
|
|
187
|
+
name: string;
|
|
188
|
+
force?: Partial<ForceConfig>;
|
|
189
|
+
camera?: {
|
|
190
|
+
mode?: CameraMode;
|
|
191
|
+
position?: {
|
|
192
|
+
x: number;
|
|
193
|
+
y: number;
|
|
194
|
+
z: number;
|
|
195
|
+
};
|
|
196
|
+
target?: {
|
|
197
|
+
x: number;
|
|
198
|
+
y: number;
|
|
199
|
+
z: number;
|
|
200
|
+
};
|
|
201
|
+
zoom?: number;
|
|
202
|
+
transitionDuration?: number;
|
|
203
|
+
minDistance?: number;
|
|
204
|
+
maxDistance?: number;
|
|
205
|
+
boundary?: {
|
|
206
|
+
min: {
|
|
207
|
+
x: number;
|
|
208
|
+
y: number;
|
|
209
|
+
z: number;
|
|
210
|
+
};
|
|
211
|
+
max: {
|
|
212
|
+
x: number;
|
|
213
|
+
y: number;
|
|
214
|
+
z: number;
|
|
215
|
+
};
|
|
216
|
+
} | null;
|
|
217
|
+
};
|
|
218
|
+
nodes?: {
|
|
219
|
+
state?: (node: GraphNode) => NodeState;
|
|
220
|
+
};
|
|
221
|
+
links?: {
|
|
222
|
+
opacity?: number;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region ui/Tooltips.d.ts
|
|
227
|
+
/**
|
|
228
|
+
* Renderer function type for custom tooltip rendering
|
|
229
|
+
* Can mount React, Vue, or any other framework component
|
|
230
|
+
*/
|
|
231
|
+
type TooltipRenderer = (container: HTMLElement, node: GraphNode, type: 'preview' | 'full', x: number, y: number, onPositionUpdate?: (callback: (x: number, y: number) => void) => void) => void | (() => void);
|
|
232
|
+
/**
|
|
233
|
+
* Cursor handler for custom cursor behavior
|
|
234
|
+
*/
|
|
235
|
+
type CursorHandler = (canvas: HTMLCanvasElement | null, state: 'default' | 'pointer' | 'grab') => void;
|
|
236
|
+
interface TooltipConfig {
|
|
237
|
+
/** Custom renderer for tooltips (React, Vue, etc.) */
|
|
238
|
+
renderer?: TooltipRenderer;
|
|
239
|
+
/** Custom cursor handler */
|
|
240
|
+
cursorHandler?: CursorHandler;
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region core/EventEmitter.d.ts
|
|
244
|
+
declare class EventEmitter {
|
|
245
|
+
private listeners;
|
|
246
|
+
protected listenerCount(event: string): number;
|
|
247
|
+
on(event: string, listener: Function): () => void;
|
|
248
|
+
off(event: string, listener: Function): void;
|
|
249
|
+
emit(event: string, ...args: any[]): void;
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region controls/InputProcessor.d.ts
|
|
253
|
+
/**
|
|
254
|
+
* Manages pointer/mouse input and emits interaction events
|
|
255
|
+
* Uses GPU picking for efficient node detection
|
|
256
|
+
*/
|
|
257
|
+
declare class InputProcessor extends EventEmitter {
|
|
258
|
+
private pickFn;
|
|
259
|
+
private canvas;
|
|
260
|
+
private viewport;
|
|
261
|
+
private readonly CLICK_THRESHOLD;
|
|
262
|
+
private readonly HOVER_TO_POP_MS;
|
|
263
|
+
private pointer;
|
|
264
|
+
private canvasPointer;
|
|
265
|
+
private isPointerDown;
|
|
266
|
+
private isDragging;
|
|
267
|
+
private mouseDownTime;
|
|
268
|
+
private draggedIndex;
|
|
269
|
+
private currentHoverIndex;
|
|
270
|
+
private hoverStartTime;
|
|
271
|
+
private hoverProgress;
|
|
272
|
+
private hasPopped;
|
|
273
|
+
private lastClientX;
|
|
274
|
+
private lastClientY;
|
|
275
|
+
constructor(pickFn: (x: number, y: number) => number, // Injected
|
|
276
|
+
canvas: HTMLCanvasElement, viewport: {
|
|
277
|
+
width: number;
|
|
278
|
+
height: number;
|
|
279
|
+
});
|
|
280
|
+
private setupEventListeners;
|
|
281
|
+
private handlePointerMove;
|
|
282
|
+
private handlePointerDown;
|
|
283
|
+
private handlePointerUp;
|
|
284
|
+
private handlePointerLeave;
|
|
285
|
+
private updateHover;
|
|
286
|
+
/**
|
|
287
|
+
* Update hover state even when pointer is stationary
|
|
288
|
+
* Called from render loop
|
|
289
|
+
*/
|
|
290
|
+
update(): void;
|
|
291
|
+
private updatePointer;
|
|
292
|
+
/**
|
|
293
|
+
* Update viewport dimensions on resize
|
|
294
|
+
*/
|
|
295
|
+
resize(width: number, height: number): void;
|
|
296
|
+
dispose(): void;
|
|
297
|
+
}
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region controls/handlers/HoverHandler.d.ts
|
|
300
|
+
declare class HoverHandler extends EventEmitter {
|
|
301
|
+
private getNodeByIndex;
|
|
302
|
+
constructor(getNodeByIndex: (index: number) => GraphNode | null);
|
|
303
|
+
private handleHoverStart;
|
|
304
|
+
private handleHover;
|
|
305
|
+
private handlePop;
|
|
306
|
+
private handleHoverEnd;
|
|
307
|
+
dispose(): void;
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region controls/handlers/ClickHandler.d.ts
|
|
311
|
+
declare class ClickHandler extends EventEmitter {
|
|
312
|
+
private getNodeByIndex;
|
|
313
|
+
constructor(getNodeByIndex: (index: number) => GraphNode | null);
|
|
314
|
+
private handleClick;
|
|
315
|
+
dispose(): void;
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region textures/SimulationBuffers.d.ts
|
|
319
|
+
/**
|
|
320
|
+
* Manages dynamic render targets updated by force simulation
|
|
321
|
+
* Uses ping-pong technique for GPU computation
|
|
322
|
+
* Buffers are created lazily when data is initialized
|
|
323
|
+
*/
|
|
324
|
+
declare class SimulationBuffers {
|
|
325
|
+
private renderer;
|
|
326
|
+
private textureSize;
|
|
327
|
+
private positionBuffers;
|
|
328
|
+
private velocityBuffers;
|
|
329
|
+
private isInitialized;
|
|
330
|
+
constructor(renderer: THREE.WebGLRenderer);
|
|
331
|
+
/**
|
|
332
|
+
* Check if buffers are initialized
|
|
333
|
+
*/
|
|
334
|
+
isReady(): boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Initialize buffers with point count and initial positions
|
|
337
|
+
*/
|
|
338
|
+
init(pointsCount: number, initialPositions?: Float32Array): void;
|
|
339
|
+
/**
|
|
340
|
+
* Resize buffers (re-initializes with new size)
|
|
341
|
+
*/
|
|
342
|
+
resize(pointsCount: number, preserveData?: boolean): void;
|
|
343
|
+
private calculateTextureSize;
|
|
344
|
+
private createDynamicBuffer;
|
|
345
|
+
/**
|
|
346
|
+
* Initialize position buffers from initial data
|
|
347
|
+
*/
|
|
348
|
+
setInitialPositions(positionArray: Float32Array): void;
|
|
349
|
+
/**
|
|
350
|
+
* Update current and previous positions, but keep original positions intact
|
|
351
|
+
*/
|
|
352
|
+
updateCurrentPositions(positionArray: Float32Array): void;
|
|
353
|
+
/**
|
|
354
|
+
* Set original positions (anchors) separately from current positions
|
|
355
|
+
*/
|
|
356
|
+
setOriginalPositions(positionArray: Float32Array): void;
|
|
357
|
+
/**
|
|
358
|
+
* Initialize velocity buffers (usually to zero)
|
|
359
|
+
*/
|
|
360
|
+
initVelocities(): void;
|
|
361
|
+
/**
|
|
362
|
+
* Swap position buffers (ping-pong)
|
|
363
|
+
*/
|
|
364
|
+
swapPositions(): void;
|
|
365
|
+
/**
|
|
366
|
+
* Swap velocity buffers (ping-pong)
|
|
367
|
+
*/
|
|
368
|
+
swapVelocities(): void;
|
|
369
|
+
/**
|
|
370
|
+
* Reset positions to original state
|
|
371
|
+
*/
|
|
372
|
+
resetPositions(): void;
|
|
373
|
+
/**
|
|
374
|
+
* Read current positions back from GPU (expensive operation)
|
|
375
|
+
* Returns RGBA float array (x, y, z, state)
|
|
376
|
+
*/
|
|
377
|
+
readPositions(): Float32Array;
|
|
378
|
+
getCurrentPositionTarget(): THREE.WebGLRenderTarget | null;
|
|
379
|
+
getPreviousPositionTarget(): THREE.WebGLRenderTarget | null;
|
|
380
|
+
getCurrentPositionTexture(): THREE.Texture<unknown>;
|
|
381
|
+
getPreviousPositionTexture(): THREE.Texture | null;
|
|
382
|
+
getOriginalPositionTexture(): THREE.Texture | null;
|
|
383
|
+
getCurrentVelocityTarget(): THREE.WebGLRenderTarget | null;
|
|
384
|
+
getPreviousVelocityTarget(): THREE.WebGLRenderTarget | null;
|
|
385
|
+
getCurrentVelocityTexture(): THREE.Texture | null;
|
|
386
|
+
getPreviousVelocityTexture(): THREE.Texture | null;
|
|
387
|
+
getTextureSize(): number;
|
|
388
|
+
private arrayToTextureData;
|
|
389
|
+
private createDataTexture;
|
|
390
|
+
private copyTextureToBuffer;
|
|
391
|
+
private copyBufferToBuffer;
|
|
392
|
+
dispose(): void;
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region types/iAttractor.d.ts
|
|
396
|
+
/**
|
|
397
|
+
* Simple 3D vector type
|
|
398
|
+
*/
|
|
399
|
+
interface Vec3 {
|
|
400
|
+
x: number;
|
|
401
|
+
y: number;
|
|
402
|
+
z: number;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Attractor - A point in space that attracts nodes of specific groups
|
|
406
|
+
*/
|
|
407
|
+
interface Attractor {
|
|
408
|
+
/** Unique identifier */
|
|
409
|
+
id: string;
|
|
410
|
+
/** Position in world space */
|
|
411
|
+
position: Vec3;
|
|
412
|
+
/** Radius of attraction (default: 0.0) - nodes within this radius are not pulled further */
|
|
413
|
+
radius?: number;
|
|
414
|
+
/** Groups of nodes attracted to this attractor (empty = attracts all) */
|
|
415
|
+
groups: string[];
|
|
416
|
+
/** Strength of attraction (default: 1.0) */
|
|
417
|
+
strength?: number;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Resolved attractor with defaults applied
|
|
421
|
+
*/
|
|
422
|
+
interface ResolvedAttractor {
|
|
423
|
+
id: string;
|
|
424
|
+
position: Vec3;
|
|
425
|
+
groups: string[];
|
|
426
|
+
strength: number;
|
|
427
|
+
radius: number;
|
|
428
|
+
}
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region textures/StaticAssets.d.ts
|
|
431
|
+
/**
|
|
432
|
+
* Manages read-only GPU textures created at initialization
|
|
433
|
+
* These never change during simulation (except for mode changes)
|
|
434
|
+
*
|
|
435
|
+
* Node data: radii, colors
|
|
436
|
+
* Link data: source/target indices, properties
|
|
437
|
+
*/
|
|
438
|
+
declare class StaticAssets {
|
|
439
|
+
private nodeRadiiTexture;
|
|
440
|
+
private nodeColorsTexture;
|
|
441
|
+
private linkIndicesTexture;
|
|
442
|
+
private linkPropertiesTexture;
|
|
443
|
+
private nodeLinkMapTexture;
|
|
444
|
+
private nodeTextureSize;
|
|
445
|
+
private linkTextureSize;
|
|
446
|
+
constructor();
|
|
447
|
+
/**
|
|
448
|
+
* Set/update node radii texture
|
|
449
|
+
*/
|
|
450
|
+
setNodeRadii(radii: Float32Array, textureSize: number): void;
|
|
451
|
+
/**
|
|
452
|
+
* Set/update node colors texture
|
|
453
|
+
*/
|
|
454
|
+
setNodeColors(colors: Float32Array, textureSize: number): void;
|
|
455
|
+
/**
|
|
456
|
+
* Set link indices (source/target pairs)
|
|
457
|
+
* Format: [sourceX, sourceY, targetX, targetY] per link
|
|
458
|
+
*/
|
|
459
|
+
setLinkIndices(linkIndices: Float32Array, textureSize: number): void;
|
|
460
|
+
/**
|
|
461
|
+
* Set link properties (strength, distance, etc.)
|
|
462
|
+
*/
|
|
463
|
+
setLinkProperties(linkProperties: Float32Array, textureSize: number): void;
|
|
464
|
+
setNodeLinkMap(linkMap: Float32Array, textureSize: number): void;
|
|
465
|
+
/**
|
|
466
|
+
* Create a data texture with proper settings for GPU compute
|
|
467
|
+
*/
|
|
468
|
+
private createTexture;
|
|
469
|
+
getNodeRadiiTexture(): THREE.DataTexture | null;
|
|
470
|
+
getNodeColorsTexture(): THREE.DataTexture | null;
|
|
471
|
+
getLinkIndicesTexture(): THREE.DataTexture | null;
|
|
472
|
+
getLinkPropertiesTexture(): THREE.DataTexture | null;
|
|
473
|
+
getLinkMapTexture(): THREE.DataTexture | null;
|
|
474
|
+
getNodeTextureSize(): number;
|
|
475
|
+
getLinkTextureSize(): number;
|
|
476
|
+
/**
|
|
477
|
+
* Check if assets are ready
|
|
478
|
+
*/
|
|
479
|
+
hasNodeAssets(): boolean;
|
|
480
|
+
hasLinkAssets(): boolean;
|
|
481
|
+
/**
|
|
482
|
+
* Cleanup
|
|
483
|
+
*/
|
|
484
|
+
dispose(): void;
|
|
485
|
+
}
|
|
486
|
+
declare const staticAssets: StaticAssets;
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region simulation/BasePass.d.ts
|
|
489
|
+
interface PassContext {
|
|
490
|
+
scene: THREE.Scene;
|
|
491
|
+
camera: THREE.Camera;
|
|
492
|
+
quad: THREE.BufferGeometry;
|
|
493
|
+
simBuffers: SimulationBuffers;
|
|
494
|
+
assets: StaticAssets;
|
|
495
|
+
renderer: THREE.WebGLRenderer;
|
|
496
|
+
config: ForceConfig;
|
|
497
|
+
textureSize: number;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Base class for GPU force simulation passes
|
|
501
|
+
* Each pass operates on simulation buffers and can read from static assets
|
|
502
|
+
*/
|
|
503
|
+
declare abstract class BasePass {
|
|
504
|
+
protected material: THREE.ShaderMaterial | null;
|
|
505
|
+
protected enabled: boolean;
|
|
506
|
+
/**
|
|
507
|
+
* Get the name/identifier for this pass
|
|
508
|
+
*/
|
|
509
|
+
abstract getName(): string;
|
|
510
|
+
/**
|
|
511
|
+
* Initialize the shader material for this pass
|
|
512
|
+
*/
|
|
513
|
+
abstract initMaterial(context: PassContext): void;
|
|
514
|
+
/**
|
|
515
|
+
* Update uniforms before executing the pass
|
|
516
|
+
*/
|
|
517
|
+
abstract updateUniforms(context: PassContext): void;
|
|
518
|
+
/**
|
|
519
|
+
* Execute the pass (renders to current velocity target)
|
|
520
|
+
*/
|
|
521
|
+
execute(context: PassContext): void;
|
|
522
|
+
/**
|
|
523
|
+
* Render the compute shader
|
|
524
|
+
*/
|
|
525
|
+
protected render(context: PassContext): void;
|
|
526
|
+
/**
|
|
527
|
+
* Create a shader material helper
|
|
528
|
+
*/
|
|
529
|
+
protected createMaterial(vertexShader: string, fragmentShader: string, uniforms: {
|
|
530
|
+
[uniform: string]: THREE.IUniform;
|
|
531
|
+
}): THREE.ShaderMaterial;
|
|
532
|
+
/**
|
|
533
|
+
* Safe uniform setter - avoids TypeScript strict null check issues
|
|
534
|
+
*/
|
|
535
|
+
protected setUniform(name: string, value: unknown): void;
|
|
536
|
+
/**
|
|
537
|
+
* Enable or disable this pass
|
|
538
|
+
*/
|
|
539
|
+
setEnabled(enabled: boolean): void;
|
|
540
|
+
/**
|
|
541
|
+
* Check if pass is enabled
|
|
542
|
+
*/
|
|
543
|
+
isEnabled(): boolean;
|
|
544
|
+
/**
|
|
545
|
+
* Get the material for external access
|
|
546
|
+
*/
|
|
547
|
+
getMaterial(): THREE.ShaderMaterial | null;
|
|
548
|
+
/**
|
|
549
|
+
* Cleanup resources
|
|
550
|
+
*/
|
|
551
|
+
dispose(): void;
|
|
552
|
+
}
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region simulation/passes/AttractorPass.d.ts
|
|
555
|
+
/**
|
|
556
|
+
* Attractor force pass - attracts nodes to attractor points based on group membership
|
|
557
|
+
*
|
|
558
|
+
* Usage:
|
|
559
|
+
* attractorPass.setAttractors([
|
|
560
|
+
* { id: 'center', position: { x: 0, y: 0, z: 0 }, categories: ['root'] }, // categories acts as groups
|
|
561
|
+
* { id: 'left', position: { x: -100, y: 0, z: 0 }, categories: ['artwork', 'series'] }
|
|
562
|
+
* ])
|
|
563
|
+
*/
|
|
564
|
+
declare class AttractorPass extends BasePass {
|
|
565
|
+
private attractors;
|
|
566
|
+
private groupMap;
|
|
567
|
+
private attractorsTexture;
|
|
568
|
+
private attractorGroupsTexture;
|
|
569
|
+
private attractorParamsTexture;
|
|
570
|
+
private nodeGroupsTexture;
|
|
571
|
+
getName(): string;
|
|
572
|
+
initMaterial(context: PassContext): void;
|
|
573
|
+
updateUniforms(context: PassContext): void;
|
|
574
|
+
/**
|
|
575
|
+
* Set attractors for the simulation
|
|
576
|
+
*/
|
|
577
|
+
setAttractors(attractors: Attractor[]): void;
|
|
578
|
+
/**
|
|
579
|
+
* Add a single attractor
|
|
580
|
+
*/
|
|
581
|
+
addAttractor(attractor: Attractor): void;
|
|
582
|
+
/**
|
|
583
|
+
* Remove an attractor by ID
|
|
584
|
+
*/
|
|
585
|
+
removeAttractor(id: string): void;
|
|
586
|
+
/**
|
|
587
|
+
* Update an existing attractor's position
|
|
588
|
+
*/
|
|
589
|
+
updateAttractorPosition(id: string, position: Vec3): void;
|
|
590
|
+
/**
|
|
591
|
+
* Get current attractors
|
|
592
|
+
*/
|
|
593
|
+
getAttractors(): ResolvedAttractor[];
|
|
594
|
+
/**
|
|
595
|
+
* Set node groups from graph data
|
|
596
|
+
* Call this when graph data changes or grouping criteria changes
|
|
597
|
+
*/
|
|
598
|
+
setNodeGroups(groups: string[][], textureSize: number): void;
|
|
599
|
+
/**
|
|
600
|
+
* Get the group map (group name -> index)
|
|
601
|
+
*/
|
|
602
|
+
getGroupMap(): Map<string, number>;
|
|
603
|
+
private createAttractorTextures;
|
|
604
|
+
private updateAttractorTextures;
|
|
605
|
+
dispose(): void;
|
|
606
|
+
}
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region simulation/ForceSimulation.d.ts
|
|
609
|
+
/**
|
|
610
|
+
* ForceSimulation - GPU-based force simulation
|
|
611
|
+
*
|
|
612
|
+
* Simple architecture:
|
|
613
|
+
* - Single shared config object (ForceConfig)
|
|
614
|
+
* - All passes read directly from config via PassContext
|
|
615
|
+
* - Enable flags control which passes execute
|
|
616
|
+
* - No manual syncing required
|
|
617
|
+
*/
|
|
618
|
+
declare class ForceSimulation {
|
|
619
|
+
private renderer;
|
|
620
|
+
private simulationBuffers;
|
|
621
|
+
private computeScene;
|
|
622
|
+
private computeCamera;
|
|
623
|
+
private computeQuad;
|
|
624
|
+
private velocityCarryPass;
|
|
625
|
+
private collisionPass;
|
|
626
|
+
private manyBodyPass;
|
|
627
|
+
private gravityPass;
|
|
628
|
+
private linkPass;
|
|
629
|
+
private elasticPass;
|
|
630
|
+
private attractorPass;
|
|
631
|
+
private dragPass;
|
|
632
|
+
private integratePass;
|
|
633
|
+
private forcePasses;
|
|
634
|
+
readonly config: ForceConfig;
|
|
635
|
+
private isInitialized;
|
|
636
|
+
private iterationCount;
|
|
637
|
+
constructor(renderer: THREE.WebGLRenderer);
|
|
638
|
+
private createComputeQuad;
|
|
639
|
+
/**
|
|
640
|
+
* Initialize simulation with buffers
|
|
641
|
+
*/
|
|
642
|
+
initialize(simulationBuffers: SimulationBuffers): void;
|
|
643
|
+
private createContext;
|
|
644
|
+
/**
|
|
645
|
+
* Check if a pass should execute based on config
|
|
646
|
+
*/
|
|
647
|
+
private shouldExecutePass;
|
|
648
|
+
/**
|
|
649
|
+
* Run one simulation step
|
|
650
|
+
*/
|
|
651
|
+
step(deltaTime?: number): void;
|
|
652
|
+
/**
|
|
653
|
+
* Get config for GUI binding
|
|
654
|
+
* Modify this object directly - changes take effect on next step()
|
|
655
|
+
*/
|
|
656
|
+
getConfig(): ForceConfig;
|
|
657
|
+
/**
|
|
658
|
+
* Re-heat the simulation (set alpha to 1)
|
|
659
|
+
*/
|
|
660
|
+
reheat(amt?: number): void;
|
|
661
|
+
startDrag(index: number, targetWorldPos: THREE.Vector3): void;
|
|
662
|
+
updateDrag(targetWorldPos: THREE.Vector3): void;
|
|
663
|
+
endDrag(): void;
|
|
664
|
+
/**
|
|
665
|
+
* Set attractors for category-based attraction
|
|
666
|
+
* @param attractors Array of attractor definitions
|
|
667
|
+
*/
|
|
668
|
+
setAttractors(attractors: Attractor[]): void;
|
|
669
|
+
/**
|
|
670
|
+
* Add a single attractor
|
|
671
|
+
*/
|
|
672
|
+
addAttractor(attractor: Attractor): void;
|
|
673
|
+
/**
|
|
674
|
+
* Remove an attractor by ID
|
|
675
|
+
*/
|
|
676
|
+
removeAttractor(id: string): void;
|
|
677
|
+
/**
|
|
678
|
+
* Update an attractor's position (useful for animated attractors)
|
|
679
|
+
*/
|
|
680
|
+
updateAttractorPosition(id: string, position: Vec3): void;
|
|
681
|
+
/**
|
|
682
|
+
* Get current attractors
|
|
683
|
+
*/
|
|
684
|
+
getAttractors(): Attractor[];
|
|
685
|
+
/**
|
|
686
|
+
* Set node logic for attractor matching
|
|
687
|
+
* Call this when graph data changes
|
|
688
|
+
*/
|
|
689
|
+
setNodeGroups(groups: (string | string[])[]): void;
|
|
690
|
+
setNodeGroupsFromData<T>(data: T[], accessor: (item: T, index: number) => string | string[] | undefined): void;
|
|
691
|
+
/**
|
|
692
|
+
* Get the attractor pass for direct access
|
|
693
|
+
*/
|
|
694
|
+
getAttractorPass(): AttractorPass;
|
|
695
|
+
getAlpha(): number;
|
|
696
|
+
getIterationCount(): number;
|
|
697
|
+
reset(): void;
|
|
698
|
+
dispose(): void;
|
|
699
|
+
}
|
|
700
|
+
//#endregion
|
|
701
|
+
//#region controls/handlers/DragHandler.d.ts
|
|
702
|
+
declare class DragHandler extends EventEmitter {
|
|
703
|
+
private getNodeByIndex;
|
|
704
|
+
private cameraController?;
|
|
705
|
+
private forceSimulation?;
|
|
706
|
+
private viewport?;
|
|
707
|
+
private isDragging;
|
|
708
|
+
private raycaster;
|
|
709
|
+
private dragPlane;
|
|
710
|
+
private pointer;
|
|
711
|
+
constructor(getNodeByIndex: (index: number) => GraphNode | null, cameraController?: CameraController, forceSimulation?: ForceSimulation, viewport?: {
|
|
712
|
+
width: number;
|
|
713
|
+
height: number;
|
|
714
|
+
});
|
|
715
|
+
/**
|
|
716
|
+
* Set up drag plane perpendicular to camera, passing through a world point
|
|
717
|
+
*/
|
|
718
|
+
private setupDragPlane;
|
|
719
|
+
private handleDragStart;
|
|
720
|
+
private handleDrag;
|
|
721
|
+
private handleDragEnd;
|
|
722
|
+
/**
|
|
723
|
+
* Convert screen coordinates to world position on drag plane
|
|
724
|
+
*/
|
|
725
|
+
private screenToWorld;
|
|
726
|
+
/**
|
|
727
|
+
* Update viewport dimensions on resize
|
|
728
|
+
*/
|
|
729
|
+
resize(width: number, height: number): void;
|
|
730
|
+
dispose(): void;
|
|
731
|
+
}
|
|
732
|
+
//#endregion
|
|
733
|
+
//#region textures/PickBuffer.d.ts
|
|
734
|
+
/**
|
|
735
|
+
* Manages GPU picking buffer for mouse interaction
|
|
736
|
+
* Separate from simulation buffers as it has different lifecycle
|
|
737
|
+
*/
|
|
738
|
+
declare class PickBuffer {
|
|
739
|
+
private renderer;
|
|
740
|
+
private pickTarget;
|
|
741
|
+
constructor(renderer: THREE.WebGLRenderer);
|
|
742
|
+
/**
|
|
743
|
+
* Ensure pick buffer matches viewport size
|
|
744
|
+
*/
|
|
745
|
+
resize(width: number, height: number): void;
|
|
746
|
+
private createPickBuffer;
|
|
747
|
+
/**
|
|
748
|
+
* Read node ID at pixel coordinates
|
|
749
|
+
*/
|
|
750
|
+
readIdAt(x: number, y: number): number;
|
|
751
|
+
/**
|
|
752
|
+
* Render scene to pick buffer
|
|
753
|
+
*/
|
|
754
|
+
render(scene: THREE.Scene, camera: THREE.Camera): void;
|
|
755
|
+
getTarget(): THREE.WebGLRenderTarget | null;
|
|
756
|
+
dispose(): void;
|
|
757
|
+
}
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region rendering/links/LinksRenderer.d.ts
|
|
760
|
+
/**
|
|
761
|
+
* LinksRenderer - Renders links as line segments
|
|
762
|
+
* Uses shared SimulationBuffers for node positions
|
|
763
|
+
* Manages link-specific opacity and highlighting
|
|
764
|
+
*/
|
|
765
|
+
declare class LinksRenderer {
|
|
766
|
+
private scene;
|
|
767
|
+
private renderer;
|
|
768
|
+
private lines;
|
|
769
|
+
private links;
|
|
770
|
+
private nodeIndexMap;
|
|
771
|
+
private linkIndexMap;
|
|
772
|
+
private interpolationSteps;
|
|
773
|
+
params: {
|
|
774
|
+
noiseStrength: number;
|
|
775
|
+
defaultAlpha: number;
|
|
776
|
+
highlightAlpha: number;
|
|
777
|
+
dimmedAlpha: number;
|
|
778
|
+
is2D: boolean;
|
|
779
|
+
};
|
|
780
|
+
private linkOpacity;
|
|
781
|
+
private simulationBuffers;
|
|
782
|
+
constructor(scene: THREE.Scene, renderer: THREE.WebGLRenderer);
|
|
783
|
+
/**
|
|
784
|
+
* Create link geometry and materials
|
|
785
|
+
* Receives shared buffers as dependencies
|
|
786
|
+
*/
|
|
787
|
+
create(links: GraphLink[], nodes: GraphNode[], simulationBuffers: SimulationBuffers): void;
|
|
788
|
+
/**
|
|
789
|
+
* Update position texture from simulation
|
|
790
|
+
* This is the SHARED texture used by both nodes and links
|
|
791
|
+
*/
|
|
792
|
+
setPositionTexture(positionTexture: THREE.Texture): void;
|
|
793
|
+
/**
|
|
794
|
+
* Update shader uniforms (called each frame)
|
|
795
|
+
*/
|
|
796
|
+
update(time: number): void;
|
|
797
|
+
/**
|
|
798
|
+
* Update link opacity (called every frame)
|
|
799
|
+
*/
|
|
800
|
+
updateOpacity(): void;
|
|
801
|
+
/**
|
|
802
|
+
* Highlight links connected to a specific node
|
|
803
|
+
*/
|
|
804
|
+
highlightConnectedLinks(nodeId: string, step?: number): void;
|
|
805
|
+
/**
|
|
806
|
+
* Clear all highlights (return to defaultAlpha)
|
|
807
|
+
*/
|
|
808
|
+
clearHighlights(step?: number): void;
|
|
809
|
+
/**
|
|
810
|
+
* Update noise strength parameter
|
|
811
|
+
*/
|
|
812
|
+
setNoiseStrength(strength: number): void;
|
|
813
|
+
/**
|
|
814
|
+
* Update alpha parameters
|
|
815
|
+
*/
|
|
816
|
+
setAlphaParams(params: {
|
|
817
|
+
defaultAlpha?: number;
|
|
818
|
+
highlightAlpha?: number;
|
|
819
|
+
dimmedAlpha?: number;
|
|
820
|
+
}): void;
|
|
821
|
+
/**
|
|
822
|
+
* Unified configuration method
|
|
823
|
+
*/
|
|
824
|
+
setOptions(options: LinkOptions): void;
|
|
825
|
+
/**
|
|
826
|
+
* Refresh shader uniforms when params change
|
|
827
|
+
*/
|
|
828
|
+
refreshUniforms(): void;
|
|
829
|
+
/**
|
|
830
|
+
* Handle window resize
|
|
831
|
+
*/
|
|
832
|
+
resize(width: number, height: number): void;
|
|
833
|
+
/**
|
|
834
|
+
* Set visibility of links
|
|
835
|
+
*/
|
|
836
|
+
setVisible(visible: boolean): void;
|
|
837
|
+
/**
|
|
838
|
+
* Check if links are visible
|
|
839
|
+
*/
|
|
840
|
+
isVisible(): boolean;
|
|
841
|
+
/**
|
|
842
|
+
* Cleanup
|
|
843
|
+
*/
|
|
844
|
+
dispose(): void;
|
|
845
|
+
/**
|
|
846
|
+
* Build node index mapping
|
|
847
|
+
*/
|
|
848
|
+
private buildNodeMapping;
|
|
849
|
+
/**
|
|
850
|
+
* Create link geometry with interpolated segments
|
|
851
|
+
*/
|
|
852
|
+
private createLinkGeometry;
|
|
853
|
+
/**
|
|
854
|
+
* Build all link-related textures for simulation
|
|
855
|
+
* - linkIndicesData: parent node INDEX per link entry (organized by child)
|
|
856
|
+
* - linkPropertiesData: strength/distance per link entry
|
|
857
|
+
* - nodeLinkMapData: per-node metadata (startX, startY, count, hasLinks)
|
|
858
|
+
*/
|
|
859
|
+
private buildLinkTextures;
|
|
860
|
+
/**
|
|
861
|
+
* Create render material with all uniforms
|
|
862
|
+
*/
|
|
863
|
+
private createRenderMaterial;
|
|
864
|
+
}
|
|
865
|
+
interface LinkOptions {
|
|
866
|
+
visible?: boolean;
|
|
867
|
+
noiseStrength?: number;
|
|
868
|
+
alpha?: {
|
|
869
|
+
default?: number;
|
|
870
|
+
highlight?: number;
|
|
871
|
+
dimmed?: number;
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
//#endregion
|
|
875
|
+
//#region rendering/nodes/NodesRenderer.d.ts
|
|
876
|
+
declare class NodesRenderer {
|
|
877
|
+
private scene;
|
|
878
|
+
private renderer;
|
|
879
|
+
private points;
|
|
880
|
+
private pickMaterial;
|
|
881
|
+
private nodeIndexMap;
|
|
882
|
+
private idArray;
|
|
883
|
+
private nodeOpacity;
|
|
884
|
+
private targets;
|
|
885
|
+
params: {
|
|
886
|
+
defaultAlpha: number;
|
|
887
|
+
highlightAlpha: number;
|
|
888
|
+
dimmedAlpha: number;
|
|
889
|
+
};
|
|
890
|
+
private simulationBuffers;
|
|
891
|
+
private pickBuffer;
|
|
892
|
+
constructor(scene: THREE.Scene, renderer: THREE.WebGLRenderer);
|
|
893
|
+
create(nodes: GraphNode[], simulationBuffers: SimulationBuffers, pickBuffer: PickBuffer): void;
|
|
894
|
+
setPositionTexture(positionTexture: THREE.Texture): void;
|
|
895
|
+
pick(pixelX: number, pixelY: number, camera: THREE.Camera): number;
|
|
896
|
+
highlight(nodeIds: string[], step?: number): void;
|
|
897
|
+
clearHighlights(step?: number): void;
|
|
898
|
+
/**
|
|
899
|
+
* Update node opacity (called every frame)
|
|
900
|
+
*/
|
|
901
|
+
updateOpacity(): void;
|
|
902
|
+
resize(width: number, height: number): void;
|
|
903
|
+
dispose(): void;
|
|
904
|
+
private buildNodeMapping;
|
|
905
|
+
/**
|
|
906
|
+
* Create all node data in one pass
|
|
907
|
+
* Returns: colors, sizes, radii, nodeIds, pointIndices, alphaIndex
|
|
908
|
+
*/
|
|
909
|
+
private createNodeData;
|
|
910
|
+
private createGeometry;
|
|
911
|
+
private createRenderMaterial;
|
|
912
|
+
private createPickMaterial;
|
|
913
|
+
}
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region rendering/GraphScene.d.ts
|
|
916
|
+
/**
|
|
917
|
+
* GraphScene - Manages the 3D scene, camera, and renderers
|
|
918
|
+
* Responsibilities:
|
|
919
|
+
* - Scene setup and lifecycle
|
|
920
|
+
* - Node and link rendering
|
|
921
|
+
* - Camera control
|
|
922
|
+
* - Tooltip management
|
|
923
|
+
* - Mode application (visual changes)
|
|
924
|
+
*/
|
|
925
|
+
declare class GraphScene {
|
|
926
|
+
readonly scene: THREE.Scene;
|
|
927
|
+
readonly renderer: THREE.WebGLRenderer;
|
|
928
|
+
readonly camera: CameraController;
|
|
929
|
+
private nodeRenderer;
|
|
930
|
+
private clock;
|
|
931
|
+
private linkRenderer;
|
|
932
|
+
constructor(canvas: HTMLCanvasElement, cameraConfig?: CameraConfig);
|
|
933
|
+
/**
|
|
934
|
+
* Initialize scene with nodes and links
|
|
935
|
+
*/
|
|
936
|
+
create(nodes: GraphNode[], links: GraphLink[], simulationBuffers: SimulationBuffers, pickBuffer: PickBuffer, groupOrder?: string[]): void;
|
|
937
|
+
/**
|
|
938
|
+
* Apply visual mode (colors, sizes, camera position)
|
|
939
|
+
*/
|
|
940
|
+
applyMode(mode: string, options?: {
|
|
941
|
+
transitionDuration?: number;
|
|
942
|
+
cameraTransitionDuration?: number;
|
|
943
|
+
}): void;
|
|
944
|
+
/**
|
|
945
|
+
* Update position textures from simulation
|
|
946
|
+
*/
|
|
947
|
+
updatePositions(positionTexture: THREE.Texture): void;
|
|
948
|
+
/**
|
|
949
|
+
* Update time-based uniforms (called each frame with elapsed time)
|
|
950
|
+
*/
|
|
951
|
+
update(elapsedTime: number): void;
|
|
952
|
+
/**
|
|
953
|
+
* GPU picking at canvas coordinates
|
|
954
|
+
*/
|
|
955
|
+
pick(pixelX: number, pixelY: number): number;
|
|
956
|
+
/**
|
|
957
|
+
* Render the scene
|
|
958
|
+
*/
|
|
959
|
+
render(): void;
|
|
960
|
+
/**
|
|
961
|
+
* Handle window resize
|
|
962
|
+
*/
|
|
963
|
+
resize(width: number, height: number): void;
|
|
964
|
+
/**
|
|
965
|
+
* Cleanup all resources
|
|
966
|
+
*/
|
|
967
|
+
dispose(): void;
|
|
968
|
+
private applyDefaultMode;
|
|
969
|
+
getCamera(): CameraController;
|
|
970
|
+
getNodeRenderer(): NodesRenderer | null;
|
|
971
|
+
getLinkRenderer(): LinksRenderer | null;
|
|
972
|
+
}
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region ui/TooltipManager.d.ts
|
|
975
|
+
declare class TooltipManager {
|
|
976
|
+
private container;
|
|
977
|
+
private canvas;
|
|
978
|
+
private mainTooltip;
|
|
979
|
+
private previewTooltip;
|
|
980
|
+
private chainTooltips;
|
|
981
|
+
private config;
|
|
982
|
+
private closeButton;
|
|
983
|
+
private onCloseCallback?;
|
|
984
|
+
constructor(container: HTMLElement, canvas: HTMLCanvasElement, config?: TooltipConfig);
|
|
985
|
+
/**
|
|
986
|
+
* Show grab cursor when hovering over a node
|
|
987
|
+
*/
|
|
988
|
+
showGrabIcon(x: number, y: number, progress: number): void;
|
|
989
|
+
hideGrabIcon(): void;
|
|
990
|
+
/**
|
|
991
|
+
* Show preview tooltip (triggered by pop event when hover reaches 1.0)
|
|
992
|
+
*/
|
|
993
|
+
showPreview(node: GraphNode, x: number, y: number): void;
|
|
994
|
+
hidePreview(): void;
|
|
995
|
+
/**
|
|
996
|
+
* Show full tooltip (triggered by click)
|
|
997
|
+
*/
|
|
998
|
+
showFull(node: GraphNode, x: number, y: number): void;
|
|
999
|
+
hideFull(): void;
|
|
1000
|
+
/**
|
|
1001
|
+
* Set callback for when tooltip is closed
|
|
1002
|
+
*/
|
|
1003
|
+
setOnCloseCallback(callback: () => void): void;
|
|
1004
|
+
/**
|
|
1005
|
+
* Add close button to tooltip
|
|
1006
|
+
*/
|
|
1007
|
+
private addCloseButton;
|
|
1008
|
+
/**
|
|
1009
|
+
* Remove close button from tooltip
|
|
1010
|
+
*/
|
|
1011
|
+
private removeCloseButton;
|
|
1012
|
+
/**
|
|
1013
|
+
* Hide all tooltips
|
|
1014
|
+
*/
|
|
1015
|
+
hideAll(): void;
|
|
1016
|
+
/**
|
|
1017
|
+
* Generate preview content (subset of fields)
|
|
1018
|
+
*/
|
|
1019
|
+
private generatePreviewContent;
|
|
1020
|
+
/**
|
|
1021
|
+
* Generate full tooltip content (all fields)
|
|
1022
|
+
*/
|
|
1023
|
+
private generateFullContent;
|
|
1024
|
+
private escapeHtml;
|
|
1025
|
+
showMainTooltip(content: string, x: number, y: number): void;
|
|
1026
|
+
hideMainTooltip(): void;
|
|
1027
|
+
showChainTooltip(nodeId: string, content: string, x: number, y: number): void;
|
|
1028
|
+
hideChainTooltips(): void;
|
|
1029
|
+
updateMainTooltipPos(x: number, y: number): void;
|
|
1030
|
+
dispose(): void;
|
|
1031
|
+
}
|
|
1032
|
+
//#endregion
|
|
1033
|
+
//#region controls/InteractionManager.d.ts
|
|
1034
|
+
declare class InteractionManager {
|
|
1035
|
+
private graphScene?;
|
|
1036
|
+
private getConnectedNodeIds?;
|
|
1037
|
+
private pointerInput;
|
|
1038
|
+
private hoverHandler;
|
|
1039
|
+
private clickHandler;
|
|
1040
|
+
private dragHandler;
|
|
1041
|
+
tooltipManager: TooltipManager;
|
|
1042
|
+
private isDragging;
|
|
1043
|
+
isTooltipSticky: boolean;
|
|
1044
|
+
stickyNodeId: string | null;
|
|
1045
|
+
searchHighlightIds: string[];
|
|
1046
|
+
constructor(pickFunction: (x: number, y: number) => number, canvas: HTMLCanvasElement, viewport: {
|
|
1047
|
+
width: number;
|
|
1048
|
+
height: number;
|
|
1049
|
+
}, getNodeByIndex: (index: number) => GraphNode | null, cameraController?: CameraController, forceSimulation?: ForceSimulation, tooltipConfig?: TooltipConfig, graphScene?: GraphScene, getConnectedNodeIds?: (nodeId: string) => string[]);
|
|
1050
|
+
private wireEvents;
|
|
1051
|
+
private wireTooltipEvents;
|
|
1052
|
+
/**
|
|
1053
|
+
* Wire visual feedback events (opacity, highlighting)
|
|
1054
|
+
* Centralized control of visual responses to interactions
|
|
1055
|
+
*/
|
|
1056
|
+
private wireVisualFeedbackEvents;
|
|
1057
|
+
getPointerInput(): InputProcessor;
|
|
1058
|
+
getHoverHandler(): HoverHandler;
|
|
1059
|
+
getClickHandler(): ClickHandler;
|
|
1060
|
+
getDragHandler(): DragHandler;
|
|
1061
|
+
getTooltipManager(): TooltipManager;
|
|
1062
|
+
isTooltipStickyOpen(): boolean;
|
|
1063
|
+
/**
|
|
1064
|
+
* Update viewport dimensions on resize
|
|
1065
|
+
*/
|
|
1066
|
+
resize(width: number, height: number): void;
|
|
1067
|
+
cleanup(): void;
|
|
1068
|
+
dispose(): void;
|
|
1069
|
+
}
|
|
1070
|
+
//#endregion
|
|
1071
|
+
//#region core/Clock.d.ts
|
|
1072
|
+
/**
|
|
1073
|
+
* Clock - Unified timing for the force graph package
|
|
1074
|
+
*/
|
|
1075
|
+
declare class Clock {
|
|
1076
|
+
private previousTime;
|
|
1077
|
+
private elapsedTime;
|
|
1078
|
+
private deltaTime;
|
|
1079
|
+
private isRunning;
|
|
1080
|
+
private maxDeltaTime;
|
|
1081
|
+
constructor();
|
|
1082
|
+
/**
|
|
1083
|
+
* Start the clock
|
|
1084
|
+
*/
|
|
1085
|
+
start(): void;
|
|
1086
|
+
/**
|
|
1087
|
+
* Stop the clock
|
|
1088
|
+
*/
|
|
1089
|
+
stop(): void;
|
|
1090
|
+
/**
|
|
1091
|
+
* Update the clock - call once per frame
|
|
1092
|
+
* @returns delta time in seconds
|
|
1093
|
+
*/
|
|
1094
|
+
update(): number;
|
|
1095
|
+
/**
|
|
1096
|
+
* Get delta time in seconds
|
|
1097
|
+
*/
|
|
1098
|
+
getDeltaTime(): number;
|
|
1099
|
+
/**
|
|
1100
|
+
* Get total elapsed time in seconds
|
|
1101
|
+
*/
|
|
1102
|
+
getElapsedTime(): number;
|
|
1103
|
+
/**
|
|
1104
|
+
* Check if clock is running
|
|
1105
|
+
*/
|
|
1106
|
+
getIsRunning(): boolean;
|
|
1107
|
+
}
|
|
1108
|
+
//#endregion
|
|
1109
|
+
//#region core/GraphStore.d.ts
|
|
1110
|
+
/**
|
|
1111
|
+
* GraphStore - Central data management
|
|
1112
|
+
* Responsibilities:
|
|
1113
|
+
* - Store raw graph data (nodes, links)
|
|
1114
|
+
* - Node/Link CRUD operations
|
|
1115
|
+
* - ID mapping and lookups
|
|
1116
|
+
* - Data validation
|
|
1117
|
+
* - Change notifications
|
|
1118
|
+
*/
|
|
1119
|
+
declare class GraphStore {
|
|
1120
|
+
private nodes;
|
|
1121
|
+
private links;
|
|
1122
|
+
private nodeArray;
|
|
1123
|
+
private linkArray;
|
|
1124
|
+
private nodeIdToIndex;
|
|
1125
|
+
private linkIdToIndex;
|
|
1126
|
+
private nodeToLinks;
|
|
1127
|
+
constructor();
|
|
1128
|
+
/**
|
|
1129
|
+
* Set graph data (replaces all)
|
|
1130
|
+
*/
|
|
1131
|
+
setData(data: GraphData): void;
|
|
1132
|
+
/**
|
|
1133
|
+
* Add nodes
|
|
1134
|
+
*/
|
|
1135
|
+
addNodes(nodes: GraphNode[]): void;
|
|
1136
|
+
/**
|
|
1137
|
+
* Remove nodes (and connected links)
|
|
1138
|
+
*/
|
|
1139
|
+
removeNodes(nodeIds: string[]): void;
|
|
1140
|
+
/**
|
|
1141
|
+
* Add links
|
|
1142
|
+
*/
|
|
1143
|
+
addLinks(links: GraphLink[]): void;
|
|
1144
|
+
/**
|
|
1145
|
+
* Remove links
|
|
1146
|
+
*/
|
|
1147
|
+
removeLinks(linkIds: string[]): void;
|
|
1148
|
+
/**
|
|
1149
|
+
* Get all nodes as array
|
|
1150
|
+
*/
|
|
1151
|
+
getNodes(): GraphNode[];
|
|
1152
|
+
/**
|
|
1153
|
+
* Get all links as array
|
|
1154
|
+
*/
|
|
1155
|
+
getLinks(): GraphLink[];
|
|
1156
|
+
/**
|
|
1157
|
+
* Get connected node IDs for a given node
|
|
1158
|
+
*/
|
|
1159
|
+
getConnectedNodeIds(nodeId: string): string[];
|
|
1160
|
+
/**
|
|
1161
|
+
* Get node by ID
|
|
1162
|
+
*/
|
|
1163
|
+
getNodeById(id: string): GraphNode | null;
|
|
1164
|
+
/**
|
|
1165
|
+
* Get node by index
|
|
1166
|
+
*/
|
|
1167
|
+
getNodeByIndex(index: number): GraphNode | null;
|
|
1168
|
+
/**
|
|
1169
|
+
* Get node index
|
|
1170
|
+
*/
|
|
1171
|
+
getNodeIndex(id: string): number;
|
|
1172
|
+
/**
|
|
1173
|
+
* Get link by ID
|
|
1174
|
+
*/
|
|
1175
|
+
getLinkById(id: string): GraphLink | null;
|
|
1176
|
+
/**
|
|
1177
|
+
* Get links connected to node
|
|
1178
|
+
*/
|
|
1179
|
+
getNodeLinks(nodeId: string): GraphLink[];
|
|
1180
|
+
/**
|
|
1181
|
+
* Get node count
|
|
1182
|
+
*/
|
|
1183
|
+
getNodeCount(): number;
|
|
1184
|
+
/**
|
|
1185
|
+
* Get link count
|
|
1186
|
+
*/
|
|
1187
|
+
getLinkCount(): number;
|
|
1188
|
+
/**
|
|
1189
|
+
* Clear all data
|
|
1190
|
+
*/
|
|
1191
|
+
clear(): void;
|
|
1192
|
+
private getLinkId;
|
|
1193
|
+
private addLinkConnectivity;
|
|
1194
|
+
private removeLinkConnectivity;
|
|
1195
|
+
private rebuildNodeArrays;
|
|
1196
|
+
private rebuildLinkArrays;
|
|
1197
|
+
}
|
|
1198
|
+
//#endregion
|
|
1199
|
+
//#region core/Engine.d.ts
|
|
1200
|
+
interface EngineOptions {
|
|
1201
|
+
width?: number;
|
|
1202
|
+
height?: number;
|
|
1203
|
+
backgroundColor?: string;
|
|
1204
|
+
tooltipConfig?: TooltipConfig;
|
|
1205
|
+
groupOrder?: string[];
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Engine - Main orchestrator
|
|
1209
|
+
* Responsibilities:
|
|
1210
|
+
* - Owns all shared buffers (StaticAssets, SimulationBuffers, PickBuffer)
|
|
1211
|
+
* - Coordinates GraphStore, GraphScene, ForceSimulation
|
|
1212
|
+
* - Manages render loop
|
|
1213
|
+
* - Handles user interaction
|
|
1214
|
+
*/
|
|
1215
|
+
declare class Engine {
|
|
1216
|
+
readonly canvas: HTMLCanvasElement;
|
|
1217
|
+
readonly graphStore: GraphStore;
|
|
1218
|
+
private graphScene;
|
|
1219
|
+
private forceSimulation;
|
|
1220
|
+
interactionManager: InteractionManager;
|
|
1221
|
+
private clock;
|
|
1222
|
+
private simulationBuffers;
|
|
1223
|
+
private pickBuffer;
|
|
1224
|
+
private animationFrameId;
|
|
1225
|
+
private isRunning;
|
|
1226
|
+
private boundResizeHandler;
|
|
1227
|
+
private groupOrder?;
|
|
1228
|
+
constructor(canvas: HTMLCanvasElement, options?: EngineOptions);
|
|
1229
|
+
/**
|
|
1230
|
+
* Handle window resize event
|
|
1231
|
+
*/
|
|
1232
|
+
private handleWindowResize;
|
|
1233
|
+
/**
|
|
1234
|
+
* Set graph data
|
|
1235
|
+
*/
|
|
1236
|
+
setData(data: GraphData): void;
|
|
1237
|
+
/**
|
|
1238
|
+
* Update node states based on a callback
|
|
1239
|
+
* This allows changing visibility/behavior without resetting the simulation
|
|
1240
|
+
*/
|
|
1241
|
+
updateNodeStates(callback: (node: GraphNode) => NodeState): void;
|
|
1242
|
+
/**
|
|
1243
|
+
* Reheat the simulation
|
|
1244
|
+
*/
|
|
1245
|
+
reheat(alpha?: number): void;
|
|
1246
|
+
/**
|
|
1247
|
+
* Set alpha decay
|
|
1248
|
+
*/
|
|
1249
|
+
setAlphaDecay(decay: number): void;
|
|
1250
|
+
/**
|
|
1251
|
+
* Get current alpha
|
|
1252
|
+
*/
|
|
1253
|
+
getAlpha(): number;
|
|
1254
|
+
/**Apply a preset to the graph
|
|
1255
|
+
*/
|
|
1256
|
+
applyPreset(preset: GraphPreset): void;
|
|
1257
|
+
/**
|
|
1258
|
+
*
|
|
1259
|
+
* Start render loop
|
|
1260
|
+
*/
|
|
1261
|
+
start(): void;
|
|
1262
|
+
/**
|
|
1263
|
+
* Stop render loop
|
|
1264
|
+
*/
|
|
1265
|
+
stop(): void;
|
|
1266
|
+
/**
|
|
1267
|
+
* Render loop
|
|
1268
|
+
*/
|
|
1269
|
+
private animate;
|
|
1270
|
+
/**
|
|
1271
|
+
* GPU pick node at canvas coordinates
|
|
1272
|
+
*/
|
|
1273
|
+
pickNode(x: number, y: number): string | null;
|
|
1274
|
+
/**
|
|
1275
|
+
* Get node by ID
|
|
1276
|
+
*/
|
|
1277
|
+
getNodeById(id: string): GraphNode | null;
|
|
1278
|
+
/**
|
|
1279
|
+
* Highlight nodes
|
|
1280
|
+
*/
|
|
1281
|
+
highlightNodes(nodeIds: string[]): void;
|
|
1282
|
+
/**
|
|
1283
|
+
* Clear highlights
|
|
1284
|
+
*/
|
|
1285
|
+
clearHighlights(): void;
|
|
1286
|
+
/**
|
|
1287
|
+
* Get node position in 3D space
|
|
1288
|
+
*/
|
|
1289
|
+
getNodePosition(nodeId: string): THREE.Vector3 | null;
|
|
1290
|
+
/**
|
|
1291
|
+
* Get node screen position from world position
|
|
1292
|
+
*/
|
|
1293
|
+
getNodeScreenPosition(nodeId: string): {
|
|
1294
|
+
x: number;
|
|
1295
|
+
y: number;
|
|
1296
|
+
} | null;
|
|
1297
|
+
/**
|
|
1298
|
+
* Update sticky tooltip position to follow node during camera movement
|
|
1299
|
+
*/
|
|
1300
|
+
private updateStickyTooltipPosition;
|
|
1301
|
+
/**
|
|
1302
|
+
* Programmatically select a node (highlight + tooltip)
|
|
1303
|
+
*/
|
|
1304
|
+
selectNode(nodeId: string): void;
|
|
1305
|
+
/**
|
|
1306
|
+
* Resize canvas and all dependent components
|
|
1307
|
+
*/
|
|
1308
|
+
resize(width: number, height: number): void;
|
|
1309
|
+
/**
|
|
1310
|
+
* Get the unified clock for timing information
|
|
1311
|
+
*/
|
|
1312
|
+
getClock(): Clock;
|
|
1313
|
+
/**
|
|
1314
|
+
* Get all nodes
|
|
1315
|
+
*/
|
|
1316
|
+
get nodes(): GraphNode[];
|
|
1317
|
+
/**
|
|
1318
|
+
* Get all links
|
|
1319
|
+
*/
|
|
1320
|
+
get links(): GraphLink[];
|
|
1321
|
+
/**
|
|
1322
|
+
* Get force simulation for external configuration (GUI binding)
|
|
1323
|
+
*/
|
|
1324
|
+
get simulation(): ForceSimulation;
|
|
1325
|
+
/**
|
|
1326
|
+
* Get camera controller for external configuration
|
|
1327
|
+
*/
|
|
1328
|
+
get camera(): CameraController;
|
|
1329
|
+
/**
|
|
1330
|
+
* Set camera mode (Orbit, Map, Fly)
|
|
1331
|
+
*/
|
|
1332
|
+
setCameraMode(mode: CameraMode): void;
|
|
1333
|
+
/**
|
|
1334
|
+
* Animate camera to look at a specific target from a specific position
|
|
1335
|
+
*/
|
|
1336
|
+
setCameraLookAt(position: {
|
|
1337
|
+
x: number;
|
|
1338
|
+
y: number;
|
|
1339
|
+
z: number;
|
|
1340
|
+
}, target: {
|
|
1341
|
+
x: number;
|
|
1342
|
+
y: number;
|
|
1343
|
+
z: number;
|
|
1344
|
+
}, transitionDuration?: number): Promise<void>;
|
|
1345
|
+
/**
|
|
1346
|
+
* Focus camera on a specific target node
|
|
1347
|
+
*/
|
|
1348
|
+
setCameraFocus(target: {
|
|
1349
|
+
x: number;
|
|
1350
|
+
y: number;
|
|
1351
|
+
z: number;
|
|
1352
|
+
}, distance: number, transitionDuration?: number): Promise<void>;
|
|
1353
|
+
/**
|
|
1354
|
+
* Cleanup
|
|
1355
|
+
*/
|
|
1356
|
+
dispose(): void;
|
|
1357
|
+
private calculateTextureSize;
|
|
1358
|
+
}
|
|
1359
|
+
//#endregion
|
|
1360
|
+
//#region core/StyleRegistry.d.ts
|
|
1361
|
+
/** Color input - can be THREE.Color, hex number, or CSS color string */
|
|
1362
|
+
type ColorInput = THREE.Color | number | string;
|
|
1363
|
+
/**
|
|
1364
|
+
* Visual properties for a node category (input)
|
|
1365
|
+
*/
|
|
1366
|
+
interface NodeStyle {
|
|
1367
|
+
color: ColorInput;
|
|
1368
|
+
size: number;
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Visual properties for a link category (input)
|
|
1372
|
+
*/
|
|
1373
|
+
interface LinkStyle {
|
|
1374
|
+
color: ColorInput;
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Resolved node style with THREE.Color
|
|
1378
|
+
*/
|
|
1379
|
+
interface ResolvedNodeStyle {
|
|
1380
|
+
color: THREE.Color;
|
|
1381
|
+
size: number;
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Resolved link style with THREE.Color
|
|
1385
|
+
*/
|
|
1386
|
+
interface ResolvedLinkStyle {
|
|
1387
|
+
color: THREE.Color;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* StyleRegistry - Manages visual styles for node and link categories
|
|
1391
|
+
*
|
|
1392
|
+
* Usage:
|
|
1393
|
+
* styleRegistry.setNodeStyle('person', { color: 0xff0000, size: 20 })
|
|
1394
|
+
* styleRegistry.setLinkStyle('friendship', { color: '#00ff00', width: 2 })
|
|
1395
|
+
*
|
|
1396
|
+
* const style = styleRegistry.getNodeStyle('person')
|
|
1397
|
+
*/
|
|
1398
|
+
declare class StyleRegistry {
|
|
1399
|
+
private nodeStyles;
|
|
1400
|
+
private linkStyles;
|
|
1401
|
+
private defaultNodeStyle;
|
|
1402
|
+
private defaultLinkStyle;
|
|
1403
|
+
/**
|
|
1404
|
+
* Convert color input to THREE.Color
|
|
1405
|
+
*/
|
|
1406
|
+
private toColor;
|
|
1407
|
+
/**
|
|
1408
|
+
* Set the default style for nodes without a category
|
|
1409
|
+
*/
|
|
1410
|
+
setDefaultNodeStyle(style: Partial<NodeStyle>): void;
|
|
1411
|
+
/**
|
|
1412
|
+
* Set the default style for links without a category
|
|
1413
|
+
*/
|
|
1414
|
+
setDefaultLinkStyle(style: Partial<LinkStyle>): void;
|
|
1415
|
+
/**
|
|
1416
|
+
* Register a style for a node category
|
|
1417
|
+
*/
|
|
1418
|
+
setNodeStyle(category: string, style: NodeStyle): void;
|
|
1419
|
+
/**
|
|
1420
|
+
* Register multiple node styles at once
|
|
1421
|
+
*/
|
|
1422
|
+
setNodeStyles(styles: Record<string, NodeStyle>): void;
|
|
1423
|
+
/**
|
|
1424
|
+
* Register a style for a link category
|
|
1425
|
+
*/
|
|
1426
|
+
setLinkStyle(category: string, style: LinkStyle): void;
|
|
1427
|
+
/**
|
|
1428
|
+
* Register multiple link styles at once
|
|
1429
|
+
*/
|
|
1430
|
+
setLinkStyles(styles: Record<string, LinkStyle>): void;
|
|
1431
|
+
/**
|
|
1432
|
+
* Get the resolved style for a node category
|
|
1433
|
+
*/
|
|
1434
|
+
getNodeStyle(category?: string): ResolvedNodeStyle;
|
|
1435
|
+
/**
|
|
1436
|
+
* Get the resolved style for a link category
|
|
1437
|
+
*/
|
|
1438
|
+
getLinkStyle(category?: string): ResolvedLinkStyle;
|
|
1439
|
+
/**
|
|
1440
|
+
* Check if a node category exists
|
|
1441
|
+
*/
|
|
1442
|
+
hasNodeStyle(category: string): boolean;
|
|
1443
|
+
/**
|
|
1444
|
+
* Check if a link category exists
|
|
1445
|
+
*/
|
|
1446
|
+
hasLinkStyle(category: string): boolean;
|
|
1447
|
+
/**
|
|
1448
|
+
* Remove a node style
|
|
1449
|
+
*/
|
|
1450
|
+
removeNodeStyle(category: string): void;
|
|
1451
|
+
/**
|
|
1452
|
+
* Remove a link style
|
|
1453
|
+
*/
|
|
1454
|
+
removeLinkStyle(category: string): void;
|
|
1455
|
+
/**
|
|
1456
|
+
* Clear all styles
|
|
1457
|
+
*/
|
|
1458
|
+
clear(): void;
|
|
1459
|
+
/**
|
|
1460
|
+
* Get all registered node categories
|
|
1461
|
+
*/
|
|
1462
|
+
getNodeCategories(): string[];
|
|
1463
|
+
/**
|
|
1464
|
+
* Get all registered link categories
|
|
1465
|
+
*/
|
|
1466
|
+
getLinkCategories(): string[];
|
|
1467
|
+
}
|
|
1468
|
+
declare const styleRegistry: StyleRegistry;
|
|
1469
|
+
//#endregion
|
|
1470
|
+
//#region types/iEngineConfig.d.ts
|
|
1471
|
+
interface EngineConfig {
|
|
1472
|
+
container: HTMLElement;
|
|
1473
|
+
width?: number;
|
|
1474
|
+
height?: number;
|
|
1475
|
+
antialias?: boolean;
|
|
1476
|
+
alpha?: boolean;
|
|
1477
|
+
}
|
|
1478
|
+
//#endregion
|
|
1468
1479
|
export { type Attractor, type CameraConfig, CameraMode, Clock, Engine, type EngineConfig, type ForceConfig, ForceSimulation, type GraphData, type GraphLink, type GraphNode, type GraphPreset, GraphScene, GraphStore, type LinkStyle, NodeState, type NodeStyle, PickBuffer, type ResolvedAttractor, type ResolvedLinkStyle, type ResolvedNodeStyle, SimulationBuffers, StaticAssets, type Vec3, staticAssets, styleRegistry };
|