Skip to main content

he3d_core/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![forbid(unsafe_code)]
3
4//! HE3D core.
5//! HE3D 核心。
6//!
7//! Owns the scene graph, resources (meshes, textures, materials), and stable generational IDs.
8//! 拥有场景图、资源(网格、纹理、材质)以及稳定的代际 ID。
9//! A [`Scene`] owns its resources directly through [`Arena`]s; IDs are cheap handles that never dangle.
10//! 一个 [`Scene`] 直接通过 [`Arena`] 拥有其资源;ID 是永不悬垂的廉价句柄。
11//!
12//! Everything here is `no_std + alloc`. The optional `std` feature only adds convenience impls (e.g. `std::error::Error`); it never enables `std` for any dependency by default.
13//! 此处所有内容都是 `no_std + alloc`。可选的 `std` 特性仅添加便捷实现(例如 `std::error::Error`);它永远不会默认启用任何依赖的 `std`。
14
15extern crate alloc;
16
17mod arena;
18mod camera;
19mod color;
20mod error;
21mod light;
22mod material;
23mod mesh;
24mod scene;
25mod texture;
26mod transform;
27
28pub use arena::{Arena, Id};
29pub use camera::Camera;
30pub use color::{ColorRgba8, Rgb};
31pub use error::Error;
32pub use light::DirectionalLight;
33pub use material::Material;
34pub use mesh::{MAX_VERTEX_COUNT, Mesh};
35pub use scene::{RenderObject, Scene};
36pub use texture::Texture;
37pub use transform::Transform;
38
39/// Stable handle to a [`Mesh`].
40/// 指向 [`Mesh`] 的稳定句柄。
41pub type MeshId = Id<Mesh>;
42/// Stable handle to a [`Texture`].
43/// 指向 [`Texture`] 的稳定句柄。
44pub type TextureId = Id<Texture>;
45/// Stable handle to a [`RenderObject`].
46/// 指向 [`RenderObject`] 的稳定句柄。
47pub type ObjectId = Id<RenderObject>;
48
49#[cfg(test)]
50mod tests {
51   use alloc::vec;
52   use alloc::vec::Vec;
53
54   #[test]
55   fn alloc_is_available() {
56      let mut v: Vec<u32> = vec![0, 1, 2];
57      v.push(3);
58      assert_eq!(v, [0, 1, 2, 3]);
59   }
60}