diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 3a472be..75eb069 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -552,15 +552,22 @@ this.noFrame = false; - if (frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height) + const { x, y, width, height } = frame; + const xNotFit = x + width > this.baseTexture.width; + const yNotFit = y + height > this.baseTexture.height; + + if (xNotFit || yNotFit) { + const relationship = xNotFit && yNotFit ? 'and' : 'or'; + const errorX = `X: ${x} + ${width} = ${x + width} > ${this.baseTexture.width}`; + const errorY = `Y: ${y} + ${height} = ${y + height} > ${this.baseTexture.height}`; + throw new Error('Texture Error: frame does not fit inside the base Texture dimensions: ' - + `X: ${frame.x} + ${frame.width} = ${frame.x + frame.width} > ${this.baseTexture.width} ` - + `Y: ${frame.y} + ${frame.height} = ${frame.y + frame.height} > ${this.baseTexture.height}`); + + `${errorX} ${relationship} ${errorY}`); } - // this.valid = frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded; - this.valid = frame && frame.width && frame.height && this.baseTexture.hasLoaded; + // this.valid = width && height && this.baseTexture.source && this.baseTexture.hasLoaded; + this.valid = width && height && this.baseTexture.hasLoaded; if (!this.trim && !this.rotate) {