3d-force-graph 1.73.5 → 1.74.0

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 (38) hide show
  1. package/README.md +2 -3
  2. package/dist/3d-force-graph.d.ts +4 -6
  3. package/dist/3d-force-graph.js +25529 -38300
  4. package/dist/3d-force-graph.js.map +1 -1
  5. package/dist/3d-force-graph.min.js +3 -3
  6. package/example/async-load/index.html +1 -2
  7. package/example/auto-colored/index.html +1 -2
  8. package/example/basic/index.html +1 -2
  9. package/example/bloom-effect/index.html +1 -2
  10. package/example/camera-auto-orbit/index.html +1 -2
  11. package/example/click-to-focus/index.html +1 -2
  12. package/example/collision-detection/index.html +1 -2
  13. package/example/controls-fly/index.html +1 -2
  14. package/example/controls-orbit/index.html +1 -2
  15. package/example/curved-links/index.html +1 -2
  16. package/example/custom-node-geometry/index.html +1 -2
  17. package/example/dag-yarn/index.html +2 -3
  18. package/example/directional-links-arrows/index.html +1 -2
  19. package/example/directional-links-particles/index.html +1 -2
  20. package/example/dynamic/index.html +1 -1
  21. package/example/emit-particles/index.html +1 -2
  22. package/example/expandable-nodes/index.html +1 -1
  23. package/example/fit-to-canvas/index.html +1 -2
  24. package/example/fix-dragged-nodes/index.html +1 -2
  25. package/example/gradient-links/index.html +1 -2
  26. package/example/highlight/index.html +1 -2
  27. package/example/html-nodes/index.html +1 -2
  28. package/example/img-nodes/index.html +1 -2
  29. package/example/large-graph/index.html +1 -1
  30. package/example/manipulate-link-force/index.html +1 -2
  31. package/example/multi-selection/index.html +1 -2
  32. package/example/pause-resume/index.html +1 -2
  33. package/example/responsive/index.html +1 -2
  34. package/example/scene/index.html +1 -2
  35. package/example/text-links/index.html +1 -2
  36. package/example/text-nodes/index.html +1 -2
  37. package/example/tree/index.html +2 -3
  38. package/package.json +6 -6
@@ -9,8 +9,7 @@
9
9
  <div id="3d-graph"></div>
10
10
 
11
11
  <script>
12
- const Graph = ForceGraph3D()
13
- (document.getElementById('3d-graph'))
12
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
14
13
  .jsonUrl('../datasets/miserables.json')
15
14
  .nodeLabel('id')
16
15
  .nodeAutoColorBy('group');
@@ -25,8 +25,7 @@
25
25
  }))
26
26
  };
27
27
 
28
- const Graph = ForceGraph3D()
29
- (document.getElementById('3d-graph'))
28
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
30
29
  .nodeAutoColorBy('group')
31
30
  .linkAutoColorBy(d => gData.nodes[d.source].group)
32
31
  .linkOpacity(0.5)
@@ -21,8 +21,7 @@
21
21
  }))
22
22
  };
23
23
 
24
- const Graph = ForceGraph3D()
25
- (document.getElementById('3d-graph'))
24
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
26
25
  .graphData(gData);
27
26
  </script>
28
27
  </body>
@@ -12,8 +12,7 @@
12
12
  <script type="module">
13
13
  import { UnrealBloomPass } from '//unpkg.com/three/examples/jsm/postprocessing/UnrealBloomPass.js';
14
14
 
15
- const Graph = ForceGraph3D()
16
- (document.getElementById('3d-graph'))
15
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
17
16
  .backgroundColor('#000003')
18
17
  .jsonUrl('../datasets/miserables.json')
19
18
  .nodeLabel('id')
@@ -23,8 +23,7 @@
23
23
 
24
24
  const distance = 1400;
25
25
 
26
- const Graph = ForceGraph3D()
27
- (document.getElementById('3d-graph'))
26
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
28
27
  .enableNodeDrag(false)
29
28
  .enableNavigationControls(false)
30
29
  .showNavInfo(false)
@@ -11,8 +11,7 @@
11
11
  <script>
12
12
  const elem = document.getElementById('3d-graph');
13
13
 
14
- const Graph = ForceGraph3D()
15
- (elem)
14
+ const Graph = new ForceGraph3D(elem)
16
15
  .jsonUrl('../datasets/miserables.json')
