abstract class BaseEntity<RtEntityType : Entity> : BaseScenePose, Entity

Known direct subclasses
ActivitySpace

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

AnchorEntity

An AnchorEntity tracks a androidx.xr.runtime.math.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.

GltfModelEntity

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

GroupEntity

An Entity that contains no content, but can have an arbitrary number of children.

PanelEntity

PanelEntity contains an arbitrary 2D Android View, within a spatialized XR scene.

SurfaceEntity

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

Known indirect subclasses
ActivityPanelEntity

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

MainPanelEntity

Represents the main spatialized panel in a Scene.


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

Summary

Public functions

open Unit
addChild(child: Entity)

Sets an Entity to be a child of this Entity in the scene graph.

open Boolean
addComponent(component: Component)

Adds a Component to this Entity.

open Unit

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

open Float
getAlpha(relativeTo: Int)

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

open List<Component>

Retrieves all components attached to this Entity.

open List<T>

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

open Pose
getPose(relativeTo: Int)

Returns the Pose for this Entity, relative to the provided Space.

open Float
getScale(relativeTo: Int)

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

open Boolean
isEnabled(includeParents: Boolean)

Returns the enabled status of this Entity.

open Unit

Remove all components from this Entity.

open Unit

Removes the given Component from this Entity.

open Unit
setAlpha(alpha: Float, relativeTo: Int)

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

open Unit
setEnabled(enabled: Boolean)

Sets the local enabled state of this Entity.

open Unit
setPose(pose: Pose, relativeTo: Int)

Sets the Pose for this Entity.

open Unit
setScale(scale: Float, relativeTo: Int)

Sets the scale of this Entity relative to given Space.

Public properties

open CharSequence

Alternate text for this Entity to be consumed by Accessibility systems.

open Entity?

The parent of this Entity, from which this Entity will inherit most of its properties.

Inherited functions

From androidx.xr.scenecore.Entity
open @FloatRange(from = 0.0, to = 1.0) Float

Returns the alpha transparency set for this Entity.

open Pose

Returns the Pose for this Entity, relative to its parent.

open @FloatRange(from = 0.0) Float

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

open Unit
setAlpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the alpha transparency of the Entity and its children.

open Unit
setPose(pose: Pose)

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

open Unit
setScale(scale: @FloatRange(from = 0.0) Float)

Sets the scale of this Entity relative to its parent.

From androidx.xr.scenecore.ScenePose
abstract suspend HitTestResult
hitTest(origin: Vector3, direction: Vector3)

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

abstract suspend HitTestResult
hitTest(origin: Vector3, direction: Vector3, hitTestFilter: Int)

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

abstract Pose
transformPoseTo(pose: Pose, destination: ScenePose)

Returns a Pose relative to this ScenePose, transformed into a Pose relative to the destination.

Inherited properties

From androidx.xr.scenecore.ScenePose
abstract Pose

The current Pose relative to the activity space root.

Public functions

addChild

open fun addChild(child: Entity): Unit

Sets an Entity to be a child of this Entity in the scene graph. The child Entity will inherit properties from the parent, and will be represented in the parent's 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

open 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 was successfully added to the Entity.

dispose

open 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

open fun getAlpha(relativeTo: Int): Float

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

Parameters
relativeTo: Int

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

getComponents

open fun getComponents(): List<Component>

Retrieves all components attached to this Entity.

Returns
List<Component>

List attached to this Entity.

getComponentsOfType

open 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.

getPose

open fun getPose(relativeTo: Int): Pose

Returns the Pose for this Entity, relative to the provided Space.

Parameters
relativeTo: Int

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

open fun getScale(relativeTo: Int): Float

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

Parameters
relativeTo: Int

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

Returns
Float

Current uniform scale applied to self and children.

isEnabled

open fun isEnabled(includeParents: Boolean): Boolean

Returns the enabled status of this Entity.

Parameters
includeParents: Boolean

Whether to include the enabled 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 enabled. If includeParents is false, the local enabled state is returned. Regardless of the local enabled state, an Entity will be considered disabled if any of its ancestors are disabled.

removeAllComponents

open fun removeAllComponents(): Unit

Remove all components from this Entity.

removeComponent

open fun removeComponent(component: Component): Unit

Removes the given Component from this Entity.

Parameters
component: Component

Component to be removed from this entity.

setAlpha

open fun setAlpha(alpha: Float, relativeTo: Int): 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

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

setEnabled

open fun setEnabled(enabled: Boolean): Unit

Sets the local enabled state of this Entity.

When false, this Entity and all descendants will not be rendered in the scene, and the Entity will not respond to input events. If an Entity's local enabled state is true, the Entity will still be considered not enabled if at least one of its ancestors is not enabled.

Parameters
enabled: Boolean

The new local enabled state of this Entity.

setPose

open fun setPose(pose: Pose, relativeTo: Int): 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

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

setScale

open fun setScale(scale: Float, relativeTo: Int): 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

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

Public properties

contentDescription

open var contentDescriptionCharSequence

Alternate text for this Entity to be consumed by Accessibility systems.

parent

open var parentEntity?

The parent of this Entity, from which this Entity will inherit most of its properties. For example, this Entity's Pose is defined in relation to the parent Entity's coordinate space, so as the parent moves, this Entity will move with it. Setting the parent to null will remove the Entity from the scene graph.