Information about the position and orientation of a real-world flat surface detected in a world-tracking AR session.
关于在世界跟踪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对象。 每个平面锚点提供关于表面的估计位置和形状的信息。
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轴的旋转。 因此,使用此锚点的变换将3D模型资源放置在场景中会导致模型出现“右侧朝上”。
ARPlaneAnchorAlignmentVertical
The plane is parallel to gravity.
飞机与重力平行。
讨论
垂直平面锚点的transform属性包含旋转分量。 也就是说,变换矩阵表示旋转水平面以匹配检测到的表面的方向的结果。
Using Detailed Plane Geometry
geometry
A coarse triangle mesh representing the general shape of the detected plane.
表示检测到的平面的一般形状的粗糙三角形网格。
讨论
该网格提供了描述飞机的估计2D尺寸的顶点,索引和纹理坐标缓冲区。
您可以通过将这些缓冲区传递给您的首选渲染引擎来可视化平面几何图形。 要使用SceneKit可视化平面几何,请创建一个ARSCNPlaneGeometry实例并使用其updateFromPlaneGeometry:方法更新它以加工平面几何。
ARPlaneGeometry
A 3D mesh describing the shape of a detected plane in world-tracking AR sessions.
描述世界跟踪AR会话中检测到的平面形状的3D网格。
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.)
概述
此类提供检测平面的估计一般形状,采用适用于各种渲染技术或导出3D资产的详细3D网格形式。 (有关使用SceneKit可视化平面几何的快速方法,请参阅ARSCNPlaneGeometry类。)
与仅为被检测平面估计矩形区域的ARPlaneAnchor中心和范围属性不同,平面锚点的几何属性提供了该平面覆盖的二维区域的更详细估计。例如,如果ARKit检测到圆形桌面,则生成的ARPlaneGeometry对象大致与表的一般形状匹配。随着会话继续运行,ARKit提供更新的平面锚点,其关联的几何图形改进平面的估计形状。
您可以使用此模型更精确地放置应仅出现在检测到的平面上的3D内容 - 例如,以确保虚拟对象不会脱离桌子边缘。您也可以使用此模型创建遮挡几何图形,该遮挡几何图形将相机图像中检测到的表面后面的其他虚拟内容隐藏起来。
平面几何形状总是凸起的。 (也就是说,平面几何的边界多边形是一个包含ARKit识别或估计是平面一部分的所有点的最小凸包。)
Accessing Mesh Data
vertexCount
The number of elements in the vertices buffer.
顶点缓冲区中元素的数量。
vertices
A buffer of vertex positions for each point in the plane mesh.
平面网格中每个点的顶点位置缓冲区。
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.
讨论
此缓冲区中的每个float3值表示网格中顶点的位置,该坐标系的原点由拥有平面锚点的变换矩阵定义。
vertexCount属性提供缓冲区中元素的数量。
该缓冲区与三角形指标缓冲区一起描述覆盖平面整个表面的网格。 使用此网格用于涉及填充形状的目的,例如渲染表面的实体3D表示。 如果您只需要知道形状的轮廓,请参阅boundaryVertices属性。
textureCoordinateCount
The number of elements in the textureCoordinates buffer.
textureCoordinates缓冲中的元素数量。
textureCoordinates
A buffer of texture coordinate values for each point in the plane mesh.
平面网格中每个点的纹理坐标值的缓冲区。
Discussion
Each float2 value in this buffer represents the UV texture coordinates for the vertex at the corresponding index in the vertices buffer.
讨论
此缓冲区中的每个float2值表示顶点缓冲区中相应索引处顶点的UV纹理坐标。
triangleCount
The number of triangles described by the triangleIndices buffer.
由triangleIndices缓冲区描述的三角形的数量。
Discussion
Each set of three indices forms a triangle, so the number of indices in the triangleIndicesbuffer is three times the triangleCount value.
讨论
每组三个索引形成一个三角形,因此triangleIndices缓冲区中索引的数量是triangleCount值的三倍。
triangleIndices
A buffer of indices describing the triangle mesh formed by the plane geometry's vertex data.
索引的缓冲区,用于描述由平面几何的顶点数据形成的三角形网格。
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.
讨论
此缓冲区中的每个16位整数值都表示顶点和textureCoordinates缓冲区的索引。 每组三个索引都标识形成网格中单个三角形的顶点。 (也就是说,此缓冲区适合用作基于GPU渲染或创建3D模型asset文件的三角形网格的索引缓冲区。)
每组三个索引形成一个三角形,因此triangleIndices缓冲区中索引的数量是triangleCount值的三倍。
Finding Boundary Points
boundaryVertexCount
The number of elements in the boundaryVertices buffer.
boundaryVertices缓冲区中元素的数量。
boundaryVertices
A buffer of vertex positions for each point along the plane's boundary.
沿着平面边界的每个点的顶点位置的缓冲区。
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.
讨论
该缓冲区中的每个float3值表示一个坐标系中沿着所估计平面的边界多边形的顶点位置,该坐标系的原点由拥有平面锚的变换矩阵定义。
boundaryVertexCount属性提供缓冲区中元素的数量。
该缓冲区定义了该平面的边界多边形。 将它用于仅需要多边形定义的目的,例如渲染平面估计形状的轮廓或测试点是否位于有界区域内。 如果您需要填充的形状(例如,渲染表面的实体3D表示),请参阅顶点属性。