@fusefactory/fuse-three-forcegraph 1.0.3 → 1.0.5

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