Skip to content

Commit 4560857

Browse files
committed
Update to Jetpack release of January 28
1 parent 243ef2f commit 4560857

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ androidx-window = "1.5.1"
3030
androidx-window-core = "1.5.1"
3131
androidx-window-java = "1.5.1"
3232
androidx-work-runtime = "2.11.0"
33-
androidx-xr-arcore = "1.0.0-alpha09"
34-
androidx-xr-compose = "1.0.0-alpha09"
35-
androidx-xr-scenecore = "1.0.0-alpha10"
33+
androidx-xr-arcore = "1.0.0-alpha10"
34+
androidx-xr-compose = "1.0.0-alpha10"
35+
androidx-xr-scenecore = "1.0.0-alpha11"
3636
androidxHiltNavigationCompose = "1.3.0"
3737
appcompat = "1.7.1"
3838
arcorePlayServices = "1.0.0-alpha09"

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pluginManagement {
88
}
99
}
1010
plugins {
11-
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
11+
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
1212
}
1313
dependencyResolutionManagement {
1414
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

xr/src/main/java/com/example/xr/arcore/Planes.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
package com.example.xr.arcore
1818

19+
import androidx.xr.arcore.ArDevice
1920
import androidx.xr.arcore.Plane
2021
import androidx.xr.runtime.Config
2122
import androidx.xr.runtime.Session
2223
import androidx.xr.runtime.SessionConfigureSuccess
23-
import androidx.xr.runtime.math.Pose
2424
import androidx.xr.runtime.math.Ray
2525
import androidx.xr.scenecore.scene
2626

@@ -46,8 +46,9 @@ private suspend fun subscribePlanes(session: Session) {
4646
}
4747

4848
private fun hitTestTable(session: Session) {
49-
val pose = session.scene.spatialUser.head?.transformPoseTo(Pose(), session.scene.perceptionSpace) ?: return
50-
val ray = Ray(pose.translation, pose.forward)
49+
val devicePose = ArDevice.getInstance(session).state.value.devicePose
50+
val activitySpacePose = session.scene.perceptionSpace.transformPoseTo(devicePose, session.scene.activitySpace)
51+
val ray = Ray(activitySpacePose.translation, activitySpacePose.forward)
5152
// [START androidxr_arcore_hitTest]
5253
val results = androidx.xr.arcore.hitTest(session, ray)
5354
// When interested in the first Table hit:

xr/src/main/java/com/example/xr/misc/ModeTransition.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717
package com.example.xr.misc
1818

1919
import androidx.compose.runtime.Composable
20-
import androidx.xr.compose.platform.LocalSpatialConfiguration
20+
import androidx.xr.compose.platform.LocalSession
2121
import androidx.xr.runtime.Session
2222
import androidx.xr.scenecore.scene
2323

2424
@Composable
2525
fun modeTransitionCompose() {
2626
// [START androidxr_misc_modeTransitionCompose]
27-
LocalSpatialConfiguration.current.requestHomeSpaceMode()
27+
val session = LocalSession.current ?: return
28+
session.scene.requestHomeSpaceMode()
2829
// or
29-
LocalSpatialConfiguration.current.requestFullSpaceMode()
30+
session.scene.requestFullSpaceMode()
3031
// [END androidxr_misc_modeTransitionCompose]
3132
}
3233

xr/src/main/java/com/example/xr/scenecore/SpatialVideo.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import androidx.lifecycle.lifecycleScope
2323
import androidx.media3.common.C
2424
import androidx.media3.common.MediaItem
2525
import androidx.media3.exoplayer.ExoPlayer
26+
import androidx.xr.arcore.ArDevice
2627
import androidx.xr.runtime.Session
2728
import androidx.xr.runtime.math.FloatSize2d
2829
import androidx.xr.runtime.math.Pose
@@ -57,15 +58,15 @@ private fun ComponentActivity.surfaceEntityCreate(xrSession: Session) {
5758

5859
private fun ComponentActivity.surfaceEntityCreateSbs(xrSession: Session) {
5960
// [START androidxr_scenecore_surfaceEntityCreateSbs]
61+
val devicePose = ArDevice.getInstance(xrSession).state.value.devicePose
62+
val activitySpacePose = xrSession.scene.perceptionSpace.transformPoseTo(devicePose, xrSession.scene.activitySpace)
63+
6064
// Set up the surface for playing a 180° video on a hemisphere.
6165
val hemisphereStereoSurfaceEntity =
6266
SurfaceEntity.create(
6367
session = xrSession,
6468
stereoMode = SurfaceEntity.StereoMode.SIDE_BY_SIDE,
65-
pose = xrSession.scene.spatialUser.head?.transformPoseTo(
66-
Pose.Identity,
67-
xrSession.scene.activitySpace
68-
)!!,
69+
pose = activitySpacePose,
6970
shape = SurfaceEntity.Shape.Hemisphere(1.0f),
7071
)
7172
// ... and use the surface for playing the media.
@@ -74,15 +75,14 @@ private fun ComponentActivity.surfaceEntityCreateSbs(xrSession: Session) {
7475

7576
private fun ComponentActivity.surfaceEntityCreateTb(xrSession: Session) {
7677
// [START androidxr_scenecore_surfaceEntityCreateTb]
78+
val devicePose = ArDevice.getInstance(xrSession).state.value.devicePose
79+
val activitySpacePose = xrSession.scene.perceptionSpace.transformPoseTo(devicePose, xrSession.scene.activitySpace)
7780
// Set up the surface for playing a 360° video on a sphere.
7881
val sphereStereoSurfaceEntity =
7982
SurfaceEntity.create(
8083
session = xrSession,
8184
stereoMode = SurfaceEntity.StereoMode.TOP_BOTTOM,
82-
pose = xrSession.scene.spatialUser.head?.transformPoseTo(
83-
Pose.Identity,
84-
xrSession.scene.activitySpace
85-
)!!,
85+
pose = activitySpacePose,
8686
shape = SurfaceEntity.Shape.Sphere(1.0f),
8787
)
8888
// ... and use the surface for playing the media.

0 commit comments

Comments
 (0)