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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With