17
16
  .nodeLabel('id')
18
17
  .nodeAutoColorBy('group')
@@ -20,8 +20,7 @@
20
20
  vz: Math.random()
21
21
  }));
22
22
 
23
- const Graph = ForceGraph3D()
24
- (document.getElementById('3d-graph'));
23
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'));
25
24
 
26
25
  Graph.cooldownTime(Infinity)
27
26
  .d3AlphaDecay(0)
@@ -9,8 +9,7 @@
9
9
  <div id="3d-graph"></div>
10
10
 
11
11
  <script>
12
- const Graph = ForceGraph3D({ controlType: 'fly' })
13
- (document.getElementById('3d-graph'))
12
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'), { controlType: 'fly' })
14
13
  .jsonUrl('../datasets/miserables.json')
15
14
  .nodeLabel('id')
16
15
  .nodeAutoColorBy('group');
@@ -9,8 +9,7 @@
9
9
  <div id="3d-graph"></div>
10
10
 
11
11
  <script>
12
- const Graph = ForceGraph3D({ controlType: 'orbit' })
13
- (document.getElementById('3d-graph'))
12
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'), { controlType: 'orbit' })
14
13
  .jsonUrl('../datasets/miserables.json')
15
14
  .nodeLabel('id')
16
15
  .nodeAutoColorBy('group');
@@ -49,8 +49,7 @@
49
49
  ]
50
50
  };
51
51
 
52
- const Graph = ForceGraph3D()
53
- (document.getElementById('3d-graph'))
52
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
54
53
  .linkCurvature('curvature')
55
54
  .linkCurveRotation('rotation')
56
55
  .linkDirectionalParticles(2)
@@ -23,8 +23,7 @@
23
23
  }))
24
24
  };
25
25
 
26
- const Graph = ForceGraph3D()
27
- (document.getElementById('3d-graph'))
26
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
28
27
  .nodeThreeObject(({ id }) => new THREE.Mesh(
29
28
  [
30
29
  new THREE.BoxGeometry(Math.random() * 20, Math.random() * 20, Math.random() * 20),
@@ -24,7 +24,7 @@
24
24
  .onChange(orientation => graph && graph.dagMode(orientation));
25
25
 
26
26
  // graph config
27
- const graph = ForceGraph3D()
27
+ const graph = new ForceGraph3D(document.getElementById('graph'))
28
28
  .backgroundColor('#101020')
29
29
  .linkColor(() => 'rgba(255, 255, 255, 0.6)')
30
30
  .dagMode('lr')
@@ -67,8 +67,7 @@
67
67
  }
68
68
  });
69
69
 
70
- graph(document.getElementById('graph'))
71
- .graphData({ nodes, links });
70
+ graph.graphData({ nodes, links });
72
71
  });
73
72
  </script>
74
73
  </body>
@@ -21,8 +21,7 @@
21
21
  }))
22
22
  };
23
23
 
24
- const Graph = ForceGraph3D()
25
- (document.getElementById('3d-graph'))
24
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
26
25
  .graphData(gData)
27
26
  .linkDirectionalArrowLength(3.5)
28
27
  .linkDirectionalArrowRelPos(1)
@@ -9,8 +9,7 @@
9
9
  <div id="3d-graph"></div>
10
10
 
11
11
  <script>
12
- const Graph = ForceGraph3D()
13
- (document.getElementById('3d-graph'))
12
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
14
13
  .jsonUrl('../datasets/miserables.json')
15
14
  .nodeLabel('id')
16
15
  .nodeAutoColorBy('group')
@@ -16,7 +16,7 @@
16
16
 
17
17
  const elem = document.getElementById("3d-graph");
18
18
 
19
- const Graph = ForceGraph3D()(elem)
19
+ const Graph = new ForceGraph3D(elem)
20
20
  .enableNodeDrag(false)
21
21
  .onNodeClick(removeNode)
22
22
  .graphData(initData);
@@ -31,8 +31,7 @@
31
31
  }))
32
32
  };
33
33
 
34
- const Graph = ForceGraph3D()
35
- (document.getElementById('3d-graph'))
34
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
36
35
  .linkDirectionalParticleColor(() => 'red')
37
36
  .linkDirectionalParticleWidth(4)
38
37
  .linkHoverPrecision(10)
