8000 Fix broken environment geometry animation · androidx/androidx@e65c3d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit e65c3d8

Browse files
author
Jay Abi-Saad
committed
Fix broken environment geometry animation
Fixes: b/470450138 Change-Id: I6fbdb13462920b50f0f0765bcb989a4d653e1002
1 parent d53df48 commit e65c3d8

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

xr/scenecore/scenecore-spatial-rendering/src/main/java/androidx/xr/scenecore/spatial/rendering/SpatialEnvironmentFeatureImpl.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ internal class SpatialEnvironmentFeatureImpl(
130130
)
131131
}
132132
if (animationName != null) {
133-
impressApi.animateGltfModel(geometryImpressNode, animationName, true)
133+
// animateGltfModel is itself an asynchronous call, and it blocks execution
134+
// until the animation finishes. We need to wrap this call in a coroutine so
135+
// that we can proceed with the parenting of the environment instead of
136+
// waiting for the animation to complete.
137+
coroutineScope.launch {
138+
impressApi.animateGltfModel(geometryImpressNode, animationName, true)
139+
}
134140
}
135141
impressApi.setImpressNodeParent(geometryImpressNode, subspaceNode)
136142
}

xr/scenecore/scenecore-spatial-rendering/src/test/java/androidx/xr/scenecore/spatial/rendering/SpatialEnvironmentFeatureImplTest.kt

Lines changed: 16 additions & 0 deletions
< 6880 /tr>
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,22 @@ class SpatialEnvironmentFeatureImplTest {
463463
assertThat(actualParentHandle).isEqualTo(expectedParentHandle)
464464
}
465465

466+
@Test
467+
fun setPreferredSpatialEnvironment_asyncAnimation_startsAnimation() = runBlocking {
468+
val exr = fakeLoadEnvironment("fakeEnvironment")
469+
val gltf = fakeLoadGltfAsset("fakeGltfAsset")
470+
val animationName = "fakeAnimation"
471+
472+
environment.preferredSpatialEnvironment =
473+
SpatialEnvironmentPreference(exr, gltf, null, null, animationName)
474+
475+
// Will execute animateGltfModel.
476+
runUiThreadTasks()
477+
478+
val loopingAnimatingNodes = fakeImpressApi.impressNodeLoopAnimatingSize()
479+
assertThat(loopingAnimatingNodes).isEqualTo(1)
480+
}
481+
466482
@Test
467483
fun dispose_clearsResources() = runBlocking {
468484
val exr = fakeLoadEnvironment("fakeEnvironment")

0 commit comments

Comments
 (0)
0