@@ -424,6 +424,7 @@ class RenderWebGL extends EventEmitter {
424
424
425
425
/**
426
426
* Check if a particular Drawable is touching a particular color.
427
+ * Unlike touching drawable, touching color tests invisible sprites.
427
428
* @param {int } drawableID The ID of the Drawable to check.
428
429
* @param {Array<int> } color3b Test if the Drawable is touching this color.
429
430
* @param {Array<int> } [mask3b] Optionally mask the check to this part of Drawable.
@@ -435,11 +436,11 @@ class RenderWebGL extends EventEmitter {
435
436
436
437
const bounds = this . _touchingBounds ( drawableID ) ;
437
438
if ( ! bounds ) {
438
- return ;
439
+ return false ;
439
440
}
440
441
const candidateIDs = this . _filterCandidatesTouching ( drawableID , this . _drawList , bounds ) ;
441
442
if ( ! candidateIDs ) {
442
- return ;
443
+ return false ;
443
444
}
444
445
445
446
// Limit size of viewport to the bounds around the target Drawable,
@@ -477,7 +478,10 @@ class RenderWebGL extends EventEmitter {
477
478
ShaderManager . DRAW_MODE . colorMask :
478
479
ShaderManager . DRAW_MODE . silhouette ,
479
480
projection ,
480
- { extraUniforms} ) ;
481
+ {
482
+ extraUniforms,
483
+ ignoreVisibility : true // Touching color ignores sprite visibility
484
+ } ) ;
481
485
482
486
gl . stencilFunc ( gl . EQUAL , 1 , 1 ) ;
483
487
gl . stencilOp ( gl . KEEP , gl . KEEP , gl . KEEP ) ;
@@ -533,11 +537,11 @@ class RenderWebGL extends EventEmitter {
533
537
534
538
const bounds = this . _touchingBounds ( drawableID ) ;
535
539
if ( ! bounds ) {
536
- return ;
540
+ return false ;
537
541
}
538
542
candidateIDs = this . _filterCandidatesTouching ( drawableID , candidateIDs , bounds ) ;
539
543
if ( ! candidateIDs ) {
540
- return ;
544
+ return false ;
541
545
}
542
546
543
547
// Limit size of viewport to the bounds around the target Drawable,
@@ -1003,7 +1007,7 @@ class RenderWebGL extends EventEmitter {
1003
1007
1004
1008
try {
1005
1009
gl . disable ( gl . BLEND ) ;
1006
- this . _drawThese ( [ stampID ] , ShaderManager . DRAW_MODE . default , projection , { isStamping : true } ) ;
1010
+ this . _drawThese ( [ stampID ] , ShaderManager . DRAW_MODE . default , projection , { ignoreVisibility : true } ) ;
1007
1011
} finally {
1008
1012
gl . enable ( gl . BLEND ) ;
1009
1013
}
@@ -1097,7 +1101,7 @@ class RenderWebGL extends EventEmitter {
1097
1101
* @param {idFilterFunc } opts.filter An optional filter function.
1098
1102
* @param {object.<string,*> } opts.extraUniforms Extra uniforms for the shaders.
1099
1103
* @param {int } opts.effectMask Bitmask for effects to allow
1100
- * @param {boolean } opts.isStamping Stamp mode ignores sprite visibility, always drawing.
1104
+ * @param {boolean } opts.ignoreVisibility Draw all, despite visibility (e.g. stamping, touching color)
1101
1105
* @private
1102
1106
*/
1103
1107
_drawThese ( drawables , drawMode , projection , opts = { } ) {
@@ -1114,8 +1118,9 @@ class RenderWebGL extends EventEmitter {
1114
1118
const drawable = this . _allDrawables [ drawableID ] ;
1115
1119
/** @todo check if drawable is inside the viewport before anything else */
1116
1120
1117
- // Hidden drawables (e.g., by a "hide" block) are not drawn unless stamping
1118
- if ( ! drawable . getVisible ( ) && ! opts . isStamping ) continue ;
1121
+ // Hidden drawables (e.g., by a "hide" block) are not drawn unless
1122
+ // the ignoreVisibility flag is used (e.g. for stamping or touchingColor).
1123
+ if ( ! drawable . getVisible ( ) && ! opts . ignoreVisibility ) continue ;
1119
1124
1120
1125
const drawableScale = drawable . scale ;
1121
1126
0 commit comments