forked from walaankit/location-based-ar-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
46 lines (40 loc) · 1.34 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
45
46
window.onload = () => {
const params = new URLSearchParams(window.location.search);
var latitude = 22.816;
var longitude = 70.8385;
if (params.has("lat")) {
latitude = params.get("lat");
}
if (params.has("long")) {
longitude = params.get("long");
}
renderPlaces(latitude, longitude);
};
function renderPlaces(latitude, longitude) {
console.log(
"🚀 ~ file: script.js ~ line 15 ~ renderPlaces ~ latitude",
latitude,
longitude
);
let scene = document.querySelector("a-scene");
let model = document.createElement("a-entity");
model.setAttribute(
"gps-entity-place",
`latitude: ${latitude}; longitude: ${longitude};`
);
model.setAttribute("gltf-model", "./assets/pole/pole_v2.gltf");
model.setAttribute("rotation", "270 270 270");
model.setAttribute("animation-mixer", "");
model.setAttribute("scale", "0.3 0.3 0.3");
model.setAttribute("cursor-listener");
model.classList.add("clickable");
// model.setAttribute("position", "0 -2 0");
model.object3D.position.y = -90;
model.addEventListener("loaded", () => {
window.dispatchEvent(new CustomEvent("gps-entity-place-loaded"));
});
model.addEventListener("click", function(evt) {
alert("Model clicked.")
});
scene.appendChild(model);
}