-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboxes-audio.html
62 lines (53 loc) · 2.09 KB
/
boxes-audio.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello, WebVR! - A-Frame</title>
<meta name="description" content="Hello, WebVR! - A-Frame">
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
<script src="https://unpkg.com/aframe-animation-component/dist/aframe-animation-component.min.js"></script>
<script>
AFRAME.registerComponent('cursor-listener', {
init: function () {
this.el.addEventListener('click', function (evt) {
console.log(this.id);
if (this.id === 'adabox') {
console.log("Box triggered");
this.setAttribute('sound', { src: '#ada' });
}
})
}
})
</script>
</head>
<body>
<a-scene>
<a-assets>
<audio id="click-sound" crossorigin="anonymous" src="https://cdn.aframe.io/360-image-gallery-boilerplate/audio/click.ogg"></audio>
<audio id="ada" crossorigin="anonymous" src="https://ucarecdn.com/59427ee4-49d5-4983-b79b-410ec846f5f9/"></audio>
</a-assets>
<a-box id="adabox" src="images/ada1.jpg" scale="1 1 0" cursor-listener sound="on: click; src: #click-sound" position="-1 2 -3" shader="flat" shadow>
<a-animation attribute="position"
from="-1 2 -3"
to="-1 2.1 -3"
repeat="indefinite"
direction="alternate">
</a-animation>
</a-box>
<a-box src="images/margaret.jpg" scale="1 1 0" cursor-listener sound="on: click; src: #click-sound" shader="flat" position="1 2.75 -3" shadow>
<!-- <a-animation attribute="position"
from="1 2.85 -3"
to="1 2.75 -3"
repeat="indefinite"
direction="alternate">
</a-animation> -->
</a-box>
<a-plane position="0 0 -4" rotation="-90 0 0" width="8" height="4" color="#6625b4" shadow></a-plane>
<a-sky color="black"></a-sky>
<a-camera>
<a-cursor color="white">
</a-cursor>
</a-camera>
</a-scene>
</body>
</html>