diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index afae59b..14a7aec 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] env: CARGO_TERM_COLOR: always @@ -75,4 +75,18 @@ jobs: sweep-cache: true - name: Check documentation - run: cargo doc --locked --workspace --all-features --document-private-items --no-deps \ No newline at end of file + run: cargo doc --locked --workspace --all-features --document-private-items --no-deps + + test: + name: Test + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Run cargo test + run: cargo test diff --git a/Cargo.toml b/Cargo.toml index dc849d1..55e8562 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,8 @@ members = [ "crates/wgsparkl-testbed3d", "crates/wgsparkl2d", "crates/wgsparkl3d", + "examples3d", + "examples2d", ] resolver = "2" @@ -32,6 +34,10 @@ wgparry2d = { git = "https://github.com/dimforge/wgmath.git", rev = "6d17942bd84 wgrapier3d = { git = "https://github.com/dimforge/wgmath.git", rev = "6d17942bd841efdfcc696d8455b22be3a8ddfe8d" } wgrapier2d = { git = "https://github.com/dimforge/wgmath.git", rev = "6d17942bd841efdfcc696d8455b22be3a8ddfe8d" } rapier3d = { git = "https://github.com/vrixyz/rapier.git", branch = "uber_physics_context" } +rapier2d = { git = "https://github.com/vrixyz/rapier.git", branch = "uber_physics_context" } [profile.release] opt-level = 'z' + +[profile.dev] +opt-level = 1 diff --git a/build_wasm.sh b/build_wasm.sh index 8b2f27d..430d650 100755 --- a/build_wasm.sh +++ b/build_wasm.sh @@ -1,11 +1,11 @@ #!/bin/sh -cargo build --example elasticity2 --release --target wasm32-unknown-unknown --features dim2 -cargo build --example elasticity3 --release --target wasm32-unknown-unknown --features dim3 -wasm-bindgen --no-typescript --target web --out-dir dist2d --out-name elasticity2 ./target/wasm32-unknown-unknown/release/examples/elasticity2.wasm -wasm-bindgen --no-typescript --target web --out-dir dist3d --out-name elasticity3 ./target/wasm32-unknown-unknown/release/examples/elasticity3.wasm -wasm-opt -Oz -o ./dist2d/opt.wasm ./dist2d/elasticity2_bg.wasm && mv ./dist2d/opt.wasm ./dist2d/elasticity2_bg.wasm -wasm-opt -Oz -o ./dist3d/opt.wasm ./dist3d/elasticity3_bg.wasm && mv ./dist3d/opt.wasm ./dist3d/elasticity3_bg.wasm +cargo build -p wgsparkl-examples-2d --release --target wasm32-unknown-unknown +cargo build -p wgsparkl-examples-3d --release --target wasm32-unknown-unknown +wasm-bindgen --no-typescript --target web --out-dir dist2d --out-name wgsparkl-examples-2d ./target/wasm32-unknown-unknown/release/wgsparkl-examples-2d.wasm +wasm-bindgen --no-typescript --target web --out-dir dist3d --out-name wgsparkl-examples-3d ./target/wasm32-unknown-unknown/release/wgsparkl-examples-3d.wasm +wasm-opt -Oz -o ./dist2d/opt.wasm ./dist2d/wgsparkl-examples-2d_bg.wasm && mv ./dist2d/opt.wasm ./dist2d/wgsparkl-examples-2d_bg.wasm +wasm-opt -Oz -o ./dist3d/opt.wasm ./dist3d/wgsparkl-examples-3d_bg.wasm && mv ./dist3d/opt.wasm ./dist3d/wgsparkl-examples-3d_bg.wasm -brotli ./dist2d/elasticity2_bg.wasm && mv ./dist2d/elasticity2_bg.wasm.br ./dist2d/elasticity2_bg.wasm -brotli ./dist3d/elasticity3_bg.wasm && mv ./dist3d/elasticity3_bg.wasm.br ./dist3d/elasticity3_bg.wasm \ No newline at end of file +brotli ./dist2d/wgsparkl-examples-2d_bg.wasm && mv ./dist2d/wgsparkl-examples-2d_bg.wasm.br ./dist2d/wgsparkl-examples-2d_bg.wasm +brotli ./dist3d/wgsparkl-examples-3d_bg.wasm && mv ./dist3d/wgsparkl-examples-3d_bg.wasm.br ./dist3d/wgsparkl-examples-3d_bg.wasm \ No newline at end of file diff --git a/crates/wgsparkl-testbed2d/Cargo.toml b/crates/wgsparkl-testbed2d/Cargo.toml index 8971c05..483c7e8 100644 --- a/crates/wgsparkl-testbed2d/Cargo.toml +++ b/crates/wgsparkl-testbed2d/Cargo.toml @@ -13,8 +13,8 @@ path = "../../src_testbed/lib.rs" required-features = ["dim2"] [features] -dim2 = [] default = ["dim2"] +dim2 = [] [dependencies] nalgebra = { workspace = true, features = ["rand"] } diff --git a/crates/wgsparkl-testbed3d/Cargo.toml b/crates/wgsparkl-testbed3d/Cargo.toml index 3d79cf2..d652796 100644 --- a/crates/wgsparkl-testbed3d/Cargo.toml +++ b/crates/wgsparkl-testbed3d/Cargo.toml @@ -13,8 +13,8 @@ path = "../../src_testbed/lib.rs" required-features = ["dim3"] [features] -dim3 = [] default = ["dim3"] +dim3 = [] [dependencies] nalgebra = { workspace = true, features = ["rand"] } diff --git a/crates/wgsparkl2d/Cargo.toml b/crates/wgsparkl2d/Cargo.toml index 8645eba..0c06e39 100644 --- a/crates/wgsparkl2d/Cargo.toml +++ b/crates/wgsparkl2d/Cargo.toml @@ -36,10 +36,5 @@ getrandom = { version = "0.3.1", features = ["wasm_js"] } uuid = { version = "1", features = ["js"] } [dev-dependencies] -nalgebra = { version = "0.33", features = ["rand"] } futures-test = "0.3" serial_test = "3" -approx = "0.5" -async-std = { version = "1", features = ["attributes"] } -bevy = { version = "0.15.0", features = ["shader_format_glsl", "shader_format_spirv", "webgpu"] } -wgsparkl_testbed2d = { path = "../wgsparkl-testbed2d", features = ["dim2"] } diff --git a/crates/wgsparkl3d/Cargo.toml b/crates/wgsparkl3d/Cargo.toml index 6654d2e..f0fed7e 100644 --- a/crates/wgsparkl3d/Cargo.toml +++ b/crates/wgsparkl3d/Cargo.toml @@ -15,6 +15,9 @@ required-features = ["dim3"] [features] default = ["dim3"] dim3 = [] +load_gltf = ["obj-rs", "image"] +load_obj = ["gltf", "image"] +load_bevy = ["bevy", "image"] [dependencies] nalgebra = { workspace = true } @@ -33,11 +36,24 @@ wgrapier3d = "0.2" # TODO: make rapier optional? rapier3d = "0.23" +# for loaders +# TODO: slim bevy features +bevy = { version = "0.15.0", features = [ + "shader_format_glsl", + "shader_format_spirv", + "webgpu", + "jpeg", +], optional = true } +gltf = { version = "1.3", features = [ + "KHR_materials_pbrSpecularGlossiness", +], optional = true } +obj-rs = { version = "0.7", default-features = false, optional = true } +image = { version = "0.25", optional = true } + + [dev-dependencies] -nalgebra = { version = "0.33", features = ["rand"] } futures-test = "0.3" serial_test = "3" -approx = "0.5" -async-std = { version = "1", features = ["attributes"] } -bevy = { version = "0.15.0", features = ["shader_format_glsl", "shader_format_spirv", "webgpu"] } -wgsparkl_testbed3d = { path = "../wgsparkl-testbed3d" } \ No newline at end of file + +[package.metadata.docs.rs] +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] diff --git a/dist2d/index.html b/dist2d/index.html index 0bb9815..3794f6a 100644 --- a/dist2d/index.html +++ b/dist2d/index.html @@ -3,7 +3,7 @@