PortalCrossingComponent
A component that allows entities to cross portal boundaries.
Declaration
struct PortalCrossingComponentOverview
Set this component on an entity inside the portal world to opt that entity — and its descendants — into the portal’s crossing behavior. RealityKit then renders parts of the entity inside the portal as portal content and parts outside in the host scene.
Crossing-eligible entities cross the boundary configured by crossingMode on the portal entity:
With PortalComponent.CrossingMode.plane(_:), entities cross an infinite plane.
With PortalComponent.CrossingMode.volume(_:), entities cross the faces of a box.
The component has no configurable state; its presence on an entity is what enables crossing.
Inheritance
PortalCrossingComponent propagates down the entity hierarchy. Setting it on an ancestor makes every descendant crossing-eligible without setting it on each one individually:
let world = Entity()
world.components.set(WorldComponent())
let group = Entity()
group.components.set(PortalCrossingComponent())
let body = Entity()
let head = Entity()
group.addChild(body)
group.addChild(head)
world.addChild(group)
// `body` and `head` both cross the portal because their ancestor `group` opts in.An entity isn’t crossing-eligible if no ancestor in its chain (including itself) has PortalCrossingComponent, if isEnabled is false on any ancestor in the chain, or if it isn’t a descendant of an entity with WorldComponent.
See PortalComponent for an end-to-end portal setup.