systems to doms
parent
ba1aa215b7
commit
c3d51b5549
|
@ -54,6 +54,7 @@ GameLib.Component.COMPONENT_MOUSE = 0x18;
|
||||||
GameLib.Component.COMPONENT_SKELETON = 0x19;
|
GameLib.Component.COMPONENT_SKELETON = 0x19;
|
||||||
GameLib.Component.COMPONENT_TEXTURE = 0x1a;
|
GameLib.Component.COMPONENT_TEXTURE = 0x1a;
|
||||||
GameLib.Component.COMPONENT_ENTITY_MANAGER = 0x1b;
|
GameLib.Component.COMPONENT_ENTITY_MANAGER = 0x1b;
|
||||||
|
GameLib.Component.COMPONENT_DOM_ELEMENT = 0x1c;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Components are linked at runtime - for storing, we just store the ID
|
* Components are linked at runtime - for storing, we just store the ID
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
* API DomElement
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
* @param domElementId
|
||||||
|
* @param parentEntity
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.API.DomElement = function(
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
domElementId,
|
||||||
|
parentEntity
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_DOM_ELEMENT,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
parentEntity
|
||||||
|
);
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.Utils.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||||
|
name = 'DOM Element (' + this.id + ')';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(domElementId)) {
|
||||||
|
domElementId = '';
|
||||||
|
}
|
||||||
|
this.domElementId = domElementId;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.API.DomElement.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
GameLib.API.DomElement.prototype.constructor = GameLib.API.DomElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an API domElement from an Object domElement
|
||||||
|
* @param objectDomElement
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.API.DomElement.FromObjectDomElement = function (objectDomElement) {
|
||||||
|
return new GameLib.API.DomElement(
|
||||||
|
objectDomElement.id,
|
||||||
|
objectDomElement.name,
|
||||||
|
objectDomElement.domElementId,
|
||||||
|
objectDomElement.parentEntity
|
||||||
|
)
|
||||||
|
};
|
|
@ -26,32 +26,6 @@ GameLib.API.Entity = function(
|
||||||
this.components = components;
|
this.components = components;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a components to the entity
|
|
||||||
* @param component GameLib.Component
|
|
||||||
*/
|
|
||||||
GameLib.API.Entity.prototype.addComponent = function(component) {
|
|
||||||
this.components.push(component);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a component from this entity
|
|
||||||
* @param component GameLib.Component
|
|
||||||
*/
|
|
||||||
GameLib.API.Entity.prototype.removeComponent = function(component) {
|
|
||||||
|
|
||||||
var index = this.components.indexOf(component);
|
|
||||||
|
|
||||||
if (index == -1) {
|
|
||||||
console.log('failed to remove component');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.components.splice(index, 1);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an API entity from an Object entity
|
* Returns an API entity from an Object entity
|
||||||
* @param objectEntity
|
* @param objectEntity
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* @param name String
|
* @param name String
|
||||||
* @param systemType
|
* @param systemType
|
||||||
* @param entityManager
|
* @param entityManager
|
||||||
|
* @param domElement
|
||||||
|
* @param domStats
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -12,13 +14,19 @@ GameLib.API.System = function (
|
||||||
name,
|
name,
|
||||||
systemType,
|
systemType,
|
||||||
entityManager,
|
entityManager,
|
||||||
|
domElement,
|
||||||
|
domStats,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
GameLib.Component.call(
|
||||||
this,
|
this,
|
||||||
GameLib.Component.COMPONENT_SYSTEM,
|
GameLib.Component.COMPONENT_SYSTEM,
|
||||||
null,
|
{
|
||||||
|
'entityManager' : GameLib.EntityManager,
|
||||||
|
'domElement' : GameLib.DomElement,
|
||||||
|
'domStats' : GameLib.DomElement
|
||||||
|
},
|
||||||
null,
|
null,
|
||||||
parentEntity
|
parentEntity
|
||||||
);
|
);
|
||||||
|
@ -42,6 +50,16 @@ GameLib.API.System = function (
|
||||||
entityManager = null;
|
entityManager = null;
|
||||||
}
|
}
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(domElement)){
|
||||||
|
domElement = null;
|
||||||
|
}
|
||||||
|
this.domElement = domElement;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(domStats)){
|
||||||
|
domStats = null;
|
||||||
|
}
|
||||||
|
this.domStats = domStats;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.API.System.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.API.System.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
@ -58,6 +76,8 @@ GameLib.API.System.FromObjectComponent = function(objectComponent) {
|
||||||
objectComponent.name,
|
objectComponent.name,
|
||||||
objectComponent.systemType,
|
objectComponent.systemType,
|
||||||
objectComponent.entityManager,
|
objectComponent.entityManager,
|
||||||
|
objectComponent.domElement,
|
||||||
|
objectComponent.domStats,
|
||||||
objectComponent.parentEntity
|
objectComponent.parentEntity
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,28 +2,53 @@
|
||||||
* Raw Editor API object - should always correspond with the Editor Schema
|
* Raw Editor API object - should always correspond with the Editor Schema
|
||||||
* @param id
|
* @param id
|
||||||
* @param name
|
* @param name
|
||||||
* @param game [GameLib.API.D3.Game]
|
* @param baseUrl
|
||||||
|
* @param path
|
||||||
|
* @param games [GameLib.API.D3.Game]
|
||||||
|
* @param scenes
|
||||||
|
* @param cameras
|
||||||
|
* @param composers
|
||||||
|
* @param viewports
|
||||||
|
* @param renderers
|
||||||
|
* @param renderTargets
|
||||||
|
* @param systems
|
||||||
|
* @param entityManager
|
||||||
* @param allSelected
|
* @param allSelected
|
||||||
* @param selectedObjects
|
* @param selectedObjects
|
||||||
* @param viewports
|
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Editor = function(
|
GameLib.D3.API.Editor = function(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
game,
|
baseUrl,
|
||||||
|
path,
|
||||||
|
games,
|
||||||
|
scenes,
|
||||||
|
cameras,
|
||||||
|
composers,
|
||||||
|
viewports,
|
||||||
|
renderers,
|
||||||
|
renderTargets,
|
||||||
|
systems,
|
||||||
|
entityManager,
|
||||||
allSelected,
|
allSelected,
|
||||||
selectedObjects,
|
selectedObjects,
|
||||||
viewports,
|
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
GameLib.Component.call(
|
||||||
this,
|
this,
|
||||||
GameLib.Component.COMPONENT_EDITOR,
|
GameLib.Component.COMPONENT_EDITOR,
|
||||||
{
|
{
|
||||||
'game' : GameLib.D3.Game,
|
'games' : [GameLib.D3.Game],
|
||||||
'viewports' : [GameLib.D3.Viewport]
|
'scenes' : [GameLib.D3.Scene],
|
||||||
|
'cameras' : [GameLib.D3.Camera],
|
||||||
|
'composers' : [GameLib.D3.Composer],
|
||||||
|
'viewports' : [GameLib.D3.Viewport],
|
||||||
|
'renderers' : [GameLib.D3.Renderer],
|
||||||
|
'renderTargets' : [GameLib.D3.RenderTarget],
|
||||||
|
'systems' : [GameLib.System],
|
||||||
|
'entityManager' : GameLib.EntityManager
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
parentEntity
|
parentEntity
|
||||||
|
@ -39,10 +64,60 @@ GameLib.D3.API.Editor = function(
|
||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(game)) {
|
if (GameLib.Utils.UndefinedOrNull(baseUrl)) {
|
||||||
game = null;
|
baseUrl = '';
|
||||||
}
|
}
|
||||||
this.game = game;
|
this.baseUrl = baseUrl;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(path)) {
|
||||||
|
path = '';
|
||||||
|
}
|
||||||
|
this.path = path;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(games)) {
|
||||||
|
games = [];
|
||||||
|
}
|
||||||
|
this.games = games;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(scenes)) {
|
||||||
|
scenes = [];
|
||||||
|
}
|
||||||
|
this.scenes = scenes;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(cameras)) {
|
||||||
|
cameras = [];
|
||||||
|
}
|
||||||
|
this.cameras = cameras;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(composers)) {
|
||||||
|
composers = [];
|
||||||
|
}
|
||||||
|
this.composers = composers;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(viewports)) {
|
||||||
|
viewports = [];
|
||||||
|
}
|
||||||
|
this.viewports = viewports;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(renderers)) {
|
||||||
|
renderers = [];
|
||||||
|
}
|
||||||
|
this.renderers = renderers;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(renderTargets)) {
|
||||||
|
renderTargets = [];
|
||||||
|
}
|
||||||
|
this.renderTargets = renderTargets;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(systems)) {
|
||||||
|
systems = [];
|
||||||
|
}
|
||||||
|
this.systems = systems;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
|
||||||
|
entityManager = new GameLib.API.EntityManager();
|
||||||
|
}
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(allSelected)) {
|
if (GameLib.Utils.UndefinedOrNull(allSelected)) {
|
||||||
allSelected = false;
|
allSelected = false;
|
||||||
|
@ -54,11 +129,6 @@ GameLib.D3.API.Editor = function(
|
||||||
}
|
}
|
||||||
this.selectedObjects = selectedObjects;
|
this.selectedObjects = selectedObjects;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(viewports)) {
|
|
||||||
viewports = [];
|
|
||||||
}
|
|
||||||
this.viewports = viewports;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Editor.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Editor.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
@ -70,13 +140,101 @@ GameLib.D3.API.Editor.prototype.constructor = GameLib.D3.API.Editor;
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
|
GameLib.D3.API.Editor.FromObjectEditor = function(objectEditor) {
|
||||||
|
|
||||||
|
var apiGames = [];
|
||||||
|
var apiScenes = [];
|
||||||
|
var apiCameras = [];
|
||||||
|
var apiComposers = [];
|
||||||
|
var apiViewports = [];
|
||||||
|
var apiRenderers = [];
|
||||||
|
var apiRenderTargets = [];
|
||||||
|
var apiSystems = [];
|
||||||
|
var apiEntityManager = null;
|
||||||
|
|
||||||
|
if (objectEditor.games) {
|
||||||
|
apiGames = objectEditor.games.map(
|
||||||
|
function(objectGame){
|
||||||
|
return GameLib.D3.API.Game.FromObjectGame(objectGame);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectEditor.scenes) {
|
||||||
|
apiScenes = objectEditor.scenes.map(
|
||||||
|
function(objectScene){
|
||||||
|
return GameLib.D3.API.Scene.FromObjectScene(objectScene);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectEditor.cameras) {
|
||||||
|
apiCameras = objectEditor.cameras.map(
|
||||||
|
function(objectCamera){
|
||||||
|
return GameLib.D3.API.Camera.FromObjectCamera(objectCamera);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectEditor.composers) {
|
||||||
|
apiComposers = objectEditor.composers.map(
|
||||||
|
function(objectComposer){
|
||||||
|
return GameLib.D3.API.Composer.FromObjectComponent(objectComposer);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectEditor.viewports) {
|
||||||
|
apiViewports = objectEditor.viewports.map(
|
||||||
|
function(objectViewport){
|
||||||
|
return GameLib.D3.API.Viewport.FromObjectViewport(objectViewport);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectEditor.renderers) {
|
||||||
|
apiRenderers = objectEditor.renderers.map(
|
||||||
|
function(objectRenderer){
|
||||||
|
return GameLib.D3.API.Renderer.FromObjectComponent(objectRenderer);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectEditor.renderTargets) {
|
||||||
|
apiRenderTargets = objectEditor.renderTargets.map(
|
||||||
|
function(objectRenderTarget){
|
||||||
|
return GameLib.D3.API.RenderTarget.FromObjectComponent(objectRenderTarget);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectEditor.systems) {
|
||||||
|
apiSystems = objectEditor.systems.map(
|
||||||
|
function(objectSystem){
|
||||||
|
return GameLib.API.System.FromObjectComponent(objectSystem);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectEditor.entityManager) {
|
||||||
|
apiEntityManager = GameLib.API.EntityManager.FromObjectEntityManager(objectEditor.entityManager);
|
||||||
|
}
|
||||||
|
|
||||||
return new GameLib.D3.API.Editor(
|
return new GameLib.D3.API.Editor(
|
||||||
objectEditor.id,
|
objectEditor.id,
|
||||||
objectEditor.name,
|
objectEditor.name,
|
||||||
objectEditor.game,
|
objectEditor.baseUrl,
|
||||||
|
objectEditor.path,
|
||||||
|
apiGames,
|
||||||
|
apiScenes,
|
||||||
|
apiCameras,
|
||||||
|
apiComposers,
|
||||||
|
apiViewports,
|
||||||
|
apiRenderers,
|
||||||
|
apiRenderTargets,
|
||||||
|
apiSystems,
|
||||||
|
apiEntityManager,
|
||||||
objectEditor.allSelected,
|
objectEditor.allSelected,
|
||||||
objectEditor.selectedObjects,
|
objectEditor.selectedObjects,
|
||||||
objectEditor.viewports,
|
|
||||||
objectEditor.parentEntity
|
objectEditor.parentEntity
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
* @param height
|
* @param height
|
||||||
* @param baseUrl
|
* @param baseUrl
|
||||||
* @param path
|
* @param path
|
||||||
* @param scenes
|
|
||||||
* @param cameras
|
* @param cameras
|
||||||
* @param renderers
|
* @param renderers
|
||||||
* @param composers
|
* @param composers
|
||||||
|
* @param renderTargets
|
||||||
* @param systems
|
* @param systems
|
||||||
* @param viewports
|
* @param viewports
|
||||||
* @param entityManager
|
* @param entityManager
|
||||||
|
@ -26,12 +26,12 @@ GameLib.D3.API.Game = function(
|
||||||
gameType,
|
gameType,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
scenes,
|
|
||||||
cameras,
|
cameras,
|
||||||
renderers,
|
|
||||||
composers,
|
composers,
|
||||||
systems,
|
|
||||||
viewports,
|
viewports,
|
||||||
|
renderers,
|
||||||
|
renderTargets,
|
||||||
|
systems,
|
||||||
entityManager,
|
entityManager,
|
||||||
mouse,
|
mouse,
|
||||||
parentEntity
|
parentEntity
|
||||||
|
@ -40,12 +40,12 @@ GameLib.D3.API.Game = function(
|
||||||
this,
|
this,
|
||||||
GameLib.Component.COMPONENT_GAME,
|
GameLib.Component.COMPONENT_GAME,
|
||||||
{
|
{
|
||||||
'scenes' : [GameLib.D3.Scene],
|
|
||||||
'cameras' : [GameLib.D3.Camera],
|
'cameras' : [GameLib.D3.Camera],
|
||||||
'renderers' : [GameLib.D3.Renderer],
|
|
||||||
'composers' : [GameLib.D3.Composer],
|
'composers' : [GameLib.D3.Composer],
|
||||||
'systems' : [GameLib.System],
|
|
||||||
'viewports' : [GameLib.D3.Viewport],
|
'viewports' : [GameLib.D3.Viewport],
|
||||||
|
'renderers' : [GameLib.D3.Renderer],
|
||||||
|
'renderTargets' : [GameLib.D3.RenderTarget],
|
||||||
|
'systems' : [GameLib.System],
|
||||||
'entityManager' : GameLib.EntityManager,
|
'entityManager' : GameLib.EntityManager,
|
||||||
'mouse' : GameLib.Mouse
|
'mouse' : GameLib.Mouse
|
||||||
},
|
},
|
||||||
|
@ -70,7 +70,7 @@ GameLib.D3.API.Game = function(
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(path)) {
|
if (GameLib.Utils.UndefinedOrNull(path)) {
|
||||||
path = null;
|
path = '';
|
||||||
}
|
}
|
||||||
this.path = path;
|
this.path = path;
|
||||||
|
|
||||||
|
@ -89,36 +89,36 @@ GameLib.D3.API.Game = function(
|
||||||
}
|
}
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(scenes)) {
|
|
||||||
scenes = [];
|
|
||||||
}
|
|
||||||
this.scenes = scenes;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(cameras)) {
|
if (GameLib.Utils.UndefinedOrNull(cameras)) {
|
||||||
cameras = [];
|
cameras = [];
|
||||||
}
|
}
|
||||||
this.cameras = cameras;
|
this.cameras = cameras;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(renderers)) {
|
|
||||||
renderers = [];
|
|
||||||
}
|
|
||||||
this.renderers = renderers;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(composers)) {
|
if (GameLib.Utils.UndefinedOrNull(composers)) {
|
||||||
composers = [];
|
composers = [];
|
||||||
}
|
}
|
||||||
this.composers = composers;
|
this.composers = composers;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(systems)) {
|
|
||||||
systems = [];
|
|
||||||
}
|
|
||||||
this.systems = systems;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(viewports)) {
|
if (GameLib.Utils.UndefinedOrNull(viewports)) {
|
||||||
viewports = [];
|
viewports = [];
|
||||||
}
|
}
|
||||||
this.viewports = viewports;
|
this.viewports = viewports;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(renderers)) {
|
||||||
|
renderers = [];
|
||||||
|
}
|
||||||
|
this.renderers = renderers;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(renderTargets)) {
|
||||||
|
renderTargets = [];
|
||||||
|
}
|
||||||
|
this.renderTargets = renderTargets;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(systems)) {
|
||||||
|
systems = [];
|
||||||
|
}
|
||||||
|
this.systems = systems;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
|
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
|
||||||
entityManager = new GameLib.API.EntityManager();
|
entityManager = new GameLib.API.EntityManager();
|
||||||
}
|
}
|
||||||
|
@ -140,24 +140,16 @@ 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 apiScenes = [];
|
|
||||||
var apiCameras = [];
|
var apiCameras = [];
|
||||||
var apiRenderers = [];
|
|
||||||
var apiComposers = [];
|
var apiComposers = [];
|
||||||
var apiSystems = [];
|
|
||||||
var apiViewports = [];
|
var apiViewports = [];
|
||||||
|
var apiRenderers = [];
|
||||||
|
var apiRenderTargets = [];
|
||||||
|
var apiSystems = [];
|
||||||
|
|
||||||
var apiEntityManager = null;
|
var apiEntityManager = null;
|
||||||
var apiMouse = null;
|
var apiMouse = null;
|
||||||
|
|
||||||
if (objectGame.scenes) {
|
|
||||||
apiScenes = objectGame.scenes.map(
|
|
||||||
function(objectScene){
|
|
||||||
return GameLib.D3.API.Scene.FromObjectScene(objectScene);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objectGame.cameras) {
|
if (objectGame.cameras) {
|
||||||
apiCameras = objectGame.cameras.map(
|
apiCameras = objectGame.cameras.map(
|
||||||
function(objectCamera){
|
function(objectCamera){
|
||||||
|
@ -166,14 +158,6 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectGame.renderers) {
|
|
||||||
apiRenderers = objectGame.renderers.map(
|
|
||||||
function(objectRenderer){
|
|
||||||
return GameLib.D3.API.Renderer.FromObjectComponent(objectRenderer);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objectGame.composers) {
|
if (objectGame.composers) {
|
||||||
apiComposers = objectGame.composers.map(
|
apiComposers = objectGame.composers.map(
|
||||||
function(objectComposer){
|
function(objectComposer){
|
||||||
|
@ -182,14 +166,6 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectGame.systems) {
|
|
||||||
apiSystems = objectGame.systems.map(
|
|
||||||
function(objectSystem){
|
|
||||||
return GameLib.API.System.FromObjectComponent(objectSystem);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objectGame.viewports) {
|
if (objectGame.viewports) {
|
||||||
apiViewports = objectGame.viewports.map(
|
apiViewports = objectGame.viewports.map(
|
||||||
function(objectViewport){
|
function(objectViewport){
|
||||||
|
@ -198,6 +174,30 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (objectGame.renderers) {
|
||||||
|
apiRenderers = objectGame.renderers.map(
|
||||||
|
function(objectRenderer){
|
||||||
|
return GameLib.D3.API.Renderer.FromObjectComponent(objectRenderer);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectGame.renderTargets) {
|
||||||
|
apiRenderTargets = objectGame.renderTargets.map(
|
||||||
|
function(objectRenderTarget){
|
||||||
|
return GameLib.D3.API.RenderTarget.FromObjectComponent(objectRenderTarget);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objectGame.systems) {
|
||||||
|
apiSystems = objectGame.systems.map(
|
||||||
|
function(objectSystem){
|
||||||
|
return GameLib.API.System.FromObjectComponent(objectSystem);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (objectGame.entityManager) {
|
if (objectGame.entityManager) {
|
||||||
apiEntityManager = GameLib.API.EntityManager.FromObjectEntityManager(objectGame.entityManager);
|
apiEntityManager = GameLib.API.EntityManager.FromObjectEntityManager(objectGame.entityManager);
|
||||||
}
|
}
|
||||||
|
@ -214,12 +214,12 @@ GameLib.D3.API.Game.FromObjectGame = function(objectGame) {
|
||||||
objectGame.gameType,
|
objectGame.gameType,
|
||||||
objectGame.width,
|
objectGame.width,
|
||||||
objectGame.height,
|
objectGame.height,
|
||||||
apiScenes,
|
|
||||||
apiCameras,
|
apiCameras,
|
||||||
apiRenderers,
|
|
||||||
apiComposers,
|
apiComposers,
|
||||||
apiSystems,
|
|
||||||
apiViewports,
|
apiViewports,
|
||||||
|
apiRenderers,
|
||||||
|
apiRenderTargets,
|
||||||
|
apiSystems,
|
||||||
apiEntityManager,
|
apiEntityManager,
|
||||||
apiMouse,
|
apiMouse,
|
||||||
objectGame.parentEntity
|
objectGame.parentEntity
|
||||||
|
|
|
@ -142,6 +142,7 @@ GameLib.D3.API.Material = function(
|
||||||
specularMap,
|
specularMap,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
GameLib.Component.call(
|
||||||
this,
|
this,
|
||||||
GameLib.Component.COMPONENT_MATERIAL,
|
GameLib.Component.COMPONENT_MATERIAL,
|
||||||
|
|
|
@ -27,7 +27,8 @@ GameLib.D3.API.Scene = function(
|
||||||
GameLib.Component.COMPONENT_SCENE,
|
GameLib.Component.COMPONENT_SCENE,
|
||||||
{
|
{
|
||||||
'meshes' : [GameLib.D3.Mesh],
|
'meshes' : [GameLib.D3.Mesh],
|
||||||
'lights' : [GameLib.D3.Light]
|
'lights' : [GameLib.D3.Light],
|
||||||
|
'imageFactory' : GameLib.D3.ImageFactory
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
parentEntity
|
parentEntity
|
||||||
|
|
|
@ -26,42 +26,156 @@ GameLib.D3.Editor = function(
|
||||||
this,
|
this,
|
||||||
apiEditor.id,
|
apiEditor.id,
|
||||||
apiEditor.name,
|
apiEditor.name,
|
||||||
apiEditor.game,
|
apiEditor.baseUrl,
|
||||||
|
apiEditor.path,
|
||||||
|
apiEditor.games,
|
||||||
|
apiEditor.scenes,
|
||||||
|
apiEditor.cameras,
|
||||||
|
apiEditor.composers,
|
||||||
|
apiEditor.viewports,
|
||||||
|
apiEditor.renderers,
|
||||||
|
apiEditor.renderTargets,
|
||||||
|
apiEditor.systems,
|
||||||
|
apiEditor.entityManager,
|
||||||
apiEditor.allSelected,
|
apiEditor.allSelected,
|
||||||
apiEditor.selectedObjects,
|
apiEditor.selectedObjects,
|
||||||
apiEditor.viewports,
|
|
||||||
apiEditor.parentEntity
|
apiEditor.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.game) {
|
this.imageFactory = new GameLib.D3.ImageFactory(
|
||||||
if (this.game instanceof GameLib.D3.API.Game) {
|
|
||||||
this.game = new GameLib.D3.Game(
|
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.game
|
this.baseUrl + this.path
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.games) {
|
||||||
|
this.games = this.games.map(
|
||||||
|
function (apiGame) {
|
||||||
|
if (apiGame instanceof GameLib.D3.API.Game) {
|
||||||
|
return new GameLib.D3.Game(
|
||||||
|
this.graphics,
|
||||||
|
apiGame
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.warn('Game not of type API.Game');
|
console.warn('game not of type API.Game');
|
||||||
throw new Error('Game not of type API.Game');
|
throw new Error('game not of type API.Game');
|
||||||
}
|
}
|
||||||
|
}.bind(this)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.scenes = this.scenes.map(
|
||||||
|
function (apiScene) {
|
||||||
|
if (apiScene instanceof GameLib.D3.API.Scene) {
|
||||||
|
return new GameLib.D3.Scene(
|
||||||
|
this.graphics,
|
||||||
|
apiScene,
|
||||||
|
this.imageFactory,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
console.warn('apiScene not of type API.Scene');
|
||||||
|
throw new Error('apiScene not of type API.Scene');
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.cameras = this.cameras.map(
|
||||||
|
function (apiCamera) {
|
||||||
|
if (apiCamera instanceof GameLib.D3.API.Camera) {
|
||||||
|
return new GameLib.D3.Camera(
|
||||||
|
this.graphics,
|
||||||
|
apiCamera
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
console.warn('apiCamera not of type API.Camera');
|
||||||
|
throw new Error('apiCamera not of type API.Camera');
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.composers = this.composers.map(
|
||||||
|
function (apiComposer) {
|
||||||
|
if (apiComposer instanceof GameLib.D3.API.Composer) {
|
||||||
|
return new GameLib.D3.Composer(
|
||||||
|
this.graphics,
|
||||||
|
apiComposer
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
console.warn('apiComposer not of type API.Composer');
|
||||||
|
throw new Error('apiComposer not of type API.Composer');
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
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 GameLib.D3.Viewport(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiViewport
|
apiViewport
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
console.warn('Viewport not of type API.Viewport');
|
console.warn('apiViewport not of type API.Viewport');
|
||||||
throw new Error('Viewport not of type API.Viewport');
|
throw new Error('apiViewport not of type API.Viewport');
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
}.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('apiRenderer not of type API.Renderer');
|
||||||
|
throw new Error('apiRenderer not of type API.Renderer');
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.renderTargets = this.renderTargets.map(
|
||||||
|
function (apiRenderTarget) {
|
||||||
|
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) {
|
||||||
|
return GameLib.D3.RenderTarget(
|
||||||
|
this.graphics,
|
||||||
|
apiRenderTarget
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
console.warn('apiRenderTarget not of type API.RenderTarget');
|
||||||
|
throw new Error('apiRenderTarget not of type API.RenderTarget');
|
||||||
|
}
|
||||||
|
}.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('apiSystem not of type API.System');
|
||||||
|
throw new Error('apiSystem not of type API.System');
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.entityManager) {
|
||||||
|
if (this.entityManager instanceof GameLib.API.EntityManager) {
|
||||||
|
this.entityManager = new GameLib.EntityManager(
|
||||||
|
this.graphics,
|
||||||
|
this.entityManager
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.warn('entityManager not of type API.EntityManager');
|
||||||
|
throw new Error('entityManager not of type API.EntityManager');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(onSelectionChanged)) {
|
if (GameLib.Utils.UndefinedOrNull(onSelectionChanged)) {
|
||||||
onSelectionChanged = null;
|
onSelectionChanged = null;
|
||||||
}
|
}
|
||||||
|
@ -113,37 +227,145 @@ GameLib.D3.Editor.prototype.updateInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Editor.prototype.toApiEditor = function() {
|
GameLib.D3.Editor.prototype.toApiEditor = function() {
|
||||||
|
|
||||||
var apiGame = null;
|
var apiGames = [];
|
||||||
if (this.game) {
|
var apiScenes = [];
|
||||||
if (this.game instanceof GameLib.D3.Game) {
|
var apiCameras = [];
|
||||||
apiGame = this.game.toApiGame();
|
var apiComposers = [];
|
||||||
|
var apiViewports = [];
|
||||||
|
var apiRenderers = [];
|
||||||
|
var apiRenderTargets = [];
|
||||||
|
var apiSystems = [];
|
||||||
|
var apiEntityManager = null;
|
||||||
|
|
||||||
|
if (this.games) {
|
||||||
|
apiGames = this.games.map(
|
||||||
|
function(game) {
|
||||||
|
if (game instanceof GameLib.D3.Game) {
|
||||||
|
return game.toApiGame();
|
||||||
} else {
|
} else {
|
||||||
console.warn('Game not an instance of Game');
|
console.warn('game not an instance of Game');
|
||||||
throw new Error('Game not an instance of Game');
|
throw new Error('game not an instance of Game');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.composers) {
|
||||||
|
apiComposers = this.composers.map(
|
||||||
|
function(composer) {
|
||||||
|
if (composer instanceof GameLib.D3.Composer) {
|
||||||
|
return composer.toApiComponent();
|
||||||
|
} else {
|
||||||
|
console.warn('composer not an instance of Composer');
|
||||||
|
throw new Error('composer not an instance of Composer');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
var apiViewports = [];
|
|
||||||
if (this.viewports) {
|
if (this.viewports) {
|
||||||
apiViewports = this.viewports.map(
|
apiViewports = this.viewports.map(
|
||||||
function(viewport) {
|
function(viewport) {
|
||||||
if (viewport instanceof GameLib.D3.Viewport) {
|
if (viewport instanceof GameLib.D3.Viewport) {
|
||||||
return viewport.toApiComponent();
|
return viewport.toApiComponent();
|
||||||
} else {
|
} else {
|
||||||
console.warn('Viewport not an instance of Viewport');
|
console.warn('viewport not an instance of Viewport');
|
||||||
throw new Error('Viewport not an instance of Viewport');
|
throw new Error('viewport not an instance of Viewport');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.renderers) {
|
||||||
|
apiRenderers = this.renderers.map(
|
||||||
|
function(renderer) {
|
||||||
|
if (renderer instanceof GameLib.D3.Renderer) {
|
||||||
|
return renderer.toApiComponent();
|
||||||
|
} else {
|
||||||
|
console.warn('renderer not an instance of Renderer');
|
||||||
|
throw new Error('renderer not an instance of Renderer');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.renderTargets) {
|
||||||
|
apiRenderTargets = this.renderTargets.map(
|
||||||
|
function(renderTarget) {
|
||||||
|
if (renderTarget instanceof GameLib.D3.RenderTarget) {
|
||||||
|
return renderTarget.toApiComponent();
|
||||||
|
} else {
|
||||||
|
console.warn('renderTarget not an instance of RenderTarget');
|
||||||
|
throw new Error('renderTarget not an instance of RenderTarget');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.systems) {
|
||||||
|
apiSystems = this.systems.map(
|
||||||
|
function(system) {
|
||||||
|
if (system instanceof GameLib.System) {
|
||||||
|
return system.toApiComponent();
|
||||||
|
} else {
|
||||||
|
console.warn('system not an instance of System');
|
||||||
|
throw new Error('system not an instance of System');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new GameLib.D3.API.Editor(
|
return new GameLib.D3.API.Editor(
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
apiGame,
|
this.baseUrl,
|
||||||
|
this.path,
|
||||||
|
apiGames,
|
||||||
|
apiScenes,
|
||||||
|
apiCameras,
|
||||||
|
apiComposers,
|
||||||
|
apiViewports,
|
||||||
|
apiRenderers,
|
||||||
|
apiRenderTargets,
|
||||||
|
apiSystems,
|
||||||
|
apiEntityManager,
|
||||||
this.allSelected,
|
this.allSelected,
|
||||||
this.selectedObjects,
|
this.selectedObjects,
|
||||||
apiViewports,
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* 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
|
* @param imageFactory GameLib.D3.ImageFactory
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Game = function (
|
GameLib.D3.Game = function (
|
||||||
|
@ -27,12 +27,12 @@ GameLib.D3.Game = function (
|
||||||
apiGame.gameType,
|
apiGame.gameType,
|
||||||
apiGame.width,
|
apiGame.width,
|
||||||
apiGame.height,
|
apiGame.height,
|
||||||
apiGame.scenes,
|
|
||||||
apiGame.cameras,
|
apiGame.cameras,
|
||||||
apiGame.renderers,
|
|
||||||
apiGame.composers,
|
apiGame.composers,
|
||||||
apiGame.systems,
|
|
||||||
apiGame.viewports,
|
apiGame.viewports,
|
||||||
|
apiGame.renderers,
|
||||||
|
apiGame.renderTargets,
|
||||||
|
apiGame.systems,
|
||||||
apiGame.entityManager,
|
apiGame.entityManager,
|
||||||
apiGame.mouse,
|
apiGame.mouse,
|
||||||
apiGame.parentEntity
|
apiGame.parentEntity
|
||||||
|
@ -41,117 +41,105 @@ GameLib.D3.Game = function (
|
||||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||||
imageFactory = GameLib.D3.ImageFactory(
|
imageFactory = GameLib.D3.ImageFactory(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.baseUrl
|
this.baseUrl + this.path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.imageFactory = imageFactory;
|
this.imageFactory = imageFactory;
|
||||||
|
|
||||||
this.scenes = this.scenes.map(
|
|
||||||
function(apiScene) {
|
|
||||||
|
|
||||||
if (apiScene instanceof GameLib.D3.API.Scene) {
|
|
||||||
return new GameLib.D3.Scene(
|
|
||||||
this.graphics,
|
|
||||||
apiScene,
|
|
||||||
this.imageFactory,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
console.warn('Scene not of type API.Scene');
|
|
||||||
throw new Error('Scene not of type API.Scene');
|
|
||||||
}
|
|
||||||
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.cameras = this.cameras.map(
|
this.cameras = this.cameras.map(
|
||||||
function(apiCamera) {
|
function (apiCamera) {
|
||||||
|
|
||||||
if (apiCamera instanceof GameLib.D3.API.Camera) {
|
if (apiCamera instanceof GameLib.D3.API.Camera) {
|
||||||
return new GameLib.D3.Camera(
|
return new GameLib.D3.Camera(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiCamera
|
apiCamera
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
console.warn('Camera not of type API.Camera');
|
console.warn('apiCamera not of type API.Camera');
|
||||||
throw new Error('Camera not of type API.Camera');
|
throw new Error('apiCamera not of type API.Camera');
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.renderers = this.renderers.map(
|
|
||||||
function(apiRenderer) {
|
|
||||||
|
|
||||||
if (apiRenderer instanceof GameLib.D3.API.Renderer) {
|
|
||||||
return new 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)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.composers = this.composers.map(
|
this.composers = this.composers.map(
|
||||||
function(apiComposer) {
|
function (apiComposer) {
|
||||||
|
|
||||||
if (apiComposer instanceof GameLib.D3.API.Composer) {
|
if (apiComposer instanceof GameLib.D3.API.Composer) {
|
||||||
return new GameLib.D3.Composer(
|
return new GameLib.D3.Composer(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiComposer
|
apiComposer
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
console.warn('Composer not of type API.Composer');
|
console.warn('apiComposer not of type API.Composer');
|
||||||
throw new Error('Composer not of type API.Composer');
|
throw new Error('apiComposer not of type API.Composer');
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.systems = this.systems.map(
|
|
||||||
function(apiSystem) {
|
|
||||||
|
|
||||||
if (apiSystem instanceof GameLib.D3.API.System) {
|
|
||||||
return new 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)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
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 new GameLib.D3.Viewport(
|
return GameLib.D3.Viewport(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiViewport
|
apiViewport
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
console.warn('Viewport not of type API.Viewport');
|
console.warn('apiViewport not of type API.Viewport');
|
||||||
throw new Error('Viewport not of type API.Viewport');
|
throw new Error('apiViewport not of type API.Viewport');
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
}.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('apiRenderer not of type API.Renderer');
|
||||||
|
throw new Error('apiRenderer not of type API.Renderer');
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.renderTargets = this.renderTargets.map(
|
||||||
|
function (apiRenderTarget) {
|
||||||
|
if (apiRenderTarget instanceof GameLib.D3.API.RenderTarget) {
|
||||||
|
return GameLib.D3.RenderTarget(
|
||||||
|
this.graphics,
|
||||||
|
apiRenderTarget
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
console.warn('apiRenderTarget not of type API.RenderTarget');
|
||||||
|
throw new Error('apiRenderTarget not of type API.RenderTarget');
|
||||||
|
}
|
||||||
|
}.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('apiSystem not of type API.System');
|
||||||
|
throw new Error('apiSystem not of type API.System');
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.entityManager) {
|
||||||
if (this.entityManager instanceof GameLib.API.EntityManager) {
|
if (this.entityManager instanceof GameLib.API.EntityManager) {
|
||||||
this.entityManager = new GameLib.EntityManager(
|
this.entityManager = new GameLib.EntityManager(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.entityManager
|
this.entityManager
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('EntityManager not of type API.EntityManager');
|
console.warn('entityManager not of type API.EntityManager');
|
||||||
throw new Error('EntityManager not of type API.EntityManager');
|
throw new Error('entityManager not of type API.EntityManager');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mouse instanceof GameLib.API.Mouse) {
|
if (this.mouse instanceof GameLib.API.Mouse) {
|
||||||
|
@ -226,101 +214,102 @@ GameLib.D3.Game.prototype.updateInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Game.prototype.toApiGame = function() {
|
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 = [];
|
var apiCameras = [];
|
||||||
|
var apiComposers = [];
|
||||||
|
var apiViewports = [];
|
||||||
|
var apiRenderers = [];
|
||||||
|
var apiRenderTargets = [];
|
||||||
|
var apiSystems = [];
|
||||||
|
var apiEntityManager = null;
|
||||||
|
var apiMouse = null;
|
||||||
|
|
||||||
if (this.cameras) {
|
if (this.cameras) {
|
||||||
apiCameras = this.cameras.map(
|
apiCameras = this.cameras.map(
|
||||||
function(camera) {
|
function(camera) {
|
||||||
if (camera instanceof GameLib.D3.Camera) {
|
if (camera instanceof GameLib.D3.Camera) {
|
||||||
return camera.toApiCamera();
|
return camera.toApiCamera();
|
||||||
} else {
|
} else {
|
||||||
console.warn('Camera not an instance of Camera');
|
console.warn('camera not an instance of Camera');
|
||||||
throw new Error('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) {
|
if (this.composers) {
|
||||||
apiComposers = this.composers.map(
|
apiComposers = this.composers.map(
|
||||||
function(composer) {
|
function(composer) {
|
||||||
if (composer instanceof GameLib.D3.Composer) {
|
if (composer instanceof GameLib.D3.Composer) {
|
||||||
return composer.toApiComposer();
|
return composer.toApiComponent();
|
||||||
} else {
|
} else {
|
||||||
console.warn('Composer not an instance of Composer');
|
console.warn('composer not an instance of Composer');
|
||||||
throw new Error('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) {
|
if (this.viewports) {
|
||||||
apiViewports = this.viewports.map(
|
apiViewports = this.viewports.map(
|
||||||
function(viewport) {
|
function(viewport) {
|
||||||
if (viewport instanceof GameLib.D3.Viewport) {
|
if (viewport instanceof GameLib.D3.Viewport) {
|
||||||
return viewport.toApiViewport();
|
return viewport.toApiComponent();
|
||||||
} else {
|
} else {
|
||||||
console.warn('Viewport not an instance of Viewport');
|
console.warn('viewport not an instance of Viewport');
|
||||||
throw new Error('Viewport not an instance of Viewport');
|
throw new Error('viewport not an instance of Viewport');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.renderers) {
|
||||||
|
apiRenderers = this.renderers.map(
|
||||||
|
function(renderer) {
|
||||||
|
if (renderer instanceof GameLib.D3.Renderer) {
|
||||||
|
return renderer.toApiComponent();
|
||||||
|
} else {
|
||||||
|
console.warn('renderer not an instance of Renderer');
|
||||||
|
throw new Error('renderer not an instance of Renderer');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.renderTargets) {
|
||||||
|
apiRenderTargets = this.renderTargets.map(
|
||||||
|
function(renderTarget) {
|
||||||
|
if (renderTarget instanceof GameLib.D3.RenderTarget) {
|
||||||
|
return renderTarget.toApiComponent();
|
||||||
|
} else {
|
||||||
|
console.warn('renderTarget not an instance of RenderTarget');
|
||||||
|
throw new Error('renderTarget not an instance of RenderTarget');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.systems) {
|
||||||
|
apiSystems = this.systems.map(
|
||||||
|
function(system) {
|
||||||
|
if (system instanceof GameLib.System) {
|
||||||
|
return system.toApiComponent();
|
||||||
|
} else {
|
||||||
|
console.warn('system not an instance of System');
|
||||||
|
throw new Error('system not an instance of System');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiEntityManager = null;
|
|
||||||
if (this.entityManager) {
|
if (this.entityManager) {
|
||||||
if (this.entityManager instanceof GameLib.EntityManager) {
|
if (this.entityManager instanceof GameLib.EntityManager) {
|
||||||
apiEntityManager = this.entityManager.toApiEntityManager();
|
apiEntityManager = this.entityManager.toApiEntityManager();
|
||||||
} else {
|
} else {
|
||||||
console.warn('EntityManager not an instance of EntityManager');
|
console.warn('entityManager not an instance of EntityManager');
|
||||||
throw new Error('EntityManager not an instance of EntityManager');
|
throw new Error('entityManager not an instance of EntityManager');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiMouse = null;
|
|
||||||
if (this.mouse) {
|
if (this.mouse) {
|
||||||
if (this.mouse instanceof GameLib.Mouse) {
|
if (this.mouse instanceof GameLib.Mouse) {
|
||||||
apiMouse = this.mouse.toApiMouse();
|
apiMouse = this.mouse.toApiMouse();
|
||||||
|
@ -338,12 +327,12 @@ GameLib.D3.Game.prototype.toApiGame = function() {
|
||||||
this.gameType,
|
this.gameType,
|
||||||
this.width,
|
this.width,
|
||||||
this.height,
|
this.height,
|
||||||
apiScenes,
|
|
||||||
apiCameras,
|
apiCameras,
|
||||||
apiRenderers,
|
|
||||||
apiComposers,
|
apiComposers,
|
||||||
apiSystems,
|
|
||||||
apiViewports,
|
apiViewports,
|
||||||
|
apiRenderers,
|
||||||
|
apiRenderTargets,
|
||||||
|
apiSystems,
|
||||||
apiEntityManager,
|
apiEntityManager,
|
||||||
apiMouse,
|
apiMouse,
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
|
|
|
@ -221,22 +221,16 @@ GameLib.D3.Input.Editor.prototype.onKeyPress = function(event) {
|
||||||
this.editor.selectedObjects = [];
|
this.editor.selectedObjects = [];
|
||||||
|
|
||||||
if (this.editor.allSelected) {
|
if (this.editor.allSelected) {
|
||||||
this.editor.games.map(
|
for (var property in this.editor.idToObject) {
|
||||||
function(game) {
|
if (this.editor.idToObject.hasOwnProperty(property)) {
|
||||||
|
|
||||||
for (var property in game.idToObject) {
|
|
||||||
if (game.idToObject.hasOwnProperty(property)) {
|
|
||||||
this.editor.selectedObjects.push(
|
this.editor.selectedObjects.push(
|
||||||
new GameLib.D3.SelectedObject(
|
new GameLib.D3.SelectedObject(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
game.idToObject(property)
|
this.editor.idToObject(property)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.editor.onSelectionChanged) {
|
if (this.editor.onSelectionChanged) {
|
||||||
|
@ -310,18 +304,15 @@ GameLib.D3.Input.Editor.prototype.onMouseDown = function(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
var meshCollections = this.editor.game.scenes.map(
|
var meshes = [];
|
||||||
function(scene) {
|
|
||||||
return scene.meshes;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
var meshes = meshCollections.reduce(
|
for (var property in this.editor.idToObject) {
|
||||||
function(result, meshCollection) {
|
if (this.editor.idToObject.hasOwnProperty(property)) {
|
||||||
return result.concat(meshCollection);
|
if (this.editor.idToObject[property] instanceof GameLib.D3.Mesh) {
|
||||||
},
|
meshes.push(this.editor.idToObject[property]);
|
||||||
[]
|
}
|
||||||
);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var intersects = this.raycaster.getIntersectedObjects(meshes);
|
var intersects = this.raycaster.getIntersectedObjects(meshes);
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,10 @@ GameLib.D3.Material = function Material(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||||
console.warn('Cannot create a material without specifying an ImageFactory');
|
console.warn('Cannot create a Material fully without specifying an ImageFactory');
|
||||||
throw new Error('Cannot create a material without specifying an ImageFactory');
|
imageFactory = null;
|
||||||
}
|
}
|
||||||
|
this.imageFactory = imageFactory;
|
||||||
|
|
||||||
GameLib.D3.API.Material.call(
|
GameLib.D3.API.Material.call(
|
||||||
this,
|
this,
|
||||||
|
@ -121,7 +122,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.alphaMap = new GameLib.D3.Texture(
|
this.alphaMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.alphaMap,
|
this.alphaMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.alphaMap is not an instance of API.Texture');
|
console.warn('this.alphaMap is not an instance of API.Texture');
|
||||||
|
@ -134,7 +135,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.aoMap = new GameLib.D3.Texture(
|
this.aoMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.aoMap,
|
this.aoMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.aoMap is not an instance of API.Texture');
|
console.warn('this.aoMap is not an instance of API.Texture');
|
||||||
|
@ -147,7 +148,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.bumpMap = new GameLib.D3.Texture(
|
this.bumpMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.bumpMap,
|
this.bumpMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.bumpMap is not an instance of API.Texture');
|
console.warn('this.bumpMap is not an instance of API.Texture');
|
||||||
|
@ -160,7 +161,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.diffuseMap = new GameLib.D3.Texture(
|
this.diffuseMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.diffuseMap,
|
this.diffuseMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.diffuseMap is not an instance of API.Texture');
|
console.warn('this.diffuseMap is not an instance of API.Texture');
|
||||||
|
@ -173,7 +174,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.displacementMap = new GameLib.D3.Texture(
|
this.displacementMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.displacementMap,
|
this.displacementMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.displacementMap is not an instance of API.Texture');
|
console.warn('this.displacementMap is not an instance of API.Texture');
|
||||||
|
@ -186,7 +187,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.emissiveMap = new GameLib.D3.Texture(
|
this.emissiveMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.emissiveMap,
|
this.emissiveMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.emissiveMap is not an instance of API.Texture');
|
console.warn('this.emissiveMap is not an instance of API.Texture');
|
||||||
|
@ -199,7 +200,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.environmentMap = new GameLib.D3.Texture(
|
this.environmentMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.environmentMap,
|
this.environmentMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.environmentMap is not an instance of API.Texture');
|
console.warn('this.environmentMap is not an instance of API.Texture');
|
||||||
|
@ -212,7 +213,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.lightMap = new GameLib.D3.Texture(
|
this.lightMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.lightMap,
|
this.lightMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.lightMap is not an instance of API.Texture');
|
console.warn('this.lightMap is not an instance of API.Texture');
|
||||||
|
@ -225,7 +226,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.metalnessMap = new GameLib.D3.Texture(
|
this.metalnessMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.metalnessMap,
|
this.metalnessMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.metalnessMap is not an instance of API.Texture');
|
console.warn('this.metalnessMap is not an instance of API.Texture');
|
||||||
|
@ -238,7 +239,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.normalMap = new GameLib.D3.Texture(
|
this.normalMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.normalMap,
|
this.normalMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.normalMap is not an instance of API.Texture');
|
console.warn('this.normalMap is not an instance of API.Texture');
|
||||||
|
@ -251,7 +252,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.roughnessMap = new GameLib.D3.Texture(
|
this.roughnessMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.roughnessMap,
|
this.roughnessMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.roughnessMap is not an instance of API.Texture');
|
console.warn('this.roughnessMap is not an instance of API.Texture');
|
||||||
|
@ -264,7 +265,7 @@ GameLib.D3.Material = function Material(
|
||||||
this.specularMap = new GameLib.D3.Texture(
|
this.specularMap = new GameLib.D3.Texture(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.specularMap,
|
this.specularMap,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn('this.specularMap is not an instance of API.Texture');
|
console.warn('this.specularMap is not an instance of API.Texture');
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
/**
|
/**
|
||||||
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
|
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param computeNormals Boolean
|
|
||||||
* @param apiMesh GameLib.D3.API.Mesh
|
* @param apiMesh GameLib.D3.API.Mesh
|
||||||
* @param imageFactory GameLib.D3.ImageFactory
|
* @param imageFactory GameLib.D3.ImageFactory
|
||||||
|
* @param computeNormals Boolean
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh = function (
|
GameLib.D3.Mesh = function (
|
||||||
graphics,
|
graphics,
|
||||||
apiMesh,
|
apiMesh,
|
||||||
computeNormals,
|
imageFactory,
|
||||||
imageFactory
|
computeNormals
|
||||||
) {
|
) {
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.graphics.isNotThreeThrow();
|
this.graphics.isNotThreeThrow();
|
||||||
|
@ -25,9 +25,10 @@ GameLib.D3.Mesh = function (
|
||||||
this.computeNormals = computeNormals;
|
this.computeNormals = computeNormals;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||||
console.warn('Cannot create a Mesh without specifying an ImageFactory');
|
console.warn('Cannot create Meshes fully without specifying an ImageFactory for downloading Textures');
|
||||||
throw new Error('Cannot create a Mesh without specifying an ImageFactory');
|
imageFactory = null;
|
||||||
}
|
}
|
||||||
|
this.imageFactory = imageFactory;
|
||||||
|
|
||||||
GameLib.D3.API.Mesh.call(
|
GameLib.D3.API.Mesh.call(
|
||||||
this,
|
this,
|
||||||
|
@ -62,7 +63,7 @@ GameLib.D3.Mesh = function (
|
||||||
return new GameLib.D3.Material(
|
return new GameLib.D3.Material(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
apiMaterial,
|
apiMaterial,
|
||||||
imageFactory
|
this.imageFactory
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
console.warn('API material not of instance API.Material');
|
console.warn('API material not of instance API.Material');
|
||||||
|
@ -77,7 +78,6 @@ GameLib.D3.Mesh = function (
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.skeleton
|
this.skeleton
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.vertices = this.vertices.map(
|
this.vertices = this.vertices.map(
|
||||||
|
|
|
@ -41,12 +41,11 @@ GameLib.D3.Scene = function (
|
||||||
);
|
);
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||||
console.warn('Cannot create a Scene without specifying an ImageFactory');
|
console.warn('Creating a scene without an ImageFactory');
|
||||||
throw new Error('Cannot create a Scene without specifying an ImageFactory');
|
imageFactory = null;
|
||||||
}
|
}
|
||||||
this.imageFactory = imageFactory;
|
this.imageFactory = imageFactory;
|
||||||
|
|
||||||
|
|
||||||
this.meshes = this.meshes.map(
|
this.meshes = this.meshes.map(
|
||||||
function(apiMesh) {
|
function(apiMesh) {
|
||||||
|
|
||||||
|
@ -173,16 +172,16 @@ 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 computeNormals boolean to indicate whether or not to recalculate normals
|
|
||||||
* @param imageFactory GameLib.D3.ImageFactory
|
* @param imageFactory GameLib.D3.ImageFactory
|
||||||
|
* @param computeNormals boolean to indicate whether or not to recalculate normals
|
||||||
* @returns {GameLib.D3.Scene}
|
* @returns {GameLib.D3.Scene}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene.FromObjectScene = function(
|
GameLib.D3.Scene.FromObjectScene = function(
|
||||||
graphics,
|
graphics,
|
||||||
objectScene,
|
objectScene,
|
||||||
computeNormals,
|
imageFactory,
|
||||||
imageFactory
|
computeNormals
|
||||||
) {
|
) {
|
||||||
var apiScene = GameLib.D3.API.Scene.FromObjectScene(objectScene);
|
var apiScene = GameLib.D3.API.Scene.FromObjectScene(objectScene);
|
||||||
|
|
||||||
|
@ -214,8 +213,8 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
var scene = GameLib.D3.Scene.FromObjectScene(
|
var scene = GameLib.D3.Scene.FromObjectScene(
|
||||||
graphics,
|
graphics,
|
||||||
objectScene,
|
objectScene,
|
||||||
computeNormals,
|
imageFactory,
|
||||||
imageFactory
|
computeNormals
|
||||||
);
|
);
|
||||||
|
|
||||||
onLoaded(scene);
|
onLoaded(scene);
|
||||||
|
|
|
@ -3,14 +3,12 @@
|
||||||
* created
|
* created
|
||||||
* @param apiTexture
|
* @param apiTexture
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param imageFactory GameLib.D3.ImageFactory result
|
* @param imageFactory GameLib.D3.ImageFactory
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture = function Texture(
|
GameLib.D3.Texture = function Texture(
|
||||||
graphics,
|
graphics,
|
||||||
apiTexture,
|
apiTexture,
|
||||||
// parentMaterial,
|
|
||||||
// parentMaterialInstanceMapId,
|
|
||||||
imageFactory
|
imageFactory
|
||||||
) {
|
) {
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
@ -21,9 +19,10 @@ GameLib.D3.Texture = function Texture(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
|
||||||
console.warn('Cannot create a material without specifying an ImageFactory');
|
console.warn('Cannot create a Texture without specifying an ImageFactory');
|
||||||
throw new Error('Cannot create a material without specifying an ImageFactory');
|
imageFactory = null;
|
||||||
}
|
}
|
||||||
|
this.imageFactory = imageFactory;
|
||||||
|
|
||||||
GameLib.D3.API.Texture.call(
|
GameLib.D3.API.Texture.call(
|
||||||
this,
|
this,
|
||||||
|
@ -63,15 +62,11 @@ GameLib.D3.Texture = function Texture(
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
|
||||||
// this.parentMaterial = parentMaterial;
|
|
||||||
//
|
|
||||||
// this.parentMaterialInstanceMapId = parentMaterialInstanceMapId;
|
|
||||||
|
|
||||||
this.imageInstance = null;
|
this.imageInstance = null;
|
||||||
|
|
||||||
this.instance = null;
|
this.instance = null;
|
||||||
|
|
||||||
this.loadTexture(imageFactory);
|
this.loadTexture();
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Texture.prototype = Object.create(GameLib.D3.API.Texture.prototype);
|
GameLib.D3.Texture.prototype = Object.create(GameLib.D3.API.Texture.prototype);
|
||||||
|
@ -79,18 +74,15 @@ GameLib.D3.Texture.prototype.constructor = GameLib.D3.Texture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a texture from the image factory, it could already have downloaded, and then it updates the instance
|
* Loads a texture from the image factory, it could already have downloaded, and then it updates the instance
|
||||||
* @param imageFactory
|
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture.prototype.loadTexture = function(imageFactory) {
|
GameLib.D3.Texture.prototype.loadTexture = function() {
|
||||||
|
|
||||||
this.imageData = imageFactory(this.imagePath);
|
this.imageData = this.imageFactory(this.imagePath);
|
||||||
|
|
||||||
this.imageData.then(
|
this.imageData.then(
|
||||||
function (imageInstance){
|
function (imageInstance){
|
||||||
this.imageInstance = imageInstance;
|
this.imageInstance = imageInstance;
|
||||||
this.instance = this.createInstance();
|
this.instance = this.createInstance();
|
||||||
// this.parentMaterial.instance[this.parentMaterialInstanceMapId] = this.instance;
|
|
||||||
// this.parentMaterial.instance.needsUpdate = true;
|
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
function onRejected() {
|
function onRejected() {
|
||||||
}
|
}
|
||||||
|
@ -221,12 +213,6 @@ GameLib.D3.Texture.prototype.createInstance = function(update) {
|
||||||
instance.premultiplyAlpha = this.premultiplyAlpha;
|
instance.premultiplyAlpha = this.premultiplyAlpha;
|
||||||
instance.textureType = this.textureType;
|
instance.textureType = this.textureType;
|
||||||
|
|
||||||
// if (this.parentMaterial &&
|
|
||||||
// this.parentMaterial.instance &&
|
|
||||||
// this.parentMaterialInstanceMapId) {
|
|
||||||
// this.parentMaterial.instance[this.parentMaterialInstanceMapId] = instance;
|
|
||||||
// }
|
|
||||||
|
|
||||||
instance.needsUpdate = true;
|
instance.needsUpdate = true;
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -290,8 +276,6 @@ GameLib.D3.Texture.prototype.toApiTexture = function() {
|
||||||
GameLib.D3.Texture.FromObjectTexture = function(
|
GameLib.D3.Texture.FromObjectTexture = function(
|
||||||
graphics,
|
graphics,
|
||||||
objectTexture,
|
objectTexture,
|
||||||
// gameLibMaterial,
|
|
||||||
// instanceMapId,
|
|
||||||
imageFactory
|
imageFactory
|
||||||
) {
|
) {
|
||||||
var apiTexture = GameLib.D3.API.Texture.FromObjectTexture(objectTexture);
|
var apiTexture = GameLib.D3.API.Texture.FromObjectTexture(objectTexture);
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/**
|
||||||
|
* Runtime domElement for updating instance objects
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param apiDomElement GameLib.API.DomElement
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.DomElement = function (graphics, apiDomElement) {
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
GameLib.API.DomElement.call(
|
||||||
|
this,
|
||||||
|
apiDomElement.id,
|
||||||
|
apiDomElement.name,
|
||||||
|
apiDomElement.domElementId,
|
||||||
|
apiDomElement.parentEntity
|
||||||
|
);
|
||||||
|
|
||||||
|
this.instance = this.createInstance();
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.DomElement.prototype = Object.create(GameLib.API.DomElement.prototype);
|
||||||
|
GameLib.DomElement.prototype.constructor = GameLib.DomElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance domElement
|
||||||
|
* @param update
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.DomElement.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
|
var instance = document.getElementById(this.domElementId);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the instance vector, calls updateInstance on the parent object
|
||||||
|
*/
|
||||||
|
GameLib.DomElement.prototype.updateInstance = function() {
|
||||||
|
this.createInstance(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts runtime vector to API Vector
|
||||||
|
* @returns {GameLib.API.DomElement}
|
||||||
|
*/
|
||||||
|
GameLib.DomElement.prototype.toApiDomElement = function() {
|
||||||
|
return new GameLib.API.DomElement(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
this.domElementId,
|
||||||
|
this.parentEntity
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends domInstance to DOM instance
|
||||||
|
* @param domInstance
|
||||||
|
*/
|
||||||
|
GameLib.DomElement.prototype.append = function(domInstance) {
|
||||||
|
this.instance.appendChild(domInstance);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears DOM instance
|
||||||
|
*/
|
||||||
|
GameLib.DomElement.prototype.clear = function() {
|
||||||
|
this.instance.innerHTML = '';
|
||||||
|
};
|
|
@ -1,34 +1,32 @@
|
||||||
/**
|
/**
|
||||||
* 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 graphics
|
||||||
* @param apiSystem GameLib.API.System
|
* @param apiSystem GameLib.API.System
|
||||||
* @param domElement
|
|
||||||
* @param domStats
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.System = function(
|
GameLib.System = function(
|
||||||
apiSystem,
|
graphics,
|
||||||
domElement,
|
apiSystem
|
||||||
domStats
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiSystem)) {
|
||||||
|
apiSystem = {};
|
||||||
|
}
|
||||||
|
|
||||||
GameLib.API.System.call(
|
GameLib.API.System.call(
|
||||||
this,
|
this,
|
||||||
apiSystem.id,
|
apiSystem.id,
|
||||||
apiSystem.name,
|
apiSystem.name,
|
||||||
apiSystem.systemType,
|
apiSystem.systemType,
|
||||||
apiSystem.entityManager,
|
apiSystem.entityManager,
|
||||||
|
apiSystem.domElement,
|
||||||
|
apiSystem.domStats,
|
||||||
apiSystem.parentEntity
|
apiSystem.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(domElement)){
|
|
||||||
domElement = null;
|
|
||||||
}
|
|
||||||
this.domElement = domElement;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(domStats)){
|
|
||||||
domStats = null;
|
|
||||||
}
|
|
||||||
this.domStats = domStats;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -174,3 +172,20 @@ GameLib.System.prototype.stop = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts runtime vector to API Vector
|
||||||
|
* @returns {GameLib.API.Mouse}
|
||||||
|
*/
|
||||||
|
GameLib.System.prototype.toApiSystem = function() {
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
return new GameLib.API.System(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
this.systemType,
|
||||||
|
this.domElement.toApiDo,
|
||||||
|
this.domStats,
|
||||||
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue