phetsims / buoyancy

"Buoyancy" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
2 stars 2 forks source link

Factor out label code for MassTag #102

Closed zepumph closed 2 months ago

zepumph commented 2 months ago

While working on https://github.com/phetsims/buoyancy/issues/96, I was asked for:

Put the colors on the A and B labels. I know that we discussed changing the colors of that labels, but for now, let's put them the same color that the other screens, blue for B and red for A.

And what I ended up finding was a lot of very connected, hard coded, duplicated, and confusing code that I would like to tease out. Basically the label for the numeric mass of an object, and the label/name for the mass, are kinda overloaded. MassLabelNode is doing both, but really it should just be working for the readout of the mass of the mass. I'd like to make a new type for MassTagView, the quad that provided the label to THREE for the name of the object (A/B/1A...).

Furthermore, there was awkard logic special to if it was primary/secondard vs a custom other tag. This made the color change request really challenging. I'll clean up the code before adding support for any MassTag to have its own custom color.

zepumph commented 2 months ago

Getting pretty close, but not quite there yet:

image

phet.densityBuoyancyCommon.DensityBuoyancyCommonStrings.massLabel["1aStringProperty"].value = '22fdsafdsa2'
zepumph commented 2 months ago

Ok, we are at a good stopping point. Next we can make custom colors for different MassTag. I also feel like we may want to change MassTag to a class instead of an enum for better flexibility.

zepumph commented 2 months ago

Good progress here, but I shelved the changes locally and will need to come back to it.

zepumph commented 2 months ago

Alright. I finally got to a commit point. This means that we now have a new file called MassTag, a new serialization for PhET-iO, and much more flexibility about how to provide the desired color for a mass tag (from the model side. It also meant that the task in https://github.com/phetsims/buoyancy/issues/96 ended up being one line of code, which is definitely a great thing! We also were able to improve the mobius code quite a bit, making it more dynamic, since that is the direction that our code base (and design requests) is heading towards.

Closing