Problem with scaling the meshes and clip plane

Hello everyone

I have a vertically clip plane on Y axis. the clip plane work correctly at the scale 1, but when I scaling all the meshes in the scene, the clip plane work wrong.

here you can see the clip plane is working perfect:
chrome-capture (10)

and then when I scaling all the meshes and also clip plane it doesn’t section correctly.
chrome-capture (11)

How can I solve this problem?

here is my PG: https://www.babylonjs-playground.com/#Y21CI9#1

So something with scaling it in the grouping you are doing is not working correctly (aka scaling root). When I go and scale the individual meshes in the inspector it does not do this.

1 Like

I don’t think the issue comes from the way you’re scaling your group, everything seems to be resized as it should be.
But as @msDestiny14 pointed out, scaling the children (only ‘boxes’) is a possible workaround, see in this playground.
The cliping works fine, but then the plane2 object doesn’t have the right amplitude (from the cube’s top to bottom).

Your real issue is that it’s not plane2 that’s cliping your object (that’s merely an indicator you created), it’s clipPlane2. And while plane2.parent has been set to your root object (line 50), and thus scales down as expected as you’re sliding down, the clipPlane2 doesn’t. It’s not in the group, why should it ?
Proof is that when scaled at 0.5, the inner box starts being cliped at about this sliding point here :


And if you only scale back to 1 :

That’s exactly where plane2 (meaning clipPlane2) was in space.

So if the workaround I mentionned doesn’t do the trick for you, the solution would be to reposition dynamically your clipPlane2 object in your observable according to scale changing, or have the slider move plane2 along the Ys and then make clipPlane2 be wherever plane2 is.
I would have tried it out but I’m getting a little confused with your really huge positions and dimensions, I think you’ll know your way around better than me. :slight_smile: Anyway, hope to have helped !

2 Likes

thanks a lot for your Explanation :pray:. You are right, but I am a little confused , how should I reposition dynamically my clipPlane2 correctly?

my huge positions and dimensions its because I am working on a GIS 3D APP.

Hi @msDestiny14 Thank you so much for answering to my question :pray:, you are right, but I cannot found the problem.

1 Like

I’ll have a look.

I still don’t understand what exactly is happening in your onValueChangedObservable function around lines 86-94 (I think you shouldn’t use clipPlane2 to set plane2.position).

An example of what I meant by that is on this new playground here, it should be close to what you want (solution on line 111).

1 Like

Thanks a lot for your helping. Its Great :pray: