在Android Xr App(以及Arcore App)中,加载具有基本交互功能的3D模型的最简单方法是实现Sceneviever。您可以在场景中移动并旋转
glTF
模型,但是,我看不到在将Y轴周围预先修复模型并在将其加载到场景之前将其预先移动的方法。
如何使用Android Xr App?设置模型(又称姿势)的初步位置和方向
Scene Viewer
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
}
.glb
模型的位置和方向不能在
.gltf
的Kotlin代码或Scene Viewer
html tag中更改。