pub struct TextureSlot {
pub texture: Option<TextureHandle>,
pub transform: TextureTransform,
pub channel: u8,
}Expand description
A texture slot that holds a texture reference and its UV transformation.
This is the primary way materials reference textures. Each slot can optionally contain a texture handle and UV transformation parameters.
§Example
ⓘ
// Create a slot with a texture
let slot = TextureSlot::new(texture_handle);
// Create a slot with custom transform
let slot = TextureSlot::with_transform(texture_handle, TextureTransform {
offset: Vec2::new(0.5, 0.0),
rotation: 0.0,
scale: Vec2::ONE,
});Fields§
§texture: Option<TextureHandle>The texture handle (None if no texture is assigned)
transform: TextureTransformUV transformation applied to this texture
channel: u8UV channel index (for meshes with multiple UV sets)
Implementations§
Source§impl TextureSlot
impl TextureSlot
Sourcepub fn new(handle: TextureHandle) -> TextureSlot
pub fn new(handle: TextureHandle) -> TextureSlot
Creates a new texture slot with default transform.
Sourcepub fn with_transform(
handle: TextureHandle,
transform: TextureTransform,
) -> TextureSlot
pub fn with_transform( handle: TextureHandle, transform: TextureTransform, ) -> TextureSlot
Creates a new texture slot with a custom transform.
Sourcepub fn compute_matrix(&self) -> Mat3Padded
pub fn compute_matrix(&self) -> Mat3Padded
Computes the UV transformation matrix (3x3).
Transform order: Translate * Rotate * Scale
The resulting matrix is in column-major order for WGSL compatibility.
pub fn is_some(&self) -> bool
pub fn is_none(&self) -> bool
Sourcepub fn set_texture(&mut self, handle: Option<TextureHandle>)
pub fn set_texture(&mut self, handle: Option<TextureHandle>)
Sets the texture handle.
Trait Implementations§
Source§impl Clone for TextureSlot
impl Clone for TextureSlot
Source§fn clone(&self) -> TextureSlot
fn clone(&self) -> TextureSlot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TextureSlot
impl Debug for TextureSlot
Source§impl Default for TextureSlot
impl Default for TextureSlot
Source§fn default() -> TextureSlot
fn default() -> TextureSlot
Returns the “default value” for a type. Read more
Source§impl From<Option<TextureHandle>> for TextureSlot
impl From<Option<TextureHandle>> for TextureSlot
Source§fn from(opt: Option<TextureHandle>) -> TextureSlot
fn from(opt: Option<TextureHandle>) -> TextureSlot
Converts to this type from the input type.
Source§impl From<Option<TextureSource>> for TextureSlot
impl From<Option<TextureSource>> for TextureSlot
Source§fn from(opt: Option<TextureSource>) -> TextureSlot
fn from(opt: Option<TextureSource>) -> TextureSlot
Converts to this type from the input type.
Source§impl From<TextureHandle> for TextureSlot
impl From<TextureHandle> for TextureSlot
Source§fn from(handle: TextureHandle) -> TextureSlot
fn from(handle: TextureHandle) -> TextureSlot
Converts to this type from the input type.
Source§impl From<TextureSource> for TextureSlot
impl From<TextureSource> for TextureSlot
Source§fn from(source: TextureSource) -> TextureSlot
fn from(source: TextureSource) -> TextureSlot
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for TextureSlot
impl RefUnwindSafe for TextureSlot
impl Send for TextureSlot
impl Sync for TextureSlot
impl Unpin for TextureSlot
impl UnsafeUnpin for TextureSlot
impl UnwindSafe for TextureSlot
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().