-
Notifications
You must be signed in to change notification settings - Fork 3
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
generalize LaserPointerNode #2
Comments
In MOTHA, it's implement programmatically in LightNode. In BLL, it's an image file (light.png) used in LightNode. In bending-light, it's 2 image files (laser.png, laser_knob.png), with or without a "knob". The laser has a knob if it's both rotatable and translatable, no knob if it's only rotatable. Very odd, because when a knob is present, the knob is used to do rotation. |
The name LightNode is a bit too generic for this. How about LaserPointerNode? Here's a real laser pointer: @samreid What do you think about the name LaserPointerNode? Or something else? |
Generalization is done. Remaining tasks:
|
LaserPointerNode is the best name I've heard so far, with LaserNode a close second. |
In 29b5edf, I removed the short-circuit of |
LaserPointerNode lives in scenery-phet, and all tasks in #2 (comment) have been completed. LaserPointerNode is now used in beers-law-lab.LightNode, which had been instrumented for PhET-iO. LightNode was not calling Assigning to @samreid to: (1) Verify that it's correct to call (2) Do a general review of LaserPointerNode (which may make sense to do at the same time as phetsims/bending-light#339) |
The formatting is inconsistent here, I'll choose the most prevalent style which appears in 3 of the 4 sites: /**
* Sets the enabled state of the laser's button.
* @param {boolean} value
* @public
*/
setEnabled: function( value ) {
this.button.enabled = value;
},
set enabled( value ) { this.setEnabled( value ); },
/**
* Gets the enabled state of the laser's button.
* @returns {boolean}
* @public
*/
getEnabled: function() {return this.button.enabled; },
get enabled() { return this.getEnabled(); } |
I noticed this line: options.children = [ nozzleNode, bodyNode, this.button ]; This means any children passed in through the options would be overwritten. Two potential solutions to this:
EDIT: I thought there would be a way to visualize multiple checkboxes in an issue, but couldn't find it, so I've removed the comment checkbox. |
I noticed this default: buttonTouchExpansion: 15, But I thought we had decided that common code wouldn't expand touch areas by default? |
We spent time on ProbeNode making sure the light came from the top left no matter how the ProbeNode was oriented, but it looks like the gradients in LaserPointerNode are hard-coded. Should we address this? EDIT: Here's a picture of LaserPointerNode in MOTHA showing the light coming from the bottom left on the button, the left on the laser and the top-left on the control panel: |
Is it redundant to put |
Review summary: LaserPointerNode.js is in good shape. It is well organized and well-commented, nice work! If I have any other suggestions after integrating into bending light, I'll create separate issues. Back to you @pixelzoom. |
One more thought, I saw this code: tandem: options.tandem ? options.tandem.createTandem( 'button' ) : null and realized it is a bit more idiomatic for us to use tandem: options.tandem && options.tandem.createTandem( 'button' ) |
In #2 (comment), @samreid said:
We decided that common-code that was not PhET-specific (sun, scenery, etc.) would not set defaults, but that PhET-specific common-code (eg, scenery-phet) would set defaults that were appropriate for typical PhET uses. LaserPointerNode is in scenery-phet, so it's setting a default that's typically useful for PhET. |
In #2 (comment), @samreid asked:
This is a more general discussion than I'd like to have here. If you want to pursue it, please open a general issue and label for developer-meeting. |
Addressed comment #2 (comment): // add any children specified by the client
options.children = [ nozzleNode, bodyNode, this.button ].concat( options.children || [] ); |
Re #2 (comment), lighting direction... Good point, I'll have a look. @samreid How do you intend to address this in Bending Light, where the laser is dynamically rotated? |
LaserPointerNode added to 'Components' screen of scenery-phet demo application. |
Re lighting cues, there are 2 issues: (1) The button: (2) The body: Back to @samreid for feedback. |
I implemented what I described in #2 (comment) for lighting cues. I needed to add one additional option, All review comments have been addressed. Back to @samreid for review. |
Changes look great, the last thing I would recommend for this file is to document (in the DEFAULT_OPTIONS) for the nozzle if its width is parallel to the laser direction or perpendicular. For someone unfamiliar with the sim, they may think the nozzle width is how wide it is (perpendicular). |
I guess the same argument applies to the laser body itself. The code appears that the width is along the parallel axis, which makes sense for a normal 2d rectangle, but not when referring to the dimensions of a laser pointer. Imagine a laser pointer pointing up like in the MOTHA example above. What would you call the laser pointer Not recommending a specific action at this point, just want to discuss it to understand what's best. |
The JSdoc defines this component's default orientation:
As with any UI component, I would expect the semantics of all options to be relative to the non-transformed orientation. And since we're dealing with the view coordinate frame, I would expect |
Sounds good since developers will have to be familiar with the default orientation. I think we're done here, nice work. |
Thanks for the thorough review! |
It's now used in MOTHA, BLL, bending-light.
The text was updated successfully, but these errors were encountered: