<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/MeshResource/generateBox(size:cornerRadius:)-2ovma",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation12MeshResourceC11generateBox4size12cornerRadiusACs5SIMD3VySfG_SftFZ"
  },
  "title" : "generateBox(size:cornerRadius:)"
}
-->

# generateBox(size:cornerRadius:)

Creates a box mesh from a vector of three scalar values that represent width, height, and depth, respectively, and a radius for the corners.

```
@MainActor @preconcurrency static func generateBox(size: SIMD3<Float>, cornerRadius: Float = 0) -> MeshResource
```

## Parameters

`size`

The length of the box’s width, height, and depth, in meters,
along the x-, y-, and z-axis, respectively.

`cornerRadius`

The radius of each corner’s circular arc, in meters.
Values for `cornerRadius` can be, at most, equal to
`min(size.x, size.y, size.z) / 2.0`.
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]`.

## Discussion

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

> Note: The method clamps `cornerRadius` so that it doesn’t exceed half
> the length of the box’s smallest dimension.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)