The base class for objects that are part of a 3D asset, including meshes, cameras, and lights.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- Model I/O
When you load content from an asset file using the
MDLAsset class, Model I/O creates instances of the
MDLLight. For asset formats that describe a collection of meshes, cameras, and lights organized in a hierarchy of spatial transforms, Model I/O also creates instances of the
MDLObject class itself to describe the transform nodes that organize the asset’s visual content. Similarly, you use the
MDLObject class and its subclasses when creating an object graph to be exported as an asset file using the
Extending Model I/O with Components
Model I/O allows you to customize the content and relationships in an object graph with components. For each aspect of an object’s functionality, you use a component protocol (extending the
MDLComponent protocol) to define functionality and a class adopting that protocol to implement it. Then, you can use the
set methods to associate those objects with any instance of the
MDLObject class or of one of its subclasses. For example, you might define a protocol to add gameplay-related information such as scripting triggers to certain meshes, lights, or cameras in a scene.
Model I/O itself uses this mechanism to handle object hierarchies and spatial transforms: The methods listed in Working with Object Hierarchies use the
MDLObject protocol to model hierarchic relationships between objects in an asset, and the methods listed in Working with Objects in Space use the
MDLTransform protocol to model coordinate space relationships. To add support for an asset file format or object graph that uses other ways to store or compute these relationships, you can use your own classes that adopt these protocols.