Creates a mesh from the specified SceneKit geometry, using the specified allocator.


convenience init(scnGeometry: SCNGeometry, bufferAllocator: MDLMeshBufferAllocator?)



A SceneKit geometry object.


An object responsible for allocating mesh vertex data. If nil, Model I/O uses an internal allocator object.

Return Value

A new mesh object.


SceneKit is a high-level framework for modeling, animating, and displaying 3D scenes. (For details, see SceneKit.) The SCNGeometry class describes a source of vertex data for rendering a single 3D object, and contains both a set of geometry elements (SCNGeometryElement objects) that describe index data and a set of material assignments that describe rendering appearance information.

Importing a SceneKit geometry creates not only a MDLMesh object, but also associated MDLSubmesh and MDLMaterial objects corresponding to the geometry’s elements and materials.

In Model I/O, a MDLMesh object represents both a mesh’s geometry and (as a MDLObject subclass) its position and orientation in a scene. In SceneKit, an SCNGeometry object represents only the geometry, and the SCNNode object containing a geometry contains location and orientation information. To also import location and orientation, import the geometry’s containing node as a MDLObject or MDLAsset object.

The allocator parameter controls vertex data allocation for the mesh. For example, to use the MetalKit framework for loading vertex data into GPU buffers for rendering using Metal, pass a MTKMeshBufferAllocator object. By specifying an allocator, you can ensure that mesh data is copied a minimal number of times between being read from a file and being loaded into GPU memory for rendering.

See Also

Importing Mesh Objects from SceneKit

init(scnGeometry: SCNGeometry)

Creates a mesh from the specified SceneKit geometry.