diff --git a/app/src/main/java/com/example/helloandroidxr/environment/EnvironmentController.kt b/app/src/main/java/com/example/helloandroidxr/environment/EnvironmentController.kt index 1c01024..f7b8e9e 100644 --- a/app/src/main/java/com/example/helloandroidxr/environment/EnvironmentController.kt +++ b/app/src/main/java/com/example/helloandroidxr/environment/EnvironmentController.kt @@ -20,8 +20,8 @@ import android.annotation.SuppressLint import android.util.Log import androidx.core.net.toUri import androidx.xr.runtime.Session -import androidx.xr.scenecore.ExrImage import androidx.xr.scenecore.GltfModel +import androidx.xr.scenecore.ImageBasedLightingAsset import androidx.xr.scenecore.SpatialEnvironment import androidx.xr.scenecore.scene import kotlinx.coroutines.CoroutineScope @@ -32,9 +32,9 @@ class EnvironmentController(private val xrSession: Session, private val coroutin private val assetCache: HashMap = HashMap() private var activeEnvironmentModelName: String? = null - fun requestHomeSpaceMode() = xrSession.scene.requestHomeSpaceMode() + fun requestHomeSpaceMode() = xrSession.scene.requestHomeSpace() - fun requestFullSpaceMode() = xrSession.scene.requestFullSpaceMode() + fun requestFullSpaceMode() = xrSession.scene.requestFullSpace() fun requestPassthrough() { xrSession.scene.spatialEnvironment.preferredPassthroughOpacity = 1f @@ -50,15 +50,15 @@ class EnvironmentController(private val xrSession: Session, private val coroutin if (activeEnvironmentModelName == null || activeEnvironmentModelName != environmentModelName ) { - val lightingForSkybox = ExrImage.createFromZip( - xrSession, - Paths.get("environments/green_hills_ibl.zip") + val lightingForSkybox = ImageBasedLightingAsset.createFromZip( + session = xrSession, + path = Paths.get("environments/green_hills_ibl.zip") ) val environmentModel = assetCache[environmentModelName] as GltfModel SpatialEnvironment.SpatialEnvironmentPreference( geometry = environmentModel, - skybox = lightingForSkybox, + imageBasedLightingAsset = lightingForSkybox, ).let { xrSession.scene.spatialEnvironment.preferredSpatialEnvironment = it } diff --git a/app/src/main/java/com/example/helloandroidxr/ui/HelloAndroidXRApp.kt b/app/src/main/java/com/example/helloandroidxr/ui/HelloAndroidXRApp.kt index 9169aaa..3666e13 100644 --- a/app/src/main/java/com/example/helloandroidxr/ui/HelloAndroidXRApp.kt +++ b/app/src/main/java/com/example/helloandroidxr/ui/HelloAndroidXRApp.kt @@ -68,12 +68,12 @@ import androidx.xr.compose.subspace.layout.SubspaceModifier import androidx.xr.compose.subspace.layout.fillMaxSize import androidx.xr.compose.subspace.layout.fillMaxWidth import androidx.xr.compose.subspace.layout.height +import androidx.xr.compose.subspace.layout.movable import androidx.xr.compose.subspace.layout.offset import androidx.xr.compose.subspace.layout.padding import androidx.xr.compose.subspace.layout.resizable import androidx.xr.compose.subspace.layout.rotate import androidx.xr.compose.subspace.layout.size -import androidx.xr.compose.subspace.layout.transformingMovable import androidx.xr.compose.subspace.layout.width import androidx.xr.runtime.math.Quaternion import com.example.helloandroidxr.R @@ -181,7 +181,7 @@ private fun SpatialLayout( .alpha(animatedAlpha.value) .size(400.dp) .padding(bottom = 16.dp) - .transformingMovable() + .movable() .resizable(), ) { firstSupportingContent() @@ -190,7 +190,7 @@ private fun SpatialLayout( SubspaceModifier .alpha(animatedAlpha.value) .weight(1f) - .transformingMovable() + .movable() .resizable(), ) { secondSupportingContent() @@ -201,7 +201,7 @@ private fun SpatialLayout( .alpha(animatedAlpha.value) .fillMaxSize() .padding(end = 16.dp) - .transformingMovable() + .movable() .resizable(), ) { Column { diff --git a/app/src/main/java/com/example/helloandroidxr/ui/components/BugdroidModel.kt b/app/src/main/java/com/example/helloandroidxr/ui/components/BugdroidModel.kt index 02919a5..e0bcd0f 100644 --- a/app/src/main/java/com/example/helloandroidxr/ui/components/BugdroidModel.kt +++ b/app/src/main/java/com/example/helloandroidxr/ui/components/BugdroidModel.kt @@ -27,6 +27,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.platform.LocalDensity import androidx.xr.compose.platform.LocalSession import androidx.xr.compose.spatial.PlanarEmbeddedSubspace +import androidx.xr.compose.subspace.ExperimentalSpatialGltfAnimationApi import androidx.xr.compose.subspace.SpatialGltfModel import androidx.xr.compose.subspace.SpatialGltfModelAnimation import androidx.xr.compose.subspace.SpatialGltfModelSource @@ -38,10 +39,8 @@ import androidx.xr.compose.unit.Meter import androidx.xr.runtime.math.Vector4 import androidx.xr.scenecore.AlphaMode import androidx.xr.scenecore.KhronosPbrMaterial -import androidx.xr.scenecore.Texture import com.example.helloandroidxr.viewmodel.ModelTransform import java.nio.file.Paths -import kotlin.io.path.Path // Bugdroid glb height in meters private const val bugdroidHeight = 2.08f @@ -49,6 +48,7 @@ private const val bugdroidHeight = 2.08f // The desired amount of the available layout height to use for the bugdroid private const val fillRatio = 0.5f +@OptIn(ExperimentalSpatialGltfAnimationApi::class) @SuppressLint("NewApi", "RestrictedApi") @Composable fun BugdroidModel( @@ -84,17 +84,6 @@ fun BugdroidModel( alphaMode = AlphaMode.OPAQUE ).also { pbrMaterial = it - // Load a texture; using a plain white texture for visibility of the base color factor - val texture = Texture.create( - session = xrSession, - path = Path("textures/white.png") - ) - - // Apply the texture and configure occlusion to define ambient lighting strength. - it.setOcclusionTexture( - texture = texture, - strength = modelTransform.materialProperties.ambientOcclusion - ) // Apply the initial material properties. Base Color is RGBA value it.setBaseColorFactor( @@ -138,8 +127,8 @@ fun BugdroidModel( } // Control the model's animation state based on the animateBugdroid flag. - LaunchedEffect(bugdroidModelState.animations) { - val animation = bugdroidModelState.animations.find { + LaunchedEffect(bugdroidModelState.getAnimations()) { + val animation = bugdroidModelState.getAnimations().find { it.name == "Armature|Take 001|BaseLayer" } if (animateBugdroid) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 215d6cb..0f8441c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,14 +1,14 @@ [versions] -androidx-runtime = "1.11.2" -agp = "9.2.1" -arcore = "1.0.0-alpha14" -compose = "1.0.0-alpha14" +androidx-runtime = "1.11.4" +agp = "9.3.1" +arcore = "1.0.0-beta01" +compose = "1.0.0-alpha16" extensionsXr = "1.3.0" -scenecore = "1.0.0-alpha15" -kotlin = "2.3.21" +scenecore = "1.0.0-beta01" +kotlin = "2.4.10" concurrentFuturesKtx = "1.3.0" activityCompose = "1.13.0" -composeBom = "2026.05.01" +composeBom = "2026.06.01" material = "1.14.0" adaptiveAndroid = "1.2.0"