Skip to main content

Module mesh_uv

Module mesh_uv 

Source
Expand description

UV unwrapping and normal smoothing for EditableMesh: projections, UV transforms, flat shading and crease-angle smoothing. All methods work on local-space geometry and mark the mesh as changed.

use kvas_engine::{mesh::MeshData, mesh_edit::EditableMesh};
use glam::Vec3;
let mut mesh = EditableMesh::from_mesh(&MeshData::primitive("cube").unwrap()).unwrap();
mesh.project_planar(Vec3::Y, 2.0);   // 2 metres per texture repeat, seen from above
mesh.normalize_uv(0.02);             // fit into 0..1 with a small border
mesh.smooth_normals(40.0);           // edges sharper than 40 degrees stay hard