如何从代码中访问 3D 模型零件

发布于 2025-01-12 03:13:26 字数 30745 浏览 0 评论 0原文

我正在开发 RealityKit 应用程序项目,并尝试访问 3D 模型网格部件以更改其颜色或向其特定部分添加纹理, 我正在使用 usdz 和 obj 格式

我尝试了此代码,但出现运行时错误,

//bring Object from files
    
        let model = try! ModelEntity.loadModel(named: "frog.usdz")
        let anchorEntity = AnchorEntity(plane: .any)
        anchorEntity.addChild(model)
        print("Model is \(anchorEntity.children[0].components[ModelComponent]!)")

      //  let modelEntity = model.children[0] as! ModelEntity

      var part: ModelComponent = anchorEntity.children[0].components[ModelComponent]!
        
        print(part.mesh.contents.models.count)
      
        var List: MeshModelCollection = []
        List = part.mesh.contents.models
        print("head is \(List["/Head_Roundcube/Mesh"]!)")
        var head = List["/Head_Roundcube/Mesh"]! as? ModelComponent
        for item in part.mesh.contents.models {
            print("item: \(item.parts)")
        }
      //  print(part)
                
        //chenge the color if the object
        var material = SimpleMaterial()
        material.baseColor = .color(.white)
       // model.model?.materials = [material]
        head?.materials = [material]
        
        part.materials[0] = material
        
        model.addChild(part as! Entity)
       
         
        model.generateCollisionShapes(recursive: true)
        arView.installGestures([.translation,.rotation,.scale],for: model)
        arView.scene.anchors.append(anchorEntity)

有发生错误的屏幕截图 屏幕截图

这是我正在处理的对象 3d 对象

这些是控制台消息

