Render meshes before completion of download
This commit is contained in:
parent
c3b5e954a0
commit
b8468a8afb
2 changed files with 11 additions and 7 deletions
|
@ -452,12 +452,14 @@ async function init(container: HTMLElement, modelId = MODEL_ID) {
|
||||||
|
|
||||||
const { renderer, scene, camera, controls } = buildScene(container, extent);
|
const { renderer, scene, camera, controls } = buildScene(container, extent);
|
||||||
|
|
||||||
|
// Start render loop
|
||||||
|
renderer.setAnimationLoop(animate(() => {}));
|
||||||
|
|
||||||
// Build the 3D model
|
// Build the 3D model
|
||||||
const meshes = await buildMeshes(mappedFeatures);
|
|
||||||
const model = new Group();
|
const model = new Group();
|
||||||
model.add(...meshes);
|
|
||||||
model.name = "geologic-model";
|
model.name = "geologic-model";
|
||||||
scene.add(model);
|
scene.add(model);
|
||||||
|
await buildMeshes(mappedFeatures, model);
|
||||||
|
|
||||||
// Add a coordinate grid to the scene
|
// Add a coordinate grid to the scene
|
||||||
const { gridHelper, annotations } = buildCoordinateGrid(extent);
|
const { gridHelper, annotations } = buildCoordinateGrid(extent);
|
||||||
|
@ -489,6 +491,7 @@ async function init(container: HTMLElement, modelId = MODEL_ID) {
|
||||||
map.visible = false;
|
map.visible = false;
|
||||||
scene.add(map);
|
scene.add(map);
|
||||||
|
|
||||||
|
// Update render loop to include topography
|
||||||
const topography = scene.getObjectByName("Topography") as Mesh;
|
const topography = scene.getObjectByName("Topography") as Mesh;
|
||||||
renderer.setAnimationLoop(
|
renderer.setAnimationLoop(
|
||||||
animate(rendererCallback(camera, renderer, scene, map, extent, topography))
|
animate(rendererCallback(camera, renderer, scene, map, extent, topography))
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {
|
||||||
BufferAttribute,
|
BufferAttribute,
|
||||||
BufferGeometry,
|
BufferGeometry,
|
||||||
DoubleSide,
|
DoubleSide,
|
||||||
|
Group,
|
||||||
Mesh,
|
Mesh,
|
||||||
MeshStandardMaterial,
|
MeshStandardMaterial,
|
||||||
} from "three";
|
} from "three";
|
||||||
|
@ -17,18 +18,18 @@ interface MappedFeature {
|
||||||
preview: { legend_color: string; legend_text: string };
|
preview: { legend_color: string; legend_text: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function buildMeshes(mappedFeatures: MappedFeature[]) {
|
export async function buildMeshes(
|
||||||
const meshes = [];
|
mappedFeatures: MappedFeature[],
|
||||||
|
model: Group
|
||||||
|
) {
|
||||||
for (let i = 0; i < mappedFeatures.length; i++) {
|
for (let i = 0; i < mappedFeatures.length; i++) {
|
||||||
const layerData = mappedFeatures[i];
|
const layerData = mappedFeatures[i];
|
||||||
const mesh = await buildMesh(layerData);
|
const mesh = await buildMesh(layerData);
|
||||||
if (layerData.name === "Topography") {
|
if (layerData.name === "Topography") {
|
||||||
mesh.visible = false;
|
mesh.visible = false;
|
||||||
}
|
}
|
||||||
meshes.push(mesh);
|
model.add(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
return meshes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildMesh(layerData: MappedFeature) {
|
async function buildMesh(layerData: MappedFeature) {
|
||||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue