index.html 853 B

12345678910111213141516171819202122232425262728293031
  1. <head>
  2. <style> body { margin: 0; } </style>
  3. <script src="//unpkg.com/three"></script>
  4. <script src="//unpkg.com/three-spritetext"></script>
  5. <script src="//unpkg.com/3d-force-graph"></script>
  6. <!--<script src="../../dist/3d-force-graph.js"></script>-->
  7. </head>
  8. <body>
  9. <div id="3d-graph"></div>
  10. <script>
  11. const Graph = ForceGraph3D()
  12. (document.getElementById('3d-graph'))
  13. .jsonUrl('../datasets/miserables.json')
  14. .nodeAutoColorBy('group')
  15. .nodeThreeObject(node => {
  16. const sprite = new SpriteText(node.id);
  17. sprite.material.depthWrite = false; // make sprite background transparent
  18. sprite.color = node.color;
  19. sprite.textHeight = 8;
  20. return sprite;
  21. });
  22. // Spread nodes a little wider
  23. Graph.d3Force('charge').strength(-120);
  24. </script>
  25. </body>