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

Add a range for Score.targetXProperty #192

Closed
zepumph opened this issue Oct 17, 2019 · 15 comments
Closed

Add a range for Score.targetXProperty #192

zepumph opened this issue Oct 17, 2019 · 15 comments

Comments

@zepumph
Copy link
Member

zepumph commented Oct 17, 2019

No description provided.

@zepumph zepumph self-assigned this Oct 17, 2019
@zepumph
Copy link
Member Author

zepumph commented Nov 8, 2019

After some more investigation, it looks like this could benefit from having a dynamic range, just like in phetsims/gravity-force-lab#172.

This is because the range is based on the current zoom (in view coords). I will investigate supporting this and report back.

@zepumph
Copy link
Member Author

zepumph commented Nov 8, 2019

In the above commits I added a range to the targetXProperty. This is dependent on the current transform, and so is set by the view.

In general this is an excellent improvement for studio. Another bonus we got was a behavior change where now the score target won't get "lost" off to the right of the screen when you zoom out, move it far away from the cannon, and then zoom back in. I set it up to clamp back within the draggable area of the score.

@arouinfar would you please review these two pieces.

  1. The behaviour in any brand of the score target and how it stays on the screen always.
  2. In studio, look at scoreTargetXProperty, and how you can move it with the slider now. That is based on its sibling scoretargetXRangeProperty. Does this look as desired in studio? Do you think that scoreTargetXProperty should be phetioFeatures? (I know we haven't had that conversation just yet about that).

Let me know what you think!

@zepumph
Copy link
Member Author

zepumph commented Nov 8, 2019

@zepumph
Copy link
Member Author

zepumph commented Nov 8, 2019

As a note, @samreid, @chrisklus @zepumph all discussed the changes to NumberProperty. We noticed that when updating the rangeProperty, you need to make sure the current value of the Property is within that range otherwise you will error out when changing the range. In PM this meant adding this line before setting the range:

      this.targetXProperty.set( Util.clamp( this.targetXProperty.value, newRange.min, newRange.max ) );

We thought about having an option in NumberProperty, like

        // if false, error out, otherwise, when the range Property changes the value, 
        clampValueOnRangeChange: false

but didn't feel like it was perfectly in line with how axon Propeties tend to work, and fail validation. It felt too graceful. Also, what is the difference between that, and just clamping on setValue also (which it felt clear wasn't a good thing to do)?

No action steps here, just a note of a review discussion.

@zepumph
Copy link
Member Author

zepumph commented Nov 16, 2019

  • Another note, this change is failing fuzzing, especially on the state wrapper, with "value failed isValidValue". It always occurs with both screens at different MVT zooms.
    image

Note it is from the downstream sim.

@arouinfar this issue is still assigned to you to just discuss the last part of #192 (comment).

@arouinfar
Copy link
Contributor

The behaviour in any brand of the score target and how it stays on the screen always.

Behavior's looking great!

In studio, look at scoreTargetXProperty, and how you can move it with the slider now. That is based on its sibling scoretargetXRangeProperty. Does this look as desired in studio? Do you think that scoreTargetXProperty should be phetioFeatures? (I know we haven't had that conversation just yet about that).

I think this is looking good in studio. I would not feature the score.targetXRangeProperty, but I think we would want to feature score.targetXProperty. Since this isn't a common component, my guess is that it's best to defer featuring until overrides, but I'll defer to @zepumph.

@zepumph
Copy link
Member Author

zepumph commented Jan 8, 2020

That sounds like a great plan. I added a checkbox to your comment in #219. Closing

@zepumph zepumph closed this as completed Jan 8, 2020
@zepumph zepumph reopened this Jan 8, 2020
@zepumph
Copy link
Member Author

zepumph commented Jan 8, 2020

Ooops, I still see a checkbox for me to investigate.

@zepumph
Copy link
Member Author

zepumph commented Jan 8, 2020

This is easily reproducible.

  • state wrapper
  • increase the state setting time with ?numberOfMillisecondsBetweenUpdates=4000
  • set the bottom state to be all the way zoomed in and move the target to under the cannon.
  • Then in in between one cycle zoom all the way out and move the target all the way left.

The state wrapper will try to set the NumberProperty before its range has been updated to the new, larger Range, and so it fails out in NumberProperty.assertNumberPropertyValidateValue.

I'm unsure how to handle this. Perhaps I will bring it to the other PhET-iO devs to see.

@zepumph
Copy link
Member Author

zepumph commented Jan 8, 2020

The state setting bug was fixed by treating the range and value of a NumberPropertyIO as one atomic operation during setValue of the state set. This is now fixed and can be closed.

@zepumph zepumph closed this as completed Jan 8, 2020
@zepumph
Copy link
Member Author

zepumph commented Jan 24, 2020

I wonder if work over in phetsims/axon#274 has changed how I should implement this. Perhaps it would be better for this Property to be nested underneath the NumberProperty.

@zepumph
Copy link
Member Author

zepumph commented Feb 27, 2020

The rangeProperty was nested in the above commit. Closing

@zepumph zepumph closed this as completed Feb 27, 2020
@arouinfar
Copy link
Contributor

@zepumph when reviewing the sim in studio for #244, I saw some odd behavior with score.targetXProperty.rangeProperty. Unfortunately, it seems to be inconsistent, and I'm not sure how to reliably reproduce.

Twice now, I've seen the current value of projectileMotion.introScreen.model.score.targetXProperty.rangeProperty show up as [-100, 100], instead of the correct range for the default/current zoom level.

We'd also like to remove the slider from studio interface for score.targetXProperty since it adjusts in finer increments than the target within the sim.

@arouinfar arouinfar reopened this Feb 24, 2021
zepumph added a commit that referenced this issue Apr 21, 2021
@zepumph
Copy link
Member Author

zepumph commented Apr 21, 2021

Good find. Because the range is based on the modelViewTransform (in the view), but is created in the model (before the view is created), we need a bogus initial value to fill the range to start. I made this [-100,100]. This is not ideal, but wasn't buggy expect that I wasn't re-calculating based on the transform on reset.

Above fixes this because it recalculates the range on reset. Please review.

@arouinfar
Copy link
Contributor

I haven't been able to reproduce in master, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants