AR 内容必须正确放置和大小,才能融入场景。与现实世界中的物体一样,距离较远的虚拟物体应看起来更小。您可以执行命中测试(或在 AR Foundation for Unity 中执行光线投射),确定 3D 对象在场景中的正确位置。正确的放置可确保 AR 内容以适当的(表观)尺寸呈现。
点击测试可以找到真实的 3D 几何图形与由原点和方向组成的虚拟光线之间的交集。使用设备摄像头作为原点的射线最常用的方法是,不过 ARCore 包含一个 API,用于执行在世界空间坐标中使用任意射线的命中测试。
假设有一条光线,来源于用户设备相机,它向前延伸,直至射中场景的 3D 几何图形(例如地面、墙壁或物体)。一旦发生这种情况,您会收到命中结果列表,或与检测到的场景几何图形的交集。该列表会按设备与设备的距离进行排序,最近的交叉路口排在最前面。这一点很重要,因为通常情况下,您看不到被其他对象遮挡的对象,因此在大多数情况下,第一个结果最为重要。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2023-12-02。"],[[["ARCore hit-tests, or raycasts, help you determine the correct placement and scale of virtual objects in the real world by finding intersections between a ray and the scene's geometry."],["Hit results provide distance, pose, and trackable information, allowing you to realistically anchor 3D content."],["There are four hit result types: Depth, Plane, Feature Point, and Instant Placement, each with different use cases and tradeoffs depending on the desired outcome and device capabilities."],["Depth hit results, available on Depth supported devices, utilize depth information for precise object placement on any surface, while Plane hit results are suitable for floors and walls."],["Feature Point hit results rely on visual features, and Instant Placement allows for fast content placement even with initially unknown depth and scale."]]],[]]