@@ -50,7 +50,7 @@
50
50
  };
51
51
 
52
52
  const elem = document.getElementById('3d-graph');
53
- const Graph = ForceGraph3D()(elem)
53
+ const Graph = new ForceGraph3D(elem)
54
54
  .graphData(getPrunedTree())
55
55
  .linkDirectionalParticles(2)
56
56
  .nodeColor(node => !node.childLinks.length ? 'green' : node.collapsed ? 'red' : 'yellow')
@@ -21,8 +21,7 @@
21
21
  }))
22
22
  };
23
23
 
24
- const Graph = ForceGraph3D()
25
- (document.getElementById('3d-graph'))
24
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
26
25
  .cooldownTicks(100)
27
26
  .graphData(gData);
28
27
 
@@ -9,8 +9,7 @@
9
9
  <div id="3d-graph"></div>
10
10
 
11
11
  <script>
12
- const Graph = ForceGraph3D()
13
- (document.getElementById('3d-graph'))
12
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
14
13
  .jsonUrl('../datasets/miserables.json')
15
14
  .nodeLabel('id')
16
15
  .nodeAutoColorBy('group')
@@ -27,8 +27,7 @@
27
27
 
28
28
  const nodeColorScale = d3.scaleOrdinal(d3.schemeRdYlGn[4]);
29
29
 
30
- const Graph = ForceGraph3D()
31
- (document.getElementById('3d-graph'))
30
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
32
31
  .nodeColor(node => nodeColorScale(node.id))
33
32
  .linkThreeObject(link => {
34
33
  // 2 (nodes) x 3 (r+g+b) bytes between [0, 1]
@@ -40,8 +40,7 @@
40
40
  const highlightLinks = new Set();
41
41
  let hoverNode = null;
42
42
 
43
- const Graph = ForceGraph3D()
44
- (document.getElementById('3d-graph'))
43
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
45
44
  .graphData(gData)
46
45
  .nodeColor(node => highlightNodes.has(node) ? node === hoverNode ? 'rgb(255,0,0,1)' : 'rgba(255,160,0,0.8)' : 'rgba(0,255,255,0.6)')
47
46
  .linkWidth(link => highlightLinks.has(link) ? 4 : 1)
@@ -22,10 +22,9 @@
22
22
  <script type="module">
23
23
  import { CSS2DRenderer, CSS2DObject } from '//unpkg.com/three/examples/jsm/renderers/CSS2DRenderer.js';
24
24
 
25
- const Graph = ForceGraph3D({
25
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'), {
26
26
  extraRenderers: [new CSS2DRenderer()]
27
27
  })
28
- (document.getElementById('3d-graph'))
29
28
  .jsonUrl('../datasets/miserables.json')
30
29
  .nodeAutoColorBy('group')
31
30
  .nodeThreeObject(node => {
@@ -24,8 +24,7 @@
24
24
  }))
25
25
  };
26
26
 
27
- const Graph = ForceGraph3D()
28
- (document.getElementById('3d-graph'))
27
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
29
28
  .nodeThreeObject(({ img }) => {
30
29
  const imgTexture = new THREE.TextureLoader().load(`./imgs/${img}`);
31
30
  imgTexture.colorSpace = THREE.SRGBColorSpace;
@@ -12,7 +12,7 @@
12
12
  <script>
13
13
  const elem = document.getElementById('3d-graph');
14
14
 
15
- const Graph = ForceGraph3D()(elem)
15
+ const Graph = new ForceGraph3D(elem)
16
16
  .jsonUrl('../datasets/blocks.json')
17
17
  .nodeAutoColorBy('user')
18
18
  .nodeLabel(node => `${node.user}: ${node.description}`)
@@ -23,8 +23,7 @@
23
23
  }))
24
24
  };
25
25
 
26
- const graph = ForceGraph3D()
27
- (document.getElementById('3d-graph'))
26
+ const graph = new ForceGraph3D(document.getElementById('3d-graph'))
28
27
  .nodeLabel(node => node.id)
29
28
  .linkColor(link => link.color ? 'red' : 'green' )
30
29
  .linkOpacity(1)
@@ -23,8 +23,7 @@
23
23
 
24
24
  let selectedNodes = new Set();
25
25
 
26
- const Graph = ForceGraph3D()
27
- (document.getElementById('3d-graph'))
26
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
28
27
  .graphData(gData)
