-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboxes-moving.html
69 lines (59 loc) · 2.25 KB
/
boxes-moving.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
<!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 () {
var colors = ['orange', '#4CC3D9', '#EF2D5E', '#FFC65D']
this.el.addEventListener('click', function (evt) {
console.log("Box triggered");
var color = colors[Math.floor(Math.random()*colors.length)];
this.setAttribute('material', 'color', color);
})
}
})
</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>
</a-assets>
<a-box cursor-listener sound="on: click; src: #click-sound" position="-1 2 -3" color="#4CC3D9" shadow>
<a-animation attribute="position"
from="-1 2 -3"
to="-1 2.1 -3"
repeat="indefinite"
direction="alternate">
</a-animation>
</a-box>
<a-box cursor-listener sound="on: click; src: #click-sound" position="0 0.75 -3" color="#EF2D5E" shadow>
<a-animation attribute="position"
from="0 0.85 -3"
to="0 0.75 -3"
repeat="indefinite"
direction="alternate">
</a-animation>
</a-box>
<a-box cursor-listener sound="on: click; src: #click-sound" position="1.25 1.5 -3" color="#FFC65D" shadow>
<a-animation attribute="rotation"
dur="10000"
fill="forwards"
to="360 360 0"
repeat="indefinite">
</a-animation>
</a-box>
<a-plane position="0 0 -4" rotation="-90 0 0" width="8" height="8" color="#9eef37" shadow></a-plane>
<a-sky color="black"></a-sky>
<a-camera>
<a-cursor color="white">
</a-cursor>
</a-camera>
</a-scene>
</body>
</html>