Setting the Mesh invisible, my instances from that Mesh do also disappear

I set the visibility of my objects to false after instancing, but the instances do also disappear.
y?
lines 477-479

I got that advise previously to do so, and here it does work:

What do I do differently?

Basically I do want to hide the Source Mesh.

Thx.
Werner

Maybe @cedric or @sebavan can help here?

Thx. would be great. Do i do something wrong in the code?
I am also getting some warnings creating the instances in the debugger. Might that be the issue?

It looks like the mesh is made invisible before all instances are rendered.

Though this small trick of mine does not really work here. There must be a better way to commit all these instances before making the source mesh invisible. I’m sure one of the Guys called in will have the answer so I won’t bother trying myself. But I guess with this small test it already makes it clear that the instances do not show because the source mesh is hidden before they all have been created. At least, I guess so :thinking:

Right.
If I do the visible&invisible in the Inspector via the eye icon, it does work.
So there might be something like the order of execution.

I noticed that you’re creating the instances right away but you wait for 20 frames to finish creating the meshes (that’s why there’s a warning in the console about creating instances from meshes without geometry). So I moved your init code so that it runs right away, before creating the instances, instead of waiting 20 frames, and then it seems to be working. :slight_smile:

3 Likes

Wow. Thanks so much blake!
Amazing!!

Sometimes I get this

88logger.ts:103 BJS - [14:57:00]: Instances should only be created for meshes with geometry.

Is this coming up if the array for the vertices is empty and I try to create instances?

1 Like

Your welcome and yep, once you call applyToMesh to apply the geometry data (positions, indices, etc) then you should be ready to create instances. :slight_smile:

3 Likes