ZKe
ZKe

Reputation: 101

ARKit model problem, the object moves with the camera, instead of stick to the environment

I'm working on an app using ARKit in XCode. I want to set my object fixed, therefore I can have a close look at it. But the fact is that the object moves with the camera, I can't shorten the distance between my camera and my object by moving my phone.

func addCar(x: Float = 0, y: Float = 0, z: Float = -0.5) {
        guard let carScene = SCNScene(named: "NanYi.dae") else { fatalError("Unable to find FruitCake.dae") }
        let carNode = SCNNode()
        let carSceneChildNodes = carScene.rootNode.childNodes

        for childNode in carSceneChildNodes {
            carNode.addChildNode(childNode)
        }
        carNode.position = SCNVector3(x, y, z)
        carNode.scale = SCNVector3(0.5, 0.5, 0.5)
        sceneView.scene.rootNode.addChildNode(carNode)
    }

And also, the structure of my 3D object is like this, https://drive.google.com/file/d/1ErVzPa_24fWHFlL6nHLzJBwj0TtbMtQ1/view?usp=sharing

Upvotes: 1

Views: 224

Answers (1)

ZKe
ZKe

Reputation: 101

Problem solved. If you are using a very large or complex model, you need to scale it down to a very very small size. Then it works.

Upvotes: 2

Related Questions