diff --git a/src/game-lib-d3-texture.js b/src/game-lib-d3-texture.js index 3278c6c..25267df 100644 --- a/src/game-lib-d3-texture.js +++ b/src/game-lib-d3-texture.js @@ -203,15 +203,18 @@ GameLib.D3.Texture.prototype.createInstance = function() { } else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_NORMAL) { - if (GameLib.Utils.UndefinedOrNull(this.image)) { + if ( + GameLib.Utils.UndefinedOrNull(this.image) || + GameLib.Utils.UndefinedOrNull(this.image.instance) + ) { this.instance = new THREE.Texture(); } else { - if (GameLib.Utils.UndefinedOrNull(this.image.instance)) { - throw new Error('no image instance'); - } + //if (GameLib.Utils.UndefinedOrNull(this.image.instance)) { + // throw new Error('no image instance'); + //} this.instance = new THREE.Texture( this.image.instance @@ -304,7 +307,26 @@ GameLib.D3.Texture.prototype.updateInstance = function() { } else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_CANVAS) { - console.log('todo : canvas change check here'); + if ( + GameLib.Utils.UndefinedOrNull(this.canvas) && + this.instance.canvas + ) { + try { + this.createInstance(); + imageChanged = true; + } catch (error) { + console.error(error); + } + } + + if (this.canvas && this.canvas.instance && this.instance.image !== this.canvas.instance) { + try { + this.createInstance(); + imageChanged = true; + } catch (error) { + console.error(error); + } + } } else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_CUBE) {