Meshes that added to scene after createOrUpdateSelectionOctree get invisible

Attention to lines:

// scene.createOrUpdateSelectionOctree();
BABYLON.MeshBuilder.CreateBox("box", {size: 1}, scene);
// scene.createOrUpdateSelectionOctree();

it’s provide to expected behavior:
image

But when we add a box after createOrUpdateSelectionOctree:

scene.createOrUpdateSelectionOctree();
BABYLON.MeshBuilder.CreateBox("box", {size: 1}, scene);
// scene.createOrUpdateSelectionOctree();

the result is not expected:
image

But it is to exist in the Inspector:

And it’s become visible only after the second run of createOrUpdateSelectionOctree:

scene.createOrUpdateSelectionOctree();
BABYLON.MeshBuilder.CreateBox("box", {size: 1}, scene);
scene.createOrUpdateSelectionOctree();

I didn’t found anything about this behavior in the docs Optimizing With Octrees | Babylon.js Documentation

So, is this a bug, or all is fine?

It’s normal. the first time you create the octree, then you update it each time you add objects.

1 Like