I have following scene with csg: https://www.babylonjs-playground.com/#KUM5WC#14
I want to draw only the outside edges and the ones of the holes (In playground it needs very long to load and after a rerun one plate is disappearing, you have to reload the page to work again - outside of playground there is no need to refresh the page).
Changing newMeshHolePlate.enableEdgesRendering(0.001); has no effect
I am sorry but I am having some trouble to understand exactly what you are trying to do but maybe @JohnK or @jerome would have some ideas ? they are both awesome with geometry !!!
Basicly I want this look. Only the Edges, what you would also see with a directional light.
But my goal is that every site it lit the same and that the âhardâ edges are visible / black.
The plate in red is my âstartâ and the plate above is what I want to get.
@sebavan if this is what @Browork wants is there a case for making _edgesRenderer public are might that have unknown knock on effects? Is there an alternative such as setting a parameter somewhere?
Bonus question (Or should I create a seperate question for this?:
I also want to have holes that dont get through or are coming from the side like in this csg example: https://www.babylonjs-playground.com/#KUM5WC#20
Your provided solution worked well for holes that go through, but how could I achieve holes, that dont go through, or are coming from the side?
However, the edge renderer builds the lines of the edges at construction time (in the constructor). So, whenever the geometry changes, the edge renderer must be disposed / re-enabled to have it regenerate the edges. I have done it in the PG, but be aware it can take some time, depending of the number of planes with holes you have.
The split I have done to create the vertices on the border can be improved when the hole is not in the center of the plane. Currently, you get:
The vertices on the border could be dispatched better to avoid having triangles too thin, which can lead to some artifacts with the edge renderer
You will have to perform some deeper changes if you want multiple holes in a plane, and I donât think it is very easy, basically itâs CSG done by hand, even if the shapes are simple and known in advance - one plane and several circles.
Last thing, in the PG you should give a multiple of 4 for numCirclePoints, else you wonât get sharp corners for the plane:
I know the edge drawing from some CAD tools, when you make a hole in it you get the edges drawn so it looks better.
Originally I come from threejs, but the easy to use CSG part brought me to babylonjs.
Is there a way to âfakeâ the edge drawing like with lighting or textures?
But to do this âproperlyâ I should go with planes and holes ?
Its a bit above my understanding, but could you explain the makeHole method?
makeHole(ground1, 10 * 4, cx, cz, r, r, 0.3, false);
Note that using the edges renderer does not work because the CSG processing can produce triangles like this:
There are two triangles, ABC and CDE.
AC is not shared by another triangle, so the renderer considers it to be an edge and draws it.
For this to be rendered correctly by the edges renderer, the triangles EBC and ABE should be created and ABC removed (that needs a tessellation, that may not be easy to do in the general case).
AC is drawn because it is not shared by any triangle, it is an edge of ABC only.
Thatâs the problem: thatâs not because E is between A and C that the system knows EC is part of AC (the system does not know that E is between A and C). For the system, AC and EC are different edges and are from different triangles (ABC for one and CDE for the other).
In your second picture, EC is shared by 2 triangles (CDE and BCE), thatâs why it is not considered an edge to be drawn (and also because the angle between both triangles is small enough).
Iâm currently working on the algorithm to produce the second picture above (you canât see it in the picture, but there was an artifact in the bottom of the box because I did not handle all cases of triangle tessellation).