29
28
  .nodeRelSize(9)
30
29
  .nodeColor(node => selectedNodes.has(node) ? 'yellow' : 'grey')
@@ -32,8 +32,7 @@
32
32
  const distance = 1400;
33
33
 
34
34
  let isRotationActive = true;
35
- const Graph = ForceGraph3D()
36
- (document.getElementById('3d-graph'))
35
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
37
36
  .enableNodeDrag(false)
38
37
  .enableNavigationControls(false)
39
38
  .showNavInfo(false)
@@ -23,8 +23,7 @@
23
23
  }))
24
24
  };
25
25
 
26
- const Graph = ForceGraph3D()
27
- (document.getElementById('3d-graph'))
26
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
28
27
  .height(window.innerHeight - 60)
29
28
  .graphData(gData);
30
29
 
@@ -23,8 +23,7 @@
23
23
  }))
24
24
  };
25
25
 
26
- const graph = ForceGraph3D()
27
- (document.getElementById('3d-graph'))
26
+ const graph = new ForceGraph3D(document.getElementById('3d-graph'))
28
27
  .graphData(gData);
29
28
 
30
29
  const planeGeometry = new THREE.PlaneGeometry(1000, 1000, 1, 1);
@@ -12,8 +12,7 @@
12
12
  <script type="module">
13
13
  import SpriteText from "//unpkg.com/three-spritetext/dist/three-spritetext.mjs";
14
14
 
15
- const Graph = ForceGraph3D()
16
- (document.getElementById('3d-graph'))
15
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
17
16
  .jsonUrl('../datasets/miserables.json')
18
17
  .nodeLabel('id')
19
18
  .nodeAutoColorBy('group')
@@ -12,8 +12,7 @@
12
12
  <script type="module">
13
13
  import SpriteText from "//unpkg.com/three-spritetext/dist/three-spritetext.mjs";
14
14
 
15
- const Graph = ForceGraph3D()
16
- (document.getElementById('3d-graph'))
15
+ const Graph = new ForceGraph3D(document.getElementById('3d-graph'))
17
16
  .jsonUrl('../datasets/miserables.json')
18
17
  .nodeAutoColorBy('group')
19
18
  .nodeThreeObject(node => {
@@ -22,7 +22,7 @@
22
22
 
23
23
  // graph config
24
24
  const NODE_REL_SIZE = 1;
25
- const graph = ForceGraph3D()
25
+ const graph = new ForceGraph3D(document.getElementById('graph'))
26
26
  .dagMode('td')
27
27
  .dagLevelDistance(200)
28
28
  .backgroundColor('#101020')
@@ -69,8 +69,7 @@
69
69
  }
70
70
  });
71
71
 
72
- graph(document.getElementById('graph'))
73
- .graphData({ nodes, links });
72
+ graph.graphData({ nodes, links });
74
73
  });
75
74
  </script>
76
75
  </body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "3d-force-graph",
3
- "version": "1.73.5",
3
+ "version": "1.74.0",
4
4
  "description": "UI component for a 3D force-directed graph using ThreeJS and d3-force-3d layout engine",
5
5
  "type": "module",
6
6
  "unpkg": "dist/3d-force-graph.min.js",
@@ -47,10 +47,10 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "accessor-fn": "1",
50
- "kapsule": "1",
50
+ "kapsule": "^1.16",
51
51
  "three": ">=0.118 <1",
52
52
  "three-forcegraph": "1",
53
- "three-render-objects": "^1.29"
53
+ "three-render-objects": "^1.32"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/core": "^7.26.0",
@@ -59,12 +59,12 @@
59
59
  "@rollup/plugin-commonjs": "^28.0.1",
60
60
  "@rollup/plugin-node-resolve": "^15.3.0",
61
61
  "@rollup/plugin-terser": "^0.4.4",
62
- "postcss": "^8.4.47",
62
+ "postcss": "^8.4.49",
63
63
  "rimraf": "^6.0.1",
64
- "rollup": "^4.24.3",
64
+ "rollup": "^4.28.0",
65
65
  "rollup-plugin-dts": "^6.1.1",
66
66
  "rollup-plugin-postcss": "^4.0.2",
67
- "typescript": "^5.6.3"
67
+ "typescript": "^5.7.2"
68
68
  },
69
69
  "engines": {
70
70
  "node": ">=12"