Skip to main content

Mesh3dAttributes

Struct Mesh3dAttributes 

Source
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

Source

pub const fn new() -> Self

Omits every optional attribute without allocating backing arrays.

Source

pub fn with_texture_coordinates( self, coordinates: Vec<TextureCoordinate2d>, ) -> Self

Supplies normalized model UVs; mesh construction validates the count.

Source

pub fn with_vertex_colors(self, colors: Vec<Color>) -> Result<Self, 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.

Source

pub fn with_normals(self, normals: Vec<Vec3>) -> Result<Self, 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.

Source

pub fn normals(&self) -> Option<&[Vec3]>

Supplied normalized model normals, distinguishing omission from empty.

Source

pub fn texture_coordinates(&self) -> Option<&[TextureCoordinate2d]>

Supplied UVs, distinguishing omission from an explicit empty array.

Source

pub fn vertex_colors(&self) -> Option<&[Color]>

Supplied straight-linear colors, distinguishing omission from empty.

Trait Implementations§

Source§

impl Debug for Mesh3dAttributes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Mesh3dAttributes

Source§

fn default() -> Mesh3dAttributes

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Mesh3dAttributes

Source§

fn eq(&self, other: &Mesh3dAttributes) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Mesh3dAttributes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,