Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample color model #6

Open
wants to merge 25 commits into
base: cpic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
07c19b4
compiling 3d (from folder)
Vrixyz Mar 3, 2025
8922108
add an example loading a mesh into a particle
Vrixyz Mar 4, 2025
e94f20d
attempt to sample vertex colors from material
Vrixyz Mar 8, 2025
82e67e2
attempt to load glb into particles ; not working
Vrixyz Mar 10, 2025
ec3aa08
better model to showcase
Vrixyz Mar 11, 2025
56215de
correct color loading for gltf
Vrixyz Mar 11, 2025
6d6bbd1
wip loading banana and knife
Vrixyz Mar 12, 2025
00f01a1
format credits
Vrixyz Mar 12, 2025
d501afa
correctly load rigidbody coupling
Vrixyz Mar 12, 2025
4276c3e
knife cutting through banana (but cut is bugged)
Vrixyz Mar 12, 2025
25dc1f4
knife with open blade correctly cuts :)
Vrixyz Mar 12, 2025
37b7124
better time management
Vrixyz Mar 12, 2025
51c4af3
inside the banana is now white/yellow
Vrixyz Mar 12, 2025
841a565
attempt to use lib examples
Vrixyz Mar 13, 2025
cca0349
knif model follow its rigidbody
Vrixyz Mar 14, 2025
0c1be37
add comment about sample_mesh
Vrixyz Mar 14, 2025
5b38cf6
use binary for examples 3d
Vrixyz Mar 14, 2025
82ffe57
use binary for examples 2d
Vrixyz Mar 14, 2025
1b971d9
fix wasm build
Vrixyz Mar 14, 2025
27768c3
better banana cut ; moved utils functions to wgsparkl behind a featur…
Vrixyz Mar 17, 2025
0b2c38e
less bevy specific examples
Vrixyz Mar 18, 2025
f22a3f6
independant example for loading a glb to point cloud
Vrixyz Mar 18, 2025
c7fe2b3
fix some slippy lints
Vrixyz Mar 18, 2025
996eb87
better banana cut
Vrixyz Mar 18, 2025
b799c92
fix 2d examples
Vrixyz Mar 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ members = [
"crates/wgsparkl-testbed3d",
"crates/wgsparkl2d",
"crates/wgsparkl3d",
"examples3d",
"examples2d",
]
resolver = "2"

Expand All @@ -23,15 +25,31 @@ rust.unexpected_cfgs = { level = "warn", check-cfg = [
] }

[patch.crates-io]
parry2d = { path = "../parry/crates/parry2d" }
parry3d = { path = "../parry/crates/parry3d" }
encase = { path = "../encase" }
wgcore = { path = "../wgmath/crates/wgcore" }
wgebra = { path = "../wgmath/crates/wgebra" }
wgparry2d = { path = "../wgmath/crates/wgparry/crates/wgparry2d" }
wgparry3d = { path = "../wgmath/crates/wgparry/crates/wgparry3d" }
wgrapier2d = { path = "../wgmath/crates/wgrapier/crates/wgrapier2d" }
wgrapier3d = { path = "../wgmath/crates/wgrapier/crates/wgrapier3d" }
# parry2d = { path = "../parry/crates/parry2d" }
# parry3d = { path = "../parry/crates/parry3d" }
# encase = { path = "../encase" }
# wgcore = { path = "../wgmath/crates/wgcore" }
# wgebra = { path = "../wgmath/crates/wgebra" }
# wgparry2d = { path = "../wgmath/crates/wgparry/crates/wgparry2d" }
# wgparry3d = { path = "../wgmath/crates/wgparry/crates/wgparry3d" }
# wgrapier2d = { path = "../wgmath/crates/wgrapier/crates/wgrapier2d" }
# wgrapier3d = { path = "../wgmath/crates/wgrapier/crates/wgrapier3d" }

parry2d = { git = "https://github.com/dimforge/parry.git", rev = "407fb449504dde7ba0a3d80a8de7e37ac991a77a" }
parry3d = { git = "https://github.com/dimforge/parry.git", rev = "407fb449504dde7ba0a3d80a8de7e37ac991a77a" }
encase = { git = "https://github.com/sebcrozet/encase.git", rev = "6755c1414c225cbeac9fde1ff9394b70d3b05404" }
# wgcore = { git = "https://github.com/dimforge/wgmath.git", rev = "32b54c802be6040c5f003e7d3def4a33e4730d92" }
wgcore = { git = "https://github.com/dimforge/wgmath.git", branch = "wgml-chat" }
wgcore-derive = { git = "https://github.com/dimforge/wgmath.git", branch = "wgml-chat" }
wgebra = { git = "https://github.com/dimforge/wgmath.git", branch = "wgml-chat" }
# wgparry2d = { git = "https://github.com/dimforge/wgmath.git", rev = "32b54c802be6040c5f003e7d3def4a33e4730d92" }
wgparry3d = { git = "https://github.com/dimforge/wgmath.git", branch = "wgml-chat" }
# wgrapier2d = { git = "https://github.com/dimforge/wgmath.git", rev = "32b54c802be6040c5f003e7d3def4a33e4730d92" }
wgrapier3d = { git = "https://github.com/dimforge/wgmath.git", branch = "wgml-chat" }
rapier3d = { git = "https://github.com/vrixyz/rapier.git", branch = "uber_physics_context" }

