Information about the position and orientation of a real-world flat surface detected in a world-tracking AR session.
關(guān)于在世界跟蹤AR Session中檢測到的真實世界平面的位置和方向的信息。
Overview
When you run a world-tracking AR session whose?planeDetection?option is enabled, the session automatically adds to its list of anchors an?ARPlaneAnchor?object for each flat surface ARKit detects with the back-facing camera. Each plane anchor provides information about the estimated position and shape of the surface.
概述
當您運行啟用了planeDetection選項的世界追蹤AR Session時, Session會自動向ARKit使用后置攝像頭檢測到的每個平面的錨點列表添加一個ARPlaneAnchor對象。 每個平面錨點提供關(guān)于表面的估計位置和形狀的信息。
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Determining Plane Orientation
alignment
The general orientation of the detected plane with respect to gravity.
檢測到的平面相對于重力的大致方向。
ARPlaneAnchorAlignment
Values describing possible general orientations of a detected plane with respect to gravity.
描述檢測平面相對于重力可能的總體方向的值。
Alignment Values
ARPlaneAnchorAlignmentHorizontal
The plane is perpendicular to gravity.
該平面垂直于重力。
Discussion
The?transform?property for a horizontal plane anchor includes no rotation about the x- or z-axis. Thus, using this anchor's transform to place a 3D model asset in your scene results in the model appearing "right side up".
討論
水平平面錨點的transform屬性不包含圍繞x或z軸的旋轉(zhuǎn)。 因此,使用此錨點的變換將3D模型資源放置在場景中會導致模型出現(xiàn)“右側(cè)朝上”。
ARPlaneAnchorAlignmentVertical
The plane is parallel to gravity.
飛機與重力平行。
討論
垂直平面錨點的transform屬性包含旋轉(zhuǎn)分量。 也就是說,變換矩陣表示旋轉(zhuǎn)水平面以匹配檢測到的表面的方向的結(jié)果。
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Using Detailed Plane Geometry
geometry
A coarse triangle mesh representing the general shape of the detected plane.
表示檢測到的平面的一般形狀的粗糙三角形網(wǎng)格。
討論
該網(wǎng)格提供了描述飛機的估計2D尺寸的頂點,索引和紋理坐標緩沖區(qū)。
您可以通過將這些緩沖區(qū)傳遞給您的首選渲染引擎來可視化平面幾何圖形。 要使用SceneKit可視化平面幾何,請創(chuàng)建一個ARSCNPlaneGeometry實例并使用其updateFromPlaneGeometry:方法更新它以加工平面幾何。
ARPlaneGeometry
A 3D mesh describing the shape of a detected plane in world-tracking AR sessions.
描述世界跟蹤AR會話中檢測到的平面形狀的3D網(wǎng)格。
Overview
This class provides the estimated general shape of a detected plane, in the form of a detailed 3D mesh appropriate for use with various rendering technologies or for exporting 3D assets. (For a quick way to visualize a plane geometry using SceneKit, see the?ARSCNPlaneGeometryclass.)
Unlike the?ARPlaneAnchor?center?and?extent?properties, which estimate only a rectangular area for a detected plane, a plane anchor's?geometry?property provides a more detailed estimate of the 2D area covered by that plane. For example, if ARKit detects a circular tabletop, the resulting?ARPlaneGeometry?objects roughly match the general shape of the table. As the session continues to run, ARKit provides updated plane anchors whose associated geometry refines the estimated shape of the plane.
You can use this model to more precisely place 3D content that should appear only on a detected flat surface—for example, to ensure that virtual objects don't fall off the edge of a table. You can also use this model to create occlusion geometry, which hides other virtual content behind the detected surface in the camera image.
The shape of a plane geometry is always convex. (That is, the boundary polygon for a plane geometry is a minimal convex hull enclosing all points that ARKit recognizes or estimates are part of the plane.)
概述
此類提供檢測平面的估計一般形狀,采用適用于各種渲染技術(shù)或?qū)С?D資產(chǎn)的詳細3D網(wǎng)格形式。 (有關(guān)使用SceneKit可視化平面幾何的快速方法,請參閱ARSCNPlaneGeometry類。)
與僅為被檢測平面估計矩形區(qū)域的ARPlaneAnchor中心和范圍屬性不同,平面錨點的幾何屬性提供了該平面覆蓋的二維區(qū)域的更詳細估計。例如,如果ARKit檢測到圓形桌面,則生成的ARPlaneGeometry對象大致與表的一般形狀匹配。隨著會話繼續(xù)運行,ARKit提供更新的平面錨點,其關(guān)聯(lián)的幾何圖形改進平面的估計形狀。
您可以使用此模型更精確地放置應(yīng)僅出現(xiàn)在檢測到的平面上的3D內(nèi)容 - 例如,以確保虛擬對象不會脫離桌子邊緣。您也可以使用此模型創(chuàng)建遮擋幾何圖形,該遮擋幾何圖形將相機圖像中檢測到的表面后面的其他虛擬內(nèi)容隱藏起來。
平面幾何形狀總是凸起的。 (也就是說,平面幾何的邊界多邊形是一個包含ARKit識別或估計是平面一部分的所有點的最小凸包。)
Accessing Mesh Data
vertexCount
The number of elements in the?vertices?buffer.
頂點緩沖區(qū)中元素的數(shù)量。
vertices
A buffer of vertex positions for each point in the plane mesh.
平面網(wǎng)格中每個點的頂點位置緩沖區(qū)。
Discussion
Each?float3?value in this buffer represents the position of a vertex in the mesh, in a coordinate system whose origin is defined by the owning plane anchor's?transform?matrix.
The?vertexCount?property provides the number of elements in the buffer.?
This buffer, together with the?triangleIndices?buffer, describes a mesh covering the entire surface of the plane. Use this mesh for purposes that involve the filled shape, such as rendering a solid 3D representation of the surface. If instead you only need to know the outline of the shape, see the?boundaryVertices?property.
討論
此緩沖區(qū)中的每個float3值表示網(wǎng)格中頂點的位置,該坐標系的原點由擁有平面錨點的變換矩陣定義。
vertexCount屬性提供緩沖區(qū)中元素的數(shù)量。
該緩沖區(qū)與三角形指標緩沖區(qū)一起描述覆蓋平面整個表面的網(wǎng)格。 使用此網(wǎng)格用于涉及填充形狀的目的,例如渲染表面的實體3D表示。 如果您只需要知道形狀的輪廓,請參閱boundaryVertices屬性。
textureCoordinateCount
The number of elements in the?textureCoordinates?buffer.
textureCoordinates緩沖中的元素數(shù)量。
textureCoordinates
A buffer of texture coordinate values for each point in the plane mesh.
平面網(wǎng)格中每個點的紋理坐標值的緩沖區(qū)。
Discussion
Each?float2?value in this buffer represents the UV texture coordinates for the vertex at the corresponding index in the?vertices?buffer.
討論
此緩沖區(qū)中的每個float2值表示頂點緩沖區(qū)中相應(yīng)索引處頂點的UV紋理坐標。
triangleCount
The number of triangles described by the?triangleIndices?buffer.
由triangleIndices緩沖區(qū)描述的三角形的數(shù)量。
Discussion
Each set of three indices forms a triangle, so the number of indices in the?triangleIndicesbuffer is three times the?triangleCount?value.
討論
每組三個索引形成一個三角形,因此triangleIndices緩沖區(qū)中索引的數(shù)量是triangleCount值的三倍。
triangleIndices
A buffer of indices describing the triangle mesh formed by the plane geometry's vertex data.
索引的緩沖區(qū),用于描述由平面幾何的頂點數(shù)據(jù)形成的三角形網(wǎng)格。
Discussion
Each 16-bit integer value in this buffer represents an index into the?vertices?and?textureCoordinates?buffers. Each set of three indices identifies the vertices that form a single triangle in the mesh. (That is, this buffer is appropriate for use as an index buffer for a triangle mesh in GPU-based rendering or creating 3D model asset files.)
Each set of three indices forms a triangle, so the number of indices in the?triangleIndicesbuffer is three times the?triangleCount?value.
討論
此緩沖區(qū)中的每個16位整數(shù)值都表示頂點和textureCoordinates緩沖區(qū)的索引。 每組三個索引都標識形成網(wǎng)格中單個三角形的頂點。 (也就是說,此緩沖區(qū)適合用作基于GPU渲染或創(chuàng)建3D模型asset文件的三角形網(wǎng)格的索引緩沖區(qū)。)
每組三個索引形成一個三角形,因此triangleIndices緩沖區(qū)中索引的數(shù)量是triangleCount值的三倍。
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Finding Boundary Points
boundaryVertexCount
The number of elements in the?boundaryVertices?buffer.
boundaryVertices緩沖區(qū)中元素的數(shù)量。
boundaryVertices
A buffer of vertex positions for each point along the plane's boundary.
沿著平面邊界的每個點的頂點位置的緩沖區(qū)。
Discussion
Each?float3?value in this buffer represents the position of a vertex along the boundary polygon of the estimated plane, in a coordinate system whose origin is defined by the owning plane anchor's?transform?matrix.
The?boundaryVertexCount?property provides the number of elements in the buffer.?
This buffer defines the boundary polygon of the plane. Use it for purposes that require only that polygon's definition, such as rendering an outline of the plane's estimated shape or testing whether a point is inside the bounded region. If instead you need the filled shape (for example, to render a solid 3D representation of the surface), see the?vertices?property.
討論
該緩沖區(qū)中的每個float3值表示一個坐標系中沿著所估計平面的邊界多邊形的頂點位置,該坐標系的原點由擁有平面錨的變換矩陣定義。
boundaryVertexCount屬性提供緩沖區(qū)中元素的數(shù)量。
該緩沖區(qū)定義了該平面的邊界多邊形。 將它用于僅需要多邊形定義的目的,例如渲染平面估計形狀的輪廓或測試點是否位于有界區(qū)域內(nèi)。 如果您需要填充的形狀(例如,渲染表面的實體3D表示),請參閱頂點屬性。