@@ -23,6 +23,7 @@ import androidx.lifecycle.lifecycleScope
2323import androidx.media3.common.C
2424import androidx.media3.common.MediaItem
2525import androidx.media3.exoplayer.ExoPlayer
26+ import androidx.xr.arcore.ArDevice
2627import androidx.xr.runtime.Session
2728import androidx.xr.runtime.math.FloatSize2d
2829import androidx.xr.runtime.math.Pose
@@ -57,15 +58,15 @@ private fun ComponentActivity.surfaceEntityCreate(xrSession: Session) {
5758
5859private 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
7576private 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