Search code examples
kotlinandroid-jetpack-composearcoreandroid-xrscenecore

Setting 3D model's pose in Scene Viewer for Android XR app


In Android XR app (and in ARCore app), the simplest way to load a 3D model with basic interaction capabilities is to implement a Scene Viewer. You can move and rotate a glTF model in the scene, however, I don't see a way to pre-rotate the model around the Y axis and pre-move it along the Z axis before loading it into the scene.

How can I set a preliminary position and orientation of the model (a.k.a. Pose) using Scene Viewer for Android XR app?

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            AppTheme {
                val intent = sceneViewerWithIntent()
                startActivity(intent)
            }
        }
    }
}

fun sceneViewerWithIntent(): Intent {
    val intent = Intent(Intent.ACTION_VIEW)
    val domain = "https://raw.githubusercontent.com/"
    val path = "KhronosGroup/glTF-Sample-Models/refs/heads/main/2.0/AntiqueCamera/glTF-Binary/AntiqueCamera.glb"
    val type = "model/gltf-binary"

    val data = Uri
        .parse("https://arvr.google.com/scene-viewer/1.2")
        .buildUpon()
        .appendQueryParameter("file", domain + path)
        .build()
    intent.setDataAndType(data, type)
    return intent
}

enter image description here


Solution

  • Unfortunately, at this moment, the preliminary position and orientation (pose) of the .glb/.gltf model in the XR scene cannot be changed either in the Scene Viewer's Kotlin code or in the <model-viewer> HTML tag.