@threlte/extras

<Portal>

A component that renders its children as children of an object that can exist anywhere in your Threlte application. You can either provide an object that will be the parent of the children or use the prop id to render into a <PortalTarget>.

Although Portals are extremely helpful in certain situations, it can be hard to reason about them at times. It’s recommended to use them sparingly.

Examples

Render Helper Objects

Some objects such as the THREE.DirectionalLightHelper need to be added to the scene instead of the light itself or another parent to be functional. We can use the <Portal> component for that.

Render to a <PortalTarget>

You can define where a <Portal> should render its children by using the component <PortalTarget>.

Component Signature

Props

name
type
required
default
description

id
string
no
default
The id of the portal to render into.

object
THREE.Object3D
no