diff options
| author | LLLL Colonq <llll@colonq> | 2025-01-15 21:21:22 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-01-15 21:21:22 -0500 |
| commit | 82d1c94d999654bda5d40108393eade80b77342c (patch) | |
| tree | 2a05c0ffe34ba47933ca39ebef3c3609fb6a5d2a /src/lib.rs | |
| parent | f1b47ccb8a92280df51bb28b495829f8f7f8127e (diff) | |
Update
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -11,6 +11,8 @@ pub mod font; pub mod shadow; pub mod audio; pub mod net; +use std::ops::Rem; + #[cfg(target_arch = "wasm32")] use winit::platform::web::EventLoopExtWebSys; @@ -272,7 +274,8 @@ use wasm_bindgen::prelude::*; #[cfg(target_arch = "wasm32")] struct TestGame { - font: font::Font, + font: font::Bitmap, + tt: font::TrueType, cube: mesh::Mesh, fox: scene::Scene, tex: texture::Texture, @@ -281,9 +284,9 @@ struct TestGame { impl TestGame { pub async fn new(ctx: &context::Context) -> Self { Self { - font: font::Font::new(ctx), + font: font::Bitmap::new(ctx), + tt: font::TrueType::new(ctx), cube: mesh::Mesh::from_obj(ctx, include_bytes!("assets/meshes/cube.obj")), - // fox: scene::Scene::from_gltf(ctx, include_bytes!("/home/llll/src/colonq/assets/lcolonq_flat.vrm")), fox: scene::Scene::from_gltf(ctx, include_bytes!("assets/scenes/fox.glb")), tex: texture::Texture::new(ctx, include_bytes!("assets/textures/test.png")), shader: shader::Shader::new(ctx, include_str!("assets/shaders/scene/vert.glsl"), include_str!("assets/shaders/scene/frag.glsl")), @@ -294,34 +297,36 @@ impl state::Game for TestGame { fn update(&mut self, ctx: &context::Context, st: &mut state::State) -> Option<()> { st.move_camera( ctx, - &glam::Vec3::new(0.0, 0.0, -10.0), + &glam::Vec3::new(0.0, 0.0, -1.0), &glam::Vec3::new(0.0, 0.0, 1.0), &glam::Vec3::new(0.0, 1.0, 0.0), ); Some(()) } fn render(&mut self, ctx: &context::Context, st: &mut state::State) -> Option<()> { - if let Some(n) = self.fox.nodes_by_name.get("b_Neck_04").and_then(|i| self.fox.nodes.get_mut(*i)) { - n.transform *= glam::Mat4::from_rotation_y(0.05); - } + // if let Some(n) = self.fox.nodes_by_name.get("J_Bip_C_Neck").and_then(|i| self.fox.nodes.get_mut(*i)) { + // n.transform *= glam::Mat4::from_rotation_z(0.05); + // } + self.fox.reflect_animation("Run", (st.tick as f32 / 60.0).rem(3.0)); st.bind_3d(ctx, &self.shader); self.shader.set_position_3d( ctx, &glam::Mat4::from_scale_rotation_translation( - glam::Vec3::new(0.1, 0.1, 0.1), + glam::Vec3::new(0.005, 0.005, 0.005), glam::Quat::from_rotation_y(st.tick as f32 / 60.0), - glam::Vec3::new(0.0, -5.0, 0.0), + glam::Vec3::new(0.0, -0.2, 0.0), ), ); self.tex.bind(ctx); self.fox.render(ctx, &self.shader); - self.font.render_text(ctx, &glam::Vec2::new(0.0, 0.0), "he's all fucked up"); + self.font.render_text(ctx, &glam::Vec2::new(0.0, 0.0), "he's all FIXED up"); + self.tt.render_text(ctx, &glam::Vec2::new(10.0, 10.0), "tESTge"); Some(()) } } #[cfg(target_arch = "wasm32")] #[wasm_bindgen] -pub async fn main_js() { +pub async fn main_js_test() { run(TestGame::new).await; } |
