pub struct ModelMesh {
pub positions: Vec<[f32; 3]>,
pub normals: Vec<[f32; 3]>,
pub uvs: Vec<[f32; 2]>,
pub indices: Vec<u32>,
}Expand description
A lightweight mesh representation loaded from a 3D model file.
Fields§
§positions: Vec<[f32; 3]>Vertex positions [x, y, z].
normals: Vec<[f32; 3]>Vertex normals [nx, ny, nz].
uvs: Vec<[f32; 2]>Texture coordinates [u, v].
indices: Vec<u32>Triangle indices.
Implementations§
Source§impl ModelMesh
impl ModelMesh
Sourcepub fn from_gltf(bytes: &[u8]) -> Result<Self, ModelLoadError>
pub fn from_gltf(bytes: &[u8]) -> Result<Self, ModelLoadError>
Load the first mesh from a glTF binary (.glb) or JSON (.gltf)
buffer.
Extracts positions, normals, texture coordinates, and triangle
indices from the first primitive of the first mesh in the file.
Missing normals default to [0, 0, 1]; missing UVs default to
[0, 0].
§Errors
Returns ModelLoadError::Parse if the glTF data is malformed,
or ModelLoadError::NoMesh if the file contains no mesh
primitives.
Source§impl ModelMesh
impl ModelMesh
Sourcepub fn from_obj(bytes: &[u8]) -> Result<Self, ModelLoadError>
pub fn from_obj(bytes: &[u8]) -> Result<Self, ModelLoadError>
Load the first mesh from a Wavefront OBJ buffer.
Parses the OBJ data (no MTL material support). Extracts
positions, normals, and texture coordinates from the first
model. Missing normals default to [0, 0, 1]; missing UVs
default to [0, 0].
§Errors
Returns ModelLoadError::Parse if the OBJ data is malformed,
or ModelLoadError::NoMesh if the file contains no models.