# Scene

Artifact: [androidx.xr.scenecore:scenecore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore) [View Source](https://cs.android.com/search?q=file:androidx/xr/scenecore/Scene.kt+class:androidx.xr.scenecore.Scene) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
public final class Scene
```

<br />

*** ** * ** ***

Scene is the primary interface to SceneCore functionality for the application. Each spatialized `https://developer.android.com/reference/android/app/Activity.html` must create and hold an instance of a Scene.

Once created, the application can use the Scene object to create spatialized entities, such as Widget panels and geometric models, set the background environment, and anchor content to the real world.

## Summary

| ### Public fields |
|---|---|
| `final lateinit @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#activitySpace()` The `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace` is a special entity that represents the space in which the application is launched. |
| `final lateinit @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#mainPanelEntity()` A spatialized `https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity` associated with the "main window" for the Activity. |
| `final lateinit @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PerceptionSpace` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#perceptionSpace()` The `https://developer.android.com/reference/androidx/xr/scenecore/PerceptionSpace` represents the origin of the space in which ARCore for Jetpack XR provides tracking info. |
| `final lateinit @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability>` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#spatialCapabilities()` The current `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` of `https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability` constants available in the Session. |
| `final lateinit @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#spatialEnvironment()` The `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment` for this scene. |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#addSpatialCapabilitiesChangedListener(java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability>> listener )` Adds the given `https://developer.android.com/reference/java/util/function/Consumer.html` as a listener to be invoked when this `https://developer.android.com/reference/androidx/xr/runtime/Session`'s spatial capabilities change. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#addSpatialCapabilitiesChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability>> listener )` Adds the given `https://developer.android.com/reference/java/util/function/Consumer.html` as a listener to be invoked when this `https://developer.android.com/reference/androidx/xr/runtime/Session`'s spatial capabilities change. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#addSpatialVisibilityChangedListener(java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialVisibility> listener )` Adds a listener to be invoked on the main thread executor when the spatial visibility of the rendered content of the entire scene (all entities, including children of `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace`s and `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`) changes within the user's field of view. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#addSpatialVisibilityChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialVisibility> listener )` Adds a listener to be invoked when the spatial visibility of the rendered content of the entire scene (all entities, including children of `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace`s and `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`) changes within the user's field of view. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#clearSpaceChangedListener()()` Releases the listener previously set by `https://developer.android.com/reference/androidx/xr/scenecore/Scene#setSpaceChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)` and reinstates the default behavior of automatically updating the `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()`'s pose and scale on the main thread executor. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#getActivitySpace()()` The `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace` is a special entity that represents the space in which the application is launched. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | `<T extends https://developer.android.com/reference/androidx/xr/scenecore/Entity> https://developer.android.com/reference/androidx/xr/scenecore/Scene#getEntitiesOfType(java.lang.Class)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> type)` Returns all entities of the given type or its subtypes. |
| `final https://developer.android.com/reference/androidx/xr/scenecore/Entity` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#getKeyEntity()()` The primary `https://developer.android.com/reference/androidx/xr/scenecore/Entity` that serves as the spatial reference for the scene's content. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#getMainPanelEntity()()` A spatialized `https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity` associated with the "main window" for the Activity. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PanelClippingConfig` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#getPanelClippingConfig()()` The current clipping configuration of all panels in the Scene. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PerceptionSpace` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#getPerceptionSpace()()` The `https://developer.android.com/reference/androidx/xr/scenecore/PerceptionSpace` represents the origin of the space in which ARCore for Jetpack XR provides tracking info. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability>` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#getSpatialCapabilities()()` The current `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` of `https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability` constants available in the Session. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#getSpatialEnvironment()()` The `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment` for this scene. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PixelDensity` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#getVirtualPixelDensity()()` Provides access to the `https://developer.android.com/reference/androidx/xr/scenecore/PixelDensity` standards for this scene. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#removeSpatialCapabilitiesChangedListener(java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability>> listener )` Releases the given `https://developer.android.com/reference/java/util/function/Consumer.html` from receiving updates when the `https://developer.android.com/reference/androidx/xr/runtime/Session`'s `https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability` change. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#removeSpatialVisibilityChangedListener(java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialVisibility> listener )` Releases the listener previously added by `https://developer.android.com/reference/androidx/xr/scenecore/Scene#addSpatialVisibilityChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)`. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#requestFullSpace()()` If the `https://developer.android.com/reference/android/app/Activity.html` has focus, causes the Activity to be placed in Full Space. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#requestHomeSpace()()` If the `https://developer.android.com/reference/android/app/Activity.html` has focus, causes the Activity to be placed in Home Space. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#setKeyEntity(androidx.xr.scenecore.Entity)(https://developer.android.com/reference/androidx/xr/scenecore/Entity value)` The primary `https://developer.android.com/reference/androidx/xr/scenecore/Entity` that serves as the spatial reference for the scene's content. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#setPanelClippingConfig(androidx.xr.scenecore.PanelClippingConfig)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PanelClippingConfig value)` The current clipping configuration of all panels in the Scene. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#setSpaceChangedListener(java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpaceChangeEvent> listener )` Sets the listener to be invoked on the main thread executor when the space for the Scene has changed, such as from Home Space to Full Space. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/Scene#setSpaceChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpaceChangeEvent> listener )` Sets the listener to be invoked when the space has changed, such as from Home Space to Full Space. |

## Public fields

### activitySpace

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final lateinit @NonNull ActivitySpace activitySpace
```

The `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace` is a special entity that represents the space in which the application is launched. It is the default parent of all entities in the scene.

The ActivitySpace is created automatically when the `https://developer.android.com/reference/androidx/xr/runtime/Session` is created.

### mainPanelEntity

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final lateinit @NonNull MainPanelEntity mainPanelEntity
```

A spatialized `https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity` associated with the "main window" for the Activity. When in Home Space Mode, this is the application's "main window".

If called multiple times, this will return the same MainPanelEntity.

### perceptionSpace

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final lateinit @NonNull PerceptionSpace perceptionSpace
```

The `https://developer.android.com/reference/androidx/xr/scenecore/PerceptionSpace` represents the origin of the space in which ARCore for Jetpack XR provides tracking info. The transformations provided by the PerceptionSpace are only valid for the call frame, as the transformation can be changed by the system at any time.

### spatialCapabilities

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final lateinit @NonNull Set<@NonNull SpatialCapability> spatialCapabilities
```

The current `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` of `https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability` constants available in the Session. The set may change within a session. The returned object will not update if the capabilities change; this method should be called again to get the latest set of capabilities, or clients can subscribe to changes with `https://developer.android.com/reference/androidx/xr/scenecore/Scene#addSpatialCapabilitiesChangedListener(java.util.function.Consumer)`.

### spatialEnvironment

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final lateinit @NonNull SpatialEnvironment spatialEnvironment
```

The `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment` for this scene.

This object provides APIs to manage the XR background and passthrough settings. Use it to set a custom skybox, define the 3D geometry of the environment, and control the opacity of the camera passthrough feed.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment` |   |

## Public methods

### addSpatialCapabilitiesChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void addSpatialCapabilitiesChangedListener(
    @NonNull Consumer<@NonNull Set<@NonNull SpatialCapability>> listener
)
```

Adds the given `https://developer.android.com/reference/java/util/function/Consumer.html` as a listener to be invoked when this `https://developer.android.com/reference/androidx/xr/runtime/Session`'s spatial capabilities change.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability>> listener` | The Consumer to be invoked asynchronously, on the main thread. The set includes every currently-available `https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability`. |

### addSpatialCapabilitiesChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void addSpatialCapabilitiesChangedListener(
    @NonNull Executor callbackExecutor,
    @NonNull Consumer<@NonNull Set<@NonNull SpatialCapability>> listener
)
```

Adds the given `https://developer.android.com/reference/java/util/function/Consumer.html` as a listener to be invoked when this `https://developer.android.com/reference/androidx/xr/runtime/Session`'s spatial capabilities change.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` to run the listener on. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability>> listener` | The Consumer to be invoked asynchronously on the given callbackExecutor. The set includes every currently-available `https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability`. |

### addSpatialVisibilityChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void addSpatialVisibilityChangedListener(
    @NonNull Consumer<@NonNull SpatialVisibility> listener
)
```

Adds a listener to be invoked on the main thread executor when the spatial visibility of the rendered content of the entire scene (all entities, including children of `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace`s and `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`) changes within the user's field of view. In Home Space Mode, the listener continues to monitor the spatial visibility of the application's main panel.

This API only checks if the bounding box of all rendered content (even if partially transparent) is within the user's field of view. Content not rendered due to full transparency (alpha=0) or being hidden is not considered. If the entities in the scene or any of their ancestors are hidden using `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setEnabled(kotlin.Boolean)` (enabled=false) or if the entities are turned fully transparent using `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setAlpha(kotlin.Float)` (alpha=0.0), then the SpatialVisibility checks will return `https://developer.android.com/reference/androidx/xr/scenecore/SpatialVisibility#OUTSIDE_FIELD_OF_VIEW()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialVisibility> listener` | The `https://developer.android.com/reference/java/util/function/Consumer.html` to be invoked asynchronously on the main thread whenever the `https://developer.android.com/reference/androidx/xr/scenecore/SpatialVisibility` of the renderable content changes. |

### addSpatialVisibilityChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void addSpatialVisibilityChangedListener(
    @NonNull Executor callbackExecutor,
    @NonNull Consumer<@NonNull SpatialVisibility> listener
)
```

Adds a listener to be invoked when the spatial visibility of the rendered content of the entire scene (all entities, including children of `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace`s and `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`) changes within the user's field of view. In Home Space Mode, the listener continues to monitor the spatial visibility of the application's main panel.

This API only checks if the bounding box of all rendered content (even if partially transparent) is within the user's field of view. Content not rendered due to full transparency (alpha=0) or being hidden is not considered. If the entities in the scene or any of their ancestors are hidden using `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setEnabled(kotlin.Boolean)` (enabled=false) or if the entities are turned fully transparent using `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setAlpha(kotlin.Float)` (alpha=0.0), then the SpatialVisibility checks will return `https://developer.android.com/reference/androidx/xr/scenecore/SpatialVisibility#OUTSIDE_FIELD_OF_VIEW()`.

The listener is invoked on the provided `https://developer.android.com/reference/java/util/concurrent/Executor.html`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` to run the listener on. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialVisibility> listener` | The `https://developer.android.com/reference/java/util/function/Consumer.html` to be invoked asynchronously on the given callbackExecutor whenever the `https://developer.android.com/reference/androidx/xr/scenecore/SpatialVisibility` of the renderable content changes. |

### clearSpaceChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void clearSpaceChangedListener()
```

Releases the listener previously set by `https://developer.android.com/reference/androidx/xr/scenecore/Scene#setSpaceChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)` and reinstates the default behavior of automatically updating the `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()`'s pose and scale on the main thread executor.

The listener is automatically released at the end of the Scene's lifecycle even if this method is not explicitly called.

### getActivitySpace

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull ActivitySpace getActivitySpace()
```

The `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace` is a special entity that represents the space in which the application is launched. It is the default parent of all entities in the scene.

The ActivitySpace is created automatically when the `https://developer.android.com/reference/androidx/xr/runtime/Session` is created.

### getEntitiesOfType

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull List<@NonNull T> <T extends Entity> getEntitiesOfType(@NonNull Class<@NonNull T> type)
```

Returns all entities of the given type or its subtypes.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> type` | the type of `https://developer.android.com/reference/androidx/xr/scenecore/Entity` to return. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | a list of all entities of the given type. |

