diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 684eee3..709b7cf 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -115,14 +115,6 @@ */ this._glTextures = {}; - /** - * Does the texture on the GPU need to be updated? - * - * @member {boolean} - * @private - */ - this._needsUpdate = false; - // if no source passed don't try to load if (source) { @@ -149,23 +141,14 @@ utils.eventTarget.mixin(BaseTexture.prototype); -Object.defineProperties(BaseTexture.prototype, { - needsUpdate: { - get: function () - { - return this._needsUpdate; - }, - set: function (val) - { - this._needsUpdate = val; - - if (val) - { - this.emit('update', this); - } - } - } -}); +/** + * Updates the texture on all the webgl renderers. + * + * @fires update + */ +BaseTexture.prototype.update = function () { + this.emit('update', this); +}; /** * Load a source. @@ -294,7 +277,7 @@ this.width = this.source.naturalWidth || this.source.width; this.height = this.source.naturalHeight || this.source.height; - this.needsUpdate = true; + this.update(); }; /** diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 684eee3..709b7cf 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -115,14 +115,6 @@ */ this._glTextures = {}; - /** - * Does the texture on the GPU need to be updated? - * - * @member {boolean} - * @private - */ - this._needsUpdate = false; - // if no source passed don't try to load if (source) { @@ -149,23 +141,14 @@ utils.eventTarget.mixin(BaseTexture.prototype); -Object.defineProperties(BaseTexture.prototype, { - needsUpdate: { - get: function () - { - return this._needsUpdate; - }, - set: function (val) - { - this._needsUpdate = val; - - if (val) - { - this.emit('update', this); - } - } - } -}); +/** + * Updates the texture on all the webgl renderers. + * + * @fires update + */ +BaseTexture.prototype.update = function () { + this.emit('update', this); +}; /** * Load a source. @@ -294,7 +277,7 @@ this.width = this.source.naturalWidth || this.source.width; this.height = this.source.naturalHeight || this.source.height; - this.needsUpdate = true; + this.update(); }; /** diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 949991d..6eed011 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -125,17 +125,6 @@ eventTarget.mixin(Texture.prototype); Object.defineProperties(Texture.prototype, { - needsUpdate: { - get: function () - { - return this.baseTexture.needsUpdate; - }, - set: function (val) - { - this.baseTexture.needsUpdate = val; - } - }, - frame: { get: function () { @@ -176,6 +165,15 @@ }); /** + * Updates this texture on the gpu. + * + */ +Texture.prototype.update = function () +{ + this.baseTexture.update(); +}; + +/** * Called when the base texture is loaded * * @private diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 684eee3..709b7cf 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -115,14 +115,6 @@ */ this._glTextures = {}; - /** - * Does the texture on the GPU need to be updated? - * - * @member {boolean} - * @private - */ - this._needsUpdate = false; - // if no source passed don't try to load if (source) { @@ -149,23 +141,14 @@ utils.eventTarget.mixin(BaseTexture.prototype); -Object.defineProperties(BaseTexture.prototype, { - needsUpdate: { - get: function () - { - return this._needsUpdate; - }, - set: function (val) - { - this._needsUpdate = val; - - if (val) - { - this.emit('update', this); - } - } - } -}); +/** + * Updates the texture on all the webgl renderers. + * + * @fires update + */ +BaseTexture.prototype.update = function () { + this.emit('update', this); +}; /** * Load a source. @@ -294,7 +277,7 @@ this.width = this.source.naturalWidth || this.source.width; this.height = this.source.naturalHeight || this.source.height; - this.needsUpdate = true; + this.update(); }; /** diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 949991d..6eed011 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -125,17 +125,6 @@ eventTarget.mixin(Texture.prototype); Object.defineProperties(Texture.prototype, { - needsUpdate: { - get: function () - { - return this.baseTexture.needsUpdate; - }, - set: function (val) - { - this.baseTexture.needsUpdate = val; - } - }, - frame: { get: function () { @@ -176,6 +165,15 @@ }); /** + * Updates this texture on the gpu. + * + */ +Texture.prototype.update = function () +{ + this.baseTexture.update(); +}; + +/** * Called when the base texture is loaded * * @private diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index f03ef64..fb658ec 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -56,7 +56,7 @@ if (this.autoUpdate) { window.requestAnimationFrame(this._boundOnUpdate); - this.needsUpdate = true; + this.update(); } }; diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 684eee3..709b7cf 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -115,14 +115,6 @@ */ this._glTextures = {}; - /** - * Does the texture on the GPU need to be updated? - * - * @member {boolean} - * @private - */ - this._needsUpdate = false; - // if no source passed don't try to load if (source) { @@ -149,23 +141,14 @@ utils.eventTarget.mixin(BaseTexture.prototype); -Object.defineProperties(BaseTexture.prototype, { - needsUpdate: { - get: function () - { - return this._needsUpdate; - }, - set: function (val) - { - this._needsUpdate = val; - - if (val) - { - this.emit('update', this); - } - } - } -}); +/** + * Updates the texture on all the webgl renderers. + * + * @fires update + */ +BaseTexture.prototype.update = function () { + this.emit('update', this); +}; /** * Load a source. @@ -294,7 +277,7 @@ this.width = this.source.naturalWidth || this.source.width; this.height = this.source.naturalHeight || this.source.height; - this.needsUpdate = true; + this.update(); }; /** diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 949991d..6eed011 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -125,17 +125,6 @@ eventTarget.mixin(Texture.prototype); Object.defineProperties(Texture.prototype, { - needsUpdate: { - get: function () - { - return this.baseTexture.needsUpdate; - }, - set: function (val) - { - this.baseTexture.needsUpdate = val; - } - }, - frame: { get: function () { @@ -176,6 +165,15 @@ }); /** + * Updates this texture on the gpu. + * + */ +Texture.prototype.update = function () +{ + this.baseTexture.update(); +}; + +/** * Called when the base texture is loaded * * @private diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index f03ef64..fb658ec 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -56,7 +56,7 @@ if (this.autoUpdate) { window.requestAnimationFrame(this._boundOnUpdate); - this.needsUpdate = true; + this.update(); } }; diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index 25b5a0e..4c90363 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -13,7 +13,7 @@ */ function TilingSprite(texture, width, height) { - core.Sprite.call( this, texture); + core.Sprite.call(this, texture); /** * The with of the tiling sprite @@ -129,15 +129,6 @@ if (!this.tilingTexture || this._refreshTexture) { this.generateTilingTexture(true); - - if (this.tilingTexture && this.tilingTexture.needsUpdate) - { - //TODO - tweaking - renderer.updateTexture(this.tilingTexture.baseTexture); - this.tilingTexture.needsUpdate = false; - // this.tilingTexture._uvs = null; - } - } else { @@ -413,7 +404,7 @@ canvasBuffer.resize(targetWidth, targetHeight); this.tilingTexture.baseTexture.width = targetWidth; this.tilingTexture.baseTexture.height = targetHeight; - this.tilingTexture.needsUpdate = true; + this.tilingTexture.update(); } else { diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 684eee3..709b7cf 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -115,14 +115,6 @@ */ this._glTextures = {}; - /** - * Does the texture on the GPU need to be updated? - * - * @member {boolean} - * @private - */ - this._needsUpdate = false; - // if no source passed don't try to load if (source) { @@ -149,23 +141,14 @@ utils.eventTarget.mixin(BaseTexture.prototype); -Object.defineProperties(BaseTexture.prototype, { - needsUpdate: { - get: function () - { - return this._needsUpdate; - }, - set: function (val) - { - this._needsUpdate = val; - - if (val) - { - this.emit('update', this); - } - } - } -}); +/** + * Updates the texture on all the webgl renderers. + * + * @fires update + */ +BaseTexture.prototype.update = function () { + this.emit('update', this); +}; /** * Load a source. @@ -294,7 +277,7 @@ this.width = this.source.naturalWidth || this.source.width; this.height = this.source.naturalHeight || this.source.height; - this.needsUpdate = true; + this.update(); }; /** diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 949991d..6eed011 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -125,17 +125,6 @@ eventTarget.mixin(Texture.prototype); Object.defineProperties(Texture.prototype, { - needsUpdate: { - get: function () - { - return this.baseTexture.needsUpdate; - }, - set: function (val) - { - this.baseTexture.needsUpdate = val; - } - }, - frame: { get: function () { @@ -176,6 +165,15 @@ }); /** + * Updates this texture on the gpu. + * + */ +Texture.prototype.update = function () +{ + this.baseTexture.update(); +}; + +/** * Called when the base texture is loaded * * @private diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index f03ef64..fb658ec 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -56,7 +56,7 @@ if (this.autoUpdate) { window.requestAnimationFrame(this._boundOnUpdate); - this.needsUpdate = true; + this.update(); } }; diff --git a/src/extras/TilingSprite.js b/src/extras/TilingSprite.js index 25b5a0e..4c90363 100644 --- a/src/extras/TilingSprite.js +++ b/src/extras/TilingSprite.js @@ -13,7 +13,7 @@ */ function TilingSprite(texture, width, height) { - core.Sprite.call( this, texture); + core.Sprite.call(this, texture); /** * The with of the tiling sprite @@ -129,15 +129,6 @@ if (!this.tilingTexture || this._refreshTexture) { this.generateTilingTexture(true); - - if (this.tilingTexture && this.tilingTexture.needsUpdate) - { - //TODO - tweaking - renderer.updateTexture(this.tilingTexture.baseTexture); - this.tilingTexture.needsUpdate = false; - // this.tilingTexture._uvs = null; - } - } else { @@ -413,7 +404,7 @@ canvasBuffer.resize(targetWidth, targetHeight); this.tilingTexture.baseTexture.width = targetWidth; this.tilingTexture.baseTexture.height = targetHeight; - this.tilingTexture.needsUpdate = true; + this.tilingTexture.update(); } else { diff --git a/src/text/Text.js b/src/text/Text.js index 161ab71..a6b337a 100644 --- a/src/text/Text.js +++ b/src/text/Text.js @@ -325,7 +325,7 @@ this._width = this.canvas.width; this._height = this.canvas.height; - this.texture.needsUpdate = true; + this.texture.update(); this.dirty = false; };