reload image if imagedata available

beta.r3js.org
-=yb4f310 2017-09-29 06:09:47 +02:00
parent 24b9212247
commit da84dc459f
3 changed files with 85 additions and 26 deletions

View File

@ -316,7 +316,7 @@ GameLib.System.GUI.prototype.buildQuaternionControl = function(folder, component
GameLib.System.GUI.prototype.buildVectorControl = function(folder, componentTemplate, property) {
var step = 0.1;
var step = 0.01;
var object = componentTemplate.template;

View File

@ -42,6 +42,9 @@ GameLib.System.Input = function(
this.touchEnd = this.onTouchEnd.bind(this);
this.touchCancel = this.onTouchCancel.bind(this);
this.keyboardKeyUp = this.onKeyboardKeyUp.bind(this);
this.keyboardKeyDown = this.onKeyboardKeyDown.bind(this);
};
GameLib.System.Input.prototype = Object.create(GameLib.System.prototype);
@ -92,7 +95,30 @@ GameLib.System.Input.prototype.start = function() {
);
}.bind(this)
)
} else if (this.editorControls.length > 0) {
}
/**
* Same for keyboard controls
*/
if (this.keyboardControls.length > 0) {
this.keyboardControls.map(
function(keyboardControl) {
keyboardControl.domElement.instance.addEventListener(
'keyup',
this.keyboardKeyUp,
false
);
keyboardControl.domElement.instance.addEventListener(
'keydown',
this.keyboardKeyDown,
false
);
}.bind(this)
)
}
if (this.editorControls.length > 0) {
this.renderers = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Renderer);
@ -164,10 +190,26 @@ GameLib.System.Input.prototype.start = function() {
);
}
};
if (this.keyboardControls.length > 0) {
GameLib.System.Input.prototype.onKeyboardKeyUp = function(event) {
GameLib.Event.Emit(
GameLib.Event.KEY_DOWN,
{
code : event.code
}
);
};
GameLib.System.Input.prototype.onKeyboardKeyDown = function(event) {
GameLib.Event.Emit(
GameLib.Event.KEY_UP,
{
code : event.code
}
);
}
};
GameLib.System.Input.prototype.onTouchStart = function(event) {
@ -606,6 +648,25 @@ GameLib.System.Input.prototype.stop = function() {
)
}
if (this.keyboardControls.length > 0) {
this.keyboardControls.map(
function(keyboardControl) {
keyboardControl.domElement.instance.removeEventListener(
'keydown',
this.keyboardKeyDown,
false
);
keyboardControl.domElement.instance.removeEventListener(
'keyup',
this.keyboardKeyUp,
false
);
}.bind(this)
)
}
};

View File

@ -737,30 +737,28 @@ GameLib.System.Storage.prototype.imageUploadComplete = function(data) {
*/
data.images.map(function(imageData){
var image = runtimeImages.reduce(
function(result, runtimeImage){
var image = null;
if (imageData.id === runtimeImage.id) {
result = runtimeImage;
}
return result;
},
null
);
if (image) {
/**
* Do Nothing - the runtime version of this image already exists and simply needs to load
*/
if (imageData) {
/**
* Overrride this image if possible
* @type {GameLib.D3.Image}
*/
image = GameLib.D3.Image.FromObject(this.graphics, imageData);
} else {
/**
* We don't have this runtime version of the image - create it
* @type {GameLib.D3.Image}
*/
image = GameLib.D3.Image.FromObject(this.graphics, imageData);
}
image = runtimeImages.reduce(
function(result, runtimeImage){
if (imageData.id === runtimeImage.id) {
result = runtimeImage;
}
return result;
},
null
);
}
GameLib.Event.Emit(