How to create meshes for a street network?

I’ve been working on generating meshes for the streets in Cryptovoxels. So instead of having one big ground plane, I’ll have geometry with a street, road markings, and a raised footpath on each side of the street. I have a json array with all the street coordinates in 2d, and what I’ve been doing is creating boxes that extrude those lines into 3d, then using CSG to merge the meshes and generate a city-wide streetmap. However, I’ve found this is far too slow to use in realtime, since the CSG merging seems to be o(n^2). So I’ve got two options:

  • Precompute the street geometry and slice it into a grid of meshes
  • Do something else clever I haven’t thought of

Is there some better solution to this that I’m missing?

Looks like you’re describing modular workflow. This will allow you to easily get tiles (example).

About the how-to in BJS, it seems a bit complex (LOD, loading only tiles near user, etc).

I would use :

  • a logical data map describing all street networks and all the objects in this map
  • one or more SPS to display only the objects in the camera area, then I would recycle the solid particles to render the upcoming objects when the camera moves.

example : Test Babylon SP Terrain
You can fly endlessly above the terrain. The objects are just depicted in a logical map : a blue box here, a yellow sphere there, etc. There are more than 80K in the map.
A SPS is used, built with only 3000 solid particles from the expected types : boxes, spheres, etc. When the camera enters in the object area, it’s rendered with a recycled solid particle from its type.

The computation time is reduced and is fixed as only 3000 particles maximum are computed each frame. Only their location/rotation/scaling/color/texture change, not their geometry.

2 Likes

Ah thanks team. I’m going to try pre-generate the street map and page it in using a tiling system. The modular workflow and SPS look like good hints. I’ll try and write up my progress once it’s done :slight_smile: