viewport, editor, game, systems

beta.r3js.org
Theunis Johannes Botha 2017-01-12 04:44:01 +01:00
parent 24897794af
commit b5cdce22ab
12 changed files with 604 additions and 326 deletions

View File

@ -0,0 +1,63 @@
/**
* This component renders a scene
* @param id String
* @param name String
* @param systemType
* @param entityManager
* @param parentEntity
* @constructor
*/
GameLib.API.System = function (
id,
name,
systemType,
entityManager,
parentEntity
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_SYSTEM,
null,
null,
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = "System (" + this.id + ")";
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(systemType)) {
systemType = GameLib.System.SYSTEM_TYPE_RENDER;
}
this.systemType = systemType;
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
entityManager = null;
}
this.entityManager = entityManager;
};
GameLib.API.System.prototype = Object.create(GameLib.Component.prototype);
GameLib.API.System.prototype.constructor = GameLib.API.System;
/**
* Object to GameLib.D3.API.System
* @param objectComponent
* @constructor
*/
GameLib.API.System.FromObjectComponent = function(objectComponent) {
return new GameLib.API.System(
objectComponent.id,
objectComponent.name,
objectComponent.systemType,
objectComponent.entityManager,
objectComponent.parentEntity
);
};

View File

@ -44,6 +44,7 @@ GameLib.Component.COMPONENT_GAME = 0x10;
GameLib.Component.COMPONENT_INPUT_EDITOR = 0x11;
GameLib.Component.COMPONENT_EDITOR = 0x12;
GameLib.Component.COMPONENT_VIEWPORT = 0x13;
GameLib.Component.COMPONENT_SYSTEM = 0x14;
/**
* Components are linked at runtime - for storing, we just store the ID

View File

@ -51,6 +51,11 @@ GameLib.D3.API.Editor = function(
}
this.selectedObjects = selectedObjects;
if (GameLib.Utils.UndefinedOrNull(viewports)) {
viewports = [];
}
this.viewports = viewports;
};
GameLib.D3.API.Editor.prototype = Object.create(GameLib.Component.prototype);
@ -68,6 +73,7 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
objectEditor.games,
objectEditor.allSelected,
objectEditor.selectedObjects,
objectEditor.viewports,
objectEditor.parentEntity
);
};

View File

@ -10,9 +10,9 @@
* @param renderers
* @param composers
* @param systems
* @param viewports
* @param entityManager
* @param mouse
* @param raycaster
* @param activeCameraIndex
* @param activeRendererIndex
* @param parentEntity
@ -29,11 +29,9 @@ GameLib.D3.API.Game = function(
renderers,
composers,
systems,
viewports,
entityManager,
mouse,
raycaster,
activeCameraIndex,
activeRendererIndex,
parentEntity
) {
GameLib.Component.call(
@ -45,9 +43,9 @@ GameLib.D3.API.Game = function(
'renderers' : [GameLib.D3.Renderer],
'composers' : [GameLib.D3.Composer],
'systems' : [GameLib.D3.System],
'viewports' : [GameLib.D3.Viewport],
'entityManager' : GameLib.EntityManager,
'mouse' : GameLib.D3.Mouse,
'raycaster' : GameLib.D3.Raycaster
'mouse' : GameLib.D3.Mouse
},
null,
parentEntity
@ -103,6 +101,11 @@ GameLib.D3.API.Game = function(
}
this.systems = systems;
if (GameLib.Utils.UndefinedOrNull(viewports)) {
viewports = [];
}
this.viewports = viewports;
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
entityManager = new GameLib.API.EntityManager();
}
@ -112,21 +115,6 @@ GameLib.D3.API.Game = function(
mouse = null;
}
this.mouse = mouse;
if (GameLib.Utils.UndefinedOrNull(raycaster)) {
raycaster = null;
}
this.raycaster = raycaster;
if (GameLib.Utils.UndefinedOrNull(activeCameraIndex)) {
activeCameraIndex = 0;
}
this.activeCameraIndex = activeCameraIndex;
if (GameLib.Utils.UndefinedOrNull(activeRendererIndex)) {
activeRendererIndex = 0;
}
this.activeRendererIndex = activeRendererIndex;
};
GameLib.D3.API.Game.prototype = Object.create(GameLib.Component.prototype);
@ -144,10 +132,10 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
var apiRenderers = [];
var apiComposers = [];
var apiSystems = [];
var apiViewports = [];
var apiEntityManager = null;
var apiMouse = null;
var apiRaycaster = null;
if (objectGame.scenes) {
apiScenes = objectGame.scenes.map(
@ -189,6 +177,14 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
);
}
if (objectGame.viewports) {
apiViewports = objectGame.viewports.map(
function(objectViewport){
return GameLib.API.Viewport.FromObjectViewport(objectViewport);
}
);
}
if (objectGame.entityManager) {
apiEntityManager = GameLib.API.Entity.FromObjectEntity(objectGame.entityManager);
}
@ -197,10 +193,6 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
apiMouse = GameLib.API.Mouse.FromObjectMouse(objectGame.mouse);
}
if (objectGame.raycaster) {
apiRaycaster = GameLib.API.Raycaster.FromObjectRaycaster(objectGame.raycaster);
}
return new GameLib.D3.API.Game(
objectGame.id,
objectGame.name,
@ -212,11 +204,9 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
apiRenderers,
apiComposers,
apiSystems,
apiViewports,
apiEntityManager,
apiMouse,
apiRaycaster,
objectGame.activeCameraIndex,
objectGame.activeRendererIndex,
objectGame.parentEntity
);

View File

@ -2,15 +2,11 @@
* Creates a Editor object
* @param graphics GameLib.D3.Graphics
* @param apiEditor GameLib.D3.API.Editor
* @param document
* @param window
* @constructor
*/
GameLib.D3.Editor = function(
graphics,
apiEditor,
document,
window
apiEditor
) {
this.graphics = graphics;
@ -22,20 +18,22 @@ GameLib.D3.Editor = function(
apiEditor.name,
apiEditor.games,
apiEditor.allSelected,
apiEditor.selectedObjects,
apiEditor.viewports,
apiEditor.parentEntity
);
if (GameLib.Utils.UndefinedOrNull(document)) {
console.warn('Cannot create an Editor Object without reference to the DOM document');
throw new Error('Cannot create an Editor Object without reference to the DOM document');
}
this.document = document;
if (GameLib.Utils.UndefinedOrNull(window)) {
console.warn('Cannot create an Editor Object without reference to the DOM window');
throw new Error('Cannot create an Editor Object without reference to the DOM window');
}
this.window = window;
//
//if (GameLib.Utils.UndefinedOrNull(document)) {
// console.warn('Cannot create an Editor Object without reference to the DOM document');
// throw new Error('Cannot create an Editor Object without reference to the DOM document');
//}
//this.document = document;
//
//if (GameLib.Utils.UndefinedOrNull(window)) {
// console.warn('Cannot create an Editor Object without reference to the DOM window');
// throw new Error('Cannot create an Editor Object without reference to the DOM window');
//}
//this.window = window;
this.instance = this.createInstance();
};
@ -71,17 +69,41 @@ GameLib.D3.Editor.prototype.updateInstance = function() {
*/
GameLib.D3.Editor.prototype.toApiEditor = function() {
var apiGames = this.games.map(
function(game) {
return game.toApiComponent();
}
);
var apiGames = [];
if (this.games) {
apiGames = this.games.map(
function(game) {
if (game instanceof GameLib.D3.Game) {
return game.toApiGame();
} else {
console.warn('Game not an instance of Game');
throw new Error('Game not an instance of Game');
}
}
);
}
var apiViewports = [];
if (this.viewports) {
apiViewports = this.viewports.map(
function(viewport) {
if (viewport instanceof GameLib.D3.Viewport) {
return viewport.toApiViewport();
} else {
console.warn('Viewport not an instance of Viewport');
throw new Error('Viewport not an instance of Viewport');
}
}
);
}
return new GameLib.D3.API.Editor(
this.id,
this.name,
apiGames,
this.allSelected,
this.selectedObjects,
apiViewports,
GameLib.Utils.IdOrNull(this.parentEntity)
);

View File

@ -24,88 +24,313 @@ GameLib.D3.Game = function (
apiGame.renderers,
apiGame.composers,
apiGame.systems,
apiGame.viewports,
apiGame.entityManager,
apiGame.mouse,
apiGame.raycaster,
apiGame.activeCameraIndex,
apiGame.activeRendererIndex,
apiGame.parentEntity
);
this.scenes = this.scenes.map(
function(apiScene) {
return GameLib.D3.Scene(
this.graphics,
apiScene
)
if (apiScene instanceof GameLib.D3.API.Scene) {
return GameLib.D3.Scene(
this.graphics,
apiScene
)
} else {
console.warn('Scene not of type API.Scene');
throw new Error('Scene not of type API.Scene');
}
}.bind(this)
);
this.entityManager.entities.map(
function (entity) {
this.idToObject[entity.id] = entity;
entity.components.map(
function(component) {
if (component instanceof GameLib.Component) {
this.idToObject[component.id] = component;
}
}.bind(this)
)
}.bind(this)
);
this.cameras = this.cameras.map(
function(apiCamera) {
this.entityManager.linkObjects(this.idToObject);
if (apiCamera instanceof GameLib.D3.API.Camera) {
return GameLib.D3.Camera(
this.graphics,
apiCamera
)
} else {
console.warn('Camera not of type API.Camera');
throw new Error('Camera not of type API.Camera');
}
}.bind(this)
);
this.renderers = this.renderers.map(
function(apiRenderer) {
if (apiRenderer instanceof GameLib.D3.API.Renderer) {
return GameLib.D3.Renderer(
this.graphics,
apiRenderer
)
} else {
console.warn('Renderer not of type API.Renderer');
throw new Error('Renderer not of type API.Renderer');
}
}.bind(this)
);
this.composers = this.composers.map(
function(apiComposer) {
if (apiComposer instanceof GameLib.D3.API.Composer) {
return GameLib.D3.Composer(
this.graphics,
apiComposer
)
} else {
console.warn('Composer not of type API.Composer');
throw new Error('Composer not of type API.Composer');
}
}.bind(this)
);
this.systems = this.systems.map(
function(apiSystem) {
if (apiSystem instanceof GameLib.D3.API.System) {
return GameLib.D3.System(
this.graphics,
apiSystem
)
} else {
console.warn('System not of type API.System');
throw new Error('System not of type API.System');
}
}.bind(this)
);
this.viewports = this.viewports.map(
function(apiViewport) {
if (apiViewport instanceof GameLib.D3.API.Viewport) {
return GameLib.D3.Viewport(
this.graphics,
apiViewport
)
} else {
console.warn('Viewport not of type API.Viewport');
throw new Error('Viewport not of type API.Viewport');
}
}.bind(this)
);
this.idToObject = {};
if (this.entityManager instanceof GameLib.API.EntityManager) {
this.entityManager = new GameLib.EntityManager(
this.graphics,
this.entityManager
);
this.entityManager.entities.map(
function (entity) {
this.idToObject[entity.id] = entity;
entity.components.map(
function(component) {
if (component instanceof GameLib.Component) {
this.idToObject[component.id] = component;
} else {
console.warn('Component not of type Component');
throw new Error('Component not of type Component');
}
}.bind(this)
)
}.bind(this)
);
this.entityManager.linkObjects(this.idToObject);
} else {
console.warn('EntityManager not of type API.EntityManager');
throw new Error('EntityManager not of type API.EntityManager');
}
this.scenes = {};
};
GameLib.D3.Game.prototype = Object.create(GameLib.D3.API.Game.prototype);
GameLib.D3.Game.prototype.constructor = GameLib.D3.Game;
GameLib.D3.Game.GAME_TYPE_VR_PONG = 0x1;
GameLib.D3.Game.GAME_TYPE_VR_RACER = 0x2;
GameLib.D3.Game.prototype.addScene = function(
scene,
identifer
) {
this.scenes[identifer] = scene;
/**
* Creates a camera instance of 'graphics' type (only THREE for now)
* @returns {THREE.Game}
*/
GameLib.D3.Game.prototype.createInstance = function(update) {
var instance = null;
if (update) {
instance = this.instance;
}
return instance;
};
GameLib.D3.Game.prototype.processPhysics = function (
dt
) {
for(var s in this.scenes) {
var scene = this.scenes[s];
for(var w in scene.worlds) {
var world = scene.worlds[w];
world.step(dt);
}
}
/**
* Updates the instance with the current state
*/
GameLib.D3.Game.prototype.updateInstance = function() {
this.instance = this.createInstance(true);
};
GameLib.D3.Game.prototype.render = function(
dt,
renderer
) {
for(var s in this.scenes) {
var scene = this.scenes[s];
scene.render(dt, renderer);
}
/**
* Converts a GameLib.D3.Game to a new GameLib.D3.API.Game
* @returns {GameLib.D3.API.Game}
*/
GameLib.D3.Game.prototype.toApiGame = function() {
var apiScenes = [];
if (this.scenes) {
apiScenes = this.scenes.map(
function(scene) {
if (scene instanceof GameLib.D3.Scene) {
return scene.toApiScene();
} else {
console.warn('Scene not an instance of Scene');
throw new Error('Scene not an instance of Scene');
}
}
);
}
var apiCameras = [];
if (this.cameras) {
apiCameras = this.cameras.map(
function(camera) {
if (camera instanceof GameLib.D3.Camera) {
return camera.toApiCamera();
} else {
console.warn('Camera not an instance of Camera');
throw new Error('Camera not an instance of Camera');
}
}
);
}
var apiRenderers = [];
if (this.renderers) {
apiRenderers = this.renderers.map(
function(renderer) {
if (renderer instanceof GameLib.D3.Renderer) {
return renderer.toApiRenderer();
} else {
console.warn('Renderer not an instance of Renderer');
throw new Error('Renderer not an instance of Renderer');
}
}
);
}
var apiComposers = [];
if (this.composers) {
apiComposers = this.composers.map(
function(composer) {
if (composer instanceof GameLib.D3.Composer) {
return composer.toApiComposer();
} else {
console.warn('Composer not an instance of Composer');
throw new Error('Composer not an instance of Composer');
}
}
);
}
var apiSystems = [];
if (this.systems) {
apiSystems = this.systems.map(
function(system) {
if (system instanceof GameLib.System) {
return system.toApiSystem();
} else {
console.warn('System not an instance of System');
throw new Error('System not an instance of System');
}
}
);
}
var apiViewports = [];
if (this.viewports) {
apiViewports = this.viewports.map(
function(viewport) {
if (viewport instanceof GameLib.D3.Viewport) {
return viewport.toApiViewport();
} else {
console.warn('Viewport not an instance of Viewport');
throw new Error('Viewport not an instance of Viewport');
}
}
);
}
var apiEntityManager = null;
if (this.entityManager) {
if (this.entityManager instanceof GameLib.EntityManager) {
apiEntityManager = this.entityManager.toApiEntityManager();
} else {
console.warn('EntityManager not an instance of EntityManager');
throw new Error('EntityManager not an instance of EntityManager');
}
}
var apiMouse = null;
if (this.mouse) {
if (this.mouse instanceof GameLib.Mouse) {
apiMouse = this.mouse.toApiMouse();
} else {
console.warn('Mouse not an instance of Mouse');
throw new Error('Mouse not an instance of Mouse');
}
}
return new GameLib.D3.API.Game(
this.id,
this.name,
this.gameType,
this.width,
this.height,
apiScenes,
apiCameras,
apiRenderers,
apiComposers,
apiSystems,
apiViewports,
apiEntityManager,
apiMouse,
GameLib.Utils.IdOrNull(this.parentEntity)
);
};
GameLib.D3.Game.prototype.update = function(
dt,
fixedDt
) {
for(var s in this.scenes) {
var scene = this.scenes[s];
/**
* Converts from an Object Game to a GameLib.D3.Game
* @param graphics GameLib.D3.Graphics
* @param objectGame Object
* @returns {GameLib.D3.Game}
* @constructor
*/
GameLib.D3.Game.FromObjectGame = function(graphics, objectGame) {
for(var w in scene.worlds) {
var world = scene.worlds[w];
// NOTE: We are calling the step function with a variable timestep!
world.step(fixedDt, dt);
}
var apiGame = GameLib.D3.API.Game.FromObjectGame(objectGame);
scene.update(dt);
scene.lateUpdate(dt);
}
};
return new GameLib.D3.Game(
graphics,
apiGame
);
};

View File

@ -19,10 +19,17 @@ GameLib.EntityManager = function(
this.entities = this.entities.map(
function(apiEntity) {
return new GameLib.Entity(
this.graphics,
apiEntity
)
if (apiEntity instanceof GameLib.API.Entity) {
return new GameLib.Entity(
this.graphics,
apiEntity
)
} else {
console.warn('Entity not of type API.Entity');
throw new Error('Entity not of type API.Entity');
}
}.bind(this)
);

View File

@ -1,37 +0,0 @@
/**
* System takes care of updating all the entities (based on their component data)
* @param entityManager GameLib.EntityManager
* @constructor
*/
GameLib.System = function(
entityManager
) {
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
entityManager = null;
}
this.entityManager = entityManager;
};
GameLib.System.SYSTEM_TYPE_RENDER = 0x1;
GameLib.System.SYSTEM_TYPE_ANIMATION = 0x2;
GameLib.System.SYSTEM_TYPE_INPUT = 0x3;
GameLib.System.SYSTEM_TYPE_ALL = 0x4;
/**
* @callback
* @override
*/
GameLib.System.prototype.start = function() {};
/**
* @callback
* @override
*/
GameLib.System.prototype.update = function() {};
/**
* @callback
* @override
*/
GameLib.System.prototype.stop = function() {};

View File

@ -1,71 +0,0 @@
/**
* System takes care of updating all the entities (based on their component data)
* @constructor
*/
GameLib.System.Animation = function(
entityManager
) {
GameLib.System.call(
this,
entityManager
);
this.pathFollowingObjects = [];
this.followObjects = [];
this.meshObjects = [];
this.lookAtObjects = [];
this.cameraObjects = [];
this.lightObjects = [];
};
GameLib.System.Animation.prototype = Object.create(GameLib.System.prototype);
GameLib.System.Animation.prototype.constructor = GameLib.System.Animation;
GameLib.System.Animation.prototype.start = function() {
this.pathFollowingObjects = this.entityManager.query([GameLib.D3.PathFollowing]);
this.followObjects = this.entityManager.query([GameLib.D3.Follow]);
this.meshObjects = this.entityManager.query([GameLib.D3.Mesh]);
this.lookAtObjects = this.entityManager.query([GameLib.D3.LookAt]);
this.cameraObjects = this.entityManager.query([GameLib.D3.Camera]);
this.lightObjects = this.entityManager.query([GameLib.D3.Light]);
};
/**
* @override
*/
GameLib.System.Animation.prototype.update = function(deltaTime) {
this.pathFollowingObjects.forEach(function(object) {
object.update(deltaTime);
});
this.followObjects.forEach(function(object) {
object.update(deltaTime);
});
this.lookAtObjects.forEach(function(object) {
object.update(deltaTime);
});
this.meshObjects.forEach(function(object) {
object.updateInstance();
});
this.cameraObjects.forEach(function(object) {
object.updateInstance();
});
this.lightObjects.forEach(function(object) {
object.updateInstance();
});
};
GameLib.System.Animation.prototype.stop = function() {
this.pathFollowingObjects = [];
this.followObjects = [];
this.meshObjects = [];
this.lookAtObjects = [];
this.cameraObjects = [];
this.lightObjects = [];
};

View File

@ -1,38 +0,0 @@
/**
* System takes care of updating all the entities (based on their component data)
* @constructor
*/
GameLib.System.Input = function(
entityManager
) {
GameLib.System.call(
this,
entityManager
);
this.driveInputObjects = [];
};
GameLib.System.Input.prototype = Object.create(GameLib.System.prototype);
GameLib.System.Input.prototype.constructor = GameLib.System.Input;
GameLib.System.Input.prototype.start = function() {
this.driveInputObjects = this.entityManager.query([GameLib.D3.Input.Drive]);
};
/**
*
* @param deltaTime
*/
GameLib.System.Input.prototype.update = function(deltaTime) {
this.driveInputObjects.forEach(
function(object) {
object.update(deltaTime);
}
);
};
GameLib.System.Input.prototype.stop = function() {
this.driveInputObjects = [];
};

View File

@ -1,66 +0,0 @@
/**
* System takes care of updating all the entities (based on their component data)
* @constructor
*/
GameLib.System.Render = function(
entityManager,
domElement,
stats
) {
GameLib.System.call(
this,
entityManager
);
if (GameLib.Utils.UndefinedOrNull(domElement)) {
domElement = null;
}
this.domElement = domElement;
if (GameLib.Utils.UndefinedOrNull(stats)) {
stats = null;
}
this.stats = stats;
this.renderers = [];
this.viewports = [];
};
GameLib.System.Render.prototype = Object.create(GameLib.System.prototype);
GameLib.System.Render.prototype.constructor = GameLib.System.Render;
/**
*
*/
GameLib.System.Render.prototype.start = function() {
this.domElement.innerHTML = '';
this.domElement.appendChild(this.stats.dom);
this.renderers = this.entityManager.query([GameLib.D3.Renderer]);
this.renderers.forEach(
function (renderer) {
this.domElement.appendChild(renderer.instance.domElement);
}.bind(this)
);
this.viewports = this.entityManager.query([GameLib.D3.Viewport]);
};
/**
*
* @param deltaTime
*/
GameLib.System.Render.prototype.update = function(deltaTime) {
this.viewports.forEach(
function (viewport) {
viewport.update(deltaTime);
}
);
};
GameLib.System.Render.prototype.stop = function() {
this.domElement.innerHTML = '';
this.renderers = [];
this.viewports = [];
};

176
src/game-lib-system.js Normal file
View File

@ -0,0 +1,176 @@
/**
* System takes care of updating all the entities (based on their component data)
* @param apiSystem GameLib.API.System
* @param domElement
* @param domStats
* @constructor
*/
GameLib.System = function(
apiSystem,
domElement,
domStats
) {
GameLib.API.System.call(
this,
apiSystem.id,
apiSystem.name,
apiSystem.systemType,
apiSystem.entityManager,
apiSystem.parentEntity
);
if (GameLib.Utils.UndefinedOrNull(domElement)){
domElement = null;
}
this.domElement = domElement;
if (GameLib.Utils.UndefinedOrNull(domStats)){
domStats = null;
}
this.domStats = domStats;
};
GameLib.System.prototype = Object.create(GameLib.API.System.prototype);
GameLib.System.prototype.constructor = GameLib.System;
GameLib.System.SYSTEM_TYPE_RENDER = 0x1;
GameLib.System.SYSTEM_TYPE_ANIMATION = 0x2;
GameLib.System.SYSTEM_TYPE_INPUT = 0x3;
GameLib.System.SYSTEM_TYPE_ALL = 0x4;
/**
* @callback
* @override
*/
GameLib.System.prototype.start = function() {
if (this.systemType == GameLib.System.SYSTEM_TYPE_INPUT) {
this.driveInputObjects = this.entityManager.query([GameLib.D3.Input.Drive]);
}
if (this.systemType == GameLib.System.SYSTEM_TYPE_RENDER) {
if (GameLib.Utils.UndefinedOrNull(this.domElement)) {
console.warn('Cannot start a rendering system without a valid DOM element');
throw new Error('Cannot start a rendering system without a valid DOM element');
}
this.domElement.innerHTML = '';
if (GameLib.Utils.UndefinedOrNull(this.domStats)) {
console.warn('No stats DOM - will run the render process without statistics information');
} else {
this.domElement.appendChild(this.domStats);
}
this.renderers = this.entityManager.query([GameLib.D3.Renderer]);
this.renderers.forEach(
function (renderer) {
this.domElement.appendChild(renderer.instance.domElement);
}.bind(this)
);
this.viewports = this.entityManager.query([GameLib.D3.Viewport]);
}
if (this.systemType == GameLib.System.SYSTEM_TYPE_ANIMATION) {
this.pathFollowingObjects = this.entityManager.query([GameLib.D3.PathFollowing]);
this.followObjects = this.entityManager.query([GameLib.D3.Follow]);
this.meshObjects = this.entityManager.query([GameLib.D3.Mesh]);
this.lookAtObjects = this.entityManager.query([GameLib.D3.LookAt]);
this.cameraObjects = this.entityManager.query([GameLib.D3.Camera]);
this.lightObjects = this.entityManager.query([GameLib.D3.Light]);
}
};
/**
* @callback
* @override
*/
GameLib.System.prototype.update = function() {
if (this.systemType == GameLib.System.SYSTEM_TYPE_INPUT) {
this.driveInputObjects.forEach(
function(object) {
object.update(deltaTime);
}
);
}
if (this.systemType == GameLib.System.SYSTEM_TYPE_RENDER) {
this.viewports.forEach(
function (viewport) {
viewport.update(deltaTime);
}
);
}
if (this.systemType == GameLib.System.SYSTEM_TYPE_ANIMATION) {
this.pathFollowingObjects.forEach(
function(object) {
object.update(deltaTime);
}
);
this.followObjects.forEach(
function(object) {
object.update(deltaTime);
}
);
this.lookAtObjects.forEach(
function(object) {
object.update(deltaTime);
}
);
this.meshObjects.forEach(
function(object) {
object.updateInstance();
}
);
this.cameraObjects.forEach(
function(object) {
object.updateInstance();
}
);
this.lightObjects.forEach(
function(object) {
object.updateInstance();
}
);
}
};
/**
* @callback
* @override
*/
GameLib.System.prototype.stop = function() {
if (this.systemType == GameLib.System.SYSTEM_TYPE_INPUT) {
this.driveInputObjects = [];
}
if (this.systemType == GameLib.System.SYSTEM_TYPE_RENDER) {
this.domElement.innerHTML = 'Rendering System Stopped';
this.renderers = [];
this.viewports = [];
}
if (this.systemType == GameLib.System.SYSTEM_TYPE_ANIMATION) {
this.pathFollowingObjects = [];
this.followObjects = [];
this.meshObjects = [];
this.lookAtObjects = [];
this.cameraObjects = [];
this.lightObjects = [];
}
};