From 09a56a92554c7c400d524371b16553abd29a08c0 Mon Sep 17 00:00:00 2001 From: denz1994 Date: Mon, 11 May 2020 15:10:49 -0400 Subject: [PATCH] Correct Direction.id values. https://github.com/phetsims/masses-and-springs/issues/359 --- js/common/model/Direction.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/js/common/model/Direction.js b/js/common/model/Direction.js index d4e69266..629ed5d8 100644 --- a/js/common/model/Direction.js +++ b/js/common/model/Direction.js @@ -11,25 +11,32 @@ import Vector2 from '../../../../dot/js/Vector2.js'; import Enumeration from '../../../../phet-core/js/Enumeration.js'; import buildAMolecule from '../../buildAMolecule.js'; +// constants +const DirectionOrientation = Enumeration.byKeys( [ 'NORTH', 'EAST', 'SOUTH', 'WEST' ] ); + class DirectionValue { /** * @param {Vector2} vector + * @param {string} id */ - constructor( vector ) { + constructor( vector, id ) { // @public {Vector2} this.vector = vector; + // @public {number} + this.id = id; + // @public {DirectionValue} this.opposite = null; } } // Declare cardinal direction values -const NORTH = new DirectionValue( new Vector2( 0, 1 ) ); -const SOUTH = new DirectionValue( new Vector2( 0, -1 ) ); -const EAST = new DirectionValue( new Vector2( 1, 0 ) ); -const WEST = new DirectionValue( new Vector2( -1, 0 ) ); +const NORTH = new DirectionValue( new Vector2( 0, 1 ), DirectionOrientation.NORTH ); +const SOUTH = new DirectionValue( new Vector2( 0, -1 ), DirectionOrientation.SOUTH ); +const EAST = new DirectionValue( new Vector2( 1, 0 ), DirectionOrientation.EAST ); +const WEST = new DirectionValue( new Vector2( -1, 0 ), DirectionOrientation.WEST ); // Declare opposites NORTH.opposite = SOUTH;