From fb875a86ababdf8ec8fbdc85b8a611e587b1427f Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Thu, 18 Jul 2024 08:47:09 -0600 Subject: [PATCH] Remove materialValidValues, see https://github.com/phetsims/density-buoyancy-common/issues/270 --- .../model/BuoyancyBasicsExploreModel.ts | 11 +------ js/common/model/Mass.ts | 33 ++----------------- 2 files changed, 3 insertions(+), 41 deletions(-) diff --git a/js/buoyancy-basics/model/BuoyancyBasicsExploreModel.ts b/js/buoyancy-basics/model/BuoyancyBasicsExploreModel.ts index 1c0ee7a0..17955592 100644 --- a/js/buoyancy-basics/model/BuoyancyBasicsExploreModel.ts +++ b/js/buoyancy-basics/model/BuoyancyBasicsExploreModel.ts @@ -12,12 +12,11 @@ import Matrix3 from '../../../../dot/js/Matrix3.js'; import Vector2 from '../../../../dot/js/Vector2.js'; import Cube from '../../common/model/Cube.js'; import DensityBuoyancyModel, { DensityBuoyancyModelOptions } from '../../common/model/DensityBuoyancyModel.js'; -import Material, { CustomSolidMaterial } from '../../common/model/Material.js'; +import Material from '../../common/model/Material.js'; import Scale, { DisplayType } from '../../common/model/Scale.js'; import TwoBlockMode from '../../common/model/TwoBlockMode.js'; import densityBuoyancyCommon from '../../densityBuoyancyCommon.js'; import MassTag from '../../common/model/MassTag.js'; -import { Color, ColorProperty } from '../../../../scenery/js/imports.js'; type BuoyancyBasicsExploreModelOptions = DensityBuoyancyModelOptions; @@ -42,10 +41,6 @@ export default class BuoyancyBasicsExploreModel extends DensityBuoyancyModel { this.massA = Cube.createWithMass( this.engine, Material.WOOD, new Vector2( -0.2, 0.2 ), 2, { tag: MassTag.OBJECT_A, adjustableMaterial: true, - materialValidValues: Material.SIMPLE_MASS_MATERIALS.concat( [ new CustomSolidMaterial( blockATandem.createTandem( 'customMaterial' ), { - density: 1000, - colorProperty: new ColorProperty( Color.RED ) - } ) ] ), adjustableColor: false, tandem: blockATandem } ); @@ -55,10 +50,6 @@ export default class BuoyancyBasicsExploreModel extends DensityBuoyancyModel { this.massB = Cube.createWithMass( this.engine, Material.ALUMINUM, new Vector2( 0.05, 0.35 ), 13.5, { tag: MassTag.OBJECT_B, adjustableMaterial: true, - materialValidValues: Material.SIMPLE_MASS_MATERIALS.concat( [ new CustomSolidMaterial( blockBTandem.createTandem( 'customMaterial' ), { - density: 1000, - colorProperty: new ColorProperty( Color.RED ) - } ) ] ), adjustableColor: false, tandem: blockBTandem, visible: false diff --git a/js/common/model/Mass.ts b/js/common/model/Mass.ts index 9a1f5a33..fdec34bb 100644 --- a/js/common/model/Mass.ts +++ b/js/common/model/Mass.ts @@ -20,7 +20,7 @@ import Vector3 from '../../../../dot/js/Vector3.js'; import { Shape } from '../../../../kite/js/imports.js'; import EnumerationIO from '../../../../tandem/js/types/EnumerationIO.js'; import optionize, { combineOptions } from '../../../../phet-core/js/optionize.js'; -import { Color, ColorProperty, GatedVisibleProperty, PDOMValueType } from '../../../../scenery/js/imports.js'; +import { GatedVisibleProperty, PDOMValueType } from '../../../../scenery/js/imports.js'; import PhetioObject, { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js'; import Tandem from '../../../../tandem/js/Tandem.js'; import BooleanIO from '../../../../tandem/js/types/BooleanIO.js'; @@ -77,9 +77,6 @@ type SelfOptions = { volumePropertyOptions?: NumberPropertyOptions; massPropertyOptions?: NumberPropertyOptions; - // Accepted values for the Material Combo Box - materialValidValues?: Material[]; - minVolume?: number; maxVolume?: number; }; @@ -205,32 +202,6 @@ export default abstract class Mass extends PhetioObject { materialPropertyOptions: {}, volumePropertyOptions: {}, massPropertyOptions: {}, - - /* - TODO: Make the default an empty list and move this list to density's mystery screen - // TODO: Should all masses be created with their valid materials immediately? - // TODO: Move the materialValidValues over to the view, and let each materialProperty be able to take on any material. - // TODO: please note `materialPropertyOptions`. https://github.com/phetsims/density-buoyancy-common/issues/270 - */ - materialValidValues: [ - Material.ALUMINUM, - Material.BRICK, - Material.COPPER, - Material.ICE, - Material.PLATINUM, - Material.STEEL, - Material.STYROFOAM, - Material.WOOD, - - // TODO: Visit this tandem after moving elsewhere, see https://github.com/phetsims/density-buoyancy-common/issues/270 - new CustomSolidMaterial( providedOptions.tandem ? - providedOptions.tandem.createTandem( 'customSolidMaterial' ) : - Tandem.OPT_OUT, { - density: 1000, - colorProperty: new ColorProperty( Color.white ) - } ) - ], - minVolume: 0, maxVolume: Number.POSITIVE_INFINITY }, providedOptions ); @@ -274,7 +245,7 @@ export default abstract class Mass extends PhetioObject { this.visibleProperty = new GatedVisibleProperty( this.internalVisibleProperty, tandem ); - this.materialProperty = new MaterialProperty( options.material, tandem => new CustomSolidMaterial( tandem.createTandem( 'customMaterial' ), { + this.materialProperty = new MaterialProperty( options.material, tandem => new CustomSolidMaterial( tandem, { density: options.material.density, // TODO: It is incorrect to take the range of the default value, this affects the color, see https://github.com/phetsims/density-buoyancy-common/issues/268