ARAnchor和AnchorEntity有什么区别? [英] What's the difference between ARAnchor and AnchorEntity?

查看:309
本文介绍了ARAnchor和AnchorEntity有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用RealityKit做一些实验.

I'm currently doing some experiments with RealityKit.

我一直在看一些示例代码,对于ARAnchorAnchorEntity之间的区别以及何时使用它们之间的区别我有些困惑.

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 other Entity's as children, so you can add model objects directly to the anchor. You can't do this with ARAnchor, you have to add model objects "manually" to the rootNode, 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 for AnchorEntity 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?

推荐答案

RealityKit的AnchorEntity类大大扩展了ARAnchors的功能.

RealityKit's AnchorEntity class greatly extends the capabilities of ARAnchors.

ARKit中的

ARAnchor 类和RealityKit中的 AnchorEntity 类都是出于相同的神圣目的而制作的-将3D内容绑定到现实世界中的对象

ARAnchor class in ARKit and AnchorEntity class in RealityKit were both made for the same divine purpose – to tether a 3D content to your real-world objects.

但是,这两个类在场景中的层次结构上略有不同.这是描述其外观的图像:

But these two classes slightly differ in hierarchical construction found in scenes. Here's an image depicting how it looks like:

Apple Developer文档说:

Apple Developer documentation says:

在RealityKit框架中,您将AnchorEntity实例用作实体层次结构的根,并将其添加到场景实例的 anchors collection 中.这使ARKit可以将锚实体及其所有层次后代放置到现实世界中.

In RealityKit framework you use an AnchorEntity instance as the root of an entity hierarchy, and add it to the anchors collection for a Scene instance. This enables ARKit to place the anchor entity, along with all of its hierarchical descendants, into the real world.

此外,文档还介绍了有关AnchorEntity的以下内容:

Also the documentation says about AnchorEntity the following :

除了锚实体从Entity类继承的组件之外,锚实体还符合HasAnchoring协议,并为其提供了AnchoringComponent实例.

In addition to the components the anchor entity inherits from the Entity class, the anchor entity also conforms to the HasAnchoring protocol, giving it an AnchoringComponent instance.

AnchorEntity其中包含三个构建基块:

AnchorEntity has three building blocks in it:

  • 变换组件(包含平移,旋转和缩放的变换矩阵)
  • 同步组件(网络应用程序的实体同步数据)
  • 锚定组件(这是将3D内容锚定到现实世界中的方式)
  • Transform component (transform matrix containing translate, rotate and scale)
  • Synchronization component (entity's synchro-data for networked applications)
  • Anchoring component (it's how 3D content can be anchored to the real world)

查看此图片以了解有关实体的更多信息.所有实体都有Synchronization component可以帮助组织协作会议.

Look at this picture to find out more about entities. All entities have Synchronization component that helps organise collaborative sessions.

并且AnchorEntity具有九种用于不同目的的特定类型:

And AnchorEntity has nine specific types for different purposes:

  • 身体
  • 相机
  • 图片
  • 对象
  • 飞机
  • 世界
  • raycastResult
  • 锚(来自ARKit)

您可以同时在应用程序中同时使用类ARAnchorAnchorEntity .或者,您可以只使用AnchorEntity类,因为它已经足够了.

You can simultaneously use both classes ARAnchor and AnchorEntity in your app. Or you can use just AnchorEntity class 'cause it's all-sufficient one.

有关ARAnchor类的其他信息,请查看 此帖子 .

For additional info on ARAnchor class, please look at THIS POST.

这篇关于ARAnchor和AnchorEntity有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