diff --git a/js/demo/sim-like-components/model/BoxOfBalls.ts b/js/demo/sim-like-components/model/BoxOfBalls.ts index fdcc8818..b4609c2f 100644 --- a/js/demo/sim-like-components/model/BoxOfBalls.ts +++ b/js/demo/sim-like-components/model/BoxOfBalls.ts @@ -26,15 +26,15 @@ const createRandomColor = () => { }; class BoxOfBalls { + + // an array the contains the balls that are in this box + public readonly balls: ObservableArray; + + // the bounding box private readonly box: Shape; - private readonly balls: ObservableArray; constructor( width: number, height: number ) { - - // @public (read-only) {Shape.rect} - the bounding box this.box = Shape.rect( 50, 0, width, height ); - - // @public (read-only) {ObservableArrayDef} this.balls = createObservableArray(); } diff --git a/js/demo/sim-like-components/model/SimLikeComponentsModel.ts b/js/demo/sim-like-components/model/SimLikeComponentsModel.ts index 2583b2ba..ed5b5c50 100644 --- a/js/demo/sim-like-components/model/SimLikeComponentsModel.ts +++ b/js/demo/sim-like-components/model/SimLikeComponentsModel.ts @@ -1,7 +1,5 @@ // Copyright 2018-2020, University of Colorado Boulder -// @ts-nocheck - /** * A model that exists only for the purposes of demonstrating sonification, particularly how view and model elements are * used together to hook up sonification elements. @@ -16,24 +14,26 @@ import BoxOfBalls from './BoxOfBalls.js'; class SimLikeComponentsModel { - /** - * @constructor - */ - constructor() { + // a box containing bouncing balls + public readonly boxOfBalls: BoxOfBalls; - // @public (read-only) {BoxOfBalls) - box containing bouncing balls, size empirically determined - this.boxOfBalls = new BoxOfBalls( 135, 80 ); + // controls the number of balls in the box + public readonly numberOfBallsProperty: NumberProperty; - // @public {NumberProperty} - controls the number of balls in the box - this.numberOfBallsProperty = new NumberProperty( 0 ); + // controls whether the balls are bouncing around in the box or still + public readonly ballsMovingProperty: BooleanProperty; - // @public {BooleanProperty} - controls whether the balls are bouncing around in the box or still - this.ballsMovingProperty = new BooleanProperty( false ); + // tracks whether a reset is happening + public readonly resetInProgressProperty: BooleanProperty; - // @public {BooleanProperty} - tracks whether a reset is happening + constructor() { + + this.boxOfBalls = new BoxOfBalls( 135, 80 ); // size empirically determined + this.numberOfBallsProperty = new NumberProperty( 0 ); + this.ballsMovingProperty = new BooleanProperty( false ); this.resetInProgressProperty = new BooleanProperty( false ); - // add or remove balls as the count changes + // Add or remove balls as the count changes. this.numberOfBallsProperty.link( desiredNumberOfBalls => { const numberBallsInBox = this.boxOfBalls.balls.lengthProperty.get(); if ( desiredNumberOfBalls > numberBallsInBox ) { @@ -50,10 +50,10 @@ class SimLikeComponentsModel { } /** - * @param {number} dt - delta time, in seconds + * @param dt - delta time, in seconds * @public */ - step( dt ) { + step( dt: number ) { if ( this.ballsMovingProperty.value ) { this.boxOfBalls.step( dt ); } @@ -68,7 +68,6 @@ class SimLikeComponentsModel { this.ballsMovingProperty.reset(); this.resetInProgressProperty.value = false; } - } tambo.register( 'SimLikeComponentsModel', SimLikeComponentsModel );