Skip to content

Commit 1f0f899

Browse files
committed
Always use getAABB for bitmap skins when determining fenced position
1 parent 25df9f1 commit 1f0f899

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/BitmapSkin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ class BitmapSkin extends Skin {
5959
return this._texture;
6060
}
6161

62+
/**
63+
* Get the bounds of the drawable for determining its fenced position.
64+
* @param {Array<number>} drawable - The Drawable instance this skin is using.
65+
* @return {!Rectangle} The drawable's bounds. For compatibility with Scratch 2, we always use getAABB for bitmaps.
66+
*/
67+
getFenceBounds (drawable) {
68+
return drawable.getAABB();
69+
}
70+
6271
/**
6372
* Set the contents of this skin to a snapshot of the provided bitmap data.
6473
* @param {ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} bitmapData - new contents for this skin.

src/RenderWebGL.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ class RenderWebGL extends EventEmitter {
13161316

13171317
const dx = x - drawable._position[0];
13181318
const dy = y - drawable._position[1];
1319-
const aabb = drawable.getFastBounds();
1319+
const aabb = drawable._skin.getFenceBounds(drawable);
13201320
const inset = Math.floor(Math.min(aabb.width, aabb.height) / 2);
13211321

13221322
const sx = this._xRight - Math.min(FENCE_WIDTH, inset);

src/Skin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ class Skin extends EventEmitter {
136136
return null;
137137
}
138138

139+
/**
140+
* Get the bounds of the drawable for determining its fenced position.
141+
* @param {Array<number>} drawable - The Drawable instance this skin is using.
142+
* @return {!Rectangle} The drawable's bounds.
143+
*/
144+
getFenceBounds (drawable) {
145+
return drawable.getFastBounds();
146+
}
147+
139148
/**
140149
* Update and returns the uniforms for this skin.
141150
* @param {Array<number>} scale - The scaling factors to be used.
28 KB
Binary file not shown.

0 commit comments

Comments
 (0)