Capping clipped meshes with textured faces

I came across this topic from last year https://forum.babylonjs.com/t/how-to-display-clipped-thininstances-boxes-as-solid/51661 which describes a method of “capping” clipped meshes in the scene.

I am trying to replicate something similar but with textures, not just colors. My requirement also does not need to support instancing like the original post, just individual meshes loaded from GLBs

I have a current solution similar to the stencil plane example from the forum post above that supports a texture, but I have other processes making use of the stencil buffer right now that complicates things. It also gets in the way of picking clipped meshes accurately if Im trying to pick based the “capped” side of the mesh.

So in short, Im looking for a way to “cap” clipped meshes and have the rendered cap display the same texture as the mesh without needing to rely on the stencil buffer (similar to the final solution in the above post but with texture support)

Thanks as always for any help.

You can do it this way to see the inside of the mesh and keeping the texture:

However, I don’t see a way to calculate texture coordinates to make it appear as a “cap”…

Hm alright. Thank you for the example, I’ll see if I can get my stencil cap to cooperate with picking then.