canvas check for textures

beta.r3js.org
-=yb4f310 2017-10-27 10:08:16 +02:00
parent 4f3f777762
commit 7b963ce085
1 changed files with 27 additions and 5 deletions

View File

@ -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) {