@cosmos.gl/graph 2.6.2 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-CSMQs8iI.js +19876 -0
- package/dist/index-CSMQs8iI.js.map +1 -0
- package/dist/index.js +14 -14658
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1057 -473
- package/dist/index.min.js.map +1 -1
- package/dist/{config.d.ts → src/config.d.ts} +2 -18
- package/dist/{graph → src/graph}/utils/error-message.d.ts +1 -1
- package/dist/src/helper.d.ts +61 -0
- package/dist/{index.d.ts → src/index.d.ts} +28 -5
- package/dist/{modules → src/modules}/Clusters/index.d.ts +13 -6
- package/dist/{modules → src/modules}/ForceCenter/index.d.ts +11 -3
- package/dist/src/modules/ForceGravity/index.d.ts +13 -0
- package/dist/{modules → src/modules}/ForceLink/index.d.ts +10 -4
- package/dist/src/modules/ForceManyBody/index.d.ts +26 -0
- package/dist/src/modules/ForceMouse/index.d.ts +13 -0
- package/dist/{modules → src/modules}/Lines/index.d.ts +16 -5
- package/dist/{modules → src/modules}/Points/index.d.ts +32 -16
- package/dist/src/modules/Shared/buffer.d.ts +1 -0
- package/dist/src/modules/Shared/texture-utils.d.ts +8 -0
- package/dist/src/modules/Shared/uniform-utils.d.ts +11 -0
- package/dist/src/modules/Store/index.d.ts +169 -0
- package/dist/{modules → src/modules}/core-module.d.ts +3 -3
- package/dist/{variables.d.ts → src/variables.d.ts} +0 -2
- package/dist/vite.config.d.ts +2 -0
- package/dist/webgl-device-QoBMYpnS.js +3933 -0
- package/dist/webgl-device-QoBMYpnS.js.map +1 -0
- package/package.json +1 -1
- package/dist/helper.d.ts +0 -24
- package/dist/modules/ForceGravity/index.d.ts +0 -6
- package/dist/modules/ForceManyBody/index.d.ts +0 -16
- package/dist/modules/ForceManyBody/quadtree-frag-shader.d.ts +0 -1
- package/dist/modules/ForceManyBodyQuadtree/index.d.ts +0 -15
- package/dist/modules/ForceManyBodyQuadtree/quadtree-frag-shader.d.ts +0 -1
- package/dist/modules/ForceMouse/index.d.ts +0 -6
- package/dist/modules/Shared/buffer.d.ts +0 -8
- package/dist/modules/Store/index.d.ts +0 -75
- /package/dist/{modules → src/modules}/Drag/index.d.ts +0 -0
- /package/dist/{modules → src/modules}/FPSMonitor/css.d.ts +0 -0
- /package/dist/{modules → src/modules}/FPSMonitor/index.d.ts +0 -0
- /package/dist/{modules → src/modules}/ForceLink/force-spring.d.ts +0 -0
- /package/dist/{modules → src/modules}/GraphData/index.d.ts +0 -0
- /package/dist/{modules → src/modules}/Lines/geometry.d.ts +0 -0
- /package/dist/{modules → src/modules}/Points/atlas-utils.d.ts +0 -0
- /package/dist/{modules → src/modules}/Zoom/index.d.ts +0 -0
|
@@ -213,13 +213,6 @@ export interface GraphConfigInterface {
|
|
|
213
213
|
* Default value: `0.25`
|
|
214
214
|
*/
|
|
215
215
|
linkVisibilityMinTransparency?: number;
|
|
216
|
-
/**
|
|
217
|
-
* Use the classic quadtree algorithm for the Many-Body force.
|
|
218
|
-
* This property will be applied only on component initialization and it
|
|
219
|
-
* can't be changed using the `setConfig` method.
|
|
220
|
-
* Default value: `false`
|
|
221
|
-
*/
|
|
222
|
-
useClassicQuadtree?: boolean;
|
|
223
216
|
/**
|
|
224
217
|
* Decay coefficient. Use smaller values if you want the simulation to "cool down" slower.
|
|
225
218
|
* Default value: `5000`
|
|
@@ -242,16 +235,9 @@ export interface GraphConfigInterface {
|
|
|
242
235
|
simulationRepulsion?: number;
|
|
243
236
|
/**
|
|
244
237
|
* Decreases / increases the detalization of the Many-Body force calculations.
|
|
245
|
-
* When `useClassicQuadtree` is set to `true`, this property corresponds to the Barnes–Hut approximation criterion.
|
|
246
238
|
* Default value: `1.15`
|
|
247
239
|
*/
|
|
248
240
|
simulationRepulsionTheta?: number;
|
|
249
|
-
/**
|
|
250
|
-
* Barnes–Hut approximation depth.
|
|
251
|
-
* Can only be used when `useClassicQuadtree` is set `true`.
|
|
252
|
-
* Default value: `12`
|
|
253
|
-
*/
|
|
254
|
-
simulationRepulsionQuadtreeLevels?: number;
|
|
255
241
|
/**
|
|
256
242
|
* Link spring force coefficient.
|
|
257
243
|
* Default value: `1`
|
|
@@ -447,8 +433,8 @@ export interface GraphConfigInterface {
|
|
|
447
433
|
*/
|
|
448
434
|
showFPSMonitor?: boolean;
|
|
449
435
|
/**
|
|
450
|
-
*
|
|
451
|
-
* Default value: `2`
|
|
436
|
+
* Pixel ratio for the canvas. Higher values use more GPU memory but provide better quality on high-DPI displays.
|
|
437
|
+
* Default value: `window.devicePixelRatio || 2`
|
|
452
438
|
*/
|
|
453
439
|
pixelRatio?: number;
|
|
454
440
|
/**
|
|
@@ -588,13 +574,11 @@ export declare class GraphConfig implements GraphConfigInterface {
|
|
|
588
574
|
scaleLinksOnZoom: boolean;
|
|
589
575
|
linkVisibilityDistanceRange: number[];
|
|
590
576
|
linkVisibilityMinTransparency: number;
|
|
591
|
-
useClassicQuadtree: boolean;
|
|
592
577
|
simulationDecay: number;
|
|
593
578
|
simulationGravity: number;
|
|
594
579
|
simulationCenter: number;
|
|
595
580
|
simulationRepulsion: number;
|
|
596
581
|
simulationRepulsionTheta: number;
|
|
597
|
-
simulationRepulsionQuadtreeLevels: number;
|
|
598
582
|
simulationLinkSpring: number;
|
|
599
583
|
simulationLinkDistance: number;
|
|
600
584
|
simulationLinkDistRandomVariationRange: number[];
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @param container The HTML element to append the error message to
|
|
4
4
|
* @returns The created error div element
|
|
5
5
|
*/
|
|
6
|
-
export declare function createWebGLErrorMessage(container: HTMLElement): HTMLDivElement;
|
|
6
|
+
export declare function createWebGLErrorMessage(container: HTMLElement, error: string): HTMLDivElement;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Device, Framebuffer } from '@luma.gl/core';
|
|
2
|
+
import { default as DOMPurify } from 'dompurify';
|
|
3
|
+
export declare const isFunction: <T>(a: T) => boolean;
|
|
4
|
+
export declare const isArray: <T>(a: unknown | T[]) => a is T[];
|
|
5
|
+
export declare const isObject: <T>(a: T) => boolean;
|
|
6
|
+
export declare const isAClassInstance: <T>(a: T) => boolean;
|
|
7
|
+
export declare const isPlainObject: <T>(a: T) => boolean;
|
|
8
|
+
export declare function getRgbaColor(value: string | [number, number, number, number]): [number, number, number, number];
|
|
9
|
+
export declare function rgbToBrightness(r: number, g: number, b: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: Migrate from deprecated `readPixelsToArrayWebGL` to CommandEncoder API
|
|
12
|
+
*
|
|
13
|
+
* `readPixelsToArrayWebGL` is deprecated in luma.gl v9. The recommended modern approach is:
|
|
14
|
+
*
|
|
15
|
+
* 1. Create a buffer to hold the pixel data:
|
|
16
|
+
* const buffer = device.createBuffer({
|
|
17
|
+
* byteLength: width * height * 4 * 4, // RGBA, 4 bytes per float
|
|
18
|
+
* usage: Buffer.COPY_DST | Buffer.MAP_READ
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* 2. Copy texture/framebuffer to buffer using command encoder:
|
|
22
|
+
* const commandEncoder = device.createCommandEncoder();
|
|
23
|
+
* commandEncoder.copyTextureToBuffer({
|
|
24
|
+
* sourceTexture: fbo, // Can be Texture or Framebuffer
|
|
25
|
+
* width: sourceWidth ?? fbo.width,
|
|
26
|
+
* height: sourceHeight ?? fbo.height,
|
|
27
|
+
* origin: [sourceX, sourceY],
|
|
28
|
+
* destinationBuffer: buffer
|
|
29
|
+
* });
|
|
30
|
+
* const commandBuffer = commandEncoder.finish();
|
|
31
|
+
* device.submit(commandBuffer);
|
|
32
|
+
*
|
|
33
|
+
* 3. Read the data from the buffer (async):
|
|
34
|
+
* const pixelData = await buffer.readAsync(); // Returns ArrayBuffer
|
|
35
|
+
* return new Float32Array(pixelData);
|
|
36
|
+
*
|
|
37
|
+
* Note: The modern approach is asynchronous, so this function signature would need to change
|
|
38
|
+
* to return Promise<Float32Array> or we'd need to handle async at all call sites (18 locations).
|
|
39
|
+
*
|
|
40
|
+
* Migration impact:
|
|
41
|
+
* - This function is used in 18 places across the codebase
|
|
42
|
+
* - All call sites would need to be updated to handle async
|
|
43
|
+
* - Consider batching the migration to avoid inconsistencies
|
|
44
|
+
*
|
|
45
|
+
* Current status: Deprecated but still functional. Keeping for now until full migration can be planned.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readPixels(device: Device, fbo: Framebuffer, sourceX?: number, sourceY?: number, sourceWidth?: number, sourceHeight?: number): Float32Array;
|
|
48
|
+
export declare function clamp(num: number, min: number, max: number): number;
|
|
49
|
+
export declare function isNumber(value: number | undefined | null | typeof NaN): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Sanitizes HTML content to prevent XSS attacks using DOMPurify
|
|
52
|
+
*
|
|
53
|
+
* This function is used internally to sanitize HTML content before setting innerHTML,
|
|
54
|
+
* such as in attribution text. It uses a safe default configuration that allows
|
|
55
|
+
* only common safe HTML elements and attributes.
|
|
56
|
+
*
|
|
57
|
+
* @param html The HTML string to sanitize
|
|
58
|
+
* @param options Optional DOMPurify configuration options to override defaults
|
|
59
|
+
* @returns Sanitized HTML string safe for innerHTML usage
|
|
60
|
+
*/
|
|
61
|
+
export declare function sanitizeHtml(html: string, options?: DOMPurify.Config): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Device } from '@luma.gl/core';
|
|
1
2
|
import { GraphConfig, GraphConfigInterface } from './config';
|
|
2
3
|
import { GraphData } from './modules/GraphData';
|
|
3
4
|
export declare class Graph {
|
|
@@ -6,7 +7,8 @@ export declare class Graph {
|
|
|
6
7
|
private canvas;
|
|
7
8
|
private attributionDivElement;
|
|
8
9
|
private canvasD3Selection;
|
|
9
|
-
private
|
|
10
|
+
private device;
|
|
11
|
+
private deviceInitPromise;
|
|
10
12
|
private requestAnimationFrameId;
|
|
11
13
|
private isRightClickMouse;
|
|
12
14
|
private store;
|
|
@@ -52,7 +54,7 @@ export declare class Graph {
|
|
|
52
54
|
private isForceCenterUpdateNeeded;
|
|
53
55
|
private isPointImageSizesUpdateNeeded;
|
|
54
56
|
private _isDestroyed;
|
|
55
|
-
constructor(div: HTMLDivElement, config?: GraphConfigInterface);
|
|
57
|
+
constructor(div: HTMLDivElement, config?: GraphConfigInterface, devicePromise?: Promise<Device>);
|
|
56
58
|
/**
|
|
57
59
|
* Returns the current simulation progress
|
|
58
60
|
*/
|
|
@@ -511,10 +513,31 @@ export declare class Graph {
|
|
|
511
513
|
*/
|
|
512
514
|
pair(pointPositions: number[]): [number, number][];
|
|
513
515
|
/**
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* @param
|
|
516
|
+
* Ensures device is initialized before executing a method.
|
|
517
|
+
* If device is not ready, queues the method to run after initialization.
|
|
518
|
+
* @param callback - Function to execute once device is ready
|
|
519
|
+
* @returns true if device was not ready and operation was queued, false if device is ready
|
|
520
|
+
*/
|
|
521
|
+
private ensureDevice;
|
|
522
|
+
/**
|
|
523
|
+
* Validates that a device has the required HTMLCanvasElement canvas context.
|
|
524
|
+
* Cosmos requires an HTMLCanvasElement canvas context and does not support
|
|
525
|
+
* OffscreenCanvas or compute-only devices.
|
|
526
|
+
* @param device - The device to validate
|
|
527
|
+
* @returns The validated canvas context (guaranteed to be non-null and HTMLCanvasElement type)
|
|
528
|
+
* @throws Error if the device does not meet Cosmos requirements
|
|
517
529
|
*/
|
|
530
|
+
private validateDevice;
|
|
531
|
+
/**
|
|
532
|
+
* Internal device creation method
|
|
533
|
+
* Graph class decides what device to create with sensible defaults
|
|
534
|
+
*/
|
|
535
|
+
private createDevice;
|
|
536
|
+
/**
|
|
537
|
+
* Updates and recreates the graph visualization based on pending changes.
|
|
538
|
+
*
|
|
539
|
+
* @param simulationAlpha - Optional alpha value to set. If not provided, keeps current alpha.
|
|
540
|
+
*/
|
|
518
541
|
private update;
|
|
519
542
|
/**
|
|
520
543
|
* Runs one step of the simulation (forces, position updates, alpha decay).
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Framebuffer } from '@luma.gl/core';
|
|
2
2
|
import { CoreModule } from '../core-module';
|
|
3
3
|
export declare class Clusters extends CoreModule {
|
|
4
|
-
centermassFbo:
|
|
4
|
+
centermassFbo: Framebuffer | undefined;
|
|
5
5
|
clusterCount: number | undefined;
|
|
6
|
-
private clusterFbo;
|
|
7
|
-
private clusterPositionsFbo;
|
|
8
|
-
private clusterForceCoefficientFbo;
|
|
9
|
-
private clearCentermassCommand;
|
|
10
6
|
private calculateCentermassCommand;
|
|
11
7
|
private applyForcesCommand;
|
|
12
8
|
private clusterTexture;
|
|
@@ -15,8 +11,19 @@ export declare class Clusters extends CoreModule {
|
|
|
15
11
|
private centermassTexture;
|
|
16
12
|
private pointIndices;
|
|
17
13
|
private clustersTextureSize;
|
|
14
|
+
private applyForcesVertexCoordBuffer;
|
|
15
|
+
private previousPointsTextureSize;
|
|
16
|
+
private previousClustersTextureSize;
|
|
17
|
+
private previousClusterCount;
|
|
18
|
+
private calculateCentermassUniformStore;
|
|
19
|
+
private applyForcesUniformStore;
|
|
18
20
|
create(): void;
|
|
19
21
|
initPrograms(): void;
|
|
20
22
|
calculateCentermass(): void;
|
|
21
23
|
run(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Destruction order matters
|
|
26
|
+
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
27
|
+
*/
|
|
28
|
+
destroy(): void;
|
|
22
29
|
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { CoreModule } from '../core-module';
|
|
2
2
|
export declare class ForceCenter extends CoreModule {
|
|
3
|
+
private centermassTexture;
|
|
3
4
|
private centermassFbo;
|
|
4
|
-
private
|
|
5
|
+
private pointIndices;
|
|
5
6
|
private calculateCentermassCommand;
|
|
6
7
|
private runCommand;
|
|
7
|
-
private
|
|
8
|
-
private
|
|
8
|
+
private forceVertexCoordBuffer;
|
|
9
|
+
private calculateUniformStore;
|
|
10
|
+
private forceUniformStore;
|
|
11
|
+
private previousPointsTextureSize;
|
|
9
12
|
create(): void;
|
|
10
13
|
initPrograms(): void;
|
|
11
14
|
run(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Destruction order matters
|
|
17
|
+
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
18
|
+
*/
|
|
19
|
+
destroy(): void;
|
|
12
20
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CoreModule } from '../core-module';
|
|
2
|
+
export declare class ForceGravity extends CoreModule {
|
|
3
|
+
private runCommand;
|
|
4
|
+
private vertexCoordBuffer;
|
|
5
|
+
private uniformStore;
|
|
6
|
+
initPrograms(): void;
|
|
7
|
+
run(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Destruction order matters
|
|
10
|
+
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
11
|
+
*/
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
@@ -4,14 +4,15 @@ export declare enum LinkDirection {
|
|
|
4
4
|
INCOMING = "incoming"
|
|
5
5
|
}
|
|
6
6
|
export declare class ForceLink extends CoreModule {
|
|
7
|
-
private linkFirstIndicesAndAmountFbo;
|
|
8
|
-
private indicesFbo;
|
|
9
|
-
private biasAndStrengthFbo;
|
|
10
|
-
private randomDistanceFbo;
|
|
11
7
|
private linkFirstIndicesAndAmount;
|
|
12
8
|
private indices;
|
|
13
9
|
private maxPointDegree;
|
|
10
|
+
private previousMaxPointDegree;
|
|
11
|
+
private previousPointsTextureSize;
|
|
12
|
+
private previousLinksTextureSize;
|
|
14
13
|
private runCommand;
|
|
14
|
+
private vertexCoordBuffer;
|
|
15
|
+
private uniformStore;
|
|
15
16
|
private linkFirstIndicesAndAmountTexture;
|
|
16
17
|
private indicesTexture;
|
|
17
18
|
private biasAndStrengthTexture;
|
|
@@ -19,4 +20,9 @@ export declare class ForceLink extends CoreModule {
|
|
|
19
20
|
create(direction: LinkDirection): void;
|
|
20
21
|
initPrograms(): void;
|
|
21
22
|
run(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Destruction order matters
|
|
25
|
+
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
26
|
+
*/
|
|
27
|
+
destroy(): void;
|
|
22
28
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CoreModule } from '../core-module';
|
|
2
|
+
export declare class ForceManyBody extends CoreModule {
|
|
3
|
+
private randomValuesTexture;
|
|
4
|
+
private pointIndices;
|
|
5
|
+
private levels;
|
|
6
|
+
private levelTargets;
|
|
7
|
+
private calculateLevelsCommand;
|
|
8
|
+
private forceCommand;
|
|
9
|
+
private forceFromItsOwnCentermassCommand;
|
|
10
|
+
private forceVertexCoordBuffer;
|
|
11
|
+
private calculateLevelsUniformStore;
|
|
12
|
+
private forceUniformStore;
|
|
13
|
+
private forceCenterUniformStore;
|
|
14
|
+
private previousPointsTextureSize;
|
|
15
|
+
private previousSpaceSize;
|
|
16
|
+
create(): void;
|
|
17
|
+
initPrograms(): void;
|
|
18
|
+
run(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Destruction order matters
|
|
21
|
+
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
22
|
+
*/
|
|
23
|
+
destroy(): void;
|
|
24
|
+
private drawLevels;
|
|
25
|
+
private drawForces;
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CoreModule } from '../core-module';
|
|
2
|
+
export declare class ForceMouse extends CoreModule {
|
|
3
|
+
private runCommand;
|
|
4
|
+
private vertexCoordBuffer;
|
|
5
|
+
private uniformStore;
|
|
6
|
+
initPrograms(): void;
|
|
7
|
+
run(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Destruction order matters
|
|
10
|
+
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
11
|
+
*/
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Framebuffer, RenderPass } from '@luma.gl/core';
|
|
2
2
|
import { CoreModule } from '../core-module';
|
|
3
3
|
export declare class Lines extends CoreModule {
|
|
4
|
-
linkIndexFbo:
|
|
5
|
-
hoveredLineIndexFbo:
|
|
4
|
+
linkIndexFbo: Framebuffer | undefined;
|
|
5
|
+
hoveredLineIndexFbo: Framebuffer | undefined;
|
|
6
6
|
private drawCurveCommand;
|
|
7
7
|
private hoveredLineIndexCommand;
|
|
8
|
-
private
|
|
8
|
+
private pointABuffer;
|
|
9
|
+
private pointBBuffer;
|
|
9
10
|
private colorBuffer;
|
|
10
11
|
private widthBuffer;
|
|
11
12
|
private arrowBuffer;
|
|
@@ -13,8 +14,13 @@ export declare class Lines extends CoreModule {
|
|
|
13
14
|
private curveLineBuffer;
|
|
14
15
|
private linkIndexBuffer;
|
|
15
16
|
private quadBuffer;
|
|
17
|
+
private linkIndexTexture;
|
|
18
|
+
private hoveredLineIndexTexture;
|
|
19
|
+
private drawLineUniformStore;
|
|
20
|
+
private hoveredLineIndexUniformStore;
|
|
21
|
+
private previousScreenSize;
|
|
16
22
|
initPrograms(): void;
|
|
17
|
-
draw(): void;
|
|
23
|
+
draw(renderPass: RenderPass): void;
|
|
18
24
|
updateLinkIndexFbo(): void;
|
|
19
25
|
updatePointsBuffer(): void;
|
|
20
26
|
updateColor(): void;
|
|
@@ -22,4 +28,9 @@ export declare class Lines extends CoreModule {
|
|
|
22
28
|
updateArrow(): void;
|
|
23
29
|
updateCurveLineGeometry(): void;
|
|
24
30
|
findHoveredLine(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Destruction order matters
|
|
33
|
+
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
34
|
+
*/
|
|
35
|
+
destroy(): void;
|
|
25
36
|
}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Framebuffer, Texture, RenderPass } from '@luma.gl/core';
|
|
2
2
|
import { CoreModule } from '../core-module';
|
|
3
3
|
export declare class Points extends CoreModule {
|
|
4
|
-
currentPositionFbo:
|
|
5
|
-
previousPositionFbo:
|
|
6
|
-
velocityFbo:
|
|
7
|
-
selectedFbo:
|
|
8
|
-
hoveredFbo:
|
|
9
|
-
greyoutStatusFbo: regl.Framebuffer2D | undefined;
|
|
4
|
+
currentPositionFbo: Framebuffer | undefined;
|
|
5
|
+
previousPositionFbo: Framebuffer | undefined;
|
|
6
|
+
velocityFbo: Framebuffer | undefined;
|
|
7
|
+
selectedFbo: Framebuffer | undefined;
|
|
8
|
+
hoveredFbo: Framebuffer | undefined;
|
|
10
9
|
scaleX: ((x: number) => number) | undefined;
|
|
11
10
|
scaleY: ((y: number) => number) | undefined;
|
|
12
11
|
shouldSkipRescale: boolean | undefined;
|
|
13
|
-
imageAtlasTexture:
|
|
12
|
+
imageAtlasTexture: Texture | undefined;
|
|
14
13
|
imageCount: number;
|
|
14
|
+
currentPositionTexture: Texture | undefined;
|
|
15
|
+
previousPositionTexture: Texture | undefined;
|
|
16
|
+
velocityTexture: Texture | undefined;
|
|
17
|
+
greyoutStatusTexture: Texture | undefined;
|
|
15
18
|
private colorBuffer;
|
|
16
|
-
private sizeFbo;
|
|
17
19
|
private sizeBuffer;
|
|
18
20
|
private shapeBuffer;
|
|
19
21
|
private imageIndicesBuffer;
|
|
20
22
|
private imageSizesBuffer;
|
|
21
23
|
private imageAtlasCoordsTexture;
|
|
22
24
|
private imageAtlasCoordsTextureSize;
|
|
23
|
-
private trackedIndicesFbo;
|
|
24
25
|
private trackedPositionsFbo;
|
|
25
26
|
private sampledPointsFbo;
|
|
26
27
|
private trackedPositions;
|
|
@@ -32,23 +33,33 @@ export declare class Points extends CoreModule {
|
|
|
32
33
|
private findPointsOnAreaSelectionCommand;
|
|
33
34
|
private findPointsOnPolygonSelectionCommand;
|
|
34
35
|
private findHoveredPointCommand;
|
|
35
|
-
private clearHoveredFboCommand;
|
|
36
|
-
private clearSampledPointsFboCommand;
|
|
37
36
|
private fillSampledPointsFboCommand;
|
|
38
37
|
private trackPointsCommand;
|
|
38
|
+
private updatePositionVertexCoordBuffer;
|
|
39
|
+
private dragPointVertexCoordBuffer;
|
|
40
|
+
private findPointsOnAreaSelectionVertexCoordBuffer;
|
|
41
|
+
private findPointsOnPolygonSelectionVertexCoordBuffer;
|
|
42
|
+
private drawHighlightedVertexCoordBuffer;
|
|
43
|
+
private trackPointsVertexCoordBuffer;
|
|
39
44
|
private trackedIndices;
|
|
40
45
|
private selectedTexture;
|
|
41
|
-
private greyoutStatusTexture;
|
|
42
46
|
private pinnedStatusTexture;
|
|
43
|
-
private pinnedStatusFbo;
|
|
44
47
|
private sizeTexture;
|
|
45
48
|
private trackedIndicesTexture;
|
|
46
49
|
private polygonPathTexture;
|
|
47
|
-
private polygonPathFbo;
|
|
48
50
|
private polygonPathLength;
|
|
49
51
|
private drawPointIndices;
|
|
50
52
|
private hoveredPointIndices;
|
|
51
53
|
private sampledPointIndices;
|
|
54
|
+
private updatePositionUniformStore;
|
|
55
|
+
private dragPointUniformStore;
|
|
56
|
+
private drawUniformStore;
|
|
57
|
+
private findPointsOnAreaSelectionUniformStore;
|
|
58
|
+
private findPointsOnPolygonSelectionUniformStore;
|
|
59
|
+
private findHoveredPointUniformStore;
|
|
60
|
+
private fillSampledPointsUniformStore;
|
|
61
|
+
private drawHighlightedUniformStore;
|
|
62
|
+
private trackPointsUniformStore;
|
|
52
63
|
updatePositions(): void;
|
|
53
64
|
initPrograms(): void;
|
|
54
65
|
updateColor(): void;
|
|
@@ -61,7 +72,7 @@ export declare class Points extends CoreModule {
|
|
|
61
72
|
createAtlas(): void;
|
|
62
73
|
updateSampledPointsGrid(): void;
|
|
63
74
|
trackPoints(): void;
|
|
64
|
-
draw(): void;
|
|
75
|
+
draw(renderPass: RenderPass): void;
|
|
65
76
|
updatePosition(): void;
|
|
66
77
|
drag(): void;
|
|
67
78
|
findPointsOnAreaSelection(): void;
|
|
@@ -84,6 +95,11 @@ export declare class Points extends CoreModule {
|
|
|
84
95
|
positions: number[];
|
|
85
96
|
};
|
|
86
97
|
getTrackedPositionsArray(): number[];
|
|
98
|
+
/**
|
|
99
|
+
* Destruction order matters
|
|
100
|
+
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
101
|
+
* */
|
|
102
|
+
destroy(): void;
|
|
87
103
|
private swapFbo;
|
|
88
104
|
private rescaleInitialNodePositions;
|
|
89
105
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createIndexesForBuffer(textureSize: number): Float32Array;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TextureFormat } from '@luma.gl/core';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates bytesPerRow for texture uploads.
|
|
4
|
+
* @param format - Texture format
|
|
5
|
+
* @param width - Texture width in pixels
|
|
6
|
+
* @returns bytesPerRow in bytes
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBytesPerRow(format: TextureFormat, width: number): number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates and normalizes array values to fixed-size tuples for shader uniforms.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Ensures a value is a vec2 tuple [number, number].
|
|
6
|
+
*/
|
|
7
|
+
export declare function ensureVec2(arr: number[] | undefined, fallback: [number, number]): [number, number];
|
|
8
|
+
/**
|
|
9
|
+
* Ensures a value is a vec4 tuple [number, number, number, number].
|
|
10
|
+
*/
|
|
11
|
+
export declare function ensureVec4(arr: number[] | undefined, fallback: [number, number, number, number]): [number, number, number, number];
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { mat3 } from 'gl-matrix';
|
|
2
|
+
import { GraphConfigInterface } from '../../config';
|
|
3
|
+
export declare const ALPHA_MIN = 0.001;
|
|
4
|
+
export declare const MAX_POINT_SIZE = 64;
|
|
5
|
+
/**
|
|
6
|
+
* Maximum number of executions to delay before performing hover detection.
|
|
7
|
+
* This threshold prevents excessive hover detection calls for performance optimization.
|
|
8
|
+
* The `findHoveredItem` method will skip actual detection until this count is reached.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MAX_HOVER_DETECTION_DELAY = 4;
|
|
11
|
+
export type Hovered = {
|
|
12
|
+
index: number;
|
|
13
|
+
position: [number, number];
|
|
14
|
+
};
|
|
15
|
+
type Focused = {
|
|
16
|
+
index: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Type alias for a 4x4 matrix stored as a 16-element array in column-major order.
|
|
20
|
+
* Used for std140 uniform buffer layout compatibility.
|
|
21
|
+
*/
|
|
22
|
+
type Mat4Array = [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number];
|
|
23
|
+
export declare class Store {
|
|
24
|
+
pointsTextureSize: number;
|
|
25
|
+
linksTextureSize: number;
|
|
26
|
+
alpha: number;
|
|
27
|
+
transform: mat3;
|
|
28
|
+
screenSize: [number, number];
|
|
29
|
+
mousePosition: number[];
|
|
30
|
+
screenMousePosition: number[];
|
|
31
|
+
selectedArea: number[][];
|
|
32
|
+
isSimulationRunning: boolean;
|
|
33
|
+
simulationProgress: number;
|
|
34
|
+
selectedIndices: Float32Array | null;
|
|
35
|
+
maxPointSize: number;
|
|
36
|
+
hoveredPoint: Hovered | undefined;
|
|
37
|
+
focusedPoint: Focused | undefined;
|
|
38
|
+
draggingPointIndex: number | undefined;
|
|
39
|
+
hoveredLinkIndex: number | undefined;
|
|
40
|
+
adjustedSpaceSize: number;
|
|
41
|
+
isSpaceKeyPressed: boolean;
|
|
42
|
+
div: HTMLDivElement | undefined;
|
|
43
|
+
webglMaxTextureSize: number;
|
|
44
|
+
hoveredPointRingColor: number[];
|
|
45
|
+
focusedPointRingColor: number[];
|
|
46
|
+
hoveredLinkColor: number[];
|
|
47
|
+
greyoutPointColor: number[];
|
|
48
|
+
isDarkenGreyout: boolean;
|
|
49
|
+
isLinkHoveringEnabled: boolean;
|
|
50
|
+
private alphaTarget;
|
|
51
|
+
private scalePointX;
|
|
52
|
+
private scalePointY;
|
|
53
|
+
private random;
|
|
54
|
+
private _backgroundColor;
|
|
55
|
+
get backgroundColor(): [number, number, number, number];
|
|
56
|
+
/**
|
|
57
|
+
* Gets the transformation matrix as a 4x4 matrix for std140 uniform buffer layout.
|
|
58
|
+
*
|
|
59
|
+
* This method converts the internal 3x3 transformation matrix (mat3) to a 4x4 matrix format
|
|
60
|
+
* required by WebGPU uniform buffers using the std140 layout standard.
|
|
61
|
+
*
|
|
62
|
+
* ## Matrix Storage Format
|
|
63
|
+
*
|
|
64
|
+
* Matrices are stored in **column-major order** (GLSL convention). The internal `transform`
|
|
65
|
+
* array is a 9-element array representing a 3x3 matrix:
|
|
66
|
+
*
|
|
67
|
+
* ```
|
|
68
|
+
* [m00, m10, m20, m01, m11, m21, m02, m12, m22]
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* Which represents the matrix:
|
|
72
|
+
* ```
|
|
73
|
+
* [m00 m01 m02]
|
|
74
|
+
* [m10 m11 m12]
|
|
75
|
+
* [m20 m21 m22]
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* ## Why This Conversion Is Needed
|
|
79
|
+
*
|
|
80
|
+
* The internal `transform` property stores a 3x3 matrix (9 elements) which is sufficient for
|
|
81
|
+
* 2D transformations (translation, rotation, scaling in x/y plane). However, when passing
|
|
82
|
+
* transformation matrices to GPU shaders via uniform buffers, we must comply with the std140
|
|
83
|
+
* layout standard.
|
|
84
|
+
*
|
|
85
|
+
* ### std140 Layout Requirements
|
|
86
|
+
*
|
|
87
|
+
* The std140 layout standard (used in both OpenGL and WebGPU) defines strict alignment rules:
|
|
88
|
+
*
|
|
89
|
+
* 1. **Matrix Alignment**: In std140, matrices are stored as arrays of column vectors
|
|
90
|
+
* - `mat3` requires each column to be aligned to 16 bytes (vec4 alignment)
|
|
91
|
+
* - This means `mat3` occupies 3 columns × 16 bytes = 48 bytes total
|
|
92
|
+
* - `mat4` occupies 4 columns × 16 bytes = 64 bytes total
|
|
93
|
+
*
|
|
94
|
+
* 2. **Alignment Issues with mat3**:
|
|
95
|
+
* - The 48-byte size of `mat3` creates awkward alignment and padding requirements
|
|
96
|
+
* - Different GPU drivers may handle `mat3` padding inconsistently
|
|
97
|
+
* - This can lead to data misalignment and incorrect transformations
|
|
98
|
+
*
|
|
99
|
+
* 3. **Why mat4 is Preferred**:
|
|
100
|
+
* - `mat4` has clean 64-byte alignment (power of 2)
|
|
101
|
+
* - Consistent behavior across all GPU drivers and platforms
|
|
102
|
+
* - The shader can easily extract the 3x3 portion: `mat3 transformMat3 = mat3(transformationMatrix)`
|
|
103
|
+
* - The 4th column is set to `[0, 0, 0, 1]` (homogeneous coordinate) which doesn't affect 2D transforms
|
|
104
|
+
*
|
|
105
|
+
* ### Conversion Process
|
|
106
|
+
*
|
|
107
|
+
* The 3x3 matrix is converted to 4x4 by:
|
|
108
|
+
* - Placing the 3x3 values in the top-left corner (preserving column-major order)
|
|
109
|
+
* - Setting the 4th column to `[0, 0, 0, 1]` (homogeneous coordinate)
|
|
110
|
+
* - The 4th row is implicitly `[0, 0, 0, 1]` due to column-major storage
|
|
111
|
+
*
|
|
112
|
+
* This creates a valid 4x4 transformation matrix that:
|
|
113
|
+
* - Maintains the same 2D transformation behavior
|
|
114
|
+
* - Satisfies std140 alignment requirements
|
|
115
|
+
* - Works consistently across all GPU platforms
|
|
116
|
+
*
|
|
117
|
+
* ### Usage in Shaders
|
|
118
|
+
*
|
|
119
|
+
* Shaders using uniform buffers receive this as `mat4` and extract the 3x3 portion:
|
|
120
|
+
* ```glsl
|
|
121
|
+
* layout(std140) uniform uniforms {
|
|
122
|
+
* mat4 transformationMatrix;
|
|
123
|
+
* } uniforms;
|
|
124
|
+
*
|
|
125
|
+
* mat3 transformMat3 = mat3(uniforms.transformationMatrix);
|
|
126
|
+
* vec3 final = transformMat3 * vec3(position, 1);
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @returns A 16-element array representing a 4x4 matrix in column-major order,
|
|
130
|
+
* suitable for std140 uniform buffer layout. The matrix preserves the
|
|
131
|
+
* 2D transformation from the original 3x3 matrix.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const matrix = store.transformationMatrix4x4;
|
|
136
|
+
* uniformStore.setUniforms({
|
|
137
|
+
* uniforms: {
|
|
138
|
+
* transformationMatrix: matrix // Expects mat4x4<f32> in shader
|
|
139
|
+
* }
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
get transformationMatrix4x4(): Mat4Array;
|
|
144
|
+
set backgroundColor(color: [number, number, number, number]);
|
|
145
|
+
addRandomSeed(seed: number | string): void;
|
|
146
|
+
getRandomFloat(min: number, max: number): number;
|
|
147
|
+
/**
|
|
148
|
+
* If the config parameter `spaceSize` exceeds the limits of WebGL,
|
|
149
|
+
* it reduces the space size without changing the config parameter.
|
|
150
|
+
* Ensures `spaceSize` is always a positive number >= 2 (required for Math.log2).
|
|
151
|
+
*/
|
|
152
|
+
adjustSpaceSize(configSpaceSize: number, webglMaxTextureSize: number): void;
|
|
153
|
+
/**
|
|
154
|
+
* Sets the WebGL texture size limit for use in atlas creation and other texture operations.
|
|
155
|
+
*/
|
|
156
|
+
setWebGLMaxTextureSize(webglMaxTextureSize: number): void;
|
|
157
|
+
updateScreenSize(width: number, height: number): void;
|
|
158
|
+
scaleX(x: number): number;
|
|
159
|
+
scaleY(y: number): number;
|
|
160
|
+
setHoveredPointRingColor(color: string | [number, number, number, number]): void;
|
|
161
|
+
setFocusedPointRingColor(color: string | [number, number, number, number]): void;
|
|
162
|
+
setGreyoutPointColor(color: string | [number, number, number, number] | undefined): void;
|
|
163
|
+
updateLinkHoveringEnabled(config: Pick<GraphConfigInterface, 'onLinkClick' | 'onLinkMouseOver' | 'onLinkMouseOut'>): void;
|
|
164
|
+
setHoveredLinkColor(color?: string | [number, number, number, number]): void;
|
|
165
|
+
setFocusedPoint(index?: number): void;
|
|
166
|
+
addAlpha(decay: number): number;
|
|
167
|
+
private alphaDecay;
|
|
168
|
+
}
|
|
169
|
+
export {};
|