index.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <head>
  2. <style> body { margin: 0; } </style>
  3. <script src="//unpkg.com/3d-force-graph"></script>
  4. <!--<script src="../../dist/3d-force-graph.js"></script>-->
  5. </head>
  6. <body>
  7. <div id="3d-graph"></div>
  8. <script>
  9. const gData = {
  10. nodes: [...Array(14).keys()].map(i => ({ id: i })),
  11. links: [
  12. { source: 0, target: 1, curvature: 0, rotation: 0 },
  13. { source: 0, target: 1, curvature: 0.8, rotation: 0 },
  14. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 1 / 6 },
  15. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 2 / 6 },
  16. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 3 / 6 },
  17. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 4 / 6 },
  18. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 5 / 6 },
  19. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI },
  20. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 7 / 6 },
  21. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 8 / 6 },
  22. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 9 / 6 },
  23. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 10 / 6 },
  24. { source: 0, target: 1, curvature: 0.8, rotation: Math.PI * 11 / 6 },
  25. { source: 2, target: 3, curvature: 0.4, rotation: 0 },
  26. { source: 3, target: 2, curvature: 0.4, rotation: Math.PI / 2 },
  27. { source: 2, target: 3, curvature: 0.4, rotation: Math.PI },
  28. { source: 3, target: 2, curvature: 0.4, rotation: -Math.PI / 2 },
  29. { source: 4, target: 4, curvature: 0.3, rotation: 0 },
  30. { source: 4, target: 4, curvature: 0.3, rotation: Math.PI * 2 / 3 },
  31. { source: 4, target: 4, curvature: 0.3, rotation: Math.PI * 4 / 3 },
  32. { source: 5, target: 6, curvature: 0, rotation: 0 },
  33. { source: 5, target: 5, curvature: 0.5, rotation: 0 },
  34. { source: 6, target: 6, curvature: -0.5, rotation: 0 },
  35. { source: 7, target: 8, curvature: 0.2, rotation: 0 },
  36. { source: 8, target: 9, curvature: 0.5, rotation: 0 },
  37. { source: 9, target: 10, curvature: 0.7, rotation: 0 },
  38. { source: 10, target: 11, curvature: 1, rotation: 0 },
  39. { source: 11, target: 12, curvature: 2, rotation: 0 },
  40. { source: 12, target: 7, curvature: 4, rotation: 0 },
  41. { source: 13, target: 13, curvature: 0.1, rotation: 0 },
  42. { source: 13, target: 13, curvature: 0.2, rotation: 0 },
  43. { source: 13, target: 13, curvature: 0.5, rotation: 0 },
  44. { source: 13, target: 13, curvature: 0.7, rotation: 0 },
  45. { source: 13, target: 13, curvature: 1, rotation: 0 }
  46. ]
  47. };
  48. const Graph = ForceGraph3D()
  49. (document.getElementById('3d-graph'))
  50. .linkCurvature('curvature')
  51. .linkCurveRotation('rotation')
  52. .linkDirectionalParticles(2)
  53. .graphData(gData);
  54. </script>
  55. </body>