如何旋转使用ARCORE SceneView渲染的3D模型我已使用Sceneview
private lateinit var场景:Scene 私有lateinit变量节点:节点
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.act_main)
scene = sceneView.scene
render(Uri.parse("coffee_cup.sfb"))
}
private fun render(uri: Uri) {
ModelRenderable.builder()
.setSource(this, uri)
.build()
.thenAccept {
addNode(it)
}
.exceptionally {
Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show()
return@exceptionally null
}
}
private fun addNode(model: ModelRenderable?) {
model?.let {
node = Node().apply {
setParent(scene)
localPosition = Vector3(0f, -2f, -7f)
localScale = Vector3(3f, 3f, 3f)
renderable = it
}
scene.addChild(node)
}
答案 0 :(得分:1)
在Node()。apply的代码块中,添加以下内容:
localRotation(Quaternion.axisAngle(new Vector3(-1f, 0, 0), 90f));
根据您希望对象旋转的方式修改(X,Y,Z)值。我提供的坐标将使对象面向相机。