wip faster texture loading

This commit is contained in:
David Allemang
2026-07-04 12:16:34 -04:00
parent a00d8c52d7
commit 57660397aa
5 changed files with 94 additions and 52 deletions

View File

@@ -94,7 +94,7 @@ export class Engine {
};
this.atlasTexture = gl.createTexture();
this.atlas = new TextureAtlas(512);
this.atlas = new TextureAtlas(256);
this.dioramas = [];
this.renderRequested = false;
@@ -160,6 +160,7 @@ export class Engine {
}
// 2. Build geometries & instantiate WebGL buffers
const load_tasks = [];
const newMeshes = [];
for (const [hash, pool] of instancePool.entries()) {
const modelJSON = await loadModel(pool.partDef.model);
@@ -167,7 +168,7 @@ export class Engine {
for (const el of modelJSON.elements || []) {
for (const face of Object.values(el.faces || {})) {
const texPath = resolveTexture(modelJSON, face.texture);
if (texPath) await this.atlas.load(texPath);
if (texPath) load_tasks.push(this.atlas.load(texPath));
}
}
@@ -179,7 +180,8 @@ export class Engine {
newMeshes.push(this.createInstancedMesh(geometry, instanceCount, matrixArray, colorArray));
}
this.updateAtlasTexture();
await Promise.all(load_tasks)
this.updateAtlasTexture()
return newMeshes;
}