@cosmos.gl/graph 3.0.0-beta.5 → 3.0.0-beta.7
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/README.md +21 -2
- package/dist/config.d.ts +127 -179
- package/dist/index.d.ts +77 -41
- package/dist/index.js +1341 -993
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +163 -67
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Clusters/index.d.ts +9 -0
- package/dist/modules/GraphData/index.d.ts +4 -5
- package/dist/modules/Lines/conic-curve-module.d.ts +2 -0
- package/dist/modules/Lines/index.d.ts +10 -0
- package/dist/modules/Points/index.d.ts +7 -0
- package/dist/modules/Zoom/index.d.ts +4 -0
- package/dist/variables.d.ts +75 -43
- package/package.json +3 -3
|
@@ -11,6 +11,13 @@ export declare class Clusters extends CoreModule {
|
|
|
11
11
|
private centermassTexture;
|
|
12
12
|
private pointIndices;
|
|
13
13
|
private clustersTextureSize;
|
|
14
|
+
/**
|
|
15
|
+
* Cached result of the last `getCentroidPositions()` computation.
|
|
16
|
+
* Populated when the simulation is inactive to avoid redundant GPU render passes and readbacks.
|
|
17
|
+
* Nulled in `create()` and `destroy()` to handle structural changes (e.g. `setPointPositions`,
|
|
18
|
+
* `setPointClusters`). Positional changes are handled separately via `Points.areClusterCentroidsUpToDate`.
|
|
19
|
+
*/
|
|
20
|
+
private cachedCentroidPositions;
|
|
14
21
|
private applyForcesVertexCoordBuffer;
|
|
15
22
|
private previousPointsTextureSize;
|
|
16
23
|
private previousClustersTextureSize;
|
|
@@ -20,6 +27,8 @@ export declare class Clusters extends CoreModule {
|
|
|
20
27
|
create(): void;
|
|
21
28
|
initPrograms(): void;
|
|
22
29
|
calculateCentermass(): void;
|
|
30
|
+
/** Do not mutate the returned array; it may be the internal cache. */
|
|
31
|
+
getCentroidPositions(): Readonly<number[]>;
|
|
23
32
|
run(): void;
|
|
24
33
|
/**
|
|
25
34
|
* Destruction order matters
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphConfigInterface } from '../../config';
|
|
2
2
|
export declare enum PointShape {
|
|
3
3
|
Circle = 0,
|
|
4
4
|
Square = 1,
|
|
@@ -52,7 +52,7 @@ export declare class GraphData {
|
|
|
52
52
|
inDegree: number[] | undefined;
|
|
53
53
|
outDegree: number[] | undefined;
|
|
54
54
|
private _config;
|
|
55
|
-
constructor(config:
|
|
55
|
+
constructor(config: GraphConfigInterface);
|
|
56
56
|
get pointsNumber(): number | undefined;
|
|
57
57
|
get linksNumber(): number | undefined;
|
|
58
58
|
updatePoints(): void;
|
|
@@ -65,9 +65,8 @@ export declare class GraphData {
|
|
|
65
65
|
*/
|
|
66
66
|
updatePointSize(): void;
|
|
67
67
|
/**
|
|
68
|
-
* Updates the point shapes based on the input data or default
|
|
69
|
-
*
|
|
70
|
-
* Images are rendered above shapes.
|
|
68
|
+
* Updates the point shapes based on the input data or default config value.
|
|
69
|
+
* Images are rendered above shapes.
|
|
71
70
|
*/
|
|
72
71
|
updatePointShape(): void;
|
|
73
72
|
/**
|
|
@@ -3,8 +3,10 @@ import { CoreModule } from '../core-module';
|
|
|
3
3
|
export declare class Lines extends CoreModule {
|
|
4
4
|
linkIndexFbo: Framebuffer | undefined;
|
|
5
5
|
hoveredLineIndexFbo: Framebuffer | undefined;
|
|
6
|
+
sampledLinksFbo: Framebuffer | undefined;
|
|
6
7
|
private drawCurveCommand;
|
|
7
8
|
private hoveredLineIndexCommand;
|
|
9
|
+
private fillSampledLinksFboCommand;
|
|
8
10
|
private pointABuffer;
|
|
9
11
|
private pointBBuffer;
|
|
10
12
|
private colorBuffer;
|
|
@@ -16,17 +18,25 @@ export declare class Lines extends CoreModule {
|
|
|
16
18
|
private quadBuffer;
|
|
17
19
|
private linkIndexTexture;
|
|
18
20
|
private hoveredLineIndexTexture;
|
|
21
|
+
private fillSampledLinksUniformStore;
|
|
19
22
|
private drawLineUniformStore;
|
|
20
23
|
private hoveredLineIndexUniformStore;
|
|
21
24
|
private previousScreenSize;
|
|
22
25
|
initPrograms(): void;
|
|
23
26
|
draw(renderPass: RenderPass): void;
|
|
24
27
|
updateLinkIndexFbo(): void;
|
|
28
|
+
updateSampledLinksGrid(): void;
|
|
25
29
|
updatePointsBuffer(): void;
|
|
26
30
|
updateColor(): void;
|
|
27
31
|
updateWidth(): void;
|
|
28
32
|
updateArrow(): void;
|
|
29
33
|
updateCurveLineGeometry(): void;
|
|
34
|
+
getSampledLinkPositionsMap(): Map<number, [number, number, number]>;
|
|
35
|
+
getSampledLinks(): {
|
|
36
|
+
indices: number[];
|
|
37
|
+
positions: number[];
|
|
38
|
+
angles: number[];
|
|
39
|
+
};
|
|
30
40
|
findHoveredLine(): void;
|
|
31
41
|
/**
|
|
32
42
|
* Destruction order matters
|
|
@@ -15,6 +15,13 @@ export declare class Points extends CoreModule {
|
|
|
15
15
|
previousPositionTexture: Texture | undefined;
|
|
16
16
|
velocityTexture: Texture | undefined;
|
|
17
17
|
greyoutStatusTexture: Texture | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the cached cluster centroid positions are still valid.
|
|
20
|
+
* Set to `false` in `swapFbo()` whenever GPU point positions change (simulation tick or drag).
|
|
21
|
+
* Set to `true` by `Clusters.getCentroidPositions()` after a fresh computation.
|
|
22
|
+
* Used together with `Clusters.cachedCentroidPositions` to skip redundant GPU readbacks.
|
|
23
|
+
*/
|
|
24
|
+
areClusterCentroidsUpToDate: boolean;
|
|
18
25
|
private colorBuffer;
|
|
19
26
|
private sizeBuffer;
|
|
20
27
|
private shapeBuffer;
|
|
@@ -7,6 +7,10 @@ export declare class Zoom {
|
|
|
7
7
|
eventTransform: ZoomTransform;
|
|
8
8
|
behavior: import('d3-zoom').ZoomBehavior<HTMLCanvasElement, undefined>;
|
|
9
9
|
isRunning: boolean;
|
|
10
|
+
/** Per-call override for `enableSimulationDuringZoom` config, set by programmatic zoom methods.
|
|
11
|
+
* Stale value after transition ends is harmless since `isRunning` is `false` at that point.
|
|
12
|
+
* Cleared on user-driven zoom start. */
|
|
13
|
+
shouldEnableSimulationDuringZoomOverride: boolean | undefined;
|
|
10
14
|
constructor(store: Store, config: GraphConfigInterface);
|
|
11
15
|
/**
|
|
12
16
|
* Returns the zoom transform that fits the given point positions into the viewport.
|
package/dist/variables.d.ts
CHANGED
|
@@ -1,64 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare const defaultPointSize = 4;
|
|
6
|
-
export declare const defaultLinkColor = "#666666";
|
|
7
|
-
export declare const defaultGreyoutLinkOpacity = 0.1;
|
|
8
|
-
export declare const defaultLinkOpacity = 1;
|
|
9
|
-
export declare const defaultLinkWidth = 1;
|
|
10
|
-
export declare const defaultBackgroundColor = "#222222";
|
|
1
|
+
import { PointShape } from './modules/GraphData';
|
|
2
|
+
/**
|
|
3
|
+
* Default values for all graph configuration properties.
|
|
4
|
+
*/
|
|
11
5
|
export declare const defaultConfigValues: {
|
|
12
|
-
enableSimulation:
|
|
6
|
+
enableSimulation: true;
|
|
7
|
+
backgroundColor: string;
|
|
8
|
+
/** Setting to 4096 because larger values crash the graph on iOS. More info: https://github.com/cosmosgl/graph/issues/203 */
|
|
13
9
|
spaceSize: number;
|
|
10
|
+
pointDefaultColor: string;
|
|
11
|
+
pointDefaultSize: number;
|
|
12
|
+
pointDefaultShape: PointShape.Circle;
|
|
13
|
+
pointOpacity: number;
|
|
14
|
+
pointGreyoutOpacity: undefined;
|
|
15
|
+
pointGreyoutColor: undefined;
|
|
14
16
|
pointSizeScale: number;
|
|
17
|
+
scalePointsOnZoom: false;
|
|
18
|
+
hoveredPointCursor: string;
|
|
19
|
+
renderHoveredPointRing: false;
|
|
20
|
+
hoveredPointRingColor: string;
|
|
21
|
+
focusedPointRingColor: string;
|
|
22
|
+
focusedPointIndex: undefined;
|
|
23
|
+
renderLinks: true;
|
|
24
|
+
linkDefaultColor: string;
|
|
25
|
+
linkDefaultWidth: number;
|
|
26
|
+
linkOpacity: number;
|
|
27
|
+
linkGreyoutOpacity: number;
|
|
15
28
|
linkWidthScale: number;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
curvedLinks: boolean;
|
|
29
|
+
scaleLinksOnZoom: false;
|
|
30
|
+
curvedLinks: false;
|
|
19
31
|
curvedLinkSegments: number;
|
|
20
32
|
curvedLinkWeight: number;
|
|
21
33
|
curvedLinkControlPointDistance: number;
|
|
22
|
-
|
|
34
|
+
linkDefaultArrows: false;
|
|
35
|
+
linkArrowsSizeScale: number;
|
|
23
36
|
linkVisibilityDistanceRange: number[];
|
|
24
37
|
linkVisibilityMinTransparency: number;
|
|
25
|
-
hoveredPointCursor: string;
|
|
26
38
|
hoveredLinkCursor: string;
|
|
27
|
-
renderHoveredPointRing: boolean;
|
|
28
|
-
hoveredPointRingColor: string;
|
|
29
39
|
hoveredLinkColor: undefined;
|
|
30
40
|
hoveredLinkWidthIncrease: number;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
simulationDecay: number;
|
|
42
|
+
simulationGravity: number;
|
|
43
|
+
simulationCenter: number;
|
|
44
|
+
simulationRepulsion: number;
|
|
45
|
+
simulationRepulsionTheta: number;
|
|
46
|
+
simulationLinkSpring: number;
|
|
47
|
+
simulationLinkDistance: number;
|
|
48
|
+
simulationLinkDistRandomVariationRange: number[];
|
|
49
|
+
simulationRepulsionFromMouse: number;
|
|
50
|
+
simulationFriction: number;
|
|
51
|
+
simulationCluster: number;
|
|
52
|
+
enableRightClickRepulsion: false;
|
|
53
|
+
onSimulationStart: undefined;
|
|
54
|
+
onSimulationTick: undefined;
|
|
55
|
+
onSimulationEnd: undefined;
|
|
56
|
+
onSimulationPause: undefined;
|
|
57
|
+
onSimulationUnpause: undefined;
|
|
58
|
+
onClick: undefined;
|
|
59
|
+
onPointClick: undefined;
|
|
60
|
+
onLinkClick: undefined;
|
|
61
|
+
onBackgroundClick: undefined;
|
|
62
|
+
onContextMenu: undefined;
|
|
63
|
+
onPointContextMenu: undefined;
|
|
64
|
+
onLinkContextMenu: undefined;
|
|
65
|
+
onBackgroundContextMenu: undefined;
|
|
66
|
+
onMouseMove: undefined;
|
|
67
|
+
onPointMouseOver: undefined;
|
|
68
|
+
onPointMouseOut: undefined;
|
|
69
|
+
onLinkMouseOver: undefined;
|
|
70
|
+
onLinkMouseOut: undefined;
|
|
71
|
+
onZoomStart: undefined;
|
|
72
|
+
onZoom: undefined;
|
|
73
|
+
onZoomEnd: undefined;
|
|
74
|
+
onDragStart: undefined;
|
|
75
|
+
onDrag: undefined;
|
|
76
|
+
onDragEnd: undefined;
|
|
77
|
+
showFPSMonitor: false;
|
|
47
78
|
pixelRatio: number;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
fitViewOnInit: boolean;
|
|
79
|
+
enableZoom: true;
|
|
80
|
+
enableSimulationDuringZoom: false;
|
|
81
|
+
initialZoomLevel: undefined;
|
|
82
|
+
enableDrag: false;
|
|
83
|
+
fitViewOnInit: true;
|
|
54
84
|
fitViewDelay: number;
|
|
55
85
|
fitViewPadding: number;
|
|
56
86
|
fitViewDuration: number;
|
|
87
|
+
fitViewByPointsInRect: undefined;
|
|
88
|
+
fitViewByPointIndices: undefined;
|
|
57
89
|
pointSamplingDistance: number;
|
|
58
|
-
|
|
90
|
+
linkSamplingDistance: number;
|
|
91
|
+
randomSeed: undefined;
|
|
59
92
|
rescalePositions: undefined;
|
|
60
|
-
|
|
93
|
+
attribution: string;
|
|
61
94
|
};
|
|
62
95
|
export declare const hoveredPointRingOpacity = 0.7;
|
|
63
96
|
export declare const focusedPointRingOpacity = 0.95;
|
|
64
|
-
export declare const defaultScaleToZoom = 3;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmos.gl/graph",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.7",
|
|
4
4
|
"description": "GPU-based force graph layout and rendering",
|
|
5
5
|
"jsdelivr": "dist/index.min.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"repository": "git://github.com/
|
|
9
|
+
"repository": "git://github.com/cosmosgl/graph.git",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"homepage": "https://cosmosgl.github.io/graph",
|
|
36
36
|
"author": "cosmos.gl",
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@interacta/css-labels": "^0.
|
|
38
|
+
"@interacta/css-labels": "^0.6.0",
|
|
39
39
|
"@jls-digital/storybook-addon-code": "^1.0.4",
|
|
40
40
|
"@storybook/addon-essentials": "^8.4.5",
|
|
41
41
|
"@storybook/addon-interactions": "^8.4.5",
|