Skip to content

Commit

Permalink
Added an option to catch image load errors on textures
Browse files Browse the repository at this point in the history
  • Loading branch information
subblue committed Jun 9, 2013
1 parent a51aff9 commit 1f940a2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/Texture.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit 1f940a2

Please sign in to comment.