Skip to content

Commit

Permalink
Converted to use PhetioObject, see phetsims/tandem#46
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Dec 15, 2017
1 parent d6c743c commit 9563d9e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
4 changes: 3 additions & 1 deletion js/singlebulb/model/SingleBulbModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ define( function( require ) {
} );

// @public
this.photonBeam = new SingleBulbPhotonBeam( this, SingleBulbConstants.SINGLE_BEAM_LENGTH, tandem.createTandem( 'photonBeam' ) );
this.photonBeam = new SingleBulbPhotonBeam( this, SingleBulbConstants.SINGLE_BEAM_LENGTH, {
tandem: tandem.createTandem( 'photonBeam' )
} );

var self = this;

Expand Down
22 changes: 13 additions & 9 deletions js/singlebulb/model/SingleBulbPhotonBeam.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ define( function( require ) {
var ColorVisionConstants = require( 'COLOR_VISION/common/ColorVisionConstants' );
var Emitter = require( 'AXON/Emitter' );
var inherit = require( 'PHET_CORE/inherit' );
var PhetioObject = require( 'TANDEM/PhetioObject' );
var SingleBulbConstants = require( 'COLOR_VISION/singlebulb/SingleBulbConstants' );
var SingleBulbPhoton = require( 'COLOR_VISION/singlebulb/model/SingleBulbPhoton' );
var Vector2 = require( 'DOT/Vector2' );
Expand All @@ -28,10 +29,16 @@ define( function( require ) {
/**
* @param {SingleBulbModel} model
* @param {number} beamLength the length of the beam. This is used to determine what location to restart the photons.
* @param {Tandem} tandem
* @param {Object} options - required
* @constructor
*/
function SingleBulbPhotonBeam( model, beamLength, tandem ) {
function SingleBulbPhotonBeam( model, beamLength, options ) {

options = _.extend( {
phetioType: SingleBulbPhotonBeamIO
}, options );

PhetioObject.call( this, options );

// @public
this.photons = [];
Expand All @@ -41,9 +48,7 @@ define( function( require ) {
this.model = model;

// @public
this.photonGroupTandem = tandem.createGroupTandem( 'photons' );

tandem.addInstance( this, { phetioType: SingleBulbPhotonBeamIO } );
this.photonGroupTandem = options.tandem.createGroupTandem( 'photons' );

// @public
this.repaintEmitter = new Emitter();
Expand All @@ -58,7 +63,7 @@ define( function( require ) {
return new Color( r, g, b, 1 );
}

return inherit( Object, SingleBulbPhotonBeam, {
return inherit( PhetioObject, SingleBulbPhotonBeam, {

// @public
updateAnimationFrame: function( dt ) {
Expand Down Expand Up @@ -156,7 +161,7 @@ define( function( require ) {
}
);
blackPhoton.passedFilter = true;
this.photons.push( blackPshoton );
this.photons.push( blackPhoton );
}

// emit a black photon for resetting the perceived color to black if the flashlight is off
Expand Down Expand Up @@ -209,6 +214,5 @@ define( function( require ) {
this.photons[ i ].location.x = 0;
}
}

} );
} );
} );

0 comments on commit 9563d9e

Please sign in to comment.