where to store components
parent
8c551eb936
commit
585c8e0d6f
|
@ -4,6 +4,7 @@
|
||||||
* @param name
|
* @param name
|
||||||
* @param baseUrl
|
* @param baseUrl
|
||||||
* @param path
|
* @param path
|
||||||
|
* @param imageFactory
|
||||||
* @param games [GameLib.API.D3.Game]
|
* @param games [GameLib.API.D3.Game]
|
||||||
* @param scenes
|
* @param scenes
|
||||||
* @param cameras
|
* @param cameras
|
||||||
|
@ -23,6 +24,7 @@ GameLib.D3.API.Editor = function(
|
||||||
name,
|
name,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
path,
|
path,
|
||||||
|
imageFactory,
|
||||||
games,
|
games,
|
||||||
scenes,
|
scenes,
|
||||||
cameras,
|
cameras,
|
||||||
|
@ -40,6 +42,7 @@ GameLib.D3.API.Editor = function(
|
||||||
this,
|
this,
|
||||||
GameLib.Component.COMPONENT_EDITOR,
|
GameLib.Component.COMPONENT_EDITOR,
|
||||||
{
|
{
|
||||||
|
'imageFactory' : GameLib.D3.ImageFactory,
|
||||||
'games' : [GameLib.D3.Game],
|
'games' : [GameLib.D3.Game],
|
||||||
'scenes' : [GameLib.D3.Scene],
|
'scenes' : [GameLib.D3.Scene],
|
||||||
'cameras' : [GameLib.D3.Camera],
|
'cameras' : [GameLib.D3.Camera],
|
||||||
|
@ -74,6 +77,11 @@ GameLib.D3.API.Editor = function(
|
||||||
}
|
}
|
||||||
this.path = path;
|
this.path = path;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||||
|
imageFactory = null;
|
||||||
|
}
|
||||||
|
this.imageFactory = imageFactory;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(games)) {
|
if (GameLib.Utils.UndefinedOrNull(games)) {
|
||||||
games = [];
|
games = [];
|
||||||
}
|
}
|
||||||
|
@ -141,6 +149,7 @@ GameLib.D3.API.Editor.prototype.constructor = GameLib.D3.API.Editor;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
|
GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
|
||||||
|
|
||||||
|
var apiImageFactory = null;
|
||||||
var apiGames = [];
|
var apiGames = [];
|
||||||
var apiScenes = [];
|
var apiScenes = [];
|
||||||
var apiCameras = [];
|
var apiCameras = [];
|
||||||
|
@ -151,6 +160,10 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
|
||||||
var apiSystems = [];
|
var apiSystems = [];
|
||||||
var apiEntityManager = null;
|
var apiEntityManager = null;
|
||||||
|
|
||||||
|
if (objectEditor.imageFactory) {
|
||||||
|
apiImageFactory = GameLib.D3.API.ImageFactory.FromObjectImageFactory(objectEditor.imageFactory);
|
||||||
|
}
|
||||||
|
|
||||||
if (objectEditor.games) {
|
if (objectEditor.games) {
|
||||||
apiGames = objectEditor.games.map(
|
apiGames = objectEditor.games.map(
|
||||||
function(objectGame){
|
function(objectGame){
|
||||||
|
@ -224,6 +237,7 @@ GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
|
||||||
objectEditor.name,
|
objectEditor.name,
|
||||||
objectEditor.baseUrl,
|
objectEditor.baseUrl,
|
||||||
objectEditor.path,
|
objectEditor.path,
|
||||||
|
apiImageFactory,
|
||||||
apiGames,
|
apiGames,
|
||||||
apiScenes,
|
apiScenes,
|
||||||
apiCameras,
|
apiCameras,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* @param id
|
* @param id
|
||||||
* @param name
|
* @param name
|
||||||
* @param gameType
|
* @param gameType
|
||||||
|
* @param imageFactory
|
||||||
* @param width
|
* @param width
|
||||||
* @param height
|
* @param height
|
||||||
* @param baseUrl
|
* @param baseUrl
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
* @param systems
|
* @param systems
|
||||||
* @param viewports
|
* @param viewports
|
||||||
* @param entityManager
|
* @param entityManager
|
||||||
* @param mouse
|
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -23,9 +23,8 @@ GameLib.D3.API.Game = function(
|
||||||
name,
|
name,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
path,
|
path,
|
||||||
|
imageFactory,
|
||||||
gameType,
|
gameType,
|
||||||
width,
|
|
||||||
height,
|
|
||||||
cameras,
|
cameras,
|
||||||
composers,
|
composers,
|
||||||
viewports,
|
viewports,
|
||||||
|
@ -33,21 +32,20 @@ GameLib.D3.API.Game = function(
|
||||||
renderTargets,
|
renderTargets,
|
||||||
systems,
|
systems,
|
||||||
entityManager,
|
entityManager,
|
||||||
mouse,
|
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
GameLib.Component.call(
|
||||||
this,
|
this,
|
||||||
GameLib.Component.COMPONENT_GAME,
|
GameLib.Component.COMPONENT_GAME,
|
||||||
{
|
{
|
||||||
|
'imageFactory' : GameLib.D3.ImageFactory,
|
||||||
'cameras' : [GameLib.D3.Camera],
|
'cameras' : [GameLib.D3.Camera],
|
||||||
'composers' : [GameLib.D3.Composer],
|
'composers' : [GameLib.D3.Composer],
|
||||||
'viewports' : [GameLib.D3.Viewport],
|
'viewports' : [GameLib.D3.Viewport],
|
||||||
'renderers' : [GameLib.D3.Renderer],
|
'renderers' : [GameLib.D3.Renderer],
|
||||||
'renderTargets' : [GameLib.D3.RenderTarget],
|
'renderTargets' : [GameLib.D3.RenderTarget],
|
||||||
'systems' : [GameLib.System],
|
'systems' : [GameLib.System],
|
||||||
'entityManager' : GameLib.EntityManager,
|
'entityManager' : GameLib.EntityManager
|
||||||
'mouse' : GameLib.Mouse
|
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
parentEntity
|
parentEntity
|
||||||
|
@ -74,21 +72,16 @@ GameLib.D3.API.Game = function(
|
||||||
}
|
}
|
||||||
this.path = path;
|
this.path = path;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||||
|
imageFactory = null;
|
||||||
|
}
|
||||||
|
this.imageFactory = imageFactory;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(gameType)) {
|
if (GameLib.Utils.UndefinedOrNull(gameType)) {
|
||||||
gameType = GameLib.D3.Game.GAME_TYPE_VR_PONG;
|
gameType = GameLib.D3.Game.GAME_TYPE_VR_PONG;
|
||||||
}
|
}
|
||||||
this.gameType = gameType;
|
this.gameType = gameType;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(width)) {
|
|
||||||
width = 800;
|
|
||||||
}
|
|
||||||
this.width = width;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(height)) {
|
|
||||||
height = 600;
|
|
||||||
}
|
|
||||||
this.height = height;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(cameras)) {
|
if (GameLib.Utils.UndefinedOrNull(cameras)) {
|
||||||
cameras = [];
|
cameras = [];
|
||||||
}
|
}
|
||||||
|
@ -120,14 +113,10 @@ GameLib.D3.API.Game = function(
|
||||||
this.systems = systems;
|
this.systems = systems;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
|
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
|
||||||
entityManager = new GameLib.API.EntityManager();
|
entityManager = null;
|
||||||
}
|
}
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(mouse)) {
|
|
||||||
mouse = new GameLib.API.Mouse();
|
|
||||||
}
|
|
||||||
this.mouse = mouse;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Game.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Game.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
@ -140,6 +129,7 @@ GameLib.D3.API.Game.prototype.constructor = GameLib.D3.API.Game;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||||
|
|
||||||
|
var apiImageFactory = null;
|
||||||
var apiCameras = [];
|
var apiCameras = [];
|
||||||
var apiComposers = [];
|
var apiComposers = [];
|
||||||
var apiViewports = [];
|
var apiViewports = [];
|
||||||
|
@ -148,7 +138,10 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||||
var apiSystems = [];
|
var apiSystems = [];
|
||||||
|
|
||||||
var apiEntityManager = null;
|
var apiEntityManager = null;
|
||||||
var apiMouse = null;
|
|
||||||
|
if (objectGame.imageFactory) {
|
||||||
|
apiImageFactory = GameLib.D3.API.ImageFactory.FromObjectImageFactory(objectGame.imageFactory);
|
||||||
|
}
|
||||||
|
|
||||||
if (objectGame.cameras) {
|
if (objectGame.cameras) {
|
||||||
apiCameras = objectGame.cameras.map(
|
apiCameras = objectGame.cameras.map(
|
||||||
|
@ -202,18 +195,13 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||||
apiEntityManager = GameLib.API.EntityManager.FromObjectEntityManager(objectGame.entityManager);
|
apiEntityManager = GameLib.API.EntityManager.FromObjectEntityManager(objectGame.entityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectGame.mouse) {
|
|
||||||
apiMouse = GameLib.API.Mouse.FromObjectMouse(objectGame.mouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new GameLib.D3.API.Game(
|
return new GameLib.D3.API.Game(
|
||||||
objectGame.id,
|
objectGame.id,
|
||||||
objectGame.name,
|
objectGame.name,
|
||||||
objectGame.baseUrl,
|
objectGame.baseUrl,
|
||||||
objectGame.path,
|
objectGame.path,
|
||||||
|
apiImageFactory,
|
||||||
objectGame.gameType,
|
objectGame.gameType,
|
||||||
objectGame.width,
|
|
||||||
objectGame.height,
|
|
||||||
apiCameras,
|
apiCameras,
|
||||||
apiComposers,
|
apiComposers,
|
||||||
apiViewports,
|
apiViewports,
|
||||||
|
@ -221,7 +209,6 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||||
apiRenderTargets,
|
apiRenderTargets,
|
||||||
apiSystems,
|
apiSystems,
|
||||||
apiEntityManager,
|
apiEntityManager,
|
||||||
apiMouse,
|
|
||||||
objectGame.parentEntity
|
objectGame.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* This component makes the parentEntity (ex. car) follow the path provided by the spline
|
* This component makes the parentEntity (ex. car) follow the path provided by the spline
|
||||||
* @param id String
|
* @param id String
|
||||||
* @param name String
|
* @param name String
|
||||||
* @param domElementId
|
* @param domElement
|
||||||
* @param domContainerId
|
* @param domContainer
|
||||||
* @param editor GameLib.D3.API.Editor
|
* @param editor GameLib.D3.API.Editor
|
||||||
* @param camera
|
* @param camera
|
||||||
* @param widthOffset
|
* @param widthOffset
|
||||||
|
@ -17,8 +17,8 @@
|
||||||
GameLib.D3.API.Input.Editor = function (
|
GameLib.D3.API.Input.Editor = function (
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
domElementId,
|
domElement,
|
||||||
domContainerId,
|
domContainer,
|
||||||
editor,
|
editor,
|
||||||
camera,
|
camera,
|
||||||
widthOffset,
|
widthOffset,
|
||||||
|
@ -49,15 +49,15 @@ GameLib.D3.API.Input.Editor = function (
|
||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(domElementId)) {
|
if (GameLib.Utils.UndefinedOrNull(domElement)) {
|
||||||
domElementId = 'divCanvas';
|
domElement = null;
|
||||||
}
|
}
|
||||||
this.domElementId = domElementId;
|
this.domElement = domElement;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(domContainerId)) {
|
if (GameLib.Utils.UndefinedOrNull(domContainer)) {
|
||||||
domContainerId = 'divContainer';
|
domContainer = null;
|
||||||
}
|
}
|
||||||
this.domContainerId = domContainerId;
|
this.domContainer = domContainer;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(editor)) {
|
if (GameLib.Utils.UndefinedOrNull(editor)) {
|
||||||
editor = null;
|
editor = null;
|
||||||
|
@ -108,8 +108,8 @@ GameLib.D3.API.Input.Editor.FromObjectComponent = function(objectComponent) {
|
||||||
return new GameLib.D3.API.Input.Editor(
|
return new GameLib.D3.API.Input.Editor(
|
||||||
objectComponent.id,
|
objectComponent.id,
|
||||||
objectComponent.name,
|
objectComponent.name,
|
||||||
objectComponent.domElementId,
|
objectComponent.domElement,
|
||||||
objectComponent.domContainerId,
|
objectComponent.domContainer,
|
||||||
objectComponent.editor,
|
objectComponent.editor,
|
||||||
objectComponent.camera,
|
objectComponent.camera,
|
||||||
objectComponent.widthOffset,
|
objectComponent.widthOffset,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
GameLib.D3.API.Scene = function(
|
GameLib.D3.API.Scene = function(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
|
imageFactory,
|
||||||
meshes,
|
meshes,
|
||||||
position,
|
position,
|
||||||
quaternion,
|
quaternion,
|
||||||
|
@ -30,6 +31,7 @@ GameLib.D3.API.Scene = function(
|
||||||
this,
|
this,
|
||||||
GameLib.Component.COMPONENT_SCENE,
|
GameLib.Component.COMPONENT_SCENE,
|
||||||
{
|
{
|
||||||
|
'imageFactory' : GameLib.D3.ImageFactory,
|
||||||
'meshes' : [GameLib.D3.Mesh],
|
'meshes' : [GameLib.D3.Mesh],
|
||||||
'lights' : [GameLib.D3.Light],
|
'lights' : [GameLib.D3.Light],
|
||||||
'textures' : [GameLib.D3.Texture],
|
'textures' : [GameLib.D3.Texture],
|
||||||
|
@ -49,6 +51,12 @@ GameLib.D3.API.Scene = function(
|
||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||||
|
imageFactory = null;
|
||||||
|
console.warn('Constructing an API Scene with no Image Factory')
|
||||||
|
}
|
||||||
|
this.imageFactory = imageFactory;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(meshes)) {
|
if (GameLib.Utils.UndefinedOrNull(meshes)) {
|
||||||
meshes = [];
|
meshes = [];
|
||||||
}
|
}
|
||||||
|
@ -101,6 +109,7 @@ GameLib.D3.API.Scene.prototype.constructor = GameLib.D3.API.Scene;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Scene.FromObjectScene = function(objectScene) {
|
GameLib.D3.API.Scene.FromObjectScene = function(objectScene) {
|
||||||
|
|
||||||
|
var apiImageFactory = null;
|
||||||
var apiMeshes = [];
|
var apiMeshes = [];
|
||||||
var apiLights = [];
|
var apiLights = [];
|
||||||
var apiTextures = [];
|
var apiTextures = [];
|
||||||
|
@ -110,6 +119,10 @@ GameLib.D3.API.Scene.FromObjectScene = function(objectScene) {
|
||||||
var apiQuaternion = new GameLib.API.Quaternion();
|
var apiQuaternion = new GameLib.API.Quaternion();
|
||||||
var apiScale = new GameLib.API.Vector3(1,1,1);
|
var apiScale = new GameLib.API.Vector3(1,1,1);
|
||||||
|
|
||||||
|
if (objectScene.imageFactory) {
|
||||||
|
apiImageFactory = GameLib.D3.API.ImageFactory.FromObjectImageFactory(objectScene.imageFactory);
|
||||||
|
}
|
||||||
|
|
||||||
if (objectScene.meshes) {
|
if (objectScene.meshes) {
|
||||||
apiMeshes = objectScene.meshes.map(
|
apiMeshes = objectScene.meshes.map(
|
||||||
function(objectMesh) {
|
function(objectMesh) {
|
||||||
|
@ -157,6 +170,7 @@ GameLib.D3.API.Scene.FromObjectScene = function(objectScene) {
|
||||||
return new GameLib.D3.API.Scene(
|
return new GameLib.D3.API.Scene(
|
||||||
objectScene.id,
|
objectScene.id,
|
||||||
objectScene.name,
|
objectScene.name,
|
||||||
|
apiImageFactory,
|
||||||
apiMeshes,
|
apiMeshes,
|
||||||
apiPosition,
|
apiPosition,
|
||||||
apiQuaternion,
|
apiQuaternion,
|
||||||
|
|
|
@ -26,6 +26,34 @@ GameLib.D3.Composer = function (
|
||||||
apiComposer.parentEntity
|
apiComposer.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.renderer instanceof GameLib.D3.API.Renderer) {
|
||||||
|
this.renderer = new GameLib.D3.Renderer(
|
||||||
|
this.graphics,
|
||||||
|
this.renderer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.renderTarget instanceof GameLib.D3.API.RenderTarget) {
|
||||||
|
this.renderTarget = new GameLib.D3.RenderTarget(
|
||||||
|
this.graphics,
|
||||||
|
this.renderTarget
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.passes = this.passes.map(
|
||||||
|
function (apiPass) {
|
||||||
|
if (apiPass instanceof GameLib.D3.API.Pass) {
|
||||||
|
return GameLib.D3.Pass(
|
||||||
|
this.graphics,
|
||||||
|
apiPass
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
console.warn('apiPass not of type API.Pass');
|
||||||
|
throw new Error('apiPass not of type API.Pass');
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
this.buildIdToObject();
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
this.instance = this.createInstance();
|
||||||
|
|
|
@ -28,6 +28,7 @@ GameLib.D3.Editor = function(
|
||||||
apiEditor.name,
|
apiEditor.name,
|
||||||
apiEditor.baseUrl,
|
apiEditor.baseUrl,
|
||||||
apiEditor.path,
|
apiEditor.path,
|
||||||
|
apiEditor.imageFactory,
|
||||||
apiEditor.games,
|
apiEditor.games,
|
||||||
apiEditor.scenes,
|
apiEditor.scenes,
|
||||||
apiEditor.cameras,
|
apiEditor.cameras,
|
||||||
|
@ -42,10 +43,12 @@ GameLib.D3.Editor = function(
|
||||||
apiEditor.parentEntity
|
apiEditor.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
this.imageFactory = new GameLib.D3.ImageFactory(
|
if (this.imageFactory instanceof GameLib.D3.API.ImageFactory) {
|
||||||
this.graphics,
|
this.imageFactory = new GameLib.D3.ImageFactory(
|
||||||
this.baseUrl + this.path
|
this.graphics,
|
||||||
);
|
this.imageFactory
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.games) {
|
if (this.games) {
|
||||||
this.games = this.games.map(
|
this.games = this.games.map(
|
||||||
|
@ -53,7 +56,8 @@ GameLib.D3.Editor = function(
|
||||||
if (apiGame instanceof GameLib.D3.API.Game) {
|
if (apiGame instanceof GameLib.D3.API.Game) {
|
||||||
return new GameLib.D3.Game(
|
return new GameLib.D3.Game(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiGame
|
apiGame,
|
||||||
|
this.imageFactory
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -111,7 +115,7 @@ GameLib.D3.Editor = function(
|
||||||
this.viewports = this.viewports.map(
|
this.viewports = this.viewports.map(
|
||||||
function (apiViewport) {
|
function (apiViewport) {
|
||||||
if (apiViewport instanceof GameLib.D3.API.Viewport) {
|
if (apiViewport instanceof GameLib.D3.API.Viewport) {
|
||||||
return GameLib.D3.Viewport(
|
return new GameLib.D3.Viewport(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiViewport
|
apiViewport
|
||||||
)
|
)
|
||||||
|
@ -125,7 +129,7 @@ GameLib.D3.Editor = function(
|
||||||
this.renderers = this.renderers.map(
|
this.renderers = this.renderers.map(
|
||||||
function (apiRenderer) {
|
function (apiRenderer) {
|
||||||
if (apiRenderer instanceof GameLib.D3.API.Renderer) {
|
if (apiRenderer instanceof GameLib.D3.API.Renderer) {
|
||||||
return GameLib.D3.Renderer(
|
return new GameLib.D3.Renderer(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiRenderer
|
apiRenderer
|
||||||
)
|
)
|
||||||
|
@ -139,7 +143,7 @@ GameLib.D3.Editor = function(
|
||||||
this.renderTargets = this.renderTargets.map(
|
this.renderTargets = this.renderTargets.map(
|
||||||
function (apiRenderTarget) {
|
function (apiRenderTarget) {
|
||||||
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) {
|
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) {
|
||||||
return GameLib.D3.RenderTarget(
|
return new GameLib.D3.RenderTarget(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiRenderTarget
|
apiRenderTarget
|
||||||
)
|
)
|
||||||
|
@ -152,8 +156,8 @@ GameLib.D3.Editor = function(
|
||||||
|
|
||||||
this.systems = this.systems.map(
|
this.systems = this.systems.map(
|
||||||
function (apiSystem) {
|
function (apiSystem) {
|
||||||
if (apiSystem instanceof GameLib.D3.API.System) {
|
if (apiSystem instanceof GameLib.API.System) {
|
||||||
return GameLib.D3.System(
|
return new GameLib.System(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiSystem
|
apiSystem
|
||||||
)
|
)
|
||||||
|
@ -193,6 +197,11 @@ GameLib.D3.Editor = function(
|
||||||
|
|
||||||
this.buildIdToObject();
|
this.buildIdToObject();
|
||||||
|
|
||||||
|
this.meshMoveMode = false;
|
||||||
|
this.meshMoveXMode = false;
|
||||||
|
this.meshMoveYMode = false;
|
||||||
|
this.meshMoveZMode = false;
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
this.instance = this.createInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -227,6 +236,7 @@ GameLib.D3.Editor.prototype.updateInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Editor.prototype.toApiEditor = function() {
|
GameLib.D3.Editor.prototype.toApiEditor = function() {
|
||||||
|
|
||||||
|
var apiImageFactory = null;
|
||||||
var apiGames = [];
|
var apiGames = [];
|
||||||
var apiScenes = [];
|
var apiScenes = [];
|
||||||
var apiCameras = [];
|
var apiCameras = [];
|
||||||
|
@ -237,6 +247,10 @@ GameLib.D3.Editor.prototype.toApiEditor = function() {
|
||||||
var apiSystems = [];
|
var apiSystems = [];
|
||||||
var apiEntityManager = null;
|
var apiEntityManager = null;
|
||||||
|
|
||||||
|
if (this.imageFactory instanceof GameLib.D3.ImageFactory) {
|
||||||
|
apiImageFactory = this.imageFactory.toApiImageFactory();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.games) {
|
if (this.games) {
|
||||||
apiGames = this.games.map(
|
apiGames = this.games.map(
|
||||||
function(game) {
|
function(game) {
|
||||||
|
@ -355,6 +369,7 @@ GameLib.D3.Editor.prototype.toApiEditor = function() {
|
||||||
this.name,
|
this.name,
|
||||||
this.baseUrl,
|
this.baseUrl,
|
||||||
this.path,
|
this.path,
|
||||||
|
apiImageFactory,
|
||||||
apiGames,
|
apiGames,
|
||||||
apiScenes,
|
apiScenes,
|
||||||
apiCameras,
|
apiCameras,
|
||||||
|
|
|
@ -2,13 +2,11 @@
|
||||||
* Game Runtime
|
* Game Runtime
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param apiGame GameLib.D3.API.Game
|
* @param apiGame GameLib.D3.API.Game
|
||||||
* @param imageFactory GameLib.D3.ImageFactory
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Game = function (
|
GameLib.D3.Game = function (
|
||||||
graphics,
|
graphics,
|
||||||
apiGame,
|
apiGame
|
||||||
imageFactory
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
@ -24,9 +22,8 @@ GameLib.D3.Game = function (
|
||||||
apiGame.name,
|
apiGame.name,
|
||||||
apiGame.baseUrl,
|
apiGame.baseUrl,
|
||||||
apiGame.path,
|
apiGame.path,
|
||||||
|
apiGame.imageFactory,
|
||||||
apiGame.gameType,
|
apiGame.gameType,
|
||||||
apiGame.width,
|
|
||||||
apiGame.height,
|
|
||||||
apiGame.cameras,
|
apiGame.cameras,
|
||||||
apiGame.composers,
|
apiGame.composers,
|
||||||
apiGame.viewports,
|
apiGame.viewports,
|
||||||
|
@ -34,17 +31,15 @@ GameLib.D3.Game = function (
|
||||||
apiGame.renderTargets,
|
apiGame.renderTargets,
|
||||||
apiGame.systems,
|
apiGame.systems,
|
||||||
apiGame.entityManager,
|
apiGame.entityManager,
|
||||||
apiGame.mouse,
|
|
||||||
apiGame.parentEntity
|
apiGame.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
if (this.imageFactory instanceof GameLib.D3.API.ImageFactory) {
|
||||||
imageFactory = GameLib.D3.ImageFactory(
|
this.imageFactory = new GameLib.D3.ImageFactory(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.baseUrl + this.path
|
this.imageFactory
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.imageFactory = imageFactory;
|
|
||||||
|
|
||||||
this.cameras = this.cameras.map(
|
this.cameras = this.cameras.map(
|
||||||
function (apiCamera) {
|
function (apiCamera) {
|
||||||
|
@ -77,7 +72,7 @@ GameLib.D3.Game = function (
|
||||||
this.viewports = this.viewports.map(
|
this.viewports = this.viewports.map(
|
||||||
function (apiViewport) {
|
function (apiViewport) {
|
||||||
if (apiViewport instanceof GameLib.D3.API.Viewport) {
|
if (apiViewport instanceof GameLib.D3.API.Viewport) {
|
||||||
return GameLib.D3.Viewport(
|
return new GameLib.D3.Viewport(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiViewport
|
apiViewport
|
||||||
)
|
)
|
||||||
|
@ -91,7 +86,7 @@ GameLib.D3.Game = function (
|
||||||
this.renderers = this.renderers.map(
|
this.renderers = this.renderers.map(
|
||||||
function (apiRenderer) {
|
function (apiRenderer) {
|
||||||
if (apiRenderer instanceof GameLib.D3.API.Renderer) {
|
if (apiRenderer instanceof GameLib.D3.API.Renderer) {
|
||||||
return GameLib.D3.Renderer(
|
return new GameLib.D3.Renderer(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiRenderer
|
apiRenderer
|
||||||
)
|
)
|
||||||
|
@ -105,7 +100,7 @@ GameLib.D3.Game = function (
|
||||||
this.renderTargets = this.renderTargets.map(
|
this.renderTargets = this.renderTargets.map(
|
||||||
function (apiRenderTarget) {
|
function (apiRenderTarget) {
|
||||||
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) {
|
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) {
|
||||||
return GameLib.D3.RenderTarget(
|
return new GameLib.D3.RenderTarget(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiRenderTarget
|
apiRenderTarget
|
||||||
)
|
)
|
||||||
|
@ -118,8 +113,8 @@ GameLib.D3.Game = function (
|
||||||
|
|
||||||
this.systems = this.systems.map(
|
this.systems = this.systems.map(
|
||||||
function (apiSystem) {
|
function (apiSystem) {
|
||||||
if (apiSystem instanceof GameLib.D3.API.System) {
|
if (apiSystem instanceof GameLib.API.System) {
|
||||||
return GameLib.D3.System(
|
return new GameLib.System(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiSystem
|
apiSystem
|
||||||
)
|
)
|
||||||
|
@ -142,16 +137,6 @@ GameLib.D3.Game = function (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mouse instanceof GameLib.API.Mouse) {
|
|
||||||
this.mouse = new GameLib.Mouse(
|
|
||||||
this.graphics,
|
|
||||||
this.mouse
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.warn('mouse not of type API.Mouse');
|
|
||||||
throw new Error('mouse not of type API.Mouse');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.buildIdToObject();
|
this.buildIdToObject();
|
||||||
|
|
||||||
this.entityManager.linkObjects(this.idToObject);
|
this.entityManager.linkObjects(this.idToObject);
|
||||||
|
@ -214,6 +199,7 @@ GameLib.D3.Game.prototype.updateInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Game.prototype.toApiGame = function() {
|
GameLib.D3.Game.prototype.toApiGame = function() {
|
||||||
|
|
||||||
|
var apiImageFactory = null;
|
||||||
var apiCameras = [];
|
var apiCameras = [];
|
||||||
var apiComposers = [];
|
var apiComposers = [];
|
||||||
var apiViewports = [];
|
var apiViewports = [];
|
||||||
|
@ -221,7 +207,10 @@ GameLib.D3.Game.prototype.toApiGame = function() {
|
||||||
var apiRenderTargets = [];
|
var apiRenderTargets = [];
|
||||||
var apiSystems = [];
|
var apiSystems = [];
|
||||||
var apiEntityManager = null;
|
var apiEntityManager = null;
|
||||||
var apiMouse = null;
|
|
||||||
|
if (this.imageFactory instanceof GameLib.D3.ImageFactory) {
|
||||||
|
apiImageFactory = this.imageFactory.toApiImageFactory();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.cameras) {
|
if (this.cameras) {
|
||||||
apiCameras = this.cameras.map(
|
apiCameras = this.cameras.map(
|
||||||
|
@ -310,23 +299,13 @@ GameLib.D3.Game.prototype.toApiGame = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
return new GameLib.D3.API.Game(
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
this.baseUrl,
|
this.baseUrl,
|
||||||
this.path,
|
this.path,
|
||||||
|
apiImageFactory,
|
||||||
this.gameType,
|
this.gameType,
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
apiCameras,
|
apiCameras,
|
||||||
apiComposers,
|
apiComposers,
|
||||||
apiViewports,
|
apiViewports,
|
||||||
|
@ -334,7 +313,6 @@ GameLib.D3.Game.prototype.toApiGame = function() {
|
||||||
apiRenderTargets,
|
apiRenderTargets,
|
||||||
apiSystems,
|
apiSystems,
|
||||||
apiEntityManager,
|
apiEntityManager,
|
||||||
apiMouse,
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,8 +22,8 @@ GameLib.D3.Input.Editor = function (
|
||||||
this,
|
this,
|
||||||
apiInputEditor.id,
|
apiInputEditor.id,
|
||||||
apiInputEditor.name,
|
apiInputEditor.name,
|
||||||
apiInputEditor.domElementId,
|
apiInputEditor.domElement,
|
||||||
apiInputEditor.domContainerId,
|
apiInputEditor.domContainer,
|
||||||
apiInputEditor.editor,
|
apiInputEditor.editor,
|
||||||
apiInputEditor.camera,
|
apiInputEditor.camera,
|
||||||
apiInputEditor.widthOffset,
|
apiInputEditor.widthOffset,
|
||||||
|
@ -35,13 +35,25 @@ GameLib.D3.Input.Editor = function (
|
||||||
);
|
);
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(dom)) {
|
if (GameLib.Utils.UndefinedOrNull(dom)) {
|
||||||
console.warn('Cannot create Input without an handle to the DOM');
|
console.warn('Cannot create window resize event without handle to the DOM');
|
||||||
throw new Error('Cannot create Input without an handle to the DOM');
|
dom = null;
|
||||||
|
// throw new Error('Cannot create Input without an handle to the DOM');
|
||||||
}
|
}
|
||||||
this.dom = dom;
|
this.dom = dom;
|
||||||
|
|
||||||
this.element = null;
|
if (this.domElement instanceof GameLib.API.DomElement) {
|
||||||
this.container = null;
|
this.domElement = new GameLib.DomElement(
|
||||||
|
this.graphics,
|
||||||
|
this.domElement
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.domContainer instanceof GameLib.API.DomElement) {
|
||||||
|
this.domContainer = new GameLib.DomElement(
|
||||||
|
this.graphics,
|
||||||
|
this.domContainer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
this.meshMoveMode = false;
|
this.meshMoveMode = false;
|
||||||
this.meshMoveXMode = false;
|
this.meshMoveXMode = false;
|
||||||
|
@ -77,18 +89,6 @@ GameLib.D3.Input.Editor.prototype.constructor = GameLib.D3.Input.Editor;
|
||||||
|
|
||||||
GameLib.D3.Input.Editor.prototype.createInstance = function(update) {
|
GameLib.D3.Input.Editor.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
this.element = this.dom.document.getElementById(this.domElementId);
|
|
||||||
if (!this.element) {
|
|
||||||
console.warn('Could not locate DOM element with ID: ' + this.domElementId);
|
|
||||||
throw new Error('Could not locate DOM element with ID: ' + this.domElementId);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.container = this.dom.document.getElementById(this.domContainerId);
|
|
||||||
if (!this.container) {
|
|
||||||
console.warn('Could not locate DOM container with ID: ' + this.domContainerId);
|
|
||||||
throw new Error('Could not locate DOM container with ID: ' + this.domContainerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
var instance = null;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
@ -98,39 +98,40 @@ GameLib.D3.Input.Editor.prototype.createInstance = function(update) {
|
||||||
} else {
|
} else {
|
||||||
instance = new THREE.EditorControls(
|
instance = new THREE.EditorControls(
|
||||||
this.camera.instance,
|
this.camera.instance,
|
||||||
this.element
|
this.domElement.instance
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.element.addEventListener(
|
this.domElement.instance.addEventListener(
|
||||||
'mousemove',
|
'mousemove',
|
||||||
this.mouseMove,
|
this.mouseMove,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
this.element.addEventListener(
|
this.domElement.instance.addEventListener(
|
||||||
'contextmenu',
|
'contextmenu',
|
||||||
this.contextMenu,
|
this.contextMenu,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
this.element.addEventListener(
|
this.domElement.instance.addEventListener(
|
||||||
'mousedown',
|
'mousedown',
|
||||||
this.mouseDown,
|
this.mouseDown,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
this.element.addEventListener(
|
this.domElement.instance.addEventListener(
|
||||||
'keydown',
|
'keydown',
|
||||||
this.keyPress,
|
this.keyPress,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
this.dom.window.addEventListener(
|
//TODO : window resize
|
||||||
'resize',
|
// this.dom.window.addEventListener(
|
||||||
this.resize,
|
// 'resize',
|
||||||
false
|
// this.resize,
|
||||||
);
|
// false
|
||||||
|
// );
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
@ -175,8 +176,8 @@ GameLib.D3.Input.Editor.FromObjectComponent = function(graphics, objectComponent
|
||||||
|
|
||||||
GameLib.D3.Input.Editor.prototype.onWindowResize = function() {
|
GameLib.D3.Input.Editor.prototype.onWindowResize = function() {
|
||||||
|
|
||||||
this.container.style.height = (this.window.innerHeight - this.containerHeightOffset) + 'px';
|
this.domContainer.instance.style.height = (this.window.innerHeight - this.containerHeightOffset) + 'px';
|
||||||
this.container.style.width = (this.window.innerWidth - this.containerWidthOffset) + 'px';
|
this.domContainer.instance.style.width = (this.window.innerWidth - this.containerWidthOffset) + 'px';
|
||||||
|
|
||||||
var width = this.window.innerWidth - this.widthOffset;
|
var width = this.window.innerWidth - this.widthOffset;
|
||||||
|
|
||||||
|
@ -444,31 +445,5 @@ GameLib.D3.Input.Editor.prototype.onContextMenu = function(event){
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Input.Editor.prototype.update = function(deltaTime) {
|
GameLib.D3.Input.Editor.prototype.update = function(deltaTime) {
|
||||||
if (this.pathFollowingComponent) {
|
return;
|
||||||
|
|
||||||
this.pathFollowingComponent.mesh.localPosition.x = (this.heightOffset * this.pathFollowingComponent.rotationMatrix.up.x);
|
|
||||||
this.pathFollowingComponent.mesh.localPosition.y = (this.heightOffset * this.pathFollowingComponent.rotationMatrix.up.y);
|
|
||||||
this.pathFollowingComponent.mesh.localPosition.z = (this.heightOffset * this.pathFollowingComponent.rotationMatrix.up.z);
|
|
||||||
|
|
||||||
if (this.keyLeft) {
|
|
||||||
this.distance -= this.distanceGrain;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.keyRight) {
|
|
||||||
this.distance += this.distanceGrain;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.pathFollowingComponent.mesh.localPosition.x += (this.distance * this.pathFollowingComponent.rotationMatrix.left.x);
|
|
||||||
this.pathFollowingComponent.mesh.localPosition.y += (this.distance * this.pathFollowingComponent.rotationMatrix.left.y);
|
|
||||||
this.pathFollowingComponent.mesh.localPosition.z += (this.distance * this.pathFollowingComponent.rotationMatrix.left.z);
|
|
||||||
|
|
||||||
this.wheelFL.localRotation.x += this.rotationFactor * this.pathFollowingComponent.currentSpeed;
|
|
||||||
this.wheelFR.localRotation.x += this.rotationFactor * this.pathFollowingComponent.currentSpeed;
|
|
||||||
|
|
||||||
this.wheelFL.localRotation.x += this.rotationFactor * this.pathFollowingComponent.currentSpeed;
|
|
||||||
this.wheelFR.localRotation.x += this.rotationFactor * this.pathFollowingComponent.currentSpeed;
|
|
||||||
|
|
||||||
this.wheelRL.localRotation.x += this.rotationFactor * this.pathFollowingComponent.currentSpeed;
|
|
||||||
this.wheelRR.localRotation.x += this.rotationFactor * this.pathFollowingComponent.currentSpeed;
|
|
||||||
}
|
|
||||||
};
|
};
|
|
@ -10,7 +10,6 @@
|
||||||
GameLib.D3.Scene = function (
|
GameLib.D3.Scene = function (
|
||||||
graphics,
|
graphics,
|
||||||
apiScene,
|
apiScene,
|
||||||
imageFactory,
|
|
||||||
computeNormals
|
computeNormals
|
||||||
) {
|
) {
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
@ -29,6 +28,7 @@ GameLib.D3.Scene = function (
|
||||||
this,
|
this,
|
||||||
apiScene.id,
|
apiScene.id,
|
||||||
apiScene.name,
|
apiScene.name,
|
||||||
|
apiScene.imageFactory,
|
||||||
apiScene.meshes,
|
apiScene.meshes,
|
||||||
apiScene.position,
|
apiScene.position,
|
||||||
apiScene.quaternion,
|
apiScene.quaternion,
|
||||||
|
@ -40,11 +40,12 @@ GameLib.D3.Scene = function (
|
||||||
apiScene.parentEntity
|
apiScene.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
if (this.imageFactory instanceof GameLib.D3.API.ImageFactory) {
|
||||||
console.warn('Creating a scene without an ImageFactory');
|
this.imageFactory = new GameLib.D3.ImageFactory(
|
||||||
imageFactory = null;
|
this.graphics,
|
||||||
|
this.imageFactory
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this.imageFactory = imageFactory;
|
|
||||||
|
|
||||||
this.meshes = this.meshes.map(
|
this.meshes = this.meshes.map(
|
||||||
function(apiMesh) {
|
function(apiMesh) {
|
||||||
|
@ -202,6 +203,11 @@ GameLib.D3.Scene.prototype.createInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene.prototype.toApiScene = function() {
|
GameLib.D3.Scene.prototype.toApiScene = function() {
|
||||||
|
|
||||||
|
var apiImageFactory = null;
|
||||||
|
if (this.imageFactory instanceof GameLib.D3.ImageFactory) {
|
||||||
|
apiImageFactory = this.imageFactory.toApiImageFactory();
|
||||||
|
}
|
||||||
|
|
||||||
var apiMeshes = this.meshes.map(
|
var apiMeshes = this.meshes.map(
|
||||||
function(mesh) {
|
function(mesh) {
|
||||||
return mesh.toApiMesh();
|
return mesh.toApiMesh();
|
||||||
|
@ -229,6 +235,7 @@ GameLib.D3.Scene.prototype.toApiScene = function() {
|
||||||
return new GameLib.D3.API.Scene(
|
return new GameLib.D3.API.Scene(
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
|
apiImageFactory,
|
||||||
apiMeshes,
|
apiMeshes,
|
||||||
this.position.toApiVector(),
|
this.position.toApiVector(),
|
||||||
this.quaternion.toApiQuaternion(),
|
this.quaternion.toApiQuaternion(),
|
||||||
|
@ -245,7 +252,6 @@ GameLib.D3.Scene.prototype.toApiScene = function() {
|
||||||
* Converts a scene Object to a GameLib.D3.Scene object
|
* Converts a scene Object to a GameLib.D3.Scene object
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param objectScene Object
|
* @param objectScene Object
|
||||||
* @param imageFactory GameLib.D3.ImageFactory
|
|
||||||
* @param computeNormals boolean to indicate whether or not to recalculate normals
|
* @param computeNormals boolean to indicate whether or not to recalculate normals
|
||||||
* @returns {GameLib.D3.Scene}
|
* @returns {GameLib.D3.Scene}
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -253,7 +259,6 @@ GameLib.D3.Scene.prototype.toApiScene = function() {
|
||||||
GameLib.D3.Scene.FromObjectScene = function(
|
GameLib.D3.Scene.FromObjectScene = function(
|
||||||
graphics,
|
graphics,
|
||||||
objectScene,
|
objectScene,
|
||||||
imageFactory,
|
|
||||||
computeNormals
|
computeNormals
|
||||||
) {
|
) {
|
||||||
var apiScene = GameLib.D3.API.Scene.FromObjectScene(objectScene);
|
var apiScene = GameLib.D3.API.Scene.FromObjectScene(objectScene);
|
||||||
|
@ -261,7 +266,6 @@ GameLib.D3.Scene.FromObjectScene = function(
|
||||||
return new GameLib.D3.Scene(
|
return new GameLib.D3.Scene(
|
||||||
graphics,
|
graphics,
|
||||||
apiScene,
|
apiScene,
|
||||||
imageFactory,
|
|
||||||
computeNormals
|
computeNormals
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -272,20 +276,17 @@ GameLib.D3.Scene.FromObjectScene = function(
|
||||||
* @param objectScene Object (as it comes from the API)
|
* @param objectScene Object (as it comes from the API)
|
||||||
* @param computeNormals
|
* @param computeNormals
|
||||||
* @param onLoaded
|
* @param onLoaded
|
||||||
* @param imageFactory GameLib.D3.ImageFactory
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene.LoadScene = function(
|
GameLib.D3.Scene.LoadScene = function(
|
||||||
graphics,
|
graphics,
|
||||||
objectScene,
|
objectScene,
|
||||||
computeNormals,
|
computeNormals,
|
||||||
onLoaded,
|
onLoaded
|
||||||
imageFactory
|
|
||||||
) {
|
) {
|
||||||
var scene = GameLib.D3.Scene.FromObjectScene(
|
var scene = GameLib.D3.Scene.FromObjectScene(
|
||||||
graphics,
|
graphics,
|
||||||
objectScene,
|
objectScene,
|
||||||
imageFactory,
|
|
||||||
computeNormals
|
computeNormals
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -298,14 +299,12 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
* @param partialSceneObject Object {path: '', name: ''}
|
* @param partialSceneObject Object {path: '', name: ''}
|
||||||
* @param apiUrl
|
* @param apiUrl
|
||||||
* @param onLoaded
|
* @param onLoaded
|
||||||
* @param imageFactory GameLib.D3.ImageFactory
|
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene.LoadSceneFromApi = function(
|
GameLib.D3.Scene.LoadSceneFromApi = function(
|
||||||
graphics,
|
graphics,
|
||||||
partialSceneObject,
|
partialSceneObject,
|
||||||
apiUrl,
|
apiUrl,
|
||||||
onLoaded,
|
onLoaded
|
||||||
imageFactory
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -344,8 +343,7 @@ GameLib.D3.Scene.LoadSceneFromApi = function(
|
||||||
graphics,
|
graphics,
|
||||||
objectScene,
|
objectScene,
|
||||||
true,
|
true,
|
||||||
onLoaded,
|
onLoaded
|
||||||
imageFactory
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Viewport = function (
|
GameLib.D3.Viewport = function (
|
||||||
graphics,
|
graphics,
|
||||||
apiViewport,
|
apiViewport
|
||||||
imageFactory
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
@ -18,11 +17,6 @@ GameLib.D3.Viewport = function (
|
||||||
apiViewport = {};
|
apiViewport = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
|
||||||
imageFactory = null;
|
|
||||||
}
|
|
||||||
this.imageFactory = imageFactory;
|
|
||||||
|
|
||||||
GameLib.D3.API.Viewport.call(
|
GameLib.D3.API.Viewport.call(
|
||||||
this,
|
this,
|
||||||
apiViewport.id,
|
apiViewport.id,
|
||||||
|
@ -55,8 +49,7 @@ GameLib.D3.Viewport = function (
|
||||||
if (this.scene instanceof GameLib.D3.API.Scene) {
|
if (this.scene instanceof GameLib.D3.API.Scene) {
|
||||||
this.scene = new GameLib.D3.Scene(
|
this.scene = new GameLib.D3.Scene(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.scene,
|
this.scene
|
||||||
this.imageFactory
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,7 @@ GameLib.DomElement.prototype.constructor = GameLib.DomElement;
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
GameLib.DomElement.prototype.createInstance = function(update) {
|
GameLib.DomElement.prototype.createInstance = function(update) {
|
||||||
|
return document.getElementById(this.domElementId);
|
||||||
var instance = document.getElementById(this.domElementId);
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,6 +61,10 @@ GameLib.Entity = function (
|
||||||
return new GameLib.D3.Follow(this.graphics, apiComponent);
|
return new GameLib.D3.Follow(this.graphics, apiComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (apiComponent instanceof GameLib.D3.API.Input.Editor) {
|
||||||
|
return new GameLib.D3.Input.Editor(this.graphics, apiComponent);
|
||||||
|
}
|
||||||
|
|
||||||
if (apiComponent instanceof GameLib.D3.API.Input.Drive) {
|
if (apiComponent instanceof GameLib.D3.API.Input.Drive) {
|
||||||
return new GameLib.D3.Input.Drive(this.graphics, apiComponent);
|
return new GameLib.D3.Input.Drive(this.graphics, apiComponent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,10 @@ GameLib.Mouse = function (graphics, apiMouse) {
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMouse)){
|
||||||
|
apiMouse = {};
|
||||||
|
}
|
||||||
|
|
||||||
GameLib.API.Mouse.call(
|
GameLib.API.Mouse.call(
|
||||||
this,
|
this,
|
||||||
apiMouse.id,
|
apiMouse.id,
|
||||||
|
|
|
@ -27,7 +27,19 @@ GameLib.System = function(
|
||||||
apiSystem.parentEntity
|
apiSystem.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.entityManager instanceof GameLib.API.EntityManager) {
|
||||||
|
this.entityManager = new GameLib.EntityManager(
|
||||||
|
this.graphics,
|
||||||
|
this.entityManager
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.domElement instanceof GameLib.API.DomElement) {
|
||||||
|
this.domElement = new GameLib.DomElement(
|
||||||
|
this.graphics,
|
||||||
|
this.domElement
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.prototype = Object.create(GameLib.API.System.prototype);
|
GameLib.System.prototype = Object.create(GameLib.API.System.prototype);
|
||||||
|
@ -179,13 +191,23 @@ GameLib.System.prototype.stop = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.System.prototype.toApiSystem = function() {
|
GameLib.System.prototype.toApiSystem = function() {
|
||||||
|
|
||||||
//TODO
|
var apiDomElement = null;
|
||||||
|
if (this.domElement instanceof GameLib.DomElement) {
|
||||||
|
apiDomElement = this.domElement.toApiDomElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
var apiDomStats = null;
|
||||||
|
if (this.domStats instanceof GameLib.DomElement) {
|
||||||
|
apiDomStats = this.domStats.toApiDomElement();
|
||||||
|
}
|
||||||
|
|
||||||
return new GameLib.API.System(
|
return new GameLib.API.System(
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
this.systemType,
|
this.systemType,
|
||||||
this.domElement.toApiDo,
|
GameLib.Utils.IdOrNull(this.entityManager),
|
||||||
this.domStats,
|
apiDomElement,
|
||||||
|
apiDomStats,
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue