blade_render/
lib.rs

1#![cfg(not(any(gles, target_arch = "wasm32")))]
2#![allow(irrefutable_let_patterns, clippy::new_without_default)]
3#![warn(
4    trivial_casts,
5    trivial_numeric_casts,
6    unused_extern_crates,
7    //TODO: re-enable. Currently doesn't like "mem::size_of" on newer Rust
8    //unused_qualifications,
9    // We don't match on a reference, unless required.
10    clippy::pattern_type_mismatch,
11)]
12
13mod asset_hub;
14pub mod model;
15mod render;
16pub mod shader;
17pub mod texture;
18pub mod util;
19
20pub use asset_hub::*;
21pub use model::Model;
22pub use render::*;
23pub use shader::Shader;
24pub use texture::Texture;
25
26// Has to match the `Vertex` in shaders
27#[repr(C)]
28#[derive(Clone, Copy, Debug, Default, bytemuck::Zeroable, bytemuck::Pod)]
29pub struct Vertex {
30    pub position: [f32; 3],
31    pub bitangent_sign: f32,
32    pub tex_coords: [f32; 2],
33    pub normal: u32,
34    pub tangent: u32,
35}
36
37#[derive(Clone, Copy, Debug)]
38pub struct Camera {
39    pub pos: mint::Vector3<f32>,
40    pub rot: mint::Quaternion<f32>,
41    pub fov_y: f32,
42    pub depth: f32,
43}
44
45pub struct Object {
46    pub model: blade_asset::Handle<Model>,
47    pub transform: blade_graphics::Transform,
48    pub prev_transform: blade_graphics::Transform,
49}
50
51impl From<blade_asset::Handle<Model>> for Object {
52    fn from(model: blade_asset::Handle<Model>) -> Self {
53        Self {
54            model,
55            transform: blade_graphics::IDENTITY_TRANSFORM,
56            prev_transform: blade_graphics::IDENTITY_TRANSFORM,
57        }
58    }
59}