CLASS
MeshData
public class MeshData
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 (status, meshData) = meshDownloader.downloadMesh(meshId: meshId)
if status.isOk() {
print("Mesh vertices: \(meshData.vertices.count)")
print("Mesh triangles: \(meshData.indices.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.
Properties
verticesPtr
public let verticesPtr: UnsafeBufferPointer\<Float\>
Pointer to the vertices data. Array of 3 floats per vertex.
uvsPtr
public let uvsPtr: UnsafeBufferPointer\<Float\>?
Pointer to the UVs data. Array of 2 floats per UV.
indicesPtr
public let indicesPtr: UnsafeBufferPointer\<UInt32\>
Pointer to the indices data. Array of 3 indices per triangle.
normalsPtr
public let normalsPtr: UnsafeBufferPointer\<Float\>?
Pointer to the normals data. Array of 3 floats per normal. Only available for live meshing.
Methods
init(fromC:owner:)
public init(fromC cMeshData: ARDK_MeshData, owner: ResourceOwner? = nil)
toSCNGeometry(material:)
public func toSCNGeometry(material: SCNMaterial? = nil) -> SCNGeometry?
Creates a SceneKit geometry from this mesh chunk's vertex positions, normals and triangle indices.
- Parameter material: Optional material to apply to the resulting geometry.
- Returns:
SCNGeometryrepresenting the mesh.
Parameters
| Name | Description |
|---|---|
| material | Optional material to apply to the resulting geometry. |