Function buildPlaneGeometry

  • Creates a plane-shaped SceneGeometry.

    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.

    Creating a SceneMesh with a plane-shaped SceneGeometry:

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

    Parameters

    • cfg: {
          center: number[];
          xSegments: number;
          xSize: number;
          zSegments: number;
          zSize: number;
      } = ...

      Configuration for the plane geometry.

      • center: number[]

        The 3D point indicating the center of the plane.

      • xSegments: number

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

      • xSize: number

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

      • zSegments: number

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

      • zSize: number

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

    Returns GeometryArrays

    The geometry arrays for the plane, including positions, normals, UVs, and indices.

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