Skip to content

Commit

Permalink
Pass model properties instead of model, see #289
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Jan 1, 2019
1 parent 277ef9a commit 139e258
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion js/slits/view/SlitsScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ define( require => {

// When enabled by a query parameter, show the theoretical interference pattern.
if ( WaveInterferenceQueryParameters.theory ) {
this.addChild( new TheoryInterferenceOverlay( model, this.waveAreaNode.bounds, {
this.addChild( new TheoryInterferenceOverlay( model.sceneProperty, model.scenes, this.waveAreaNode.bounds, {
clipArea: Shape.bounds( this.waveAreaNode.bounds )
} ) );
}
Expand Down
13 changes: 7 additions & 6 deletions js/slits/view/TheoryInterferenceOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ define( require => {
class TheoryInterferenceOverlay extends Node {

/**
* @param {SlitsModel} model
* @param {Property.<Scene>} sceneProperty
* @param {Scene[]} scenes
* @param {Bounds2} viewBounds - the area where the lattice appears
* @param {Object} [options]
*/
constructor( model, viewBounds, options ) {
constructor( sceneProperty, scenes, viewBounds, options ) {
super( options );

const updateLines = () => {
this.removeAllChildren();
const barrierType = model.sceneProperty.value.barrierTypeProperty.get();
const barrierType = sceneProperty.value.barrierTypeProperty.get();
if ( barrierType !== BarrierTypeEnum.NO_BARRIER ) {

const scene = model.sceneProperty.value;
const scene = sceneProperty.value;
this.modelViewTransform = ModelViewTransform2.createRectangleMapping( scene.getWaveAreaBounds(), viewBounds );

const barrierY = viewBounds.centerY;
Expand Down Expand Up @@ -113,8 +114,8 @@ define( require => {
}
};

model.sceneProperty.link( updateLines );
model.scenes.forEach( scene => {
sceneProperty.link( updateLines );
scenes.forEach( scene => {

// When any of the relevant physical Properties change, update the lines.
scene.barrierTypeProperty.link( updateLines );
Expand Down

0 comments on commit 139e258

Please sign in to comment.