diff --git a/js/spin/model/ParticleSourceModel.ts b/js/spin/model/ParticleSourceModel.ts index 8ba89a6..cfe2fa6 100644 --- a/js/spin/model/ParticleSourceModel.ts +++ b/js/spin/model/ParticleSourceModel.ts @@ -50,20 +50,19 @@ export default class ParticleSourceModel { this.sourceModeProperty = new Property( SourceMode.SINGLE, { tandem: tandem.createTandem( 'sourceModeProperty' ), phetioValueType: EnumerationIO( SourceMode ), - validValues: SourceMode.enumeration.values + validValues: SourceMode.enumeration.values, + phetioFeatured: true } ); this.isContinuousModeProperty = new DerivedProperty( [ this.sourceModeProperty ], sourceMode => sourceMode === SourceMode.CONTINUOUS ); this.particleAmountProperty = new NumberProperty( 0.1, { tandem: tandem.createTandem( 'particleAmountProperty' ), - range: new Range( 0, 1 ) + range: new Range( 0, 1 ), + phetioFeatured: true } ); - this.positionProperty = new Vector2Property( position, { - tandem: tandem.createTandem( 'positionProperty' ), - phetioReadOnly: true - } ); + this.positionProperty = new Vector2Property( position ); this.exitLocalPosition = new Vector2( 0, 0 ); @@ -75,7 +74,8 @@ export default class ParticleSourceModel { this.spinStateProperty = new Property( initialSpinState, { tandem: tandem.createTandem( 'spinStateProperty' ), phetioValueType: EnumerationIO( SpinDirection ), - validValues: SpinDirection.enumeration.values + validValues: SpinDirection.enumeration.values, + phetioFeatured: true } ); this.customSpinStateProperty = new Vector2Property( SpinDirection.spinToVector( initialSpinState ) ); diff --git a/js/spin/model/SpinModel.ts b/js/spin/model/SpinModel.ts index 08247fa..33bd717 100644 --- a/js/spin/model/SpinModel.ts +++ b/js/spin/model/SpinModel.ts @@ -80,7 +80,8 @@ export default class SpinModel implements TModel { this.currentExperimentProperty = new Property( SpinExperiment.EXPERIMENT_1, { tandem: providedOptions.tandem.createTandem( 'currentExperimentProperty' ), phetioValueType: EnumerationIO( SpinExperiment ), - validValues: SpinExperiment.enumeration.values + validValues: SpinExperiment.enumeration.values, + phetioFeatured: true } ); this.isCustomExperimentProperty = new DerivedProperty( [ this.currentExperimentProperty ], @@ -114,7 +115,7 @@ export default class SpinModel implements TModel { // This is needed for the number sliders to work properly. this.downProbabilityProperty = new NumberProperty( 1 - this.upProbabilityProperty.value ); - const sternGerlachsTandem = providedOptions.tandem.createTandem( 'SternGerlachs' ); + const sternGerlachsTandem = providedOptions.tandem.createTandem( 'sternGerlachs' ); this.sternGerlachs = [ new SternGerlach( new Vector2( 0.8, 0 ), true, sternGerlachsTandem.createTandem( 'firstSternGerlach' ) ), new SternGerlach( new Vector2( 2, 0.3 ), false, sternGerlachsTandem.createTandem( 'secondSternGerlach' ) ), @@ -142,13 +143,6 @@ export default class SpinModel implements TModel { ) ]; - // Find the first inactive single particle and activate it - this.particleSourceModel.currentlyShootingParticlesProperty.link( shooting => { - if ( shooting ) { - this.particleSystem.shootSingleParticle(); - } - } ); - this.expectedPercentageVisibleProperty = new BooleanProperty( false, { tandem: providedOptions.tandem.createTandem( 'expectedPercentageVisibleProperty' ) } ); diff --git a/js/spin/view/ParticleSourceNode.ts b/js/spin/view/ParticleSourceNode.ts index 5e7a850..ed52fd5 100644 --- a/js/spin/view/ParticleSourceNode.ts +++ b/js/spin/view/ParticleSourceNode.ts @@ -7,6 +7,7 @@ * @author Agustín Vallejo */ +import BooleanProperty from '../../../../axon/js/BooleanProperty.js'; import DerivedProperty from '../../../../axon/js/DerivedProperty.js'; import Dimension2 from '../../../../dot/js/Dimension2.js'; import { Shape } from '../../../../kite/js/imports.js'; @@ -21,6 +22,7 @@ import QuantumMeasurementColors from '../../common/QuantumMeasurementColors.js'; import quantumMeasurement from '../../quantumMeasurement.js'; import QuantumMeasurementStrings from '../../QuantumMeasurementStrings.js'; import ParticleSourceModel from '../model/ParticleSourceModel.js'; +import { ParticleSystem } from '../model/ParticleSystem.js'; import { SourceMode } from '../model/SourceMode.js'; import HBarOverTwoNode from './HBarOverTwoNode.js'; @@ -30,6 +32,7 @@ export default class ParticleSourceNode extends Node { public constructor( particleSourceModel: ParticleSourceModel, + particleSystem: ParticleSystem, modelViewTransform: ModelViewTransform2, tandem: Tandem ) { @@ -65,9 +68,11 @@ export default class ParticleSourceNode extends Node { particleSourceBarrel.rotateAround( particleSourceBarrel.center, Math.PI / 4 ); particleSourceBarrel.center.y = particleSourceRectangle.center.y; + const currentlyShootingParticlesProperty = new BooleanProperty( false ); + // Button for 'single' mode const shootParticleButton = new RoundMomentaryButton( - particleSourceModel.currentlyShootingParticlesProperty, false, true, { + currentlyShootingParticlesProperty, false, true, { scale: 0.7, baseColor: QuantumMeasurementColors.downColorProperty, visibleProperty: DerivedProperty.not( particleSourceModel.isContinuousModeProperty ), @@ -75,6 +80,12 @@ export default class ParticleSourceNode extends Node { tandem: tandem.createTandem( 'shootParticleButton' ) } ); + currentlyShootingParticlesProperty.link( shooting => { + if ( shooting ) { + particleSystem.shootSingleParticle(); + } + } ); + // Slider for 'continuous' mode const sliderRange = particleSourceModel.particleAmountProperty.range; const particleAmountSlider = new HSlider( particleSourceModel.particleAmountProperty, sliderRange, { diff --git a/js/spin/view/SpinMeasurementArea.ts b/js/spin/view/SpinMeasurementArea.ts index 1a2a544..1e04562 100644 --- a/js/spin/view/SpinMeasurementArea.ts +++ b/js/spin/view/SpinMeasurementArea.ts @@ -62,7 +62,12 @@ export default class SpinMeasurementArea extends VBox { 180 // empirically determined ); - const particleSourceNode = new ParticleSourceNode( model.particleSourceModel, modelViewTransform, tandem.createTandem( 'particleSourceNode' ) ); + const particleSourceNode = new ParticleSourceNode( + model.particleSourceModel, + model.particleSystem, + modelViewTransform, + tandem.createTandem( 'particleSourceNode' ) + ); const sternGerlachNodes = [ new SternGerlachNode(