### getKeyEntity

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final Entity getKeyEntity()
```

The primary `https://developer.android.com/reference/androidx/xr/scenecore/Entity` that serves as the spatial reference for the scene's content.

This entity is used to maintain visual continuity during spatial mode transitions. When entering Full Space Mode or re-centering the scene, the system provides a recommended pose and scale. SceneCore's default mode change handler applies those to the entity designated as `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()` to help preserve the user's spatial context across these mode transitions.

Starting with Spatial API v2, setting `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()` allows SceneCore to share the entity's pose with the system as a spatial continuity hint. The system uses this hint to maintain visual consistency when the current activity transitions to the Home Space or when a new activity is launched.

Spaces, such as `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace` or `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`, cannot be set as the `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()` and will throw `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` if set.

By default, this is set to `https://developer.android.com/reference/androidx/xr/scenecore/Scene#mainPanelEntity()`. This field can be `null` if the key entity was cleared by setting this value to `null`. When `null`, the default listener takes no action during spatial mode changes.

When a new non-null `https://developer.android.com/reference/androidx/xr/scenecore/Entity` is assigned as `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()`, the `https://developer.android.com/reference/androidx/xr/scenecore/Scene#spaceChangedListener()` is immediately invoked with the last known recommended pose and scale values if the following conditions are met:

1. The previous value of `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()` was `null`.

2. There are cached pose and scale values, provided by the system earlier.

### getMainPanelEntity

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull MainPanelEntity getMainPanelEntity()
```

A spatialized `https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity` associated with the "main window" for the Activity. When in Home Space Mode, this is the application's "main window".

If called multiple times, this will return the same MainPanelEntity.

### getPanelClippingConfig

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull PanelClippingConfig getPanelClippingConfig()
```

The current clipping configuration of all panels in the Scene.

Setting this property updates the clipping behavior.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/xr/scenecore/PanelClippingConfig` |   |

### getPerceptionSpace

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull PerceptionSpace getPerceptionSpace()
```

The `https://developer.android.com/reference/androidx/xr/scenecore/PerceptionSpace` represents the origin of the space in which ARCore for Jetpack XR provides tracking info. The transformations provided by the PerceptionSpace are only valid for the call frame, as the transformation can be changed by the system at any time.

### getSpatialCapabilities

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull Set<@NonNull SpatialCapability> getSpatialCapabilities()
```

The current `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` of `https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability` constants available in the Session. The set may change within a session. The returned object will not update if the capabilities change; this method should be called again to get the latest set of capabilities, or clients can subscribe to changes with `https://developer.android.com/reference/androidx/xr/scenecore/Scene#addSpatialCapabilitiesChangedListener(java.util.function.Consumer)`.

### getSpatialEnvironment

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull SpatialEnvironment getSpatialEnvironment()
```

The `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment` for this scene.

This object provides APIs to manage the XR background and passthrough settings. Use it to set a custom skybox, define the 3D geometry of the environment, and control the opacity of the camera passthrough feed.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment` |   |

### getVirtualPixelDensity

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull PixelDensity getVirtualPixelDensity()
```

Provides access to the `https://developer.android.com/reference/androidx/xr/scenecore/PixelDensity` standards for this scene.

This specific density represents the default number of **virtual pixels** that correspond to one physical meter in `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`.

Since the spatial coordinate system is emulated, these pixels represent content units (texture resolution) used to define entities such as `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity`, rather than physical display pixels.

It is a static hardware constant and ignores user-level display preference overrides (system density changes).

### removeSpatialCapabilitiesChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void removeSpatialCapabilitiesChangedListener(
    @NonNull Consumer<@NonNull Set<@NonNull SpatialCapability>> listener
)
```

Releases the given `https://developer.android.com/reference/java/util/function/Consumer.html` from receiving updates when the `https://developer.android.com/reference/androidx/xr/runtime/Session`'s `https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability` change.

