Skip to content

Commit

Permalink
optimization and bug fix - sensors shouldn't interrogate the model if…
Browse files Browse the repository at this point in the history
… not enabled, see #191
  • Loading branch information
jbphet committed Jan 24, 2019
1 parent 8df95dc commit 99af46a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions js/common/model/TemperatureAndColorSensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ define( function( require ) {

/**
* @public
* @param {number} dt
*/
step: function( dt ) {
var temperatureAndColor = this.model.getTemperatureAndColorAtLocation( this.positionProperty.value );
this.sensedTemperatureProperty.set( temperatureAndColor.temperature );
this.sensedElementColorProperty.set( temperatureAndColor.color );
step: function() {
if ( this.activeProperty.value ) {
var temperatureAndColor = this.model.getTemperatureAndColorAtLocation( this.positionProperty.value );
this.sensedTemperatureProperty.set( temperatureAndColor.temperature );
this.sensedElementColorProperty.set( temperatureAndColor.color );
}
else {
this.sensedTemperatureProperty.set( EFACConstants.ROOM_TEMPERATURE );
this.sensedElementColorProperty.set( EFACConstants.TEMPERATURE_SENSOR_INACTIVE_COLOR );
}
},

/**
Expand Down

0 comments on commit 99af46a

Please sign in to comment.