From b24efea1078963d4c291b23bda685b0993a91cf9 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Mon, 21 Aug 2023 11:53:40 -0600 Subject: [PATCH] just pass in positionProperty, https://github.com/phetsims/build-a-nucleus/issues/149 --- js/chart-intro/view/ChartIntroScreenView.ts | 2 +- js/common/view/BANScreenView.ts | 4 ++-- js/decay/view/DecayScreenView.ts | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/js/chart-intro/view/ChartIntroScreenView.ts b/js/chart-intro/view/ChartIntroScreenView.ts index 2ad0d94..072abe4 100644 --- a/js/chart-intro/view/ChartIntroScreenView.ts +++ b/js/chart-intro/view/ChartIntroScreenView.ts @@ -272,7 +272,7 @@ class ChartIntroScreenView extends BANScreenView { * Returns whether the nucleon is within a rectangular capture radius defined by the left edge of the proton arrow * buttons, the right edge of the neutron arrow buttons, below the periodic table, and above the arrow buttons. */ - protected override isNucleonInCaptureArea( nucleon: Particle, atom: ParticleAtom ): boolean { + protected override isNucleonInCaptureArea( nucleon: Particle ): boolean { const nucleonViewPosition = this.particleTransform.modelToViewPosition( nucleon.positionProperty.value ); return this.protonEnergyLevelNode.boundsProperty.value.dilated( BANConstants.PARTICLE_DIAMETER ).containsPoint( nucleonViewPosition ) || diff --git a/js/common/view/BANScreenView.ts b/js/common/view/BANScreenView.ts index 5c06c6e..9452ce0 100644 --- a/js/common/view/BANScreenView.ts +++ b/js/common/view/BANScreenView.ts @@ -786,7 +786,7 @@ abstract class BANScreenView> const particleCreatorNodeCenter = nucleon.type === ParticleType.PROTON.particleTypeString ? this.protonsCreatorNode.center : this.neutronsCreatorNode.center; - if ( this.isNucleonInCaptureArea( nucleon, atom ) || + if ( this.isNucleonInCaptureArea( nucleon, atom.positionProperty ) || // if removing the nucleon will create a nuclide that does not exist, re-add the nucleon to the atom ( ( this.model.particleAtom.protonCountProperty.value + this.model.particleAtom.neutronCountProperty.value ) !== 0 && @@ -806,7 +806,7 @@ abstract class BANScreenView> * Returns if a nucleon is in the capture area which is in a certain radius around the atom in the Decay Screen, and * the energy level area in the Chart Screen. */ - protected abstract isNucleonInCaptureArea( nucleon: Particle, atom: ParticleAtom ): boolean; + protected abstract isNucleonInCaptureArea( nucleon: Particle, atomPositionProperty: TReadOnlyProperty ): boolean; /** * Add particleView to correct layer. diff --git a/js/decay/view/DecayScreenView.ts b/js/decay/view/DecayScreenView.ts index 01e51f9..83c883b 100644 --- a/js/decay/view/DecayScreenView.ts +++ b/js/decay/view/DecayScreenView.ts @@ -29,6 +29,7 @@ import AlphaParticle from '../../common/model/AlphaParticle.js'; import ReturnButton from '../../../../scenery-phet/js/buttons/ReturnButton.js'; import BANQueryParameters from '../../common/BANQueryParameters.js'; import ShowElectronCloudCheckbox from './ShowElectronCloudCheckbox.js'; +import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js'; // constants const NUCLEON_CAPTURE_RADIUS = 100; @@ -310,8 +311,8 @@ class DecayScreenView extends BANScreenView { /** * Returns whether the nucleon is within the circular capture radius around the atom. */ - protected override isNucleonInCaptureArea( nucleon: Particle, atom: ParticleAtom ): boolean { - return nucleon.positionProperty.value.distance( atom.positionProperty.value ) < NUCLEON_CAPTURE_RADIUS; + protected override isNucleonInCaptureArea( nucleon: Particle, atomPositionProperty: TReadOnlyProperty ): boolean { + return nucleon.positionProperty.value.distance( atomPositionProperty.value ) < NUCLEON_CAPTURE_RADIUS; } protected override reset(): void {