ARKit 中渲染器和 session 方法的区别
Difference between renderer and session methods in ARKit
我检查了以下两个示例代码:https://developer.apple.com/documentation/arkit/capturing_body_motion_in_3d
func session(_ session: ARSession, didUpdate anchors: [ARAnchor])
{
for anchor in anchors
{
guard let bodyAnchor = anchor as? ARBodyAnchor else { continue }
let skeleton = bodyAnchor.skeleton
}
}
和:https://developer.apple.com/documentation/arkit/tracking_and_visualizing_faces
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor)
{
guard let faceAnchor = anchor as? ARFaceAnchor else { return }
let blendShapes = faceAnchor.blendShapes
}
提取面部BlendShape的代码使用"renderer"获取BlendShape的值。
但是,检测 body 移动的代码使用 "session" 来获取值。
这两个代码似乎都是为了获取从 ARAnchor 更新的值。
"renderer"和"session"有什么区别?
如何在不同时间使用这两个代码?
renderer(_:didUpdate:for:)
和 session(_:didUpdate:)
实例方法都以 60 fps 的速度更新 AR 内容(camera/model 位置或某些特定数据,如面部表情)。它们的工作方式几乎相同,但目的不同。对于五个 renderer(...)
实例方法,您必须实施 ARSCNViewDelegate protocol. For four session(...)
instance methods you have to implement ARSessionDelegate 协议。
官方文档说:
ARSCNViewDelegate's methods provide the automatic synchronization of SceneKit content with an AR session. And ARSessionDelegate's methods work directly with ARFrame objects.
主要区别是:
你必须使用 renderer(_:didUpdate:for:)
ARKit+SceneKit copula 的实例方法,因为它适用于 ARSCNView 对象。
此外,您可以对 ARKit+SceneKit copula 使用 session(_:didUpdate:)
方法,因为它也适用于 ARSCNView 对象。
并且您必须对 ARKit+RealityKit copula 使用 session(_:didUpdate:)
方法,因为它适用于 ARView 对象。
我检查了以下两个示例代码:https://developer.apple.com/documentation/arkit/capturing_body_motion_in_3d
func session(_ session: ARSession, didUpdate anchors: [ARAnchor])
{
for anchor in anchors
{
guard let bodyAnchor = anchor as? ARBodyAnchor else { continue }
let skeleton = bodyAnchor.skeleton
}
}
和:https://developer.apple.com/documentation/arkit/tracking_and_visualizing_faces
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor)
{
guard let faceAnchor = anchor as? ARFaceAnchor else { return }
let blendShapes = faceAnchor.blendShapes
}
提取面部BlendShape的代码使用"renderer"获取BlendShape的值。
但是,检测 body 移动的代码使用 "session" 来获取值。
这两个代码似乎都是为了获取从 ARAnchor 更新的值。
"renderer"和"session"有什么区别?
如何在不同时间使用这两个代码?
renderer(_:didUpdate:for:)
和 session(_:didUpdate:)
实例方法都以 60 fps 的速度更新 AR 内容(camera/model 位置或某些特定数据,如面部表情)。它们的工作方式几乎相同,但目的不同。对于五个 renderer(...)
实例方法,您必须实施 ARSCNViewDelegate protocol. For four session(...)
instance methods you have to implement ARSessionDelegate 协议。
官方文档说:
ARSCNViewDelegate's methods provide the automatic synchronization of SceneKit content with an AR session. And ARSessionDelegate's methods work directly with ARFrame objects.
主要区别是:
你必须使用
renderer(_:didUpdate:for:)
ARKit+SceneKit copula 的实例方法,因为它适用于 ARSCNView 对象。此外,您可以对 ARKit+SceneKit copula 使用
session(_:didUpdate:)
方法,因为它也适用于 ARSCNView 对象。并且您必须对 ARKit+RealityKit copula 使用
session(_:didUpdate:)
方法,因为它适用于 ARView 对象。