{
const renderer = new THREE.WebGLRenderer({antialias: true});
const controls = new THREE.OrbitControls(camera, renderer.domElement);
renderer.setSize(width, height);
renderer.setPixelRatio(devicePixelRatio);
invalidation.then(() => (controls.dispose(), renderer.dispose()));
const render = () => { renderer.render(scene, camera); };
controls.addEventListener("change", render);
render();
for (let i = scene.children.length - 1; i >= 0; i--) {
let type = scene.children[i].type
if (type === "Mesh" || type === "Line") {
let mesh = scene.children[i];
scene.remove(mesh);
mesh.geometry.dispose();
mesh.material.dispose();
}
}
const tgeo = new ThreeGeo({
tokenMapbox: tgeoParams.token,
});
tgeo.getTerrain(latlng, tgeoParams.radius, tgeoParams.zoom, {
onVectorDem: (objs) => {
objs.forEach((obj) => { scene.add(obj); });
render();
},
});
return renderer.domElement;
}