[英]how to rotate a 3d model rendered with ARCORE SceneView
how to rotate a 3d model rendered with ARCORE SceneView i have used Sceneview 如何旋转使用ARCORE SceneView渲染的3D模型我已经使用了Sceneview
private lateinit var scene: Scene private lateinit var node: Node 私有lateinit var场景:场景私有lateinit var节点:节点
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)
}
Within the code block of Node().apply, add the following: 在Node()。apply的代码块中,添加以下内容:
localRotation(Quaternion.axisAngle(new Vector3(-1f, 0, 0), 90f));
Modify the (X,Y,Z) values according to how you want the object rotated. 根据您希望对象旋转的方式修改(X,Y,Z)值。 The coordinates I provided will make the object face the camera.
我提供的坐标将使对象面向相机。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.