summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-03-03 18:56:22 -0500
committerLLLL Colonq <llll@colonq>2025-03-03 18:56:38 -0500
commit8450893a1c0598b3af8c7cf9a9c39966e754ae14 (patch)
treed5c3162c91b44aa1e52e1098ae729aec5d305e2a /src
parente73044fbd51f9c8f15eb6bd60248887ccd8b16f0 (diff)
Move example to example
Diffstat (limited to 'src')
-rw-r--r--src/assets/fonts/ComicNeue-Regular.ttfbin54848 -> 0 bytes
-rw-r--r--src/assets/meshes/cube.obj38
-rw-r--r--src/assets/scenes/fox.glbbin162852 -> 0 bytes
-rw-r--r--src/assets/textures/test.pngbin125 -> 0 bytes
-rw-r--r--src/lib.rs74
-rw-r--r--src/main.rs8
-rw-r--r--src/scene.rs7
7 files changed, 7 insertions, 120 deletions
diff --git a/src/assets/fonts/ComicNeue-Regular.ttf b/src/assets/fonts/ComicNeue-Regular.ttf
deleted file mode 100644
index d454f46..0000000
--- a/src/assets/fonts/ComicNeue-Regular.ttf
+++ /dev/null
Binary files differ
diff --git a/src/assets/meshes/cube.obj b/src/assets/meshes/cube.obj
deleted file mode 100644
index 2f3a670..0000000
--- a/src/assets/meshes/cube.obj
+++ /dev/null
@@ -1,38 +0,0 @@
-# Blender 4.1.1
-# www.blender.org
-o Cube
-v 1.000000 1.000000 -1.000000
-v 1.000000 -1.000000 -1.000000
-v 1.000000 1.000000 1.000000
-v 1.000000 -1.000000 1.000000
-v -1.000000 1.000000 -1.000000
-v -1.000000 -1.000000 -1.000000
-v -1.000000 1.000000 1.000000
-v -1.000000 -1.000000 1.000000
-vn -0.0000 1.0000 -0.0000
-vn -0.0000 -0.0000 1.0000
-vn -1.0000 -0.0000 -0.0000
-vn -0.0000 -1.0000 -0.0000
-vn 1.0000 -0.0000 -0.0000
-vn -0.0000 -0.0000 -1.0000
-vt 0.625000 0.500000
-vt 0.875000 0.500000
-vt 0.875000 0.750000
-vt 0.625000 0.750000
-vt 0.375000 0.750000
-vt 0.625000 1.000000
-vt 0.375000 1.000000
-vt 0.375000 0.000000
-vt 0.625000 0.000000
-vt 0.625000 0.250000
-vt 0.375000 0.250000
-vt 0.125000 0.500000
-vt 0.375000 0.500000
-vt 0.125000 0.750000
-s 0
-f 1/1/1 5/2/1 7/3/1 3/4/1
-f 4/5/2 3/4/2 7/6/2 8/7/2
-f 8/8/3 7/9/3 5/10/3 6/11/3
-f 6/12/4 2/13/4 4/5/4 8/14/4
-f 2/13/5 1/1/5 3/4/5 4/5/5
-f 6/11/6 5/10/6 1/1/6 2/13/6
diff --git a/src/assets/scenes/fox.glb b/src/assets/scenes/fox.glb
deleted file mode 100644
index 1ef5c0d..0000000
--- a/src/assets/scenes/fox.glb
+++ /dev/null
Binary files differ
diff --git a/src/assets/textures/test.png b/src/assets/textures/test.png
deleted file mode 100644
index 0752be0..0000000
--- a/src/assets/textures/test.png
+++ /dev/null
Binary files differ
diff --git a/src/lib.rs b/src/lib.rs
index 7f60300..e39b474 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -13,8 +13,6 @@ pub mod audio;
pub mod net;
pub mod save;
-use std::ops::Rem;
-
#[cfg(target_arch = "wasm32")]
use winit::platform::web::EventLoopExtWebSys;
@@ -312,75 +310,3 @@ where
});
});
}
-
-#[cfg(target_arch = "wasm32")]
-use wasm_bindgen::prelude::*;
-
-pub struct TestGame {
- font: font::Bitmap,
- tt: font::TrueType,
- // cube: mesh::Mesh,
- fox: scene::Scene,
- tex: texture::Texture,
- shader: shader::Shader,
-}
-
-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")),
- 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")),
- }
- }
-}
-
-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, -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("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::Quat::from_rotation_y(st.tick as f32 / 60.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, 10.0), "he's all FIXED up");
- self.tt.render_text_helper(
- ctx, &glam::Vec2::new(10.0, 60.0), &glam::Vec2::new(20.0, 30.0),
- "tESTge",
- &[
- glam::Vec3::new(1.0, 0.0, 0.0),
- glam::Vec3::new(0.0, 1.0, 0.0),
- ],
- );
- Some(())
- }
-}
-
-#[cfg(target_arch = "wasm32")]
-#[wasm_bindgen]
-pub async fn main_js_test() {
- run(240, 160, Options::empty(), TestGame::new).await;
-}
diff --git a/src/main.rs b/src/main.rs
deleted file mode 100644
index f7c2a88..0000000
--- a/src/main.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#[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::Options::empty(), teleia::TestGame::new).await;
-}
diff --git a/src/scene.rs b/src/scene.rs
index 9e98936..3146b5d 100644
--- a/src/scene.rs
+++ b/src/scene.rs
@@ -79,6 +79,13 @@ pub struct Scene {
}
impl Scene {
+ pub fn load_default_shader(ctx: &context::Context) -> shader::Shader {
+ shader::Shader::new(
+ ctx,
+ include_str!("assets/shaders/scene/vert.glsl"),
+ include_str!("assets/shaders/scene/frag.glsl")
+ )
+ }
pub fn from_gltf(ctx: &context::Context, bytes: &[u8]) -> Self {
let (gltf, buffers, images) = gltf::import_slice(bytes).expect("failed to parse GLTF");
let get_buffer_data = |b: gltf::Buffer| {