<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ModelIO",
  "identifier" : "/documentation/ModelIO/MDLAsset/init(url:vertexDescriptor:bufferAllocator:preserveTopology:error:)-510xi",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(cs)MDLAsset(im)initWithURL:vertexDescriptor:bufferAllocator:preserveTopology:error:"
  },
  "title" : "init(url:vertexDescriptor:bufferAllocator:preserveTopology:error:)"
}
-->

# init(url:vertexDescriptor:bufferAllocator:preserveTopology:error:)

Initializes an asset from the file at the specified URL, using the specified options for allocating and transforming data during import.

```
init(url URL: URL, vertexDescriptor: MDLVertexDescriptor?, bufferAllocator: (any MDLMeshBufferAllocator)?, preserveTopology: Bool, error: NSErrorPointer)
```

## Parameters

`URL`

A URL specifying the location an asset file.

`vertexDescriptor`

An object describing the vertex data format to be loaded from the asset, or `nil` to use the asset’s vertex buffers as found in the file.

`bufferAllocator`

The allocator object to use for loading mesh data from the asset, or `nil` to use a default allocator.

`preserveTopology`

If <doc://com.apple.documentation/documentation/Swift/true>, Model I/O uses the asset’s submesh index buffers as found in the file, using the appropriate [`MDLGeometryType`](/documentation/ModelIO/MDLGeometryType) value for each submesh and generating [`MDLSubmeshTopology`](/documentation/ModelIO/MDLSubmeshTopology) buffers as needed for variable-topology submeshes. If <doc://com.apple.documentation/documentation/Swift/false>, Model I/O reformats index buffers to create triangle submeshes.

`error`

Upon return, an object describing any errors that occur while loading the asset.

## Return Value

A new asset object.

## Discussion

Use this initializer when you need to ensure that mesh data from the asset is allocated and formatted correctly for your intended use. For example, to use the MetalKit framework for loading vertex data into GPU buffers for rendering using Metal, pass a <doc://com.apple.documentation/documentation/MetalKit/MTKMeshBufferAllocator> object for the `bufferAllocator` parameter. If you specify a [`MDLVertexDescriptor`](/documentation/ModelIO/MDLVertexDescriptor) object for the `vertexDescriptor` parameter, Model I/O automatically transforms mesh data to the specified vertex format upon loading. If you specify <doc://com.apple.documentation/documentation/Swift/false> for the `preserveTopology` parameter, Model I/O automatically transforms submesh data to create triangle meshes (the optimal format for rendering on most GPUs). By using these parameters, you ensure that mesh data is copied and transformed a minimal number of times between being read from a file and being loaded into GPU memory for rendering.

Use the [`canImportFileExtension(_:)`](/documentation/ModelIO/MDLAsset/canImportFileExtension(_:)) method to determine whether Model I/O  can import an asset.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)