-
Notifications
You must be signed in to change notification settings - Fork 67
/
scripting.html
76 lines (55 loc) · 1.62 KB
/
scripting.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
72
73
74
75
76
<!doctype HTML>
<html>
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<script src="js/aframe.min.js"></script>
<script src="js/aframe-ar.js"></script>
<body style="margin: 0px; overflow: hidden;">
<script>
AFRAME.registerComponent('updater', {
init: function()
{
// declare variable for later access
this.num = 0;
// you can also access the underlying 3D object of a scene object,
// for example:
// let target = document.querySelector('#earth').object3D;
// target.scale.set( 0.75, 0.75, 0.75 );
},
// time = total time since init (milliseconds)
// timeDelta = time since last tick
tick: function (time, timeDelta)
{
this.num += 1;
// console.log( this.num );
}
});
// access underlying 3D object this component is attached to
AFRAME.registerComponent('spinner', {
init: function()
{
this.el.object3D.scale.set(0.75, 0.75, 0.75);
},
tick: function (time, timeDelta)
{
this.el.object3D.rotation.y += 0.01
}
});
</script>
<a-scene embedded vr-mode-ui="enabled: false;" arjs="debugUIEnabled: false;">
<a-assets>
<img id="earth-sphere" src="images/earth-sphere.jpg" />
</a-assets>
<a-marker type="pattern" url="data/kanji.patt">
<a-sphere
id="earth"
position="0 0.5 0"
material="src: #earth-sphere; transparent: true; opacity: 0.95;"
spinner >
</a-sphere>
</a-marker>
<a-entity camera></a-entity>
<!-- empty entity, running previously declared script -->
<a-entity updater></a-entity>
</a-scene>
</body>
</html>