Class

MDLAsset

An indexed container for 3D objects and associated information, such as transform hierarchies, meshes, cameras, and lights.

Declaration

@interface MDLAsset : NSObject

Overview

You create a MDLAsset object by loading data from a URL, and you can export an asset to any of several file formats. To access the objects contained in an asset, use Fast Enumeration, the objectAtIndex: method, or subscripting. Each object in an asset can be the root of a hierarchy of objects. To traverse that hierarchy, use an object’s children property.

An asset may contain timed information, such as a series of mesh morphs. In such cases, the asset’s frameInterval property is nonzero and the startTime and endTime properties indicate the range of sample times available in the asset data. For objects contained in the asset, you can use methods such as localTransformAtTime: and boundingBoxAtTime: to access object properties at a specific time sample. Requesting a sample outside the time range clamps to the start or end sample. Some asset formats support continuous sampling with interpolation for times between the samples stored in the asset; other asset formats are discrete. For an asset with discrete time information, requesting a sample time that falls between the samples stored in the asset returns data for the immediately preceding time.

Topics

Creating an Asset

+ canImportFileExtension:

Returns a Boolean value that indicates whether the MDLAsset class can read asset data from files with the specified extension.

- initWithURL:

Initializes an asset from the file at the specified URL.

- initWithBufferAllocator:

Initializes an empty asset, using the specified buffer allocator.

- initWithURL:vertexDescriptor:bufferAllocator:

Initializes an asset from the file at the specified URL, using the specified vertex descriptor and buffer allocator.

- initWithURL: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.

Exporting an Asset

+ canExportFileExtension:

Returns a Boolean value that indicates whether the MDLAsset class can write asset data as a file with the specified format extension.

- exportAssetToURL:

Writes asset data to a file at the specified URL.

- exportAssetToURL:error:

Writes asset data to a file at the specified URL and reports errors that occur during export.

Working with Asset Content

- objectAtIndex:

Returns the top-level object at the specified index in the asset.

- objectAtIndexedSubscript:

Returns the top-level object at the specified index in the asset, using subscript syntax.

count

The number of top-level objects in the asset.

- childObjectsOfClass:

Returns all objects contained in the asset of the specified class.

- addObject:

Adds the specified object to the asset’s list of top-level objects.

- removeObject:

Removes the specified object from the asset’s list of top-level objects.

boundingBox

The minimum region entirely enclosing the asset’s contents.

- boundingBoxAtTime:

Returns the minimum region entirely enclosing the asset’s contents at the specified time sample.

URL

The URL from which the asset was loaded, if available.

bufferAllocator

An object responsible for allocating mesh vertex data loaded from the asset.

vertexDescriptor

The description of the vertex data format to be used for loading mesh data from the asset.

masters

An array of objects that can be reused in the asset's object hierarchy through instancing.

Working with Timed Information

frameInterval

The time interval between data samples in the asset.

startTime

The timestamp for the first timed data sample in the asset.

endTime

The timestamp for the last timed data sample in the asset.

Working with Lights

+ placeLightProbesWithDensity:heuristic:usingIrradianceDataSource:

Automatically creates and places light probes for use in illuminating a scene.

MDLProbePlacement

Options affecting automatic placement of light probes in a scene, used with the placeLightProbesWithDensity:heuristic:usingIrradianceDataSource: method.

Importing Assets from SceneKit

+ assetWithSCNScene:bufferAllocator:

Creates an asset from the specified SceneKit scene, using the specified allocator.

+ assetWithSCNScene:

Creates an asset from the specified SceneKit scene.

Constants

Asset File Types

Uniform Type Identifiers for file formats supported by the Model I/O framework.

Instance Properties

Relationships

Inherits From

See Also

3D Asset Basics

MDLObject

The base class for objects that are part of a 3D asset, including meshes, cameras, and lights.

MDLTransform

A description of the local coordinate space transformations for a 3D object.

MDLMesh

A container for vertex buffer data to be used in rendering a 3D object.

MDLSubmesh

A container for index buffer data and material information to be used in rendering all or part of a 3D object.

MDLSubmeshTopology

A description of how a submesh's index buffer data is arranged and how that arrangement should be used to produce the submesh's intended 3D shape.

MDLNamed

The common interface for Model I/O objects that expose a human-readable name.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software