How to scale cut plane d translation with rotation?

Hi there,

I’ve been looking into cut planes, and so far so good with the basics. However, I’ve got a bit stuck on trying to add an x + y rotation combined with a z translation with a visible plane.

The translations of the cut plane work great, but it looks like during my translation I need to scale the d value - in my current example whenever I apply an x and y rotation, the visible plane has an unwanted offset. I’m not sure how to remove the visible offset and I’m guessing it’s a scaling issue. I’m not sure how to remove it.

I’m using the following playground as a guide to get me going: https://www.babylonjs-playground.com/#Y6W087#68

Thanks for any help or guidance you can give :slight_smile:

Well, it’s hard to help without a repro that fails. You should try to provide a repro where things don’t work as expected so that we can have a look.

It fails in the playground :slight_smile: try the sliders and you ll see that both planes do not match when moving them.

Indeed!

The problem comes from the fact that the normals should be normalized after they have been transformed:

https://www.babylonjs-playground.com/#Y6W087#69

3 Likes

Long live the king @Evgeni_Popov !!! :slight_smile: GG

2 Likes

Thank you so much @Evgeni_Popov and @sebavan - that works perfectly! I got completely muddled up were the normalisation was supposed to be. Thanks :slight_smile:

@Evgeni_Popov and @sebavan - sorry to bug you both again.

The above example is brilliant, but I’ve managed to get stuck again.

Is there a way to rotate the cut plane at its translated position? At the moment, like in the above example, when you translate along the z, the rotation point remains to be at the scene.clipPlane3.normal vector. I’d like to move the rotation point to where the cut plane has been translated to. So that the rotation pivots about the visible plane?

Thanks again for all your help, any guidance would be greatly appreciated :slight_smile:

I don’t really understand what you want to achieve…

It seems it’s not related to clip planes anymore but it’s more a math question? In that case, maybe @JohnK will know what you want to do(?)

Thank you @Evgeni_Popov, sorry it’s not very clear. This is all still new to me so appreciate your help so far :slight_smile:

Hi all,

First off, I just wanted to say a huge thanks to @Evgeni_Popov and @sebavan. You’ve always gone above and beyond to show me the way. It’s a learning curve, but a good one!

I’ve finally managed to pick the above back up to see if I can further my understanding (I thought I had the maths but failed). I’ve been experimenting with the above to see how to implement cut sections with models that are off-centred in world space. Similar to the question above, but the model position is (50, 100, 1000) instead of (0,0,0).

I’ve made some progress. I’ve managed to get the Z translation and X rotation to mostly work (apart from the visible plane flipping/spinning behaviour).

The block I’ve run into is how to get the Y rotation to work with the new model coordinate. I’m guessing I’ve taken the wrong approach, and at this point, my brain keeps going round in circles.

Can anyone see where I’m going wrong? https://www.babylonjs-playground.com/#Y6W087#112

Green slider mostly works (x-rotation) as intended (excluding the visible plane flipping behaviour, not sure how to fix that either)

Red slider, no luck. I’m trying to apply the y-rotation (like the example here: https://www.babylonjs-playground.com/#Y6W087#69)

The blue slider works (z-translation).

I’m experimenting to see if I can get the cut rotations to happen in the centre of the model, instead of the world space. So it feels more fluid.

Thanks for any guidance/help :slight_smile:

Playground

It seems it does it:

https://www.babylonjs-playground.com/#Y6W087#118

You can use plane.transform to apply a transform to the plane (here a translation).

1 Like

Thanks @Evgeni_Popov, that’s awesome! Learnt something new again. Thanks for your help :slight_smile: