Skip to content

Commit

Permalink
Remove gap from pre-loaded energy chunks, see #178
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisklus committed Feb 25, 2019
1 parent 9b1d347 commit 82cebc5
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions js/systems/model/TeaKettle.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,27 +268,25 @@ define( require => {

if ( energySinceLastChunk >= EFACConstants.ENERGY_PER_CHUNK ) {

// Create a chunk inside the tea kettle (at the water surface).
const initialPosition = new Vector2( this.positionProperty.value.x,
this.positionProperty.value.y + WATER_SURFACE_HEIGHT_OFFSET );

const energyType = phet.joist.random.nextDouble() > 0.2 ? EnergyType.MECHANICAL : EnergyType.THERMAL;
// Create a thermal chunk inside the burner.
const xRange = THERMAL_ENERGY_CHUNK_X_ORIGIN_RANGE;
const initialPosition = new Vector2(
this.positionProperty.value.x + xRange.min + phet.joist.random.nextDouble() * xRange.getLength(),
this.positionProperty.value.y + THERMAL_ENERGY_CHUNK_Y_ORIGIN
);

const newEnergyChunk = new EnergyChunk(
energyType,
const energyChunk = new EnergyChunk(
EnergyType.THERMAL,
initialPosition,
Vector2.ZERO,
this.energyChunksVisibleProperty
);
this.energyChunkList.push( newEnergyChunk );

const travelDistance = newEnergyChunk.positionProperty.get().distance(
this.positionProperty.value.plus( SPOUT_BOTTOM_OFFSET ) );
this.energyChunkList.push( energyChunk );

// create path mover to spout bottom
this.energyChunkMovers.push( new EnergyChunkPathMover( newEnergyChunk,
EnergyChunkPathMover.createPathFromOffsets( this.positionProperty.value, [ SPOUT_BOTTOM_OFFSET ] ),
travelDistance / ENERGY_CHUNK_WATER_TO_SPOUT_TIME ) );
this.energyChunkMovers.push( new EnergyChunkPathMover( energyChunk,
this.createThermalEnergyChunkPath( initialPosition, this.positionProperty.value ),
EFACConstants.ENERGY_CHUNK_VELOCITY
) );

energySinceLastChunk -= EFACConstants.ENERGY_PER_CHUNK;
}
Expand All @@ -300,6 +298,9 @@ define( require => {

// An energy chunk has traversed to the output of this system, or passed the point of moving to the next system.
preloadComplete = true;

// a chunk was recently released from the burner because of preloading, so reset the heat energy level
this.heatEnergyProducedSinceLastChunk = 0;
}
}
}
Expand Down

0 comments on commit 82cebc5

Please sign in to comment.