From 39a0ff935e6298193188d8569ae3cbb96807f34c Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Wed, 22 Jan 2025 09:29:20 -0500 Subject: Update --- src/lib.rs | 25 ++++++++++++------------- src/main.rs | 8 ++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 src/main.rs (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index db802f0..78202b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,6 @@ pub mod shadow; pub mod audio; pub mod net; -#[cfg(target_arch = "wasm32")] use std::ops::Rem; #[cfg(target_arch = "wasm32")] @@ -273,8 +272,8 @@ where #[cfg(target_arch = "wasm32")] use wasm_bindgen::prelude::*; -#[cfg(target_arch = "wasm32")] -struct TestGame { + +pub struct TestGame { font: font::Bitmap, tt: font::TrueType, cube: mesh::Mesh, @@ -282,21 +281,21 @@ struct TestGame { tex: texture::Texture, shader: shader::Shader, } -#[cfg(target_arch = "wasm32")] + impl TestGame { pub async fn new(ctx: &context::Context) -> Self { Self { font: font::Bitmap::new(ctx), tt: font::TrueType::new(ctx, 12.0, include_bytes!("assets/fonts/ComicNeue-Regular.ttf")), cube: mesh::Mesh::from_obj(ctx, include_bytes!("assets/meshes/cube.obj")), - // fox: scene::Scene::from_gltf(ctx, include_bytes!("assets/scenes/fox.glb")), - 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")), + // fox: scene::Scene::from_gltf(ctx, include_bytes!("/home/llll/src/colonq/assets/lcolonq_flat.vrm")), 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")), } } } -#[cfg(target_arch = "wasm32")] + impl state::Game for TestGame { fn update(&mut self, ctx: &context::Context, st: &mut state::State) -> Option<()> { st.move_camera( @@ -308,16 +307,16 @@ impl state::Game for TestGame { Some(()) } fn render(&mut self, ctx: &context::Context, st: &mut state::State) -> Option<()> { - 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)); + // 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.005, 0.005, 0.005), - glam::Vec3::new(1.0, 1.0, 1.0), + glam::Vec3::new(0.005, 0.005, 0.005), + // glam::Vec3::new(1.0, 1.0, 1.0), glam::Quat::from_rotation_y(st.tick as f32 / 60.0), glam::Vec3::new(0.0, -0.2, 0.0), ), diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..5bbebd1 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,8 @@ +#[cfg(target_arch = "wasm32")] +pub fn main() {} + +#[cfg(not(target_arch = "wasm32"))] +#[tokio::main] +pub async fn main() { + teleia::run("teleia test", 240, 160, teleia::TestGame::new).await; +} -- cgit v1.2.3