# SpatialEnvironmentTester

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

*** ** * ** ***


```
class SpatialEnvironmentTester
```

<br />

*** ** * ** ***

A test utility for accessing and inspecting the spatial data associated with the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpatialEnvironment`.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/testing/SpatialEnvironmentTester#triggerPassthroughOpacityChanged(kotlin.Float)( opacity: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Simulates a change in the user-visible passthrough opacity, notifying all registered listeners. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/testing/SpatialEnvironmentTester#triggerSpatialEnvironmentChanged(kotlin.Boolean)(active: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Simulates a change in the active state of the preferred spatial environment, notifying all registered listeners. |

## Public functions

### triggerPassthroughOpacityChanged

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

```
fun triggerPassthroughOpacityChanged(
    opacity: @FloatRange(from = 0.0, to = 1.0) Float
): Unit
```

Simulates a change in the user-visible passthrough opacity, notifying all registered listeners.

This affects the value returned by `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpatialEnvironment#currentPassthroughOpacity()` and triggers callbacks registered via `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpatialEnvironment#addPassthroughOpacityChangedListener(java.util.function.Consumer)`.

A value of 0.0f means no passthrough is shown, and a value of 1.0f means the passthrough completely obscures the spatial environment geometry and skybox.

| Parameters |
|---|---|
| `opacity: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The current passthrough opacity value between 0.0f and 1.0f. |

### triggerSpatialEnvironmentChanged

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

```
fun triggerSpatialEnvironmentChanged(active: Boolean): Unit
```

Simulates a change in the active state of the preferred spatial environment, notifying all registered listeners.

This affects the value returned by `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpatialEnvironment#isPreferredSpatialEnvironmentActive()` and triggers callbacks registered via `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpatialEnvironment#addSpatialEnvironmentChangedListener(java.util.function.Consumer)`.

| Parameters |
|---|---|
| `active: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if the environment preference is active. |