toArray1D static method
Get a 1D array of heightmap values from a 1D array of plane vertices.
Float32List vertices
A 1D array containing the vertex positions of the geometry representing the
terrain.
TerrainOptions options
A map of settings defining properties of the terrain. The only properties
that matter here are xSegments and ySegments, which represent how many
vertices wide and deep the terrain plane is, respectively (and therefore
also the dimensions of the returned array).
return Float32List A 1D array representing the terrain's heightmap.
Implementation
static Float32List toArray1D(Float32List vertices) {
final tgt = Float32List(vertices.length ~/ 3);
for (int i = 0, l = tgt.length; i < l; i++) {
tgt[i] = vertices[i*3 + 2];
}
return tgt;
}