Function buildBoxGeometry

  • Creates box-shaped geometry arrays.

    This function generates the geometry arrays required for a box mesh with configurable sizes along each axis. It provides vertex positions, UV coordinates, and indices to define the box's geometry. You can adjust the box's size along the X, Y, and Z axes and also specify its center position in 3D space.

    const boxGeometry = buildBoxGeometry({
    center: [0, 0, 0], // Center of the box
    xSize: 2, // Half-size along the X-axis
    ySize: 1, // Half-size along the Y-axis
    zSize: 1.5 // Half-size along the Z-axis
    });

    Parameters

    • cfg: { center?: number[]; xSize?: number; ySize?: number; zSize?: number } = ...

      Configurations for the box geometry.

      • Optionalcenter?: number[]

        The center of the box in 3D space, default is the origin [0, 0, 0].

      • OptionalxSize?: number

        Half-size of the box along the X-axis. The default value is 1.0.

      • OptionalySize?: number

        Half-size of the box along the Y-axis. The default value is 1.0.

      • OptionalzSize?: number

        Half-size of the box along the Z-axis. The default value is 1.0.

    Returns GeometryArrays | SDKError

    Returns the geometry arrays for the box or an SDKError if the input sizes are invalid.

    If any of the sizes (xSize, ySize, or zSize) are negative, an error is thrown.