In our project, we are currently working on optimizations using Batch groups. So I add meshes instances using the same material in a same group.
But when we are launching the project, only one mesh of the group is displayed (rendered ?) (and this is everytime the last mesh I added to the group which is visible).
The things very important I think is that we got a main menu with which allow the player to select a scene.
When we are choosing a scene, a script will find all the models of the scene with a specific tag (for example “Scene1”), and load all these models.
The code bellow show you how we load a choosen scene :
this.start.enabled = false;
const oldHierarchy = this.app.root.findByName('Root');
const scene = this.app.scenes.find("Scene" + Utils.selectedMission);
const self = this;
// Load both the hierarchy and scene settings
self.app.scenes.loadSceneHierarchy(scene.url, function (err, parent) {
if (!err) {
self.app.scenes.loadSceneSettings(scene.url, function (err, parent) {
if (!err) {
oldHierarchy.destroy();
} else {
console.error(err);
}
});
} else {
console.error(err);
}
});
If you have a response for this issue, that would be great. We search for many hours without finding any solution.
Thanks in advance,
Thanks for your response !
I already tried dynamic batching and it does not worked. But i’ll try tomorrow using static models to if there any changes on the render.
const oldHierarchy = this.app.root.findByName('Root');
const scene = this.app.scenes.find("Scene1");
const self = this;
oldHierarchy.destroy(); // destroy here so batch group are ok
self.app.scenes.loadSceneHierarchy(scene.url, function (err, parent)
{
if (!err)
self.app.scenes.loadSceneSettings(scene.url, function (err, parent)
{
if (err)
console.error(err);
});
else
console.error(err);
});
If destroy is later, the batch group doesn’t work!
const oldHierarchy = this.app.root.findByName('Root');
const scene = this.app.scenes.find("Scene1");
const self = this;
self.app.scenes.loadSceneHierarchy(scene.url, function (err, parent)
{
if (!err)
self.app.scenes.loadSceneSettings(scene.url, function (err, parent)
{
if (err)
console.error(err);
else
oldHierarchy.destroy(); // destroy here, batch group are NOT ok
});
else
console.error(err);
});