Entity

The base class for all entities in a scene.

An Entity represents a distinct element within a scene.

Note:

  • Each entity automatically has a TransformComponent added upon creation.

  • Multiple Components can be attached to an entity, but only one instance per component type. That is, an entity cannot have two components of the same type.

  • Components collectively define the properties and behavior of the entity within the scene.

Inheritors

Constructors

Link copied to clipboard
@MainThread
constructor()

The default constructor for Entity.

Types

Link copied to clipboard
class CloneOptions(val recursive: Boolean = false, val shouldShareMaterialInstance: Boolean = false)

Represents options for cloning operations.

Link copied to clipboard
object Companion

The companion object of Entity.

Link copied to clipboard
class ComponentSet : Collection<Component>

A set of stored components. The set represents all the components stored on an Entity. Each Entity can hold only one Component of any given type.

Properties

Link copied to clipboard

A set of components that have been added to this entity.

Link copied to clipboard
@get:JvmName(name = "isEnabled")
@get:MainThread
@set:MainThread
var enabled: Boolean

Gets or sets the current entity's enabled state. The default enabled state is true.

Link copied to clipboard
val id: Long

The unique ID of the entity.

Link copied to clipboard
@Volatile
var scene: Scene?

The Scene to which this entity belongs.

Link copied to clipboard
@get:JvmName(name = "isValid")
@get:MainThread
val valid: Boolean

Indicates whether the current Entity is valid (i.e., not destroyed).

Functions

Link copied to clipboard
@MainThread
fun addChild(entity: Entity): Boolean

Adds a child entity to the current entity instance.

Link copied to clipboard
@MainThread
fun clone(cloneOptions: Entity.CloneOptions = CloneOptions()): Entity?

Creates and returns a copy of this entity based on the specified cloning options.

Link copied to clipboard
@MainThread
fun convertPositionFrom(position: Vector3, baseEntity: Entity?): Vector3

Converts a position relative to a baseEntity to the current entity.

Link copied to clipboard
@MainThread
fun convertPositionTo(position: Vector3, targetEntity: Entity?): Vector3

Converts a position relative to the current entity to a targetEntity.

Link copied to clipboard
@MainThread
fun convertRotationFrom(rotation: Quat, baseEntity: Entity?): Quat

Converts a rotation relative to a baseEntity to the current entity.

Link copied to clipboard
@MainThread
fun convertRotationTo(rotation: Quat, targetEntity: Entity?): Quat

Converts a rotation relative to the current entity to a targetEntity.

Link copied to clipboard
@MainThread
fun convertScaleFrom(scale: Vector3, baseEntity: Entity?): Vector3

Converts a scale relative to a baseEntity to the current entity.

Link copied to clipboard
@MainThread
fun convertScaleTo(scale: Vector3, targetEntity: Entity?): Vector3

Converts a scale relative to the current entity to a targetEntity.

Link copied to clipboard
@MainThread
fun convertTransformFrom(transform: Transform, baseEntity: Entity?): Transform

Converts a Transform relative to a baseEntity to the current entity.

Link copied to clipboard
@MainThread
fun convertTransformTo(transform: Transform, targetEntity: Entity?): Transform

Converts a Transform relative to the current entity to a targetEntity.

Link copied to clipboard
@MainThread
fun destroy(recursively: Boolean = true): Boolean

Destroys this entity and, by default, all its children recursively.

Link copied to clipboard
@MainThread
fun findEntity(name: String): Entity?

Searches for an entity by its name within the entire depth of its tree structure, including the entity itself. If there are multiple entities with the same name, only the first matching entity encountered will be returned.

Link copied to clipboard
@MainThread
fun findSkinnedMeshEntity(includeDisabled: Boolean = false): Array<Entity>

Finds all entities with a skinned mesh component within this entity and its children. The search traverses the entire entity hierarchy starting from the current entity.

Link copied to clipboard
@MainThread
fun getAnimationResources(): Array<AnimationResource>

Gets the animation resources associated with the current entity.

Link copied to clipboard
@MainThread
fun getChildren(): Array<Entity>

Gets all child entities of the current entity.

Link copied to clipboard
@MainThread
fun getChildrenCount(): Int

Gets the number of child entities of the current entity.

Link copied to clipboard
@MainThread
fun getName(): String

Gets the name of the current entity.

Link copied to clipboard
@MainThread
fun getParent(): Entity?

Gets the parent entity of the current entity.

Link copied to clipboard
@MainThread
fun getVisualBounds(relativeTo: Entity?, recursive: Boolean = true, enabledOnly: Boolean = false): BoundingBox

Computes a bounding box for the entity in the specified space, optionally including child entities.

Link copied to clipboard
@MainThread
fun hasChild(): Boolean

Checks if the current entity has any child entities.

Link copied to clipboard
@MainThread
fun hasParent(): Boolean

Checks if the current entity has a parent entity.

Link copied to clipboard
@MainThread
fun isChild(child: Entity): Boolean

Checks if the specified entity is a child of the current entity.

Link copied to clipboard
@MainThread
fun isParent(parent: Entity): Boolean

Checks if the specified entity is the parent of the current entity.

Link copied to clipboard
@MainThread
fun playAnimation(animationResource: AnimationResource, config: AnimationPlayConfig = AnimationPlayConfig()): AnimationPlaybackController

Uses the current entity to play an animation resource.

Link copied to clipboard
@MainThread
fun playAudio(audioResource: AudioAsset): AudioPlayerController

Plays the specified audio attached to the entity and returns a controller to manage audio playback.

Link copied to clipboard

Immediately starts playing an audio stream with the specified configuration.

Link copied to clipboard

Plays a preloaded Timeline using the current entity.

Link copied to clipboard
@MainThread
fun prepareAudio(audioResource: AudioAsset): AudioPlayerController

Prepares the specified audio attached to the entity and returns a controller to manage audio playback.

Link copied to clipboard

Prepares an audio stream for low-latency playback with specified configuration.

Link copied to clipboard
@MainThread
fun removeAllChildren(): Boolean

Removes all child entities from the current entity.

Link copied to clipboard
@MainThread
fun removeChild(child: Entity): Boolean

Removes a child entity from the current entity.

Link copied to clipboard
@MainThread
fun removeFromParent(): Boolean

Removes the current entity from its parent entity.

Link copied to clipboard
@MainThread
fun setName(name: String)

Sets the name of the current entity.

Link copied to clipboard
@MainThread
fun setParent(newParent: Entity): Boolean

Sets the specified entity as the parent of the current entity.

Link copied to clipboard
@MainThread
fun stopAllAnimations()

Stops all animations playing on the current Entity.

Link copied to clipboard
@MainThread
fun stopAllAudio()

Stops playing all audios on the current entity.

Link copied to clipboard
open override fun toString(): String