Skip to content

Commit

Permalink
Only construct the tangible controller when running with query parame…
Browse files Browse the repository at this point in the history
…ters, see #398
  • Loading branch information
jessegreenberg committed Mar 21, 2023
1 parent 9da80ed commit 7574829
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion js/quadrilateral/view/QuadrilateralNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import QuadrilateralDescriber from './QuadrilateralDescriber.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import Multilink from '../../../../axon/js/Multilink.js';
import BooleanProperty from '../../../../axon/js/BooleanProperty.js';

// constants
const cornerAStringProperty = QuadrilateralStrings.a11y.cornerAStringProperty;
Expand Down
12 changes: 7 additions & 5 deletions js/quadrilateral/view/QuadrilateralScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export default class QuadrilateralScreenView extends ScreenView {
private readonly quadrilateralDescriber: QuadrilateralDescriber;
private readonly quadrilateralAlerter: QuadrilateralAlerter;

// REVIEW: Do we want prototype components going out in production code? Or move to a subclass? Or make nullable?
private readonly quadrilateralTangibleController: QuadrilateralTangibleController;
// Prototype components are only constructed and available when running with relevant query parameters.
private readonly quadrilateralTangibleController: QuadrilateralTangibleController | null = null;
private readonly quadrilateralMediaPipe: QuadrilateralMediaPipe | null = null;

public constructor( model: QuadrilateralModel, optionsModel: QuadrilateralOptionsModel, tandem: Tandem ) {
Expand Down Expand Up @@ -125,7 +125,9 @@ export default class QuadrilateralScreenView extends ScreenView {
} );

// tangible components
this.quadrilateralTangibleController = new QuadrilateralTangibleController( model );
if ( QuadrilateralQueryParameters.deviceConnection || MediaPipeQueryParameters.cameraInput === 'hands' ) {
this.quadrilateralTangibleController = new QuadrilateralTangibleController( model );
}

// this parent only has children if relevant query params are provided, but is always created for easy layout
const deviceConnectionParentNode = new VBox( {
Expand All @@ -134,13 +136,13 @@ export default class QuadrilateralScreenView extends ScreenView {
} );
if ( QuadrilateralQueryParameters.deviceConnection ) {
deviceConnectionParentNode.children = [
new QuadrilateralTangibleControls( model.tangibleConnectionModel, this.quadrilateralTangibleController, tandem.createTandem( 'connectionControls' ) )
new QuadrilateralTangibleControls( model.tangibleConnectionModel, this.quadrilateralTangibleController!, tandem.createTandem( 'connectionControls' ) )
];
deviceConnectionParentNode.top = gridNode.top;
deviceConnectionParentNode.left = resetAllButton.left;
}
if ( MediaPipeQueryParameters.cameraInput === 'hands' ) {
this.quadrilateralMediaPipe = new QuadrilateralMediaPipe( model, this.quadrilateralTangibleController );
this.quadrilateralMediaPipe = new QuadrilateralMediaPipe( model, this.quadrilateralTangibleController! );
}

// voicing components
Expand Down

0 comments on commit 7574829

Please sign in to comment.