-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex_with_logos.html
41 lines (36 loc) · 1.26 KB
/
index_with_logos.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
<head>
<style> body { margin: 0; } </style>
<script src="//unpkg.com/three"></script>
<script src="https://unpkg.com/3d-force-graph"></script>
<script src="//unpkg.com/three/examples/js/renderers/CSS2DRenderer.js"></script>
<!-- <script src="../../dist/3d-force-graph.js"></script>-->
</head>
<body>
<div id="3d-graph"></div>
<script>
const elem = document.getElementById('3d-graph');
const Graph = ForceGraph3D(
{
extraRenderers: [new THREE.CSS2DRenderer()]
}
)(elem)
.jsonUrl('blocks.json')
//.dagMode('radialout')
//.nodeColor(node => node.color)
//.nodeRelSize(3)
.nodeLabel(node => `${node.type}: ${node.name}`)
.linkOpacity(0.2)
.linkAutoColorBy('type')
.linkDirectionalParticles('particles')
.onNodeClick(node => window.open("https://api.llama.fi/protocol/" + node.slug, '_blank'))
.nodeThreeObject(node => {
const nodeEl = document.createElement('img');
nodeEl.src = node.logo
nodeEl.width = 10
nodeEl.height = 10
nodeEl.className = 'node-logo';
return new THREE.CSS2DObject(nodeEl);
})
.nodeThreeObjectExtend(true);
</script>
</body>