wip faster texture loading
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user