Skip to content

Commit dbe1057

Browse files
committed
Always use getAABB for bitmap skins
1 parent c8b9516 commit dbe1057

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed

src/BitmapSkin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class BitmapSkin extends Skin {
2323

2424
/** @type {Array<int>} */
2525
this._textureSize = [0, 0];
26+
27+
/** @type {string} */
28+
this._typeOfSkin = 'BITMAP';
2629
}
2730

2831
/**

src/PenSkin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class PenSkin extends Skin {
8888
/** @type {HTMLCanvasElement} */
8989
this._canvas = document.createElement('canvas');
9090

91+
/** @type {string} */
92+
this._typeOfSkin = 'PEN';
93+
9194
/** @type {WebGLTexture} */
9295
this._texture = null;
9396

src/RenderWebGL.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,9 +1316,15 @@ class RenderWebGL extends EventEmitter {
13161316

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

1321+
if (drawable._skin.typeOfSkin === 'BITMAP') {
1322+
aabb = drawable.getAABB();
1323+
} else {
1324+
aabb = drawable.getFastBounds();
1325+
}
1326+
1327+
const inset = Math.floor(Math.min(aabb.width, aabb.height) / 2);
13221328
const sx = this._xRight - Math.min(FENCE_WIDTH, inset);
13231329
if (aabb.right + dx < -sx) {
13241330
x = Math.ceil(drawable._position[0] - (sx + aabb.right));

src/SVGSkin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class SVGSkin extends Skin {
3030

3131
/** @type {Number} */
3232
this._maxTextureScale = 0;
33+
34+
/** @type {string} */
35+
this._typeOfSkin = 'SVG';
3336
}
3437

3538
/**

src/Skin.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class Skin extends EventEmitter {
3030
/** @type {int} */
3131
this._id = id;
3232

33+
/** @type {string} */
34+
this._typeOfSkin = 'SKIN';
35+
3336
/** @type {Vec3} */
3437
this._rotationCenter = twgl.v3.create(0, 0);
3538

@@ -98,6 +101,14 @@ class Skin extends EventEmitter {
98101
return [0, 0];
99102
}
100103

104+
/**
105+
* @abstract
106+
* @return {string} the type of skin, as determined by the class's properties.
107+
*/
108+
get typeOfSkin () {
109+
return this._typeOfSkin;
110+
}
111+
101112
/**
102113
* Set the origin, in object space, about which this Skin should rotate.
103114
* @param {number} x - The x coordinate of the new rotation center.
28 KB
Binary file not shown.

0 commit comments

Comments
 (0)