phetsims / sound-waves

"Sound Waves" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 1 forks source link

Incorporate the code submission #3

Closed samreid closed 1 year ago

samreid commented 1 year ago

@kathy-phet said:

Can you please support Jan and Piet to contribute their HTML code of the Sound simulation?

They have signed the CLA and I received the files via zip file.

samreid commented 1 year ago

In adding the initial submission above, I had to make numerous changes to update the code to work with current master. Not sure everything is working as expected. In particular, I don't hear sound and some things are not draggable.

It seems the files in the zip are timestamped Sept 9 2020, so that may indicate that time gap.

For transparency, here is a patch that "undoes" all the changes I had to apply to get this working in master again. Please note I also applied the code formatter (which is required for linting).

```diff Index: js/SoundStrings.ts =================================================================== diff --git a/js/SoundStrings.ts b/js/SoundStrings.ts deleted file mode 100644 --- a/js/SoundStrings.ts (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ /dev/null (revision eb69a225ca9131538d4695288252930487bf6d1d) @@ -1,104 +0,0 @@ -// Copyright 2022, University of Colorado Boulder - -/** - * Auto-generated from modulify, DO NOT manually modify. - */ -/* eslint-disable */ -import getStringModule from '../../chipper/js/getStringModule.js'; -import LinkableProperty from '../../axon/js/LinkableProperty.js'; -import sound from './sound.js'; - -type StringsType = { - 'sound': { - 'title': string; - 'titleStringProperty': LinkableProperty; - }; - 'singleSource': { - 'title': string; - 'titleStringProperty': LinkableProperty; - 'help': { - 'listener': string; - 'listenerStringProperty': LinkableProperty; - } - }; - 'measure': { - 'title': string; - 'titleStringProperty': LinkableProperty; - 'clearWaves': string; - 'clearWavesStringProperty': LinkableProperty; - 'help': { - 'stick': string; - 'stickStringProperty': LinkableProperty; - 'blueLines': string; - 'blueLinesStringProperty': LinkableProperty; - } - }; - 'twoSource': { - 'title': string; - 'titleStringProperty': LinkableProperty; - 'help': { - 'upperSpeaker': string; - 'upperSpeakerStringProperty': LinkableProperty; - 'listener': string; - 'listenerStringProperty': LinkableProperty; - } - }; - 'reflection': { - 'title': string; - 'titleStringProperty': LinkableProperty; - }; - 'atm': string; - 'atmStringProperty': LinkableProperty; - 'hz': string; - 'hzStringProperty': LinkableProperty; - 'airPressure': { - 'title': string; - 'titleStringProperty': LinkableProperty; - }; - 'audioControlPanel': { - 'title': string; - 'titleStringProperty': LinkableProperty; - 'audioEnabled': string; - 'audioEnabledStringProperty': LinkableProperty; - 'speaker': string; - 'speakerStringProperty': LinkableProperty; - 'listener': string; - 'listenerStringProperty': LinkableProperty; - }; - 'soundModeControlPanel': { - 'title': string; - 'titleStringProperty': LinkableProperty; - 'continuous': string; - 'continuousStringProperty': LinkableProperty; - 'pulse': string; - 'pulseStringProperty': LinkableProperty; - 'firePulse': string; - 'firePulseStringProperty': LinkableProperty; - }; - 'reflectionControlPanel': { - 'positionSlider': string; - 'positionSliderStringProperty': LinkableProperty; - 'rotationSlider': string; - 'rotationSliderStringProperty': LinkableProperty; - }; - 'airDensityControlPanel': { - 'title': string; - 'titleStringProperty': LinkableProperty; - 'removeAir': string; - 'removeAirStringProperty': LinkableProperty; - 'addAir': string; - 'addAirStringProperty': LinkableProperty; - 'reset': string; - 'resetStringProperty': LinkableProperty; - }; - 'amplitude': string; - 'amplitudeStringProperty': LinkableProperty; - 'frequency': string; - 'frequencyStringProperty': LinkableProperty; -}; - -const SoundStrings = getStringModule( 'SOUND' ) as StringsType; - -// sound.register( 'SoundStrings', SoundStrings ); - -export default SoundStrings; Index: js/sound/view/TwoSourceView.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/view/TwoSourceView.js b/js/sound/view/TwoSourceView.js --- a/js/sound/view/TwoSourceView.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/view/TwoSourceView.js (date 1599660663000) @@ -1,5 +1,5 @@ // Copyright 2020, University of Colorado Boulder -/* eslint-disable default-import-match-filename */ // TODO Re-enable + /** * @author Piet Goris * View for the two source screen. @@ -7,7 +7,7 @@ import Bounds2 from '../../../../dot/js/Bounds2.js'; import Vector2 from '../../../../dot/js/Vector2.js'; -import { Image } from '../../../../scenery/js/imports.js'; +import Image from '../../../../scenery/js/nodes/Image.js'; import listenerImage from '../../../images/girl_png.js'; import SoundConstants from '../../common/SoundConstants.js'; import MovableNode from '../../common/view/MovableNode.js'; @@ -17,27 +17,27 @@ import SoundScreenView from './SoundScreenView.js'; class TwoSourceView extends SoundScreenView { - constructor( model ) { + constructor(model) { assert && assert( model instanceof TwoSourceModel, 'invalid model' ); - super( model ); + super(model); // Second speaker const bounds = new Bounds2( model.speaker1Position.x, 0, 1, model.getWaveAreaBounds().height ); - const speaker = new SpeakerNode( model.oscillatorProperty ); - this.speakerNode2 = new MovableNode( model.speaker2PositionProperty, bounds, model.modelViewTransform, speaker ); - speaker.setRightCenter( new Vector2( SoundConstants.SPEAKER_OFFSET, 0 ) ); - this.addChild( this.speakerNode2 ); + const speaker = new SpeakerNode(model.oscillatorProperty); + this.speakerNode2 = new MovableNode(model.speaker2PositionProperty, bounds, model.modelViewTransform, speaker); + speaker.setRightCenter(new Vector2(SoundConstants.SPEAKER_OFFSET, 0)); + this.addChild(this.speakerNode2); // Listener - const child = new Image( listenerImage ); - const listenerBounds = new Bounds2( SoundConstants.LISTENER_BOUNDS_X.min, child.height, SoundConstants.LISTENER_BOUNDS_X.max, model.getWaveAreaBounds().height - child.bottom ); - this.listener = new MovableNode( model.listenerPositionProperty, listenerBounds, model.modelViewTransform, child ); - child.setCenter( new Vector2( 0, 0 ) ); - this.addChild( this.listener ); + const child = new Image(listenerImage); + const listenerBounds = new Bounds2( SoundConstants.LISTENER_BOUNDS_X.min, child.height, SoundConstants.LISTENER_BOUNDS_X.max, model.getWaveAreaBounds().height - child.bottom); + this.listener = new MovableNode(model.listenerPositionProperty, listenerBounds, model.modelViewTransform, child); + child.setCenter(new Vector2(0,0)); + this.addChild(this.listener); - model.speaker2PositionProperty.link( value => { - this.canvasNode.source2PositionY = model.modelToLatticeTransform.modelToViewY( value.y ); - } ); + model.speaker2PositionProperty.link(value => { + this.canvasNode.source2PositionY = model.modelToLatticeTransform.modelToViewY(value.y); + }); } } Index: js/sound/view/SoundScreenView.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/view/SoundScreenView.js b/js/sound/view/SoundScreenView.js --- a/js/sound/view/SoundScreenView.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/view/SoundScreenView.js (date 1599660663000) @@ -10,7 +10,10 @@ import ResetAllButton from '../../../../scenery-phet/js/buttons/ResetAllButton.js'; import GaugeNode from '../../../../scenery-phet/js/GaugeNode.js'; import TimeControlNode from '../../../../scenery-phet/js/TimeControlNode.js'; -import { AlignGroup, Rectangle, Text, Color } from '../../../../scenery/js/imports.js'; +import AlignGroup from '../../../../scenery/js/nodes/AlignGroup.js'; +import Rectangle from '../../../../scenery/js/nodes/Rectangle.js'; +import Text from '../../../../scenery/js/nodes/Text.js'; +import Color from '../../../../scenery/js/util/Color.js'; import soundManager from '../../../../tambo/js/soundManager.js'; import WaveAreaNode from '../../../../wave-interference/js/common/view/WaveAreaNode.js'; import SineWaveGenerator from '../../../../wave-interference/js/waves/view/SineWaveGenerator.js'; @@ -20,7 +23,7 @@ import SoundControlPanel from '../../common/view/SoundControlPanel.js'; import SpeakerNode from '../../common/view/SpeakerNode.js'; import sound from '../../sound.js'; -import SoundStrings from '../../SoundStrings.js'; +import soundStrings from '../../soundStrings.js'; import SoundModel from '../model/SoundModel.js'; // constants @@ -33,16 +36,16 @@ /** * @param {SoundModel} model */ - constructor( model ) { + constructor( model) { assert && assert( model instanceof SoundModel, 'invalid model' ); super(); // @private - shows the background of the wave area for sound view and used for layout this.waveAreaNode = new WaveAreaNode( { - top: SoundConstants.CONTROL_PANEL_MARGIN + WAVE_MARGIN + 15, - centerX: this.layoutBounds.centerX - 142 - } ); + top: SoundConstants.CONTROL_PANEL_MARGIN + WAVE_MARGIN + 15, + centerX: this.layoutBounds.centerX - 142 + } ); this.addChild( this.waveAreaNode ); @@ -50,64 +53,64 @@ this.canvasNode = new LatticeCanvasNode( model.lattice, { baseColor: Color.white, hasReflection: model.hasReflection, - sourcePosition: new Vector2( SoundConstants.SOURCE_POSITION_X, Math.floor( model.modelToLatticeTransform.modelToViewY( model.speaker1Position.y ) ) ), + sourcePosition: new Vector2(SoundConstants.SOURCE_POSITION_X, Math.floor(model.modelToLatticeTransform.modelToViewY( model.speaker1Position.y ))), hasSecondSource: model.hasSecondSource } ); const latticeScale = this.waveAreaNode.width / this.canvasNode.width; this.canvasNode.mutate( { - scale: latticeScale, - center: this.waveAreaNode.center, - visible: true - } ); + scale: latticeScale, + center: this.waveAreaNode.center, + visible: true + } ); - this.addChild( this.canvasNode ); + this.addChild(this.canvasNode); // @private - alligns the control panels - this.contolPanelAlignGroup = new AlignGroup( { + this.contolPanelAlignGroup = new AlignGroup({ matchVertical: false - } ); + }); // @public - control panel resposible for setting the frequency and amplitude - this.controlPanel = new SoundControlPanel( model, this.contolPanelAlignGroup ); + this.controlPanel = new SoundControlPanel(model, this.contolPanelAlignGroup); this.controlPanel.mutate( { right: this.layoutBounds.right - SoundConstants.CONTROL_PANEL_MARGIN, - top: SoundConstants.CONTROL_PANEL_MARGIN + SoundConstants.CONTROL_PANEL_SPACING + top: SoundConstants.CONTROL_PANEL_MARGIN + SoundConstants.CONTROL_PANEL_SPACNG } ); - - this.addChild( this.controlPanel ); + + this.addChild(this.controlPanel); - if ( model.isAudioEnabledProperty ) { + if(model.isAudioEnabledProperty){ // @public - control panel responsible for the audio controls - this.audioControlPanel = new AudioControlPanel( model, this.contolPanelAlignGroup ); + this.audioControlPanel = new AudioControlPanel(model, this.contolPanelAlignGroup); this.audioControlPanel.mutate( { right: this.layoutBounds.right - SoundConstants.CONTROL_PANEL_MARGIN, top: this.controlPanel.bottom + SoundConstants.CONTROL_PANEL_SPACING } ); - - this.addChild( this.audioControlPanel ); + + this.addChild(this.audioControlPanel); // Amplitude of the hearable tone - const soundAmpitudeProperty = new NumberProperty( 0 ); + const soundAmpitudeProperty = new NumberProperty(0); // Update the final amplitude of the sine wave tone const updateSoundAmplitude = () => { - const amplitudeDampening = model.audioControlSettingProperty && model.audioControlSettingProperty.value === SoundModel.AudioControlOptions.LISTENER ? ( SoundConstants.LISTENER_BOUNDS_X.max - model.listenerPositionProperty.value.x ) / ( SoundConstants.LISTENER_BOUNDS_X.max - SoundConstants.LISTENER_BOUNDS_X.min ) : 1; + const amplitudeDampening = model.audioControlSettingProperty && model.audioControlSettingProperty.value === SoundModel.AudioControlOptions.LISTENER ? (SoundConstants.LISTENER_BOUNDS_X.max - model.listenerPositionProperty.value.x) / (SoundConstants.LISTENER_BOUNDS_X.max - SoundConstants.LISTENER_BOUNDS_X.min) : 1; const pressureDampening = model.pressureProperty ? model.pressureProperty.value : 1; - soundAmpitudeProperty.set( model.amplitudeProperty.value / 1.5 * amplitudeDampening * pressureDampening ); + soundAmpitudeProperty.set(model.amplitudeProperty.value / 1.5 * amplitudeDampening * pressureDampening); }; - model.amplitudeProperty.link( updateSoundAmplitude ); + model.amplitudeProperty.link(updateSoundAmplitude); - if ( model.pressureProperty ) { - model.pressureProperty.link( updateSoundAmplitude ); + if(model.pressureProperty){ + model.pressureProperty.link(updateSoundAmplitude); } - if ( model.audioControlSettingProperty ) { - model.audioControlSettingProperty.link( updateSoundAmplitude ); - model.listenerPositionProperty.link( updateSoundAmplitude ); + if(model.audioControlSettingProperty){ + model.audioControlSettingProperty.link(updateSoundAmplitude); + model.listenerPositionProperty.link(updateSoundAmplitude); } const sineWavePlayer = new SineWaveGenerator( @@ -117,7 +120,7 @@ model.isAudioEnabledProperty, model.isRunningProperty ] - } ); + }); // Suppress the tone when another screen is selected soundManager.addSoundGenerator( sineWavePlayer, { @@ -128,51 +131,51 @@ // Passes the bounds of the canvas to the model for use in its modelViewTranforms model.setViewBounds( this.waveAreaNode.bounds ); - if ( model.pressureProperty ) { - const speakerCenter = model.modelViewTransform.modelToViewPosition( model.speaker1Position ); + if(model.pressureProperty){ + const speakerCenter = model.modelViewTransform.modelToViewPosition(model.speaker1Position); const boxSizeX = 150; const boxSizeY = 200; // Pressure box. - const box = new Rectangle( speakerCenter.x - boxSizeX / 2, speakerCenter.y - boxSizeY / 2, boxSizeX, boxSizeY, { + const box = new Rectangle(speakerCenter.x - boxSizeX / 2, speakerCenter.y - boxSizeY / 2, boxSizeX, boxSizeY, { stroke: '#f3d99b', lineWidth: 3 - } ); + }); // Darken the pressure box in low pressures. model.pressureProperty.link( prop => { - box.setFill( new Color( 0, 0, 0, 1 - prop ) ); - } ); + box.setFill(new Color(0,0,0, 1 - prop)); + }); - this.addChild( box ); + this.addChild(box); // Pressure gauge. - const gauge = new GaugeNode( model.pressureProperty, SoundStrings.atm, model.pressureProperty.range ); + const gauge = new GaugeNode(model.pressureProperty, soundStrings.atm, model.pressureProperty.range); gauge.centerX = speakerCenter.x; - gauge.scale( 0.4 ); + gauge.scale(0.4); gauge.bottom = speakerCenter.y - boxSizeY / 2; - const oneText = new Text( '1.0' ); - const zeroText = new Text( '0.0' ); + const oneText = new Text('1.0'); + const zeroText = new Text('0.0'); oneText.centerY = gauge.centerY + GAUGE_SPACING_Y; zeroText.centerY = gauge.centerY + GAUGE_SPACING_Y; oneText.right = gauge.right - GAUGE_SPACING_X; zeroText.left = gauge.left + GAUGE_SPACING_X; - this.addChild( gauge ); + this.addChild(gauge); - this.addChild( oneText ); - this.addChild( zeroText ); + this.addChild(oneText); + this.addChild(zeroText); } // First speaker - this.speakerNode1 = new SpeakerNode( model.oscillatorProperty ); - const viewPosition = model.modelViewTransform.modelToViewPosition( model.speaker1Position ); - viewPosition.setX( viewPosition.x + SoundConstants.SPEAKER_OFFSET ); - this.speakerNode1.setRightCenter( viewPosition ); - this.addChild( this.speakerNode1 ); + this.speakerNode1 = new SpeakerNode(model.oscillatorProperty); + const viewPosition = model.modelViewTransform.modelToViewPosition( model.speaker1Position); + viewPosition.setX(viewPosition.x + SoundConstants.SPEAKER_OFFSET); + this.speakerNode1.setRightCenter(viewPosition); + this.addChild(this.speakerNode1); // Pause/play/step buttons. const timeControlNode = new TimeControlNode( model.isRunningProperty, { @@ -191,7 +194,7 @@ } } ); - this.addChild( timeControlNode ); + this.addChild(timeControlNode); const resetAllButton = new ResetAllButton( { listener: () => { Index: js/sound/view/SingleSourceView.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/view/SingleSourceView.js b/js/sound/view/SingleSourceView.js --- a/js/sound/view/SingleSourceView.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/view/SingleSourceView.js (date 1599660663000) @@ -1,5 +1,5 @@ // Copyright 2020, University of Colorado Boulder -/* eslint-disable default-import-match-filename */ // TODO Re-enable + /** * @author Piet Goris * View for the single source view. @@ -7,7 +7,7 @@ import Bounds2 from '../../../../dot/js/Bounds2.js'; import Vector2 from '../../../../dot/js/Vector2.js'; -import { Image } from '../../../../scenery/js/imports.js'; +import Image from '../../../../scenery/js/nodes/Image.js'; import listenerImage from '../../../images/girl_png.js'; import SoundConstants from '../../common/SoundConstants.js'; import MovableNode from '../../common/view/MovableNode.js'; @@ -16,16 +16,16 @@ import SoundScreenView from './SoundScreenView.js'; class SingleSourceView extends SoundScreenView { - constructor( model ) { + constructor(model) { assert && assert( model instanceof SingleSourceModel, 'invalid model' ); - super( model ); + super(model); // Listener const bounds = new Bounds2( SoundConstants.LISTENER_BOUNDS_X.min, model.listenerPositionProperty.value.y, SoundConstants.LISTENER_BOUNDS_X.max, 1 ); - const child = new Image( listenerImage ); - const listener = new MovableNode( model.listenerPositionProperty, bounds, model.modelViewTransform, child ); - child.setCenter( new Vector2( 0, 0 ) ); - this.addChild( listener ); + const child = new Image(listenerImage); + const listener = new MovableNode(model.listenerPositionProperty, bounds, model.modelViewTransform, child); + child.setCenter(new Vector2(0,0)); + this.addChild(listener); } } Index: js/sound/view/ReflectionView.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/view/ReflectionView.js b/js/sound/view/ReflectionView.js --- a/js/sound/view/ReflectionView.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/view/ReflectionView.js (date 1599660663000) @@ -5,65 +5,66 @@ * View for the reflection screen. */ -import { Shape } from '../../../../kite/js/imports.js'; -import { Node, Rectangle } from '../../../../scenery/js/imports.js'; +import Shape from '../../../../kite/js/Shape.js'; +import Node from '../../../../scenery/js/nodes/Node.js'; +import Rectangle from '../../../../scenery/js/nodes/Rectangle.js'; import SoundConstants from '../../common/SoundConstants.js'; import ReflectionControlPanel from '../../common/view/ReflectionControlPanel.js'; import SoundModeControlPanel from '../../common/view/SoundModeControlPanel.js'; import sound from '../../sound.js'; -import SingleSourceModel from '../model/SingleSourceModel.js'; +import ReflectionModel from '../model/SingleSourceModel.js'; import SoundScreenView from './SoundScreenView.js'; class ReflectionView extends SoundScreenView { - constructor( model ) { - assert && assert( model instanceof SingleSourceModel, 'invalid model' ); - super( model ); + constructor(model) { + assert && assert( model instanceof ReflectionModel, 'invalid model' ); + super(model); // @private - control panel for the angle and position of the reflection wall - this.reflectionControlPanel = new ReflectionControlPanel( model, this.contolPanelAlignGroup ); + this.reflectionControlPanel = new ReflectionControlPanel(model, this.contolPanelAlignGroup); // @private - control panel for controlling wether the speaker emits waves continuously or pulses - this.soundModeControlPanel = new SoundModeControlPanel( model, this.contolPanelAlignGroup ); + this.soundModeControlPanel = new SoundModeControlPanel(model, this.contolPanelAlignGroup); // @private - rectangle representing the reflection wall - this.reflector = new Rectangle( 0, 0, SoundConstants.WAVE_AREA_WIDTH * 2, 4, { + this.reflector = new Rectangle(0, 0, SoundConstants.WAVE_AREA_WIDTH * 2, 4, { fill: '#f3d99b', stroke: 'black', lineWidth: 1 - } ); + }); - this.reflector.setY( model.modelViewTransform.modelToViewY( SoundConstants.WAVE_AREA_WIDTH ) ); + this.reflector.setY(model.modelViewTransform.modelToViewY(SoundConstants.WAVE_AREA_WIDTH)); model.wallAngleProperty.link( prop => { - this.reflector.setRotation( -prop ); - this.canvasNode.setWallAngle( prop ); - } ); + this.reflector.setRotation(-prop); + this.canvasNode.setWallAngle(prop); + }); // @private - container for the reflector, needed for rotation this.reflectorContainer = new Node(); - this.reflectorContainer.addChild( this.reflector ); - this.reflectorContainer.setClipArea( Shape.rect( model.modelViewTransform.modelToViewX( 0 ), model.modelViewTransform.modelToViewY( 0 ), model.modelViewTransform.modelToViewDeltaX( SoundConstants.WAVE_AREA_WIDTH ), model.modelViewTransform.modelToViewDeltaY( SoundConstants.WAVE_AREA_WIDTH ) ) ); + this.reflectorContainer.addChild(this.reflector); + this.reflectorContainer.setClipArea(Shape.rect(model.modelViewTransform.modelToViewX(0), model.modelViewTransform.modelToViewY(0), model.modelViewTransform.modelToViewDeltaX(SoundConstants.WAVE_AREA_WIDTH), model.modelViewTransform.modelToViewDeltaY(SoundConstants.WAVE_AREA_WIDTH))); model.wallPositionXProperty.link( prop => { - this.reflector.setX( model.modelViewTransform.modelToViewX( prop ) ); - this.canvasNode.setWallPositionX( model.modelToLatticeTransform.modelToViewX( prop ) ); - } ); + this.reflector.setX(model.modelViewTransform.modelToViewX(prop)); + this.canvasNode.setWallPositionX(model.modelToLatticeTransform.modelToViewX(prop)); + }); - this.addChild( this.reflectorContainer ); + this.addChild(this.reflectorContainer); - this.reflectionControlPanel.mutate( { + this.reflectionControlPanel.mutate( { right: this.layoutBounds.right - SoundConstants.CONTROL_PANEL_MARGIN, top: this.controlPanel.bottom + SoundConstants.CONTROL_PANEL_SPACING } ); - this.addChild( this.reflectionControlPanel ); + this.addChild(this.reflectionControlPanel); this.soundModeControlPanel.mutate( { - right: this.layoutBounds.right - SoundConstants.CONTROL_PANEL_MARGIN, - top: this.reflectionControlPanel.bottom + SoundConstants.CONTROL_PANEL_SPACING - } ); - - this.addChild( this.soundModeControlPanel ); + right: this.layoutBounds.right - SoundConstants.CONTROL_PANEL_MARGIN, + top: this.reflectionControlPanel.bottom + SoundConstants.CONTROL_PANEL_SPACING + }); + + this.addChild(this.soundModeControlPanel); } } Index: js/sound/view/PressureView.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/view/PressureView.js b/js/sound/view/PressureView.js --- a/js/sound/view/PressureView.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/view/PressureView.js (date 1599660663000) @@ -1,11 +1,11 @@ // Copyright 2020, University of Colorado Boulder -/* eslint-disable default-import-match-filename */ // TODO Re-enable + /** * @author Piet Goris * View for the pressure screen. */ -import { Image } from '../../../../scenery/js/imports.js'; +import Image from '../../../../scenery/js/nodes/Image.js'; import listenerImage from '../../../images/girl_png.js'; import SoundConstants from '../../common/SoundConstants.js'; import AirDensityControlPanel from '../../common/view/AirDensityControlPanel.js'; @@ -14,25 +14,25 @@ import SoundScreenView from './SoundScreenView.js'; class PressureView extends SoundScreenView { - constructor( model ) { + constructor(model) { assert && assert( model instanceof PressureModel, 'invalid model' ); - super( model ); + super(model); - const center = model.modelViewTransform.modelToViewPosition( model.listenerPositionProperty.value ); + const center = model.modelViewTransform.modelToViewPosition(model.listenerPositionProperty.value); // @private - listener node - this.listener = new Image( listenerImage ); - this.listener.setCenter( center ); - this.addChild( this.listener ); - + this.listener = new Image(listenerImage); + this.listener.setCenter(center); + this.addChild(this.listener); + // @private - control panel for the air density in the box - this.pressureControlPanel = new AirDensityControlPanel( model, this.contolPanelAlignGroup ); - + this.pressureControlPanel = new AirDensityControlPanel(model, this.contolPanelAlignGroup); + this.pressureControlPanel.mutate( { right: this.layoutBounds.right - SoundConstants.CONTROL_PANEL_MARGIN, top: this.audioControlPanel.bottom + SoundConstants.CONTROL_PANEL_SPACING } ); - - this.addChild( this.pressureControlPanel ); + + this.addChild(this.pressureControlPanel); } } Index: js/sound/view/MeasureView.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/view/MeasureView.js b/js/sound/view/MeasureView.js --- a/js/sound/view/MeasureView.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/view/MeasureView.js (date 1599660663000) @@ -1,5 +1,5 @@ // Copyright 2020, University of Colorado Boulder -/* eslint-disable default-import-match-filename */ // TODO Re-enable + /** * @author Piet Goris * View for the measure screen. @@ -19,9 +19,9 @@ import SoundScreenView from './SoundScreenView.js'; class MeasureView extends SoundScreenView { - constructor( model ) { + constructor(model) { assert && assert( model instanceof MeasureModel, 'invalid model' ); - super( model ); + super(model); const rulerLength = model.modelViewTransform.modelToViewDeltaX( 500 ); const majorTickMarkWidth = rulerLength / ( 10 ); @@ -40,37 +40,37 @@ soundManager.addSoundGenerator( releaseSound, { categoryName: 'user-interface' } ); // Ruler - const rulerNode = new RulerNode( rulerLength, 50, majorTickMarkWidth, majorTickLabels, 'meter', { + const rulerNode = new RulerNode(rulerLength, 50, majorTickMarkWidth, majorTickLabels, 'meter', { minorTicksPerMajorTick: 4, insetsWidth: 60, unitsMajorTickIndex: 10, unitsSpacing: 8 - } ); - const movableRuler = new MovableNode( model.rulerPositionProperty, this.visibleBoundsProperty.value, ModelViewTransform2.createOffsetScaleMapping( new Vector2( 0, 0 ), 1 ), rulerNode ); - this.addChild( movableRuler ); + }); + const movableRuler = new MovableNode(model.rulerPositionProperty, this.visibleBoundsProperty.value, ModelViewTransform2.createOffsetScaleMapping( new Vector2( 0, 0 ), 1 ), rulerNode); + this.addChild(movableRuler); // Stopwatch - const createFormatter = units => StopwatchNode.createRichTextNumberFormatter( { + const createFormatter = units => StopwatchNode.getRichNumberFormatter( { showAsDecimal: true, units: units - } ); + }); const stopwatchNode = new StopwatchNode( model.stopwatch, { - visibleBoundsProperty: this.visibleBoundsProperty, - numberDisplayOptions: { - numberFormatter: createFormatter( 'ms' ) - }, - dragListenerOptions: { - start: () => { - grabSound.play(); - }, - end: () => { - releaseSound.play(); - } - } - } ); + visibleBoundsProperty: this.visibleBoundsProperty, + numberDisplayOptions: { + numberFormatter: createFormatter( 'ms' ) + }, + dragListenerOptions: { + start: () => { + grabSound.play(); + }, + end: () => { + releaseSound.play(); + } + } + } ); - this.addChild( stopwatchNode ); + this.addChild(stopwatchNode); } } Index: package.json IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/package.json b/package.json --- a/package.json (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/package.json (date 1599660663000) @@ -21,6 +21,6 @@ ] }, "eslintConfig": { - "extends": "../chipper/eslint/sim_eslintrc.js" + "extends": "../chipper/eslint/sim_es6_eslintrc.js" } } \ No newline at end of file Index: js/sound/SoundScreen.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/SoundScreen.js b/js/sound/SoundScreen.js --- a/js/sound/SoundScreen.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/SoundScreen.js (date 1599660663000) @@ -6,23 +6,22 @@ */ import Dimension2 from '../../../dot/js/Dimension2.js'; -import StringProperty from '../../../axon/js/StringProperty.js'; import Screen from '../../../joist/js/Screen.js'; import ScreenIcon from '../../../joist/js/ScreenIcon.js'; import SoundColors from '../common/SoundColors.js'; import sound from '../sound.js'; class SoundScreen extends Screen { - constructor( title, createModel, createView, iconImage ) { + constructor(title, createModel, createView, iconImage) { const options = { backgroundColorProperty: SoundColors.SCREEN_VIEW_BACKGROUND, - name: new StringProperty( title ), - homeScreenIcon: new ScreenIcon( iconImage, { - size: new Dimension2( Screen.MINIMUM_HOME_SCREEN_ICON_SIZE.width, Screen.MINIMUM_HOME_SCREEN_ICON_SIZE.height ), + name: title, + homeScreenIcon: new ScreenIcon(iconImage, { + size: new Dimension2(Screen.MINIMUM_HOME_SCREEN_ICON_SIZE.width, Screen.MINIMUM_HOME_SCREEN_ICON_SIZE.height), maxIconWidthProportion: 1, maxIconHeightProportion: 1 - } ), + }), showPlaySoundControl: true, audioEnabled: true }; Index: js/sound/model/TwoSourceModel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/model/TwoSourceModel.js b/js/sound/model/TwoSourceModel.js --- a/js/sound/model/TwoSourceModel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/model/TwoSourceModel.js (date 1599660663000) @@ -14,20 +14,20 @@ class TwoSourceModel extends SoundModel { constructor() { - super( { - speaker1PositionY: 1 / 3 * SoundConstants.WAVE_AREA_WIDTH, + super({ + speaker1PositionY: 1/3 * SoundConstants.WAVE_AREA_WIDTH, hasSecondSource: true - } ); + }); // @public - whether audio is enabled this.isAudioEnabledProperty = new BooleanProperty( false ); // @public - position of the listener - this.listenerPositionProperty = new Vector2Property( new Vector2( 1 / 2 * SoundConstants.WAVE_AREA_WIDTH, 1 / 2 * SoundConstants.WAVE_AREA_WIDTH ) ); + this.listenerPositionProperty = new Vector2Property(new Vector2( 1/2 * SoundConstants.WAVE_AREA_WIDTH, 1/2 * SoundConstants.WAVE_AREA_WIDTH)); // @public - position of the second speaker - this.speaker2PositionProperty = new Vector2Property( new Vector2( this.modelToLatticeTransform.viewToModelX( SoundConstants.SOURCE_POSITION_X ), 2 / 3 * SoundConstants.WAVE_AREA_WIDTH ) ); + this.speaker2PositionProperty = new Vector2Property(new Vector2(this.modelToLatticeTransform.viewToModelX(SoundConstants.SOURCE_POSITION_X), 2/3 * SoundConstants.WAVE_AREA_WIDTH)); } /** @@ -35,11 +35,11 @@ * @public */ reset() { - super.reset(); + super.reset(); - this.isAudioEnabledProperty.reset(); - this.listenerPositionProperty.reset(); - this.speaker2PositionProperty.reset(); + this.isAudioEnabledProperty.reset(); + this.listenerPositionProperty.reset(); + this.speaker2PositionProperty.reset(); } } Index: sound_en.html IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/sound_en.html b/sound_en.html --- a/sound_en.html (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/sound_en.html (date 1599660663000) @@ -33,8 +33,8 @@ }, "phet": { "requirejsNamespace": "SOUND", - "supportsSound": true, "simulation": true, + "supportsSound": true, "runnable": true, "readmeCreatedManually": true, "supportedBrands": [ @@ -67,10 +67,6 @@ { "repo": "tambo", "requirejsNamespace": "TAMBO" - }, - { - "repo": "twixt", - "requirejsNamespace": "TWIXT" } ]; @@ -80,13 +76,13 @@ // Preloads, with more included for phet-io brand let preloads = [ + '../sherpa/lib/mdn-array-from-polyfill.js', + '../sherpa/lib/es6-promise-1e68dc.auto.min.js', '../joist/js/splash.js', '../sherpa/lib/jquery-2.1.0.js', '../sherpa/lib/lodash-4.17.4.js', '../sherpa/lib/FileSaver-b8054a2.js', - '../sherpa/lib/himalaya-1.1.0.js', - '../sherpa/lib/linebreak-1.1.0.js', - '../sherpa/lib/flatqueue-1.2.1.js', + '../sherpa/lib/himalaya-0.2.7.js', '../sherpa/lib/he-1.1.1.js', '../assert/js/assert.js', '../query-string-machine/js/QueryStringMachine.js', @@ -95,14 +91,13 @@ '../sherpa/lib/base64-js-1.2.0.js', '../sherpa/lib/TextEncoderLite-3c9f6f0.js', '../tandem/js/PhetioIDUtils.js', - '../perennial-alias/js/common/SimVersion.js' + '../chipper/js/SimVersion.js' ]; if ( brand === 'phet-io' ) { preloads = preloads.concat( [ - '../chipper/js/phet-io/phetioCompareAPIs.js', '../phet-io/js/phet-io-initialize-globals.js', - '../sound/js/sound-phet-io-overrides.js' + '../sound/js/phet-io/sound-overrides.js' ] ); } @@ -115,7 +110,6 @@ script.type = type; script.src = preloadURL; script.async = false; - script.setAttribute( 'crossorigin', 'use-credentials' ); document.head.appendChild( script ); }; @@ -127,7 +121,7 @@ // Module loading in compilation-free (development) mode will be kicked off once strings are loaded. // This is done in load-unbuilt-strings.js - window.phet.chipper.loadModules = () => loadURL( '../chipper/dist/js/sound/js/sound-main.js', 'module' ); + window.phet.chipper.loadModules = () => loadURL( 'js/sound-main.js', 'module' ); \ No newline at end of file Index: js/sound/model/SoundModel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/model/SoundModel.js b/js/sound/model/SoundModel.js --- a/js/sound/model/SoundModel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/model/SoundModel.js (date 1599660663000) @@ -11,6 +11,7 @@ import Range from '../../../../dot/js/Range.js'; import Rectangle from '../../../../dot/js/Rectangle.js'; import Vector2 from '../../../../dot/js/Vector2.js'; +import Enumeration from '../../../../phet-core/js/Enumeration.js'; import EventTimer from '../../../../phet-core/js/EventTimer.js'; import merge from '../../../../phet-core/js/merge.js'; import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js'; @@ -24,30 +25,30 @@ // platforms. Here we define the frequency of events in Hz, which has been tuned so that our slowest platform has // an acceptable frame rate const eventTimerPeriod = 1 / SoundConstants.EVENT_RATE; -const frequencyRange = new Range( 0, 1 ); +const frequencyRange = new Range(0, 1); const INITIAL_FREQUENCY = 0.5; class SoundModel { - constructor( config ) { + constructor(config) { config = merge( - { + { initialAmplitude: 5, speaker1PositionY: SoundConstants.WAVE_AREA_WIDTH / 2, hasReflection: false, hasSecondSource: false - }, config ); + }, config); // @public - whether this model has a second source. this.hasSecondSource = config.hasSecondSource; // @public - whether this model has a reflection wall. this.hasReflection = config.hasReflection; - + // @public - propery that shows if the simulation in running. this.isRunningProperty = new BooleanProperty( true ); // @public - propery that shows that a pulse is firing. - this.isPulseFiringProperty = new BooleanProperty( false ); + this.isPulseFiringProperty = new BooleanProperty(false); // @public - phase of the sound wave. this.phase = 0; @@ -56,7 +57,7 @@ this.stepIndex = 0; // @private - this.temporalMask = new TemporalMask( this.wallPositionXProperty, this.wallAngleProperty ); + this.temporalMask = new TemporalMask(this.wallPositionXProperty, this.wallAngleProperty); // @public (read-only) - the value of the wave at the oscillation point this.oscillatorProperty = new NumberProperty( 0 ); @@ -103,7 +104,7 @@ this.frequencyProperty.lazyLink( phaseUpdate ); // @public - controls the amplitude of the wave. - this.amplitudeProperty = new NumberProperty( config.initialAmplitude, { + this.amplitudeProperty = new NumberProperty( config.initialAmplitude , { range: SoundConstants.AMPLITUDE_RANGE } ); @@ -127,7 +128,7 @@ this.latticeToViewTransform = null; // @public (read-only) - position of the non-moving first speaker. - this.speaker1Position = new Vector2( this.modelToLatticeTransform.viewToModelX( SoundConstants.SOURCE_POSITION_X ), config.speaker1PositionY ); + this.speaker1Position = new Vector2(this.modelToLatticeTransform.viewToModelX(SoundConstants.SOURCE_POSITION_X), config.speaker1PositionY); } /** @@ -150,7 +151,7 @@ this.latticeToViewTransform = ModelViewTransform2.createRectangleMapping( latticeBounds, tempViewBounds ); } - /** +/** * Returns a Bounds2 for the visible part of the wave area, in the coordinates of the scene. * @returns {Bounds2} the lattice model bounds, in the coordinates of this scene. * @public @@ -158,8 +159,7 @@ getWaveAreaBounds() { return new Bounds2( 0, 0, SoundConstants.WAVE_AREA_WIDTH, SoundConstants.WAVE_AREA_WIDTH ); } - - /** +/** * Generate a wave from the point sources * @private */ @@ -198,13 +198,13 @@ WaveInterferenceConstants.AMPLITUDE_CALIBRATION_SCALE * dampingByPressure; // Point source - if ( isContinuous || this.isPulseFiringProperty.get() ) { + if ( isContinuous|| this.isPulseFiringProperty.get() ) { - const j = Math.floor( this.modelToLatticeTransform.modelToViewY( this.speaker1Position.y ) ); + const j = Math.floor(this.modelToLatticeTransform.modelToViewY( this.speaker1Position.y )); this.lattice.setCurrentValue( SoundConstants.SOURCE_POSITION_X, j, waveValue ); this.oscillatorProperty.value = waveValue; - if ( amplitude > 0 && frequency > 0 ) { - this.temporalMask.set( true, this.stepIndex, j ); + if ( amplitude > 0 && frequency > 0) { + this.temporalMask.set( true, this.stepIndex, j ); temporalMaskEmpty = false; } } @@ -212,7 +212,7 @@ temporalMaskEmpty && this.temporalMask.set( false, this.stepIndex, 0 ); } - + /** * The user has initiated a single pulse. * @public @@ -285,9 +285,9 @@ for ( let i = 0; i < this.lattice.width; i++ ) { for ( let j = 0; j < this.lattice.height; j++ ) { - const distanceWithinBounds = this.temporalMask.matches( SoundConstants.SOURCE_POSITION_X, i, j, this.stepIndex ) >= 0; + const distanceWithinBounds = this.temporalMask.matches(SoundConstants.SOURCE_POSITION_X, i, j, this.stepIndex ) >= 0; - this.lattice.setAllowed( i, j, distanceWithinBounds ); + this.lattice.setAllowed(i, j, distanceWithinBounds ); } } @@ -302,13 +302,13 @@ * @param {boolean} manualStep - true if the step button is being pressed * @public */ - advanceTime( dt, manualStep ) { + advanceTime(dt, manualStep ) { if ( this.isRunningProperty.get() || manualStep ) { // Correction constant taken from wave-interference const correction = 2.4187847116091334 * SoundConstants.WAVE_AREA_WIDTH / 500; - if ( this.stopwatch ) { - this.stopwatch.step( dt * correction ); + if(this.stopwatch){ + this.stopwatch.step( dt * correction); } this.lattice.interpolationRatio = this.eventTimer.getRatio(); @@ -335,18 +335,13 @@ * Audio Control can either be set to SPEAKER or LISTENER * @public */ -SoundModel.AudioControlOptions = [ 'SPEAKER', 'LISTENER' ]; -SoundModel.AudioControlOptions.SPEAKER = 'SPEAKER'; -SoundModel.AudioControlOptions.LISTENER = 'LISTENER'; +SoundModel.AudioControlOptions = Enumeration.byKeys( [ 'SPEAKER', 'LISTENER' ] ); /** * Sound Mode can either be set to CONTINUOUS or PULSE * @public */ -// TODO: Enumeration -SoundModel.SoundModeOptions = [ 'CONTINUOUS', 'PULSE' ]; -SoundModel.SoundModeOptions.CONTINUOUS = 'CONTINUOUS'; -SoundModel.SoundModeOptions.PULSE = 'PULSE'; +SoundModel.SoundModeOptions = Enumeration.byKeys( [ 'CONTINUOUS', 'PULSE' ] ); sound.register( 'SoundModel', SoundModel ); export default SoundModel; \ No newline at end of file Index: js/sound/model/SingleSourceModel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/model/SingleSourceModel.js b/js/sound/model/SingleSourceModel.js --- a/js/sound/model/SingleSourceModel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/model/SingleSourceModel.js (date 1599660663000) @@ -23,10 +23,10 @@ // @public - indicates the user selection for the audio control setting this.audioControlSettingProperty = new Property( SoundModel.AudioControlOptions.SPEAKER, { validValues: SoundModel.AudioControlOptions.VALUES - } ); + }); // @public - position of the listener - this.listenerPositionProperty = new Vector2Property( new Vector2( 1 / 2 * SoundConstants.WAVE_AREA_WIDTH, SoundConstants.WAVE_AREA_WIDTH / 2 ) ); + this.listenerPositionProperty = new Vector2Property(new Vector2(1/2 * SoundConstants.WAVE_AREA_WIDTH, SoundConstants.WAVE_AREA_WIDTH / 2)); } Index: js/sound/model/ReflectionModel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/model/ReflectionModel.js b/js/sound/model/ReflectionModel.js --- a/js/sound/model/ReflectionModel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/model/ReflectionModel.js (date 1599660663000) @@ -14,24 +14,24 @@ class ReflectionModel extends SoundModel { constructor() { - super( { + super({ hasReflection: true - } ); + }); // @public - x coordinate of the wall origin position - this.wallPositionXProperty = new NumberProperty( 1 / 3 * SoundConstants.WAVE_AREA_WIDTH, { - range: new Range( 1 / 3 * SoundConstants.WAVE_AREA_WIDTH, 2 / 3 * SoundConstants.WAVE_AREA_WIDTH ) - } ); + this.wallPositionXProperty = new NumberProperty(1 / 3 * SoundConstants.WAVE_AREA_WIDTH, { + range: new Range( 1 / 3 * SoundConstants.WAVE_AREA_WIDTH, 2/3 * SoundConstants.WAVE_AREA_WIDTH ) + }); // @public - angle of the wall in radians - this.wallAngleProperty = new NumberProperty( Math.PI / 4, { - range: new Range( 1 / 10 * Math.PI, 1 / 2 * Math.PI ) - } ); + this.wallAngleProperty = new NumberProperty(Math.PI / 4, { + range: new Range( 1 / 10 * Math.PI, 1/2 * Math.PI ) + }); // @public - indicates the user selection for the sound mode control setting this.soundModeProperty = new Property( SoundModel.SoundModeOptions.CONTINUOUS, { validValues: SoundModel.SoundModeOptions.VALUES - } ); + }); } /** Index: js/sound/model/PressureModel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/model/PressureModel.js b/js/sound/model/PressureModel.js --- a/js/sound/model/PressureModel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/model/PressureModel.js (date 1599660663000) @@ -30,10 +30,10 @@ // @public - indicates the user selection for the audio control setting this.audioControlSettingProperty = new Property( SoundModel.AudioControlOptions.SPEAKER, { validValues: SoundModel.AudioControlOptions.VALUES - } ); + }); // @public - position of the listener - this.listenerPositionProperty = new Vector2Property( new Vector2( SoundConstants.WAVE_AREA_WIDTH / 2, SoundConstants.WAVE_AREA_WIDTH / 2 ) ); + this.listenerPositionProperty = new Vector2Property(new Vector2(SoundConstants.WAVE_AREA_WIDTH / 2, SoundConstants.WAVE_AREA_WIDTH / 2)); } Index: js/sound/model/MeasureModel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound/model/MeasureModel.js b/js/sound/model/MeasureModel.js --- a/js/sound/model/MeasureModel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound/model/MeasureModel.js (date 1599660663000) @@ -14,21 +14,21 @@ class MeasureModel extends SoundModel { constructor() { - super( { + super({ initialAmplitude: 10 - } ); + }); // @public {Stopwatch} this.stopwatch = new Stopwatch( { - position: new Vector2( 450, 50 ), + position: new Vector2(450, 50), timePropertyOptions: { range: new Range( 0, 999.99 ) }, isVisible: true - } ); + }); // @public - position of the ruler - this.rulerPositionProperty = new Vector2Property( new Vector2( 200, 460 ) ); + this.rulerPositionProperty = new Vector2Property( new Vector2(200, 460 )); } /** Index: js/common/view/SpeakerNode.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/SpeakerNode.js b/js/common/view/SpeakerNode.js --- a/js/common/view/SpeakerNode.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/SpeakerNode.js (date 1599660663000) @@ -1,11 +1,12 @@ // Copyright 2018-2020, University of Colorado Boulder -/* eslint-disable default-import-match-filename */ // TODO Re-enable + /** * Node for the speaker, oscillates with the values of the oscillatorProperty. */ import Utils from '../../../../dot/js/Utils.js'; -import { Node, Image } from '../../../../scenery/js/imports.js'; +import Image from '../../../../scenery/js/nodes/Image.js'; +import Node from '../../../../scenery/js/nodes/Node.js'; import speakerL10Image from '../../../../wave-interference/images/speaker/speaker_L10_png.js'; import speakerL1Image from '../../../../wave-interference/images/speaker/speaker_L1_png.js'; import speakerL2Image from '../../../../wave-interference/images/speaker/speaker_L2_png.js'; @@ -57,14 +58,14 @@ class SpeakerNode extends Node { - constructor( oscillatorProperty ) { + constructor(oscillatorProperty) { super(); const image = new Image( speakerImageMID, { scale: 0.75 } ); - this.children = [ image ]; + this.children = [image]; oscillatorProperty.link( value => { const max = SoundConstants.AMPLITUDE_RANGE.max * SoundConstants.AMPLITUDE_CALIBRATION_SCALE; Index: js/common/view/SoundSlider.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/SoundSlider.js b/js/common/view/SoundSlider.js --- a/js/common/view/SoundSlider.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/SoundSlider.js (date 1599660663000) @@ -33,7 +33,7 @@ const maxTickIndex = ( options && options.maxTickIndex ) ? options.maxTickIndex : 10; assert && assert( property.range, 'SoundSlider.property requires range' ); - + const min = property.range.min; const max = property.range.max; const ticks = _.range( 0, maxTickIndex + 1 ).map( index => { Index: js/common/view/SoundModeControlPanel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/SoundModeControlPanel.js b/js/common/view/SoundModeControlPanel.js --- a/js/common/view/SoundModeControlPanel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/SoundModeControlPanel.js (date 1599660663000) @@ -5,7 +5,8 @@ */ import merge from '../../../../phet-core/js/merge.js'; -import { Node, Text } from '../../../../scenery/js/imports.js'; +import Node from '../../../../scenery/js/nodes/Node.js'; +import Text from '../../../../scenery/js/nodes/Text.js'; import RectangularPushButton from '../../../../sun/js/buttons/RectangularPushButton.js'; import VerticalAquaRadioButtonGroup from '../../../../sun/js/VerticalAquaRadioButtonGroup.js'; import WaveInterferencePanel from '../../../../wave-interference/js/common/view/WaveInterferencePanel.js'; @@ -13,12 +14,12 @@ import SoundConstants from '../../common/SoundConstants.js'; import sound from '../../sound.js'; import SoundModel from '../../sound/model/SoundModel.js'; -import SoundStrings from '../../SoundStrings.js'; +import soundStrings from '../../soundStrings.js'; -const titleString = SoundStrings.soundModeControlPanel.title; -const continuousOptionString = SoundStrings.soundModeControlPanel.continuous; -const pulseOptionString = SoundStrings.soundModeControlPanel.pulse; -const firePulseString = SoundStrings.soundModeControlPanel.firePulse; +const titleString = soundStrings.soundModeControlPanel.title; +const continuousOptionString = soundStrings.soundModeControlPanel.continuous; +const pulseOptionString = soundStrings.soundModeControlPanel.pulse; +const firePulseString = soundStrings.soundModeControlPanel.firePulse; class SoundModeControlPanel extends WaveInterferencePanel { @@ -27,53 +28,53 @@ * @param {AlignGroup} alignGroup * @param {Object} [options] */ - constructor( model, alignGroup, options ) { - options = merge( { + constructor( model, alignGroup, options) { + options = merge({ maxWidth: WaveInterferenceConstants.PANEL_MAX_WIDTH, yMargin: 4 - }, options ); + }, options); - const boxText = new Text( titleString ); + const boxText = new Text(titleString); - const radioButtons = new VerticalAquaRadioButtonGroup( model.soundModeProperty, [ { - createNode: tandem => new Text( continuousOptionString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), + const radioButtons = new VerticalAquaRadioButtonGroup(model.soundModeProperty, [ { + node: new Text(continuousOptionString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), value: SoundModel.SoundModeOptions.CONTINUOUS }, { - createNode: tandem => new Text( pulseOptionString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), + node: new Text(pulseOptionString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), value: SoundModel.SoundModeOptions.PULSE - } ], { + }], { spacing: options.yMargin } ); const container = new Node(); radioButtons.top = boxText.bottom + SoundConstants.CONTROL_PANEL_SPACING; - const firePulseButton = new RectangularPushButton( { - content: new Text( firePulseString ), + const firePulseButton = new RectangularPushButton({ + content: new Text(firePulseString), listener: () => model.startPulse() - } ); + }); firePulseButton.top = radioButtons.bottom + SoundConstants.CONTROL_PANEL_SPACING; container.children = [ - boxText, - radioButtons, - firePulseButton - ]; + boxText, + radioButtons, + firePulseButton + ]; firePulseButton.centerX = container.centerX; const updateEnabled = () => { - firePulseButton.setEnabled( model.soundModeProperty.value !== SoundModel.SoundModeOptions.CONTINUOUS && !model.isPulseFiringProperty.value ); + firePulseButton.setEnabled(model.soundModeProperty.value !== SoundModel.SoundModeOptions.CONTINUOUS && !model.isPulseFiringProperty.value); }; - model.soundModeProperty.link( updateEnabled ); - model.isPulseFiringProperty.link( updateEnabled ); + model.soundModeProperty.link(updateEnabled); + model.isPulseFiringProperty.link(updateEnabled); const content = alignGroup.createBox( container ); - content.setXAlign( 'center' ); + content.setXAlign('center'); - super( content, options ); + super( content, options); } } Index: js/common/view/SoundControlPanel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/SoundControlPanel.js b/js/common/view/SoundControlPanel.js --- a/js/common/view/SoundControlPanel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/SoundControlPanel.js (date 1599660663000) @@ -7,19 +7,21 @@ import Utils from '../../../../dot/js/Utils.js'; import merge from '../../../../phet-core/js/merge.js'; -import { Node, Text, HSeparator } from '../../../../scenery/js/imports.js'; +import Node from '../../../../scenery/js/nodes/Node.js'; +import Text from '../../../../scenery/js/nodes/Text.js'; import RectangularPushButton from '../../../../sun/js/buttons/RectangularPushButton.js'; +import HSeparator from '../../../../sun/js/HSeparator.js'; import WaveInterferencePanel from '../../../../wave-interference/js/common/view/WaveInterferencePanel.js'; import WaveInterferenceConstants from '../../../../wave-interference/js/common/WaveInterferenceConstants.js'; import SoundConstants from '../../common/SoundConstants.js'; import sound from '../../sound.js'; -import SoundStrings from '../../SoundStrings.js'; +import soundStrings from '../../soundStrings.js'; import PropertyControlSlider from './PropertyControlSlider.js'; -const amplitudeString = SoundStrings.amplitude; -const frequencyString = SoundStrings.frequency; -const clearString = SoundStrings.measure.clearWaves; -const hzString = SoundStrings.hz; +const amplitudeString = soundStrings.amplitude; +const frequencyString = soundStrings.frequency; +const clearString = soundStrings.measure.clearWaves; +const hzString = soundStrings.hz; class SoundControlPanel extends WaveInterferencePanel { @@ -36,8 +38,8 @@ }, options ); const frequencyControl = new PropertyControlSlider( frequencyString, model.frequencyProperty, { - valueToText: value => ( Utils.roundSymmetric( value * 1000 ) ).toString() + hzString - } ); + valueToText: value => (Utils.roundSymmetric(value * 1000)).toString() + hzString + }); const amplitudeControl = new PropertyControlSlider( amplitudeString, model.amplitudeProperty ); const centerX = frequencyControl.centerX; @@ -48,15 +50,15 @@ amplitudeControl.top = frequencyControl.bottom + SoundConstants.CONTROL_PANEL_SPACING; const container = new Node(); - const clearButton = new RectangularPushButton( { + const clearButton = new RectangularPushButton({ listener: () => { model.clearWaves(); }, - content: new Text( clearString ) - } ); + content: new Text(clearString) + }); clearButton.top = amplitudeControl.bottom + SoundConstants.CONTROL_PANEL_SPACING; - const separator = new HSeparator( { minWidth: frequencyControl.width } ); + const separator = new HSeparator( frequencyControl.width ); separator.top = amplitudeControl.bottom + SoundConstants.CONTROL_PANEL_SPACING; separator.centerX = centerX; @@ -64,10 +66,10 @@ clearButton.centerX = centerX; container.children = [ - frequencyControl, - amplitudeControl, - ...( model.stopwatch ? [ separator, clearButton ] : [] ) - ]; + frequencyControl, + amplitudeControl, + ...( model.stopwatch ? [separator, clearButton ] : [] ) + ]; const content = alignGroup.createBox( container ); Index: js/common/view/ReflectionControlPanel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/ReflectionControlPanel.js b/js/common/view/ReflectionControlPanel.js --- a/js/common/view/ReflectionControlPanel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/ReflectionControlPanel.js (date 1599660663000) @@ -5,15 +5,15 @@ */ import merge from '../../../../phet-core/js/merge.js'; -import { Node } from '../../../../scenery/js/imports.js'; +import Node from '../../../../scenery/js/nodes/Node.js'; import WaveInterferencePanel from '../../../../wave-interference/js/common/view/WaveInterferencePanel.js'; import WaveInterferenceConstants from '../../../../wave-interference/js/common/WaveInterferenceConstants.js'; import sound from '../../sound.js'; -import SoundStrings from '../../SoundStrings.js'; +import soundStrings from '../../soundStrings.js'; import PropertyControlSlider from './PropertyControlSlider.js'; -const positionSliderString = SoundStrings.reflectionControlPanel.positionSlider; -const rotationSliderString = SoundStrings.reflectionControlPanel.rotationSlider; +const positionSliderString = soundStrings.reflectionControlPanel.positionSlider; +const rotationSliderString = soundStrings.reflectionControlPanel.rotationSlider; class ReflectionControlPanel extends WaveInterferencePanel { @@ -30,7 +30,7 @@ }, options ); const wallPositionXControl = new PropertyControlSlider( positionSliderString, model.wallPositionXProperty ); - const wallAngleControl = new PropertyControlSlider( rotationSliderString, model.wallAngleProperty ); + const wallAngleControl = new PropertyControlSlider(rotationSliderString , model.wallAngleProperty ); const centerX = wallPositionXControl.centerX; wallAngleControl.centerX = centerX; @@ -41,9 +41,9 @@ const container = new Node(); container.children = [ - wallPositionXControl, - wallAngleControl - ]; + wallPositionXControl, + wallAngleControl + ]; const content = alignGroup.createBox( container ); Index: images/license.json IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/images/license.json b/images/license.json --- a/images/license.json (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/images/license.json (date 1599660663000) @@ -1,44 +1,3 @@ { - "girl.png": { - "text": [ - "Copyright 2021 University of Colorado Boulder" - ], - "projectURL": "https://phet.colorado.edu", - "license": "contact phethelp@colorado.edu" - }, - "measureIcon.png": { - "text": [ - "Copyright 2022 University of Colorado Boulder" - ], - "projectURL": "https://phet.colorado.edu", - "license": "contact phethelp@colorado.edu" - }, - "pressureIcon.png": { - "text": [ - "Copyright 2022 University of Colorado Boulder" - ], - "projectURL": "https://phet.colorado.edu", - "license": "contact phethelp@colorado.edu" - }, - "reflectionIcon.png": { - "text": [ - "Copyright 2022 University of Colorado Boulder" - ], - "projectURL": "https://phet.colorado.edu", - "license": "contact phethelp@colorado.edu" - }, - "singleSourceIcon.png": { - "text": [ - "Copyright 2022 University of Colorado Boulder" - ], - "projectURL": "https://phet.colorado.edu", - "license": "contact phethelp@colorado.edu" - }, - "twoSourceIcon.png": { - "text": [ - "Copyright 2022 University of Colorado Boulder" - ], - "projectURL": "https://phet.colorado.edu", - "license": "contact phethelp@colorado.edu" - } + } \ No newline at end of file Index: js/common/view/PropertyControlSlider.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/PropertyControlSlider.js b/js/common/view/PropertyControlSlider.js --- a/js/common/view/PropertyControlSlider.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/PropertyControlSlider.js (date 1599660663000) @@ -5,37 +5,38 @@ */ import merge from '../../../../phet-core/js/merge.js'; -import { Node, Text } from '../../../../scenery/js/imports.js'; +import Node from '../../../../scenery/js/nodes/Node.js'; +import Text from '../../../../scenery/js/nodes/Text.js'; import WaveInterferenceUtils from '../../../../wave-interference/js/common/WaveInterferenceUtils.js'; import SoundSlider from '../../common/view/SoundSlider.js'; import sound from '../../sound.js'; class ProtertyControlSlider extends Node { - constructor( titleText, property, options ) { + constructor(titleText, property, options) { options = merge( { valueToText: null - }, options ); + }, options); - const title = new Text( titleText ); - const valueDisplay = new Text( '' ); + const title = new Text(titleText); + const valueDisplay = new Text(''); valueDisplay.top = title.bottom + 5; - const sliderContainer = new SoundSlider( property ); + const sliderContainer = new SoundSlider(property); sliderContainer.centerX = title.centerX; - sliderContainer.top = ( options.valueToText ? valueDisplay.bottom : title.bottom ) + WaveInterferenceUtils.getSliderTitleSpacing( title ); + sliderContainer.top = (options.valueToText ? valueDisplay.bottom : title.bottom) + WaveInterferenceUtils.getSliderTitleSpacing( title ); valueDisplay.right = sliderContainer.right; - if ( options.valueToText ) { - property.link( value => { - valueDisplay.setText( options.valueToText( value ) ); + if(options.valueToText){ + property.link(value => { + valueDisplay.setText(options.valueToText(value)); valueDisplay.right = sliderContainer.right; - } ); + }); } super( { children: [ title, - ...( options.valueToText ? [ valueDisplay ] : [] ), - sliderContainer ] + ...(options.valueToText ? [valueDisplay] : []), + sliderContainer ] } ); Index: js/common/view/MovableNode.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/MovableNode.js b/js/common/view/MovableNode.js --- a/js/common/view/MovableNode.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/MovableNode.js (date 1599660663000) @@ -4,12 +4,12 @@ * A node which can be dragged within the given bounds. */ -import Property from '../../../../axon/js/Property.js'; +import MovableDragHandler from '../../../../scenery-phet/js/input/MovableDragHandler.js'; +import Node from '../../../../scenery/js/nodes/Node.js'; import sound from '../../sound.js'; -import { Node, DragListener } from '../../../../scenery/js/imports.js'; class MoveableNode extends Node { - constructor( positionProperty, dragBounds, modelViewTransform, child ) { + constructor(positionProperty, dragBounds, modelViewTransform, child) { super(); // interactivity @@ -23,15 +23,12 @@ } ); // @private (phet-io) - - // TODO: Upgraded from another listener type - this.movableDragHandler = new DragListener( { - property: positionProperty, - dragBoundsProperty: new Property( dragBounds ), // TODO + this.movableDragHandler = new MovableDragHandler( positionProperty, { + dragBounds: dragBounds, modelViewTransform: modelViewTransform } ); - this.children = [ child ]; + this.children = [child]; this.addInputListener( this.movableDragHandler ); } Index: js/common/view/LatticeCanvasNode.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/LatticeCanvasNode.js b/js/common/view/LatticeCanvasNode.js --- a/js/common/view/LatticeCanvasNode.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/LatticeCanvasNode.js (date 1599660663000) @@ -8,7 +8,8 @@ import Utils from '../../../../dot/js/Utils.js'; import Vector2 from '../../../../dot/js/Vector2.js'; import merge from '../../../../phet-core/js/merge.js'; -import { CanvasNode, Color } from '../../../../scenery/js/imports.js'; +import CanvasNode from '../../../../scenery/js/nodes/CanvasNode.js'; +import Color from '../../../../scenery/js/util/Color.js'; import ImageDataRenderer from '../../../../wave-interference/js/common/view/ImageDataRenderer.js'; import WaveInterferenceConstants from '../../../../wave-interference/js/common/WaveInterferenceConstants.js'; import WaveInterferenceUtils from '../../../../wave-interference/js/common/WaveInterferenceUtils.js'; @@ -24,7 +25,7 @@ * @param {Lattice} lattice * @param {Object} [options] */ - constructor( lattice, options ) { + constructor( lattice, options) { options = merge( { @@ -33,10 +34,10 @@ layerSplit: true, // ensure we're on our own layer baseColor: Color.blue, hasReflection: false, - sourcePosition: new Vector2( 0, 0 ), + sourcePosition: new Vector2(0,0), hasSecondSource: false, source2PositionY: 0, - wallAngle: Math.PI / 4 + wallAngle: Math.PI/4 }, options ); @@ -93,7 +94,7 @@ * @public */ - setWallPositionX( x ) { + setWallPositionX(x) { this.wallPositionX = x; } @@ -103,7 +104,7 @@ * @public */ - setWallAngle( angle ) { + setWallAngle(angle) { this.wallAngle = angle; } @@ -118,14 +119,14 @@ } /** - * Gets dampened lattice value - * @public - */ - getDampenedValue( x, y ) { - const distance = this.sourcePosition.distanceXY( x, y ); - const distanceDampen = distance >= 0 && distance <= SoundConstants.MAX_SOUND_DISTANCE ? ( SoundConstants.MAX_SOUND_DISTANCE - distance ) / SoundConstants.MAX_SOUND_DISTANCE : 0; + * Gets dampened lattice value + * @public + */ + getDampenedValue(x,y ) { + const distance = this.sourcePosition.distanceXY(x, y); + const distanceDampen = distance >= 0 && distance <= SoundConstants.MAX_SOUND_DISTANCE ? (SoundConstants.MAX_SOUND_DISTANCE - distance) / SoundConstants.MAX_SOUND_DISTANCE : 0; - return this.lattice.getInterpolatedValue( x, y ) * distanceDampen; + return this.lattice.getInterpolatedValue(x, y) * distanceDampen; } /** @@ -151,29 +152,29 @@ let addition = 0; let zeroOut = 1; - if ( this.hasReflection ) { - if ( k >= this.sourcePosition.x && k < Utils.roundSymmetric( this.wallPositionX ) - ( i - height + dampY ) / Math.tan( this.wallAngle ) ) { - const originalPos = new Vector2( k, i ); - const wallVector = Vector2.createPolar( 1, -this.wallAngle ); - const wallOrigin = new Vector2( this.wallPositionX, height - dampY ); - const mirroredPosition = wallVector.withMagnitude( originalPos.copy().minus( wallOrigin ).dot( wallVector ) ).plus( wallOrigin ); - const perp = mirroredPosition.minus( originalPos ).times( 2 ); - const final = originalPos.plus( perp ); - const finalX = Utils.roundSymmetric( final.x ); - const finalY = Utils.roundSymmetric( final.y ); + if(this.hasReflection){ + if(k >= this.sourcePosition.x && k < Utils.roundSymmetric(this.wallPositionX) - (i - height + dampY) / Math.tan(this.wallAngle)){ + const originalPos = new Vector2(k, i); + const wallVector = Vector2.createPolar(1, -this.wallAngle); + const wallOrigin = new Vector2(this.wallPositionX, height - dampY); + const mirroredPosition = wallVector.withMagnitude(originalPos.copy().minus(wallOrigin).dot(wallVector)).plus(wallOrigin); + const perp = mirroredPosition.minus(originalPos).times(2); + const final = originalPos.plus(perp); + const finalX = Utils.roundSymmetric(final.x); + const finalY = Utils.roundSymmetric(final.y); - addition = this.getDampenedValue( finalX, finalY ); + addition = this.getDampenedValue(finalX, finalY); } - else { + else{ zeroOut = 0; } } - if ( this.hasSecondSource ) { - addition = this.getDampenedValue( k, Utils.roundSymmetric( i + this.sourcePosition.y - this.source2PositionY ) ); + if(this.hasSecondSource){ + addition = this.getDampenedValue(k, Utils.roundSymmetric(i + this.sourcePosition.y - this.source2PositionY)); } - const waveValue = ( this.getDampenedValue( k, i ) + addition ) * zeroOut; + const waveValue = (this.getDampenedValue(k, i) + addition) * zeroOut; if ( waveValue > 0 ) { intensity = Utils.linear( 0, 2, CUTOFF, 1, waveValue ); Index: js/common/view/AudioControlPanel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/AudioControlPanel.js b/js/common/view/AudioControlPanel.js --- a/js/common/view/AudioControlPanel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/AudioControlPanel.js (date 1599660663000) @@ -5,7 +5,8 @@ */ import merge from '../../../../phet-core/js/merge.js'; -import { Node, Text } from '../../../../scenery/js/imports.js'; +import Node from '../../../../scenery/js/nodes/Node.js'; +import Text from '../../../../scenery/js/nodes/Text.js'; import Checkbox from '../../../../sun/js/Checkbox.js'; import VerticalAquaRadioButtonGroup from '../../../../sun/js/VerticalAquaRadioButtonGroup.js'; import WaveInterferencePanel from '../../../../wave-interference/js/common/view/WaveInterferencePanel.js'; @@ -13,12 +14,12 @@ import SoundConstants from '../../common/SoundConstants.js'; import sound from '../../sound.js'; import SoundModel from '../../sound/model/SoundModel.js'; -import SoundStrings from '../../SoundStrings.js'; +import soundStrings from '../../soundStrings.js'; -const titleString = SoundStrings.audioControlPanel.title; -const audioEnabledString = SoundStrings.audioControlPanel.audioEnabled; -const speakerAudioString = SoundStrings.audioControlPanel.speaker; -const listenerAudioString = SoundStrings.audioControlPanel.listener; +const titleString = soundStrings.audioControlPanel.title; +const audioEnabledString = soundStrings.audioControlPanel.audioEnabled; +const speakerAudioString = soundStrings.audioControlPanel.speaker; +const listenerAudioString = soundStrings.audioControlPanel.listener; class AudioControlPanel extends WaveInterferencePanel { @@ -27,50 +28,49 @@ * @param {AlignGroup} alignGroup * @param {Object} [options] */ - constructor( model, alignGroup, options ) { - options = merge( { + constructor( model, alignGroup, options) { + options = merge({ maxWidth: WaveInterferenceConstants.PANEL_MAX_WIDTH, yMargin: 4 - }, options ); + }, options); - const boxText = new Text( titleString ); + const boxText = new Text(titleString); const graphCheckbox = new Checkbox( - model.isAudioEnabledProperty, - new Text( audioEnabledString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), - { + new Text(audioEnabledString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), + model.isAudioEnabledProperty, { boxWidth: 15 - } ); + }); graphCheckbox.top = boxText.bottom + SoundConstants.CONTROL_PANEL_SPACING; let radioButtons; - if ( model.audioControlSettingProperty ) { - radioButtons = new VerticalAquaRadioButtonGroup( model.audioControlSettingProperty, [ { - createNode: tandem => new Text( speakerAudioString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), + if(model.audioControlSettingProperty){ + radioButtons = new VerticalAquaRadioButtonGroup(model.audioControlSettingProperty, [ { + node: new Text(speakerAudioString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), value: SoundModel.AudioControlOptions.SPEAKER }, { - createNode: tandem => new Text( listenerAudioString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), + node: new Text(listenerAudioString, WaveInterferenceConstants.CONTROL_PANEL_TEXT_MAX_WIDTH_OPTIONS ), value: SoundModel.AudioControlOptions.LISTENER - } ], { + }], { spacing: options.yMargin } ); radioButtons.top = graphCheckbox.bottom + SoundConstants.CONTROL_PANEL_SPACING; } - + const container = new Node(); container.children = [ - boxText, - graphCheckbox, - ...( model.audioControlSettingProperty ? [ radioButtons ] : [] ) - ]; + boxText, + graphCheckbox, + ...(model.audioControlSettingProperty ? [radioButtons] : []) + ]; const content = alignGroup.createBox( container ); - content.setXAlign( 'left' ); + content.setXAlign('left'); - super( content, options ); + super( content, options); } } Index: js/common/view/AirDensityControlPanel.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/AirDensityControlPanel.js b/js/common/view/AirDensityControlPanel.js --- a/js/common/view/AirDensityControlPanel.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/view/AirDensityControlPanel.js (date 1599660663000) @@ -5,16 +5,17 @@ */ import merge from '../../../../phet-core/js/merge.js'; -import { Node, Text } from '../../../../scenery/js/imports.js'; +import Node from '../../../../scenery/js/nodes/Node.js'; +import Text from '../../../../scenery/js/nodes/Text.js'; import RectangularPushButton from '../../../../sun/js/buttons/RectangularPushButton.js'; import WaveInterferencePanel from '../../../../wave-interference/js/common/view/WaveInterferencePanel.js'; import WaveInterferenceConstants from '../../../../wave-interference/js/common/WaveInterferenceConstants.js'; import sound from '../../sound.js'; -import SoundStrings from '../../SoundStrings.js'; +import soundStrings from '../../soundStrings.js'; import PropertyControlSlider from './PropertyControlSlider.js'; -const titleString = SoundStrings.airDensityControlPanel.title; -const resetString = SoundStrings.airDensityControlPanel.reset; +const titleString = soundStrings.airDensityControlPanel.title; +const resetString = soundStrings.airDensityControlPanel.reset; class AirDensityControlPanel extends WaveInterferencePanel { @@ -23,33 +24,33 @@ * @param {AlignGroup} alignGroup * @param {Object} [options] */ - constructor( model, alignGroup, options ) { - options = merge( { + constructor( model, alignGroup, options) { + options = merge({ maxWidth: WaveInterferenceConstants.PANEL_MAX_WIDTH, yMargin: 4 - }, options ); + }, options); const container = new Node(); - const resetButton = new RectangularPushButton( { - content: new Text( resetString ), + const resetButton = new RectangularPushButton({ + content: new Text(resetString), listener: () => { - model.pressureProperty.set( 1 ); + model.pressureProperty.set(1); } - } ); + }); - const airPressureContol = new PropertyControlSlider( titleString, model.pressureProperty ); + const airPressureContol = new PropertyControlSlider( titleString, model.pressureProperty); container.children = [ - airPressureContol, - resetButton - ]; + airPressureContol, + resetButton + ]; resetButton.top = airPressureContol.bottom + options.yMargin; const content = alignGroup.createBox( container ); - content.setXAlign( 'center' ); + content.setXAlign('center'); - super( content, options ); + super( content, options); } } Index: js/common/SoundConstants.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/SoundConstants.js b/js/common/SoundConstants.js --- a/js/common/SoundConstants.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/SoundConstants.js (date 1599660663000) @@ -24,9 +24,9 @@ LATTICE_PADDING: LATTICE_PADDING, SOURCE_POSITION_X: LATTICE_PADDING + 20, WAVE_AREA_WIDTH: WAVE_AREA_WIDTH, - LISTENER_BOUNDS_X: new Range( WAVE_AREA_WIDTH / 3, 4 / 5 * WAVE_AREA_WIDTH ), + LISTENER_BOUNDS_X: new Range(WAVE_AREA_WIDTH / 3, 4/5 * WAVE_AREA_WIDTH), SPEAKER_OFFSET: 55, - AMPLITUDE_RANGE: new Range( 0, 10 ), + AMPLITUDE_RANGE: new Range(0, 10), MAX_SOUND_DISTANCE: 85, EVENT_RATE: EVENT_RATE, AMPLITUDE_CALIBRATION_SCALE: AMPLITUDE_CALIBRATION_SCALE, Index: js/common/model/TemporalMask.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/model/TemporalMask.js b/js/common/model/TemporalMask.js --- a/js/common/model/TemporalMask.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/common/model/TemporalMask.js (date 1599660663000) @@ -13,7 +13,7 @@ class TemporalMask { - constructor( wallPositionXProperty, wallAngleProperty, transformModel ) { + constructor(wallPositionXProperty, wallAngleProperty, transformModel) { // @private - x coordinate of the origin position of the wall if present. this.wallPositionXProperty = wallPositionXProperty; @@ -56,7 +56,7 @@ * @returns {boolean} * @public */ - matches( horizontalSourceX, horizontalLatticeCoordinate, verticalLatticeCoordinate, numberOfSteps ) { + matches(horizontalSourceX, horizontalLatticeCoordinate, verticalLatticeCoordinate, numberOfSteps ) { // search to see if the source contributed to the value at the specified coordinate at the current numberOfSteps for ( let k = 0; k < this.deltas.length; k++ ) { @@ -71,7 +71,7 @@ const startTime = delta.numberOfSteps; const endTime = this.deltas[ k + 1 ] ? this.deltas[ k + 1 ].numberOfSteps : numberOfSteps; - const theoreticalTime = numberOfSteps - distance / ( Lattice.WAVE_SPEED ); + const theoreticalTime = numberOfSteps - distance / ( Lattice.WAVE_SPEED) ; // if theoreticalDistance matches any time in this range, the cell's value was caused by the oscillators, and // not by a reflection or numerical artifact. The tolerance is necessary because the actual group velocity @@ -81,7 +81,7 @@ const tailTolerance = 4; - if ( horizontalDelta <= 0 && theoreticalTime >= startTime - headTolerance && theoreticalTime <= endTime + tailTolerance && Math.abs( Math.atan( verticalDelta / horizontalDelta ) ) <= SoundConstants.CONE_ANGLE && ( this.wallPositionXProperty ? horizontalLatticeCoordinate < this.transformModel.modelToViewX( this.wallPositionXProperty.value ) + ( verticalLatticeCoordinate - SoundConstants.LATTICE_DIMENSION + SoundConstants.LATTICE_PADDING ) / Math.tan( -this.wallAngleProperty.value ) : true ) ) { + if (horizontalDelta <= 0 && theoreticalTime >= startTime - headTolerance && theoreticalTime <= endTime + tailTolerance && Math.abs(Math.atan(verticalDelta / horizontalDelta)) <= SoundConstants.CONE_ANGLE && (this.wallPositionXProperty ? horizontalLatticeCoordinate < this.transformModel.modelToViewX(this.wallPositionXProperty.value) + (verticalLatticeCoordinate - SoundConstants.LATTICE_DIMENSION + SoundConstants.LATTICE_PADDING) / Math.tan(-this.wallAngleProperty.value) : true)) { // Return as early as possible to improve performance return distance; Index: js/sound-main.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound-main.js b/js/sound-main.js --- a/js/sound-main.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound-main.js (date 1599660663000) @@ -1,5 +1,5 @@ // Copyright 2020, University of Colorado Boulder -/* eslint-disable default-import-match-filename */ // TODO Re-enable + /** * Main entry point for the sim. * @@ -8,7 +8,7 @@ import Sim from '../../joist/js/Sim.js'; import simLauncher from '../../joist/js/simLauncher.js'; -import { Image } from '../../scenery/js/imports.js'; +import Image from '../../scenery/js/nodes/Image.js'; import measureIcon from '../images/measureIcon_png.js'; import pressureIcon from '../images/pressureIcon_png.js'; import reflectionIcon from '../images/reflectionIcon_png.js'; @@ -25,13 +25,16 @@ import ReflectionView from './sound/view/ReflectionView.js'; import SingleSourceView from './sound/view/SingleSourceView.js'; import TwoSourceView from './sound/view/TwoSourceView.js'; -import SoundStrings from './SoundStrings.js'; +import soundStrings from './soundStrings.js'; + +const soundTitleString = soundStrings.sound.title; +const singleSourceTitle = soundStrings.singleSource.title; +const measureTitle = soundStrings.measure.title; +const twoSourceTitle = soundStrings.twoSource.title; +const reflectionTitle = soundStrings.reflection.title; +const pressureTitle = soundStrings.airPressure.title; -const singleSourceTitle = SoundStrings.singleSource.title; -const measureTitle = SoundStrings.measure.title; -const twoSourceTitle = SoundStrings.twoSource.title; -const reflectionTitle = SoundStrings.reflection.title; -const pressureTitle = SoundStrings.airPressure.title; + const simOptions = { @@ -50,13 +53,13 @@ // launch the sim - beware that scenery Image nodes created outside of simLauncher.launch() will have zero bounds // until the images are fully loaded, see https://github.com/phetsims/coulombs-law/issues/70 simLauncher.launch( () => { - const sim = new Sim( SoundStrings.sound.titleStringProperty, [ - new SoundScreen( singleSourceTitle, () => new SingleSourceModel(), model => new SingleSourceView( model ), new Image( singleSourceIcon ) ), - new SoundScreen( measureTitle, () => new MeasureModel(), model => new MeasureView( model ), new Image( measureIcon ) ), - new SoundScreen( twoSourceTitle, () => new TwoSourceModel(), model => new TwoSourceView( model ), new Image( twoSourceIcon ) ), - new SoundScreen( reflectionTitle, () => new ReflectionModel(), model => new ReflectionView( model ), new Image( reflectionIcon ) ), - new SoundScreen( pressureTitle, () => new PressureModel(), model => new PressureView( model ), new Image( pressureIcon ) ) + const sim = new Sim( soundTitleString, [ + new SoundScreen(singleSourceTitle, () => new SingleSourceModel(), model => new SingleSourceView(model), new Image(singleSourceIcon)), + new SoundScreen(measureTitle, () => new MeasureModel(), model => new MeasureView(model), new Image(measureIcon)), + new SoundScreen(twoSourceTitle, () => new TwoSourceModel(), model => new TwoSourceView(model), new Image(twoSourceIcon)), + new SoundScreen(reflectionTitle, () => new ReflectionModel(), model => new ReflectionView(model), new Image(reflectionIcon)), + new SoundScreen(pressureTitle, () => new PressureModel(), model => new PressureView(model), new Image(pressureIcon)) ], simOptions ); - + sim.start(); } ); \ No newline at end of file Index: js/sound.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/sound.js b/js/sound.js --- a/js/sound.js (revision eb69a225ca9131538d4695288252930487bf6d1d) +++ b/js/sound.js (date 1599660663000) @@ -1,4 +1,4 @@ -// Copyright 2022, University of Colorado Boulder +// Copyright 2020, University of Colorado Boulder /** * Creates the namespace for this simulation. ```
samreid commented 1 year ago

Other salient changes:

samreid commented 1 year ago

I'm the responsible dev for this sim, but it sounds like there are other priorities for the first part of this quarter, so I'll unassign for now.

samreid commented 1 year ago

The code has been integrated into GitHub, closing.