From 8f40160d539d134712e619a5324eb048892e5e89 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Fri, 9 Jun 2017 21:52:18 +0200 Subject: [PATCH] textures working nice --- src/game-lib-d3-image.js | 2 +- src/game-lib-d3-material.js | 3 +-- src/game-lib-d3-texture.js | 16 +++++++++------- src/game-lib-gui.js | 5 +++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/game-lib-d3-image.js b/src/game-lib-d3-image.js index fdafe19..03be687 100644 --- a/src/game-lib-d3-image.js +++ b/src/game-lib-d3-image.js @@ -63,7 +63,7 @@ GameLib.D3.Image.prototype.createInstance = function(update) { loader.path = data.baseUrl; loader.load( - this.path, + this.path + '?ts=' + Date.now(), function ( image ) { this.instance = image; this.publish( diff --git a/src/game-lib-d3-material.js b/src/game-lib-d3-material.js index 5338f7c..a1ab21b 100644 --- a/src/game-lib-d3-material.js +++ b/src/game-lib-d3-material.js @@ -562,6 +562,7 @@ GameLib.D3.Material.prototype.updateStandardMaterialInstance = function() { this.instance.visible = this.visible; this.instance.side = this.side; this.instance.color = this.color.instance; + // this.instance.specular = this.specular.instance; //standard material doesnt have specular color this.instance.roughness = this.roughness; this.instance.metalness = this.metalness; this.instance.lightMapIntensity = this.lightMapIntensity; @@ -803,8 +804,6 @@ GameLib.D3.Material.prototype.createInstance = function(update) { if (modified) { - data.texture.instance.needsUpdate = true; - this.publish( GameLib.Event.MATERIAL_LOADED, { diff --git a/src/game-lib-d3-texture.js b/src/game-lib-d3-texture.js index d68832b..2e6485c 100644 --- a/src/game-lib-d3-texture.js +++ b/src/game-lib-d3-texture.js @@ -204,12 +204,12 @@ GameLib.D3.Texture.prototype.createInstance = function(update) { return; } - if (this.instance) { - /** - * The texture has already been loaded - */ - return; - } + // if (this.instance) { + // /** + // * The texture has already been loaded + // */ + // return; + // } if (data.imagePath === this.image.path) { var instance = new THREE.Texture( @@ -229,7 +229,9 @@ GameLib.D3.Texture.prototype.createInstance = function(update) { { texture : this } - ) + ); + + this.instance.needsUpdate = true; } } ); diff --git a/src/game-lib-gui.js b/src/game-lib-gui.js index 11ef588..82b211b 100644 --- a/src/game-lib-gui.js +++ b/src/game-lib-gui.js @@ -672,6 +672,7 @@ GameLib.GUI.prototype.buildControl = function(folder, object, property) { function (value) { if (object[property] instanceof GameLib.Color) { object[property].fromHex(value); + object[property].updateInstance(); } else if (typeof this.initialValue === 'number') { object[property] = Number(value); } else { @@ -776,8 +777,8 @@ GameLib.GUI.prototype.buildSelectControl = function(folder, object, property, en /** * Old way of doing things */ - //parentObject.buildIdToObject(); - //object.updateInstance(); + parentObject.buildIdToObject(); + object.updateInstance(); } /**