I have an apartment picker where each apartment has a hitbox for it’s boundry.
Example
Up until now I have been using edgesRenderer
but there are some problems with it, the performance is not good, when we get up to having 500+ apartments in a model.
and secondly since our models are highly dynamic and is loaded from a custom built cms, i try to calculate the line width dynamically based on the scene size, which in some cases causes the line width to be a bit large which causes the edges to split, showing that it is not a line on the edge, but triangles for each side x 2.
So I’m on a quest to try to find a better way to draw the unit outlines.
When babylon 7 was released I saw that there is something new called greaselines.
Would grease lines be a better solution for me?
Would they be more performant than edgesRenderer?
When creating the greaselines using GreasedLineTools.MeshesToLines
can I specify that it doesn’t create lines for flat surfaces?
I would like it to behave the same way edges renderer works
I do think performance-wise GreasedLine has better performance. They do serve different usecase though. I guess there is a way to achieve edge-rendering using lines, it will just require a bit of custom work
which accepts a second parameter called predicate which is a callback function where you can decide whether to include the lines of the face being processed or not or to return an array of points whihch will be included a used to draw a line or lines:
p1,p2,p3 are the positions of the face being processed. We have a ton of information available so we can do I think whatever checks we need to decide which line gets included. We can calc the dot product of two vectors and according to its value include or drop the line:
Example for a box:
EDIT: this is not a full solution, it just shows how you can deal with predicates when using MeshesToLines
But IMHO the boundig box approach will be better in your case because your meshes may have a lot of faces which will match the predicate. In our digital twin app we create picker meshes in Blender. We position these picker meshes on the areas we want to be selectable and simply draw lines around the selected picker mesh.
Finally had some time to do a lab on GreaseLines and edges.
I ported over the EdgesGeometry algorithm from three to babylon, so that you can select at what angle you want the edges to appear.
it also works with rotated meshes, because it’s based on the normals of each vertex. (i think)
And together with the new any excellent GreaseLine material I was able to get the look I was after.
The grease lines materials possibility to making the edges the same size independant of scene size and closeness to the camera also makes for a better experience.
I have not yet tested performance on larger scenes, but will report back my findings