resize events to render system
parent
5e6fc54181
commit
20163c4f93
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
// COMPILE TIME DEFINITIONS (Generated via gulp)
|
// COMPILE TIME DEFINITIONS (Generated via gulp)
|
||||||
var __DATE__ = "Mon Dec 11 2017 13:43:48 GMT+0100 (CET)";
|
var __DATE__ = "Tue Dec 12 2017 11:13:34 GMT+0100 (CET)";
|
||||||
// END COMPILE TIME DEFINITIONS
|
// END COMPILE TIME DEFINITIONS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25758,7 +25758,8 @@ GameLib.System.Animation.prototype.start = function() {
|
||||||
function(mesh) {
|
function(mesh) {
|
||||||
this.attachAnimation(animation, mesh);
|
this.attachAnimation(animation, mesh);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
);
|
||||||
|
this.animations[animation.id] = animation;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
this.animationMeshAddedSubscription = GameLib.Event.Subscribe(
|
this.animationMeshAddedSubscription = GameLib.Event.Subscribe(
|
||||||
|
@ -25817,6 +25818,15 @@ GameLib.System.Animation.prototype.instanceCreated = function(data) {
|
||||||
this.textures[data.component.id] = data.component;
|
this.textures[data.component.id] = data.component;
|
||||||
this.textureIds = Object.keys(this.textures);
|
this.textureIds = Object.keys(this.textures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.D3.Animation) {
|
||||||
|
this.animations[data.component.id] = data.component;
|
||||||
|
data.component.meshes.map(
|
||||||
|
function(mesh){
|
||||||
|
this.attachAnimation(data.component, mesh)
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.Animation.prototype.removeComponent = function(data) {
|
GameLib.System.Animation.prototype.removeComponent = function(data) {
|
||||||
|
@ -25831,6 +25841,17 @@ GameLib.System.Animation.prototype.removeComponent = function(data) {
|
||||||
this.textureIds = Object.keys(this.textures);
|
this.textureIds = Object.keys(this.textures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.D3.Animation) {
|
||||||
|
|
||||||
|
data.component.meshes.map(
|
||||||
|
function(mesh){
|
||||||
|
this.detachAnimation(mesh)
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
delete this.animations[data.component.id];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.Animation.prototype.textureAnimatedChange = function(data) {
|
GameLib.System.Animation.prototype.textureAnimatedChange = function(data) {
|
||||||
|
@ -26827,24 +26848,24 @@ GameLib.System.Animation.prototype.stop = function() {
|
||||||
|
|
||||||
this.animationMeshRemovedSubscription.remove();
|
this.animationMeshRemovedSubscription.remove();
|
||||||
|
|
||||||
this.animations = {};
|
Object.keys(this.animations).map(
|
||||||
|
function(animationId) {
|
||||||
|
|
||||||
var meshes = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.MESH);
|
if (
|
||||||
|
this.animations[animationId] &&
|
||||||
meshes.map(
|
this.animations[animationId].meshes
|
||||||
function(mesh) {
|
) {
|
||||||
|
this.animations[animationId].meshes.map(
|
||||||
for (var property in this.latest) {
|
function (mesh) {
|
||||||
if (
|
this.detachAnimation(mesh);
|
||||||
this.latest.hasOwnProperty(property) &&
|
}.bind(this)
|
||||||
property === mesh.id
|
)
|
||||||
) {
|
|
||||||
this.detachAnimation(mesh);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.animations = {};
|
||||||
|
|
||||||
this.instanceCreatedSubscription.remove();
|
this.instanceCreatedSubscription.remove();
|
||||||
|
|
||||||
this.removeComponentSubscription.remove();
|
this.removeComponentSubscription.remove();
|
||||||
|
@ -32044,6 +32065,59 @@ GameLib.System.Render.prototype.start = function() {
|
||||||
this.render
|
this.render
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.windowResizeSubscription = this.subscribe(
|
||||||
|
GameLib.Event.WINDOW_RESIZE,
|
||||||
|
this.windowResize
|
||||||
|
);
|
||||||
|
|
||||||
|
window.addEventListener(
|
||||||
|
'resize',
|
||||||
|
this.nativeWindowResize,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.Render.prototype.nativeWindowResize = function() {
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.WINDOW_RESIZE,
|
||||||
|
{
|
||||||
|
width : window.innerWidth,
|
||||||
|
height : window.innerHeight
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.Render.prototype.windowResize = function(data) {
|
||||||
|
|
||||||
|
var aspect = (data.width / data.height);
|
||||||
|
|
||||||
|
var cameras = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.CAMERA);
|
||||||
|
|
||||||
|
cameras.map(function(camera){
|
||||||
|
camera.aspect = aspect;
|
||||||
|
camera.updateInstance('aspect');
|
||||||
|
});
|
||||||
|
|
||||||
|
var renderers = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.RENDERER);
|
||||||
|
|
||||||
|
renderers.map(
|
||||||
|
function(renderer) {
|
||||||
|
renderer.setSize(
|
||||||
|
data.width,
|
||||||
|
data.height
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE,
|
||||||
|
{
|
||||||
|
aspect : aspect,
|
||||||
|
width : data.width,
|
||||||
|
height : data.height
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32170,6 +32244,14 @@ GameLib.System.Render.prototype.stop = function() {
|
||||||
|
|
||||||
this.renderSubscription.remove();
|
this.renderSubscription.remove();
|
||||||
|
|
||||||
|
window.removeEventListener(
|
||||||
|
'resize',
|
||||||
|
this.nativeWindowResize,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
this.windowResizeSubscription.remove();
|
||||||
|
|
||||||
this.renderers.map(
|
this.renderers.map(
|
||||||
function(renderer) {
|
function(renderer) {
|
||||||
if (renderer.statistics) {
|
if (renderer.statistics) {
|
||||||
|
|
|
@ -47,7 +47,8 @@ GameLib.System.Animation.prototype.start = function() {
|
||||||
function(mesh) {
|
function(mesh) {
|
||||||
this.attachAnimation(animation, mesh);
|
this.attachAnimation(animation, mesh);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
);
|
||||||
|
this.animations[animation.id] = animation;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
this.animationMeshAddedSubscription = GameLib.Event.Subscribe(
|
this.animationMeshAddedSubscription = GameLib.Event.Subscribe(
|
||||||
|
@ -1136,24 +1137,24 @@ GameLib.System.Animation.prototype.stop = function() {
|
||||||
|
|
||||||
this.animationMeshRemovedSubscription.remove();
|
this.animationMeshRemovedSubscription.remove();
|
||||||
|
|
||||||
this.animations = {};
|
Object.keys(this.animations).map(
|
||||||
|
function(animationId) {
|
||||||
|
|
||||||
var meshes = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.MESH);
|
if (
|
||||||
|
this.animations[animationId] &&
|
||||||
meshes.map(
|
this.animations[animationId].meshes
|
||||||
function(mesh) {
|
) {
|
||||||
|
this.animations[animationId].meshes.map(
|
||||||
for (var property in this.latest) {
|
function (mesh) {
|
||||||
if (
|
this.detachAnimation(mesh);
|
||||||
this.latest.hasOwnProperty(property) &&
|
}.bind(this)
|
||||||
property === mesh.id
|
)
|
||||||
) {
|
|
||||||
this.detachAnimation(mesh);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.animations = {};
|
||||||
|
|
||||||
this.instanceCreatedSubscription.remove();
|
this.instanceCreatedSubscription.remove();
|
||||||
|
|
||||||
this.removeComponentSubscription.remove();
|
this.removeComponentSubscription.remove();
|
||||||
|
|
|
@ -45,6 +45,59 @@ GameLib.System.Render.prototype.start = function() {
|
||||||
this.render
|
this.render
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.windowResizeSubscription = this.subscribe(
|
||||||
|
GameLib.Event.WINDOW_RESIZE,
|
||||||
|
this.windowResize
|
||||||
|
);
|
||||||
|
|
||||||
|
window.addEventListener(
|
||||||
|
'resize',
|
||||||
|
this.nativeWindowResize,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.Render.prototype.nativeWindowResize = function() {
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.WINDOW_RESIZE,
|
||||||
|
{
|
||||||
|
width : window.innerWidth,
|
||||||
|
height : window.innerHeight
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.Render.prototype.windowResize = function(data) {
|
||||||
|
|
||||||
|
var aspect = (data.width / data.height);
|
||||||
|
|
||||||
|
var cameras = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.CAMERA);
|
||||||
|
|
||||||
|
cameras.map(function(camera){
|
||||||
|
camera.aspect = aspect;
|
||||||
|
camera.updateInstance('aspect');
|
||||||
|
});
|
||||||
|
|
||||||
|
var renderers = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.RENDERER);
|
||||||
|
|
||||||
|
renderers.map(
|
||||||
|
function(renderer) {
|
||||||
|
renderer.setSize(
|
||||||
|
data.width,
|
||||||
|
data.height
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE,
|
||||||
|
{
|
||||||
|
aspect : aspect,
|
||||||
|
width : data.width,
|
||||||
|
height : data.height
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,6 +224,14 @@ GameLib.System.Render.prototype.stop = function() {
|
||||||
|
|
||||||
this.renderSubscription.remove();
|
this.renderSubscription.remove();
|
||||||
|
|
||||||
|
window.removeEventListener(
|
||||||
|
'resize',
|
||||||
|
this.nativeWindowResize,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
this.windowResizeSubscription.remove();
|
||||||
|
|
||||||
this.renderers.map(
|
this.renderers.map(
|
||||||
function(renderer) {
|
function(renderer) {
|
||||||
if (renderer.statistics) {
|
if (renderer.statistics) {
|
||||||
|
|
Loading…
Reference in New Issue