[profile.release]
opt-level = 'z'

[profile.dev]
opt-level = 1
16 changes: 8 additions & 8 deletions build_wasm.sh
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +3 to +8
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2d examples seem broken on cpic branch?


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
# 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
15 changes: 11 additions & 4 deletions crates/wgsparkl-testbed2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ path = "../../src_testbed/lib.rs"
required-features = ["dim2"]

[features]
default = ["dim2"]
dim2 = []
default_features = ["dim2"]

[dependencies]
nalgebra = { workspace = true, features = ["rand"] }
Expand All @@ -31,10 +31,17 @@ 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"] }
bevy = { version = "0.15.0", features = [
"shader_format_glsl",
"shader_format_spirv",
"webgpu",
] }
#bevy_wasm_window_resize = "0.4"
bevy_editor_cam = "0.5"
bevy_egui = { version = "0.31", default-features = false, features = ["default_fonts", "render"] }
bevy_egui = { version = "0.31", default-features = false, features = [
"default_fonts",
"render",
] }
bevy_sprite = "0.15"
wgsparkl2d = { path = "../wgsparkl2d" }
futures = "0.3"
futures = "0.3"
13 changes: 10 additions & 3 deletions crates/wgsparkl-testbed3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ path = "../../src_testbed/lib.rs"
required-features = ["dim3"]

[features]
default = ["dim3"]
dim3 = []
default_features = ["dim3"]

[dependencies]
nalgebra = { workspace = true, features = ["rand"] }
Expand All @@ -31,10 +31,17 @@ 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"] }
bevy = { version = "0.15.0", features = [
"shader_format_glsl",
"shader_format_spirv",
"webgpu",
] }
bevy_editor_cam = "0.5"
#bevy_mod_picking = { version = "0.20", default-features = false }
#bevy_wasm_window_resize = "0.4"
bevy_egui = { version = "0.31", default-features = false, features = ["default_fonts", "render"] }
bevy_egui = { version = "0.31", default-features = false, features = [
"default_fonts",
"render",
] }
wgsparkl3d = { path = "../wgsparkl3d" }
futures = "0.3"
9 changes: 0 additions & 9 deletions crates/wgsparkl2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,3 @@ rapier2d = "0.23"
# For wasm?
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"] }
27 changes: 19 additions & 8 deletions crates/wgsparkl3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -33,11 +36,19 @@ wgrapier3d = "0.2"
# TODO: make rapier optional?
rapier3d = "0.23"

[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" }
# 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 }

[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
121 changes: 0 additions & 121 deletions crates/wgsparkl3d/examples/sand3.rs

This file was deleted.

2 changes: 1 addition & 1 deletion dist2d/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<body style="margin: 0px;">
<script type="module">
import init from './elasticity2.js'
import init from './wgsparkl-examples-2d.js'

init().catch((error) => {
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
Expand Down
2 changes: 1 addition & 1 deletion dist3d/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<body style="margin: 0px;">
<script type="module">
import init from './elasticity3.js'
import init from './wgsparkl-examples-3d.js'

init().catch((error) => {
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
Expand Down
24 changes: 24 additions & 0 deletions examples2d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "wgsparkl-examples-2d"
version = "0.1.0"
license = "Apache-2.0 OR Custom"
edition = "2021"

[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",
"jpeg",
] }
wgsparkl_testbed2d = { path = "../crates/wgsparkl-testbed2d" }
wgsparkl2d = { path = "../crates/wgsparkl2d" }
rapier3d = "0.23"

[lints]
workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ fn main() {
}

pub fn elastic_cut_demo(
mut commands: Commands,
device: Res<RenderDevice>,
mut app_state: ResMut<AppState>,
) {
device: RenderDevice,
app_state: &mut AppState,
_callbacks: &mut Callbacks,
) -> PhysicsContext {
let mut rapier_data = RapierData::default();
let device = device.wgpu_device();

Expand All @@ -48,6 +48,7 @@ pub fn elastic_cut_demo(
phase: 1.0,
max_stretch: f32::MAX,
}),
color: None,
});
}
}
Expand Down Expand Up @@ -118,9 +119,9 @@ pub fn elastic_cut_demo(
cell_width,
60_000,
);
commands.insert_resource(PhysicsContext {
PhysicsContext {
data,
rapier_data,
particles,
});
}
}
Loading