我正在 ARCore Android 中工作,我想在單擊按鈕時旋轉 3D 模型。我已經完成了旋轉,但問題是它不會在當前位置旋轉,即如果模型移動到平面上的其他位置,它會回到模型投影的初始位置,在這里我們可以看到旋轉。我想將我的模型旋轉到平面上的任何位置,并且它保留在那里。這是我的代碼 private void rotateRight(TransformableNode node, AxisClass objAxis, Vector3 pos) { node.getRotationController().setEnabled(true); node.getScaleController().setEnabled(true); node.getTranslationController().setEnabled(false); Quaternion rightMoveVector = new Quaternion(); rightMoveVector = tNode.getLocalRotation(); Quaternion orientations = new Quaternion(); Quaternion orientation = Quaternion.axisAngle(new Vector3(pos.x, 1.0f, pos.z), rotateAngle); node.setLocalRotation(Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), rotateAngle)); rotateAngle = rotateAngle + 30; objAxis.setRotateRight(String.valueOf(rotateAngle)); objAxis.setY_axis(String.valueOf(Math.toRadians(rotateAngle)));}
1 回答

慕桂英3389331
TA貢獻2036條經驗 獲得超8個贊
對于模型旋轉,您必須重寫 sceneform android 中的 onupdate 方法。
執行旋轉后,您必須設置模型位置,使其保持在原來的位置。
Quaternion?q1?=?tNode.getLocalRotation(); ????????Quaternion?q2?=?Quaternion.axisAngle(new?Vector3(0f,?1f,?0f),?-2f); ????????tNode.setLocalRotation(Quaternion.multiply(q1,?q2)); ????????tNode.setLocalPosition(localPosition);
添加回答
舉報
0/150
提交
取消