AR 內容的放置方式和大小必須正確,才能融入場景。虛擬物體就像真實世界中的物品一樣,遠一點的虛擬物件應較小。您可以執行命中測試 (或針對 Unity 的 AR Foundation 執行光柵),確定 3D 物件的正確位置。正確放置方式可確保 AR 內容能以適當的大小 (透明) 顯示。
命中測試能夠找到現實世界 3D 幾何圖形與由起點和方向組成的虛擬光柵之間的交集。最常使用裝置相機做為來源的 Ray 應用程式,不過 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"]],["上次更新時間: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."]]],[]]