Skip to content

Instantly share code, notes, and snippets.

@vasturiano
Last active April 22, 2021 23:29
Show Gist options
  • Select an option

  • Save vasturiano/bcfc5baa9e7998fb97b3091d2499fe16 to your computer and use it in GitHub Desktop.

Select an option

Save vasturiano/bcfc5baa9e7998fb97b3091d2499fe16 to your computer and use it in GitHub Desktop.

Revisions

  1. vasturiano revised this gist Apr 22, 2021. 2 changed files with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion index.html
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    <script src="//unpkg.com/3d-force-graph@1"></script>

    <script src="//unpkg.com/d3-octree"></script>
    <script src="//unpkg.com/d3-force-3d@1"></script>
    <script src="//unpkg.com/d3-force-3d"></script>
    </head>

    <body>
    Binary file modified thumbnail.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  2. vasturiano revised this gist Mar 12, 2018. 2 changed files with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,7 @@
    .d3Force('collide', d3.forceCollide(16))
    .nodeRelSize(8)
    .nodeColor(d => d.type === 'a' ? 'brown' : 'steelblue')
    .enableNodeDrag(false)
    .graphData({ nodes, links: [] })
    (document.getElementById('3d-graph'));
    </script>
    Binary file modified thumbnail.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  3. vasturiano revised this gist Jan 9, 2018. 1 changed file with 1 addition and 6 deletions.
    7 changes: 1 addition & 6 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,5 @@
    <head>
    <style>
    body {
    margin: 0;
    font-family: Sans-serif;
    }
    </style>
    <style> body { margin: 0; } </style>

    <script src="//unpkg.com/3d-force-graph@1"></script>

  4. vasturiano revised this gist Jan 7, 2018. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    3D version of [mbostock](https://bl.ocks.org/mbostock)'s [Radial Force](https://bl.ocks.org/mbostock/cd98bf52e9067e26945edd95e8cf6ef9).

    The two classes of nodes are attracted to a sphere's surface with configured radius of 300px (red) and 600px (blue).

    Uses [3d-force-graph](https://github.com/vasturiano/3d-force-graph) for the ThreeJS/WebGL rendering and [d3-force-3d](https://github.com/vasturiano/d3-force-3d) for the 3D versions of the radial and collision forces.
  5. vasturiano revised this gist Jan 7, 2018. 2 changed files with 0 additions and 0 deletions.
    Binary file added preview.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    Binary file added thumbnail.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  6. vasturiano created this gist Jan 7, 2018.
    33 changes: 33 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <head>
    <style>
    body {
    margin: 0;
    font-family: Sans-serif;
    }
    </style>

    <script src="//unpkg.com/3d-force-graph@1"></script>

    <script src="//unpkg.com/d3-octree"></script>
    <script src="//unpkg.com/d3-force-3d@1"></script>
    </head>

    <body>
    <div id="3d-graph"></div>

    <script>
    const N = 700;
    const nodes = [...Array(N*4).keys()].map((n) => ({ type: n > N ? 'b' : 'a' }));

    ForceGraph3D()
    .d3AlphaDecay(0.01)
    .d3VelocityDecay(0.1)
    .d3Force('charge', null) // Deactivate existing charge
    .d3Force('radial', d3.forceRadial(d => d.type === 'a' ? 300 : 600))
    .d3Force('collide', d3.forceCollide(16))
    .nodeRelSize(8)
    .nodeColor(d => d.type === 'a' ? 'brown' : 'steelblue')
    .graphData({ nodes, links: [] })
    (document.getElementById('3d-graph'));
    </script>
    </body>