-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: cpic
Are you sure you want to change the base?
Conversation
# 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 |
There was a problem hiding this comment.
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?
device: RenderDevice, | ||
app_state: &mut AppState, | ||
_callbacks: &mut Callbacks, | ||
) -> PhysicsContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples function signature was changed to be slightly less bevy-specific, the device is still a bevy struct ; and the other parameters implement resource though 🤔
// NOTE: Heightfield may be more efficient or more predictable than trimesh for the knife. | ||
let heights = nalgebra::DMatrix::zeros(10, 5); | ||
let heightfield = rapier3d::prelude::HeightField::new(heights, vector![2.0, 1.0, 10.0]); | ||
let (mut vtx, idx) = heightfield.to_trimesh(); | ||
vtx.iter_mut().for_each(|pt| { | ||
*pt = Isometry3::rotation(vector![0f32, 0f32, -90f32.to_radians()]) * *pt | ||
+ vector![0.0, 1f32, 0f32] | ||
}); | ||
let co = ColliderBuilder::trimesh(vtx, idx).unwrap(); | ||
rapier_data | ||
.colliders | ||
.insert_with_parent(co, parent_handle, &mut rapier_data.bodies); | ||
*/ | ||
for (vertices, indices) in slicer_trimeshes.iter() { | ||
// Insert collider into rapier state. | ||
|
||
let collider = ColliderBuilder::new( | ||
SharedShape::trimesh_with_flags( | ||
vertices.clone(), | ||
indices | ||
.chunks_exact(3) | ||
.map(|i| [i[0] as u32, i[1] as u32, i[2] as u32]) | ||
.collect(), | ||
TriMeshFlags::FIX_INTERNAL_EDGES, | ||
) | ||
.unwrap(), | ||
); | ||
rapier_data | ||
.colliders | ||
.insert_with_parent(collider, parent_handle, &mut rapier_data.bodies); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what's the preferred behaviour there, using a model for collision is interesting, using a heightmap will probably be more stable (but it should probably be a quad if we're after simplicity)
let y_pos = 1.3; | ||
let z_pos = -1.5; | ||
let velocity = 0.9; | ||
let extended_width = 0.15; // extended width for the horizontal move to the right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to keep the code similar to the taichi implementation, with adapted values above to fit the models used.
I added "extended_width" to have additional room for the banana slices to split more correctly (otherwise they have a tendency to stick together)
49a074a
to
c7fe2b3
Compare
# Notes | ||
|
||
banana example: | ||
|
||
- oneway+dynamic coupling makes the knife going places (bouncing weirdly). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to remove
Based on #5 ; an interesting improvement to demos would be to sample material textures to apply a relevant color to each particle.
Screencast.from.03-11-2025.03_52_13.PM.mp4
Screencast.from.03-12-2025.01_04_04.PM.mp4