Hey guys,
So my idea is this:
- backend generates heightmap images with perlin noise
- frontend gets an initial chunk (let’s say a 1024*1024 heightmap image)
- frontend generates a terrain with BABYLON.DynamicTerrain.CreateMapFromHeightMapToRef function
- if the player moves past a certain point in direction X, a new chunk is requested from the server (another 1024x1024 heightmap image), and attached to the existing mapdata, making it seem infinite.
In the documentation there is a reference to this kind of behaviour.
This is useful if we have to download dynamically new chuncks of data as the camera moves in the World.
Example :// change the terrain map on the fly
if (camera.position.z > someLimit) {
terrain.mapData = map2;
}
But I just can’t imagine how this would work.
I have to replace the whole mapdata?
Here is an example:
What if the player decides to go 2x1024 in direction X, then 1x1024 in direction Z? (essentially 2 chunks in X direction and 1 chunk in Z direction)
The server would have to generate the initial chunk, 2 to direction X, and 1 to direction Z, forming a letter L with generated chunks.
Now on the server side, I can manage the chunks by giving them coordinates (x,z) (for my example they would be (0,0), (1,0), (2,0), (2,1))
But how would this look with BabylonJS Dynamic Terrain extension?
My initial guess would have been to switch off infinite tiling, and create new instances of dynamic terrain, when walking on a new chunk, but apparently, it’s not a possible solution.