PortalComponent

@MainThread
class PortalComponent : Component

A Component that enables entity surfaces to act as portals to a target world (the targetEntity EC tree) and should be used in conjunction with PortalMaterial.

Terminologies:

To achieve the desired portal effect, you should adhere to the following design principles:

  • PortalEntity should have a PortalMaterial linked to its ModelComponent.

  • PortalEntity must be either a sibling or parent node to PortalWorldEntity, not a child.

  • PortalCrossableEntity must be a child node within a PortalWorldEntity and cannot be isolated outside of it.

  • The system can display up to 8 pairs of Portal-World relationships simultaneously. This supports up to 8 such pairs.

Usage Example

// Create world entity and crossing entity
val worldEntity = Entity()
worldEntity.components.set(PortalWorldComponent())
val willCrossingEntity = Entity()
willCrossingEntity.components.set(PortalCrossableComponent())
worldEntity.addChild(willCrossingEntity)

// Create portal entity
val portalEntity = Entity()
portalEntity.components.set(
PortalComponent(
targetEntity = worldEntity,
allowClipping = true,
doubleSide = false,
allowEntityCrossing = true
)
)

// Attach required visual components
portalEntity.components.set(ModelComponent(mesh, PortalMaterial()))

See also

Constructors

Link copied to clipboard
constructor(targetEntity: Entity, enable: Boolean = true, doubleSide: Boolean = false, allowClipping: Boolean = true, allowEntityCrossing: Boolean = true)

Constructs a PortalComponent with the specified parameters.

Properties

Link copied to clipboard
var allowClipping: Boolean

Whether clipping is allowed for the PortalComponent. The default value is true.

Link copied to clipboard
var allowEntityCrossing: Boolean

Whether entities are allowed to cross through the PortalComponent. The default value is true.

Link copied to clipboard
var doubleSide: Boolean

Whether both sides (forward and backward) of the PortalComponent are rendered. The default value is false.

Link copied to clipboard
var enable: Boolean

The enabled state of the PortalComponent. The default value is true, indicating enabled.

Link copied to clipboard

The target entity representing the world visible through the portal. If targetEntity is null, the portal will not be rendered. To render the portal correctly, set targetEntity to a valid Entity object.

Functions

Link copied to clipboard
open override fun clone(): Component

Creates and returns a copy of this Component instance.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String