Warning: in AppendProperty at line 859 of sdf/path.cpp -- Can only append a property 'triggers' to a prim path (/)
Model is ModelComponent(mesh: RealityKit.MeshResource, materials: [], _boundsMargin: 0.0)
3
head is Model(id: "/Head_Roundcube/Mesh", parts: RealityFoundation.MeshPartCollection(table: ["MeshPart": (extension in RealityFoundation):RealityKit.MeshResource.Part(bufferDict: RealityFoundation.MeshBufferDictionary(bufferTable: ["originalPartVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalPartVertexIndex", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "normals": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: "normals", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexTangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexTangent, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalModelVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalModelVertexIndex", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexNormal: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexNormal, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), indexTriangles: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt16>(id: indexTriangles, count: 12672, rate: RealityFoundation.MeshBuffers.Rate.faceVarying, elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt16>(closure: RealityFoundation.MeshBuffer<Swift.UInt16>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, count: 12672, rate: RealityFoundation.MeshBuffers.Rate.faceVarying)), "primvars:UVChannel_1": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: "primvars:UVChannel_1", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexPosition: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexPosition, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexUV: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: vertexUV, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexBitangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexBitangent, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex))]), id: "MeshPart", materialIndex: 0, materialWasInvalid: false)]))
item: MeshPartCollection(table: ["MeshPart": (extension in RealityFoundation):RealityKit.MeshResource.Part(bufferDict: RealityFoundation.MeshBufferDictionary(bufferTable: [vertexNormal: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexNormal, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexPosition: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexPosition, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "normals": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: "normals", count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalPartVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalPartVertexIndex", count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexBitangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexBitangent, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), indexTriangles: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt16>(id: indexTriangles, count: 9984, rate: RealityFoundation.MeshBuffers.Rate.faceVarying, elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt16>(closure: RealityFoundation.MeshBuffer<Swift.UInt16>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, count: 9984, rate: RealityFoundation.MeshBuffers.Rate.faceVarying)), vertexTangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexTangent, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalModelVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalModelVertexIndex", count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexUV: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: vertexUV, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "primvars:UVChannel_1": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: "primvars:UVChannel_1", count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex))]), id: "MeshPart", materialIndex: 0, materialWasInvalid: false)])
item: MeshPartCollection(table: ["MeshPart": (extension in RealityFoundation):RealityKit.MeshResource.Part(bufferDict: RealityFoundation.MeshBufferDictionary(bufferTable: [vertexBitangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexBitangent, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexPosition: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexPosition, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexUV: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: vertexUV, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexNormal: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexNormal, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "normals": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: "normals", count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexTangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexTangent, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalPartVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalPartVertexIndex", count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "primvars:UVChannel_1": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: "primvars:UVChannel_1", count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), indexTriangles: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt16>(id: indexTriangles, count: 38016, rate: RealityFoundation.MeshBuffers.Rate.faceVarying, elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt16>(closure: RealityFoundation.MeshBuffer<Swift.UInt16>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, count: 38016, rate: RealityFoundation.MeshBuffers.Rate.faceVarying)), "originalModelVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalModelVertexIndex", count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex))]), id: "MeshPart", materialIndex: 0, materialWasInvalid: false)])
item: MeshPartCollection(table: ["MeshPart": (extension in RealityFoundation):RealityKit.MeshResource.Part(bufferDict: RealityFoundation.MeshBufferDictionary(bufferTable: [vertexBitangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexBitangent, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalModelVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalModelVertexIndex", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexUV: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: vertexUV, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "normals": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: "normals", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexPosition: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexPosition, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexNormal: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexNormal, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexTangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexTangent, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalPartVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalPartVertexIndex", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), indexTriangles: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt16>(id: indexTriangles, count: 12672, rate: RealityFoundation.MeshBuffers.Rate.faceVarying, elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt16>(closure: RealityFoundation.MeshBuffer<Swift.UInt16>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, count: 12672, rate: RealityFoundation.MeshBuffers.Rate.faceVarying)), "primvars:UVChannel_1": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: "primvars:UVChannel_1", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex))]), id: "MeshPart", materialIndex: 0, materialWasInvalid: false)])
Swift/ContiguousArrayBuffer.swift:593: Fatal error: Index out of range
2022-03-07 01:31:45.189592+0300 MarsamApp[613:53684] Swift/ContiguousArrayBuffer.swift:593: Fatal error: Index out of range
(lldb) 

I am working on RealityKit app project and trying to access a 3D model mesh parts to change their color or to add texture to a specific part of it,
I am using usdz and obj format

I tried this code but I get a runtime error

//bring Object from files
    
        let model = try! ModelEntity.loadModel(named: "frog.usdz")
        let anchorEntity = AnchorEntity(plane: .any)
        anchorEntity.addChild(model)
        print("Model is \(anchorEntity.children[0].components[ModelComponent]!)")

      //  let modelEntity = model.children[0] as! ModelEntity

      var part: ModelComponent = anchorEntity.children[0].components[ModelComponent]!
        
        print(part.mesh.contents.models.count)
      
        var List: MeshModelCollection = []
        List = part.mesh.contents.models
        print("head is \(List["/Head_Roundcube/Mesh"]!)")
        var head = List["/Head_Roundcube/Mesh"]! as? ModelComponent
        for item in part.mesh.contents.models {
            print("item: \(item.parts)")
        }
      //  print(part)
                
        //chenge the color if the object
        var material = SimpleMaterial()
        material.baseColor = .color(.white)
       // model.model?.materials = [material]
        head?.materials = [material]
        
        part.materials[0] = material
        
        model.addChild(part as! Entity)
       
         
        model.generateCollisionShapes(recursive: true)
        arView.installGestures([.translation,.rotation,.scale],for: model)
        arView.scene.anchors.append(anchorEntity)

there is a screenshot of the error that occurs
Screenshot

and this is the object I and dealing with
3d object

and these are the console messages

Warning: in AppendProperty at line 859 of sdf/path.cpp -- Can only append a property 'triggers' to a prim path (/)
Model is ModelComponent(mesh: RealityKit.MeshResource, materials: [], _boundsMargin: 0.0)
3
head is Model(id: "/Head_Roundcube/Mesh", parts: RealityFoundation.MeshPartCollection(table: ["MeshPart": (extension in RealityFoundation):RealityKit.MeshResource.Part(bufferDict: RealityFoundation.MeshBufferDictionary(bufferTable: ["originalPartVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalPartVertexIndex", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "normals": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: "normals", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexTangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexTangent, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalModelVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalModelVertexIndex", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexNormal: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexNormal, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), indexTriangles: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt16>(id: indexTriangles, count: 12672, rate: RealityFoundation.MeshBuffers.Rate.faceVarying, elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt16>(closure: RealityFoundation.MeshBuffer<Swift.UInt16>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, count: 12672, rate: RealityFoundation.MeshBuffers.Rate.faceVarying)), "primvars:UVChannel_1": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: "primvars:UVChannel_1", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexPosition: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexPosition, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexUV: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: vertexUV, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexBitangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexBitangent, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex))]), id: "MeshPart", materialIndex: 0, materialWasInvalid: false)]))
item: MeshPartCollection(table: ["MeshPart": (extension in RealityFoundation):RealityKit.MeshResource.Part(bufferDict: RealityFoundation.MeshBufferDictionary(bufferTable: [vertexNormal: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexNormal, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexPosition: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexPosition, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "normals": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: "normals", count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalPartVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalPartVertexIndex", count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexBitangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexBitangent, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), indexTriangles: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt16>(id: indexTriangles, count: 9984, rate: RealityFoundation.MeshBuffers.Rate.faceVarying, elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt16>(closure: RealityFoundation.MeshBuffer<Swift.UInt16>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, count: 9984, rate: RealityFoundation.MeshBuffers.Rate.faceVarying)), vertexTangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexTangent, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalModelVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalModelVertexIndex", count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexUV: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: vertexUV, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "primvars:UVChannel_1": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: "primvars:UVChannel_1", count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 1802, rate: RealityFoundation.MeshBuffers.Rate.vertex))]), id: "MeshPart", materialIndex: 0, materialWasInvalid: false)])
item: MeshPartCollection(table: ["MeshPart": (extension in RealityFoundation):RealityKit.MeshResource.Part(bufferDict: RealityFoundation.MeshBufferDictionary(bufferTable: [vertexBitangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexBitangent, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexPosition: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexPosition, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexUV: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: vertexUV, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexNormal: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexNormal, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "normals": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: "normals", count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexTangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexTangent, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalPartVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalPartVertexIndex", count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "primvars:UVChannel_1": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: "primvars:UVChannel_1", count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex)), indexTriangles: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt16>(id: indexTriangles, count: 38016, rate: RealityFoundation.MeshBuffers.Rate.faceVarying, elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt16>(closure: RealityFoundation.MeshBuffer<Swift.UInt16>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, count: 38016, rate: RealityFoundation.MeshBuffers.Rate.faceVarying)), "originalModelVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalModelVertexIndex", count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 6625, rate: RealityFoundation.MeshBuffers.Rate.vertex))]), id: "MeshPart", materialIndex: 0, materialWasInvalid: false)])
item: MeshPartCollection(table: ["MeshPart": (extension in RealityFoundation):RealityKit.MeshResource.Part(bufferDict: RealityFoundation.MeshBufferDictionary(bufferTable: [vertexBitangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexBitangent, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalModelVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalModelVertexIndex", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexUV: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: vertexUV, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "normals": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: "normals", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexPosition: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexPosition, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexNormal: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexNormal, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), vertexTangent: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<RealityFoundation.FloatVector3Packed>(id: vertexTangent, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, buffer: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>(closure: RealityFoundation.MeshBuffer<RealityFoundation.FloatVector3Packed>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd3Float, packed: true, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), "originalPartVertexIndex": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt32>(id: "originalPartVertexIndex", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt32>(closure: RealityFoundation.MeshBuffer<Swift.UInt32>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt32, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex)), indexTriangles: RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.UInt16>(id: indexTriangles, count: 12672, rate: RealityFoundation.MeshBuffers.Rate.faceVarying, elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.UInt16>(closure: RealityFoundation.MeshBuffer<Swift.UInt16>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.uInt16, packed: false, count: 12672, rate: RealityFoundation.MeshBuffers.Rate.faceVarying)), "primvars:UVChannel_1": RealityFoundation.MeshBufferDictionary.(unknown context at $1f4023720).BufferEntry<Swift.SIMD2<Swift.Float>>(id: "primvars:UVChannel_1", count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex, elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, buffer: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>(closure: RealityFoundation.MeshBuffer<Swift.SIMD2<Swift.Float>>.Closures(getArray: (Function), getIndices: (Function), getData: (Function), chunk: (Function)), elementType: RealityFoundation.MeshBuffers.ElementType.simd2Float, packed: false, count: 2210, rate: RealityFoundation.MeshBuffers.Rate.vertex))]), id: "MeshPart", materialIndex: 0, materialWasInvalid: false)])
Swift/ContiguousArrayBuffer.swift:593: Fatal error: Index out of range
2022-03-07 01:31:45.189592+0300 MarsamApp[613:53684] Swift/ContiguousArrayBuffer.swift:593: Fatal error: Index out of range
(lldb) 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文