Created
November 11, 2019 21:35
-
-
Save nicolocarpignoli/2f05816d7338711e436ee4141108ebad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = () => { | |
let places = staticLoadPlaces(); | |
renderPlaces(places); | |
}; | |
function staticLoadPlaces() { | |
return [ | |
{ | |
name: 'Magnemite', | |
location: { | |
lat: 44.496470, | |
lng: 11.320180, | |
} | |
}, | |
]; | |
} | |
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); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment