From ec68fccaa3725187a64b8a1515516ee05f0a8243 Mon Sep 17 00:00:00 2001 From: Thomas Fuhrmann Date: Mon, 5 May 2025 09:58:58 +0200 Subject: [PATCH] Parallelize model loading --- app/three/utils/build-meshes.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/three/utils/build-meshes.ts b/app/three/utils/build-meshes.ts index fb959ae..1b06dd3 100644 --- a/app/three/utils/build-meshes.ts +++ b/app/three/utils/build-meshes.ts @@ -22,14 +22,16 @@ export async function buildMeshes( mappedFeatures: MappedFeature[], model: Group ) { - for (let i = 0; i < mappedFeatures.length; i++) { - const layerData = mappedFeatures[i]; + const meshPromises = mappedFeatures.map(async (layerData) => { const mesh = await buildMesh(layerData); if (layerData.name === "Topography") { mesh.visible = false; } + model.add(mesh); - } + }); + + await Promise.all(meshPromises); } async function buildMesh(layerData: MappedFeature) {