Function buildGridGeometry

  • Creates a grid-shaped SceneGeometry.

    This function generates the geometry arrays for a grid, which consists of lines along the X and Z axes, creating a grid pattern. The grid can be configured in terms of its size and number of divisions. The function returns the geometry arrays, including vertex positions and indices for drawing the grid.

    const gridGeometry = buildGridGeometry({
    size: 10, // Size of the grid along both X and Z axes
    divisions: 10 // Number of divisions (grid lines) along X and Z axes
    });

    Parameters

    • cfg: { divisions: number; size: number } = ...

      Configuration for the grid geometry.

      • divisions: number

        The number of divisions (lines) on the X and Z axes. Default is 1.

      • size: number

        The size of the grid along both the X and Z axes. Default is 1.

    Returns GeometryArrays

    The geometry arrays for the grid, including positions and indices for the lines.

    If any of the size or division parameters are negative, the function automatically inverts the values and logs a warning.