Parallelize model loading

This commit is contained in:
Fuhrmann 2025-05-05 09:58:58 +02:00
parent 5a5656109e
commit ec68fccaa3

View file

@ -22,14 +22,16 @@ export async function buildMeshes(
mappedFeatures: MappedFeature[], mappedFeatures: MappedFeature[],
model: Group model: Group
) { ) {
for (let i = 0; i < mappedFeatures.length; i++) { const meshPromises = mappedFeatures.map(async (layerData) => {
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;
} }
model.add(mesh); model.add(mesh);
} });
await Promise.all(meshPromises);
} }
async function buildMesh(layerData: MappedFeature) { async function buildMesh(layerData: MappedFeature) {