pub struct Mesh3dAttributes { /* private fields */ }Expand description
Extensible model-vertex data for super::Mesh3d::with_attributes.
Omitted colors multiply by white. Supplied arrays must match the model vertex count exactly, including unused vertices; an explicit empty array is not omission. No normals or simulation quantities are generated here.
use sim_engine::{Color, Mesh3d, Mesh3dAttributes, Vec3};
let attributes = Mesh3dAttributes::new().with_vertex_colors(vec![
Color::rgb(1.0, 0.0, 0.0), Color::rgb(0.0, 1.0, 0.0), Color::rgb(0.0, 0.0, 1.0),
])?;
let mesh = Mesh3d::with_attributes(
vec![Vec3::ZERO, Vec3::X, Vec3::Y], vec![0, 1, 2], Vec::new(), attributes,
)?;
assert_eq!(mesh.vertex_colors().len(), 3);Implementations§
Source§impl Mesh3dAttributes
impl Mesh3dAttributes
Sourcepub const fn new() -> Mesh3dAttributes
pub const fn new() -> Mesh3dAttributes
Omits every optional attribute without allocating backing arrays.
Sourcepub fn with_texture_coordinates(
self,
coordinates: Vec<TextureCoordinate2d>,
) -> Mesh3dAttributes
pub fn with_texture_coordinates( self, coordinates: Vec<TextureCoordinate2d>, ) -> Mesh3dAttributes
Supplies normalized model UVs; mesh construction validates the count.
Sourcepub fn with_vertex_colors(
self,
colors: Vec<Color>,
) -> Result<Mesh3dAttributes, Mesh3dError>
pub fn with_vertex_colors( self, colors: Vec<Color>, ) -> Result<Mesh3dAttributes, Mesh3dError>
Supplies normalized, straight-linear RGBA colors without clamping.
Reports the source vertex index of the first non-finite or out-of-range channel. Mesh construction separately checks the exact vertex count. Opaque surfaces ignore vertex alpha; Mask and Blend use the combined alpha. RGBA is interpolated perspectively and multiplies surface/texture tint. Mathematical display edges keep their independent wireframe colors.
Sourcepub fn with_normals(
self,
normals: Vec<Vec3>,
) -> Result<Mesh3dAttributes, Mesh3dError>
pub fn with_normals( self, normals: Vec<Vec3>, ) -> Result<Mesh3dAttributes, Mesh3dError>
Supplies finite nonzero model normals, normalized robustly in place. No face normals are inferred. Every value, including unused vertices, is validated; mesh construction separately requires an exact vertex count. Nonuniform transforms use inverse-transpose direction transport, followed by perspective interpolation and fragment normalization, not vertex normalization.
Sourcepub fn normals(&self) -> Option<&[Vec3]>
pub fn normals(&self) -> Option<&[Vec3]>
Supplied normalized model normals, distinguishing omission from empty.
Sourcepub fn texture_coordinates(&self) -> Option<&[TextureCoordinate2d]>
pub fn texture_coordinates(&self) -> Option<&[TextureCoordinate2d]>
Supplied UVs, distinguishing omission from an explicit empty array.
Sourcepub fn vertex_colors(&self) -> Option<&[Color]>
pub fn vertex_colors(&self) -> Option<&[Color]>
Supplied straight-linear colors, distinguishing omission from empty.
Trait Implementations§
Source§impl Debug for Mesh3dAttributes
impl Debug for Mesh3dAttributes
Source§impl Default for Mesh3dAttributes
impl Default for Mesh3dAttributes
Source§fn default() -> Mesh3dAttributes
fn default() -> Mesh3dAttributes
Source§impl PartialEq for Mesh3dAttributes
impl PartialEq for Mesh3dAttributes
impl StructuralPartialEq for Mesh3dAttributes
Auto Trait Implementations§
impl Freeze for Mesh3dAttributes
impl RefUnwindSafe for Mesh3dAttributes
impl Send for Mesh3dAttributes
impl Sync for Mesh3dAttributes
impl Unpin for Mesh3dAttributes
impl UnsafeUnpin for Mesh3dAttributes
impl UnwindSafe for Mesh3dAttributes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().