phetsims / friction

"Friction" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/friction
GNU General Public License v3.0
4 stars 6 forks source link

(Interactive Description) I hear "up" when I do not press up #254

Closed terracoda closed 2 years ago

terracoda commented 2 years ago

This issue might go away naturally as we finalize work on this sim.

Using VO on MacOs Big Sur 11.4

I tab to either of the book interactions. Grab the book. Press down arrow to touch the book I hear "Down. Rub fast or slow." The here "up", though I never press the up arrow.

I do not know why I am getting this random utterance of "up". After I actually move down.

Screen Shot 2021-10-04 at 10 50 35 AM
zepumph commented 2 years ago

Thanks for the bug report, this is an interesting one. It looks like the model is fighting the drag listener, because the bounds are different. When you move down, you eventually get to the bottom book. Once that occurs, the keyboard drag listener is still applying a multiplier and trying to move the book down past the book. Then it tells the model to move down, and in the model there is bounds where it knows that it can't anymore, so it "bounces" it back to be on the bottom book. Here is the logging that shows that back and forth. The y coordinate for "on top of the bottom book" is 25.

Vector2 {x: 0, y: 9.6} Vector2 {x: 0, y: 0}
MovementAlerter.js:140 Vector2 {x: 0, y: 19.2} Vector2 {x: 0, y: 9.6}
MovementAlerter.js:140 Vector2 {x: 0, y: 28.799999999999997} Vector2 {x: 0, y: 19.2}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 28.799999999999997}
MovementAlerter.js:140 Vector2 {x: 0, y: 41.8} Vector2 {x: 0, y: 25}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 41.8}
MovementAlerter.js:140 Vector2 {x: 0, y: 35.2} Vector2 {x: 0, y: 25}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 35.2}
MovementAlerter.js:140 Vector2 {x: 0, y: 32.8} Vector2 {x: 0, y: 25}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 32.8}
MovementAlerter.js:140 Vector2 {x: 0, y: 37} Vector2 {x: 0, y: 25}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 37}
MovementAlerter.js:140 Vector2 {x: 0, y: 29.2} Vector2 {x: 0, y: 25}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 29.2}
MovementAlerter.js:140 Vector2 {x: 0, y: 41.2} Vector2 {x: 0, y: 25}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 41.2}
MovementAlerter.js:140 Vector2 {x: 0, y: 34.6} Vector2 {x: 0, y: 25}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 34.6}
MovementAlerter.js:140 Vector2 {x: 0, y: 29.2} Vector2 {x: 0, y: 25}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 29.2}
MovementAlerter.js:140 Vector2 {x: 0, y: 40} Vector2 {x: 0, y: 25}
MovementAlerter.js:140 Vector2 {x: 0, y: 25} Vector2 {x: 0, y: 40}

I think I can fix this by passing in the correct bounds to the keyboard drag listener.

zepumph commented 2 years ago

I found where the bounds are defined, and I see that the bottom of it is off in space.

https://github.com/phetsims/friction/blob/84d3aaddd9240a47efd505c0a734af2a0de5ab32/js/friction/model/FrictionModel.js#L485-L490

This assumes that the move() function in the model will straighten things out. This patch fixes the initial problem, but I can't move down further than when the first row of atoms touch.


Index: js/friction/model/FrictionModel.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/friction/model/FrictionModel.js b/js/friction/model/FrictionModel.js
--- a/js/friction/model/FrictionModel.js    (revision c3e81a0a4ce83a400ef50a66860bfbba8d82e961)
+++ b/js/friction/model/FrictionModel.js    (date 1633568167275)
@@ -487,7 +487,7 @@
   -MAX_X_DISPLACEMENT, // left bound
   MIN_Y_POSITION, // top bound
   MAX_X_DISPLACEMENT, // right bound
-  2000 );
+  INITIAL_ATOM_SPACING_Y );

 FrictionModel.FrictionModelIO = IOType.fromCoreType( 'FrictionModelIO', FrictionModel, {
   documentation: 'model for the simulation'

I'm a bit stumped on this one. I'm going to need to come back to this, perhaps with a phone-a-friend.

zepumph commented 2 years ago

@samreid and I worked on this briefly, and found that it was buggy to have the model AND the keyboardDragListener setting the position Property for the book. Instead, the drag listener just needed to pass on the delta it calculated to the move. Then the two weren't fighting over who should set the Property. @terracoda please review.

terracoda commented 2 years ago

Awesome! I no longer hear "up" unless I actually move the book up.

Thanks @samreid and @zepumph!