Closed pixelzoom closed 8 years ago
Problem in Substance:
return inherit( Object, Substance, {}, { AIR: new Substance( airString, 1.000293, false, false ), WATER: new Substance( waterString, 1.333, false, false ), GLASS: new Substance( glassString, 1.5, false, false ), DIAMOND: new Substance( diamondString, DIAMOND_INDEX_OF_REFRACTION_FOR_RED_LIGHT, false, false ), MYSTERY_A: new Substance( mysteryAString, DIAMOND_INDEX_OF_REFRACTION_FOR_RED_LIGHT, true, false ), MYSTERY_B: new Substance( mysteryBString, 1.4, true, false ), DIAMOND_INDEX_OF_REFRACTION_FOR_RED_LIGHT: DIAMOND_INDEX_OF_REFRACTION_FOR_RED_LIGHT } )
The static instances are created before inherit is called, so instanceof tests will fail. See https://github.com/phetsims/phet-core/issues/24.
instanceof
The fix is to create the instances after the inherit call:
inherit( Object, Substance, {}, { DIAMOND_INDEX_OF_REFRACTION_FOR_RED_LIGHT: DIAMOND_INDEX_OF_REFRACTION_FOR_RED_LIGHT } ); Substance.AIR = new Substance( airString, 1.000293, false, false ); Substance.WATER = new Substance( waterString, 1.333, false, false ); Substance .GLASS = new Substance( glassString, 1.5, false, false ); Substance.DIAMOND = new Substance( diamondString, DIAMOND_INDEX_OF_REFRACTION_FOR_RED_LIGHT, false, false ); Substance.MYSTERY_A = new Substance( mysteryAString, DIAMOND_INDEX_OF_REFRACTION_FOR_RED_LIGHT, true, false ); Substance .MYSTERY_B = new Substance( mysteryBString, 1.4, true, false ); return Substance;
Fix described above committed and pushed. Assigned to @samreid for review.
The change set looks great, thanks @pixelzoom, closing.
Problem in Substance:
The static instances are created before inherit is called, so
instanceof
tests will fail. See https://github.com/phetsims/phet-core/issues/24.The fix is to create the instances after the inherit call: