diff options
author | Kirill Rogovoy <[email protected]> | 2021-07-23 16:41:09 +0300 |
---|---|---|
committer | Kirill Rogovoy <[email protected]> | 2021-07-23 16:41:09 +0300 |
commit | 7f3943439a7a5e20df1cca1578140a25eb973ad0 (patch) | |
tree | d7c00989db05c87ee948c4fa0ef05abd02ae0aa2 /pages/index.tsx | |
parent | c20eff6f40a994945f8b24d095c4f6f2f270c925 (diff) |
Bring physics back
Diffstat (limited to 'pages/index.tsx')
-rw-r--r-- | pages/index.tsx | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/pages/index.tsx b/pages/index.tsx index ff3f8d0..da00d0a 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -645,10 +645,31 @@ export const Graph = function (props: GraphProps) { ;(async () => { const fg = threeDim ? graph3dRef.current : graph2dRef.current const d3 = await d3promise - // fg.d3Force('x', null) - // fg.d3Force('y', null) - fg.d3Force('collide', d3.forceCollide().radius(10)) - // fg.d3Force('charge').strength(1) + if (physics.gravityOn) { + fg.d3Force('x', d3.forceX().strength(physics.gravity)) + fg.d3Force('y', d3.forceY().strength(physics.gravity)) + if (threeDim) { + if (physics.galaxy) { + fg.d3Force('x', d3.forceX().strength(physics.gravity / 5)) + fg.d3Force('z', d3.forceZ().strength(physics.gravity / 5)) + } else { + fg.d3Force('x', d3.forceX().strength(physics.gravity)) + fg.d3Force('z', d3.forceZ().strength(physics.gravity)) + } + } else { + fg.d3Force('z', null) + } + } else { + fg.d3Force('x', null) + fg.d3Force('y', null) + threeDim ? fg.d3Force('z', null) : null + } + fg.d3Force('link').strength(physics.linkStrength) + fg.d3Force('link').iterations(physics.linkIts) + physics.collision + ? fg.d3Force('collide', d3.forceCollide().radius(20)) + : fg.d3Force('collide', null) + fg.d3Force('charge').strength(physics.charge) })() }) @@ -766,9 +787,9 @@ export const Graph = function (props: GraphProps) { linkWidth: physics.linkWidth, linkDirectionalParticleWidth: physics.particlesWidth, - // d3AlphaDecay: physics.alphaDecay, - // d3AlphaMin: physics.alphaMin, - // d3VelocityDecay: physics.velocityDecay, + d3AlphaDecay: physics.alphaDecay, + d3AlphaMin: physics.alphaMin, + d3VelocityDecay: physics.velocityDecay, onNodeClick: onNodeClick, onBackgroundClick: () => { |