Hello there,
I am doing an aditive load of the diferent scenes of my game. On the tests and on the scenes I have done works perfectly, but I have added new scenes and with these last ones it is not working properly.
Here is the code I am using:
//function that loads aditively
SceneManager.prototype._loadSelectedScene = function () {
if (!this._loadingScene) {
this._loadingScene = true;
// Remove the current scene that is loaded
for (var iterator = 0; iterator < this.sceneRootEntity.children.length; iterator++) {
const i = iterator
this.sceneRootEntity.children[i].destroy();
}
//select the scene to load and make some adjustments for the player
var scene = this.app.scenes.find(this._selectedSceneName);
this.localPlayer.rigidbody.enabled = false;
//start loading the scene
this.app.scenes.loadSceneHierarchy(scene,
(err, loadedSceneRootEntity) => this.OnHierarchyLoaded(scene, err, loadedSceneRootEntity)
);
}
};
//calback function for loading scenes aditively
SceneManager.prototype.OnHierarchyLoaded = function (scene, err, loadedSceneRootEntity) {
if (err) {
console.error(err);
} else {
//reparent the scene
loadedSceneRootEntity.reparent(this.sceneRootEntity);
this.app.scenes.loadSceneSettings(scene, (err) => {
if (err) {
console.error(err);
} else {
//alert("Scene loaded");
this.app.lightmapper.bake(null, 0);
this.app.fire('sceneLoaded', loadedSceneRootEntity);
this.app.fire('TpLoadingScreenOFF')
if (this._selectedSceneName == "Expo") {
this.app.fire('changePopup', 'introExpo')
}
this._loadingScene = false;
this.localPlayer.rigidbody.enabled = true;
this.localPlayer.rigidbody.teleport(SceneManager.Origin);
}
});
}
}
In some scenes the objects are poping after doing the baking of the lights.