-
Notifications
You must be signed in to change notification settings - Fork 19
/
a-frame-dae-smooth-gps.html.bak
201 lines (160 loc) · 6.75 KB
/
a-frame-dae-smooth-gps.html.bak
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<script src="https://aframe.io/aframe/dist/aframe-master.min.js"></script>
<script src="https://cdn.rawgit.com/chrisveness/latlon-geohash/53c3d474/latlon-geohash.js"></script>
<script src="https://cdn.rawgit.com/Esri/html5-geolocation-tool-js/cdd20903/js/GeolocationHelper.js"></script>
<script src="components.js?4:03 28.09.2018"></script>
<script>
var hash_fences = {};
function ce(t,a){ var f = document.createElement(t); for(var k in a) f.setAttribute(k, a[k]); return f; }
function load_hash(d){
hash_fences[d.hash] = d.objects;
for(var i=0; i<d.objects.length; i++){
var
o = d.objects[i],
element_id = 'fence_' + o.id.replace(':', '_')
;
if(!document.getElementById(element_id)){
fences.appendChild( ce(
'a-collada-model',
{
'id': element_id,
'src': 'https://yaglov.ru/cadastre/fence.php?id='+encodeURIComponent(o.id),
'gps-place': 'longitude: '+o.extent.xmin+'; latitude: '+o.extent.ymin,
'transparent-texture': '',
// 'cursor-listener': '',
'data-cn': o.id
}
) );
}
}
}
function toggleFullScreen() {
var doc = window.document;
var docEl = doc.documentElement;
var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
if(!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
requestFullScreen.call(docEl);
} else {
cancelFullScreen.call(doc);
}
}
window.onload = function(){
var camera = document.getElementById('camera');
camera.addEventListener('componentchanged', function (evt) {
switch(evt.detail.name){
case 'rotation':
var newData = evt.target.getAttribute('rotation');
console.log('camera rotation changed', newData);
var
compassRotation = camera.components['compass-rotation'],
lookControls = camera.components['look-controls']
;
camera_angle.innerText = newData.y;
if(lookControls){
yaw_angle.innerText = THREE.Math.radToDeg(lookControls.yawObject.rotation.y);
}
if(compassRotation){
compass_heading.innerText = compassRotation.heading;
}
break;
case 'position':
var newData = evt.target.getAttribute('position');
console.log('camera position changed', newData);
var
gpsPosition = camera.components['gps-position']
;
camera_p_x.innerText = newData.x;
camera_p_z.innerText = newData.z;
if(gpsPosition){
if(gpsPosition.crd){
crd_longitude.innerText = gpsPosition.crd.longitude;
crd_latitude.innerText = gpsPosition.crd.latitude;
var hash = Geohash.encode(gpsPosition.crd.latitude, gpsPosition.crd.longitude, 7);
geohash_7chars.innerText = hash;
if(typeof(hash_fences[hash]) == 'undefined'){
hash_fences[hash] = null;
document.head.appendChild(ce('script', {
src: 'https://yaglov.ru/cadastre/hash.php?hash='+hash+'&callback=load_hash'
}));
}
}
if(gpsPosition.zeroCrd){
zero_crd_longitude.innerText = gpsPosition.zeroCrd.longitude;
zero_crd_latitude.innerText = gpsPosition.zeroCrd.latitude;
}
}
break;
}
});
};
var geoHelper = new GeolocationHelper({
/*
"UNITS" in filters ? this.UNITS = filters.UNITS : this.UNITS = "M"; // M = miles, K = km, N = nautical miles
"MAX_ACCURACY" in filters ? this.MAX_ACCURACY = filters.MAX_ACCURACY : this.MAX_ACCURACY = 100 ;
"MAX_MEDIAN_ACCURACY" in filters ? this.MAX_MEDIAN_ACCURACY = filters.MAX_MEDIAN_ACCURACY : this.MAX_MEDIAN_ACCURACY = 20;
"MAX_STDDEVIATION_ACCURACY" in filters ? this.MAX_STDDEVIATION_ACCURACY = filters.MAX_STDDEVIATION_ACCURACY : this.MAX_STDDEVIATION_ACCURACY = 2.5;
"MAX_STDDEVIATION_LAT" in filters ? this.MAX_STDDEVIATION_LAT = filters.MAX_STDDEVIATION_LAT : this.MAX_STDDEVIATION_LAT = 0.0001;
"MAX_STDDEVIATION_LON" in filters ? this.MAX_STDDEVIATION_LON = filters.MAX_STDDEVIATION_LON : this.MAX_STDDEVIATION_LON = 0.0001;
"MAX_ARRAY_SIZE" in filters ? this.MAX_ARRAY_SIZE = filters.MAX_ARRAY_SIZE : this.MAX_ARRAY_SIZE = 25;
*/
});
function smooth_gps(p){
var np;
geoHelper.process(p.coords.accuracy, p.coords.latitude, p.coords.longitude, p.timestamp, function(locationObject){
np = {
coords: {
accuracy: locationObject.med_accuracy,
latitude: locationObject.center_point.latitude,
longitude: locationObject.center_point.longitude
},
timestamp: p.timestamp
}
})
return np;
}
</script>
</head>
<body style='margin: 0px; overflow: hidden;'>
<div style="position: fixed; top: 10px; width:100%; text-align: center; z-index: 1; text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white;">
<div>
coords: <span id="crd_longitude"></span>, <span id="crd_latitude"></span>
(zero coords: <span id="zero_crd_longitude"></span>, <span id="zero_crd_latitude"></span>)
</div>
<div>
camera coords: <span id="camera_p_x"></span>, <span id="camera_p_z"></span>
</div>
<div>
compass heading: <span id="compass_heading"></span>,
camera angle: <span id="camera_angle"></span>,
yaw angle: <span id="yaw_angle"></span>
</div>
<div>geohash_7chars: <span id="geohash_7chars"></span></div>
</div>
<a-scene><!-- -->
<a-camera id="camera" user-height="1.6" gps-position="position-callback: smooth_gps" compass-rotation>
<a-cursor></a-cursor>
</a-camera>
<a-assets id="assets">
<!--
<a-asset-item id="fence_50_31_0040507_9_asset" src="fence_50_31_0040507_9.dae"></a-asset-item>
<a-asset-item id="fence_50_31_0040507_6_asset" src="fence_50_31_0040507_6.dae"></a-asset-item>
<a-asset-item id="fence_50_31_0040507_16_asset" src="fence_50_31_0040507_16.dae"></a-asset-item>
<a-asset-item id="fence_50_31_0040507_25_asset" src="fence_50_31_0040507_25.dae"></a-asset-item>
-->
</a-assets>
<a-entity id="fences">
<!--
<a-entity id="fence_50_31_0040507_9" collada-model="#fence_50_31_0040507_9_asset" transparent-texture gps-place="longitude: 37.469666813539; latitude: 55.153989996861"></a-entity>
<a-entity id="fence_50_31_0040507_6" collada-model="#fence_50_31_0040507_6_asset" transparent-texture gps-place="longitude: 37.469775988244; latitude: 55.154190366984"></a-entity>
<a-entity id="fence_50_31_0040507_16" collada-model="#fence_50_31_0040507_16_asset" transparent-texture gps-place="longitude: 37.469140087271; latitude: 55.153874109378"></a-entity>
<a-entity id="fence_50_31_0040507_25" collada-model="#fence_50_31_0040507_25_asset" transparent-texture gps-place="longitude: 37.470954400759; latitude: 55.153490379075"></a-entity>
-->
</a-entity>
<a-sky></a-sky>
</a-scene>
</body>
</html>