Hello forum!
I was optmizing the VRAM used on Apple devices. Here is the problem.
I unloaded the textureassets used by the render in the first scene when they get the ‘destroy’ call. And load them when initialize after change back to the first scene. Scripts are shown below.
var SceneAssetsManager = pc.createScript('sceneAssetsManager');
SceneAssetsManager.attributes.add("asetsManaged", { type: "asset", array: true });
SceneAssetsManager.prototype.initialize = function () {
for (var i = 0; i < this.asetsManaged.length; i++) {
if (this.asetsManaged[i] != undefined) {
this.app.assets.load(this.asetsManaged[i]);
}
}
this.entity.on('destroy',
function () {
for (var i = 0; i < this.asetsManaged.length; i++) {
if (this.asetsManaged[i] != undefined) {
this.asetsManaged[i].unload();
}
}
}.bind(this)
);
};
The problem is, when I change back to the first scene. I see all the textures correctly. But I can not bake the lightmap any more. I even try write thing like bake the lightmap when press the keyboard to see if it is because it’s not fully initialize. But it takes no effect either.
After, I tried load them before the scene is loaded. It works, but no help with the VRAM optmization becasues these assets should not take up the VRAM in the scene.
I guess it’s something with lightmaped info initialize. Any suggestions?