abstract class SpaceEntity : Entity

Known direct subclasses
ActivitySpace

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

AnchorSpace

An AnchorSpace is a SpaceEntity tracks a Pose relative to some position or surface in the "Real World." Children of this SpaceEntity will remain positioned relative to that location in the real world.


A SpaceEntity is a special Entity subtype whose position is independent of other SpaceEntity. It is parentless and its position and scale are controlled by the system. Calling setPose, setScale, or setting the Entity.parent property on a SpaceEntity will result in an UnsupportedOperationException.

Examples of SpaceEntity are ActivitySpace and AnchorSpace.

Summary

Public functions

open Pose
getPose(relativeTo: Space)

Returns the pose of the SpaceEntity relative to the specified coordinate space.

open Float
getScale(relativeTo: Space)

Returns the scale of the SpaceEntity relative to the specified coordinate space.

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

Throws UnsupportedOperationException if called.

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

Throws UnsupportedOperationException if called.

Public properties

open Entity?

Throws UnsupportedOperationException if called.

Inherited functions

From androidx.xr.scenecore.BaseScenePose
open suspend HitTestResult?
hitTest(origin: Vector3, direction: Vector3)

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

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

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

open Vector3
transformDirectionTo(direction: Vector3, destination: ScenePose)

Transforms a direction from this ScenePose's local space to the destination ScenePose's local space.

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

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

open Vector3
transformPositionTo(position: Vector3, destination: ScenePose)

Transforms a position from this ScenePose's local space to the destination ScenePose's local space.

open Vector3
transformVectorTo(vector: Vector3, destination: ScenePose)

Transforms a vector from this ScenePose's local space to the destination ScenePose's local space.

From androidx.xr.scenecore.Entity
Unit
addChild(child: Entity)

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

Boolean
addComponent(component: Component)

Adds a Component to this Entity.

@FloatRange(from = 0.0, to = 1.0) Float
getAlpha(relativeTo: Space)

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 subtypes attached to this Entity.

Boolean
isEnabled(includeParents: Boolean)

Returns the enabled status of this Entity.

Unit

Remove all components from this Entity.

Unit

Removes the given Component from this Entity.

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

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

Unit
setEnabled(enabled: Boolean)

Sets the local enabled state of this Entity.

Inherited properties

From androidx.xr.scenecore.BaseScenePose
open Pose

The current Pose relative to the activity space root.

From androidx.xr.scenecore.Entity
List<Entity>

Provides the list of all children of this entity.

CharSequence

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

Public functions

getPose

open fun getPose(relativeTo: Space = Space.PARENT): Pose

Returns the pose of the SpaceEntity relative to the specified coordinate space.

Parameters
relativeTo: Space = Space.PARENT

The coordinate space to get the pose relative to. Defaults to Space.PARENT.

Returns
Pose

The current pose of the SpaceEntity.

Throws
IllegalArgumentException

if called with Space.PARENT since SpaceEntity has no parents.

getScale

open fun getScale(relativeTo: Space = Space.PARENT): Float

Returns the scale of the SpaceEntity relative to the specified coordinate space.

Parameters
relativeTo: Space = Space.PARENT

The coordinate space to get the scale relative to. Defaults to Space.PARENT.

Returns
Float

The current scale of the SpaceEntity.

Throws
IllegalArgumentException

if called with Space.PARENT since SpaceEntity has no parents.

setPose

open fun setPose(pose: Pose, relativeTo: Space = Space.PARENT): Unit

Throws UnsupportedOperationException if called.

Note: The pose of the SpaceEntity is managed by the system. Applications should not call this method, as any changes may be overwritten by the system.

Parameters
pose: Pose

The new pose to set.

relativeTo: Space = Space.PARENT

The space in which the pose is defined. Defaults to Space.PARENT.

Throws
UnsupportedOperationException

if called.

setScale

open fun setScale(scale: Float, relativeTo: Space = Space.PARENT): Unit

Throws UnsupportedOperationException if called.

Note: The scale of an SpaceEntity is managed by the system. Applications should not call this method, as any changes may be overwritten by the system.

Parameters
scale: Float

The new scale to set.

relativeTo: Space = Space.PARENT

The space in which the scale is defined. Defaults to Space.PARENT.

Throws
UnsupportedOperationException

if called.

Public properties

parent

open var parentEntity?

Throws UnsupportedOperationException if called.

Note: The SpaceEntity has no parent; retrieving the parent will return null.

Throws
UnsupportedOperationException

when setting