Function buildGridGeometry

  • Creates a grid-shaped geometry.

    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 gridGeometryResult = 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
    });

    if (gridGeometryResult.ok) {
    const gridGeometry = gridGeometryResult.value;
    // Use gridGeometry here
    } else {
    console.error("Error creating grid geometry:", gridGeometryResult.error);
    }

    Parameters

    • cfg: { divisions?: number; size?: number }

      Configuration for the grid geometry.

      • Optionaldivisions?: number

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

      • Optionalsize?: number

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

    Returns SDKResult<GeometryArrays>

    The geometry arrays for the grid, including positions and indices for the lines, or an error message.