Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Android XR samples to align with recent API changes, including renaming 'DepthMap' to 'Depth' and 'ExrImage' to 'ImageBasedLightingAsset', and transitioning to 'SPATIAL' tracking modes. It also introduces a comprehensive set of Glimmer component samples and replaces the '.movable()' modifier with '.transformingMovable()'. Feedback identifies several issues in the 'SpatialGltfModel' sample, such as a potential null pointer exception, redundant imports, and conflicting 'LaunchedEffect' blocks that overwrite material overrides. Additionally, the reviewer noted a performance regression where material caching was removed and a duplicated documentation tag in the focus samples.
| node?.localPose = | ||
| Pose(node.localPose.translation, rotation) |
There was a problem hiding this comment.
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue |
| // Create and apply the custom material once the session is ready and the target node is available. | ||
| LaunchedEffect(node) { | ||
| val material = pbrMaterial ?: KhronosPbrMaterial.create( | ||
| val material = KhronosPbrMaterial.create( |
There was a problem hiding this comment.
The material is being re-created every time this LaunchedEffect runs, bypassing the pbrMaterial cache defined at line 78. This is less efficient than the previous implementation. Consider restoring the caching logic.
| val material = KhronosPbrMaterial.create( | |
| val material = pbrMaterial ?: KhronosPbrMaterial.create( |
| } | ||
|
|
||
| // [START androidxr_compose_SpatialGltfModelTexture] | ||
| LaunchedEffect(node) { |
There was a problem hiding this comment.
This LaunchedEffect conflicts with the one starting at line 81. Both effects use node as a key and call setMaterialOverride. Since they run concurrently, the second one will overwrite the first, making the base color factor set in the first block ineffective. Consider merging these snippets or clarifying their usage.
|
|
||
| // [START xr_glimmer_focus_activity] | ||
|
|
||
| // [START xr_glimmer_focus_activity] |
No description provided.