Function buildPlaneGeometry

  • Creates a plane-shaped geometry.

    This function generates a plane geometry with configurable dimensions and segments. The plane is created by defining a grid of vertices with associated normals and UV coordinates, and creating the indices to connect them in a grid-like fashion. The plane is then returned as a geometry that can be used to create a mesh in the scene.

    const planeGeometryResult = buildPlaneGeometry({
    xSize: 10, // Width of the plane
    zSize: 10, // Depth of the plane
    xSegments: 10, // Number of segments along the X-axis
    zSegments: 10, // Number of segments along the Z-axis
    center: [0, 0, 0] // Center position of the plane in 3D space
    });

    if (planeGeometryResult.ok) {
    const planeGeometry = planeGeometryResult.value;
    // Use planeGeometry here
    } else {
    console.error("Error creating plane geometry:", planeGeometryResult.error);
    }

    Parameters

    • cfg: {
          center?: Vec3;
          xSegments?: number;
          xSize?: number;
          zSegments?: number;
          zSize?: number;
      }

      Configuration for the plane geometry.

      • Optionalcenter?: Vec3

        The 3D point indicating the center of the plane.

      • OptionalxSegments?: number

        The number of segments along the X-axis. Default is 1.

      • OptionalxSize?: number

        The width of the plane along the X-axis. Default is 1.

      • OptionalzSegments?: number

        The number of segments along the Z-axis. Default is 1.

      • OptionalzSize?: number

        The depth of the plane along the Z-axis. Default is 1.

    Returns SDKResult<GeometryArrays>

    The geometry arrays for the plane, including positions, normals, UVs, and indices, or an error message.