openusd-schemas 0.7.0

Typed Rust APIs for USD's standard schemas (UsdGeom, UsdShade, UsdSkel, UsdPhysics, and more), built on openusd
Documentation

openusd-schemas

Crates.io Version docs.rs CI

Typed Rust APIs for USD's standard schemas, built on openusd.

A USD stage is, underneath, prims carrying loosely typed attributes. This crate puts the schemas back on top of it: ask a Mesh for its points and face counts, a Camera for its focal length, a Material for the shader bound to its surface output, a Skeleton for its joints and skinning weights — as ordinary Rust types, instead of spelling out attribute names and decoding values by hand. Every view authors as well as reads.

let mesh = geom::Mesh::get(&stage, "/World/Mesh")?.unwrap();
let points = mesh.points_attr().get::<Vec<gf::Vec3f>>()?;

Ten schema families ship here, each behind its own feature flag, so a build compiles only the domains it touches:

UsdGeom · UsdLux · UsdMedia · UsdPhysics · UsdProc · UsdRender · UsdShade · UsdSkel · UsdUI · UsdVol

The two crates share a version and release together.

Usage

Add both crates — a schema view is a handle on a stage the core opens — and enable the families you need:

[dependencies]
openusd = "0.7"
openusd-schemas = { version = "0.7", features = ["geom", "lux"] }

Nothing is enabled by default.

Feature flags

Feature Enables
geom UsdGeom — Imageable, Boundable, Xformable, shapes, Camera, Mesh, Curves, PointInstancer
lux UsdLux — light prims and Light/Shaping/Shadow APIs
media UsdMedia — SpatialAudio and AssetPreviewsAPI
physics UsdPhysics — scenes, joints, collisions, limit/drive APIs
proc UsdProc — GenerativeProcedural
render UsdRender — RenderSettings, RenderProduct, RenderVar, RenderPass
shade UsdShade — materials, shader networks, bindings, UsdPreviewSurface
skel UsdSkel — skeleton reader and skinning toolkit
ui UsdUI — Backdrop, SceneGraphPrimAPI, NodeGraphNodeAPI
vol UsdVol — Volume, OpenVDBAsset, Field3DAsset

lux, media, proc, skel, and vol build on the geom trait chain and enable it transitively.

Example

Open a stage with the core crate, then read a Mesh and its point positions and normals through the geom views:

// `PointBased` is brought in so its inherited accessors resolve on the view.
use openusd_schemas::geom::{self, PointBased};
use openusd::{gf, usd};

let stage = usd::Stage::open("scene.usda")?;

if let Some(mesh) = geom::Mesh::get(&stage, "/World/Mesh")? {
    // `points_attr` / `normals_attr` are inherited from the `PointBased` trait
    // up the chain. `point3f[]` and `normal3f[]` both decode to `Vec<gf::Vec3f>`,
    // so `get` extracts them directly.
    let points = mesh.points_attr().get::<Vec<gf::Vec3f>>()?;
    let normals = mesh.normals_attr().get::<Vec<gf::Vec3f>>()?;

    if let Some(points) = points {
        println!("{} points, normals authored: {}", points.len(), normals.is_some());
    }
}

Values a prim does not author fall back to what the schema declares, resolved through the core's usd::SchemaRegistry.

License

Licensed under the MIT License.