我想在没有Camera和ArCore的Sceneview上加载3D对象。所以我创建了一个简单的xml布局,如下所示:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.ar.sceneform.SceneView
android:id="@+id/scene"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
并像这样加载3D对象:
private fun renderObject() {
ModelRenderable.builder()
.setSource(this, R.raw.andy)
.build()
.thenAccept {
it?.let {
node = Node().apply {
setParent(scene)
localPosition = Vector3(0f, 0f, -1f)
localScale = Vector3(3f, 3f, 3f)
name = "Andy"
renderable = it
}
scene.addChild(node)
}
}
.exceptionally {
val builder = AlertDialog.Builder(this)
builder.setMessage(it.message)
.setTitle("error!")
val dialog = builder.create()
dialog.show()
return@exceptionally null
}
}
现在的问题是如何与3D对象交互,旋转,缩放和拾取元素?我看到使用ArCore有TransformableNodes,但是如果没有ArCore怎么使用呢?