@@ -972,7 +972,7 @@ class RenderWebGL extends EventEmitter {
972
972
973
973
drawable . updateMatrix ( ) ;
974
974
if ( drawable . skin ) {
975
- drawable . skin . updateSilhouette ( ) ;
975
+ drawable . skin . updateSilhouette ( this . _getDrawableScreenSpaceScale ( drawable ) ) ;
976
976
} else {
977
977
log . warn ( `Could not find skin for drawable with id: ${ drawableID } ` ) ;
978
978
}
@@ -1008,7 +1008,7 @@ class RenderWebGL extends EventEmitter {
1008
1008
if ( drawable . getVisible ( ) && drawable . getUniforms ( ) . u_ghost !== 0 ) {
1009
1009
drawable . updateMatrix ( ) ;
1010
1010
if ( drawable . skin ) {
1011
- drawable . skin . updateSilhouette ( ) ;
1011
+ drawable . skin . updateSilhouette ( this . _getDrawableScreenSpaceScale ( drawable ) ) ;
1012
1012
} else {
1013
1013
log . warn ( `Could not find skin for drawable with id: ${ id } ` ) ;
1014
1014
}
@@ -1243,7 +1243,7 @@ class RenderWebGL extends EventEmitter {
1243
1243
if ( ! drawable . skin || ! drawable . skin . getTexture ( [ 100 , 100 ] ) ) return null ;
1244
1244
1245
1245
drawable . updateMatrix ( ) ;
1246
- drawable . skin . updateSilhouette ( ) ;
1246
+ drawable . skin . updateSilhouette ( this . _getDrawableScreenSpaceScale ( drawable ) ) ;
1247
1247
const bounds = drawable . getFastBounds ( ) ;
1248
1248
1249
1249
// Limit queries to the stage size.
@@ -1281,7 +1281,7 @@ class RenderWebGL extends EventEmitter {
1281
1281
if ( drawable . skin && drawable . _visible ) {
1282
1282
// Update the CPU position data
1283
1283
drawable . updateMatrix ( ) ;
1284
- drawable . skin . updateSilhouette ( ) ;
1284
+ drawable . skin . updateSilhouette ( this . _getDrawableScreenSpaceScale ( drawable ) ) ;
1285
1285
const candidateBounds = drawable . getFastBounds ( ) ;
1286
1286
if ( bounds . intersects ( candidateBounds ) ) {
1287
1287
result . push ( {
@@ -1659,6 +1659,18 @@ class RenderWebGL extends EventEmitter {
1659
1659
this . _regionId = null ;
1660
1660
}
1661
1661
1662
+ /**
1663
+ * Get the screen-space scale of a drawable, as percentages of the drawable's "normal" size.
1664
+ * @param {Drawable } drawable The drawable whose screen-space scale we're fetching.
1665
+ * @returns {Array<number> } The screen-space X and Y dimensions of the drawable's scale, as percentages.
1666
+ */
1667
+ _getDrawableScreenSpaceScale ( drawable ) {
1668
+ return [
1669
+ drawable . scale [ 0 ] * this . _gl . canvas . width / this . _nativeSize [ 0 ] ,
1670
+ drawable . scale [ 1 ] * this . _gl . canvas . height / this . _nativeSize [ 1 ]
1671
+ ] ;
1672
+ }
1673
+
1662
1674
/**
1663
1675
* Draw a set of Drawables, by drawable ID
1664
1676
* @param {Array<int> } drawables The Drawable IDs to draw, possibly this._drawList.
@@ -1691,10 +1703,7 @@ class RenderWebGL extends EventEmitter {
1691
1703
if ( ! drawable . getVisible ( ) && ! opts . ignoreVisibility ) continue ;
1692
1704
1693
1705
// Combine drawable scale with the native vs. backing pixel ratio
1694
- const drawableScale = [
1695
- drawable . scale [ 0 ] * this . _gl . canvas . width / this . _nativeSize [ 0 ] ,
1696
- drawable . scale [ 1 ] * this . _gl . canvas . height / this . _nativeSize [ 1 ]
1697
- ] ;
1706
+ const drawableScale = this . _getDrawableScreenSpaceScale ( drawable ) ;
1698
1707
1699
1708
// If the skin or texture isn't ready yet, skip it.
1700
1709
if ( ! drawable . skin || ! drawable . skin . getTexture ( drawableScale ) ) continue ;
0 commit comments