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.2.0 extends the crate from mesh-centric loading and inspection to assets, objects, materials, lights, cameras, voxel grids, textures, skeletal animation, animated value types, submeshes, and vertex descriptors.
§Highlights
Assetfor loading, exporting, and walking ModelIO assetsMeshfor procedural primitives, vertex buffer reads, submesh inspection, and vertex descriptor accessMaterialandMaterialPropertyfor physically plausible materials and property mutationLight,PhysicallyPlausibleLight, andCamerafor scene-lighting and camera control surfacesObjectfor hierarchy creation, child traversal, and path lookupVoxelArrayfor sparse voxel grids, boolean ops, and coarse mesh generationTexturefor URL-backed textures, checkerboards, metadata, writes, and texel extractionSkeleton,PackedJointAnimation,AnimationBindComponent, and animated value wrappers for basic rigging and animation workflowsVertexDescriptorandVertexAttributewrappers for vertex layout inspection and authoring
§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_urlAsset::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
§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_descriptorVertexAttributeData::info,bytesSubmesh::index_count,index_type,geometry_type,index_buffer,material,set_materialVertexDescriptor::info,attributes,attribute_named,copyVertexAttribute::new,info,set_initialization_value
§Materials + textures
Material::new,info,material_face,property_with_semanticMaterialProperty::info,set_float,set_color,set_string,set_url,textureTexture::from_url,new_checkerboard,info,write_to_urlTexture::texel_data_top_left,texel_data_bottom_left
§Lights + cameras
Light::new,info,set_light_type,set_color_space,irradiance_at_pointPhysicallyPlausibleLight::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_box
§Voxels + animation
VoxelArray::new,info,set_voxel,voxel_exists,voxel_indices,voxels_within_extentVoxelArray::union_with,intersect_with,difference_with,coarse_mesh,meshSkeleton::new,info,joint_bind_transforms,joint_rest_transformsPackedJointAnimation::new,info,translations,rotations,scalesAnimationBindComponent::new,info,set_skeleton,set_packed_joint_animation,set_joint_pathsAnimatedScalar,AnimatedVector2/3/4,AnimatedQuaternion,AnimatedMatrix4x4AnimatedScalarArray,AnimatedVector3Array,AnimatedQuaternionArray
§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_basics
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§
Structs§
- Animated
Matrix4x4 - Animated
Quaternion - Animated
Quaternion Array - Animated
Scalar - Animated
Scalar Array - Animated
Value Info - Animated
Vector2 - Animated
Vector3 - Animated
Vector4 - Animated
Vector3 Array - Animation
Bind Component - Asset
- Asset
Info - Bounding
Box - Camera
- Camera
Info - Light
- Light
Info - Material
- Material
Info - Material
Property - Material
Property Info - Mesh
- Mesh
Buffer - Mesh
Buffer Info - Model
IoError - Object
- Object
Info - Packed
Joint Animation - Packed
Joint Animation Info - Physically
Plausible Light - Physically
Plausible Light Info - Skeleton
- Skeleton
Info - Submesh
- Texture
- Texture
Info - Vertex
Attribute - Vertex
Attribute Data - Vertex
Attribute Descriptor Info - Vertex
Attribute Info - Vertex
Descriptor - Vertex
Descriptor Info - Voxel
Array - Voxel
Array Info - Voxel
Index Extent
Enums§
- Animated
Value Interpolation - Camera
Projection - Data
Precision - Geometry
Type - Index
BitDepth - Light
Type - Material
Face - Material
Property Type - Material
Semantic - Mesh
Buffer Type - Object
Kind - Texture
Channel Encoding