use glam::Mat4;
use crate::color::{Color, WHITE};
use crate::handle::Handle;
use crate::light3d::Material3D;
use crate::mesh3d::{DrawMode, InstanceData, Mesh3D};
pub struct Draw3D {
pub mesh: Mesh3D,
pub model: Mat4,
pub texture: Option<Handle>,
pub color: Color,
pub material: Material3D,
pub draw_mode: DrawMode,
}
impl Draw3D {
pub fn new(mesh: Mesh3D, model: Mat4) -> Self {
Self {
mesh,
model,
texture: None,
color: WHITE,
material: Material3D::default(),
draw_mode: DrawMode::default(),
}
}
pub fn with_texture(mut self, texture: Handle) -> Self {
self.texture = Some(texture);
self
}
pub fn with_color(mut self, color: Color) -> Self {
self.color = color;
self
}
pub fn with_material(mut self, material: Material3D) -> Self {
self.material = material;
self
}
pub fn with_draw_mode(mut self, draw_mode: DrawMode) -> Self {
self.draw_mode = draw_mode;
self
}
}
pub struct InstancedDraw3D {
pub mesh: Mesh3D,
pub instances: Vec<InstanceData>,
pub texture: Option<Handle>,
pub material: Material3D,
}
impl InstancedDraw3D {
pub fn new(mesh: Mesh3D, instances: Vec<InstanceData>) -> Self {
Self {
mesh,
instances,
texture: None,
material: Material3D::default(),
}
}
pub fn with_texture(mut self, texture: Handle) -> Self {
self.texture = Some(texture);
self
}
pub fn with_material(mut self, material: Material3D) -> Self {
self.material = material;
self
}
pub fn instance_count(&self) -> usize {
self.instances.len()
}
}