Skip to content

Commit

Permalink
fixed an issue with the phet-io type of the mass position, see #76
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Nov 29, 2016
1 parent b6544fe commit 7de176f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions js/gravity-force-lab/GravityForceLabConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ define( function( require ) {
// constants
var MIN_MASS = 1; // kg
var MAX_MASS = 1000; // kg
var MAX_DISTANCE_FROM_CENTER = 7.48; // meters, empirically determined boundary for masses

var GravityForceLabConstants = {
MIN_MASS: MIN_MASS,
MAX_MASS: MAX_MASS,
RIGHT_MASS_BOUNDARY: MAX_DISTANCE_FROM_CENTER,
LEFT_MASS_BOUNDARY: -MAX_DISTANCE_FROM_CENTER,
MASS_RANGE: new Range( MIN_MASS, MAX_MASS )
};

Expand Down
5 changes: 3 additions & 2 deletions js/gravity-force-lab/model/GravityForceLabModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define( function( require ) {
// modules
var Color = require( 'SCENERY/util/Color' );
var gravityForceLab = require( 'GRAVITY_FORCE_LAB/gravityForceLab' );
var GravityForceLabConstants = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/GravityForceLabConstants' );
var inherit = require( 'PHET_CORE/inherit' );
var Mass = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/model/Mass' );
var Property = require( 'AXON/Property' );
Expand Down Expand Up @@ -78,8 +79,8 @@ define( function( require ) {
* @public
*/
step: function() {
var minX = LEFT_BOUNDARY + PULL_OBJECT_WIDTH + this.mass1.radiusProperty.get();
var maxX = RIGHT_BOUNDARY - PULL_OBJECT_WIDTH - this.mass2.radiusProperty.get();
var minX = GravityForceLabConstants.LEFT_MASS_BOUNDARY + PULL_OBJECT_WIDTH + this.mass1.radiusProperty.get();
var maxX = GravityForceLabConstants.RIGHT_MASS_BOUNDARY - PULL_OBJECT_WIDTH - this.mass2.radiusProperty.get();
var locationMass1 = this.mass1.positionProperty.get();
var locationMass2 = this.mass2.positionProperty.get();

Expand Down
7 changes: 5 additions & 2 deletions js/gravity-force-lab/model/Mass.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ define( function( require ) {
var GravityForceLabConstants = require( 'GRAVITY_FORCE_LAB/gravity-force-lab/GravityForceLabConstants' );
var inherit = require( 'PHET_CORE/inherit' );
var Property = require( 'AXON/Property' );
var Range = require( 'DOT/Range' );

// phet-io modules
var TColor = require( 'ifphetio!PHET_IO/types/scenery/util/TColor' );
var TNumber = require( 'ifphetio!PHET_IO/types/TNumber' );
var TVector2 = require( 'ifphetio!PHET_IO/types/dot/TVector2' );

// constants
var DENSITY = 150; // kg/m^3
Expand All @@ -46,7 +46,10 @@ define( function( require ) {

this.positionProperty = new Property( initialPosition, {
tandem: tandem.createTandem( 'positionProperty' ),
phetioValueType: TVector2
phetioValueType: TNumber( {
units: 'meters',
range: new Range( GravityForceLabConstants.LEFT_MASS_BOUNDARY, GravityForceLabConstants.RIGHT_MASS_BOUNDARY )
} )
} ); // @public

this.radiusProperty = new DerivedProperty(
Expand Down

0 comments on commit 7de176f

Please sign in to comment.