ActivitySpace


class ActivitySpace : BaseEntity


ActivitySpace is an Entity used to track the system-managed pose and boundary of the volume associated with a spatialized Activity. The Application cannot directly control this volume, but the system might update it in response to the User moving it or entering or exiting Full Space Mode.

Summary

Public functions

Unit

Adds the given Consumer as a listener to be invoked when this ActivitySpace's current boundary changes.

Unit
addOnBoundsChangedListener(
    callbackExecutor: Executor,
    listener: Consumer<FloatSize3d>
)

Adds the given Consumer as a listener to be invoked when this ActivitySpace's current boundary changes.

Unit

Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event.

Unit

Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event.

Unit

Releases the given Consumer from receiving updates when the ActivitySpace's boundary changes.

Unit

Removes the previously-added listener.

Public properties

FloatSize3d

The current bounds of this ActivitySpace.

BoundingBox

A recommended box for content to be placed in when in Full Space Mode.

Inherited functions

From androidx.xr.scenecore.BaseEntity
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.

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

From androidx.xr.scenecore.ScenePose
abstract Pose

The current Pose relative to the activity space root.

Public functions

addOnBoundsChangedListener

Added in 1.0.0-alpha06
fun addOnBoundsChangedListener(listener: Consumer<FloatSize3d>): Unit

Adds the given Consumer as a listener to be invoked when this ActivitySpace's current boundary changes.

Consumer.accept will be invoked on the main thread.

Parameters
listener: Consumer<FloatSize3d>

The Consumer to be invoked when this ActivitySpace's current boundary changes.

addOnBoundsChangedListener

Added in 1.0.0-alpha06
fun addOnBoundsChangedListener(
    callbackExecutor: Executor,
    listener: Consumer<FloatSize3d>
): Unit

Adds the given Consumer as a listener to be invoked when this ActivitySpace's current boundary changes.

Consumer.accept will be invoked on the given executor.

Parameters
callbackExecutor: Executor

The executor on which to invoke the listener on.

listener: Consumer<FloatSize3d>

The Consumer to be invoked when this ActivitySpace's current boundary changes.

addOnSpaceUpdatedListener

Added in 1.0.0-alpha06
fun addOnSpaceUpdatedListener(listener: Runnable): Unit

Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event.

When this event occurs, any ScenePose that is not a child of ActivitySpace, such as AnchorEntity and CameraView, will have a different position relative to the ActivitySpace. Therefore, this listener can be used to indicate when to invalidate any cached information about the relative difference in Pose between ActivitySpace's children and children of non-ActivitySpace ScenePoses.

The callback will be made on the SceneCore executor.

Parameters
listener: Runnable

The listener to register.

addOnSpaceUpdatedListener

Added in 1.0.0-alpha06
fun addOnSpaceUpdatedListener(executor: Executor, listener: Runnable): Unit

Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event.

When this event occurs, any ScenePose that is not a child of ActivitySpace, such as AnchorEntity and CameraView, will have a different position relative to the ActivitySpace. Therefore, this listener can be used to indicate when to invalidate any cached information about the relative difference in Pose between ActivitySpace's children and children of non-ActivitySpace ScenePoses.

Parameters
executor: Executor

The Executor on which to run the listener.

listener: Runnable

The listener to register.

removeOnBoundsChangedListener

Added in 1.0.0-alpha06
fun removeOnBoundsChangedListener(listener: Consumer<FloatSize3d>): Unit

Releases the given Consumer from receiving updates when the ActivitySpace's boundary changes.

Parameters
listener: Consumer<FloatSize3d>

The Consumer to be removed from receiving updates.

removeOnSpaceUpdatedListener

Added in 1.0.0-alpha06
fun removeOnSpaceUpdatedListener(listener: Runnable): Unit

Removes the previously-added listener.

Public properties

bounds

Added in 1.0.0-alpha06
val boundsFloatSize3d

The current bounds of this ActivitySpace.

recommendedContentBoxInFullSpace

Added in 1.0.0-alpha06
val recommendedContentBoxInFullSpaceBoundingBox

A recommended box for content to be placed in when in Full Space Mode.

The box is relative to the ActivitySpace's coordinate system. It is not scaled by the ActivitySpace's transform. The dimensions are always in meters. This provides a device-specific default volume that developers can use to size their content appropriately.