@cosmos.gl/graph 2.6.2 → 2.7.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +2 -2
- package/dist/graph/utils/error-message.d.ts +1 -1
- package/dist/helper.d.ts +39 -2
- package/dist/index-B1_1MjaX.js +19917 -0
- package/dist/index-B1_1MjaX.js.map +1 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +14 -14658
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1068 -469
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Clusters/index.d.ts +11 -6
- package/dist/modules/ForceCenter/index.d.ts +10 -3
- package/dist/modules/ForceGravity/index.d.ts +5 -1
- package/dist/modules/ForceLink/index.d.ts +8 -5
- package/dist/modules/ForceManyBody/index.d.ts +16 -7
- package/dist/modules/ForceMouse/index.d.ts +5 -1
- package/dist/modules/Lines/index.d.ts +11 -5
- package/dist/modules/Points/index.d.ts +30 -14
- package/dist/modules/Store/index.d.ts +93 -0
- package/dist/modules/core-module.d.ts +3 -3
- package/dist/webgl-device-DzkMihDq.js +3923 -0
- package/dist/webgl-device-DzkMihDq.js.map +1 -0
- package/package.json +5 -3
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Framebuffer, RenderPass } 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
6
|
private clearCentermassCommand;
|
|
10
7
|
private calculateCentermassCommand;
|
|
11
8
|
private applyForcesCommand;
|
|
@@ -15,8 +12,16 @@ export declare class Clusters extends CoreModule {
|
|
|
15
12
|
private centermassTexture;
|
|
16
13
|
private pointIndices;
|
|
17
14
|
private clustersTextureSize;
|
|
15
|
+
private clearCentermassVertexCoordBuffer;
|
|
16
|
+
private applyForcesVertexCoordBuffer;
|
|
17
|
+
private previousPointsTextureSize;
|
|
18
|
+
private previousClustersTextureSize;
|
|
19
|
+
private previousClusterCount;
|
|
20
|
+
private calculateCentermassUniformStore;
|
|
21
|
+
private applyForcesUniformStore;
|
|
18
22
|
create(): void;
|
|
19
23
|
initPrograms(): void;
|
|
20
24
|
calculateCentermass(): void;
|
|
21
|
-
run(): void;
|
|
25
|
+
run(renderPass?: RenderPass): void;
|
|
26
|
+
destroy(): void;
|
|
22
27
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { RenderPass } from '@luma.gl/core';
|
|
1
2
|
import { CoreModule } from '../core-module';
|
|
2
3
|
export declare class ForceCenter extends CoreModule {
|
|
4
|
+
private centermassTexture;
|
|
3
5
|
private centermassFbo;
|
|
6
|
+
private pointIndices;
|
|
4
7
|
private clearCentermassCommand;
|
|
5
8
|
private calculateCentermassCommand;
|
|
6
9
|
private runCommand;
|
|
7
|
-
private
|
|
8
|
-
private
|
|
10
|
+
private clearVertexCoordBuffer;
|
|
11
|
+
private forceVertexCoordBuffer;
|
|
12
|
+
private calculateUniformStore;
|
|
13
|
+
private forceUniformStore;
|
|
14
|
+
private previousPointsTextureSize;
|
|
9
15
|
create(): void;
|
|
10
16
|
initPrograms(): void;
|
|
11
|
-
run(): void;
|
|
17
|
+
run(renderPass?: RenderPass): void;
|
|
18
|
+
destroy(): void;
|
|
12
19
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { RenderPass } from '@luma.gl/core';
|
|
1
2
|
import { CoreModule } from '../core-module';
|
|
2
3
|
export declare class ForceGravity extends CoreModule {
|
|
3
4
|
private runCommand;
|
|
5
|
+
private vertexCoordBuffer;
|
|
6
|
+
private uniformStore;
|
|
4
7
|
initPrograms(): void;
|
|
5
|
-
run(): void;
|
|
8
|
+
run(renderPass?: RenderPass): void;
|
|
9
|
+
destroy(): void;
|
|
6
10
|
}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import { RenderPass } from '@luma.gl/core';
|
|
1
2
|
import { CoreModule } from '../core-module';
|
|
2
3
|
export declare enum LinkDirection {
|
|
3
4
|
OUTGOING = "outgoing",
|
|
4
5
|
INCOMING = "incoming"
|
|
5
6
|
}
|
|
6
7
|
export declare class ForceLink extends CoreModule {
|
|
7
|
-
private linkFirstIndicesAndAmountFbo;
|
|
8
|
-
private indicesFbo;
|
|
9
|
-
private biasAndStrengthFbo;
|
|
10
|
-
private randomDistanceFbo;
|
|
11
8
|
private linkFirstIndicesAndAmount;
|
|
12
9
|
private indices;
|
|
13
10
|
private maxPointDegree;
|
|
11
|
+
private previousMaxPointDegree;
|
|
12
|
+
private previousPointsTextureSize;
|
|
13
|
+
private previousLinksTextureSize;
|
|
14
14
|
private runCommand;
|
|
15
|
+
private vertexCoordBuffer;
|
|
16
|
+
private uniformStore;
|
|
15
17
|
private linkFirstIndicesAndAmountTexture;
|
|
16
18
|
private indicesTexture;
|
|
17
19
|
private biasAndStrengthTexture;
|
|
18
20
|
private randomDistanceTexture;
|
|
19
21
|
create(direction: LinkDirection): void;
|
|
20
22
|
initPrograms(): void;
|
|
21
|
-
run(): void;
|
|
23
|
+
run(renderPass?: RenderPass): void;
|
|
24
|
+
destroy(): void;
|
|
22
25
|
}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
import { RenderPass } from '@luma.gl/core';
|
|
1
2
|
import { CoreModule } from '../core-module';
|
|
2
3
|
export declare class ForceManyBody extends CoreModule {
|
|
3
|
-
private
|
|
4
|
-
private
|
|
4
|
+
private randomValuesTexture;
|
|
5
|
+
private pointIndices;
|
|
6
|
+
private levels;
|
|
7
|
+
private levelTargets;
|
|
5
8
|
private clearLevelsCommand;
|
|
6
|
-
private clearVelocityCommand;
|
|
7
9
|
private calculateLevelsCommand;
|
|
8
10
|
private forceCommand;
|
|
9
11
|
private forceFromItsOwnCentermassCommand;
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private
|
|
12
|
+
private clearLevelsVertexCoordBuffer;
|
|
13
|
+
private forceVertexCoordBuffer;
|
|
14
|
+
private calculateLevelsUniformStore;
|
|
15
|
+
private forceUniformStore;
|
|
16
|
+
private forceCenterUniformStore;
|
|
17
|
+
private previousPointsTextureSize;
|
|
18
|
+
private previousSpaceSize;
|
|
13
19
|
create(): void;
|
|
14
20
|
initPrograms(): void;
|
|
15
|
-
run(): void;
|
|
21
|
+
run(renderPass?: RenderPass): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
private drawLevels;
|
|
24
|
+
private drawForces;
|
|
16
25
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { RenderPass } from '@luma.gl/core';
|
|
1
2
|
import { CoreModule } from '../core-module';
|
|
2
3
|
export declare class ForceMouse extends CoreModule {
|
|
3
4
|
private runCommand;
|
|
5
|
+
private vertexCoordBuffer;
|
|
6
|
+
private uniformStore;
|
|
4
7
|
initPrograms(): void;
|
|
5
|
-
run(): void;
|
|
8
|
+
run(renderPass?: RenderPass): void;
|
|
9
|
+
destroy(): void;
|
|
6
10
|
}
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -36,19 +37,33 @@ export declare class Points extends CoreModule {
|
|
|
36
37
|
private clearSampledPointsFboCommand;
|
|
37
38
|
private fillSampledPointsFboCommand;
|
|
38
39
|
private trackPointsCommand;
|
|
40
|
+
private updatePositionVertexCoordBuffer;
|
|
41
|
+
private dragPointVertexCoordBuffer;
|
|
42
|
+
private findPointsOnAreaSelectionVertexCoordBuffer;
|
|
43
|
+
private findPointsOnPolygonSelectionVertexCoordBuffer;
|
|
44
|
+
private clearHoveredFboVertexCoordBuffer;
|
|
45
|
+
private clearSampledPointsFboVertexCoordBuffer;
|
|
46
|
+
private drawHighlightedVertexCoordBuffer;
|
|
47
|
+
private trackPointsVertexCoordBuffer;
|
|
39
48
|
private trackedIndices;
|
|
40
49
|
private selectedTexture;
|
|
41
|
-
private greyoutStatusTexture;
|
|
42
50
|
private pinnedStatusTexture;
|
|
43
|
-
private pinnedStatusFbo;
|
|
44
51
|
private sizeTexture;
|
|
45
52
|
private trackedIndicesTexture;
|
|
46
53
|
private polygonPathTexture;
|
|
47
|
-
private polygonPathFbo;
|
|
48
54
|
private polygonPathLength;
|
|
49
55
|
private drawPointIndices;
|
|
50
56
|
private hoveredPointIndices;
|
|
51
57
|
private sampledPointIndices;
|
|
58
|
+
private updatePositionUniformStore;
|
|
59
|
+
private dragPointUniformStore;
|
|
60
|
+
private drawUniformStore;
|
|
61
|
+
private findPointsOnAreaSelectionUniformStore;
|
|
62
|
+
private findPointsOnPolygonSelectionUniformStore;
|
|
63
|
+
private findHoveredPointUniformStore;
|
|
64
|
+
private fillSampledPointsUniformStore;
|
|
65
|
+
private drawHighlightedUniformStore;
|
|
66
|
+
private trackPointsUniformStore;
|
|
52
67
|
updatePositions(): void;
|
|
53
68
|
initPrograms(): void;
|
|
54
69
|
updateColor(): void;
|
|
@@ -61,7 +76,7 @@ export declare class Points extends CoreModule {
|
|
|
61
76
|
createAtlas(): void;
|
|
62
77
|
updateSampledPointsGrid(): void;
|
|
63
78
|
trackPoints(): void;
|
|
64
|
-
draw(): void;
|
|
79
|
+
draw(renderPass: RenderPass): void;
|
|
65
80
|
updatePosition(): void;
|
|
66
81
|
drag(): void;
|
|
67
82
|
findPointsOnAreaSelection(): void;
|
|
@@ -84,6 +99,7 @@ export declare class Points extends CoreModule {
|
|
|
84
99
|
positions: number[];
|
|
85
100
|
};
|
|
86
101
|
getTrackedPositionsArray(): number[];
|
|
102
|
+
destroy(): void;
|
|
87
103
|
private swapFbo;
|
|
88
104
|
private rescaleInitialNodePositions;
|
|
89
105
|
}
|
|
@@ -15,6 +15,11 @@ export type Hovered = {
|
|
|
15
15
|
type Focused = {
|
|
16
16
|
index: number;
|
|
17
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];
|
|
18
23
|
export declare class Store {
|
|
19
24
|
pointsTextureSize: number;
|
|
20
25
|
linksTextureSize: number;
|
|
@@ -48,6 +53,94 @@ export declare class Store {
|
|
|
48
53
|
private random;
|
|
49
54
|
private _backgroundColor;
|
|
50
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;
|
|
51
144
|
set backgroundColor(color: [number, number, number, number]);
|
|
52
145
|
addRandomSeed(seed: number | string): void;
|
|
53
146
|
getRandomFloat(min: number, max: number): number;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Device } from '@luma.gl/core';
|
|
2
2
|
import { GraphConfigInterface } from '../config';
|
|
3
3
|
import { GraphData } from './GraphData';
|
|
4
4
|
import { Points } from './Points';
|
|
5
5
|
import { Store } from './Store';
|
|
6
6
|
export declare class CoreModule {
|
|
7
|
-
readonly
|
|
7
|
+
readonly device: Device;
|
|
8
8
|
readonly config: GraphConfigInterface;
|
|
9
9
|
readonly store: Store;
|
|
10
10
|
readonly data: GraphData;
|
|
11
11
|
readonly points: Points | undefined;
|
|
12
12
|
_debugRandomNumber: number;
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(device: Device, config: GraphConfigInterface, store: Store, data: GraphData, points?: Points);
|
|
14
14
|
}
|