空间定位点Spatial anchors

空间定位点表示系统在一段时间内跟踪的重要点。A spatial anchor represents an important point in the world that the system tracks over time. 每个定位点都具有可调整的 坐标系统(基于其他定位点或引用框架),以确保定位的全息影像保持准确。Each anchor has an adjustable coordinate system, based on other anchors or frames of reference, to ensure anchored holograms stay precisely in place. 在定位点的坐标系统中渲染全息图,可以在任何给定时间精确定位到该全息图。Rendering a hologram in an anchor's coordinate system gives you the most precise positioning for that hologram at any given time. 随着系统不断地将其返回到基于现实世界的位置,这是一段时间内的小调整成本。This comes at the cost of small adjustments over time to the hologram's position as the system continually moves it back into place based on the real world.

你还可以跨应用程序会话和跨设备保留和共享空间定位点:You can also persist and share spatial anchors across application sessions and across devices:

  • 通过将本地空间锚点保存到磁盘并稍后将其加载回来,你的应用程序可以在一个 HoloLens 上跨多个应用程序会话计算同一位置。By saving local spatial anchors to disk and loading them back later, your application can calculate the same location in the real world across multiple application sessions on a single HoloLens.
  • 使用 Azure 空间锚 点创建云锚点,你的应用程序可以跨多个 HoloLens、IOS 和 Android 设备共享空间锚。By using Azure Spatial Anchors to create a cloud anchor, your application can share a spatial anchor across multiple HoloLens, iOS, and Android devices. 通过让每个设备使用相同的空间定位点呈现一个全息影像,用户将看到全息图显示在现实世界中的同一位置。By having each device render a hologram using the same spatial anchor, users will see the hologram appear at the same place in the real world. 这可实现实时共享体验。This allows for real-time shared experiences.
  • 你还可以将 Azure 空间锚点 用于每个 HoloLens、IOS 和 Android 设备上的异步全息影像。You can also use Azure Spatial Anchors for asynchronous hologram persistence across HoloLens, iOS, and Android devices. 通过共享持久云空间锚点,多个设备可以在一段时间内观察到相同的持久全息图,即使这些设备同时不存在。By sharing a durable cloud spatial anchor, multiple devices can observe the same persisted hologram over time, even if those devices aren't present together at the same time.

对于受限台式机耳机的大规模或房间规模体验,这些体验将停留在5米内,你通常可以使用 参考的阶段框架 ,而不是空间锚,为你提供一个用于呈现所有内容的单一坐标系统。For standing-scale or room-scale experiences for tethered desktop headsets that will stay within a 5-meter diameter, you can typically use the stage frame of reference instead of spatial anchors, which provides you a single coordinate system in which to render all content. 但是,如果你的应用程序允许用户在一座办公楼的整个楼层内游离超过5米,则需要使用空间锚来保持内容稳定。However, if your application lets users wander beyond 5 meters in HoloLens, perhaps operating throughout an entire floor of a building, you'll need spatial anchors to keep content stable.

