首页 > 解决方案 > 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:

ARKit Expected Image

Output:

ARKit Output Image

Can anyone explain what is my mistake ?? Help will be appreciate.

标签: iosswiftarkit

解决方案


我遵循了相同的教程,并且工作正常。我认为你激怒了你的 3D 模型。只需删除您当前的car.dae并从教程的项目启动器中添加新的。清理项目并再次运行将解决您的问题。


推荐阅读