@@ -44,40 +44,42 @@ private class Environments(val session: Session) {
44
44
// [START androidxr_scenecore_environment_setEnvironmentPreference]
45
45
val spatialEnvironmentPreference =
46
46
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) {
50
49
// The environment was successfully updated and is now visible, and any listeners
51
50
// 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
+ }
56
58
// [END androidxr_scenecore_environment_setEnvironmentPreference]
57
59
}
58
60
59
61
@Suppress(" RestrictedApi" ) // b/416066566
60
62
fun setPassthroughOpacityPreference () {
61
63
// [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 ) {
64
66
// 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 {
67
69
// The passthrough opacity preference was successfully set, but not
68
70
// immediately visible. The passthrough opacity change will be applied
69
71
// when the activity has the
70
72
// SpatialCapabilities.SPATIAL_CAPABILITY_PASSTHROUGH_CONTROL capability.
71
73
// Then, any listeners specified using addOnPassthroughOpacityChangedListener
72
- // will be notified
74
+ // will be notified.
73
75
}
74
76
// [END androidxr_scenecore_environment_setPassthroughOpacityPreference]
75
77
}
76
78
77
79
@Suppress(" RestrictedApi" ) // b/416066566
78
80
fun getCurrentPassthroughOpacity () {
79
81
// [START androidxr_scenecore_environment_getCurrentPassthroughOpacity]
80
- val currentPassthroughOpacity = session.scene.spatialEnvironment.getCurrentPassthroughOpacity()
82
+ val currentPassthroughOpacity = session.scene.spatialEnvironment.currentPassthroughOpacity
81
83
// [END androidxr_scenecore_environment_getCurrentPassthroughOpacity]
82
84
}
83
85
}
0 commit comments