-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
48 lines (44 loc) · 1.77 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
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Location Based AR.js demo</title>
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-look-at-component.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"></script>
<script>
let markerInt = 1;
window.onload = () => {
navigator.geolocation.getCurrentPosition((position) => {
document.querySelector('a-text').setAttribute('gps-entity-place', `latitude: ${position.coords.latitude}; longitude: ${position.coords.longitude};`);
});
document.querySelector('html').addEventListener('click', (ev)=> {
navigator.geolocation.getCurrentPosition((position) => {
const marker = document.createElement('a-text');
marker.setAttribute('value', 'Tomatos' + '_' + String(markerInt));
markerInt = markerInt + 1;
marker.setAttribute('scale', '3 3 3');
marker.setAttribute('look-at', '[gps-camera]');
marker.setAttribute('gps-entity-place', `latitude: ${position.coords.latitude}; longitude: ${position.coords.longitude};`);
document.querySelector('a-scene').appendChild(marker);
});
});
}
</script>
</head>
<body style="margin: 0; overflow: hidden;">
<a-scene
vr-mode-ui="enabled: false;"
embedded
arjs="sourceType: webcam; debugUIEnabled: true;"
>
<a-text
value="Cucumbers"
look-at="[gps-camera]"
scale="3 3 3"
></a-text>
<a-camera gps-camera='gpsMinDistance: 1;' rotation-reader> </a-camera>
</a-scene>
<button class="addMarker" type="button">Добавить</button>
</body>
</html>