ActivitySpace


public final class ActivitySpace implements ScenePose, Entity


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 methods

final void

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

final void
addOnBoundsChangedListener(
    @NonNull Executor callbackExecutor,
    @NonNull Consumer<@NonNull FloatSize3d> listener
)

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

final void

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

final void
addOnSpaceUpdatedListener(
    @NonNull Executor executor,
    @NonNull Runnable listener
)

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

final @NonNull FloatSize3d

The current bounds of this ActivitySpace.

final @NonNull BoundingBox

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

final void

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

final void

Removes the previously-added listener.

Inherited methods

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

Returns the alpha transparency set for this Entity.

@NonNull Pose

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

@FloatRange(from = 0.0) float

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

void
setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)

Sets the alpha transparency of the Entity and its children.

void

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

void
setScale(@FloatRange(from = 0.0) float scale)

Sets the scale of this Entity relative to its parent.

From androidx.xr.scenecore.ScenePose
abstract @NonNull Pose

The current Pose relative to the activity space root.

abstract @NonNull HitTestResult
hitTest(@NonNull Vector3 origin, @NonNull Vector3 direction)

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

abstract @NonNull HitTestResult
hitTest(
    @NonNull Vector3 origin,
    @NonNull Vector3 direction,
    int hitTestFilter
)

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

abstract @NonNull Pose
transformPoseTo(@NonNull Pose pose, @NonNull ScenePose destination)

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

Public methods

addOnBoundsChangedListener

Added in 1.0.0-alpha05
public final void addOnBoundsChangedListener(
    @NonNull Consumer<@NonNull FloatSize3d> listener
)

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
@NonNull Consumer<@NonNull FloatSize3d> listener

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

addOnBoundsChangedListener

Added in 1.0.0-alpha05
public final void addOnBoundsChangedListener(
    @NonNull Executor callbackExecutor,
    @NonNull Consumer<@NonNull FloatSize3d> listener
)

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
@NonNull Executor callbackExecutor

The executor on which to invoke the listener on.

@NonNull Consumer<@NonNull FloatSize3d> listener

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

addOnSpaceUpdatedListener

Added in 1.0.0-alpha05
public final void addOnSpaceUpdatedListener(@NonNull Runnable listener)

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
@NonNull Runnable listener

The listener to register.

addOnSpaceUpdatedListener

Added in 1.0.0-alpha05
public final void addOnSpaceUpdatedListener(
    @NonNull Executor executor,
    @NonNull Runnable listener
)

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
@NonNull Executor executor

The Executor on which to run the listener.

@NonNull Runnable listener

The listener to register.

getBounds

Added in 1.0.0-alpha05
public final @NonNull FloatSize3d getBounds()

The current bounds of this ActivitySpace.

getRecommendedContentBoxInFullSpace

Added in 1.0.0-alpha05
public final @NonNull BoundingBox getRecommendedContentBoxInFullSpace()

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.

removeOnBoundsChangedListener

Added in 1.0.0-alpha05
public final void removeOnBoundsChangedListener(
    @NonNull Consumer<@NonNull FloatSize3d> listener
)

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

Parameters
@NonNull Consumer<@NonNull FloatSize3d> listener

The Consumer to be removed from receiving updates.

removeOnSpaceUpdatedListener

Added in 1.0.0-alpha05
public final void removeOnSpaceUpdatedListener(@NonNull Runnable listener)

Removes the previously-added listener.