-
Notifications
You must be signed in to change notification settings - Fork 293
/
index-three.html
49 lines (43 loc) · 1.69 KB
/
index-three.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<head>
<style> body { margin: 0; } </style>
<script type="importmap">{ "imports": {
"react": "https://esm.sh/react",
"react-dom": "https://esm.sh/react-dom/client"
}}</script>
<script type="module">
import * as React from 'react';
window.React = React;
</script>
<script src="//unpkg.com/react-force-graph-vr" defer></script>
<!--<script src="../../src/packages/react-force-graph-vr/dist/react-force-graph-vr.js" defer></script>-->
</head>
<body>
<div id="graph"></div>
<script src="//unpkg.com/@babel/standalone"></script>
<script type="text/jsx" data-type="module">
import { createRoot } from 'react-dom';
import * as THREE from '//esm.sh/three';
import { genRandomTree } from '../datasets/random-data.js';
createRoot(document.getElementById('graph')).render(
<ForceGraphVR
graphData={genRandomTree(100)}
nodeThreeObject={({ id }) => new THREE.Mesh(
[
new THREE.BoxGeometry(Math.random() * 20, Math.random() * 20, Math.random() * 20),
new THREE.ConeGeometry(Math.random() * 10, Math.random() * 20),
new THREE.CylinderGeometry(Math.random() * 10, Math.random() * 10, Math.random() * 20),
new THREE.DodecahedronGeometry(Math.random() * 10),
new THREE.SphereGeometry(Math.random() * 10),
new THREE.TorusGeometry(Math.random() * 10, Math.random() * 2),
new THREE.TorusKnotGeometry(Math.random() * 10, Math.random() * 2)
][id%7],
new THREE.MeshLambertMaterial({
color: Math.round(Math.random() * Math.pow(2, 24)),
transparent: true,
opacity: 0.75
})
)}
/>
);
</script>
</body>