Contents

generateBox(width:height:depth:cornerRadius:splitFaces:)

Creates a box mesh from a width, height, depth, a radius for the corners, and a Boolean option that splits faces.

Declaration

@MainActor @preconcurrency static func generateBox(width: Float, height: Float, depth: Float, cornerRadius: Float = 0, splitFaces: Bool = false) -> MeshResource

Parameters

  • width:

    The length of the box’s width, in meters, along the x-axis.

  • height:

    The length of the box’s height, in meters, along the y-axis.

  • depth:

    The length of the box’s depth, in meters, along the z-axis.

  • cornerRadius:

    The radius of each corner’s circular arc, in meters. Values for cornerRadius can be, at most, equal to the smallest value of the width, height, and depth parameters. For example, if the box’s dimensions are 3.0 x 4.0 x 5.0, the corner radius needs to be in the range [0.0, 1.5].

  • splitFaces:

    A Boolean value that indicates whether you can assign up to six separate materials, one for each face. If false, you can only assign one material for all six faces.

Discussion

The method centers the box at the entity’s origin and aligns the box’s faces with the coordinate system’s axes.

See Also

Creating a box