-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsound.html
68 lines (63 loc) · 1.64 KB
/
sound.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anvil.js Lighting Demo</title>
<script src="../build/anvil.js"></script>
</head>
<body>
<canvas id="can" width="800" height="600"></canvas>
<script>
// Pull out the Scene, Polygon, Light, and SceneManager classes from the ANVIL object
const {Scene, Polygon, Light, SceneManager, Sound, SoundEmitterPolygon} = ANVIL;
// get the canvas
const can = document.getElementById("can");
// create a scene with lighting and FPS monitoring enabled
const scene = new Scene({fpsMonitoringEnabled: true});
// Create and add polygons
const polygon1 = new Polygon({
points: [
[
100, 100
],
[
150, 100
],
[
150, 150
],
[
100, 150
]
],
backgroundColor: "#FF0000"
});
const polygon2 = new SoundEmitterPolygon({
points: [
[
200, 200
],
[
250, 200
],
[
250, 250
],
[
200, 250
]
],
backgroundColor: "#00FF00"
},{
source: "song.mp3",
listener: polygon1
});
scene.addObject(polygon1);
scene.treatAsPlayer(polygon1, 5);
scene.addObject(polygon2);
// Create a SceneManager and pass it the canvas and scene
var manager = new SceneManager({canvas: can, initialScene: scene});
</script>
</body>
</html>