texture and number

beta.r3js.org
-=yb4f310 2017-05-22 20:38:00 +02:00
parent 40f8341731
commit 63d175a8d7
3 changed files with 14 additions and 4 deletions

View File

@ -75,7 +75,8 @@ GameLib.D3.ImageFactory.prototype.updateInstance = function() {
* @constructor * @constructor
*/ */
GameLib.D3.ImageFactory.prototype.loadImage = function( GameLib.D3.ImageFactory.prototype.loadImage = function(
imagePath imagePath,
force
) { ) {
imagePath = imagePath.replace(new RegExp('\/*'), '/'); imagePath = imagePath.replace(new RegExp('\/*'), '/');
@ -85,7 +86,7 @@ GameLib.D3.ImageFactory.prototype.loadImage = function(
throw new Error('Bad URL : ' + imagePath); throw new Error('Bad URL : ' + imagePath);
} }
if (this.promiseList[imagePath]) { if (!force && this.promiseList[imagePath]) {
return this.promiseList[imagePath]; return this.promiseList[imagePath];
} }

View File

@ -78,15 +78,19 @@ GameLib.D3.Texture.prototype.constructor = GameLib.D3.Texture;
/** /**
* Loads a texture from the image factory, it could already have downloaded, and then it updates the instance * Loads a texture from the image factory, it could already have downloaded, and then it updates the instance
* @param force boolean to force a reload
*/ */
GameLib.D3.Texture.prototype.loadTexture = function() { GameLib.D3.Texture.prototype.loadTexture = function(force, onComplete) {
this.imageData = this.imageFactory.loadImage(this.imagePath); this.imageData = this.imageFactory.loadImage(this.imagePath, force);
this.imageData.then( this.imageData.then(
function (imageInstance){ function (imageInstance){
this.imageInstance = imageInstance; this.imageInstance = imageInstance;
this.instance = this.createInstance(); this.instance = this.createInstance();
if (onComplete) {
onComplete();
}
// this.parentObjects.map( // this.parentObjects.map(
// function(parentObject){ // function(parentObject){
// if (parentObject instanceof GameLib.D3.Material && parentObject.updateInstance) { // if (parentObject instanceof GameLib.D3.Material && parentObject.updateInstance) {
@ -97,6 +101,9 @@ GameLib.D3.Texture.prototype.loadTexture = function() {
}.bind(this), }.bind(this),
function onRejected(message) { function onRejected(message) {
console.warn(message); console.warn(message);
if (onComplete) {
onComplete(message);
}
} }
); );
}; };

View File

@ -672,6 +672,8 @@ GameLib.GUI.prototype.buildControl = function(folder, object, property) {
function (value) { function (value) {
if (object[property] instanceof GameLib.Color) { if (object[property] instanceof GameLib.Color) {
object[property].fromHex(value); object[property].fromHex(value);
} else if (typeof this.initialValue === 'number') {
object[property] = Number(value);
} else { } else {
object[property] = value; object[property] = value;
} }