@@ -1132,114 +1132,6 @@ class RenderWebGL extends EventEmitter {
1132
1132
return Number ( hit ) ;
1133
1133
}
1134
1134
1135
- /**
1136
- * @typedef DrawableExtractionOld
1137
- * @property {Uint8Array } data Raw pixel data for the drawable
1138
- * @property {int } width Drawable bounding box width
1139
- * @property {int } height Drawable bounding box height
1140
- * @property {Array<number> } scratchOffset [x, y] offset in Scratch coordinates
1141
- * from the drawable position to the client x, y coordinate
1142
- * @property {int } x The x coordinate relative to drawable bounding box
1143
- * @property {int } y The y coordinate relative to drawable bounding box
1144
- */
1145
-
1146
- /**
1147
- * Return drawable pixel data and picking coordinates relative to the drawable bounds
1148
- * @param {int } drawableID The ID of the drawable to get pixel data for
1149
- * @param {int } x The client x coordinate of the picking location.
1150
- * @param {int } y The client y coordinate of the picking location.
1151
- * @return {?DrawableExtractionOld } Data about the picked drawable
1152
- * @deprecated Use {@link extractDrawableScreenSpace} instead.
1153
- */
1154
- extractDrawable ( drawableID , x , y ) {
1155
- this . _doExitDrawRegion ( ) ;
1156
-
1157
- const drawable = this . _allDrawables [ drawableID ] ;
1158
- if ( ! drawable ) return null ;
1159
-
1160
- // Convert client coordinates into absolute scratch units
1161
- const scratchX = this . _nativeSize [ 0 ] * ( ( x / this . _gl . canvas . clientWidth ) - 0.5 ) ;
1162
- const scratchY = this . _nativeSize [ 1 ] * ( ( y / this . _gl . canvas . clientHeight ) - 0.5 ) ;
1163
-
1164
- const gl = this . _gl ;
1165
-
1166
- const bounds = drawable . getFastBounds ( ) ;
1167
- bounds . snapToInt ( ) ;
1168
-
1169
- // Set a reasonable max limit width and height for the bufferInfo bounds
1170
- const maxTextureSize = gl . getParameter ( gl . MAX_TEXTURE_SIZE ) ;
1171
- const clampedWidth = Math . min ( 2048 , bounds . width , maxTextureSize ) ;
1172
- const clampedHeight = Math . min ( 2048 , bounds . height , maxTextureSize ) ;
1173
-
1174
- // Make a new bufferInfo since this._queryBufferInfo is limited to 480x360
1175
- const attachments = [
1176
- { format : gl . RGBA } ,
1177
- { format : gl . DEPTH_STENCIL }
1178
- ] ;
1179
- const bufferInfo = twgl . createFramebufferInfo ( gl , attachments , clampedWidth , clampedHeight ) ;
1180
-
1181
- try {
1182
- // If the new bufferInfo is invalid, fall back to using the smaller _queryBufferInfo
1183
- twgl . bindFramebufferInfo ( gl , bufferInfo ) ;
1184
- if ( gl . checkFramebufferStatus ( gl . FRAMEBUFFER ) !== gl . FRAMEBUFFER_COMPLETE ) {
1185
- twgl . bindFramebufferInfo ( gl , this . _queryBufferInfo ) ;
1186
- }
1187
-
1188
- // Translate to scratch units relative to the drawable
1189
- const pickX = scratchX - bounds . left ;
1190
- const pickY = scratchY + bounds . top ;
1191
-
1192
- // Limit size of viewport to the bounds around the target Drawable,
1193
- // and create the projection matrix for the draw.
1194
- gl . viewport ( 0 , 0 , bounds . width , bounds . height ) ;
1195
- const projection = twgl . m4 . ortho ( bounds . left , bounds . right , bounds . top , bounds . bottom , - 1 , 1 ) ;
1196
-
1197
- gl . clearColor ( 0 , 0 , 0 , 0 ) ;
1198
- gl . clear ( gl . COLOR_BUFFER_BIT ) ;
1199
- try {
1200
- gl . disable ( gl . BLEND ) ;
1201
- // ImageData objects store alpha un-premultiplied, so draw with the `straightAlpha` draw mode.
1202
- this . _drawThese ( [ drawableID ] , ShaderManager . DRAW_MODE . straightAlpha , projection ,
1203
- { effectMask : ~ ShaderManager . EFFECT_INFO . ghost . mask } ) ;
1204
- } finally {
1205
- gl . enable ( gl . BLEND ) ;
1206
- }
1207
-
1208
- const data = new Uint8Array ( Math . floor ( bounds . width * bounds . height * 4 ) ) ;
1209
- gl . readPixels ( 0 , 0 , bounds . width , bounds . height , gl . RGBA , gl . UNSIGNED_BYTE , data ) ;
1210
-
1211
- if ( this . _debugCanvas ) {
1212
- this . _debugCanvas . width = bounds . width ;
1213
- this . _debugCanvas . height = bounds . height ;
1214
- const ctx = this . _debugCanvas . getContext ( '2d' ) ;
1215
- const imageData = ctx . createImageData ( bounds . width , bounds . height ) ;
1216
- imageData . data . set ( data ) ;
1217
- ctx . putImageData ( imageData , 0 , 0 ) ;
1218
- ctx . beginPath ( ) ;
1219
- ctx . arc ( pickX , pickY , 3 , 0 , 2 * Math . PI , false ) ;
1220
- ctx . fillStyle = 'white' ;
1221
- ctx . fill ( ) ;
1222
- ctx . lineWidth = 1 ;
1223
- ctx . strokeStyle = 'black' ;
1224
- ctx . stroke ( ) ;
1225
- }
1226
-
1227
- return {
1228
- data : data ,
1229
- width : bounds . width ,
1230
- height : bounds . height ,
1231
- scratchOffset : [
1232
- - scratchX + drawable . _position [ 0 ] ,
1233
- - scratchY - drawable . _position [ 1 ]
1234
- ] ,
1235
- x : pickX ,
1236
- y : pickY
1237
- } ;
1238
- } finally {
1239
- gl . deleteFramebuffer ( bufferInfo . framebuffer ) ;
1240
- }
1241
- }
1242
-
1243
1135
/**
1244
1136
* @typedef DrawableExtraction
1245
1137
* @property {ImageData } data Raw pixel data for the drawable
@@ -2097,7 +1989,7 @@ class RenderWebGL extends EventEmitter {
2097
1989
}
2098
1990
2099
1991
// :3
2100
- RenderWebGL . prototype . canHazPixels = RenderWebGL . prototype . extractDrawable ;
1992
+ RenderWebGL . prototype . canHazPixels = RenderWebGL . prototype . extractDrawableScreenSpace ;
2101
1993
2102
1994
/**
2103
1995
* Values for setUseGPU()
0 commit comments