将 RealityKit 的 "rcproject" 添加到 ARKit 的 SCNScene
Add a RealityKit's "rcproject" to ARKit's SCNScene
我正在尝试将 .rcproject
添加到我的 SCNView。我正在与 SwitftUI 一起工作,完全迷路了。我不知道如何添加它。
目前我可以使用 ARKit 检测我在房间里的物体。但我也想在这个锚点添加来自 RealityKit 的场景。
有办法吗?
func renderer(_ renderer: SCNSceneRenderer,
didAdd node: SCNNode,
for anchor: ARAnchor) {
if let objectAnchor = anchor as? ARObjectAnchor {
let name = objectAnchor.referenceObject.name!
print("You found a \(name) object")
let titleNode = createTitleNode(name)
node.addChildNode(titleNode)
let example_scene = try! RealityExample.loadScene()
arView.scene.anchors.append(example_scene)
// not possible, because this is not a SCNScene
}
}
非常感谢。
您 can't read in Reality Composer project (.rcproject
) into ARSCNView's scene (.scn
). That's because SceneKit isn't able to handle RealityKit's objects and hierarchy. In SceneKit there are nodes (SCNNode
class) connected to scene's root node (however, if you're using SceneKit with ARKit, nodes must be also tethered with ARAnchors), but in RealityKit there are entities(ModelEntity
class)通过 AnchorEntities
连接到场景。这两个框架完全不同。
RealityKit 和 SceneKit 唯一可以共享的文件格式是 Pixar 的 .usdz
.
我正在尝试将 .rcproject
添加到我的 SCNView。我正在与 SwitftUI 一起工作,完全迷路了。我不知道如何添加它。
目前我可以使用 ARKit 检测我在房间里的物体。但我也想在这个锚点添加来自 RealityKit 的场景。
有办法吗?
func renderer(_ renderer: SCNSceneRenderer,
didAdd node: SCNNode,
for anchor: ARAnchor) {
if let objectAnchor = anchor as? ARObjectAnchor {
let name = objectAnchor.referenceObject.name!
print("You found a \(name) object")
let titleNode = createTitleNode(name)
node.addChildNode(titleNode)
let example_scene = try! RealityExample.loadScene()
arView.scene.anchors.append(example_scene)
// not possible, because this is not a SCNScene
}
}
非常感谢。
您 can't read in Reality Composer project (.rcproject
) into ARSCNView's scene (.scn
). That's because SceneKit isn't able to handle RealityKit's objects and hierarchy. In SceneKit there are nodes (SCNNode
class) connected to scene's root node (however, if you're using SceneKit with ARKit, nodes must be also tethered with ARAnchors), but in RealityKit there are entities(ModelEntity
class)通过 AnchorEntities
连接到场景。这两个框架完全不同。
RealityKit 和 SceneKit 唯一可以共享的文件格式是 Pixar 的 .usdz
.