Expand description
§modelio-rs
Safe Rust bindings for Apple’s ModelIO framework on macOS. The published Cargo package is modelio-rs; the Rust library target is modelio.
Status: v0.3.0 keeps the SDK audit at 117/117 top-level ModelIO symbols (100%) and adds callback-backed protocol wrappers for asset resolvers, mesh-buffer allocators, transform components/ops, plus first-class scattering-function wrappers.
§Highlights
Assetfor loading, exporting, and walking ModelIO assetsMeshfor procedural primitives, vertex buffer reads, submesh inspection, and vertex descriptor accessMaterial,ScatteringFunction,PhysicallyPlausibleScatteringFunction,MaterialProperty,TextureFilter,TextureSampler, and material-graph wrappers for physically plausible materials, scattering models, standalone properties, and sampler/graph authoringLight,AreaLight,PhotometricLight,PhysicallyPlausibleLight,Camera, andStereoscopicCamerafor scene-lighting and camera control surfacesObjectandObjectContainerfor hierarchy creation, child traversal, path lookup, and transform-component attachmentTransform, callback-backedTransformComponent/TransformOp,TransformStack, and typed transform ops for explicit transform authoringMeshBufferData, callback-backedMeshBufferAllocator,MeshBufferDataAllocator, and related wrappers for buffer-authoring workflowsAssetResolverplus path, bundle, relative, and callback-backed custom resolvers for asset lookup controlVoxelArrayfor sparse voxel grids, asset/mesh voxelization, boolean ops, and coarse/smooth mesh generationTexturefor URL-backed textures, checkerboards, procedural gradients/noise/sky cubes, metadata, writes, and texel extractionLightProbeandLightProbeIrradianceDataSourcefor probe generation and placement helpersSkeleton,Matrix4x4Array,PackedJointAnimation,AnimationBindComponent, and animated value wrappers for rigging and animation workflowsVertexDescriptor,VertexAttribute,VertexBufferLayout, runtime SDK constant accessors, andUtilityfor vertex layout inspection and auxiliary SDK helpers
§Quick start
use modelio::prelude::*;
fn main() -> modelio::Result<()> {
let mesh = Mesh::new_box([1.0, 1.0, 1.0], [1, 1, 1], false, GeometryType::Triangles)?;
let bbox = mesh.bounding_box();
println!("vertices={}", mesh.vertex_count());
println!("submeshes={}", mesh.submesh_count());
println!("bounds min={:?} max={:?}", bbox.min, bbox.max);
Ok(())
}§Surface overview
§Assets + objects
Asset::new,from_url,export_to_url,place_light_probesAsset::count,object_at,object_at_path,mesh_at,meshesAsset::frame_interval,start_time,end_time,up_axisObject::new,name,path,hidden,add_child,child_at,at_path,transform_component,children_containerObjectContainer::new,count,object_at,add_objectPathAssetResolver,BundleAssetResolver,RelativeAssetResolver, andAssetResolver::resolve_asset_named
§Meshes + submeshes + vertex data
Mesh::new_box,new_plane,new_ellipsoid,new_sphere,new_cylinder,new_icosahedronMesh::vertex_count,vertex_buffers,submeshes,bounding_box,vertex_descriptorMeshBuffer::map,fill_data,allocator,zone,as_data_bufferMeshBufferData,MeshBufferDataAllocator,MeshBufferZoneDefault, andMeshBufferMapVertexAttributeData::info,bytesSubmesh::index_count,index_type,geometry_type,index_buffer,material,set_material,topologySubmeshTopology::new, crease/index buffer accessors, and face-count mutationVertexDescriptor::info,attributes,attribute_named,copy,layoutsVertexAttribute::new,info,set_initialization_valueVertexBufferLayout::new,stride,set_stride
§Materials + textures
Material::new,info,material_face,property_with_semantic,property_named,load_textures_using_resolverMaterialProperty::new,info,set_float,set_color,set_string,set_url,texture,texture_samplerTextureFilter::new, wrap/filter setters, andinfoTextureSampler::new, texture/filter/transform setters, andinfoMaterialPropertyConnection,MaterialPropertyNode, andMaterialPropertyGraphfor graph construction/evaluationTexture::from_url,new_checkerboard,new_color_temperature_gradient,new_color_gradient,new_vector_noise,new_scalar_noise,new_cellular_noise,new_normal_map,new_sky_cubeTexture::info,write_to_url,update_sky_cube,texel_data_top_left,texel_data_bottom_left
§Lights + cameras
Light::new,info,set_light_type,set_color_space,irradiance_at_pointAreaLight::newandPhotometricLight::new/new_with_ies_profileplus info accessorsLightProbe::new,reflective_texture,irradiance_texture,generate_spherical_harmonics_from_irradianceLightProbeIrradianceDataSource::new,bounding_box,spherical_harmonics_levelPhysicallyPlausibleLight::new,info,set_color_temperature,set_lumens, cone-angle and attenuation settersCamera::new,info,set_projection,set_field_of_view,look_at,look_at_from,ray_to,frame_bounding_boxStereoscopicCamera::new,info, and optical separation accessors
§Transforms + animation
Transform::new,from_component,from_matrix,translation,rotation,scale, and timed settersTransformComponent::matrix,key_times,local_transform_at_time,global_transform_with_objectTransformStack::add_translate_op,add_rotate_*_op,add_scale_op,add_matrix_op,add_orient_op,transform_opsTransformOpplus typed op wrappers with animated-value accessors
§Voxels + animation
VoxelArray::new,from_asset,info,set_voxel,voxel_exists,voxel_indices,voxels_within_extentVoxelArray::set_voxels_for_mesh,union_with,intersect_with,difference_with,coarse_mesh,mesh, allocator-aware mesh extractionSkeleton::new,info,joint_bind_transforms,joint_rest_transforms,joint_*_transform_arrayMatrix4x4Array::new,info,set_float_matrices,float_matrices,clearPackedJointAnimation::new,info,translations,rotations,scalesAnimationBindComponent::new,info,set_skeleton,set_packed_joint_animation,set_joint_pathsAnimatedScalar,AnimatedVector2/3/4,AnimatedQuaternion,AnimatedMatrix4x4AnimatedScalarArray,AnimatedVector3Array,AnimatedQuaternionArray
§SDK helpers
ut_type::*andvertex_attribute_name::*expose ModelIO SDK NSString constants at runtimeUtility::convert_to_usdzwrapsMDLUtility’s USDZ conversion helper
§Examples
The crate ships numbered examples covering every logical area:
01_primitive_smoke02_asset_basics03_material_properties04_light_defaults05_physically_plausible_light06_camera_controls07_object_hierarchy08_voxel_array_boolean09_texture_checkerboard10_animation_bind_component11_animated_value_types12_submesh_material13_vertex_attribute_descriptor14_skeleton_basics15_transform_stack_basics16_mesh_buffer_allocator17_asset_resolver_light_probe
Run one with:
cargo run --example 09_texture_checkerboardRun them all with:
for ex in examples/*.rs; do cargo run --example "$(basename "$ex" .rs)"; done§Tests
Integration smoke tests live under tests/ with one file per logical area plus tests/api_coverage.rs, which validates the Swift bridge against the active macOS SDK headers.
§License
Licensed under either of Apache-2.0 or MIT at your option.
Modules§
- prelude
- Re-exports the primary Model I/O wrappers for convenient imports.
- ut_type
- Groups helper APIs for the corresponding Model I/O ut type symbols.
- vertex_
attribute_ name - Groups helper APIs for the corresponding Model I/O vertex attribute name symbols.
- vertex_
format - Groups helper APIs for the corresponding Model I/O vertex format symbols.
Structs§
- Animated
Matrix4x4 - Wraps the corresponding Model I/O animated matrix4x4 counterpart.
- Animated
Quaternion - Wraps the corresponding Model I/O animated quaternion counterpart.
- Animated
Quaternion Array - Wraps the corresponding Model I/O animated quaternion array counterpart.
- Animated
Scalar - Wraps the corresponding Model I/O animated scalar counterpart.
- Animated
Scalar Array - Wraps the corresponding Model I/O animated scalar array counterpart.
- Animated
Value - Wraps the corresponding Model I/O animated value counterpart.
- Animated
Value Info - Wraps the corresponding Model I/O animated value info counterpart.
- Animated
Vector2 - Wraps the corresponding Model I/O animated vector2 counterpart.
- Animated
Vector3 - Wraps the corresponding Model I/O animated vector3 counterpart.
- Animated
Vector4 - Wraps the corresponding Model I/O animated vector4 counterpart.
- Animated
Vector3 Array - Wraps the corresponding Model I/O animated vector3array counterpart.
- Animation
Bind Component - Wraps the corresponding Model I/O animation bind component counterpart.
- Area
Light - Wraps the corresponding Model I/O area light counterpart.
- Area
Light Info - Wraps the corresponding Model I/O area light info counterpart.
- Asset
- Wraps the corresponding Model I/O asset counterpart.
- Asset
Info - Wraps the corresponding Model I/O asset info counterpart.
- Asset
Resolver - Wraps the corresponding Model I/O asset resolver counterpart.
- Bounding
Box - Wraps the corresponding Model I/O bounding box counterpart.
- Bundle
Asset Resolver - Wraps the corresponding Model I/O bundle asset resolver counterpart.
- Camera
- Wraps the corresponding Model I/O camera counterpart.
- Camera
Info - Wraps the corresponding Model I/O camera info counterpart.
- Light
- Wraps the corresponding Model I/O light counterpart.
- Light
Info - Wraps the corresponding Model I/O light info counterpart.
- Light
Probe - Wraps the corresponding Model I/O light probe counterpart.
- Light
Probe Irradiance Data Source - Wraps the corresponding Model I/O light probe irradiance data source counterpart.
- Material
- Wraps the corresponding Model I/O material counterpart.
- Material
Info - Wraps the corresponding Model I/O material info counterpart.
- Material
Property - Wraps the corresponding Model I/O material property counterpart.
- Material
Property Connection - Wraps the corresponding Model I/O material property connection counterpart.
- Material
Property Graph - Wraps the corresponding Model I/O material property graph counterpart.
- Material
Property Info - Wraps the corresponding Model I/O material property info counterpart.
- Material
Property Node - Wraps the corresponding Model I/O material property node counterpart.
- Matrix4x4
Array - Wraps the corresponding Model I/O matrix4x4array counterpart.
- Matrix4x4
Array Info - Wraps the corresponding Model I/O matrix4x4array info counterpart.
- Mesh
- Wraps the corresponding Model I/O mesh counterpart.
- Mesh
Buffer - Wraps the corresponding Model I/O mesh buffer counterpart.
- Mesh
Buffer Allocator - Wraps the corresponding Model I/O mesh buffer allocator counterpart.
- Mesh
Buffer Data - Wraps the corresponding Model I/O mesh buffer data counterpart.
- Mesh
Buffer Data Allocator - Wraps the corresponding Model I/O mesh buffer data allocator counterpart.
- Mesh
Buffer Info - Wraps the corresponding Model I/O mesh buffer info counterpart.
- Mesh
Buffer Map - Wraps the corresponding Model I/O mesh buffer map counterpart.
- Mesh
Buffer Zone - Wraps the corresponding Model I/O mesh buffer zone counterpart.
- Mesh
Buffer Zone Default - Wraps the corresponding Model I/O mesh buffer zone default counterpart.
- Model
IoError - Wraps the corresponding Model I/O model io error counterpart.
- Object
- Wraps the corresponding Model I/O object counterpart.
- Object
Container - Wraps the corresponding Model I/O object container counterpart.
- Object
Info - Wraps the corresponding Model I/O object info counterpart.
- Packed
Joint Animation - Wraps the corresponding Model I/O packed joint animation counterpart.
- Packed
Joint Animation Info - Wraps the corresponding Model I/O packed joint animation info counterpart.
- Path
Asset Resolver - Wraps the corresponding Model I/O path asset resolver counterpart.
- Photometric
Light - Wraps the corresponding Model I/O photometric light counterpart.
- Photometric
Light Info - Wraps the corresponding Model I/O photometric light info counterpart.
- Physically
Plausible Light - Wraps the corresponding Model I/O physically plausible light counterpart.
- Physically
Plausible Light Info - Wraps the corresponding Model I/O physically plausible light info counterpart.
- Physically
Plausible Scattering Function - Wraps the corresponding Model I/O physically plausible scattering function counterpart.
- Relative
Asset Resolver - Wraps the corresponding Model I/O relative asset resolver counterpart.
- Scattering
Function - Wraps the corresponding Model I/O scattering function counterpart.
- Skeleton
- Wraps the corresponding Model I/O skeleton counterpart.
- Skeleton
Info - Wraps the corresponding Model I/O skeleton info counterpart.
- Stereoscopic
Camera - Wraps the corresponding Model I/O stereoscopic camera counterpart.
- Stereoscopic
Camera Info - Wraps the corresponding Model I/O stereoscopic camera info counterpart.
- Submesh
- Wraps the corresponding Model I/O submesh counterpart.
- Submesh
Topology - Wraps the corresponding Model I/O submesh topology counterpart.
- Texture
- Wraps the corresponding Model I/O texture counterpart.
- Texture
Filter - Wraps the corresponding Model I/O texture filter counterpart.
- Texture
Filter Info - Wraps the corresponding Model I/O texture filter info counterpart.
- Texture
Info - Wraps the corresponding Model I/O texture info counterpart.
- Texture
Sampler - Wraps the corresponding Model I/O texture sampler counterpart.
- Texture
Sampler Info - Wraps the corresponding Model I/O texture sampler info counterpart.
- Transform
- Wraps the corresponding Model I/O transform counterpart.
- Transform
Component - Wraps the corresponding Model I/O transform component counterpart.
- Transform
Matrix Op - Wraps the corresponding Model I/O counterpart.
- Transform
Op - Wraps the corresponding Model I/O transform op counterpart.
- Transform
Orient Op - Wraps the corresponding Model I/O counterpart.
- Transform
Rotate Op - Wraps the corresponding Model I/O counterpart.
- Transform
RotateX Op - Wraps the corresponding Model I/O counterpart.
- Transform
RotateY Op - Wraps the corresponding Model I/O counterpart.
- Transform
RotateZ Op - Wraps the corresponding Model I/O counterpart.
- Transform
Scale Op - Wraps the corresponding Model I/O counterpart.
- Transform
Stack - Wraps the corresponding Model I/O transform stack counterpart.
- Transform
Translate Op - Wraps the corresponding Model I/O counterpart.
- Utility
- Wraps the corresponding Model I/O utility counterpart.
- Vertex
Attribute - Wraps the corresponding Model I/O vertex attribute counterpart.
- Vertex
Attribute Data - Wraps the corresponding Model I/O vertex attribute data counterpart.
- Vertex
Attribute Descriptor Info - Wraps the corresponding Model I/O vertex attribute descriptor info counterpart.
- Vertex
Attribute Info - Wraps the corresponding Model I/O vertex attribute info counterpart.
- Vertex
Buffer Layout - Wraps the corresponding Model I/O vertex buffer layout counterpart.
- Vertex
Descriptor - Wraps the corresponding Model I/O vertex descriptor counterpart.
- Vertex
Descriptor Info - Wraps the corresponding Model I/O vertex descriptor info counterpart.
- Voxel
Array - Wraps the corresponding Model I/O voxel array counterpart.
- Voxel
Array Info - Wraps the corresponding Model I/O voxel array info counterpart.
- Voxel
Index Extent - Wraps the corresponding Model I/O voxel index extent counterpart.
Enums§
- Animated
Value Interpolation - Mirrors the corresponding Model I/O animated value interpolation enumeration.
- Asset
Resolver Event - Describes one
MDLAssetResolverprotocol request routed into Rust. - Asset
Resolver Response - Returns the result of one
MDLAssetResolverprotocol request. - Camera
Projection - Mirrors the corresponding Model I/O camera projection enumeration.
- Data
Precision - Mirrors the corresponding Model I/O data precision enumeration.
- Geometry
Type - Mirrors the corresponding Model I/O geometry type enumeration.
- Index
BitDepth - Mirrors the corresponding Model I/O index bit depth enumeration.
- Light
Type - Mirrors the corresponding Model I/O light type enumeration.
- Material
Face - Mirrors the corresponding Model I/O material face enumeration.
- Material
MipMap Filter Mode - Mirrors the corresponding Model I/O material mip map filter mode enumeration.
- Material
Property Type - Mirrors the corresponding Model I/O material property type enumeration.
- Material
Semantic - Mirrors the corresponding Model I/O material semantic enumeration.
- Material
Texture Filter Mode - Mirrors the corresponding Model I/O material texture filter mode enumeration.
- Material
Texture Wrap Mode - Mirrors the corresponding Model I/O material texture wrap mode enumeration.
- Mesh
Buffer Allocator Event - Describes one
MDLMeshBufferAllocatorprotocol request routed into Rust. - Mesh
Buffer Allocator Response - Returns the result of one
MDLMeshBufferAllocatorprotocol request. - Mesh
Buffer Type - Mirrors the corresponding Model I/O mesh buffer type enumeration.
- Object
Kind - Mirrors the corresponding Model I/O object kind enumeration.
- Probe
Placement - Mirrors the corresponding Model I/O probe placement enumeration.
- Texture
Channel Encoding - Mirrors the corresponding Model I/O texture channel encoding enumeration.
- Transform
Component Event - Describes one
MDLTransformComponentprotocol request routed into Rust. - Transform
Component Response - Returns the result of one
MDLTransformComponentprotocol request. - Transform
OpEvent - Describes one
MDLTransformOpprotocol request routed into Rust. - Transform
OpResponse - Returns the result of one
MDLTransformOpprotocol request. - Transform
OpRotation Order - Mirrors the corresponding Model I/O transform op rotation order enumeration.
Traits§
- Component
- Mirrors the corresponding Model I/O component protocol counterpart.
- Joint
Animation - Mirrors the corresponding Model I/O joint animation protocol counterpart.
- Named
- Mirrors the corresponding Model I/O named protocol counterpart.
- Object
Container Component - Mirrors the corresponding Model I/O object container component: component protocol counterpart.
Type Aliases§
- Result
- Aliases the result shape used by the corresponding Model I/O wrappers.