normalize static method

void normalize(
  1. Object3D mesh,
  2. TerrainOptions options
)

Normalize the terrain after applying a heightmap or filter.

This applies turbulence, steps, and height clamping; calls the after callback; updates normals and the bounding sphere; and marks vertices as dirty.

Mesh mesh The terrain mesh. TerrainOptions options A map of settings that control how the terrain is constructed and displayed. Valid options are the same as for {@link Terrain}().

Implementation

static void normalize(Object3D mesh, TerrainOptions options) {
  final zs = toArray1D(mesh.geometry!.attributes['position'].array.toDartList());
  if (options.turbulent) {
    turbulence(zs, options);
  }
  if (options.steps > 1) {
    step(zs, options.steps);
    smooth(zs, options);
  }

  // Keep the terrain within the allotted height range if necessary, and do easing.
  clamp(zs, options);

  // Call the "after" callback
  options.after?.call(zs, options);
  fromArray1D(mesh.geometry!.attributes['position'].array.toDartList(), zs);

  // Mark the geometry as having changed and needing updates.
  mesh.geometry?.computeBoundingSphere();
  mesh.geometry?.computeFaceNormals();
  mesh.geometry?.computeVertexNormals();
}