Skip to content

Commit

Permalink
Remove materialValidValues, see #270
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Jul 18, 2024
1 parent a3c3c1e commit fb875a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 41 deletions.
11 changes: 1 addition & 10 deletions js/buoyancy-basics/model/BuoyancyBasicsExploreModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
} );
Expand All @@ -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
Expand Down
33 changes: 2 additions & 31 deletions js/common/model/Mass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -77,9 +77,6 @@ type SelfOptions = {
volumePropertyOptions?: NumberPropertyOptions;
massPropertyOptions?: NumberPropertyOptions;

// Accepted values for the Material Combo Box
materialValidValues?: Material[];

minVolume?: number;
maxVolume?: number;
};
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fb875a8

Please sign in to comment.