Documentation
    Preparing search index...

    Function heightFieldGeometry

    • A regular grid of height samples in the XZ plane, displaced along Y (§53 "height field").

      const geometry = heightFieldGeometry({
      heights: samples, // rows × columns, row-major
      columns: 64,
      rows: 64,
      width: 100,
      depth: 100,
      });

      XZ with Y up is the orientation @fourjs/physics' height-field collider (§24) uses, and it is the one terrain, a machined surface, or a scalar field over a plan view arrives in. The field is centred on the origin: x spans [-width/2, width/2] and z spans [-depth/2, depth/2], whatever the heights do.

      Normals are central differences of the sampled surface — (−∂y/∂x, 1, −∂y/∂z) normalized, one-sided at the borders — rather than averaged face normals: the height field is a sampled function, so its gradient is the honest normal and costs two subtractions per vertex. Uv is the grid's own parameter square, u with +X and v with +Z.

      Unlike every other builder here the grid is open: there is no seam to duplicate, so a rows × columns field is exactly rows · columns vertices.

      Parameters

      Returns BufferGeometry