From 39a0ff935e6298193188d8569ae3cbb96807f34c Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Wed, 22 Jan 2025 09:29:20 -0500 Subject: Update --- Cargo.lock | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 7 ++++++- deps/gltf | 2 +- index.html | 2 +- src/lib.rs | 25 ++++++++++++------------- src/main.rs | 8 ++++++++ 6 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 6cc6179..663c60a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1596,6 +1596,29 @@ dependencies = [ "ttf-parser 0.20.0", ] +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.8", + "smallvec", + "windows-targets 0.52.6", +] + [[package]] name = "paste" version = "1.0.15" @@ -1778,6 +1801,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "regex" version = "1.11.1" @@ -2098,6 +2130,15 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -2379,6 +2420,7 @@ dependencies = [ "sdl2", "serde", "tobj", + "tokio", "tracing-wasm", "wasm-bindgen", "wasm-bindgen-futures", @@ -2499,11 +2541,25 @@ dependencies = [ "bytes", "libc", "mio", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2", + "tokio-macros", "windows-sys 0.52.0", ] +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tokio-native-tls" version = "0.3.1" diff --git a/Cargo.toml b/Cargo.toml index 47ed866..a21500d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,10 @@ edition = "2021" [lib] crate-type = ["cdylib", "rlib"] +[[bin]] +name = "tel" +path = "src/main.rs" + [profile.release] opt-level = 2 codegen-units = 1 @@ -44,4 +48,5 @@ web-sys = { version = "*", features = ["Document", "Window", "Element", "HtmlCan [target.'cfg(not(target_arch = "wasm32"))'.dependencies] env_logger = "*" sdl2 = "*" -kira = "0.9.6" \ No newline at end of file +kira = "0.9.6" +tokio = { version = "*", features = ["full"] } \ No newline at end of file diff --git a/deps/gltf b/deps/gltf index 9763a5a..2aa1bae 160000 --- a/deps/gltf +++ b/deps/gltf @@ -1 +1 @@ -Subproject commit 9763a5abe8c168eb1282a037ff16668542fe2a6d +Subproject commit 2aa1baec59d0a86384e78a3fbaa441f8f39ed710 diff --git a/index.html b/index.html index b47c5e1..be4cfac 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ - + 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