Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,9 +32,9 @@ class EnvironmentController(private val xrSession: Session, private val coroutin
private val assetCache: HashMap<String, Any> = 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
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -181,7 +181,7 @@ private fun SpatialLayout(
.alpha(animatedAlpha.value)
.size(400.dp)
.padding(bottom = 16.dp)
.transformingMovable()
.movable()
.resizable(),
) {
firstSupportingContent()
Expand All @@ -190,7 +190,7 @@ private fun SpatialLayout(
SubspaceModifier
.alpha(animatedAlpha.value)
.weight(1f)
.transformingMovable()
.movable()
.resizable(),
) {
secondSupportingContent()
Expand All @@ -201,7 +201,7 @@ private fun SpatialLayout(
.alpha(animatedAlpha.value)
.fillMaxSize()
.padding(end = 16.dp)
.transformingMovable()
.movable()
.resizable(),
) {
Column {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,17 +39,16 @@ 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

// 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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
Loading