【问题标题】:RealityKit – Face Anchor not putting model in ARRealityKit – Face Anchor 未将模型放入 AR
【发布时间】:2022-08-05 19:17:39
【问题描述】:

我正在使用 RealityKit 面部锚点。我从 SketchFab 下载了一个模型,但我试图将模型放在脸上,它不起作用并且不显示任何内容。

struct ARViewContainer: UIViewRepresentable {
    
    func makeUIView(context: Context) -> ARView {
        
        let arView = ARView(frame: .zero)
        
        let configuration = ARFaceTrackingConfiguration()
        arView.session.run(configuration)
        
        let anchor = AnchorEntity(.face)
        let model = try! Entity.loadModel(named: \"squid-game\")
        
        anchor.addChild(model)
        arView.scene.addAnchor(anchor)           
        return arView
    }       
    func updateUIView(_ uiView: ARView, context: Context) { }
}

    标签: swift swiftui scenekit arkit realitykit


    【解决方案1】:
    1. AR 开发人员可以处理的最常见问题之一是模型大小。在 RealityKit、ARKit、RoomPlan 和 SceneKit 中,工作单位是米。在 3dsMax 或 Blender 中创建的模型经常以厘米级导入 Xcode。因此,它们比应有的大 100 倍。您看不到您的模型,因为您可能在其中,并且着色器的内表面未在 RealityKit 中渲染。因此,您所需要的只是缩放模型的大小。

       anchor.scale /= 100
      
    2. 第二个常见问题是枢轴点的位置。在 99% 的情况下,支点应该在模型内部。模型的支点就像“飞镖”,.face 锚点就像“10 点”。不幸的是,RealityKit 2.0 没有控制枢轴的能力。 SceneKit 可以。

    3. 还有硬件限制。运行以下简单检查:

       if !ARFaceTrackingConfiguration.isSupported {
           print("Your device isn't supported")
       } else {
           let config = ARFaceTrackingConfiguration()
           arView.session.run(config)
       }
      
    4. 我还建议您在 Reality Composer 应用程序中打开您的 .usdz 模型,以确保它可以成功加载并且不是 100% 透明的。

    【讨论】:

      【解决方案2】:
      1. 检查您的型号。
      2. 运行演示时有error吗?
      3. 您可以使用.reality 文件进行测试,也可以从Apple Developer 站点下载示例。

      【讨论】:

        猜你喜欢
        • 2021-09-04
        • 1970-01-01
        • 1970-01-01
        • 2021-12-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-29
        相关资源
        最近更新 更多