MeshData
Declaration
class MeshDataSummary
Contains 3D mesh data for rendering and visualization.
MeshData provides access to 3D mesh geometry including vertices, indices,
normals, and texture coordinates.
Overview
MeshData includes:
- Vertices: 3D position data for mesh geometry
- Indices: The triangles that make up the mesh
- Normals: Surface normal vectors for the vertices, commonly used for lighting calculations (only available for live meshing)
- UVs: Texture coordinates for the vertices, used for mapping textures to the mesh (only available for mesh downloader)
Example Usage
let meshDownloader = nsdkSession.acquireMeshDownloader()
let chunks = meshDownloader.requestLocationMeshByAsset(
vpsMapAssetId: assetId, latitude: latitude, longitude: longitude, getTexture: true)
for try await chunk in chunks {
let meshData = chunk.meshData
print("Mesh vertices: \(meshData.verticesPtr.count / 3)")
print("Mesh triangles: \(meshData.indicesPtr.count / 3)")
// Convert to SceneKit geometry for rendering
if let geometry = meshData.toSCNGeometry() {
let node = SCNNode(geometry: geometry)
sceneView.scene.rootNode.addChildNode(node)
}
}
Memory Management
Mesh data is backed by native memory that is automatically managed.
The data remains valid as long as the MeshData instance exists.
Constructors
init(fromC cMeshData: ARDK_MeshData, owner: ResourceOwner? = nil)
Summary
Parameters
| Name | Type | Summary |
|---|---|---|
| cMeshData | ARDK_MeshData | - |
| owner | ResourceOwner? | - |
Properties
| Name | Type | Summary |
|---|---|---|
| let indicesPtr | UnsafeBufferPointer<UInt32> | Pointer to the indices data. Array of 3 indices per triangle. |
| let normalsPtr | UnsafeBufferPointer<Float>? | Pointer to the normals data. Array of 3 floats per normal. Only available for live meshing. |
| let uvsPtr | UnsafeBufferPointer<Float>? | Pointer to the UVs data. Array of 2 floats per UV. |
| let verticesPtr | UnsafeBufferPointer<Float> | Pointer to the vertices data. Array of 3 floats per vertex, in meters. For downloaded meshes, positions are in the chunk's local space (see MeshDownloaderChunk/transform)and carry no geographic data. Not converted to ARKit axes: positions use the NSDK convention (x right, y down, z forward), so negate y and z before applying ARKit-space transforms, as toSCNGeometry(material:) does. |
Methods
| Name | Type | Summary |
|---|---|---|
| toSCNGeometry | SCNGeometry? | Creates a SceneKit geometry from this mesh chunk's vertex positions, normals and triangle indices. |
Creates mesh data from a mesh-downloader result.