Question about Cylinder mesh

Hey all,
First post here and quite haven’t found what I wanted on the forum…
Ok so recently I started working with BabylonJs, and since now I was a real pleasure.
Today I struggle with a problem that I suspect is based on the basics of mesh creation of the cylinder mesh. I wanted to get a plan cut of a structure I made and I got this :
image
So I do think it’s because non identical diameters cylinders are built of a cone and the invisible part of the building pattern is still presen truining the whole process of plan cutting getting a weird form.
Just to clarify all the shapes are ths same : cylinders with 1.6 top diameter , 0.5 bottom diameter and height.
Since I’ve been working on a huge projet and I am using a lot based of this so I can’t really get a playground working easily sorry :frowning:
Thanks all

1 Like

What do you mean by “plan cutting”? How are you doing it?

Without a repro I think it will be hard to help you…

Here is what I do in a simplified version :
https://playground.babylonjs.com/#3IV74M#2
The red par is what I want and the gray part will be errased.
But In my case the base shape is more complex and I use a whole class to put elements together. In that class I do use Bounding boxes (maximum and minimum) to place elements rigth next to each other.
But in the case of my huge project I get like a small par of the bottom cylinder cut errased…
Thanks :slight_smile:

Have you tried to merge all your meshes (BABYLON.Mesh.MergeMeshes) before applying the csg?

Yes I did !
The process in the playground is the same I use in my project but at a smaller scale.
I also work with Extjs could it be the links between classes ?

I don’t know Extjs so I can’t tell, but I would say it shouldn’t have any effect…

I would say the positionning of the cones + CSG algorithm is the problem indeed, as in your PG, depending on the number of 9 in 4.9999995, it works or not…

What you could do is building your mesh with a lathe instead of two cones, as this way you will directly get a single mesh. The CSG intersection will work better on this mesh:

https://playground.babylonjs.com/#3IV74M#3

Hey again,
Sorry the weekend went by and I tried to refactor all my code again.
The fact is I don’t want to change the draw method of my elements because I use a class that merges elements whatever the type they are. And then I do the “plan cutting” and get the result I showed. I don’t think the 9 are a problem tho because in my code the figure placement is based on their bounding box.
Here I have the same result with a simplified version of the figure. Note this is after a huge refactorisation.
image
And this keeps happening only with the cylinders. I do think, and this was my original question, that cylinders with different diameters are made with cones. And then you substract the excessive “top cone” of the mesh matrix. And my guess is that when you merge those in some way in my code and not on the playground (maybe version) the substraction seems to appear after the merge and not after the cylinder creation.
Is it because there is some kind of delay before deleting, to make sure everything is drawn ? If it’s the case multithreading could be a real problem…
Sorry for the mistakes, I’m a french guy trying to speak english :smiley:
Thanks

Ok since I update my code to be more Js friendly and not ExtJs friendly, it now is mostly on the playground. And the problem occurs. Maybe you can help me better now :slight_smile:
https://playground.babylonjs.com/#3IV74M#4

It’s the CSG algorithm that produces this output because of the input meshes: I think it’s because the base of the top cylinder is not part of the top of the lower cylinder, meaning there are no common vertices.

If you first make a union CSG of the two cylinders and then perform the CSG intersection it does work:

https://playground.babylonjs.com/#3IV74M#6

1 Like

Thanks a lot for your help ! There is still a bit af unknown in this because it worked on the first version of the playground… But it’s fine by now !