From 139e258d03547a9b819b4016ee2b693fb60aabd5 Mon Sep 17 00:00:00 2001 From: samreid Date: Mon, 31 Dec 2018 20:45:40 -0700 Subject: [PATCH] Pass model properties instead of model, see https://github.com/phetsims/wave-interference/issues/289 --- js/slits/view/SlitsScreenView.js | 2 +- js/slits/view/TheoryInterferenceOverlay.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/js/slits/view/SlitsScreenView.js b/js/slits/view/SlitsScreenView.js index 8c949f53..89d8984b 100644 --- a/js/slits/view/SlitsScreenView.js +++ b/js/slits/view/SlitsScreenView.js @@ -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 ) } ) ); } diff --git a/js/slits/view/TheoryInterferenceOverlay.js b/js/slits/view/TheoryInterferenceOverlay.js index 725d52bd..b90f19d3 100644 --- a/js/slits/view/TheoryInterferenceOverlay.js +++ b/js/slits/view/TheoryInterferenceOverlay.js @@ -26,19 +26,20 @@ define( require => { class TheoryInterferenceOverlay extends Node { /** - * @param {SlitsModel} model + * @param {Property.} 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; @@ -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 );