-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
38 lines (32 loc) · 1.02 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
window.onload = () => {
let places = staticLoadPlaces();
renderPlaces(places);
};
function staticLoadPlaces() {
return [
{
name: 'Magnemite',
location: {
lat: 33.511409,
lng: -86.812054,
}
},
];
}
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('rotation', '0 180 0');
model.setAttribute('animation-mixer', '');
model.setAttribute('scale', '0.5 0.5 0.5');
model.addEventListener('loaded', () => {
window.dispatchEvent(new CustomEvent('gps-entity-place-loaded'))
});
scene.appendChild(model);
});
}