phetsims / build-a-nucleus

"Build a Nucleus" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 5 forks source link

Particle y position offset incorrect in decay screen #65

Closed Luisav1 closed 1 year ago

Luisav1 commented 1 year ago

The particle's y position is offset to a higher position when the arrows are used or when a particle is automatically returned back to the stack. This doesn't happen with dragging or ending a drag. See example below. issue

@marlitas and I noticed this bug appears when the returnParticleToStack() and createParticleFromStack() functions are used. The two functions use the following lines in BANScreenView to determine the creator node center from where to create or return particles.

    BANScreenView.protonsCreatorNodeModelCenter = this.modelViewTransform.viewToModelPosition( this.protonsCreatorNode.center );
    BANScreenView.neutronsCreatorNodeModelCenter = this.modelViewTransform.viewToModelPosition( this.neutronsCreatorNode.center );

We recently changed the ModelViewTransform so that it's passed in individually through its child classes since ChartIntroScreenView and DecayScreenView use different MVTs. See https://github.com/phetsims/build-a-nucleus/commit/77930227f9fcf89289169d0cf52db2c7e5157db7. In comparing the original MVT in BANScreenView to the MVT currently in DecayScreenView, we didn't notice any difference.

We noticed this bug when we were fixing the MVT's in ChartIntroScreenView so we rollbacked those changes, which were never committed. We logged the MVT used for each model in BANScreenView which confirmed to us that the correct MVT below is being used in DecayScreenView.

const modelViewTransform = ModelViewTransform2.createSinglePointScaleMapping(
      Vector2.ZERO,
      new Vector2( BANConstants.SCREEN_VIEW_ATOM_CENTER_X, BANConstants.SCREEN_VIEW_ATOM_CENTER_Y ), // the center of the atom node
      1.0 );

We may have shifted things but are unsure of the best way to keep moving forward in debugging.

Luisav1 commented 1 year ago

@marlitas, @chrisklus, and I realized this is a result of https://github.com/phetsims/build-a-nucleus/issues/65. Closing as it was fixed with commits made there.