ios - ARKit - SceneView Display wrong position 3D Model
问题描述
I have working on ARKit and it's my beginning. I have added 3D model to display on my ARSCNView. I'm following this tutorial: https://www.appcoda.com/arkit-3d-object/
I'm using same car model which are available in this tutorial. When I add scene node to rootNode. The position of model not proper.
My code as follow:
@IBOutlet weak var sceneView: ARSCNView!
func addCar(x: Float = 0, y: Float = 0, z: Float = -0.5) {
// Safely initialize car.dae scene
guard let carScene = SCNScene(named: "car.dae") else { return }
// Initialize a SCNNode object for the car node
let carNode = SCNNode()
let carSceneChildNodes = carScene.rootNode.childNodes
carSceneChildNodes.forEach { carNode.addChildNode($0) }
carNode.position = SCNVector3(x, y, z)
carNode.scale = SCNVector3(0.5, 0.5, 0.5)
sceneView.scene.rootNode.addChildNode(carNode)
}
I want to display car in proper position as display in following screenshot:
Expected:
Output:
Can anyone explain what is my mistake ?? Help will be appreciate.
解决方案
我遵循了相同的教程,并且工作正常。我认为你激怒了你的 3D 模型。只需删除您当前的car.dae并从教程的项目启动器中添加新的。清理项目并再次运行将解决您的问题。
推荐阅读
- java - 如何使用 JDBC 返回特定 oracle 类型的 java 类型?
- react-native - 如何以分钟间隔制作进度条?
- r - 你能解释一下为什么我不能在 R 版本 3.4.4 上安装 rlang 0.4.10 吗?
- graph - 在 Gremlin 中使用多个模式条件遍历图形
- typescript - 如何从类型中省略可选属性?
- uber-api - Uber 应用程序中的公共交通信息 - 我们可以通过 Uber Api 获取吗?
- java - 如何解决快速入门示例中的 javax.net.ssl.SSLException?
- c# - RDLC 列可见性表达式引发错误:本机编译器返回值:在此上下文中不可访问,因为它是“朋友”
- reactjs - 如何使用更新状态的自定义服务器端分页在反应钩子中执行一次useEffect
- reactjs - jsonwebtoken 解码的打字稿错误