From 75748294e6a5108787b43125adeb0bf27251ef73 Mon Sep 17 00:00:00 2001 From: Jesse Date: Tue, 21 Mar 2023 13:16:59 -0400 Subject: [PATCH] Only construct the tangible controller when running with query parameters, see #398 --- js/quadrilateral/view/QuadrilateralNode.ts | 1 - js/quadrilateral/view/QuadrilateralScreenView.ts | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/js/quadrilateral/view/QuadrilateralNode.ts b/js/quadrilateral/view/QuadrilateralNode.ts index c2d212de..77cbef76 100644 --- a/js/quadrilateral/view/QuadrilateralNode.ts +++ b/js/quadrilateral/view/QuadrilateralNode.ts @@ -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; diff --git a/js/quadrilateral/view/QuadrilateralScreenView.ts b/js/quadrilateral/view/QuadrilateralScreenView.ts index 28caa564..74c9a803 100644 --- a/js/quadrilateral/view/QuadrilateralScreenView.ts +++ b/js/quadrilateral/view/QuadrilateralScreenView.ts @@ -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 ) { @@ -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( { @@ -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