PortalComponent
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:
PortalEntity: An entity that the PortalComponent is added to.
PortalWorldEntity: An entity that the PortalWorldComponent is added to.
PortalCrossableEntity: An entity that the PortalCrossableComponent is added to.
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
Constructs a PortalComponent with the specified parameters.
Properties
Whether clipping is allowed for the PortalComponent. The default value is true.
Whether entities are allowed to cross through the PortalComponent. The default value is true.
Whether both sides (forward and backward) of the PortalComponent are rendered. The default value is false.
The enabled state of the PortalComponent. The default value is true, indicating enabled.
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.