Using CSG on imported meshes/models

Hey there Babylonians,

I’ve been trying to do CSG on an imported mesh, but it doesn’t seem to work. So my question is: are CSG functions possible between BABYLON meshes and imported/appended meshes…

Thank you!

Look at this link here: Constructive Geometry on Imported Meshes - CSG - Questions & Answers - HTML5 Game Devs Forum

It’s possible but its computationally heavy. There is an example shown here: https://www.babylonjs-playground.com/#XA6F3#10

3 Likes

Yup that works, using:

importedMesh.setVerticesData(BABYLON.VertexBuffer.UVKind, [ ]);

Let’s the CSG operations go through, but you are right it’s computationally heavy, on mobile this would kill my app’s performance.

Thank you for the help!

2 Likes

maybe do the intensive operations like that on a server and then pass the buffer back to the client?

1 Like

That’s a good idea, but It’s sort of an instant feature type of thing, if I had to wait for a server response every time the user did a CSG operation it would be tedious and slow for them to wait around to see the result.

you can see a quick demo here: Boolean Check

This reminds me of slicing software for 3D printing.

That’s what it’s for, I’m trying to come up with different ways to validate 3d models for 3D printing.

:wink: Well lucky for you I already have deployed a product for editing/validating/exporting and printing from the browser. So if you have any more questions you can hit me up in PM’s.

Also if you are just trying to do a slice like that why not use a clipping plane? It would be way faster I would assume.

1 Like

Dude, I will definitely be hitting you up for advice, thank you so much for offering help!

Also I didn’t think of clipping planes, not very familiar with them, any docs you cant point me to?

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

1 Like

:astonished: DANG!!! That’s pretty good and so smooth. Thank you!

That’s from these docs here. Simple google brought it up. Use clip planes - Babylon.js Documentation

Hello I’m a novice about OpenGL and webgl. Thanks for your good answer here. It’s really helpful to me. I have one question. When some model is clipped by a plane, can I get real clipped or sectioned points or line in the model? I mean the red line or points’s coordinate in the attached image. Thanks in advance.

The clipping is done on GPU side so if you want it in JS you will have to get it using the intersection of a plane and the mesh using CSG