From 1f940a21a7fa66a6875762492758002f20e4c2a1 Mon Sep 17 00:00:00 2001 From: Tom Beddard Date: Sun, 9 Jun 2013 22:41:08 +0100 Subject: [PATCH] Added an option to catch image load errors on textures --- src/core/Texture.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/Texture.js b/src/core/Texture.js index face378..bbbf975 100644 --- a/src/core/Texture.js +++ b/src/core/Texture.js @@ -23,6 +23,7 @@ GLOW.Texture = (function() { this.width = parameters.width; this.height = parameters.height; this.onLoadComplete = parameters.onLoadComplete; + this.onLoadError = parameters.onLoadError; this.onLoadContext = parameters.onLoadContext; this.texture = undefined; } @@ -50,6 +51,7 @@ GLOW.Texture = (function() { lowerCaseURL.indexOf( "jpeg" ) !== -1 ) { this.data = new Image(); this.data.scope = this; + this.data.onerror = this.onLoadError; this.data.onload = this.onLoadImage; this.data.src = originalURL; } else { @@ -215,6 +217,12 @@ GLOW.Texture = (function() { } }; + GLOWTexture.prototype.onLoadError = function() { + if( this.scope.onLoadError ) { + this.scope.onLoadError.call( this.scope.onLoadContext, this.scope ); + } + }; + GLOWTexture.prototype.onLoadCubeImage = function() { this.scope.itemsToLoad--; if( this.scope.itemsToLoad === 0 ) {