We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0cbbe51 commit afa96c6Copy full SHA for afa96c6
.gitignore
@@ -1,3 +1,3 @@
1
/target
2
/node_modules
3
-/dis
+/dist
index.js
@@ -11,6 +11,7 @@ import('./pkg')
11
world = wasm.World.new();
12
world.add_object(0., -380., 40., -100., 20., 20., 0.8, false);
13
world.add_object(-80., 0., 100., -400., 30., 30., 0.8, false);
14
+ world.add_object(200., 300., 0., 0., 30., 30., 0.8, true);
15
}
16
17
// Set world to the universal gravitation preset
@@ -23,9 +24,16 @@ import('./pkg')
23
24
world.set_meter_size(0.001);
25
26
27
+ function worldMultiCollision() {
28
+ world = wasm.World.new();
29
+ world.add_object(0., -380., 40., -100., 20., 20., 0.8, false);
30
+ world.add_object(-200., 20., 0., 0., 30., 30., 0.8, false);
31
+ }
32
+
33
let world_dictionary = {
34
"collision": worldCollision,
- "universal": worldUniversal
35
+ "universal": worldUniversal,
36
37
38
39
wolrd_preset_actual = document.getElementById("world_preset").value;
src/lib.rs
@@ -170,16 +170,16 @@ impl World {
170
171
if (obj.is_freeze) {
172
let impulse = (2. * dot_product) / (distance * (obj_.mass + obj_.mass));
173
- let bounce_x = (impulse * obj_.mass * delta_x) / distance + restitution_coef * ((impulse * obj_.mass * delta_x) / distance);
174
- let bounce_y = (impulse * obj_.mass * delta_y) / distance + restitution_coef * ((impulse * obj_.mass * delta_y) / distance);
+ let bounce_x = (impulse * obj_.mass * delta_x) / distance + restitution_coef * ((impulse * delta_x) / distance);
+ let bounce_y = (impulse * obj_.mass * delta_y) / distance + restitution_coef * ((impulse * delta_y) / distance);
175
176
obj_.velocity_x -= bounce_x;
177
obj_.velocity_y -= bounce_y;
178
179
else if (obj_.is_freeze) {
180
let impulse = (2. * dot_product) / (distance * (obj.mass + obj.mass));
181
- let bounce_x = (impulse * obj.mass * delta_x) / distance + restitution_coef * ((impulse * obj.mass * delta_x) / distance);
182
- let bounce_y = (impulse * obj.mass * delta_y) / distance +restitution_coef * ((impulse * obj.mass * delta_y) / distance);
+ let bounce_x = (impulse * obj.mass * delta_x) / distance + restitution_coef * ((impulse * delta_x) / distance);
+ let bounce_y = (impulse * obj.mass * delta_y) / distance +restitution_coef * ((impulse * delta_y) / distance);
183
obj.velocity_x += bounce_x;
184
obj.velocity_y += bounce_y;
185
0 commit comments