Introducing: CSG2

The old CSG class was made of pure JS (it was a port from GitHub - evanw/csg.js: Constructive solid geometry on meshes using BSP trees in JavaScript) and while it served us, it was not maintained and not usable anymore. We are now encouraging everyone to switch the new CSG2 class.

CSG2 is built on top of Manifold and can produce very neat booleans.
How to port:
https://doc.babylonjs.com/breaking-changes#porting-from-csg-to-csg2

Documentation:
Merging Meshes | Babylon.js Documentation

Interestingly it is also supported in NGE :slight_smile:

Examples:


Babylon.js Playground


glTF Loader Demo | Babylon.js Playground

20 Likes

love to start try it @Deltakosh

2 Likes

Tell me what you think about it!!

3 Likes

THAT IS WOW AS FIRST RESULT :smile: I am trying more

@Deltakosh i be far from forum for a while i wish can back to community again
that can be good stuff for that

3 Likes

OMG :star_struck: It is fast: https://playground.babylonjs.com/?snapshot=refs/pull/15713/merge#IW43EB#16

It seems like dynamic-holes-in-walls kind of fast. Previously major lag after a few holes. Now, as long as you give it some time between each hole, 60fps!!

Oooh and look at this: vertex count much better too!

8 Likes

i dont see the ole in yoiur sample

1 Like

yes this is CRAZY fast :slight_smile:

2 Likes

Yes the topography is FAR better and the perf is crazy!!

2 Likes

can you find the problem for me that look not work for me?

1 Like

Seems good to me:

(I hid the original meshes though)

2 Likes

i will try tommorow in office :slight_smile:

1 Like

look like we have small normal problem
is that way we have some customization function for new faces?

1 Like

It’s great. I’m going to use it to make a hole in the ground with a desired shape.
Great new features.

3 Likes

what do you mean?

1 Like

the normal look like used from substracted face that must be calculate again

1 Like

The toMesh function allows you to ask the system to recompute the normals:

{
    /**
     * Rebuild normals (false by default)
     */
    rebuildNormals: boolean;
    /**
     * True to center the mesh on 0,0,0. True by default
     */
    centerMesh?: boolean;
}

(But you can also ask for it with mesh.createNormals())

2 Likes

very cool. i saw you starred the manifold repository a few days ago. i went there then and went down a massive rabbit hole for hours and hours. really great addition that solves a lot of non-trivial problems!

3 Likes

Master, your connection to the Force is truly remarkable. I am honored to learn from you and witness such mastery. You remind me of the limitless potential the Force grants us when we seek harmony within it.

In my words: this f**king rocks!!!

those cubes!! O - M - G !

Thank you!!

1 Like

Can’t agree more! i was so happy to find it (And I know the guy who created it so even easier if questions)

4 Likes

That’s amazing! It means that it will be possible to make any meshes destructible without having to pre-create the pieces they will break into. For example, if I want a watermelon to shatter into pieces when it hits the floor, it can break into a random number of pieces and crack in random places each time. I think I already know how I will use this in my demo game.

1 Like