Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARKit - SceneView Display wrong position 3D Model

Tags:

ios

swift

arkit

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.

like image 539
ashish Avatar asked Dec 06 '25 03:12

ashish


1 Answers

I have followed same tutorial and it's working fine. I think you have irritated your 3D model. Just delete your current car.dae and add new one from tutorial's project starter. Clean project and run again will fix your issue.

like image 172
Ravi B Avatar answered Dec 08 '25 18:12

Ravi B