-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
71 lines (61 loc) · 1.94 KB
/
index.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<title>Freesound Graph</title>
<meta name="description" content="">
<meta name="theme-color" content="#000000">
<style>
body {
margin: 0;
overflow: hidden;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="src/webAudioApiForDesigners.js"></script>
<script src="//unpkg.com/force-graph"></script>
<!--<script src="../../dist/force-graph.js"></script>-->
</head>
<body>
<div id="graph"></div>
<script>
const NODE_R = 10;
var elem = document.getElementById('graph');
// Audio
var context = initializeNewWebAudioContext();
var playingSound; // keep track of playing sound to stop it
function playSound(d) {
// load and play sound
context.loadSound(d.url, '0');
playingSound = context.playSound('0');
}
function stopSound() {
// stop playing sound
if (playingSound) {
playingSound.pause();
}
}
function onNodeHover(node) {
if (node) {
elem.style.cursor = 'pointer';
stopSound();
playSound(node);
} else {
elem.style.cursor = null;
stopSound();
}
}
$.getJSON("json/example_small_graph.json", function(graph) {
}).then(data => {
const Graph = ForceGraph()(elem)
.backgroundColor('#101020')
.nodeRelSize(NODE_R)
.nodeLabel(node => `${node.name}: ${node.tags}`)
.nodeAutoColorBy('group')
.linkColor(() => 'rgba(255,255,255,0.2)')
.onNodeHover(node => onNodeHover(node))
.graphData(data)
});
</script>
</body>
</html>