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
*/
GameLib.D3.ImageFactory.prototype.loadImage = function(
imagePath
imagePath,
force
) {
imagePath = imagePath.replace(new RegExp('\/*'), '/');
@ -85,7 +86,7 @@ GameLib.D3.ImageFactory.prototype.loadImage = function(
throw new Error('Bad URL : ' + imagePath);
}
if (this.promiseList[imagePath]) {
if (!force && 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
* @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(
function (imageInstance){
this.imageInstance = imageInstance;
this.instance = this.createInstance();
if (onComplete) {
onComplete();
}
// this.parentObjects.map(
// function(parentObject){
// if (parentObject instanceof GameLib.D3.Material && parentObject.updateInstance) {
@ -97,6 +101,9 @@ GameLib.D3.Texture.prototype.loadTexture = function() {
}.bind(this),
function onRejected(message) {
console.warn(message);
if (onComplete) {
onComplete(message);
}
}
);
};

View File

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