CSG Tiles Implementation
Description
as we discussed in #1365 a nice to have for this library, would be to to let users/developers define the possibility of using the boolean operator against the tiles.
in that issue you said that it would be nice a solution using a CSG solution for keeping the terrain while using i.e. a bridge model positioned on the globe.
but I think it would be useful also for tunnels or bigger infrastructures which goes under the terrain.
we could use OBBs of the models, convex decompositions, or eventually even their raw geometry to subtract geometry from the tiles.
you mentioned that you created a CSG library, I still have not tried it yet, but I'd like to try it as soon as I can.
what do you think about this?
Solution
I would create a plugin which with some arguments can do the relative operations.
we could add the CSG library as a dependency, if that something which is suitable for you. or we can just extrapolate from the CSG library only what we really need for tiles geometry subtraction (I don't see any other useful operator, but I could be wrong).
Alternatives
I have no alternatives in mind, maybe the developers could create this feature on their app without modifying the library, using tile events and a custom logic. but I'd prefer a native modular integration.
Additional context
I think that this feature could unlock a big potential for the library, also for a lot of infrastructures projects.
I am available for implementation, testing and improvements if you think we should add this feature!
I think if this is going to be added I'd need to understand a concrete use case that someone is trying to achieve. Are you actually planning to use this for something? Or just interested in adding it? Adding CSG has some inevitable complexities including performance hiccups, possibilities of performing CSG in workers, etc.
but I think it would be useful also for tunnels or bigger infrastructures which goes under the terrain.
we could use OBBs of the models, convex decompositions, or eventually even their raw geometry to subtract geometry from the tiles.
One of the biggest complexities around CSG here is that it cannot be used to perform solid operations on 3d tiles. CSG requires a "water tight" geometry for both the operator and operand geometries. Individual geometries in 3D Tiles data are often not water tight at all, especially in the types of cases you'd want to bore a tunnel through the terrain. Google Photorealistic tiles would not work, for example, since each tile is open at the bottom (non visible).
The best you could get reliably is removing / clipping polygons that are within something like a "tunnel" volume. As far as I know this is an uncommon feature of CSG libraries but it is supported in three-bvh-csg which is why I mentioned "hollow" operations in the previous issue. For some more context:
| SUBTRACTION | HOLLOW_SUBTRACTION |
|---|---|
Notice how the "hollow" approach just removes the polygons without adding surface from the sphere shapes. So the visual effect will not be much different than what's being shown with the geojson clipping, though it would support 3d shape clipping rather than just 2d. So given the number of open questions and complexity I think it would be good for this to live in a separate repository for prototyping until the utility is proven out.
or we can just extrapolate from the CSG library only what we really need for tiles geometry subtraction
I would recommend just using a CSG library directly rather than removing or reimplementing some operations.
Are you actually planning to use this for something? Or just interested in adding it?
honestly for both reasons, I'd like for the platform I am building to eventually support all infrastructures (tunnels, underground stations etc... with a 3D model to display in the correct location), and when the tiles renderer is enabled in order to give more context to the asset I'd like to have this feature. this the use case I imagine. but also to give one more option for what we discussed in that previous issue. I understand maybe this is not a common requested feature, but I am sure someone else would appreciate.
One of the biggest complexities around CSG here is that it cannot be used to perform solid operations on 3d tiles. CSG requires a "water tight" for both the operator and operand geometries. Individual geometries in 3D Tiles data are often not water tight at all, especially in the types of cases you'd want to bore a tunnel through the terrain. Google Photorealistic tiles would not work, for example, since each tile is open at the bottom (non visible).
I understand the limitation you mean now, but in my case I was more thinking about having 3D models georef. so I think that the hollow subtraction could work for what I imagine.
(I like the idea of drilling a tunnel into the ground though 😄 )
I think I will create a separate repository in the coming days, experimenting this.
thank you , I will update you