From memory something like, for example, the scene data will contain a render components reference to a material, but not the material’s reference to a texture. This can be found from processing the material asset in the asset registry.
1 Like
Ok I got it working now! Thank you very much for the help!
I did implement the loading of material/model/render a bit different tho.
When loading the scene data I check the type of the item and if it is a material, model or render component. I call the processItem function again, with the data of it. This way I only need to iterate the scene registry.
LoadScene.prototype.processItem = function (item) {
let type = (typeof item);
if (type === 'object') {
if (Array.isArray(item)) {
this.processArray(item);
}
else {
this.processObject(item);
}
}
else if (type === 'number') {
// Check if the number matches an asset ID in the asset registry.
let asset = this.app.assets.get(item);
if (asset) {
if (!this.requiredAssets.includes(item)) {
this.requiredAssets.push(item);
if (asset.type === "material" || asset.type === "model" || asset.type === "render" || asset.type === "template") {
this.processItem(asset.data);
}
}
}
}
};
1 Like
Also asset.type === "template"
should be processed as well or else if you have a script referencing a template which is not part of the scene. It wont load the meshinstances.
I’ve added it in my script above
1 Like