@@ -36,8 +36,12 @@ const getLocalPosition = (drawable, vec) => {
36
36
// localPosition matches that transformation.
37
37
localPosition [ 0 ] = 0.5 - ( ( ( v0 * m [ 0 ] ) + ( v1 * m [ 4 ] ) + m [ 12 ] ) / d ) ;
38
38
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
+
41
45
EffectTransform . transformPoint ( drawable , localPosition , localPosition ) ;
42
46
}
43
47
return localPosition ;
@@ -96,7 +100,11 @@ class Drawable {
96
100
this . _inverseMatrix = twgl . m4 . identity ( ) ;
97
101
this . _inverseTransformDirty = true ;
98
102
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 ;
100
108
101
109
/** @todo move convex hull functionality, maybe bounds functionality overall, to Skin classes */
102
110
this . _convexHullPoints = null ;
@@ -159,13 +167,6 @@ class Drawable {
159
167
return [ this . _scale [ 0 ] , this . _scale [ 1 ] ] ;
160
168
}
161
169
162
- /**
163
- * @returns {int } A bitmask identifying which effects are currently in use.
164
- */
165
- getEnabledEffects ( ) {
166
- return this . _effectBits ;
167
- }
168
-
169
170
/**
170
171
* @returns {object.<string, *> } the shader uniforms to be used when rendering this Drawable.
171
172
*/
@@ -242,9 +243,9 @@ class Drawable {
242
243
updateEffect ( effectName , rawValue ) {
243
244
const effectInfo = ShaderManager . EFFECT_INFO [ effectName ] ;
244
245
if ( rawValue ) {
245
- this . _effectBits |= effectInfo . mask ;
246
+ this . enabledEffects |= effectInfo . mask ;
246
247
} else {
247
- this . _effectBits &= ~ effectInfo . mask ;
248
+ this . enabledEffects &= ~ effectInfo . mask ;
248
249
}
249
250
const converter = effectInfo . converter ;
250
251
this . _uniforms [ effectInfo . uniformName ] = converter ( rawValue ) ;
@@ -481,7 +482,7 @@ class Drawable {
481
482
}
482
483
483
484
// If the effect bits for mosaic, pixelate, whirl, or fisheye are set, use linear
484
- if ( ( this . _effectBits & (
485
+ if ( ( this . enabledEffects & (
485
486
ShaderManager . EFFECT_INFO . fisheye . mask |
486
487
ShaderManager . EFFECT_INFO . whirl . mask |
487
488
ShaderManager . EFFECT_INFO . pixelate . mask |
@@ -692,7 +693,9 @@ class Drawable {
692
693
// drawable.useNearest() ?
693
694
drawable . skin . _silhouette . colorAtNearest ( localPosition , dst ) ;
694
695
// : 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 ) ;
696
699
}
697
700
}
698
701
0 commit comments