render run loop to render system

beta.r3js.org
-=yb4f310 2017-12-12 11:36:52 +01:00
parent 20163c4f93
commit c4d70e8795
3 changed files with 63 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
// COMPILE TIME DEFINITIONS (Generated via gulp) // COMPILE TIME DEFINITIONS (Generated via gulp)
var __DATE__ = "Tue Dec 12 2017 11:13:34 GMT+0100 (CET)"; var __DATE__ = "Tue Dec 12 2017 11:35:24 GMT+0100 (CET)";
// END COMPILE TIME DEFINITIONS // END COMPILE TIME DEFINITIONS
/** /**
@ -32021,10 +32021,12 @@ GameLib.System.Physics.prototype.stop = function() {
/** /**
* System takes care of updating all the entities (based on their component data) * System takes care of updating all the entities (based on their component data)
* @param apiSystem GameLib.API.System * @param apiSystem GameLib.API.System
* @param graphicsRuntime
* @constructor * @constructor
*/ */
GameLib.System.Render = function( GameLib.System.Render = function(
apiSystem apiSystem,
graphicsRuntime
) { ) {
GameLib.System.call( GameLib.System.call(
@ -32034,6 +32036,12 @@ GameLib.System.Render = function(
this.renderSubscription = null; this.renderSubscription = null;
this.clock = new GameLib.Clock(graphicsRuntime);
this.delta = null;
this.animationFrameHook = null;
}; };
GameLib.System.Render.prototype = Object.create(GameLib.System.prototype); GameLib.System.Render.prototype = Object.create(GameLib.System.prototype);
@ -32075,6 +32083,24 @@ GameLib.System.Render.prototype.start = function() {
this.nativeWindowResize, this.nativeWindowResize,
false false
); );
this.run();
};
GameLib.System.Render.prototype.run = function() {
this.animationFrameHook = requestAnimationFrame( this.run.bind(this) );
this.delta = this.clock.getDelta();
GameLib.Event.Emit(
GameLib.Event.RENDER,
{
delta : this.delta
}
);
}; };
GameLib.System.Render.prototype.nativeWindowResize = function() { GameLib.System.Render.prototype.nativeWindowResize = function() {
@ -32238,6 +32264,8 @@ GameLib.System.Render.prototype.stop = function() {
GameLib.System.prototype.stop.call(this); GameLib.System.prototype.stop.call(this);
cancelAnimationFrame(this.animationFrameHook);
this.instanceCreatedSubscription.remove(); this.instanceCreatedSubscription.remove();
this.removeComponentSubscription.remove(); this.removeComponentSubscription.remove();

View File

@ -1,10 +1,12 @@
/** /**
* System takes care of updating all the entities (based on their component data) * System takes care of updating all the entities (based on their component data)
* @param apiSystem GameLib.API.System * @param apiSystem GameLib.API.System
* @param graphicsRuntime
* @constructor * @constructor
*/ */
GameLib.System.Render = function( GameLib.System.Render = function(
apiSystem apiSystem,
graphicsRuntime
) { ) {
GameLib.System.call( GameLib.System.call(
@ -14,6 +16,12 @@ GameLib.System.Render = function(
this.renderSubscription = null; this.renderSubscription = null;
this.clock = new GameLib.Clock(graphicsRuntime);
this.delta = null;
this.animationFrameHook = null;
}; };
GameLib.System.Render.prototype = Object.create(GameLib.System.prototype); GameLib.System.Render.prototype = Object.create(GameLib.System.prototype);
@ -55,6 +63,24 @@ GameLib.System.Render.prototype.start = function() {
this.nativeWindowResize, this.nativeWindowResize,
false false
); );
this.run();
};
GameLib.System.Render.prototype.run = function() {
this.animationFrameHook = requestAnimationFrame( this.run.bind(this) );
this.delta = this.clock.getDelta();
GameLib.Event.Emit(
GameLib.Event.RENDER,
{
delta : this.delta
}
);
}; };
GameLib.System.Render.prototype.nativeWindowResize = function() { GameLib.System.Render.prototype.nativeWindowResize = function() {
@ -218,6 +244,8 @@ GameLib.System.Render.prototype.stop = function() {
GameLib.System.prototype.stop.call(this); GameLib.System.prototype.stop.call(this);
cancelAnimationFrame(this.animationFrameHook);
this.instanceCreatedSubscription.remove(); this.instanceCreatedSubscription.remove();
this.removeComponentSubscription.remove(); this.removeComponentSubscription.remove();