ARKit 和 .dae 文件,对象之间的奇怪 space

ARKit and .dae file , strange space between object

在我使用 ARKit 和 sceneKit 的研究项目中,我在使用 .dae 文件时遇到了一个奇怪的行为。

我使用以下方法创建了 2 个对象,一个立方体和一个平面(均具有物理特性):

  func loadBox() {
        let ballGeometry = SCNBox(width: 0.2, height: 0.2, length: 0.2, chamferRadius: 0.02)
        let mat = SCNMaterial()
        mat.diffuse.contents = UIImage(named: "ball")
        ballGeometry.materials = [mat]
        //Physic
        let physSchape  = SCNPhysicsShape(geometry: ballGeometry, options: nil)
        let ballPhysic = SCNPhysicsBody(type: .dynamic, shape: physSchape)
        ballPhysic.mass = 100
        ballPhysic.friction = 0.8
        ballPhysic.isAffectedByGravity = true
        let nodeBall = SCNNode(geometry: ballGeometry)
        nodeBall.name = "ball"
        nodeBall.physicsBody = ballPhysic
        
        box = nodeBall
    }


func loadPlane(){
        let geometry = SCNPlane(width: 1, height: 1)
        let material = SCNMaterial()
        material.diffuse.contents = UIImage(named: "texture")
        geometry.materials = [material]
        // physics
        let physSchape  = SCNPhysicsShape(geometry: geometry, options: nil)
        let planePhysic = SCNPhysicsBody(type: .static, shape: physSchape)
        planePhysic.restitution = 0.0
        planePhysic.friction = 1.0
        planePhysic.isAffectedByGravity = true
        let nodo = SCNNode(geometry: geometry)
        nodo.eulerAngles.x = -.pi / 2
        nodo.physicsBody = planePhysic
        plane = nodo
    }

当我将盒子放在场景中的平面上时,它们正确定位并相互接触,如下图所示:

问题在这里:

如果我使用从互联网上下载的模型作为飞机的 .dae 文件,当将其插入场景时,它会在盒子和飞机之间创建一个奇怪的 space(见图)

我用来加载scn文件的方法。

  // load the elicopterBase
    func loadElicopterBase(){

        guard let scene = SCNScene(named: "Model.scnassets/base.scn") else {fatalError()}
       
        guard let nodo = scene.rootNode.childNode(withName: "Plane", recursively: true) else {fatalError()}
        // physics
        let physSchape  = SCNPhysicsShape(node: nodo, options: nil)
        let planePhysic = SCNPhysicsBody(type: .static, shape: physSchape)
        planePhysic.restitution = 0.0
        planePhysic.friction = 1.0
        planePhysic.isAffectedByGravity = true
        nodo.physicsBody = planePhysic
        nodo.name = "base"
            DispatchQueue.main.async {
                self.eliporto = nodo
            }
    }

看起来 .dae 文件周围有某种不可见的边界框。 我可以寻找什么或在哪里找到解决方案。

这里是 Xcode

中 .dae 文件的一些图片

像这样制作“凹多面体”类型的平面图:

let body = SCNPhysicsBody(type: .static, shape: SCNPhysicsShape(geometry: yourGeometry, options: [SCNPhysicsShape.Option.type: SCNPhysicsShape.ShapeType.concavePolyhedron]))