@@ -44,40 +44,42 @@ private class Environments(val session: Session) {
4444 // [START androidxr_scenecore_environment_setEnvironmentPreference]
4545 val spatialEnvironmentPreference =
4646 SpatialEnvironment .SpatialEnvironmentPreference (lightingForSkybox, environmentGeometry)
47- val preferenceResult =
48- session.scene.spatialEnvironment.setSpatialEnvironmentPreference(spatialEnvironmentPreference)
49- if (preferenceResult == SpatialEnvironment .SetSpatialEnvironmentPreferenceChangeApplied ()) {
47+ session.scene.spatialEnvironment.preferredSpatialEnvironment = spatialEnvironmentPreference
48+ if (session.scene.spatialEnvironment.isPreferredSpatialEnvironmentActive) {
5049 // The environment was successfully updated and is now visible, and any listeners
5150 // specified using addOnSpatialEnvironmentChangedListener will be notified.
52- } else if (preferenceResult == SpatialEnvironment .SetSpatialEnvironmentPreferenceChangePending ()) {
53- // The environment is in the process of being updated. Once visible, any listeners
54- // specified using addOnSpatialEnvironmentChangedListener will be notified.
55- }
51+ } else {
52+ // The passthrough opacity preference was successfully set, but not
53+ // immediately visible. The passthrough opacity change will be applied
54+ // when the activity has the SPATIAL_CAPABILITY_APP_ENVIRONMENT capability.
55+ // Then, any listeners specified using addOnSpatialEnvironmentChangedListener
56+ // will be notified.
57+ }
5658 // [END androidxr_scenecore_environment_setEnvironmentPreference]
5759 }
5860
5961 @Suppress(" RestrictedApi" ) // b/416066566
6062 fun setPassthroughOpacityPreference () {
6163 // [START androidxr_scenecore_environment_setPassthroughOpacityPreference]
62- val preferenceResult = session.scene.spatialEnvironment.setPassthroughOpacityPreference( 1.0f )
63- if (preferenceResult == SpatialEnvironment . SetPassthroughOpacityPreferenceChangeApplied () ) {
64+ session.scene.spatialEnvironment.preferredPassthroughOpacity = 1.0f
65+ if (session.scene.spatialEnvironment.currentPassthroughOpacity == 1.0f ) {
6466 // The passthrough opacity request succeeded and should be visible now, and any listeners
65- // specified using addOnPassthroughOpacityChangedListener will be notified
66- } else if (preferenceResult == SpatialEnvironment . SetPassthroughOpacityPreferenceChangePending ()) {
67+ // specified using addOnPassthroughOpacityChangedListener will be notified.
68+ } else {
6769 // The passthrough opacity preference was successfully set, but not
6870 // immediately visible. The passthrough opacity change will be applied
6971 // when the activity has the
7072 // SpatialCapabilities.SPATIAL_CAPABILITY_PASSTHROUGH_CONTROL capability.
7173 // Then, any listeners specified using addOnPassthroughOpacityChangedListener
72- // will be notified
74+ // will be notified.
7375 }
7476 // [END androidxr_scenecore_environment_setPassthroughOpacityPreference]
7577 }
7678
7779 @Suppress(" RestrictedApi" ) // b/416066566
7880 fun getCurrentPassthroughOpacity () {
7981 // [START androidxr_scenecore_environment_getCurrentPassthroughOpacity]
80- val currentPassthroughOpacity = session.scene.spatialEnvironment.getCurrentPassthroughOpacity()
82+ val currentPassthroughOpacity = session.scene.spatialEnvironment.currentPassthroughOpacity
8183 // [END androidxr_scenecore_environment_getCurrentPassthroughOpacity]
8284 }
8385}
0 commit comments