From e39c558536b612994966232b6fa7b47d17a54173 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Wed, 24 Jul 2024 16:29:09 -0600 Subject: [PATCH] expose all densityPropertyOptions via options, https://github.com/phetsims/density-buoyancy-common/issues/273 Signed-off-by: Michael Kauzmann --- js/buoyancy/model/applications/Bottle.ts | 4 ++-- js/common/model/CompareBlockSetModel.ts | 4 +++- js/common/model/Material.ts | 20 ++++++++++---------- js/common/model/Pool.ts | 4 +++- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/js/buoyancy/model/applications/Bottle.ts b/js/buoyancy/model/applications/Bottle.ts index 82632d56..a4d9cf8f 100644 --- a/js/buoyancy/model/applications/Bottle.ts +++ b/js/buoyancy/model/applications/Bottle.ts @@ -212,7 +212,7 @@ export default class Bottle extends ApplicationsMass { customMaterialOptions: { nameProperty: DensityBuoyancyCommonStrings.systemAStringProperty, density: ( BOTTLE_MASS + BOTTLE_INITIAL_INTERIOR_MATERIAL.density * BOTTLE_INITIAL_INTERIOR_VOLUME ) / BOTTLE_VOLUME, - densityRange: new Range( 0, 1000000000 ) + densityPropertyOptions: { range: new Range( 0, 1000000000 ) } }, massShape: MassShape.BLOCK, @@ -230,7 +230,7 @@ export default class Bottle extends ApplicationsMass { const customInsideMaterial = new CustomSolidMaterial( materialInsidePropertyTandem.createTandem( 'customMaterial' ), { density: BOTTLE_INITIAL_INTERIOR_MATERIAL.density, - densityRange: new Range( 50, 20000 ) + densityPropertyOptions: { range: new Range( 50, 20000 ) } } ); this.materialInsideProperty = new MaterialProperty( BOTTLE_INITIAL_INTERIOR_MATERIAL, customInsideMaterial, [ diff --git a/js/common/model/CompareBlockSetModel.ts b/js/common/model/CompareBlockSetModel.ts index 6266769a..7b8c7456 100644 --- a/js/common/model/CompareBlockSetModel.ts +++ b/js/common/model/CompareBlockSetModel.ts @@ -188,7 +188,9 @@ export default class CompareBlockSetModel extends BlockSetModel { cubeData.colorProperty, densityProperty.hasChangedProperty, options.initialMaterials, combineOptions( { customMaterialOptions: { - densityRange: options.sameDensityRange + densityPropertyOptions: { + range: options.sameDensityRange + } } }, getCubeOptions( cubeData.sameDensityCubeOptions ) ) ); diff --git a/js/common/model/Material.ts b/js/common/model/Material.ts index cbeeabf2..61f89d6c 100644 --- a/js/common/model/Material.ts +++ b/js/common/model/Material.ts @@ -19,7 +19,7 @@ import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js'; import TinyProperty from '../../../../axon/js/TinyProperty.js'; import ReadOnlyProperty from '../../../../axon/js/ReadOnlyProperty.js'; import Range from '../../../../dot/js/Range.js'; -import NumberProperty from '../../../../axon/js/NumberProperty.js'; +import NumberProperty, { NumberPropertyOptions } from '../../../../axon/js/NumberProperty.js'; import DerivedProperty from '../../../../axon/js/DerivedProperty.js'; import Tandem from '../../../../tandem/js/Tandem.js'; import PhetioObject, { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js'; @@ -33,7 +33,7 @@ type SelfOptions = { density?: number; // What potential densities can this Material accept? (mostly applies to custom materials) - densityRange?: Range; + densityPropertyOptions?: NumberPropertyOptions; // in SI (Pa * s). For reference a poise is 1e-2 Pa*s, and a centipoise is 1e-3 Pa*s. viscosity?: number; @@ -74,7 +74,13 @@ export default class Material extends PhetioObject implements HasValueProperty { const options = optionize()( { nameProperty: new TinyProperty( 'unknown' ), density: 1, - densityRange: new Range( 0.8, 27000 ), + densityPropertyOptions: { + tandem: tandem.createTandem( 'densityProperty' ), + phetioFeatured: true, + phetioDocumentation: 'Density of the material', + range: new Range( 0.8, 27000 ), + units: 'kg/m^3' + }, viscosity: 1e-3, custom: false, hidden: false, @@ -90,13 +96,7 @@ export default class Material extends PhetioObject implements HasValueProperty { } ); this.nameProperty = options.nameProperty; - this.densityProperty = new NumberProperty( options.density, { - tandem: this.tandem.createTandem( 'densityProperty' ), - phetioFeatured: true, - phetioDocumentation: 'Density of the material', - range: options.densityRange, - units: 'kg/m^3' - } ); + this.densityProperty = new NumberProperty( options.density, options.densityPropertyOptions ); this.viscosity = options.viscosity; this.custom = options.custom; this.hidden = options.hidden; diff --git a/js/common/model/Pool.ts b/js/common/model/Pool.ts index 22da042f..d30698da 100644 --- a/js/common/model/Pool.ts +++ b/js/common/model/Pool.ts @@ -63,7 +63,9 @@ export default class Pool extends Basin { const customFluidMaterial = new CustomLiquidMaterial( fluidMaterialPropertyTandem.createTandem( 'customMaterial' ), { density: Material.WATER.density, - densityRange: DensityBuoyancyCommonConstants.FLUID_DENSITY_RANGE_PER_M3 + densityPropertyOptions: { + range: DensityBuoyancyCommonConstants.FLUID_DENSITY_RANGE_PER_M3 + } } ); const availableMaterials = fluidSelectionType === 'justWater' ? [ Material.WATER ] :