---
title: "createPortal(world:portalEntity:style:enableClipping:enableCrossing:)"
framework: realitykit
role: symbol
role_heading: Type Method
path: "realitykit/portalfactory/createportal(world:portalentity:style:enableclipping:enablecrossing:)"
---

# createPortal(world:portalEntity:style:enableClipping:enableCrossing:)

Creates a portal targeting an existing world entity.

## Declaration

```swift
static func createPortal(world: Entity, portalEntity: Entity? = nil, style: PortalFactory.Style, enableClipping: Bool = true, enableCrossing: Bool = false) -> PortalFactory.PortalSetup
```

## Parameters

- `world`: An entity with WorldComponent. This entity must already have a WorldComponent attached, or the method will fail with a precondition.
- `portalEntity`: An optional entity to configure as the portal. If nil, a new entity is created. If provided, any existing ModelComponent and PortalComponent will be replaced. Default is nil.
- `style`: The visual style and geometry of the portal.
- `enableClipping`: When true, content is clipped at the portal boundary. Default is true.
- `enableCrossing`: When true, enables portal crossing for entities with PortalCrossingComponent. Default is false.

## Return Value

Return Value A PortalSetup containing the root entity with configured portal and world.

## Discussion

Discussion Use this method when you want multiple portals to view the same world, or when you need to configure the world entity before creating the portal. note: The world entity must have a WorldComponent. Example // Create a shared world let sharedWorld = Entity() sharedWorld.components.set(WorldComponent())

// Create two portals viewing the same world let portal1 = PortalFactory.createPortal(     world: sharedWorld,     style: .plane(width: 1.0, height: 1.0) )

let portal2 = PortalFactory.createPortal(     world: sharedWorld,     style: .plane(width: 1.5, height: 1.5) )

// Add both portals to scene content.add(portal1.rootEntity) content.add(portal2.rootEntity)

## See Also

### Creating a portal

- [createPortal(style:enableClipping:enableCrossing:)](realitykit/portalfactory/createportal(style:enableclipping:enablecrossing:).md)
