Hey!
So… I’m having a bit of an issue when it comes to InstancedMeshes, or at least my usage of them.
I’m implementing an LOD system, which means that I am constantly discarding and adding InstancedMesh instances.
Sometimes, the instances end up being invisible. I would have said that the problem was a bug in how I was handling my asynchronous removal/addition of instances, and that the instance was actually getting fully removed somehow. Except that I can raycast to it, as seen in the attached screenshot, where I am selecting the invisible instance.
I should also note the following:
-
I have set up a check for the determinant of all instance matrices. Nothing bad has shown up so far.
-
The issue appears to be random - I feed in the same transformation data to the same InstancedMesh and sometimes it works and sometimes it doesn’t.
-
The issue is on a per-instance basis, so sometimes one instance might not show while another from the same InstancedMesh does.
-
When I update the InstancedMesh (For example, by dragging one of the instances with TransformControls), all missing instances in the InstancedMesh re-appear. This leads me to believe that the problem might have to do with the instanceMatrix.needsUpdate flag.
Any ideas?