【问题标题】:RealityKit – arView.scene add AnchorEntityRealityKit – arView.scene 添加 AnchorEntity
【发布时间】:2020-08-25 00:53:51
【问题描述】:

苹果文档:Stored Entities

我的另一个问题:RealityKit – Stored Entities & Load the Scene Aynchronously from the URL

我的函数结果返回一个 (Entity & HasAnchoring)

我的问题是...如何显示 AnchorEntity。(self.arView.scene.addAnchor??)

我是新来的。谢谢

【问题讨论】:

    标签: swift augmented-reality arkit realitykit


    【解决方案1】:

    加载 AnchorEntity 后,您可以像这样将其添加到场景中:

    arView.scene.addAnchor(anchor)
    

    应该就是这样。例如,如果您在 RealityComposer 中创建项目时设置了水平面锚定,那么一旦检测到水平面,它就应该放置您的 AnchorEntity

    iOS 13.5 到 13.6.1 中存在一个错误。它已在 iOS 14 测试版中修复。一种解决方法是改用 .rcproject 文件格式。

    if let anchor = try? Entity.loadAnchor(named: "AR") {            
        arView.scene.addAnchor(anchor)
    }
    

    【讨论】:

    • 抱歉这么晚才回复您。我正在找工作。当我使用 code.anchor 时它崩溃了(Entity & HasAnchoring)。 Here is my code你能给我一些建议吗? THX.祝你有美好的一天。
    • iOS 13.5 到 13.6.1 中存在一个错误,它会导致加载 AnchorEntities 崩溃,就像在您的代码中一样。您对此无能为力,但它似乎已在 iOS 14 测试版中得到修复。因此,您可以更新到测试版,也可以使用 .rcproject 文件格式作为解决方法。我将使用解决方法更新我的答案
    • 非常非常非常感谢。 ?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-22
    • 2020-08-07
    • 1970-01-01
    • 2020-05-01
    • 2021-03-25
    • 2020-01-27
    • 2020-06-09
    相关资源
    最近更新 更多