Skip to content

Commit 60c6aa4

Browse files
author
andrewstart
committed
Fixed Sprite hit testing and RenderTextures at different resolutions.
1 parent b0bec22 commit 60c6aa4

File tree

6 files changed

+49
-36
lines changed

6 files changed

+49
-36
lines changed

bin/pixi.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,7 +3802,6 @@ if ('undefined' !== typeof module) {
38023802

38033803
},{}],11:[function(require,module,exports){
38043804
'use strict';
3805-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
38063805

38073806
function ToObject(val) {
38083807
if (val == null) {
@@ -3812,26 +3811,14 @@ function ToObject(val) {
38123811
return Object(val);
38133812
}
38143813

3815-
function ownEnumerableKeys(obj) {
3816-
var keys = Object.getOwnPropertyNames(obj);
3817-
3818-
if (Object.getOwnPropertySymbols) {
3819-
keys = keys.concat(Object.getOwnPropertySymbols(obj));
3820-
}
3821-
3822-
return keys.filter(function (key) {
3823-
return propIsEnumerable.call(obj, key);
3824-
});
3825-
}
3826-
38273814
module.exports = Object.assign || function (target, source) {
38283815
var from;
38293816
var keys;
38303817
var to = ToObject(target);
38313818

38323819
for (var s = 1; s < arguments.length; s++) {
38333820
from = arguments[s];
3834-
keys = ownEnumerableKeys(Object(from));
3821+
keys = Object.keys(Object(from));
38353822

38363823
for (var i = 0; i < keys.length; i++) {
38373824
to[keys[i]] = from[keys[i]];
@@ -15916,8 +15903,8 @@ Sprite.prototype.containsPoint = function( point )
1591615903
{
1591715904
this.worldTransform.applyInverse(point, tempPoint);
1591815905

15919-
var width = this._texture._frame.width;
15920-
var height = this._texture._frame.height;
15906+
var width = this._texture.width;
15907+
var height = this._texture.height;
1592115908
var x1 = -width * this.anchor.x;
1592215909
var y1;
1592315910

@@ -17748,14 +17735,16 @@ function RenderTexture(renderer, width, height, scaleMode, resolution)
1774817735
var baseTexture = new BaseTexture();
1774917736
baseTexture.width = width;
1775017737
baseTexture.height = height;
17738+
baseTexture.realWidth = width * resolution;
17739+
baseTexture.realHeight = height * resolution;
1775117740
baseTexture.resolution = resolution;
1775217741
baseTexture.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT;
1775317742
baseTexture.hasLoaded = true;
1775417743

1775517744

1775617745
Texture.call(this,
1775717746
baseTexture,
17758-
new math.Rectangle(0, 0, width, height)
17747+
new math.Rectangle(0, 0, baseTexture.realWidth, baseTexture.realHeight)
1775917748
);
1776017749

1776117750

@@ -17874,11 +17863,15 @@ RenderTexture.prototype.resize = function (width, height, updateBase)
1787417863

1787517864
this.valid = (width > 0 && height > 0);
1787617865

17877-
this.width = this._frame.width = this.crop.width = width;
17878-
this.height = this._frame.height = this.crop.height = height;
17866+
this.width = width;
17867+
this.height = height;
17868+
this._frame.width = this.crop.width = width * this.resolution;
17869+
this._frame.height = this.crop.height = height * this.resolution;
1787917870

1788017871
if (updateBase)
1788117872
{
17873+
this.baseTexture.realWidth = width * this.resolution;
17874+
this.baseTexture.realHeight = height * this.resolution;
1788217875
this.baseTexture.width = this.width;
1788317876
this.baseTexture.height = this.height;
1788417877
}
@@ -17888,7 +17881,14 @@ RenderTexture.prototype.resize = function (width, height, updateBase)
1788817881
return;
1788917882
}
1789017883

17891-
this.textureBuffer.resize(this.width, this.height);
17884+
if (this.renderer.type === CONST.RENDERER_TYPE.WEBGL)
17885+
{
17886+
this.textureBuffer.resize(this.width, this.height);
17887+
}
17888+
else
17889+
{
17890+
this.textureBuffer.resize(this.baseTexture.realWidth, this.baseTexture.realHeight);
17891+
}
1789217892

1789317893
if(this.filterManager)
1789417894
{
@@ -26609,4 +26609,4 @@ if (!global.cancelAnimationFrame) {
2660926609
});
2661026610

2661126611

26612-
//# sourceMappingURL=pixi.js.map
26612+
//# sourceMappingURL=pixi.js.map

bin/pixi.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/pixi.min.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/pixi.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/sprites/Sprite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ Sprite.prototype.containsPoint = function( point )
345345
{
346346
this.worldTransform.applyInverse(point, tempPoint);
347347

348-
var width = this._texture._frame.width;
349-
var height = this._texture._frame.height;
348+
var width = this._texture.width;
349+
var height = this._texture.height;
350350
var x1 = -width * this.anchor.x;
351351
var y1;
352352

src/core/textures/RenderTexture.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ function RenderTexture(renderer, width, height, scaleMode, resolution)
6767
var baseTexture = new BaseTexture();
6868
baseTexture.width = width;
6969
baseTexture.height = height;
70+
baseTexture.realWidth = width * resolution;
71+
baseTexture.realHeight = height * resolution;
7072
baseTexture.resolution = resolution;
7173
baseTexture.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT;
7274
baseTexture.hasLoaded = true;
7375

7476

7577
Texture.call(this,
7678
baseTexture,
77-
new math.Rectangle(0, 0, width, height)
79+
new math.Rectangle(0, 0, baseTexture.realWidth, baseTexture.realHeight)
7880
);
7981

8082

@@ -193,11 +195,15 @@ RenderTexture.prototype.resize = function (width, height, updateBase)
193195

194196
this.valid = (width > 0 && height > 0);
195197

196-
this.width = this._frame.width = this.crop.width = width;
197-
this.height = this._frame.height = this.crop.height = height;
198+
this.width = width;
199+
this.height = height;
200+
this._frame.width = this.crop.width = width * this.resolution;
201+
this._frame.height = this.crop.height = height * this.resolution;
198202

199203
if (updateBase)
200204
{
205+
this.baseTexture.realWidth = width * this.resolution;
206+
this.baseTexture.realHeight = height * this.resolution;
201207
this.baseTexture.width = this.width;
202208
this.baseTexture.height = this.height;
203209
}
@@ -207,7 +213,14 @@ RenderTexture.prototype.resize = function (width, height, updateBase)
207213
return;
208214
}
209215

210-
this.textureBuffer.resize(this.width, this.height);
216+
if (this.renderer.type === CONST.RENDERER_TYPE.WEBGL)
217+
{
218+
this.textureBuffer.resize(this.width, this.height);
219+
}
220+
else
221+
{
222+
this.textureBuffer.resize(this.baseTexture.realWidth, this.baseTexture.realHeight);
223+
}
211224

212225
if(this.filterManager)
213226
{

0 commit comments

Comments
 (0)