ARAnchor 和 AnchorEntity 有什么区别? [英] What's the difference between ARAnchor and AnchorEntity?
问题描述
我目前正在用 RealityKit 做一些实验.
I'm currently doing some experiments with RealityKit.
我一直在查看一些示例代码,我对 ARAnchor
和 AnchorEntity
之间的区别以及何时使用一个而不是另一个感到有些困惑.
I've been looking at some sample code, and I'm a bit confused about the differences between ARAnchor
and AnchorEntity
, and when to use one over the other.
到目前为止我知道:
- 两者都是描述现实世界中位置的锚点.
AnchorEntity
还可以将其他Entity
作为子项,因此您可以将模型对象直接添加到锚点.你不能用ARAnchor
做到这一点,你必须手动"将模型对象添加到rootNode
,并正确使用锚点的位置.莉>- 在文档中,它说 ARKit 使用添加的
ARAnchor
来优化锚点周围区域的跟踪.AnchorEntity
的文档没有指定这一点.
- Both are anchors that describes a position in the real world.
AnchorEntity
can also have otherEntity
's as children, so you can add model objects directly to the anchor. You can't do this withARAnchor
, you have to add model objects "manually" to therootNode
, and use the position of the anchor the place it correctly.- In the documentation it says that ARKit uses the added
ARAnchor
to optimize the tracking in the area around the anchor. The documentation forAnchorEntity
does not specify this.
现在我将 AnchorEntity
作为根节点"添加到会话中,因为它更易于使用,因此我可以简单地将模型作为子项直接添加到此锚点.但随后我还向场景的锚点添加了位于相同位置的 ARAnchor
,以增强围绕该点的跟踪.这是必要的吗?
Right now I add a AnchorEntity
to the session as a "root node", since it's simpler to use, so that I can simply add models as children directly to this anchor. But then I also add a ARAnchor
, located at the same position, to the scene's anchors, to enhance tracking around this point. Is this nececary?
推荐答案
更新时间:2021 年 4 月 3 日.
ARAnchor
类和 AnchorEntity
类都是为了同一个神圣的目的而创建的——连接 3D 内容到您的真实世界对象.
ARAnchor
class and AnchorEntity
class were both made for the same divine purpose – to tether a 3D content to your real-world objects.
RealityKit AnchorEntity
极大地扩展了 ARKit ARAnchor
的功能.这两者之间最重要的区别是 AnchorEntity
自动跟踪现实世界的目标,但 ARAnchor
需要 renderer(...)
或 >session(...)
实例方法来实现这一点.还要考虑到 ARAnchors
的集合存储在 ARSession 中,而 AnchorEntities
的集合存储在 Scene 中.
RealityKit AnchorEntity
greatly extends the capabilities of ARKit ARAnchor
. The most important difference between these two is that AnchorEntity
automatically tracks a real world target, but ARAnchor
needs renderer(...)
or session(...)
instance methods to accomplish this. Also take into consideration that the collection of ARAnchors
is stored in the ARSession and the collection of AnchorEntities
is stored in the Scene.
以下是层次差异:
RealityKit 的主要优点是能够同时使用不同的 AnchorEntities,例如 .plane
、.image
和 .object
.
The main advantage of RealityKit is the ability to use different AnchorEntities at the same time, such as .plane
, .image
and .object
.
在 ARKit 中,如您所知,您只能在当前会话中运行一个配置:World、Image 或 Object.然而,ARKit 中有一个例外——你可以同时运行两个配置——WorldTracking 和 FaceTracking(但第一个必须是驱动程序,另一个必须是 驱动).
In ARKit, as you know, you can run just one config in the current session: World, Image, or Object. There is an exception in ARKit, however - you can run two configs together - WorldTracking and FaceTracking (but first one has to be a driver, and the other one – driven).
Apple 开发者文档说:
Apple Developer documentation says:
在 RealityKit 框架中,您使用 AnchorEntity
实例作为实体层次结构的根,并将其添加到场景的 anchors 集合
实例.这使得 ARKit 能够将锚实体及其所有层次结构的后代放置到现实世界中.除了锚实体从Entity
类继承的组件外,锚实体还符合HasAnchoring
协议,赋予它一个AnchoringComponent
实例.
In RealityKit framework you use an
AnchorEntity
instance as the root of an entity hierarchy, and add it to theanchors collection
for a Scene instance. This enables ARKit to place the anchor entity, along with all of its hierarchical descendants, into the real world. In addition to the components the anchor entity inherits from theEntity
class, the anchor entity also conforms to theHasAnchoring
protocol, giving it anAnchoringComponent
instance.
AnchorEntity
具有三个构建块:
- 变换组件(包含平移、旋转和缩放的变换矩阵)
- 同步组件(用于多用户体验的实体同步数据)
- 锚定组件(允许选择锚的类型——
world
、body
或image
)
所有实体都有同步组件
,有助于组织协作会话.
All entities have Synchronization component
that helps organise collaborative sessions.
AnchorEntity
有九种特定的锚点类型,用于九种不同的目的:
AnchorEntity
has nine specific anchor types for nine different purposes:
- ARAnchor
- 帮助实现 10 个 ARKit 锚点,包括 ARGeoAnchor 和 ARAppClipCodeAnchor
您可以在您的应用中同时使用ARAnchor
和AnchorEntity
这两个类.或者你可以只使用AnchorEntity
类,因为它足够了.
You can simultaneously use both classesARAnchor
andAnchorEntity
in your app. Or you can use justAnchorEntity
class because it's all-sufficient one.有关
ARAnchor
和AnchorEntity
的更多信息,请查看这篇文章.For additional info about
ARAnchor
andAnchorEntity
, please look at THIS POST.这篇关于ARAnchor 和 AnchorEntity 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!