Any suggestions what could be a reliable way to render a wireframe over generic gltf meshes?
I have looked into the renderWireframeOver()
code that Babylon.js Inspector uses for the “Render wireframe over mesh” option. That clones the mesh to generate a second wireon variant of it. However, this approach fails with rigged meshes, the zero transform parent trick doesn’t reflect all transformations, animations might not be synchronized, and looks like it would get complicated when instanced meshes are involved. Not to mention having to keep track of changes in order to update the wireframe clones if meshes are altered.
Another way I can think of is to bind to one of the scene or render loop observers? So for example bind to onAfterRenderObservable
or maybe onAfterDrawPhaseObservable
. Or even registering to scene step(?) as outlineRenderer seems to do?: Babylon.js/outlineRenderer.ts at 44c29b9180daf9c49634becbb30ac7d626bddb0b · BabylonJS/Babylon.js · GitHub
In latter case I could iterate over the meshes, change the material, possibly also change the index buffer for wireframe specific one and render the same Mesh again. Then restore the original material.
However, that also seems hacky and there are so many possible observers to try this on. So I wanted to ask first if someone has insight what would be the best approach here.