texture updateInstance fixes

beta.r3js.org
-=yb4f310 2017-11-13 05:17:21 +01:00
parent e44e2bd925
commit 04844eecee
2 changed files with 98 additions and 73 deletions

View File

@ -271,7 +271,7 @@ GameLib.D3.Texture.prototype.createInstance = function() {
/**
* Updates the instance with the current state
*/
GameLib.D3.Texture.prototype.updateInstance = function() {
GameLib.D3.Texture.prototype.updateInstance = function(property) {
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
try {
@ -282,7 +282,11 @@ GameLib.D3.Texture.prototype.updateInstance = function() {
}
}
var imageChanged = false;
if (GameLib.Utils.UndefinedOrNull(property)) {
//throw new Error('need to specify a property');
}
if (property === 'image') {
if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_NORMAL) {
@ -292,7 +296,6 @@ GameLib.D3.Texture.prototype.updateInstance = function() {
) {
try {
this.createInstance();
imageChanged = true;
} catch (error) {
console.error(error);
}
@ -301,7 +304,6 @@ GameLib.D3.Texture.prototype.updateInstance = function() {
if (this.image && this.image.instance && this.instance.image !== this.image.instance) {
try {
this.createInstance();
imageChanged = true;
} catch (error) {
console.error(error);
}
@ -315,7 +317,6 @@ GameLib.D3.Texture.prototype.updateInstance = function() {
) {
try {
this.createInstance();
imageChanged = true;
} catch (error) {
console.error(error);
}
@ -324,7 +325,6 @@ GameLib.D3.Texture.prototype.updateInstance = function() {
if (this.canvas && this.canvas.instance && this.instance.image !== this.canvas.instance) {
try {
this.createInstance();
imageChanged = true;
} catch (error) {
console.error(error);
}
@ -336,27 +336,52 @@ GameLib.D3.Texture.prototype.updateInstance = function() {
}
this.instance.name = this.name;
this.instance.flipY = this.flipY;
this.instance.encoding = this.encoding;
this.instance.offset.x = this.offset.x;
this.instance.offset.y = this.offset.y;
this.instance.repeat.x = this.repeat.x;
this.instance.repeat.y = this.repeat.y;
this.instance.mapping = this.mapping;
this.instance.format = this.format;
this.instance.wrapS = this.wrapS;
this.instance.wrapT = this.wrapT;
this.instance.needsUpdate = true;
if (imageChanged) {
this.publish(
GameLib.Event.IMAGE_CHANGED,
{
texture : this
}
)
);
this.instance.needsUpdate = true;
}
if (property === 'name') {
this.instance.name = this.name;
}
if (property === 'flipY') {
this.instance.flipY = this.flipY;
}
if (property === 'encoding') {
this.instance.encoding = this.encoding;
}
if (property === 'offset') {
this.instance.offset.x = this.offset.x;
this.instance.offset.y = this.offset.y;
}
if (property === 'repeat') {
this.instance.repeat.x = this.repeat.x;
this.instance.repeat.y = this.repeat.y;
}
if (property === 'mapping') {
this.instance.mapping = this.mapping;
}
if (property === 'format') {
this.instance.format = this.format;
}
if (property === 'wrapS') {
this.instance.wrapS = this.wrapS;
}
if (property === 'wrapT') {
this.instance.wrapT = this.wrapT;
}
};

View File

@ -583,7 +583,7 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) {
/**
* Ok - this image is in use - this should notify materials when its image changes
*/
texture.updateInstance();
texture.updateInstance('image');
}
}
);