-
Notifications
You must be signed in to change notification settings - Fork 48
/
ar.html
126 lines (99 loc) · 3.67 KB
/
ar.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<!-- Simple AR
When in mobile (tested in Firefox, Chrome on Android),
point to the AFrame marker, and the objects will appear
in the screen (a red box exactly on the marker, the
other objects a bit behind, according to their Z coordinates).
-->
<html>
<head>
<script src="https://aframe.io/releases/1.4.0/aframe.min.js"></script>
<script src="https://jeromeetienne.github.io/AR.js/aframe/build/aframe-ar.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function (event) {
function brick(el, x, y, z, color) {
var box = document.createElement('a-box');
el.appendChild(box)
box.setAttribute('color', color);
box.setAttribute('rotation', '0 0 0');
box.setAttribute('position', x + ' ' + y + ' ' + z);
var cylinder = document.createElement('a-cylinder');
el.appendChild(cylinder);
cylinder.setAttribute('color', color);
cylinder.setAttribute('rotation', '90 0 0');
cylinder.setAttribute('radius', '0.33');
cylinder.setAttribute('height', '0.5');
cylinder.setAttribute('position', x + ' ' + y + ' ' + (z+0.33));
}
var owlEntity = document.querySelector('#owl');
console.log(owlEntity);
for (var i = 0; i < 2; i++){
brick(owlEntity, 0, -i, -10, '#444');
}
for (var i = 0; i < 3; i++){
brick(owlEntity, 1, -i-0.5, -10, '#444');
}
for (var i = 0; i < 2; i++){
brick(owlEntity, 1, -i-5, -10, '#444');
}
for (var i = 0; i < 3; i++){
brick(owlEntity, 2, -i-1, -10, '#444');
}
for (var i = 0; i < 4; i++){
brick(owlEntity, 2, -i-4.5, -10, '#444');
}
for (var i=0; i < 8; i++){
brick(owlEntity, 3, -i-1.5, -10, '#444')
}
for (var i=0; i < 8; i++){
brick(owlEntity, 4, -i-2, -10, '#444')
}
for (var i=0; i < 8; i++){
brick(owlEntity, 5, -i-1.5, -10, '#444')
}
for (var i = 0; i < 3; i++){
brick(owlEntity, 6, -i-1, -10, '#444');
}
for (var i = 0; i < 4; i++){
brick(owlEntity, 6, -i-4.5, -10, '#444');
}
for (var i = 0; i < 3; i++){
brick(owlEntity, 7, -i-0.5, -10, '#444');
}
for (var i = 0; i < 2; i++){
brick(owlEntity, 7, -i-5, -10, '#444');
}
for (var i = 0; i < 2; i++){
brick(owlEntity, 8, -i, -10, '#444');
}
brick(owlEntity, 2, -2, -9, '#ccc');
brick(owlEntity, 4, -3, -9, '#f90');
brick(owlEntity, 6, -2, -9, '#ccc');
for (var i = 0; i < 3; i++){
brick(owlEntity, 3, -9.5, -9-i, '#f90');
}
for (var i = 0; i < 3; i++){
brick(owlEntity, 5, -9.5, -9-i, '#f90');
}
console.log('Owl done!');
});
</script>
</head>
<body style='margin : 0px; overflow: hidden;'>
<a-scene embedded arjs>
<a-entity location="0 0 0">
<a-entity scale="0.1 0.1 0.1" position="0 1 0.5" id="owl">
</a-entity>
<a-entity text="value: Bitergia; color: orange;" scale="10 10 1" position="3.3 0.65 -0.8">
</a-entity>
<a-plane rotation="-90 0 0" width="1" height="1" color="orange"></a-plane>
<a-animation attribute="rotation"
dur="10000"
fill="forwards"
to="0 360 0"
repeat="indefinite"></a-animation>
</a-entity>
<a-marker-camera preset='custom' type='pattern' url='pattern-marker.patt'></a-marker-camera>
</a-scene>
</body>
</html>