texture updateInstance fixes
parent
e44e2bd925
commit
04844eecee
|
@ -271,7 +271,7 @@ GameLib.D3.Texture.prototype.createInstance = function() {
|
||||||
/**
|
/**
|
||||||
* Updates the instance with the current state
|
* 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)) {
|
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
|
||||||
try {
|
try {
|
||||||
|
@ -282,81 +282,106 @@ GameLib.D3.Texture.prototype.updateInstance = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var imageChanged = false;
|
if (GameLib.Utils.UndefinedOrNull(property)) {
|
||||||
|
//throw new Error('need to specify a property');
|
||||||
if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_NORMAL) {
|
|
||||||
|
|
||||||
if (
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.image) &&
|
|
||||||
this.instance.image
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
this.createInstance();
|
|
||||||
imageChanged = true;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.image && this.image.instance && this.instance.image !== this.image.instance) {
|
|
||||||
try {
|
|
||||||
this.createInstance();
|
|
||||||
imageChanged = true;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_CANVAS) {
|
|
||||||
|
|
||||||
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) {
|
|
||||||
|
|
||||||
console.log('todo : cube images change check here');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance.name = this.name;
|
if (property === 'image') {
|
||||||
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 (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_NORMAL) {
|
||||||
|
|
||||||
if (imageChanged) {
|
if (
|
||||||
this.publish(
|
GameLib.Utils.UndefinedOrNull(this.image) &&
|
||||||
GameLib.Event.IMAGE_CHANGED,
|
this.instance.image
|
||||||
{
|
) {
|
||||||
texture : this
|
try {
|
||||||
}
|
this.createInstance();
|
||||||
)
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.image && this.image.instance && this.instance.image !== this.image.instance) {
|
||||||
|
try {
|
||||||
|
this.createInstance();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_CANVAS) {
|
||||||
|
|
||||||
|
if (
|
||||||
|
GameLib.Utils.UndefinedOrNull(this.canvas) &&
|
||||||
|
this.instance.canvas
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
this.createInstance();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.canvas && this.canvas.instance && this.instance.image !== this.canvas.instance) {
|
||||||
|
try {
|
||||||
|
this.createInstance();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_CUBE) {
|
||||||
|
|
||||||
|
console.log('todo : cube images change check here');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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
|
* Ok - this image is in use - this should notify materials when its image changes
|
||||||
*/
|
*/
|
||||||
texture.updateInstance();
|
texture.updateInstance('image');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue