mirror of
https://github.com/scratchfoundation/scratch-render.git
synced 2025-08-13 23:11:46 -04:00
Always use getAABB for bitmap skins when determining fenced position
This commit is contained in:
parent
25df9f1ab7
commit
1f0f89920a
4 changed files with 19 additions and 1 deletions
|
@ -59,6 +59,15 @@ class BitmapSkin extends Skin {
|
|||
return this._texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bounds of the drawable for determining its fenced position.
|
||||
* @param {Array<number>} drawable - The Drawable instance this skin is using.
|
||||
* @return {!Rectangle} The drawable's bounds. For compatibility with Scratch 2, we always use getAABB for bitmaps.
|
||||
*/
|
||||
getFenceBounds (drawable) {
|
||||
return drawable.getAABB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the contents of this skin to a snapshot of the provided bitmap data.
|
||||
* @param {ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} bitmapData - new contents for this skin.
|
||||
|
|
|
@ -1316,7 +1316,7 @@ class RenderWebGL extends EventEmitter {
|
|||
|
||||
const dx = x - drawable._position[0];
|
||||
const dy = y - drawable._position[1];
|
||||
const aabb = drawable.getFastBounds();
|
||||
const aabb = drawable._skin.getFenceBounds(drawable);
|
||||
const inset = Math.floor(Math.min(aabb.width, aabb.height) / 2);
|
||||
|
||||
const sx = this._xRight - Math.min(FENCE_WIDTH, inset);
|
||||
|
|
|
@ -136,6 +136,15 @@ class Skin extends EventEmitter {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bounds of the drawable for determining its fenced position.
|
||||
* @param {Array<number>} drawable - The Drawable instance this skin is using.
|
||||
* @return {!Rectangle} The drawable's bounds.
|
||||
*/
|
||||
getFenceBounds (drawable) {
|
||||
return drawable.getFastBounds();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update and returns the uniforms for this skin.
|
||||
* @param {Array<number>} scale - The scaling factors to be used.
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue