InstancedMesh rendering after freezing active meshes

#1

I have a question about freezing active meshes if some of them are instances.

I’ve made a PG example in which I create an instance of a mesh and put it outside of the frustum. Then with some timeout I set the alwaysSelectAsActiveMesh property of this instance to true and immediately after that freeze active meshes list.
As a result, the instance is not rendered, although it appears in the active meshes list.

From what I’ve seen in the code, this happens because when the mesh gets frozen, it stops calculating render list for it’s instances and uses a previousBatch for it:

if (this._instanceDataStorage.isFrozen && this._instanceDataStorage.previousBatch) {
    return this._instanceDataStorage.previousBatch;
}

The problem is, previousBatch doesn’t contain the instance, because by that time it was not rendered as it was out of the frustum and didn’t have the alwaysSelectAsActiveMesh property set to true.

So the main reason this issue occurs is because these two things are done one after another within the same frame:

boxOutOfFrustum.alwaysSelectAsActiveMesh = true;
scene.freezeActiveMeshes();

My question is: is this a bug or it should be like this by design?
Thanks!

Tested on babylonjs v4.1.0-alpha.0

1 Like
#2

Definitely a bug…That should work…
Let me check :slight_smile:

#3

It will be fixed by next nightly :slight_smile:
Thanks a lot!

1 Like