Can I shrink a mesh based on a value?

Hey !
Ok this time no repo because it’s kind of a theory problem. Ca we scale a mesh in order to have a kind of margin all around the “shrinked” mesh. I have tried with the scaling option but it’s not working at all. I have tried a lot of math on the scaling side.
An example of what I want :


I know on simple meshes scaling would work but on more complicated ones it hasn’t for now.
here is how I calculate my ratios for the scaling:

[“x”, “y”, “z”].forEach(function(e){
var min = self.getMinSizeOriented(e); //basicly boundingbox.minimum
var max = self.getMaxSizeOriented(e); //asicly bounginfbox.maximum
var size = max - min;
var value = 1 - (2 * self.shrinkDistance)/size
ratios[e] = value >= 0 ? value : 1;
});

Hi @Jiraph
I think you can just scale it by square root of your “target” surface area?

PG contains function

setSurfaceArea( mesh , targetSurfaceArea )
mesh - the mesh to scale
targetSurfaceArea - Scale nb, 0.5 = half original surface area, 1 = original, 2 = double

I don’t really understand what you do here but I need to do this but without using the scale option… Because on non convex elements the scale option doesn’t apply a margin but just scales down the element. The final objective to this is to be able to get only the margin of a mesh like here : image

Here is an example where it doesn’t work :
image

the base mesh is :
image

I misunderstood then :slight_smile:
I thought you wanted to shrink your mesh based on some surface area ratio like your first image.

Something in the code for parallel outlines might help Line2D of Given Width - Babylon.js Documentation