interface Entity : ActivityPose

Known direct subclasses
BaseEntity

The BaseEntity is an implementation of Entity interface that wraps a platform entity.

Known indirect subclasses
ActivityPanelEntity

ActivityPanelEntity creates a spatial panel for embedding an Activity in Android XR.

ActivitySpace

ActivitySpace is an Entity used to track the system-managed pose and boundary of the volume associated with this Spatialized Activity.

AnchorEntity

An AnchorEntity is created to track a Pose relative to some position or surface in the "Real World." Children of this Entity will remain positioned relative to that location in the real world, for the purposes of creating Augmented Reality experiences.

BasePanelEntity

Provides implementations for common Panel functionality.

ContentlessEntity

An Entity that itself has no content.

GltfModelEntity

GltfModelEntity is a concrete implementation of Entity that hosts a glTF model.

PanelEntity

PanelEntity creates a spatial panel in Android XR.

SurfaceEntity

SurfaceEntity is a concrete implementation of Entity that hosts a StereoSurface Canvas.


Interface for a spatial Entity. An Entity's Poses are represented as being relative to their parent. Applications create and manage Entity instances to construct spatial scenes.

Summary

Public functions

Unit
addChild(child: Entity)

Sets an Entity to be represented in this coordinate space.

Boolean
addComponent(component: Component)

Adds a Component to this Entity.

Unit

Disposes of any system resources held by this Entity, and transitively calls dispose() on all its children.

open Float

Returns the alpha transparency set for this Entity.

Float
getAlpha(relativeTo: Int)

Returns the alpha transparency set for this Entity, relative to given space.

List<Component>

Retrieves all components attached to this Entity.

List<T>

Retrieves all Components of the given type T and its sub-types attached to this Entity.

Entity?

Returns the parent of this Entity.

open Pose

Returns the pose for this entity, relative to its parent.

Pose
getPose(relativeTo: Int)

Returns the pose for this entity, relative to the provided space.

open Float

Returns the local scale of this entity, not inclusive of the parent's scale.

Float
getScale(relativeTo: Int)

Returns the scale of this entity, relative to given space.

Boolean
isHidden(includeParents: Boolean)

Returns the hidden status of this Entity.

Unit

Remove all components from this Entity.

Unit

Removes the given Component from this Entity.

open Unit
setAlpha(alpha: Float)

Sets the alpha transparency of the Entity and its children.

Unit
setAlpha(alpha: Float, relativeTo: Int)

Sets the alpha transparency of the Entity relative to given space.

Unit

Sets alternate text for this entity to be consumed by Accessibility systems.

Unit
setHidden(hidden: Boolean)

Sets the local hidden state of this Entity.

Unit
setParent(parent: Entity?)

Sets this Entity to be represented in the parent's coordinate space.

open Unit
setPose(pose: Pose)

Sets the pose for this Entity, relative to its parent.

Unit
setPose(pose: Pose, relativeTo: Int)

Sets the pose for this Entity.

open Unit
setScale(scale: Float)

Sets the scale of this entity relative to its parent.

Unit
setScale(scale: Float, relativeTo: Int)

Sets the scale of this entity relative to given space.

Inherited functions

From androidx.xr.scenecore.ActivityPose
Pose

Returns the activity space pose for this ActivityPose.

ListenableFuture<HitTestResult>
hitTestAsync(origin: Vector3, direction: Vector3)

Creates a hit test from the specified origin in the specified direction into the scene.

ListenableFuture<HitTestResult>
hitTestAsync(
    origin: Vector3,
    direction: Vector3,
    @ActivityPose.HitTestFilterValue hitTestFilter: Int
)

Creates a hit test from the specified origin in the specified direction into the scene.

Pose
transformPoseTo(pose: Pose, destination: ActivityPose)

Returns a pose relative to this ActivityPose transformed into a pose relative to the destination.

Public functions

addChild

Added in 1.0.0-alpha04
fun addChild(child: Entity): Unit

Sets an Entity to be represented in this coordinate space. From a User's perspective, as this Entity moves, the child Entity will move with it.

Parameters
child: Entity

The Entity to be attached.

addComponent

Added in 1.0.0-alpha04
fun addComponent(component: Component): Boolean

Adds a Component to this Entity.

Parameters
component: Component

the Component to be added to the Entity.

Returns
Boolean

True if given Component is added to the Entity.

dispose

Added in 1.0.0-alpha04
fun dispose(): Unit

Disposes of any system resources held by this Entity, and transitively calls dispose() on all its children. Once disposed, this Entity is invalid and cannot be used again.

getAlpha

Added in 1.0.0-alpha04
open fun getAlpha(): Float

Returns the alpha transparency set for this Entity.

This does not necessarily equal the perceived alpha of the entity as the entity may have some alpha difference applied from its parent or the system.

getAlpha

Added in 1.0.0-alpha04
fun getAlpha(relativeTo: Int = Space.PARENT): Float

Returns the alpha transparency set for this Entity, relative to given space.

Parameters
relativeTo: Int = Space.PARENT

Gets alpha relative to given Space. Default value is the parent space.

getComponents

Added in 1.0.0-alpha04
fun getComponents(): List<Component>

Retrieves all components attached to this Entity.

Returns
List<Component>

List attached to this Entity.

getComponentsOfType

Added in 1.0.0-alpha04
fun <T : Component> getComponentsOfType(type: Class<T>): List<T>