虽然空间定位点非常适合应该在世界中保持固定的全息影像,但是放置定位点后,它便无法移动。While spatial anchors are great for holograms that should remain fixed in the world, once an anchor is placed, it can't be moved. 对于与用户一起标记的动态全息影像,更适合定位锚。There are alternatives to anchors that are more appropriate for dynamic holograms that tag along with the user. 最好使用固定的参考框架 (,即 Unity 世界坐标的基础) 或附加的参考框架。It's best to position dynamic holograms using a stationary frame of reference (the foundation for Unity's world coordinates) or an attached frame of reference.

最佳做法Best practices

这些空间定位点指南将帮助你呈现稳定的全息影像,准确跟踪现实世界。These spatial anchor guidelines will help you render stable holograms that accurately track the real world.

在用户需要放置空间定位点的位置创建空间定位点Create spatial anchors where users place them

通常,用户是显式放置空间锚的用户。Typically, users are the ones explicitly placing spatial anchors.

例如,在 HoloLens 上,应用程序可以使用空间映射网格将用户的 "注视" 光线与用户的 "注视" 网格相交,让用户决定放置全息图的位置。For example, on HoloLens, an application can intersect the user's gaze ray with the spatial mapping mesh to let the user decide where to place a hologram. 当用户点击来放置该全息图时,请在交点处创建一个空间锚点,然后将其放置在该锚点坐标系统的原点。When the user taps to place that hologram, create a spatial anchor at the intersection point, and then place the hologram at the origin of that anchor's coordinate system.

本地空间锚容易创建。Local spatial anchors are easy and performant to create. 如果多个定位点可以共享其底层的传感器数据,则系统会合并内部数据。The system combines internal data if multiple anchors can share their underlying sensor data. 对于用户显式放置的每个全息图,我们建议为其创建新的本地空间定位点,如下面所述的情况(如下面所述的情况除外)。We recommend creating a new local spatial anchor for each hologram that a user explicitly places, except in cases outlined below, such as rigid groups of holograms.

始终呈现定位点 3 米范围内的锚定的全息影像Always render anchored holograms within 3 meters of their anchor

空间定位点稳定定位点原点附近的坐标系。Spatial anchors stabilize their coordinate system near the anchor's origin. 如果从原点渲染全息量超过3米,则全息影像可能会遇到明显的位置错误,与来自原点的距离不同,因为有杠杆的视觉效果。If you render holograms more than 3 meters from the origin, the holograms might experience noticeable positional errors in proportion to their distance from that origin because of lever-arm effects. 如果用户位于定位点附近,则此操作将起作用,因为全息图也远离用户。This works if the user stands near the anchor, since the hologram is far away from the user, too. 换句话说,遥远全息图的角度误差将会很小。In other words, the angular error of the distant hologram will be small. 不过,如果用户走到了远处的全息图,它会在其视图中变大,使遥远定位点源的杠杆臂效果明显明显。However, if the user walks up to that distant hologram, it will be large in their view, making the lever-arm effects from the faraway anchor origin obvious.

聚集应形成固定群集的全息影像Group holograms that should form a rigid cluster

如果应用程序预期这些全息影像彼此保持固定关系,则多个全息影像可以共享同一个空间定位点。Multiple holograms can share the same spatial anchor if the application expects those holograms to maintain fixed relationships with one another.

例如,如果您要对房间中的全息阳历系统进行动画处理,则最好将所有阳历系统对象都绑定到中心的单个锚。For example, if you're animating a holographic solar system in a room, it's better to tie all of the solar system objects to a single anchor in the center. 这样,它们就可以彼此平稳地进行切换。That way, they'll move smoothly based on each other. 在这种情况下,它是一个锚定的整体系统,即使其组件部分动态地围绕定位点移动。In this case, it's the solar system as a whole that is anchored, even though its component parts are moving dynamically around the anchor.

保持全息图稳定性的关键是遵循上面的3米规则。The key caveat to maintain hologram stability is to follow the 3-meter rule above.

使用固定参照系(而不是局部空间定位点)呈现高度动态全息影像Render highly dynamic holograms using the stationary frame of reference instead of a local spatial anchor

如果你有一个高度动态的全息图(例如,人物围绕用户附近的墙壁或浮动 UI),最好跳过本地空间锚,并直接在 固定的参考框架提供的坐标系统中渲染这些全息影像。If you have a highly dynamic hologram, such as a character walking around a room or a floating UI that follows along the wall near the user, it's best to skip local spatial anchors, and render those holograms directly in the coordinate system provided by the stationary frame of reference. 在 Unity 中,可以通过在不使用 WorldAnchor 的情况下直接将全息影像置于世界坐标中来实现此目的。In Unity, you achieve this by placing holograms directly in world coordinates without a WorldAnchor. 当用户离全息影像时,固定框架中的全息影像可能会出现偏移。Holograms in a stationary frame of reference might experience drift when the user is far from the hologram. 但对于动态全息影像而言,这不太可能是显而易见的:这可能是因为全息影像经常发生移动,或者它的运动不断地使其靠近用户,而偏移量会降至最低。But this is less likely to be noticeable for dynamic holograms: either the hologram is constantly moving anyway or its motion constantly keeps it close to the user where drift will be minimized.

动态全息影像的一个有趣的例子是创建从一个锚定坐标系到另一个锚定坐标系的动画的对象。One interesting case of dynamic holograms is an object that is animating from one anchored coordinate system to another. 例如,你可能有两个 castles 的10米,每个都在其自己的空间锚,其中有一个城堡触发 cannonball。For example, you might have two castles 10 meters apart, each on their own spatial anchor with one castle firing a cannonball at the other castle. 触发 cannonball 时,可以将其呈现在固定的引用框架中的适当位置,使其与第一个城堡的定位坐标系统中的 cannon 一致。When the cannonball is fired, you can render it at the appropriate location in the stationary frame of reference to coincide with the cannon in the first castle's anchored coordinate system. 然后,它可以循着它在固定参照系中的轨迹,在空中飞行 10 米。It can then follow its trajectory in the stationary frame of reference as it flies 10 meters through the air. 当 cannonball 到达其他城堡时,可以将其移动到第二个城堡的定位坐标系中,以允许与该城堡的严格主体进行物理学计算。As the cannonball reaches the other castle, you can move it into the second castle's anchored coordinate system to allow for physics calculations with that castle's rigid bodies.

如果跨设备共享高度动态的全息图,请选择某个云空间锚作为其父项,因为不能跨设备共享固定的引用框架。If you're sharing a highly dynamic hologram across devices, pick some cloud spatial anchor to act as their parent because stationary frames of reference cannot be shared across devices. 但是,你应该确保动态全息图或查看它的设备停留在锚定的3米半径内,因此,全息图在所有设备上都显示为稳定。However, you should ensure either the dynamic hologram or the devices viewing it stay within the anchor's 3-meter radius so the hologram appears stable on all devices.

避免创建空间定位点网格Avoid creating a grid of spatial anchors

您可能想让您的应用程序在用户四处浏览时删除空间锚点的常规网格,并在移动动态对象时将其转换为锚点。You may be tempted to have your application drop a regular grid of spatial anchors as the user walks around, transitioning dynamic objects from anchor to anchor as they move around. 但是,这涉及到应用程序的更多管理,而不会带来系统本身在内部维护的深层传感器数据的好处。However, this involves more management for your application, without the benefit of the deep sensor data that the system itself maintains internally. 对于这种情况,你将通过将全息影像置于固定的参考框架中来获得更好的效果,如以上部分所述。For these cases, you'll achieve better results by placing your holograms in the stationary frame of reference as described in the section above. 在将一组云空间锚点置于静态空间周围之前,请考虑将空间锚点置于用户根据上述原则传入的密钥全息图位置,而不是创建任意的定位点网格。When you're pre-positioning a set of cloud spatial anchors around a static space, consider placing the spatial anchors at the locations of the key holograms the user comes across per the principle above rather than creating an arbitrary grid of anchors. 该操作可确保获得这些关键全息影像的最大稳定性。This ensures that you'll get maximum stability for those key holograms.

释放你不再需要的局部空间定位点Release local spatial anchors you no longer need

本地空间锚点处于活动状态时,系统会将该锚点附近的传感器数据保持一致。While a local spatial anchor is active, the system prioritizes keeping the sensor data that is near that anchor. 如果不再使用空间锚,请停止访问其坐标系统。If you're no longer using a spatial anchor, stop accessing its coordinate system. 这允许根据需要删除其基础传感器数据。This allows its underlying sensor data to be removed as necessary.

这对于已保存到空间锚定存储区的本地锚格外重要。This is especially important for local anchors you've persisted to the spatial anchor store. 这些定位点后面的传感器数据将永久保留,以允许你的应用程序在将来的会话中查找该定位点,这将减少用于跟踪其他锚点的空间。The sensor data behind these anchors will be kept around permanently to allow your application to find that anchor in future sessions, which reduces the space available to track other anchors. 仅保留需要在未来的会话中再次查找的本地锚。Only persist local anchors that you need to find again in future sessions. 如果用户不再有意义,我们建议将它们从存储中删除。We recommend removing them from the store when they're no longer meaningful to the user.

对于云空间定位点,存储可以根据场景需要进行扩展。For cloud spatial anchors, your storage can scale as your scenario requires. 你可以根据需要存储任意数量的云定位点,知道用户不再需要锚点时将其释放。You can store as many cloud anchors as you need, releasing them when you know that your users won't need the anchor again.

另请参阅See also