5个不稳定版本
0.3.0 | 2021年7月3日 |
---|---|
0.2.1 | 2021年6月6日 |
0.2.0 | 2021年6月6日 |
0.1.1 | 2020年12月28日 |
0.1.0 | 2020年12月8日 |
#74 in 数据格式
1MB
3K SLoC
Loader-3d
一个用Rust编写的简单3D加载器。此项目不试图成为最快的3D库,它作为快速开始有趣(有趣)东西的简单库。目前,该项目支持Obj和glTF文件,但添加更多格式应该很简单。
用法
use l3d::prelude::*;
// Create an instance
let instance = LoadInstance::new()
// Adds default loaders (gLTF and obj files)
.with_default();
// Load file
match instance.load(LoadOptions {
path: PathBuf::from("path/to/my/file.gltf.obj"),
..Default::default()
}) {
// Single mesh
Mesh(descriptor) => {
// descriptor.vertices: Vec<[f32; 4]>,
// descriptor.normals: Vec<[f32; 3]>,
// descriptor.uvs: Vec<[f32; 2]>,
// descriptor.tangents: Vec<[f32; 4]>,
// descriptor.material_ids: Vec<i32>,
// --- Mesh descriptors do not have a material list when they are part of a scene ---
// descriptor.materials: Option<MaterialList>,
// descriptor.meshes: Vec<VertexMesh>,
// descriptor.skeleton: Option<SkeletonDescriptor>,
// descriptor.bounds: AABB,
// descriptor.name: String,
}
// A scene with meshes and a scene graph
Scene(descriptor) => {
// descriptor.materials: MaterialList,
// descriptor.meshes: Vec<MeshDescriptor>,
// descriptor.nodes: Vec<NodeDescriptor>,
// descriptor.animations: Vec<AnimationDescriptor>,
}
// Error
None(LoadError),
}
依赖项
~21MB
~253K SLoC