@@ -3,6 +3,7 @@ import * as d3 from 'd3'; // Import D3 libraries here
3
3
import ForceGraph3D from '3d-force-graph' ; // Import 3d-force-graph library here
4
4
import dat from 'dat.gui' ; // Import dat.gui library here
5
5
import '../stylesheets/Inspect.scss' ;
6
+ import { CSS2DRenderer , CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js' ;
6
7
7
8
const Inspect = ( ) => {
8
9
useEffect ( ( ) => {
@@ -13,12 +14,14 @@ const Inspect = () => {
13
14
. onChange ( orientation => graph && graph . dagMode ( orientation ) ) ;
14
15
15
16
// graph config
16
- const NODE_REL_SIZE = 5 ;
17
- const graph = ForceGraph3D ( )
17
+ const NODE_REL_SIZE = 8 ;
18
+ const graph = ForceGraph3D ( {
19
+ extraRenderers : [ new CSS2DRenderer ( ) ]
20
+ } )
18
21
. width ( 1000 )
19
22
. height ( 500 )
20
23
. dagMode ( 'td' )
21
- . dagLevelDistance ( 50 )
24
+ . dagLevelDistance ( 100 )
22
25
. backgroundColor ( '#101020' )
23
26
. linkColor ( ( ) => 'rgba(255,255,255,0.2)' )
24
27
. nodeRelSize ( NODE_REL_SIZE )
@@ -27,6 +30,7 @@ const Inspect = () => {
27
30
. nodeLabel ( 'path' )
28
31
. nodeAutoColorBy ( 'module' )
29
32
. nodeOpacity ( 0.9 )
33
+ . nodeLabel ( 'path' )
30
34
. linkDirectionalParticles ( 2 )
31
35
. linkDirectionalParticleWidth ( 1 )
32
36
. linkDirectionalParticleSpeed ( 0.006 )
@@ -35,7 +39,8 @@ const Inspect = () => {
35
39
. d3VelocityDecay ( 0.3 ) ;
36
40
37
41
// Decrease repel intensity
38
- graph . d3Force ( 'charge' ) . strength ( - 15 ) ;
42
+ graph . d3Force ( 'charge' ) . strength ( - 500 ) ;
43
+
39
44
40
45
41
46
fetch ( 'http://localhost:1111/api/data' )
@@ -88,7 +93,15 @@ const Inspect = () => {
88
93
node , // lookAt ({ x, y, z })
89
94
3000 // ms transition duration
90
95
) ;
91
- } ) ;
96
+ } )
97
+ . nodeThreeObject ( ( node ) => {
98
+ const nodeEl = document . createElement ( 'div' ) ;
99
+ nodeEl . textContent = node . path ;
100
+ nodeEl . style . color = node . color ;
101
+ nodeEl . className = 'node-label' ;
102
+ return new CSS2DObject ( nodeEl ) ;
103
+ } )
104
+ . nodeThreeObjectExtend ( true ) ;
92
105
93
106
94
107
} ) ;
0 commit comments