How to draw the outline of a selected mesh the way Blender does it?

Hello,

I’m trying to draw the outline of a selected mesh.
As shown in the image below captured in Blender, I want to draw the border of the mesh as is, even if it is obscured by the mesh in front.

I tried two things: https://playground.babylonjs.com/#KRYSHR#1

(1) Using the renderOutline property: Outlines hidden by other meshes are not drawn.

(2) Using HighlightLayer: Outlines surrounding the visible part are drawn, excluding the hidden part.(Comment out line 21 and uncomment line 24)

Is there anyone who can help me?

If you’re ok with all edges showing, you can clone the box, then on the clone make alpha zero, turn on edges, and set renderingGroupId to 1.

Edit: or a similar technique with the highlight layer:

Edit2: renderOutline obeys the material alpha. It’s not immediately obvious to me how to get a transparent box with an opaque outline.

1 Like

here’s a good thread with more iptions:

@HiGreg
Thank you :smiley:

Your answer is very helpful. I was able to achieve the solution using target mesh cloning, renderingGroupId and visibility attribute.

This forum is really awesome! :+1:

3 Likes