The listeners are automatically released at the end of the Scene's lifecycle even if this method is not explicitly called.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialCapability>> listener` | The Consumer to be removed. It will no longer receive change events. |

### removeSpatialVisibilityChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void removeSpatialVisibilityChangedListener(
    @NonNull Consumer<@NonNull SpatialVisibility> listener
)
```

Releases the listener previously added by `https://developer.android.com/reference/androidx/xr/scenecore/Scene#addSpatialVisibilityChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)`.

The listener is automatically released at the end of the Scene's lifecycle even if this method is not explicitly called.

### requestFullSpace

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void requestFullSpace()
```

If the `https://developer.android.com/reference/android/app/Activity.html` has focus, causes the Activity to be placed in Full Space. Otherwise, this call does nothing.

### requestHomeSpace

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void requestHomeSpace()
```

If the `https://developer.android.com/reference/android/app/Activity.html` has focus, causes the Activity to be placed in Home Space. Otherwise, this call does nothing.

### setKeyEntity

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setKeyEntity(Entity value)
```

The primary `https://developer.android.com/reference/androidx/xr/scenecore/Entity` that serves as the spatial reference for the scene's content.

This entity is used to maintain visual continuity during spatial mode transitions. When entering Full Space Mode or re-centering the scene, the system provides a recommended pose and scale. SceneCore's default mode change handler applies those to the entity designated as `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()` to help preserve the user's spatial context across these mode transitions.

Starting with Spatial API v2, setting `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()` allows SceneCore to share the entity's pose with the system as a spatial continuity hint. The system uses this hint to maintain visual consistency when the current activity transitions to the Home Space or when a new activity is launched.

Spaces, such as `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace` or `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`, cannot be set as the `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()` and will throw `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` if set.

By default, this is set to `https://developer.android.com/reference/androidx/xr/scenecore/Scene#mainPanelEntity()`. This field can be `null` if the key entity was cleared by setting this value to `null`. When `null`, the default listener takes no action during spatial mode changes.

When a new non-null `https://developer.android.com/reference/androidx/xr/scenecore/Entity` is assigned as `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()`, the `https://developer.android.com/reference/androidx/xr/scenecore/Scene#spaceChangedListener()` is immediately invoked with the last known recommended pose and scale values if the following conditions are met:

1. The previous value of `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()` was `null`.

2. There are cached pose and scale values, provided by the system earlier.

### setPanelClippingConfig

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setPanelClippingConfig(@NonNull PanelClippingConfig value)
```

The current clipping configuration of all panels in the Scene.

Setting this property updates the clipping behavior.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/xr/scenecore/PanelClippingConfig` |   |

### setSpaceChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setSpaceChangedListener(
    @NonNull Consumer<@NonNull SpaceChangeEvent> listener
)
```

Sets the listener to be invoked on the main thread executor when the space for the Scene has changed, such as from Home Space to Full Space.

Because the listener will typically update the `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()`'s pose and/or scale, there can only be one listener set at a time. If a new listener is set, the previous listener will be released.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpaceChangeEvent> listener` | The `https://developer.android.com/reference/java/util/function/Consumer.html` to be invoked asynchronously on the main thread whenever the spatial mode has changed. |

### setSpaceChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setSpaceChangedListener(
    @NonNull Executor callbackExecutor,
    @NonNull Consumer<@NonNull SpaceChangeEvent> listener
)
```

Sets the listener to be invoked when the space has changed, such as from Home Space to Full Space.

The listener is invoked on the provided `https://developer.android.com/reference/java/util/concurrent/Executor.html`.

Because the listener will typically update the `https://developer.android.com/reference/androidx/xr/scenecore/Scene#keyEntity()`'s pose and/or scale, there can only be one listener set at a time. If a new listener is set, the previous listener will be released.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` on which to run the listener. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpaceChangeEvent> listener` | The `https://developer.android.com/reference/java/util/function/Consumer.html` to be invoked asynchronously on the given callbackExecutor whenever the space has changed. |