You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on other issues, I found a section of code in MultipleParticleModel that does some state setting based on an emitter provided by the phetio state engine. It looks like this:
// perform any phet-io-specific state setting actions
Tandem.PHET_IO_ENABLED && phet.phetio.phetioEngine.phetioStateEngine.stateSetEmitter.addListener( () => {
// make sure that we have the right number of scaled (i.e. non-normalized) atoms
const numberOfNormalizedMolecules = this.moleculeDataSet.numberOfMolecules;
const numberOfNonNormalizedMolecules = this.scaledAtoms.length / this.moleculeDataSet.atomsPerMolecule;
if ( numberOfNormalizedMolecules > numberOfNonNormalizedMolecules ) {
this.addAtomsForCurrentSubstance( numberOfNormalizedMolecules - numberOfNonNormalizedMolecules );
}
else if ( numberOfNonNormalizedMolecules > numberOfNormalizedMolecules ) {
_.times( ( numberOfNonNormalizedMolecules - numberOfNormalizedMolecules ) * this.moleculeDataSet.atomsPerMolecule, () => {
this.scaledAtoms.pop();
} );
}
// clear the injection counter - all atoms and molecules should be accounted for at this point
this.numMoleculesQueuedForInjectionProperty.reset();
// synchronize the positions of the scaled atoms to the normalized data set
this.syncAtomPositions();
} );
I think that this was part of an early effort to set state, and existed before the explicit toStateObject and applyState methods existed. It may no longer be necessary, but I'm not sure, and I don't have time to investigate at the moment. This code should either be removed or should be moved into the applyState method.
The text was updated successfully, but these errors were encountered:
I did some experimentation and convinced myself that the code above is needed and can't be deleted. Specifically, thinks would get off in the state wrapper if additional atoms/molecules were injected. So, I moved the code into the applyState method, and it appears to be working well. I tested it through several launches from studio, some focused testing in the state wrapper, and then fuzz testing in the state wrapper.
While working on other issues, I found a section of code in
MultipleParticleModel
that does some state setting based on an emitter provided by the phetio state engine. It looks like this:I think that this was part of an early effort to set state, and existed before the explicit
toStateObject
andapplyState
methods existed. It may no longer be necessary, but I'm not sure, and I don't have time to investigate at the moment. This code should either be removed or should be moved into theapplyState
method.The text was updated successfully, but these errors were encountered: