Skip to content

Commit

Permalink
set state for DiffusionParticle mass, speed, radius, #284
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 16, 2024
1 parent 09833ea commit 833e6ef
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions js/diffusion/model/DiffusionParticleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,30 +159,16 @@ export default class DiffusionParticleSystem extends PhetioObject {
// Update mass and temperature of existing particles. This adjusts speed of the particles.
Multilink.multilink(
[ this.particle1Settings.massProperty, this.particle1Settings.initialTemperatureProperty ],
( mass, initialTemperature ) => {
if ( !isSettingPhetioStateProperty.value ) {
updateMassAndSpeed( mass, initialTemperature, this.particles1 );
}
} );
( mass, initialTemperature ) => updateMassAndSpeed( mass, initialTemperature, this.particles1 ) );
Multilink.multilink(
[ this.particle2Settings.massProperty, this.particle2Settings.initialTemperatureProperty ],
( mass, initialTemperature ) => {
if ( !isSettingPhetioStateProperty.value ) {
updateMassAndSpeed( mass, initialTemperature, this.particles2 );
}
} );
( mass, initialTemperature ) => updateMassAndSpeed( mass, initialTemperature, this.particles2 ) );

// Update radii of existing particles.
this.particle1Settings.radiusProperty.link( radius => {
if ( !isSettingPhetioStateProperty.value ) {
updateRadius( radius, this.particles1, container.leftBounds, isPlayingProperty.value );
}
} );
this.particle2Settings.radiusProperty.link( radius => {
if ( !isSettingPhetioStateProperty.value ) {
updateRadius( radius, this.particles2, container.rightBounds, isPlayingProperty.value );
}
} );
this.particle1Settings.radiusProperty.link( radius =>
updateRadius( radius, this.particles1, container.leftBounds, isPlayingProperty.value ) );
this.particle2Settings.radiusProperty.link( radius =>
updateRadius( radius, this.particles2, container.rightBounds, isPlayingProperty.value ) );
}

public reset(): void {
Expand Down

0 comments on commit 833e6ef

Please sign in to comment.