-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
121 lines (114 loc) · 4.33 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>AWE GEO AR demo</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
<meta charset="utf-8"/>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
#container {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
overflow: hidden;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript" src="awe-loader-min.js"></script>
<script type="text/javascript">
window.addEventListener('load', function() {
// initialize awe after page loads
window.awe.init({
// automatically detect the device type
device_type: awe.AUTO_DETECT_DEVICE_TYPE,
// populate some default settings
settings: {
container_id: 'container',
fps: 30,
default_camera_position: { x:0, y:0, z:0 },
default_lights:[
{
id: 'point_light',
type: 'point',
color: 0xFFFFFF
},
],
},
ready: function() {
// load js files based on capability detection then setup the scene if successful
awe.util.require([
{
capabilities: ['gum','gyro','webgl'],
files: [
[ 'awe-standard-dependencies.js', 'awe-standard.js' ], // core dependencies for this app
'awe-standard-window_resized.js', // window resize handling plugin
'awe-standard-object_clicked.js', // object click/tap handling plugin
'awe.geo_ar.js', // geo ar plugin
],
success: function() {
// limit demo to supported devices
// NOTE: only Chrome and Firefox has implemented the DeviceOrientation API in a workable way
// so for now we are excluding all others to make sure your first experience is a happy one
var device_type = awe.device_type();
var browser_unsupported = false;
if (device_type != 'android') {
browser_unsupported = true;
} else if (!navigator.userAgent.match(/chrome|firefox/i)) {
browser_unsupported = true;
}
if (browser_unsupported) {
document.body.innerHTML = '<p>This demo currently requires a standards compliant Android browser (e.g. Chrome M33).</p>';
return;
}
// setup and paint the scene
window.awe.setup_scene();
// setup some code to handle when an object is clicked/tapped
window.addEventListener('object_clicked', function(e) {
var p = awe.projections.view(e.detail.projection_id);
awe.projections.update({ // rotate clicked object by 180 degrees around x and y axes over 10 seconds
data:{
animation: {
duration: 10,
},
rotation:{ y: p.rotation.y+180, x: p.rotation.x+180 }
},
where:{ id:e.detail.projection_id }
});
}, false);
// add some points of interest (poi) for each of the compass points
awe.pois.add({ id:'east', position: { x:Math.random()*360, y:-100, z:0 } });
// add projections to each of the pois
awe.projections.add({
id:'n',
geometry:{ shape:'plane', width:100*0.7, height:150*0.7 },
rotation:{ x:0, y:90, z:0 },
texture: { path: "kiwi.png" },
material:{
type: 'phong',
color:0xFFFFFF,
},
}, { poi_id: 'east' });
},
},
{ // else create a fallback
capabilities: [],
files: [],
success: function() {
document.body.innerHTML = '<p>This demo currently requires a standards compliant mobile browser (e.g. Firefox on Android). NOTE: iOS does not currently support WebGL or WebRTC and has not implemented the DeviceOrientation API correctly. Please see <a href="http://lists.w3.org/Archives/Public/public-geolocation/2014Jan/0000.html">this post to the W3C GeoLocation Working Group</a> for more detailed information.</p>';
return;
},
},
]);
}
});
});
</script>
</body>
</html>