Skip to content

Commit

Permalink
Making PhotonState phet-io stateful, #63
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Dec 4, 2024
1 parent 772e5a2 commit 8416d32
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions js/photons/model/Photon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ export class PhotonState {
public readonly probabilityProperty: NumberProperty;
public readonly polarization: possiblePolarizationResult;

public constructor( polarization: possiblePolarizationResult ) {
this.positionProperty = new Vector2Property( Vector2.ZERO );
this.directionProperty = new Vector2Property( RIGHT );
this.probabilityProperty = new NumberProperty( polarization === 'vertical' ? 1 : 0 );
public constructor( polarization: possiblePolarizationResult, tandem: Tandem ) {
this.positionProperty = new Vector2Property( Vector2.ZERO, {
tandem: tandem.createTandem( 'positionProperty' )
} );
this.directionProperty = new Vector2Property( RIGHT, {
tandem: tandem.createTandem( 'directionProperty' )
} );
this.probabilityProperty = new NumberProperty( polarization === 'vertical' ? 1 : 0, {
tandem: tandem.createTandem( 'probabilityProperty' )
} );
this.polarization = polarization;
}

Expand Down Expand Up @@ -104,8 +110,8 @@ export default class Photon extends PhetioObject {
} );

this.possibleStates = [
new PhotonState( 'vertical' ),
new PhotonState( 'horizontal' )
new PhotonState( 'vertical', tandem.createTandem( 'verticalState' ) ),
new PhotonState( 'horizontal', tandem.createTandem( 'horizontalState' ) )
];

// Entangle the possible states
Expand Down

1 comment on commit 8416d32

@AgustinVallejo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually its #65

Please sign in to comment.