<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/PortalComponent/BoundaryStyle/enclosingBox(depth:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation15PortalComponentV13BoundaryStyleV12enclosingBox5depthAESf_tFZ"
  },
  "title" : "enclosingBox(depth:)"
}
-->

# enclosingBox(depth:)

Returns a boundary style that uses a box enclosing the portal surface.

```
static func enclosingBox(depth: Float) -> PortalComponent.BoundaryStyle
```

## Parameters

`depth`

The depth of the box in meters, along the entity’s local Z axis.

## Discussion

The box is centered on the portal entity’s origin. Its X and Y extents come from the
accompanying [`PortalComponent.SurfaceStyle`](/documentation/RealityKit/PortalComponent/SurfaceStyle); its Z extent is the `depth` you provide.

Use this style for room-sized portals and other bounded portal spaces where content
shouldn’t extend infinitely behind the surface. Entities with
[`PortalCrossingComponent`](/documentation/RealityKit/PortalCrossingComponent) cross the box’s faces rather than an infinite plane.

This boundary corresponds to [`PortalComponent.ClippingMode.volume(_:)`](/documentation/RealityKit/PortalComponent/ClippingMode-swift.enum/volume(_:))
and [`PortalComponent.CrossingMode.volume(_:)`](/documentation/RealityKit/PortalComponent/CrossingMode-swift.enum/volume(_:)). To offset the box from the portal entity’s
origin, configure those modes directly with a [`PortalComponent.Volume`](/documentation/RealityKit/PortalComponent/Volume) that has a non-zero `position`.

---

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)