Retrieves all Components of the given type T and its sub-types attached to this Entity.

Parameters
type: Class<T>

The type of Component to retrieve.

Returns
List<T>

List of the given type attached to this Entity.

getParent

Added in 1.0.0-alpha04
fun getParent(): Entity?

Returns the parent of this Entity.

Returns
Entity?

The Entity that this Entity is attached to. Returns null if this Entity has no parent and is the root of its hierarchy.

getPose

Added in 1.0.0-alpha04
open fun getPose(): Pose

Returns the pose for this entity, relative to its parent.

Returns
Pose

Current Pose offset from the parent.

getPose

Added in 1.0.0-alpha04
fun getPose(relativeTo: Int = Space.PARENT): Pose

Returns the pose for this entity, relative to the provided space.

Parameters
relativeTo: Int = Space.PARENT

Get the pose relative to given Space. Default value is the parent space.

Returns
Pose

Current Pose of the entity relative to the given space.

getScale

Added in 1.0.0-alpha04
open fun getScale(): Float

Returns the local scale of this entity, not inclusive of the parent's scale.

Returns
Float

Current uniform scale applied to self and children.

getScale

Added in 1.0.0-alpha04
fun getScale(relativeTo: Int = Space.PARENT): Float

Returns the scale of this entity, relative to given space.

Parameters
relativeTo: Int = Space.PARENT

Get the scale relative to given Space. Default value is the parent space.

Returns
Float

Current uniform scale applied to self and children.

isHidden

Added in 1.0.0-alpha04
fun isHidden(includeParents: Boolean = true): Boolean

Returns the hidden status of this Entity.

Parameters
includeParents: Boolean = true

Whether to include the hidden status of parents in the returned value.

Returns
Boolean

If includeParents is true, the returned value will be true if this Entity or any of its ancestors is hidden. If includeParents is false, the local hidden state is returned. Regardless of the local hidden state, an entity will not be rendered if any of its ancestors are hidden.

removeAllComponents

Added in 1.0.0-alpha04
fun removeAllComponents(): Unit

Remove all components from this Entity.

removeComponent

Added in 1.0.0-alpha04
fun removeComponent(component: Component): Unit

Removes the given Component from this Entity.

Parameters
component: Component

Component to be removed from this entity.

setAlpha

Added in 1.0.0-alpha04
open fun setAlpha(alpha: Float): Unit

Sets the alpha transparency of the Entity and its children. Values are in the range 0, 1 with 0 being fully transparent and 1 being fully opaque.

This value will affect the rendering of this Entity's children. Children of this node will have their alpha levels multiplied by this value and any alpha of this entity's ancestors.

setAlpha

Added in 1.0.0-alpha04
fun setAlpha(alpha: Float, relativeTo: Int = Space.PARENT): Unit

Sets the alpha transparency of the Entity relative to given space. Values are in the range 0, 1 with 0 being fully transparent and 1 being fully opaque.

This value will affect the rendering of this Entity's children. Children of this node will have their alpha levels multiplied by this value and any alpha of this entity's ancestors.

Parameters
alpha: Float

Alpha transparency level for the Entity.

relativeTo: Int = Space.PARENT

Sets alpha relative to given Space. Default value is the parent space.

setContentDescription

Added in 1.0.0-alpha04
fun setContentDescription(text: String): Unit

Sets alternate text for this entity to be consumed by Accessibility systems.

Parameters
text: String

A11y content.

setHidden

Added in 1.0.0-alpha04
fun setHidden(hidden: Boolean): Unit

Sets the local hidden state of this Entity. When true, this Entity and all descendants will not be rendered in the scene. When the hidden state is false, an entity will be rendered if its ancestors are not hidden.

Parameters
hidden: Boolean

The new local hidden state of this Entity.

setParent

Added in 1.0.0-alpha04
fun setParent(parent: Entity?): Unit

Sets this Entity to be represented in the parent's coordinate space. From a User's perspective, as the parent moves, this Entity will move with it. Setting the parent to null will cause the Entity to not be rendered.

Parameters
parent: Entity?

The Entity to attach to.

setPose

Added in 1.0.0-alpha04
open fun setPose(pose: Pose): Unit

Sets the pose for this Entity, relative to its parent.

Parameters
pose: Pose

The Pose offset from the parent.

setPose

Added in 1.0.0-alpha04
fun setPose(pose: Pose, relativeTo: Int = Space.PARENT): Unit

Sets the pose for this Entity. The pose given is set relative to the space provided.

Parameters
pose: Pose

The Pose offset from the parent.

relativeTo: Int = Space.PARENT

Set the pose relative to given Space. Default value is the parent space.

setScale

Added in 1.0.0-alpha04
open fun setScale(scale: Float): Unit

Sets the scale of this entity relative to its parent. This value will affect the rendering of this Entity's children. As the scale increases, this will uniformly stretch the content of the Entity.

Parameters
scale: Float

The uniform scale factor from the parent.

setScale

Added in 1.0.0-alpha04
fun setScale(scale: Float, relativeTo: Int = Space.PARENT): Unit

Sets the scale of this entity relative to given space. This value will affect the rendering of this Entity's children. As the scale increases, this will uniformly stretch the content of the Entity.

Parameters
scale: Float

The uniform scale factor.

relativeTo: Int = Space.PARENT

Set the scale relative to given Space. Default value is the parent space.