@yaustar
he … going to checkout everything again today
… so i do get network errors (more than it used to) … it happens sometimes when i press play. but after a reload i don’t see any network errors anymore nor do i get it in the situation when the materials stay black.
the problem is not reproduceable for the same textures. allthough i don’t know the exact names given the error message i do see that it varies among very different textures.
as i pointed out the project is very complex, messy and was created over a long ammount of time. it is absolutly possible that i miss something since i’m throwing around arrays with dozens of textures, meshes, pbr materials and what not like i’ve gone totally crazy.
i need to point out that i’m not a coder. so this feels like show off my dirty underwear but this is how i load the textures:
SuperSecret.prototype.loadTextures = function() {
self = this;
this.materialLoadCounter = 0;
var tAssets = new Array(0);
var aCount = 0;
//materials base,bio1,bio2,caps & civ have beend picked out of a material array previously but not loaded yet
this.texturePool.push(this.base.data.aoMap, this.base.data.diffuseMap, this.base.data.emissiveMap, this.base.data.normalMap, this.base.data.opacityMap, this.base.data.heightMap);
this.texturePool.push(this.bio1.data.aoMap, this.bio1.data.diffuseMap, this.bio1.data.emissiveMap, this.bio1.data.normalMap, this.bio1.data.opacityMap, this.bio1.data.heightMap);
this.texturePool.push(this.bio2.data.aoMap, this.bio2.data.diffuseMap, this.bio2.data.emissiveMap, this.bio2.data.normalMap, this.bio2.data.opacityMap, this.bio2.data.heightMap);
this.texturePool.push(this.caps.data.aoMap, this.caps.data.diffuseMap, this.caps.data.emissiveMap, this.caps.data.normalMap, this.caps.data.opacityMap, this.caps.data.heightMap);
this.texturePool.push(this.civ.data.diffuseMap);
//not entirely sure why i did this loop in the first place - it cleanses the 'null' i get from empty texture slots
//think i could not use the type material.data returns to locate textureassets with .find() hence .get()
this.texturePool.forEach(function(tp) {
var tex = this.app.assets.get(tp);
if (tex !== undefined) {
tAssets.push(tex);
}
});
//this loop loads the textures by their id's that have been pushed from texturePool[] into tAssets[]
//with a callback to loadMaterials() which does what it is named after
tAssets.forEach(function(ta) {
ta.ready(function() {
aCount++;
if (aCount == tAssets.length) {
self.loadMaterials();
}
});
//loading. this is where i get the error. adding conditions !ta.loading && !ta.loaded prevents the error message
//but seemingly results in black materials / missingn textures
if (!ta.loading && !ta.loaded) {
this.app.assets.load(ta);
}
});
//i only have a vague idea why i needed this though doesn't fire anymore.
if (tAssets.length === 0) {
self.loadMaterials();
}
};
this is how i unload textures from vram:
//this happens in a different script as a part of a reset process and can only be triggered after loading is finished
//i just remove all the textures wich i have tagged carefully in editor - doublechecked for correct tagging several times now
var delAssets = [];
delAssets = this.app.assets.findByTag('dynamic');
for(del = 0; del < delAssets.length; del++){
delAssets[del].unload();
}
not sure if you can make something out of it but if you see something stupid or obvious let me know. without unloading the textures the whole thing works out just fine.
to give you a bit more context - i’m loading a bunch of spheres which get different materials radomly. i used asset registry/load so i can load the textures when they are needed so the app loads fast. every sphere also has a neat preloader. this is why everything is going in sequence. i avoid to fire load requests for all assets i need at the same time but one after another.
tldr - it’s complicated
…