@@ -36,8 +36,12 @@ const getLocalPosition = (drawable, vec) => {
3636 // localPosition matches that transformation.
3737 localPosition [ 0 ] = 0.5 - ( ( ( v0 * m [ 0 ] ) + ( v1 * m [ 4 ] ) + m [ 12 ] ) / d ) ;
3838 localPosition [ 1 ] = ( ( ( v0 * m [ 1 ] ) + ( v1 * m [ 5 ] ) + m [ 13 ] ) / d ) + 0.5 ;
39- // Apply texture effect transform if the localPosition is within the drawable's space.
40- if ( ( localPosition [ 0 ] >= 0 && localPosition [ 0 ] < 1 ) && ( localPosition [ 1 ] >= 0 && localPosition [ 1 ] < 1 ) ) {
39+ // Apply texture effect transform if the localPosition is within the drawable's space,
40+ // and any effects are currently active.
41+ if ( drawable . enabledEffects !== 0 &&
42+ ( localPosition [ 0 ] >= 0 && localPosition [ 0 ] < 1 ) &&
43+ ( localPosition [ 1 ] >= 0 && localPosition [ 1 ] < 1 ) ) {
44+
4145 EffectTransform . transformPoint ( drawable , localPosition , localPosition ) ;
4246 }
4347 return localPosition ;
@@ -96,7 +100,11 @@ class Drawable {
96100 this . _inverseMatrix = twgl . m4 . identity ( ) ;
97101 this . _inverseTransformDirty = true ;
98102 this . _visible = true ;
99- this . _effectBits = 0 ;
103+
104+ /** A bitmask identifying which effects are currently in use.
105+ * @readonly
106+ * @type {int } */
107+ this . enabledEffects = 0 ;
100108
101109 /** @todo move convex hull functionality, maybe bounds functionality overall, to Skin classes */
102110 this . _convexHullPoints = null ;
@@ -159,13 +167,6 @@ class Drawable {
159167 return [ this . _scale [ 0 ] , this . _scale [ 1 ] ] ;
160168 }
161169
162- /**
163- * @returns {int } A bitmask identifying which effects are currently in use.
164- */
165- getEnabledEffects ( ) {
166- return this . _effectBits ;
167- }
168-
169170 /**
170171 * @returns {object.<string, *> } the shader uniforms to be used when rendering this Drawable.
171172 */
@@ -242,9 +243,9 @@ class Drawable {
242243 updateEffect ( effectName , rawValue ) {
243244 const effectInfo = ShaderManager . EFFECT_INFO [ effectName ] ;
244245 if ( rawValue ) {
245- this . _effectBits |= effectInfo . mask ;
246+ this . enabledEffects |= effectInfo . mask ;
246247 } else {
247- this . _effectBits &= ~ effectInfo . mask ;
248+ this . enabledEffects &= ~ effectInfo . mask ;
248249 }
249250 const converter = effectInfo . converter ;
250251 this . _uniforms [ effectInfo . uniformName ] = converter ( rawValue ) ;
@@ -481,7 +482,7 @@ class Drawable {
481482 }
482483
483484 // If the effect bits for mosaic, pixelate, whirl, or fisheye are set, use linear
484- if ( ( this . _effectBits & (
485+ if ( ( this . enabledEffects & (
485486 ShaderManager . EFFECT_INFO . fisheye . mask |
486487 ShaderManager . EFFECT_INFO . whirl . mask |
487488 ShaderManager . EFFECT_INFO . pixelate . mask |
@@ -692,7 +693,9 @@ class Drawable {
692693 // drawable.useNearest() ?
693694 drawable . skin . _silhouette . colorAtNearest ( localPosition , dst ) ;
694695 // : drawable.skin._silhouette.colorAtLinear(localPosition, dst);
695- return EffectTransform . transformColor ( drawable , textColor , textColor ) ;
696+
697+ if ( drawable . enabledEffects === 0 ) return textColor ;
698+ return EffectTransform . transformColor ( drawable , textColor ) ;
696699 }
697700}
698701
0 commit comments