Expand description
A pure Rust runtime for reading and driving Live2D/Cubism-compatible model data.
Mocari is split into a small set of layers so applications can choose how much control they need:
assetsloads a.model3.jsonfile, its referenced.moc3data, pose file, and PNG textures from disk.ModelRuntimeowns the mutable model state used by motions, expressions, pose fading, and drawable mesh generation.motionandexpressionprovide lightweight players for Cubism motion and expression JSON files.render::commoncontains backend-neutral draw ordering, clipping, and vertex helpers for custom renderers.render::wgpuprovides a ready-to-use renderer when thewgpufeature is enabled.
The usual flow is to load a runtime model, update its parameters each frame, apply motions or expressions, rebuild meshes, then pass those meshes to a renderer.
use mocari::{assets::load_model_runtime, MotionPlayer};
let mut model = load_model_runtime("assets/models/Hiyori/Hiyori.model3.json")?;
let runtime = model.runtime_mut();
runtime.set_parameter_normalized("ParamAngleX", 0.75);
runtime.update_meshes();
for mesh in runtime.meshes() {
// Upload mesh.vertices() and mesh.indices() to your renderer.
}Re-exports§
pub use crate::core::DrawableId;pub use crate::core::Id;pub use crate::core::ParameterId;pub use crate::core::PartId;pub use crate::error::Error;pub use crate::error::Result;pub use crate::expression::ExpressionManager;pub use crate::expression::ExpressionPlayer;pub use crate::motion::MotionPlayer;pub use crate::runtime::HitAreaInfo;pub use crate::runtime::ModelRuntime;pub use crate::runtime::ParameterInfo;
Modules§
- assets
- Filesystem helpers for loading model assets and decoded textures. Convenience loaders for complete Cubism model folders.
- core
- Math, interpolation, parameter, and physics primitives used by the runtime. Low-level math and runtime primitives.
- error
- Shared error types returned by parsers and lower-level runtime code. Shared parser and runtime error types.
- expression
- Expression playback and blending against a
ModelRuntime. Cubism expression playback and blending. - json
- Parsers and data models for Cubism JSON sidecar files. Parsers and typed representations for Cubism JSON files.
- moc3
- Parsers and mesh builders for
.moc3model data. Parsers and mesh builders for.moc3binary model data. - motion
- Motion playback against a
ModelRuntime. Cubism motion playback. - render
- Renderer-facing helpers and optional backend implementations. Renderer-facing helpers.
- runtime
- Mutable model state used for parameter edits, pose updates, and mesh output. Mutable state for driving a loaded model.