diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/sprites/webgl/texture.vert b/src/core/sprites/webgl/texture.vert index a807596..81817b1 100644 --- a/src/core/sprites/webgl/texture.vert +++ b/src/core/sprites/webgl/texture.vert @@ -1,3 +1,4 @@ +precision highp float; attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; attribute vec4 aColor; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/sprites/webgl/texture.vert b/src/core/sprites/webgl/texture.vert index a807596..81817b1 100644 --- a/src/core/sprites/webgl/texture.vert +++ b/src/core/sprites/webgl/texture.vert @@ -1,3 +1,4 @@ +precision highp float; attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; attribute vec4 aColor; diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 3aa3182..a47a902 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -158,12 +158,10 @@ width += style.dropShadowDistance; } - width += style.padding * 2; - - this.canvas.width = Math.ceil((width + this.context.lineWidth) * this.resolution); + this.canvas.width = Math.ceil((width + (style.padding * 2)) * this.resolution); // calculate text height - const lineHeight = this.style.lineHeight || fontProperties.fontSize + style.strokeThickness; + const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + ((lines.length - 1) * lineHeight); @@ -173,7 +171,7 @@ height += style.dropShadowDistance; } - this.canvas.height = Math.ceil((height + (this._style.padding * 2)) * this.resolution); + this.canvas.height = Math.ceil((height + (style.padding * 2)) * this.resolution); this.context.scale(this.resolution, this.resolution); @@ -405,8 +403,9 @@ // Greedy wrapping algorithm that will wrap words as the line grows longer // than its horizontal bounds. let result = ''; + const style = this._style; const lines = text.split('\n'); - const wordWrapWidth = this._style.wordWrapWidth; + const wordWrapWidth = style.wordWrapWidth; for (let i = 0; i < lines.length; i++) { @@ -417,7 +416,7 @@ { const wordWidth = this.context.measureText(words[j]).width; - if (this._style.breakWords && wordWidth > wordWrapWidth) + if (style.breakWords && wordWidth > wordWrapWidth) { // Word should be split in the middle const characters = words[j].split(''); diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/sprites/webgl/texture.vert b/src/core/sprites/webgl/texture.vert index a807596..81817b1 100644 --- a/src/core/sprites/webgl/texture.vert +++ b/src/core/sprites/webgl/texture.vert @@ -1,3 +1,4 @@ +precision highp float; attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; attribute vec4 aColor; diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 3aa3182..a47a902 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -158,12 +158,10 @@ width += style.dropShadowDistance; } - width += style.padding * 2; - - this.canvas.width = Math.ceil((width + this.context.lineWidth) * this.resolution); + this.canvas.width = Math.ceil((width + (style.padding * 2)) * this.resolution); // calculate text height - const lineHeight = this.style.lineHeight || fontProperties.fontSize + style.strokeThickness; + const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + ((lines.length - 1) * lineHeight); @@ -173,7 +171,7 @@ height += style.dropShadowDistance; } - this.canvas.height = Math.ceil((height + (this._style.padding * 2)) * this.resolution); + this.canvas.height = Math.ceil((height + (style.padding * 2)) * this.resolution); this.context.scale(this.resolution, this.resolution); @@ -405,8 +403,9 @@ // Greedy wrapping algorithm that will wrap words as the line grows longer // than its horizontal bounds. let result = ''; + const style = this._style; const lines = text.split('\n'); - const wordWrapWidth = this._style.wordWrapWidth; + const wordWrapWidth = style.wordWrapWidth; for (let i = 0; i < lines.length; i++) { @@ -417,7 +416,7 @@ { const wordWidth = this.context.measureText(words[j]).width; - if (this._style.breakWords && wordWidth > wordWrapWidth) + if (style.breakWords && wordWidth > wordWrapWidth) { // Word should be split in the middle const characters = words[j].split(''); diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index a8bcfba..3393cd2 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -70,6 +70,14 @@ * @default 'tilingSprite' */ this.pluginName = 'tilingSprite'; + + /** + * Whether or not anchor affects uvs + * + * @member {boolean} + * @default false + */ + this.uvRespectAnchor = false; } /** * Changes frame clamping in corresponding textureTransform, shortcut diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/sprites/webgl/texture.vert b/src/core/sprites/webgl/texture.vert index a807596..81817b1 100644 --- a/src/core/sprites/webgl/texture.vert +++ b/src/core/sprites/webgl/texture.vert @@ -1,3 +1,4 @@ +precision highp float; attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; attribute vec4 aColor; diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 3aa3182..a47a902 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -158,12 +158,10 @@ width += style.dropShadowDistance; } - width += style.padding * 2; - - this.canvas.width = Math.ceil((width + this.context.lineWidth) * this.resolution); + this.canvas.width = Math.ceil((width + (style.padding * 2)) * this.resolution); // calculate text height - const lineHeight = this.style.lineHeight || fontProperties.fontSize + style.strokeThickness; + const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + ((lines.length - 1) * lineHeight); @@ -173,7 +171,7 @@ height += style.dropShadowDistance; } - this.canvas.height = Math.ceil((height + (this._style.padding * 2)) * this.resolution); + this.canvas.height = Math.ceil((height + (style.padding * 2)) * this.resolution); this.context.scale(this.resolution, this.resolution); @@ -405,8 +403,9 @@ // Greedy wrapping algorithm that will wrap words as the line grows longer // than its horizontal bounds. let result = ''; + const style = this._style; const lines = text.split('\n'); - const wordWrapWidth = this._style.wordWrapWidth; + const wordWrapWidth = style.wordWrapWidth; for (let i = 0; i < lines.length; i++) { @@ -417,7 +416,7 @@ { const wordWidth = this.context.measureText(words[j]).width; - if (this._style.breakWords && wordWidth > wordWrapWidth) + if (style.breakWords && wordWidth > wordWrapWidth) { // Word should be split in the middle const characters = words[j].split(''); diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index a8bcfba..3393cd2 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -70,6 +70,14 @@ * @default 'tilingSprite' */ this.pluginName = 'tilingSprite'; + + /** + * Whether or not anchor affects uvs + * + * @member {boolean} + * @default false + */ + this.uvRespectAnchor = false; } /** * Changes frame clamping in corresponding textureTransform, shortcut diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 70ed184..18043a7 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -280,7 +280,7 @@ // need to set // const m = _tempMatrix; - this.transform.worldTransform.copy(m); + this.transform.localTransform.copy(m); m.invert(); m.tx -= bounds.x; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/sprites/webgl/texture.vert b/src/core/sprites/webgl/texture.vert index a807596..81817b1 100644 --- a/src/core/sprites/webgl/texture.vert +++ b/src/core/sprites/webgl/texture.vert @@ -1,3 +1,4 @@ +precision highp float; attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; attribute vec4 aColor; diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 3aa3182..a47a902 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -158,12 +158,10 @@ width += style.dropShadowDistance; } - width += style.padding * 2; - - this.canvas.width = Math.ceil((width + this.context.lineWidth) * this.resolution); + this.canvas.width = Math.ceil((width + (style.padding * 2)) * this.resolution); // calculate text height - const lineHeight = this.style.lineHeight || fontProperties.fontSize + style.strokeThickness; + const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + ((lines.length - 1) * lineHeight); @@ -173,7 +171,7 @@ height += style.dropShadowDistance; } - this.canvas.height = Math.ceil((height + (this._style.padding * 2)) * this.resolution); + this.canvas.height = Math.ceil((height + (style.padding * 2)) * this.resolution); this.context.scale(this.resolution, this.resolution); @@ -405,8 +403,9 @@ // Greedy wrapping algorithm that will wrap words as the line grows longer // than its horizontal bounds. let result = ''; + const style = this._style; const lines = text.split('\n'); - const wordWrapWidth = this._style.wordWrapWidth; + const wordWrapWidth = style.wordWrapWidth; for (let i = 0; i < lines.length; i++) { @@ -417,7 +416,7 @@ { const wordWidth = this.context.measureText(words[j]).width; - if (this._style.breakWords && wordWidth > wordWrapWidth) + if (style.breakWords && wordWidth > wordWrapWidth) { // Word should be split in the middle const characters = words[j].split(''); diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index a8bcfba..3393cd2 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -70,6 +70,14 @@ * @default 'tilingSprite' */ this.pluginName = 'tilingSprite'; + + /** + * Whether or not anchor affects uvs + * + * @member {boolean} + * @default false + */ + this.uvRespectAnchor = false; } /** * Changes frame clamping in corresponding textureTransform, shortcut diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 70ed184..18043a7 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -280,7 +280,7 @@ // need to set // const m = _tempMatrix; - this.transform.worldTransform.copy(m); + this.transform.localTransform.copy(m); m.invert(); m.tx -= bounds.x; diff --git a/src/extras/webgl/TilingSpriteRenderer.js b/src/extras/webgl/TilingSpriteRenderer.js index b782038..dcf24cc 100644 --- a/src/extras/webgl/TilingSpriteRenderer.js +++ b/src/extras/webgl/TilingSpriteRenderer.js @@ -68,13 +68,16 @@ vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); - vertices = quad.uvs; + if (ts.uvRespectAnchor) + { + vertices = quad.uvs; - vertices[0] = vertices[6] = -ts.anchor.x; - vertices[1] = vertices[3] = -ts.anchor.y; + vertices[0] = vertices[6] = -ts.anchor.x; + vertices[1] = vertices[3] = -ts.anchor.y; - vertices[2] = vertices[4] = 1.0 - ts.anchor.x; - vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + vertices[2] = vertices[4] = 1.0 - ts.anchor.x; + vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + } quad.upload(); diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/sprites/webgl/texture.vert b/src/core/sprites/webgl/texture.vert index a807596..81817b1 100644 --- a/src/core/sprites/webgl/texture.vert +++ b/src/core/sprites/webgl/texture.vert @@ -1,3 +1,4 @@ +precision highp float; attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; attribute vec4 aColor; diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 3aa3182..a47a902 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -158,12 +158,10 @@ width += style.dropShadowDistance; } - width += style.padding * 2; - - this.canvas.width = Math.ceil((width + this.context.lineWidth) * this.resolution); + this.canvas.width = Math.ceil((width + (style.padding * 2)) * this.resolution); // calculate text height - const lineHeight = this.style.lineHeight || fontProperties.fontSize + style.strokeThickness; + const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + ((lines.length - 1) * lineHeight); @@ -173,7 +171,7 @@ height += style.dropShadowDistance; } - this.canvas.height = Math.ceil((height + (this._style.padding * 2)) * this.resolution); + this.canvas.height = Math.ceil((height + (style.padding * 2)) * this.resolution); this.context.scale(this.resolution, this.resolution); @@ -405,8 +403,9 @@ // Greedy wrapping algorithm that will wrap words as the line grows longer // than its horizontal bounds. let result = ''; + const style = this._style; const lines = text.split('\n'); - const wordWrapWidth = this._style.wordWrapWidth; + const wordWrapWidth = style.wordWrapWidth; for (let i = 0; i < lines.length; i++) { @@ -417,7 +416,7 @@ { const wordWidth = this.context.measureText(words[j]).width; - if (this._style.breakWords && wordWidth > wordWrapWidth) + if (style.breakWords && wordWidth > wordWrapWidth) { // Word should be split in the middle const characters = words[j].split(''); diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index a8bcfba..3393cd2 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -70,6 +70,14 @@ * @default 'tilingSprite' */ this.pluginName = 'tilingSprite'; + + /** + * Whether or not anchor affects uvs + * + * @member {boolean} + * @default false + */ + this.uvRespectAnchor = false; } /** * Changes frame clamping in corresponding textureTransform, shortcut diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 70ed184..18043a7 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -280,7 +280,7 @@ // need to set // const m = _tempMatrix; - this.transform.worldTransform.copy(m); + this.transform.localTransform.copy(m); m.invert(); m.tx -= bounds.x; diff --git a/src/extras/webgl/TilingSpriteRenderer.js b/src/extras/webgl/TilingSpriteRenderer.js index b782038..dcf24cc 100644 --- a/src/extras/webgl/TilingSpriteRenderer.js +++ b/src/extras/webgl/TilingSpriteRenderer.js @@ -68,13 +68,16 @@ vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); - vertices = quad.uvs; + if (ts.uvRespectAnchor) + { + vertices = quad.uvs; - vertices[0] = vertices[6] = -ts.anchor.x; - vertices[1] = vertices[3] = -ts.anchor.y; + vertices[0] = vertices[6] = -ts.anchor.x; + vertices[1] = vertices[3] = -ts.anchor.y; - vertices[2] = vertices[4] = 1.0 - ts.anchor.x; - vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + vertices[2] = vertices[4] = 1.0 - ts.anchor.x; + vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + } quad.upload(); diff --git a/src/index.js b/src/index.js index 63595bc..59356cf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ -// import polyfills -import './polyfill'; +// import polyfills. Done as an export to make sure polyfills are imported first +export * from './polyfill'; // export core export * from './deprecation'; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/sprites/webgl/texture.vert b/src/core/sprites/webgl/texture.vert index a807596..81817b1 100644 --- a/src/core/sprites/webgl/texture.vert +++ b/src/core/sprites/webgl/texture.vert @@ -1,3 +1,4 @@ +precision highp float; attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; attribute vec4 aColor; diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 3aa3182..a47a902 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -158,12 +158,10 @@ width += style.dropShadowDistance; } - width += style.padding * 2; - - this.canvas.width = Math.ceil((width + this.context.lineWidth) * this.resolution); + this.canvas.width = Math.ceil((width + (style.padding * 2)) * this.resolution); // calculate text height - const lineHeight = this.style.lineHeight || fontProperties.fontSize + style.strokeThickness; + const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + ((lines.length - 1) * lineHeight); @@ -173,7 +171,7 @@ height += style.dropShadowDistance; } - this.canvas.height = Math.ceil((height + (this._style.padding * 2)) * this.resolution); + this.canvas.height = Math.ceil((height + (style.padding * 2)) * this.resolution); this.context.scale(this.resolution, this.resolution); @@ -405,8 +403,9 @@ // Greedy wrapping algorithm that will wrap words as the line grows longer // than its horizontal bounds. let result = ''; + const style = this._style; const lines = text.split('\n'); - const wordWrapWidth = this._style.wordWrapWidth; + const wordWrapWidth = style.wordWrapWidth; for (let i = 0; i < lines.length; i++) { @@ -417,7 +416,7 @@ { const wordWidth = this.context.measureText(words[j]).width; - if (this._style.breakWords && wordWidth > wordWrapWidth) + if (style.breakWords && wordWidth > wordWrapWidth) { // Word should be split in the middle const characters = words[j].split(''); diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index a8bcfba..3393cd2 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -70,6 +70,14 @@ * @default 'tilingSprite' */ this.pluginName = 'tilingSprite'; + + /** + * Whether or not anchor affects uvs + * + * @member {boolean} + * @default false + */ + this.uvRespectAnchor = false; } /** * Changes frame clamping in corresponding textureTransform, shortcut diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 70ed184..18043a7 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -280,7 +280,7 @@ // need to set // const m = _tempMatrix; - this.transform.worldTransform.copy(m); + this.transform.localTransform.copy(m); m.invert(); m.tx -= bounds.x; diff --git a/src/extras/webgl/TilingSpriteRenderer.js b/src/extras/webgl/TilingSpriteRenderer.js index b782038..dcf24cc 100644 --- a/src/extras/webgl/TilingSpriteRenderer.js +++ b/src/extras/webgl/TilingSpriteRenderer.js @@ -68,13 +68,16 @@ vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); - vertices = quad.uvs; + if (ts.uvRespectAnchor) + { + vertices = quad.uvs; - vertices[0] = vertices[6] = -ts.anchor.x; - vertices[1] = vertices[3] = -ts.anchor.y; + vertices[0] = vertices[6] = -ts.anchor.x; + vertices[1] = vertices[3] = -ts.anchor.y; - vertices[2] = vertices[4] = 1.0 - ts.anchor.x; - vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + vertices[2] = vertices[4] = 1.0 - ts.anchor.x; + vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + } quad.upload(); diff --git a/src/index.js b/src/index.js index 63595bc..59356cf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ -// import polyfills -import './polyfill'; +// import polyfills. Done as an export to make sure polyfills are imported first +export * from './polyfill'; // export core export * from './deprecation'; diff --git a/src/mesh/geometry/Buffer.js b/src/mesh/geometry/Buffer.js index 72c361b..c8b5f56 100644 --- a/src/mesh/geometry/Buffer.js +++ b/src/mesh/geometry/Buffer.js @@ -67,6 +67,10 @@ static from(data) { + if(data instanceof Array) + { + data = new Float32Array(data); + } return new Buffer(data); } } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/sprites/webgl/texture.vert b/src/core/sprites/webgl/texture.vert index a807596..81817b1 100644 --- a/src/core/sprites/webgl/texture.vert +++ b/src/core/sprites/webgl/texture.vert @@ -1,3 +1,4 @@ +precision highp float; attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; attribute vec4 aColor; diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 3aa3182..a47a902 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -158,12 +158,10 @@ width += style.dropShadowDistance; } - width += style.padding * 2; - - this.canvas.width = Math.ceil((width + this.context.lineWidth) * this.resolution); + this.canvas.width = Math.ceil((width + (style.padding * 2)) * this.resolution); // calculate text height - const lineHeight = this.style.lineHeight || fontProperties.fontSize + style.strokeThickness; + const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + ((lines.length - 1) * lineHeight); @@ -173,7 +171,7 @@ height += style.dropShadowDistance; } - this.canvas.height = Math.ceil((height + (this._style.padding * 2)) * this.resolution); + this.canvas.height = Math.ceil((height + (style.padding * 2)) * this.resolution); this.context.scale(this.resolution, this.resolution); @@ -405,8 +403,9 @@ // Greedy wrapping algorithm that will wrap words as the line grows longer // than its horizontal bounds. let result = ''; + const style = this._style; const lines = text.split('\n'); - const wordWrapWidth = this._style.wordWrapWidth; + const wordWrapWidth = style.wordWrapWidth; for (let i = 0; i < lines.length; i++) { @@ -417,7 +416,7 @@ { const wordWidth = this.context.measureText(words[j]).width; - if (this._style.breakWords && wordWidth > wordWrapWidth) + if (style.breakWords && wordWidth > wordWrapWidth) { // Word should be split in the middle const characters = words[j].split(''); diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index a8bcfba..3393cd2 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -70,6 +70,14 @@ * @default 'tilingSprite' */ this.pluginName = 'tilingSprite'; + + /** + * Whether or not anchor affects uvs + * + * @member {boolean} + * @default false + */ + this.uvRespectAnchor = false; } /** * Changes frame clamping in corresponding textureTransform, shortcut diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 70ed184..18043a7 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -280,7 +280,7 @@ // need to set // const m = _tempMatrix; - this.transform.worldTransform.copy(m); + this.transform.localTransform.copy(m); m.invert(); m.tx -= bounds.x; diff --git a/src/extras/webgl/TilingSpriteRenderer.js b/src/extras/webgl/TilingSpriteRenderer.js index b782038..dcf24cc 100644 --- a/src/extras/webgl/TilingSpriteRenderer.js +++ b/src/extras/webgl/TilingSpriteRenderer.js @@ -68,13 +68,16 @@ vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); - vertices = quad.uvs; + if (ts.uvRespectAnchor) + { + vertices = quad.uvs; - vertices[0] = vertices[6] = -ts.anchor.x; - vertices[1] = vertices[3] = -ts.anchor.y; + vertices[0] = vertices[6] = -ts.anchor.x; + vertices[1] = vertices[3] = -ts.anchor.y; - vertices[2] = vertices[4] = 1.0 - ts.anchor.x; - vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + vertices[2] = vertices[4] = 1.0 - ts.anchor.x; + vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + } quad.upload(); diff --git a/src/index.js b/src/index.js index 63595bc..59356cf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ -// import polyfills -import './polyfill'; +// import polyfills. Done as an export to make sure polyfills are imported first +export * from './polyfill'; // export core export * from './deprecation'; diff --git a/src/mesh/geometry/Buffer.js b/src/mesh/geometry/Buffer.js index 72c361b..c8b5f56 100644 --- a/src/mesh/geometry/Buffer.js +++ b/src/mesh/geometry/Buffer.js @@ -67,6 +67,10 @@ static from(data) { + if(data instanceof Array) + { + data = new Float32Array(data); + } return new Buffer(data); } } diff --git a/src/mesh/geometry/Geometry.js b/src/mesh/geometry/Geometry.js index 60bd81f..0c2f8df 100644 --- a/src/mesh/geometry/Geometry.js +++ b/src/mesh/geometry/Geometry.js @@ -23,6 +23,11 @@ if (!buffer.data) { // its an array! + if(buffer instanceof Array) + { + buffer = new Float32Array(buffer); + } + buffer = new Buffer(buffer); } @@ -42,6 +47,11 @@ if (!buffer.data) { // its an array! + if(buffer instanceof Array) + { + buffer = new Uint16Array(buffer); + } + buffer = new Buffer(buffer); } diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 3adcdd2..c163a11 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -523,6 +523,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 45f7ab1..95f2af4 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -1121,6 +1121,10 @@ * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) { diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 1c7ad70..836f109 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -135,7 +135,7 @@ this.vaos[i].addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } - /* eslint-disable max-len */ + /* eslint-enable max-len */ } this.vao = this.vaos[0]; @@ -353,9 +353,11 @@ uint32View[index + 12] = uvs[2]; uint32View[index + 17] = uvs[3]; + /* eslint-disable max-len */ uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = sprite._tintRGB + (Math.min(sprite.worldAlpha, 1) * 255 << 24); float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; + /* eslint-enable max-len */ index += 20; } @@ -371,6 +373,8 @@ this.vaoMax++; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); + /* eslint-disable max-len */ + // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) @@ -378,6 +382,8 @@ .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + + /* eslint-enable max-len */ } this.renderer.bindVao(this.vaos[this.vertexCount]); diff --git a/src/core/sprites/webgl/texture.vert b/src/core/sprites/webgl/texture.vert index a807596..81817b1 100644 --- a/src/core/sprites/webgl/texture.vert +++ b/src/core/sprites/webgl/texture.vert @@ -1,3 +1,4 @@ +precision highp float; attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; attribute vec4 aColor; diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 3aa3182..a47a902 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -158,12 +158,10 @@ width += style.dropShadowDistance; } - width += style.padding * 2; - - this.canvas.width = Math.ceil((width + this.context.lineWidth) * this.resolution); + this.canvas.width = Math.ceil((width + (style.padding * 2)) * this.resolution); // calculate text height - const lineHeight = this.style.lineHeight || fontProperties.fontSize + style.strokeThickness; + const lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; let height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + ((lines.length - 1) * lineHeight); @@ -173,7 +171,7 @@ height += style.dropShadowDistance; } - this.canvas.height = Math.ceil((height + (this._style.padding * 2)) * this.resolution); + this.canvas.height = Math.ceil((height + (style.padding * 2)) * this.resolution); this.context.scale(this.resolution, this.resolution); @@ -405,8 +403,9 @@ // Greedy wrapping algorithm that will wrap words as the line grows longer // than its horizontal bounds. let result = ''; + const style = this._style; const lines = text.split('\n'); - const wordWrapWidth = this._style.wordWrapWidth; + const wordWrapWidth = style.wordWrapWidth; for (let i = 0; i < lines.length; i++) { @@ -417,7 +416,7 @@ { const wordWidth = this.context.measureText(words[j]).width; - if (this._style.breakWords && wordWidth > wordWrapWidth) + if (style.breakWords && wordWidth > wordWrapWidth) { // Word should be split in the middle const characters = words[j].split(''); diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index a8bcfba..3393cd2 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -70,6 +70,14 @@ * @default 'tilingSprite' */ this.pluginName = 'tilingSprite'; + + /** + * Whether or not anchor affects uvs + * + * @member {boolean} + * @default false + */ + this.uvRespectAnchor = false; } /** * Changes frame clamping in corresponding textureTransform, shortcut diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 70ed184..18043a7 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -280,7 +280,7 @@ // need to set // const m = _tempMatrix; - this.transform.worldTransform.copy(m); + this.transform.localTransform.copy(m); m.invert(); m.tx -= bounds.x; diff --git a/src/extras/webgl/TilingSpriteRenderer.js b/src/extras/webgl/TilingSpriteRenderer.js index b782038..dcf24cc 100644 --- a/src/extras/webgl/TilingSpriteRenderer.js +++ b/src/extras/webgl/TilingSpriteRenderer.js @@ -68,13 +68,16 @@ vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); - vertices = quad.uvs; + if (ts.uvRespectAnchor) + { + vertices = quad.uvs; - vertices[0] = vertices[6] = -ts.anchor.x; - vertices[1] = vertices[3] = -ts.anchor.y; + vertices[0] = vertices[6] = -ts.anchor.x; + vertices[1] = vertices[3] = -ts.anchor.y; - vertices[2] = vertices[4] = 1.0 - ts.anchor.x; - vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + vertices[2] = vertices[4] = 1.0 - ts.anchor.x; + vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + } quad.upload(); diff --git a/src/index.js b/src/index.js index 63595bc..59356cf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ -// import polyfills -import './polyfill'; +// import polyfills. Done as an export to make sure polyfills are imported first +export * from './polyfill'; // export core export * from './deprecation'; diff --git a/src/mesh/geometry/Buffer.js b/src/mesh/geometry/Buffer.js index 72c361b..c8b5f56 100644 --- a/src/mesh/geometry/Buffer.js +++ b/src/mesh/geometry/Buffer.js @@ -67,6 +67,10 @@ static from(data) { + if(data instanceof Array) + { + data = new Float32Array(data); + } return new Buffer(data); } } diff --git a/src/mesh/geometry/Geometry.js b/src/mesh/geometry/Geometry.js index 60bd81f..0c2f8df 100644 --- a/src/mesh/geometry/Geometry.js +++ b/src/mesh/geometry/Geometry.js @@ -23,6 +23,11 @@ if (!buffer.data) { // its an array! + if(buffer instanceof Array) + { + buffer = new Float32Array(buffer); + } + buffer = new Buffer(buffer); } @@ -42,6 +47,11 @@ if (!buffer.data) { // its an array! + if(buffer instanceof Array) + { + buffer = new Uint16Array(buffer); + } + buffer = new Buffer(buffer); } diff --git a/src/particles/ParticleContainer.js b/src/particles/ParticleContainer.js index 42048a8..67796cf 100644 --- a/src/particles/ParticleContainer.js +++ b/src/particles/ParticleContainer.js @@ -328,6 +328,10 @@ * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their * destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite */ destroy(options) {