Skip to content

Instantly share code, notes, and snippets.

@vasturiano
Last active September 18, 2019 01:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasturiano/b7c667a15e7e5a72067e12fc99ceaaec to your computer and use it in GitHub Desktop.
Save vasturiano/b7c667a15e7e5a72067e12fc99ceaaec to your computer and use it in GitHub Desktop.
VR Hyperspace

Simulation of random distribution of objects in 3D space after a (big) bang. Rendered in VR using 3d-force-graph-vr. Move around using arrow/wasd keys or a gamepad.

<head>
<script src="//unpkg.com/3d-force-graph-vr@1"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/4.11.0/d3.min.js"></script>
<style>
body {
margin: 0;
font-family: Sans-serif;
}
</style>
</head>
<body>
<script>
const NUM_NODES = 3000;
const nodeScale = d3.scaleLinear().range([0.03, 0.06]);
const nodes = d3.range(NUM_NODES).map(d => ({ id: d, val: nodeScale(Math.random())}));
ForceGraphVR()
.graphData({ nodes, links: [] })
.warmupTicks(50)
.cooldownTicks(0) // Don't animate-in, jump to final state
(document.body);
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment