-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
44 lines (37 loc) · 1.07 KB
/
script.js
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
window.onload = () => {
let places = staticLoadPlaces();
renderPlaces(places);
};
function staticLoadPlaces() {
return [
{
name: 'Magnemite',
location: {
lat: 50.917052,
lng: 6.039957,
}
},
{
name: 'Magnemite',
location: {
lat: 50.951011,
lng: 5.797295,
}
},
];
}
function renderPlaces(places) {
let scene = document.querySelector('a-scene');
places.forEach((place) => {
let latitude = place.location.lat;
let longitude = place.location.lng;
let model = document.createElement('a-entity');
model.setAttribute('gps-entity-place', `latitude: ${latitude}; longitude: ${longitude};`);
model.setAttribute('gltf-model', './assets/magnemite/scene.gltf');
model.setAttribute('scale', '0.2 0.2 0.2');
model.addEventListener('loaded', () => {
window.dispatchEvent(new CustomEvent('gps-entity-place-loaded'))
});
scene.appendChild(model);
});
}