This PR drastically changes the way the Terrain interacts with the IVoxelMap.
The Terrain now asks for chunks of the map when needed.
The IVoxelMap now only requires one method:
getLocalMapData(from: Vector3Like, to: Vector3Like): Promise<ILocalMapData>;
that returns the data for a portion of the map.
The ILocalMapData is defined as follows:
/** Compact object storing a portion of the map data */
interface ILocalMapData {
/** Compact array storing the voxel data.
* Each element in the array represent a coordinate in the map and stores the data of the voxel at these coordinates.
* An element:
* - should be equal to 0 if there is no voxel at these coordinates
* - should be equal to the voxel's material id + 1 if there is a voxel at these coordinates
*
* The elements should be ordered by coordinates as follow by Z first, then Y then X.
* For example, for a portion of the map between (0,0,0) and (2,2,2): (0,0,0) then (1,0,0) then (0,1,0) then (1,1,0) then (0,1,1) then (1,1,1)
*/
readonly data: Uint16Array;
/** Should be:
* - true if there are no voxels in the data
* - false if there is at least one voxel in the data
*/
readonly isEmpty: boolean;
}
This PR drastically changes the way the
Terrain
interacts with theIVoxelMap
.The
Terrain
now asks for chunks of the map when needed.The
IVoxelMap
now only requires one method:getLocalMapData(from: Vector3Like, to: Vector3Like): Promise<ILocalMapData>;
that returns the data for a portion of the map.The
ILocalMapData
is defined as follows: