Invisible InstancedMesh Instances


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?


:musical_note: When you’re an idiot and you know it, clap your hands! :musical_note:

Clap! Clap!

:musical_note: When you’re an idiot and you know it, clap your hands! :musical_note:

Clap! Clap!

:musical_note: When you’re an idiot and you know it, and you commented out needsUpdate, if you’re and idiot and you know it clap your hands! :musical_note:

Clap! Clap!

Yeah… It took me more than two days of debugging to find this…

else {
					// Okay, we're good.
					actorModel.count = actorModel.count + 1

					actorModel.setMatrixAt(index, actorMatrix)
					//actorModel.instanceMatrix.needsUpdate = true

					actorModel.userData.actorList[index] = actor

1 Like

hi S41L0R, I read that you used TransformControls for the instantedMesh. I also tried to use TransformControls to move the instancedMesh, but the instancedMesh could not be moved.I want to know if you successfully moved the instancedMesh using transformControls,thanks