Skip to content

Instantly share code, notes, and snippets.

@nicolocarpignoli
Created November 11, 2019 21:35
Show Gist options
  • Save nicolocarpignoli/2f05816d7338711e436ee4141108ebad to your computer and use it in GitHub Desktop.
Save nicolocarpignoli/2f05816d7338711e436ee4141108ebad to your computer and use it in GitHub Desktop.
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