Cube Mesh Disappear on Camera Rotate?

So I built this voxel chunk editor thing. I have this problem where some cubes disappear when the camera is rotated or zoomed. I’m assuming this is trivial and easy to diagnose, but failing that I’ll make a playground or something. Thanks🙏

After camera rotation vvv

Interesting. So without a repro I can just guess so here are some ideas:

  • Flag your voxels as mesh.alwaysSelectAsActiveMesh = true
  • Try to call computeWorldMatrix(true)

Idea #1 is probably the more promising but a Playground will definitely help

3 Likes

Yep, idea #1 fixed it.

alwaysSelectAsActiveMesh

True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
https://doc.babylonjs.com/api/classes/babylon.instancedmesh#alwaysselectasactivemesh

2 Likes

For posterity’s sake, the source of my problem was that I was calling material.freeze() on my cube meshes…

1 Like

Ha yeah good catch!