forked from skllpr/swamphacks-gator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
131 lines (115 loc) · 3.59 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
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<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/aframe-look-at-component@0.8.0/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 src="https://cdn.jsdelivr.net/npm/microsoft-cognitiveservices-speech-sdk@latest/distrib/browser/microsoft.cognitiveservices.speech.sdk.bundle-min.js"></script>
<script src="./voice.js"></script>
</head>
<body style="margin: 0; overflow: hidden;">
<a-scene
vr-mode-ui="enabled: true"
embedded
arjs="sourceType: webcam; debugUIEnabled: false;"
>
<!--<a-text
value = "Hello World ;)"
look-at="[gps-camera]"
scale="2 2 2"
></a-text>
-->
<a-camera rotation-reader> </a-camera>
</a-scene>
<script>
function handlePermission() {
navigator.permissions.query({name:'geolocation'}).then(function(result) {
if (result.state == 'granted') {
report(result.state);
//geoBtn.style.display = 'none';
} else if (result.state == 'prompt') {
report(result.state);
//geoBtn.style.display = 'none';
navigator.geolocation.getCurrentPosition(revealPosition,positionDenied,geoSettings);
} else if (result.state == 'denied') {
report(result.state);
//geoBtn.style.display = 'inline';
}
result.onchange = function() {
report(result.state);
}
});
}
function report(state) {
console.log('Permission ' + state);
}
handlePermission();
/*function successGeo() {
console.log("successfully got geoperm")
}
function failGeo() {
console.log("fail geo")
}
*/
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
var dataObj;
fetch("https://f3bd2dd3a5b9.ngrok.io/getdata", requestOptions)
.then(response => response.json())
.then(result => {console.log(result);
dataObj = result.data;
})
.catch(error => console.log('error', error));
window.onclick = function() {
// navigator.geolocation.getCurrentPosition(successGeo, failGeo);
document.querySelector('a-camera').setAttribute('gps-camera', 'minDistance:20;');
allData = [
{
message: "Mal's place",
latitude: "29.667063",
longitude: "-82.353258"
},
{
message: "Sohil's Place",
latitude: "29.654000",
longitude: "-82.345630"
},
{
message: "Gabe's crib",
latitude: "29.6134112,",
longitude: "-82.3634220"
},
{
message: "",
latitude: "1",
longitude: "32323"
}//,...
]
dataObj.forEach(element => { /// look up syntax
console.log(element);
let scene = document.querySelector('a-scene');
let newText = document.createElement('a-text');
let latitude = element.latitude;
let longitude = element.longitude;
let value = element.message;
console.log(value);
let location = document.createAttribute('gps-entity-place');
location.value ='latitude: '+ element[0]+ '; longitude: ' + element[1];
newText.setAttributeNode(location);
newText.setAttribute('value', element[2]);
newText.setAttribute('look-at', "[gps-camera]");
newText.setAttribute('scale', {x: 8, y: 8, z: 8});
scene.appendChild(newText);
})
}
</script>
</body>
</html>