-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.html
44 lines (36 loc) · 1.41 KB
/
test.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
<!doctype html>
<html>
<head>
<title>Test</title>
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no,user-scalable=no,maximum-scale=1">
<script src="bower_components/aframe/dist/aframe-v0.2.0.min.js"></script>
</head>
<body>
<a-scene id="main-scene">
<!-- Global Settings -->
<a-sky color="#d81159"></a-sky>
<a-plane height="50" width="50" material="color: #982384" rotation="-90 0 0" position="0 0 0"></a-plane>
<a-camera position="0 1.7 6" active="true" near=".05">
<a-entity cursor="fuse: true; fuseTimeout: 500"
position="0 0 -.5"
geometry="primitive: circle; radius: .005"
material="color: black; shader: flat">
</a-entity>
</a-camera>
<a-entity id="box" cursor-listener geometry="primitive: box" material="color: blue"></a-entity>
</a-scene>
<script>
// Component to change to random color on click.
AFRAME.registerComponent('click-color-change', {
init: function () {
var COLORS = ['red', 'green', 'blue'];
this.el.addEventListener('cursor-click', function () {
var randomIndex = Math.floor(Math.random() * COLORS.length);
this.setAttribute('material', 'color', COLORS[randomIndex]);
console.log('I was clicked!');
});
}
});
</script>
</body>
</html>