Render Wireframe over Mesh broken with parenting

In the inspector certain entities such as Mesh present Debug->“Render Wireframe over Mesh” as an option.

If it is turned on it also affects all children of the mesh, not only the mesh itself.

The clone of the mesh to be given a wireframe is here:

Babylon.js/meshPropertyGridComponent.tsx at 2b8856eed2256524e62fdc827bb0f537f57e3168 · BabylonJS/Babylon.js · GitHub)

It calls clone without saying not to clone children.

Note that the cloned children are not hidden and they do not show a wireframe.
In my code it even produced a bug since a child was an instance buffer and something was broken. The instances doesn’t even support wireframe rendering (on the instance at least).

I think the call to clone should have a doNotCloneChildren = true as a parameter.

Furthermore; I haven’t been able to visualize normals for an instance at all on a per-mesh level. There is an option on the source mesh itself but it doesn’t do anything. Enabling wireframe mode on the scene does work though.

I think you’re right for the “wireframe over” functionality, this PR will correct that:

Regarding the visualize normals, are you speaking of “Display normals” or “Render vertex normals”?
“Render vertex normals” is available on both the master and instance meshes and does work for me.

“Display normals” is only available on the master mesh because it is a material change and the master + instances share the same material. When enabled on the master mesh, it does work on the instance too:

(the sphere on the right is an instance of the sphere on the left)

If you are speaking of “wireframe over mesh” not available for an instance, it’s because it works by creating a clone of the mesh + setting a special material, but as said above an instance can’t have a different material than its master mesh (a clone of an instance is still an instance).

Note that:

Enabling wireframe mode on the scene does work though

works because it simply changes all the materials of the scene by wireframe materials, so when the material of the master is updated it also impacts its instances.

First; quick fix of the inspector issue! Looks awesome!

I think what I was surprised about is that the only way I could get “Render wireframe over mesh” to work for instances was to do it for the entire scene. While the option is not there for the instances themselves it is there on the source mesh, but it has no effect. But this might be expected and I am happy that I found the option on the entire scene!

I thought that setting “Render wiremesh” on the source mesh would affect the instances but no biggie!

I think you are speaking of this when enabling wireframe at the scene level:
It’s not the same thing than “Render wireframe over mesh”: the latter is displaying wireframe over existing mesh (it does this by cloning the mesh + setting a specific material), whereas the former renders all meshes as wireframes (it does this by setting the wireframe property of all materials of the scene to true).

You can simulate what setting wireframe at the scene level does by setting “Wireframe” on in the material used by your mesh/instances.

Ah that makes sense. You are right, they are different! Thanks for clearing that up and also thanks for fixing the clone-bug!