proper loading of objects
parent
a111e42d63
commit
bb0a861d35
|
@ -13,29 +13,7 @@ GameLib.API.EntityManager = function(
|
||||||
// systems,
|
// systems,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_ENTITY_MANAGER,
|
|
||||||
{
|
|
||||||
'entities' : [GameLib.Entity]
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Entity Manager (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(entities)) {
|
|
||||||
entities = [];
|
|
||||||
}
|
|
||||||
this.entities = entities;
|
|
||||||
|
|
||||||
// if (GameLib.Utils.UndefinedOrNull(systems)) {
|
// if (GameLib.Utils.UndefinedOrNull(systems)) {
|
||||||
// systems = [];
|
// systems = [];
|
|
@ -31,6 +31,7 @@ GameLib.Event.LOADED = 0xf;
|
||||||
GameLib.Event.SAVE_SUCCESS = 0x10;
|
GameLib.Event.SAVE_SUCCESS = 0x10;
|
||||||
GameLib.Event.SAVE_FAILURE = 0x11;
|
GameLib.Event.SAVE_FAILURE = 0x11;
|
||||||
GameLib.Event.LOGGED_IN = 0x12;
|
GameLib.Event.LOGGED_IN = 0x12;
|
||||||
|
GameLib.Event.COMPONENT_CREATED = 0x13;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe to some events
|
* Subscribe to some events
|
||||||
|
@ -42,62 +43,65 @@ GameLib.Event.prototype.subscribe = function(
|
||||||
callback
|
callback
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
var fn = callback.bind(this);
|
||||||
|
|
||||||
if (GameLib.Event.Subscriptions.hasOwnProperty(eventName)) {
|
if (GameLib.Event.Subscriptions.hasOwnProperty(eventName)) {
|
||||||
GameLib.Event.Subscriptions[eventName].push(callback.bind(this));
|
GameLib.Event.Subscriptions[eventName].push(fn);
|
||||||
} else {
|
} else {
|
||||||
GameLib.Event.Subscriptions[eventName] = [];
|
GameLib.Event.Subscriptions[eventName] = [];
|
||||||
GameLib.Event.Subscriptions[eventName].push(callback.bind(this));
|
GameLib.Event.Subscriptions[eventName].push(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var index = GameLib.Event.Subscriptions[eventName].indexOf(fn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a handle to the caller to allow us to unsubscribe to this event
|
||||||
|
*/
|
||||||
|
return {
|
||||||
|
fn : fn,
|
||||||
|
remove : function() {
|
||||||
|
GameLib.Event.Subscriptions[eventName].splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribe to some events
|
*
|
||||||
* TODO: incomplete
|
|
||||||
* @param eventName
|
* @param eventName
|
||||||
* @param callback
|
* @param data
|
||||||
*/
|
*/
|
||||||
GameLib.Event.prototype.unsubscribe = function(
|
|
||||||
eventName,
|
|
||||||
callback
|
|
||||||
) {
|
|
||||||
|
|
||||||
var index = -1;
|
|
||||||
|
|
||||||
if (GameLib.Event.Subscriptions.hasOwnProperty(eventName)) {
|
|
||||||
index = GameLib.Event.Subscriptions[eventName].indexOf(callback.bind(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index === -1) {
|
|
||||||
console.warn('could not unsubscribe from event - please implement this sometime (bind creates new function - store this pointer somewhere)');
|
|
||||||
} else {
|
|
||||||
GameLib.Event.Subscriptions[eventName].splice(index, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish some event happened with some data
|
* Publish some event happened with some data
|
||||||
* @param eventName
|
* @param eventName
|
||||||
* @param data
|
* @param data
|
||||||
|
* @returns {number} of callbacks executed
|
||||||
*/
|
*/
|
||||||
GameLib.Event.prototype.publish = function(
|
GameLib.Event.prototype.publish = function(
|
||||||
eventName,
|
eventName,
|
||||||
data
|
data
|
||||||
) {
|
) {
|
||||||
GameLib.Event.Emit(eventName, data);
|
return GameLib.Event.Emit(eventName, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static method call
|
* Static method call
|
||||||
|
* @param eventName
|
||||||
|
* @param data
|
||||||
|
* @returns {number} of callbacks executed
|
||||||
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.Event.Emit = function(eventName, data) {
|
GameLib.Event.Emit = function(eventName, data) {
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
if (GameLib.Event.Subscriptions.hasOwnProperty(eventName)) {
|
if (GameLib.Event.Subscriptions.hasOwnProperty(eventName)) {
|
||||||
GameLib.Event.Subscriptions[eventName].map(
|
GameLib.Event.Subscriptions[eventName].map(
|
||||||
function(callback) {
|
function(callback) {
|
||||||
callback(data);
|
callback(data);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
};
|
};
|
|
@ -4,11 +4,13 @@
|
||||||
* @param componentType
|
* @param componentType
|
||||||
* @param linkedObjects
|
* @param linkedObjects
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
|
* @param traverse
|
||||||
*/
|
*/
|
||||||
GameLib.Component = function(
|
GameLib.Component = function(
|
||||||
componentType,
|
componentType,
|
||||||
linkedObjects,
|
linkedObjects,
|
||||||
parentEntity
|
parentEntity,
|
||||||
|
traverse
|
||||||
) {
|
) {
|
||||||
if (GameLib.Utils.UndefinedOrNull(linkedObjects)) {
|
if (GameLib.Utils.UndefinedOrNull(linkedObjects)) {
|
||||||
linkedObjects = {};
|
linkedObjects = {};
|
||||||
|
@ -32,11 +34,42 @@ GameLib.Component = function(
|
||||||
|
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(traverse)) {
|
||||||
|
traverse = true;
|
||||||
|
}
|
||||||
|
this.traverse = traverse;
|
||||||
|
|
||||||
|
this.dependencies = this.getDependencies();
|
||||||
|
|
||||||
|
this.publish(
|
||||||
|
GameLib.Event.COMPONENT_CREATED,
|
||||||
|
{
|
||||||
|
component : this
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.Component.prototype = Object.create(GameLib.API.Component.prototype);
|
GameLib.Component.prototype = Object.create(GameLib.API.Component.prototype);
|
||||||
GameLib.Component.prototype.constructor = GameLib.Component;
|
GameLib.Component.prototype.constructor = GameLib.Component;
|
||||||
|
|
||||||
|
GameLib.Component.prototype.getDependencies = function() {
|
||||||
|
|
||||||
|
var dependencies = [];
|
||||||
|
|
||||||
|
for (var property in this.linkedObjects) {
|
||||||
|
if (this.linkedObjects.hasOwnProperty(property)){
|
||||||
|
if (
|
||||||
|
this.hasOwnProperty(property) &&
|
||||||
|
typeof this[property] === 'string'
|
||||||
|
) {
|
||||||
|
dependencies.push(this[property]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.Component.prototype.toString = function() {
|
GameLib.Component.prototype.toString = function() {
|
||||||
return this.id;
|
return this.id;
|
||||||
};
|
};
|
||||||
|
@ -72,6 +105,7 @@ GameLib.Component.COMPONENT_IMAGE_FACTORY = 0x1c;
|
||||||
GameLib.Component.COMPONENT_STATS = 0x1d;
|
GameLib.Component.COMPONENT_STATS = 0x1d;
|
||||||
GameLib.Component.COMPONENT_GUI = 0x1e;
|
GameLib.Component.COMPONENT_GUI = 0x1e;
|
||||||
GameLib.Component.COMPONENT_IMAGE = 0x1f;
|
GameLib.Component.COMPONENT_IMAGE = 0x1f;
|
||||||
|
GameLib.Component.COMPONENT_ENTITY = 0x20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns string name for component number
|
* Returns string name for component number
|
||||||
|
@ -112,6 +146,7 @@ GameLib.Component.GetComponentName = function(number) {
|
||||||
case 0x1d : return 'GameLib.D3.Stats';
|
case 0x1d : return 'GameLib.D3.Stats';
|
||||||
case 0x1e : return 'GameLib.GUI';
|
case 0x1e : return 'GameLib.GUI';
|
||||||
case 0x1f : return 'GameLib.D3.Image';
|
case 0x1f : return 'GameLib.D3.Image';
|
||||||
|
case 0x20 : return 'GameLib.Entity';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -126,6 +161,10 @@ GameLib.Component.prototype.toApiObject = function() {
|
||||||
|
|
||||||
GameLib.Component.prototype.buildIdToObject = function() {
|
GameLib.Component.prototype.buildIdToObject = function() {
|
||||||
|
|
||||||
|
if (!this.traverse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.built) {
|
if (this.built) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,6 @@ GameLib.API.DomElement = function(
|
||||||
}
|
}
|
||||||
this.parentEntity = parentEntity;
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_DOM_ELEMENT,
|
|
||||||
null,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,16 +26,6 @@ GameLib.API.Entity = function(
|
||||||
|
|
||||||
this.activeComponent = null;
|
this.activeComponent = null;
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_ENTITY,
|
|
||||||
{
|
|
||||||
'components' : [GameLib.Component],
|
|
||||||
'activeComponent' : GameLib.Component
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* @param id String
|
* @param id String
|
||||||
* @param name String
|
* @param name String
|
||||||
* @param systemType
|
* @param systemType
|
||||||
* @param entityManager
|
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -11,19 +10,9 @@ GameLib.API.System = function (
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
systemType,
|
systemType,
|
||||||
entityManager,
|
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_SYSTEM,
|
|
||||||
{
|
|
||||||
'entityManager' : GameLib.EntityManager
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -39,10 +28,11 @@ GameLib.API.System = function (
|
||||||
}
|
}
|
||||||
this.systemType = systemType;
|
this.systemType = systemType;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
entityManager = null;
|
parentEntity = null;
|
||||||
}
|
}
|
||||||
this.entityManager = entityManager;
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.API.System.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.API.System.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
@ -58,7 +48,6 @@ GameLib.API.System.FromObject = function(objectComponent) {
|
||||||
objectComponent.id,
|
objectComponent.id,
|
||||||
objectComponent.name,
|
objectComponent.name,
|
||||||
objectComponent.systemType,
|
objectComponent.systemType,
|
||||||
objectComponent.entityManager,
|
|
||||||
objectComponent.parentEntity
|
objectComponent.parentEntity
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,12 +42,6 @@ GameLib.D3.API.Camera = function(
|
||||||
eyeSeparation,
|
eyeSeparation,
|
||||||
focalLength
|
focalLength
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_CAMERA,
|
|
||||||
null,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
|
@ -146,6 +140,11 @@ GameLib.D3.API.Camera = function(
|
||||||
focalLength = 150;
|
focalLength = 150;
|
||||||
}
|
}
|
||||||
this.focalLength = focalLength;
|
this.focalLength = focalLength;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Camera.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Camera.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -16,18 +16,6 @@ GameLib.D3.API.Composer = function (
|
||||||
passes,
|
passes,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_COMPOSER,
|
|
||||||
{
|
|
||||||
'renderer' : GameLib.D3.Renderer,
|
|
||||||
'renderTarget' : GameLib.D3.RenderTarget,
|
|
||||||
'passes' : [GameLib.D3.Pass]
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -52,6 +40,11 @@ GameLib.D3.API.Composer = function (
|
||||||
passes = [];
|
passes = [];
|
||||||
}
|
}
|
||||||
this.passes = passes;
|
this.passes = passes;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Composer.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Composer.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -1,31 +1,21 @@
|
||||||
/**
|
/**
|
||||||
* This component makes the parentEntity (ex. car) follow the path provided by the spline
|
* Custom Code Component
|
||||||
* @param id String
|
* @param id
|
||||||
* @param name String
|
* @param name
|
||||||
* @param code String
|
|
||||||
* @param domElementId
|
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
|
* @param code
|
||||||
|
* @param domElementId
|
||||||
* @param args
|
* @param args
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.CustomCode = function (
|
GameLib.D3.API.CustomCode = function (
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
|
parentEntity,
|
||||||
code,
|
code,
|
||||||
domElementId,
|
domElementId,
|
||||||
parentEntity,
|
|
||||||
args
|
args
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_CUSTOM_CODE,
|
|
||||||
{
|
|
||||||
'args' : [GameLib.Component]
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -36,6 +26,11 @@ GameLib.D3.API.CustomCode = function (
|
||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(code)) {
|
if (GameLib.Utils.UndefinedOrNull(code)) {
|
||||||
code = '';
|
code = '';
|
||||||
}
|
}
|
||||||
|
@ -65,9 +60,9 @@ GameLib.D3.API.CustomCode.FromObject = function(objectComponent) {
|
||||||
return new GameLib.D3.API.CustomCode(
|
return new GameLib.D3.API.CustomCode(
|
||||||
objectComponent.id,
|
objectComponent.id,
|
||||||
objectComponent.name,
|
objectComponent.name,
|
||||||
|
objectComponent.parentEntity,
|
||||||
objectComponent.code,
|
objectComponent.code,
|
||||||
objectComponent.domElementId,
|
objectComponent.domElementId,
|
||||||
objectComponent.parentEntity,
|
|
||||||
objectComponent.args
|
objectComponent.args
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,13 +12,6 @@ GameLib.D3.API.ImageFactory = function(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_IMAGE_FACTORY,
|
|
||||||
null,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -34,6 +27,11 @@ GameLib.D3.API.ImageFactory = function(
|
||||||
console.warn('No baseURL defined for image factory');
|
console.warn('No baseURL defined for image factory');
|
||||||
}
|
}
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.ImageFactory.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.ImageFactory.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -30,19 +30,6 @@ GameLib.D3.API.Input.Drive = function (
|
||||||
distanceGrain,
|
distanceGrain,
|
||||||
rotationFactor
|
rotationFactor
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_INPUT_DRIVE,
|
|
||||||
{
|
|
||||||
'pathFollowingComponent' : GameLib.D3.PathFollowing,
|
|
||||||
'wheelFL' : GameLib.D3.Mesh,
|
|
||||||
'wheelFR' : GameLib.D3.Mesh,
|
|
||||||
'wheelRL' : GameLib.D3.Mesh,
|
|
||||||
'wheelRR' : GameLib.D3.Mesh
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -63,6 +50,11 @@ GameLib.D3.API.Input.Drive = function (
|
||||||
}
|
}
|
||||||
this.pathFollowingComponent = pathFollowingComponent;
|
this.pathFollowingComponent = pathFollowingComponent;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(wheelFL)) {
|
if (GameLib.Utils.UndefinedOrNull(wheelFL)) {
|
||||||
wheelFL = null;
|
wheelFL = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,6 @@ GameLib.D3.API.Input.Editor = function (
|
||||||
camera,
|
camera,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_INPUT_EDITOR,
|
|
||||||
{
|
|
||||||
'camera' : GameLib.D3.Camera
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
|
@ -43,6 +35,11 @@ GameLib.D3.API.Input.Editor = function (
|
||||||
}
|
}
|
||||||
this.camera = camera;
|
this.camera = camera;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Input.Editor.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Input.Editor.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -38,15 +38,6 @@ GameLib.D3.API.Light = function(
|
||||||
parentScene,
|
parentScene,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_LIGHT,
|
|
||||||
{
|
|
||||||
'parentScene' : GameLib.D3.Scene
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -126,6 +117,11 @@ GameLib.D3.API.Light = function(
|
||||||
parentScene = null;
|
parentScene = null;
|
||||||
}
|
}
|
||||||
this.parentScene = parentScene;
|
this.parentScene = parentScene;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)){
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Light.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Light.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -19,16 +19,6 @@ GameLib.D3.API.LookAt = function (
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_LOOK_AT,
|
|
||||||
{
|
|
||||||
'currentComponent' : GameLib.Component,
|
|
||||||
'targetComponent' : GameLib.Component
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -66,6 +56,11 @@ GameLib.D3.API.LookAt = function (
|
||||||
this.currentRotation = new GameLib.API.Quaternion();
|
this.currentRotation = new GameLib.API.Quaternion();
|
||||||
|
|
||||||
this.targetPosition = new GameLib.API.Vector3();
|
this.targetPosition = new GameLib.API.Vector3();
|
||||||
|
|
||||||
|
if(GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.LookAt.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.LookAt.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -69,7 +69,6 @@
|
||||||
* @param roughnessMap
|
* @param roughnessMap
|
||||||
* @param specularMap
|
* @param specularMap
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @param selected
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Material = function(
|
GameLib.D3.API.Material = function(
|
||||||
|
@ -144,26 +143,6 @@ GameLib.D3.API.Material = function(
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_MATERIAL,
|
|
||||||
{
|
|
||||||
'alphaMap' : GameLib.D3.Texture,
|
|
||||||
'aoMap' : GameLib.D3.Texture,
|
|
||||||
'bumpMap' : GameLib.D3.Texture,
|
|
||||||
'diffuseMap' : GameLib.D3.Texture,
|
|
||||||
'displacementMap' : GameLib.D3.Texture,
|
|
||||||
'emissiveMap' : GameLib.D3.Texture,
|
|
||||||
'environmentMap' : GameLib.D3.Texture,
|
|
||||||
'lightMap' : GameLib.D3.Texture,
|
|
||||||
'metalnessMap' : GameLib.D3.Texture,
|
|
||||||
'normalMap' : GameLib.D3.Texture,
|
|
||||||
'roughnessMap' : GameLib.D3.Texture,
|
|
||||||
'specularMap' : GameLib.D3.Texture
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -504,6 +483,11 @@ GameLib.D3.API.Material = function(
|
||||||
}
|
}
|
||||||
this.specularMap = specularMap;
|
this.specularMap = specularMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
this.needsUpdate = false;
|
this.needsUpdate = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -647,7 +631,6 @@ GameLib.D3.API.Material.FromObject = function(objectMaterial) {
|
||||||
apiNormalMap,
|
apiNormalMap,
|
||||||
apiRoughnessMap,
|
apiRoughnessMap,
|
||||||
apiSpecularMap,
|
apiSpecularMap,
|
||||||
objectMaterial.parentEntity,
|
objectMaterial.parentEntity
|
||||||
objectMaterial.selected
|
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,18 +48,6 @@ GameLib.D3.API.Mesh = function(
|
||||||
parentEntity,
|
parentEntity,
|
||||||
renderOrder
|
renderOrder
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_MESH,
|
|
||||||
{
|
|
||||||
'parentMesh' : GameLib.D3.Mesh,
|
|
||||||
'parentScene' : GameLib.D3.Scene,
|
|
||||||
'materials' : [GameLib.D3.Material],
|
|
||||||
'skeleton' : GameLib.D3.Skeleton
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -164,6 +152,11 @@ GameLib.D3.API.Mesh = function(
|
||||||
renderOrder = 0;
|
renderOrder = 0;
|
||||||
}
|
}
|
||||||
this.renderOrder = renderOrder;
|
this.renderOrder = renderOrder;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Mesh.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Mesh.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -18,17 +18,6 @@ GameLib.D3.API.Pass = function (
|
||||||
renderToScreen,
|
renderToScreen,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_PASS,
|
|
||||||
{
|
|
||||||
'camera' : GameLib.D3.Camera,
|
|
||||||
'scene' : GameLib.D3.Scene
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +45,7 @@ GameLib.D3.API.Pass = function (
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(renderToScreen)) {
|
if (GameLib.Utils.UndefinedOrNull(renderToScreen)) {
|
||||||
|
|
||||||
if (this.passType == GameLib.D3.Pass.PASS_TYPE_RENDER) {
|
if (this.passType === GameLib.D3.Pass.PASS_TYPE_RENDER) {
|
||||||
renderToScreen = false;
|
renderToScreen = false;
|
||||||
} else if (GameLib.D3.Pass.PASS_TYPE_COPY_SHADER) {
|
} else if (GameLib.D3.Pass.PASS_TYPE_COPY_SHADER) {
|
||||||
renderToScreen = true;
|
renderToScreen = true;
|
||||||
|
@ -68,6 +57,10 @@ GameLib.D3.API.Pass = function (
|
||||||
}
|
}
|
||||||
this.renderToScreen = renderToScreen;
|
this.renderToScreen = renderToScreen;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Pass.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Pass.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -48,18 +48,6 @@ GameLib.D3.API.PathFollowing = function (
|
||||||
rotationVector,
|
rotationVector,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_PATH_FOLLOWING,
|
|
||||||
{
|
|
||||||
'spline': GameLib.D3.Spline,
|
|
||||||
'mesh' : GameLib.D3.Mesh,
|
|
||||||
'raytraceMesh' : GameLib.D3.Mesh
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -164,6 +152,12 @@ GameLib.D3.API.PathFollowing = function (
|
||||||
rotationVector = new GameLib.API.Quaternion();
|
rotationVector = new GameLib.API.Quaternion();
|
||||||
}
|
}
|
||||||
this.rotationVector = rotationVector;
|
this.rotationVector = rotationVector;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.PathFollowing.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.PathFollowing.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -24,16 +24,6 @@ GameLib.D3.API.RenderTarget = function (
|
||||||
texture,
|
texture,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_RENDER_TARGET,
|
|
||||||
{
|
|
||||||
'texture' : GameLib.D3.Texture
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -79,6 +69,11 @@ GameLib.D3.API.RenderTarget = function (
|
||||||
}
|
}
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.RenderTarget.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.RenderTarget.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -24,16 +24,6 @@ GameLib.D3.API.Renderer = function (
|
||||||
clearColor,
|
clearColor,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_RENDERER,
|
|
||||||
{
|
|
||||||
'domElement' : GameLib.DomElement
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -78,6 +68,12 @@ GameLib.D3.API.Renderer = function (
|
||||||
clearColor = new GameLib.API.Color(0.58, 0.58, 0.58);
|
clearColor = new GameLib.API.Color(0.58, 0.58, 0.58);
|
||||||
}
|
}
|
||||||
this.clearColor = clearColor;
|
this.clearColor = clearColor;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Renderer.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Renderer.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -30,19 +30,6 @@ GameLib.D3.API.Scene = function(
|
||||||
activeCamera,
|
activeCamera,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_SCENE,
|
|
||||||
{
|
|
||||||
'meshes' : [GameLib.D3.Mesh],
|
|
||||||
'lights' : [GameLib.D3.Light],
|
|
||||||
'textures' : [GameLib.D3.Texture],
|
|
||||||
'materials' : [GameLib.D3.Material],
|
|
||||||
'images' : [GameLib.D3.Image],
|
|
||||||
'activeCamera' : GameLib.D3.Camera
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
|
@ -104,6 +91,11 @@ GameLib.D3.API.Scene = function(
|
||||||
}
|
}
|
||||||
this.activeCamera = activeCamera;
|
this.activeCamera = activeCamera;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Scene.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Scene.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -29,15 +29,6 @@ GameLib.D3.API.Skeleton = function (
|
||||||
}
|
}
|
||||||
this.parentEntity = parentEntity;
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_SKELETON,
|
|
||||||
{
|
|
||||||
'bones' : [GameLib.D3.Bone]
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,6 @@ GameLib.D3.API.Spline = function(
|
||||||
vertices,
|
vertices,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_SPLINE,
|
|
||||||
null,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -33,6 +26,11 @@ GameLib.D3.API.Spline = function(
|
||||||
vertices = [];
|
vertices = [];
|
||||||
}
|
}
|
||||||
this.vertices = vertices;
|
this.vertices = vertices;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Spline.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Spline.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -53,15 +53,6 @@ GameLib.D3.API.Texture = function(
|
||||||
}
|
}
|
||||||
this.parentEntity = parentEntity;
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_TEXTURE,
|
|
||||||
{
|
|
||||||
'image' : GameLib.D3.Image
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,6 @@ GameLib.D3.API.Viewport = function(
|
||||||
scenes,
|
scenes,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_VIEWPORT,
|
|
||||||
{
|
|
||||||
'scenes' : [GameLib.D3.Scene]
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
|
@ -63,6 +55,11 @@ GameLib.D3.API.Viewport = function(
|
||||||
scenes = [];
|
scenes = [];
|
||||||
}
|
}
|
||||||
this.scenes = scenes;
|
this.scenes = scenes;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Viewport.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Viewport.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -76,9 +76,12 @@ GameLib.D3.Camera = function(
|
||||||
throw new Error('lookAt not instance of API.Vector3');
|
throw new Error('lookAt not instance of API.Vector3');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_CAMERA
|
||||||
|
);
|
||||||
|
|
||||||
this.needsUpdate = false;
|
//this.needsUpdate = false;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
GameLib.D3.Camera.prototype = Object.create(GameLib.D3.API.Camera.prototype);
|
GameLib.D3.Camera.prototype = Object.create(GameLib.D3.API.Camera.prototype);
|
||||||
|
@ -94,6 +97,11 @@ GameLib.D3.Camera.CAMERA_TYPE_STEREO = 0x3;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera.prototype.createInstance = function(update) {
|
GameLib.D3.Camera.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
|
if (!this.loaded) {
|
||||||
|
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var instance = null;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
@ -101,14 +109,14 @@ GameLib.D3.Camera.prototype.createInstance = function(update) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
if (this.cameraType == GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE ) {
|
if (this.cameraType === GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE ) {
|
||||||
instance = new THREE.PerspectiveCamera(
|
instance = new THREE.PerspectiveCamera(
|
||||||
this.fov,
|
this.fov,
|
||||||
this.aspect,
|
this.aspect,
|
||||||
this.near,
|
this.near,
|
||||||
this.far
|
this.far
|
||||||
);
|
);
|
||||||
} else if (this.cameraType == GameLib.D3.Camera.CAMERA_TYPE_ORTHOGONAL) {
|
} else if (this.cameraType === GameLib.D3.Camera.CAMERA_TYPE_ORTHOGONAL) {
|
||||||
instance = new THREE.OrthographicCamera(
|
instance = new THREE.OrthographicCamera(
|
||||||
this.minX,
|
this.minX,
|
||||||
this.maxX,
|
this.maxX,
|
||||||
|
|
|
@ -30,37 +30,15 @@ GameLib.D3.Composer = function (
|
||||||
apiComposer.parentEntity
|
apiComposer.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.renderer instanceof GameLib.D3.API.Renderer) {
|
GameLib.Component.call(
|
||||||
this.renderer = new GameLib.D3.Renderer(
|
this,
|
||||||
this.graphics,
|
GameLib.Component.COMPONENT_COMPOSER,
|
||||||
this.renderer
|
{
|
||||||
)
|
'renderer' : GameLib.D3.Renderer,
|
||||||
|
'renderTarget' : GameLib.D3.RenderTarget,
|
||||||
|
'passes' : [GameLib.D3.Pass]
|
||||||
}
|
}
|
||||||
|
|
||||||
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.instance = this.createInstance();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Composer.prototype = Object.create(GameLib.D3.API.Composer.prototype);
|
GameLib.D3.Composer.prototype = Object.create(GameLib.D3.API.Composer.prototype);
|
||||||
|
@ -73,31 +51,38 @@ GameLib.D3.Composer.prototype.constructor = GameLib.D3.Composer;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Composer.prototype.createInstance = function(update) {
|
GameLib.D3.Composer.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
var instance = null;
|
if (!this.loaded) {
|
||||||
|
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
|
||||||
if (update) {
|
return null;
|
||||||
instance = this.instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.renderer &&
|
//TODO : Fix this too - make it nice (no circular references)
|
||||||
this.renderTarget) {
|
// var instance = null;
|
||||||
|
//
|
||||||
|
// if (update) {
|
||||||
|
// instance = this.instance;
|
||||||
|
// }
|
||||||
|
|
||||||
if (!THREE.EffectComposer) {
|
//TODO : Fix this still (renderer and renderTarget should be objects)
|
||||||
console.warn('No THREE.EffectComposer');
|
// if (this.renderer &&
|
||||||
throw new Error('No THREE.EffectComposer');
|
// this.renderTarget) {
|
||||||
}
|
//
|
||||||
|
// if (!THREE.EffectComposer) {
|
||||||
instance = new THREE.EffectComposer(
|
// console.warn('No THREE.EffectComposer');
|
||||||
this.renderer.instance,
|
// throw new Error('No THREE.EffectComposer');
|
||||||
this.renderTarget.instance
|
// }
|
||||||
);
|
//
|
||||||
|
// instance = new THREE.EffectComposer(
|
||||||
this.passes.map(
|
// this.renderer.instance,
|
||||||
function(pass) {
|
// this.renderTarget.instance
|
||||||
this.instance.addPass(pass.instance);
|
// );
|
||||||
}.bind(this)
|
//
|
||||||
);
|
// this.passes.map(
|
||||||
}
|
// function(pass) {
|
||||||
|
// this.instance.addPass(pass.instance);
|
||||||
|
// }.bind(this)
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,15 +19,19 @@ GameLib.D3.CustomCode = function(
|
||||||
this,
|
this,
|
||||||
apiCustomCode.id,
|
apiCustomCode.id,
|
||||||
apiCustomCode.name,
|
apiCustomCode.name,
|
||||||
|
apiCustomCode.parentEntity,
|
||||||
apiCustomCode.code,
|
apiCustomCode.code,
|
||||||
apiCustomCode.domElementId,
|
apiCustomCode.domElementId,
|
||||||
apiCustomCode.parentEntity,
|
|
||||||
apiCustomCode.args
|
apiCustomCode.args
|
||||||
);
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.COMPONENT_CUSTOM_CODE,
|
||||||
|
{
|
||||||
|
'args' : [GameLib.Component]
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.CustomCode.prototype = Object.create(GameLib.D3.API.CustomCode.prototype);
|
GameLib.D3.CustomCode.prototype = Object.create(GameLib.D3.API.CustomCode.prototype);
|
||||||
|
@ -39,6 +43,11 @@ GameLib.D3.CustomCode.prototype.constructor = GameLib.D3.CustomCode;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.CustomCode.prototype.createInstance = function(update) {
|
GameLib.D3.CustomCode.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
|
if (!this.loaded) {
|
||||||
|
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var instance = function(deltaTime) {
|
var instance = function(deltaTime) {
|
||||||
this.args['deltaTime'] = deltaTime;
|
this.args['deltaTime'] = deltaTime;
|
||||||
var f = new Function(this.code).apply(this.parentEntity, this.args);
|
var f = new Function(this.code).apply(this.parentEntity, this.args);
|
||||||
|
@ -61,22 +70,18 @@ GameLib.D3.CustomCode.prototype.updateInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.CustomCode.prototype.toApiObject = function() {
|
GameLib.D3.CustomCode.prototype.toApiObject = function() {
|
||||||
|
|
||||||
var apiArgs = [];
|
var apiArgs = this.args.map(
|
||||||
|
|
||||||
if (this.args) {
|
|
||||||
apiArgs = this.args.map(
|
|
||||||
function(arg) {
|
function(arg) {
|
||||||
return GameLib.Utils.IdOrNull(arg);
|
return GameLib.Utils.IdOrNull(arg);
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return new GameLib.D3.API.CustomCode(
|
return new GameLib.D3.API.CustomCode(
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
|
GameLib.Utils.IdOrNull(this.parentEntity),
|
||||||
this.code,
|
this.code,
|
||||||
this.domElementId,
|
this.domElementId,
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity),
|
|
||||||
apiArgs
|
apiArgs
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,6 @@ GameLib.D3.ImageFactory = function (
|
||||||
return apiImageFactory;
|
return apiImageFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(progressCallback)) {
|
|
||||||
progressCallback = null;
|
|
||||||
}
|
|
||||||
this.progressCallback = progressCallback;
|
|
||||||
|
|
||||||
GameLib.D3.API.ImageFactory.call(
|
GameLib.D3.API.ImageFactory.call(
|
||||||
this,
|
this,
|
||||||
apiImageFactory.id,
|
apiImageFactory.id,
|
||||||
|
@ -35,11 +30,17 @@ GameLib.D3.ImageFactory = function (
|
||||||
apiImageFactory.parentEntity
|
apiImageFactory.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
if (GameLib.Utils.UndefinedOrNull(progressCallback)) {
|
||||||
|
progressCallback = null;
|
||||||
|
}
|
||||||
|
this.progressCallback = progressCallback;
|
||||||
|
|
||||||
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_IMAGE_FACTORY
|
||||||
|
);
|
||||||
|
|
||||||
this.promiseList = {};
|
this.promiseList = {};
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.ImageFactory.prototype = Object.create(GameLib.D3.API.ImageFactory.prototype);
|
GameLib.D3.ImageFactory.prototype = Object.create(GameLib.D3.API.ImageFactory.prototype);
|
||||||
|
@ -47,6 +48,11 @@ GameLib.D3.ImageFactory.prototype.constructor = GameLib.D3.ImageFactory;
|
||||||
|
|
||||||
GameLib.D3.ImageFactory.prototype.createInstance = function(update) {
|
GameLib.D3.ImageFactory.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
|
if (!this.loaded) {
|
||||||
|
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var instance = null;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
|
@ -49,9 +49,17 @@ GameLib.D3.Input.Drive = function (
|
||||||
|
|
||||||
this.keyRight = false;
|
this.keyRight = false;
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.COMPONENT_INPUT_DRIVE,
|
||||||
|
{
|
||||||
|
'pathFollowingComponent' : GameLib.D3.PathFollowing,
|
||||||
|
'wheelFL' : GameLib.D3.Mesh,
|
||||||
|
'wheelFR' : GameLib.D3.Mesh,
|
||||||
|
'wheelRL' : GameLib.D3.Mesh,
|
||||||
|
'wheelRR' : GameLib.D3.Mesh
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Input.Drive.prototype = Object.create(GameLib.D3.API.Input.Drive.prototype);
|
GameLib.D3.Input.Drive.prototype = Object.create(GameLib.D3.API.Input.Drive.prototype);
|
||||||
|
@ -59,6 +67,11 @@ GameLib.D3.Input.Drive.prototype.constructor = GameLib.D3.Input.Drive;
|
||||||
|
|
||||||
GameLib.D3.Input.Drive.prototype.createInstance = function(update) {
|
GameLib.D3.Input.Drive.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
|
if (!this.loaded) {
|
||||||
|
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
return this.instance;
|
return this.instance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,15 +68,25 @@ GameLib.D3.Input.Editor = function (
|
||||||
this.graphics
|
this.graphics
|
||||||
);
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.COMPONENT_INPUT_EDITOR,
|
||||||
|
{
|
||||||
|
'camera' : GameLib.D3.Camera
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Input.Editor.prototype = Object.create(GameLib.D3.API.Input.Editor.prototype);
|
GameLib.D3.Input.Editor.prototype = Object.create(GameLib.D3.API.Input.Editor.prototype);
|
||||||
GameLib.D3.Input.Editor.prototype.constructor = GameLib.D3.Input.Editor;
|
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) {
|
||||||
|
|
||||||
|
if (!this.loaded) {
|
||||||
|
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var instance = null;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
|
@ -75,7 +75,13 @@ GameLib.D3.Light = function(
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_LIGHT,
|
||||||
|
{
|
||||||
|
'parentScene' : GameLib.D3.Scene
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Light.prototype = Object.create(GameLib.D3.API.Light.prototype);
|
GameLib.D3.Light.prototype = Object.create(GameLib.D3.API.Light.prototype);
|
||||||
|
|
|
@ -60,12 +60,23 @@ GameLib.D3.LookAt = function (
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_LOOK_AT,
|
||||||
|
{
|
||||||
|
'currentComponent' : GameLib.Component,
|
||||||
|
'targetComponent' : GameLib.Component
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.LookAt.prototype = Object.create(GameLib.D3.API.LookAt.prototype);
|
GameLib.D3.LookAt.prototype = Object.create(GameLib.D3.API.LookAt.prototype);
|
||||||
GameLib.D3.LookAt.prototype.constructor = GameLib.D3.LookAt;
|
GameLib.D3.LookAt.prototype.constructor = GameLib.D3.LookAt;
|
||||||
|
|
||||||
|
GameLib.D3.LookAt.prototype.createInstance = function() {
|
||||||
|
console.log('LookAt.createInstance()');
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.D3.LookAt.prototype.toApiObject = function() {
|
GameLib.D3.LookAt.prototype.toApiObject = function() {
|
||||||
|
|
||||||
var apiLookAt = new GameLib.D3.API.LookAt(
|
var apiLookAt = new GameLib.D3.API.LookAt(
|
||||||
|
|
|
@ -221,9 +221,24 @@ GameLib.D3.Material = function(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.COMPONENT_MATERIAL,
|
||||||
|
{
|
||||||
|
'alphaMap' : GameLib.D3.Texture,
|
||||||
|
'aoMap' : GameLib.D3.Texture,
|
||||||
|
'bumpMap' : GameLib.D3.Texture,
|
||||||
|
'diffuseMap' : GameLib.D3.Texture,
|
||||||
|
'displacementMap' : GameLib.D3.Texture,
|
||||||
|
'emissiveMap' : GameLib.D3.Texture,
|
||||||
|
'environmentMap' : GameLib.D3.Texture,
|
||||||
|
'lightMap' : GameLib.D3.Texture,
|
||||||
|
'metalnessMap' : GameLib.D3.Texture,
|
||||||
|
'normalMap' : GameLib.D3.Texture,
|
||||||
|
'roughnessMap' : GameLib.D3.Texture,
|
||||||
|
'specularMap' : GameLib.D3.Texture
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.updateTextures();
|
this.updateTextures();
|
||||||
};
|
};
|
||||||
|
|
|
@ -122,16 +122,16 @@ GameLib.D3.Mesh = function (
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.COMPONENT_MESH,
|
||||||
|
{
|
||||||
this.instance.geometry.computeBoundingBox();
|
'parentMesh' : GameLib.D3.Mesh,
|
||||||
|
'parentScene' : GameLib.D3.Scene,
|
||||||
this.width = this.instance.geometry.boundingBox.max.x - this.instance.geometry.boundingBox.min.x;
|
'materials' : [GameLib.D3.Material],
|
||||||
this.height = this.instance.geometry.boundingBox.max.y - this.instance.geometry.boundingBox.min.y;
|
'skeleton' : GameLib.D3.Skeleton
|
||||||
this.depth = this.instance.geometry.boundingBox.max.z - this.instance.geometry.boundingBox.min.z;
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype = Object.create(GameLib.D3.API.Mesh.prototype);
|
GameLib.D3.Mesh.prototype = Object.create(GameLib.D3.API.Mesh.prototype);
|
||||||
|
@ -328,6 +328,12 @@ GameLib.D3.Mesh.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
this.instance.renderOrder = this.renderOrder;
|
this.instance.renderOrder = this.renderOrder;
|
||||||
|
|
||||||
|
this.instance.geometry.computeBoundingBox();
|
||||||
|
|
||||||
|
this.width = this.instance.geometry.boundingBox.max.x - this.instance.geometry.boundingBox.min.x;
|
||||||
|
this.height = this.instance.geometry.boundingBox.max.y - this.instance.geometry.boundingBox.min.y;
|
||||||
|
this.depth = this.instance.geometry.boundingBox.max.z - this.instance.geometry.boundingBox.min.z;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var instance = null;
|
var instance = null;
|
||||||
|
@ -432,6 +438,12 @@ GameLib.D3.Mesh.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
instance.renderOrder = this.renderOrder;
|
instance.renderOrder = this.renderOrder;
|
||||||
|
|
||||||
|
instance.geometry.computeBoundingBox();
|
||||||
|
|
||||||
|
this.width = instance.geometry.boundingBox.max.x - instance.geometry.boundingBox.min.x;
|
||||||
|
this.height = instance.geometry.boundingBox.max.y - instance.geometry.boundingBox.min.y;
|
||||||
|
this.depth = instance.geometry.boundingBox.max.z - instance.geometry.boundingBox.min.z;
|
||||||
|
|
||||||
this.subscribe(
|
this.subscribe(
|
||||||
GameLib.Event.MATERIAL_LOADED,
|
GameLib.Event.MATERIAL_LOADED,
|
||||||
function(data) {
|
function(data) {
|
||||||
|
|
|
@ -73,11 +73,9 @@ GameLib.D3.Mesh.Sphere.prototype.toApiObject = function() {
|
||||||
* Converts a standard object mesh to a GameLib.D3.Mesh
|
* Converts a standard object mesh to a GameLib.D3.Mesh
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param objectMesh {Object}
|
* @param objectMesh {Object}
|
||||||
* @param computeNormals boolean to indicate whether or not to recalculate normals
|
|
||||||
* @param imageFactory GameLib.D3.ImageFactory
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.Sphere.FromObject = function(graphics, objectMesh, computeNormals, imageFactory) {
|
GameLib.D3.Mesh.Sphere.FromObject = function(graphics, objectMesh) {
|
||||||
|
|
||||||
var apiMesh = GameLib.D3.API.Mesh.FromObject(objectMesh);
|
var apiMesh = GameLib.D3.API.Mesh.FromObject(objectMesh);
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,14 @@ GameLib.D3.Pass = function (
|
||||||
apiPass.parentEntity
|
apiPass.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.COMPONENT_PASS,
|
||||||
|
{
|
||||||
|
'camera' : GameLib.D3.Camera,
|
||||||
|
'scene' : GameLib.D3.Scene
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Pass.prototype = Object.create(GameLib.D3.API.Pass.prototype);
|
GameLib.D3.Pass.prototype = Object.create(GameLib.D3.API.Pass.prototype);
|
||||||
|
|
|
@ -109,12 +109,24 @@ GameLib.D3.PathFollowing = function (
|
||||||
this.my = new GameLib.Utils.MovingAverage(10);
|
this.my = new GameLib.Utils.MovingAverage(10);
|
||||||
this.mz = new GameLib.Utils.MovingAverage(10);
|
this.mz = new GameLib.Utils.MovingAverage(10);
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_PATH_FOLLOWING,
|
||||||
|
{
|
||||||
|
'spline': GameLib.D3.Spline,
|
||||||
|
'mesh' : GameLib.D3.Mesh,
|
||||||
|
'raytraceMesh' : GameLib.D3.Mesh
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.PathFollowing.prototype = Object.create(GameLib.D3.API.PathFollowing.prototype);
|
GameLib.D3.PathFollowing.prototype = Object.create(GameLib.D3.API.PathFollowing.prototype);
|
||||||
GameLib.D3.PathFollowing.prototype.constructor = GameLib.D3.PathFollowing;
|
GameLib.D3.PathFollowing.prototype.constructor = GameLib.D3.PathFollowing;
|
||||||
|
|
||||||
|
GameLib.D3.PathFollowing.prototype.createInstance = function() {
|
||||||
|
console.log('GameLib.D3.PathFollowing.prototype.createInstance()');
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.D3.PathFollowing.prototype.toApiObject = function() {
|
GameLib.D3.PathFollowing.prototype.toApiObject = function() {
|
||||||
|
|
||||||
var apiPathFollowing = new GameLib.D3.API.PathFollowing(
|
var apiPathFollowing = new GameLib.D3.API.PathFollowing(
|
||||||
|
|
|
@ -33,9 +33,13 @@ GameLib.D3.RenderTarget = function (
|
||||||
apiRenderTarget.texture
|
apiRenderTarget.texture
|
||||||
);
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.COMPONENT_RENDER_TARGET,
|
||||||
|
{
|
||||||
|
'texture' : GameLib.D3.Texture
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.RenderTarget.prototype = Object.create(GameLib.D3.API.RenderTarget.prototype);
|
GameLib.D3.RenderTarget.prototype = Object.create(GameLib.D3.API.RenderTarget.prototype);
|
||||||
|
|
|
@ -46,7 +46,14 @@ GameLib.D3.Renderer = function (
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_RENDERER,
|
||||||
|
{
|
||||||
|
'domElement' : GameLib.DomElement
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Renderer.prototype = Object.create(GameLib.D3.API.Renderer.prototype);
|
GameLib.D3.Renderer.prototype = Object.create(GameLib.D3.API.Renderer.prototype);
|
||||||
|
|
|
@ -100,7 +100,7 @@ GameLib.D3.Scene = function (
|
||||||
apiTexture
|
apiTexture
|
||||||
);
|
);
|
||||||
|
|
||||||
this.idToObject[texture.id] = texture;
|
// this.idToObject[texture.id] = texture;
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
} else {
|
} else {
|
||||||
|
@ -121,7 +121,7 @@ GameLib.D3.Scene = function (
|
||||||
apiMaterial
|
apiMaterial
|
||||||
);
|
);
|
||||||
|
|
||||||
this.idToObject[material.id] = material;
|
// this.idToObject[material.id] = material;
|
||||||
|
|
||||||
return material;
|
return material;
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ GameLib.D3.Scene = function (
|
||||||
apiImage
|
apiImage
|
||||||
);
|
);
|
||||||
|
|
||||||
this.idToObject[image.id] = image;
|
// this.idToObject[image.id] = image;
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
|
||||||
|
@ -162,13 +162,26 @@ GameLib.D3.Scene = function (
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.idToObject[this.id] = this;
|
/**
|
||||||
|
* TODO : Refactor (linking ?)
|
||||||
|
* @type {GameLib.D3.Scene}
|
||||||
|
*/
|
||||||
|
// this.idToObject[this.id] = this;
|
||||||
|
//
|
||||||
|
// this.linkObjects(this.idToObject);
|
||||||
|
|
||||||
this.linkObjects(this.idToObject);
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.buildIdToObject();
|
GameLib.Component.COMPONENT_SCENE,
|
||||||
|
{
|
||||||
this.instance = this.createInstance();
|
'meshes' : [GameLib.D3.Mesh],
|
||||||
|
'lights' : [GameLib.D3.Light],
|
||||||
|
'textures' : [GameLib.D3.Texture],
|
||||||
|
'materials' : [GameLib.D3.Material],
|
||||||
|
'images' : [GameLib.D3.Image],
|
||||||
|
'activeCamera' : GameLib.D3.Camera
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Scene.prototype = Object.create(GameLib.D3.API.Scene.prototype);
|
GameLib.D3.Scene.prototype = Object.create(GameLib.D3.API.Scene.prototype);
|
||||||
|
|
|
@ -83,9 +83,13 @@ GameLib.D3.Skeleton = function Skeleton(
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.COMPONENT_SKELETON,
|
||||||
|
{
|
||||||
|
'bones' : [GameLib.D3.Bone]
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Skeleton.prototype = Object.create(GameLib.D3.API.Skeleton.prototype);
|
GameLib.D3.Skeleton.prototype = Object.create(GameLib.D3.API.Skeleton.prototype);
|
||||||
|
@ -122,7 +126,7 @@ GameLib.D3.Skeleton.prototype.createInstance = function(update) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bone.parentBoneIds.length == 0) {
|
if (bone.parentBoneIds.length === 0) {
|
||||||
return bone.instance;
|
return bone.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,10 @@ GameLib.D3.Spline = function (
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_SPLINE
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Spline.prototype = Object.create(GameLib.D3.API.Spline.prototype);
|
GameLib.D3.Spline.prototype = Object.create(GameLib.D3.API.Spline.prototype);
|
||||||
|
|
|
@ -19,15 +19,6 @@ GameLib.D3.Stats = function(
|
||||||
}
|
}
|
||||||
this.stats = stats;
|
this.stats = stats;
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_STATS,
|
|
||||||
{
|
|
||||||
'domElement': GameLib.DomElement
|
|
||||||
},
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -44,7 +35,18 @@ GameLib.D3.Stats = function(
|
||||||
}
|
}
|
||||||
this.domElement = domElement;
|
this.domElement = domElement;
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
|
parentEntity = null;
|
||||||
|
}
|
||||||
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_STATS,
|
||||||
|
{
|
||||||
|
'domElement': GameLib.DomElement
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Stats.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.Stats.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
|
|
@ -65,7 +65,13 @@ GameLib.D3.Texture = function(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_TEXTURE,
|
||||||
|
{
|
||||||
|
'image' : GameLib.D3.Image
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Texture.prototype = Object.create(GameLib.D3.API.Texture.prototype);
|
GameLib.D3.Texture.prototype = Object.create(GameLib.D3.API.Texture.prototype);
|
||||||
|
|
|
@ -32,9 +32,13 @@ GameLib.D3.Viewport = function (
|
||||||
apiViewport.parentEntity
|
apiViewport.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
this.buildIdToObject();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.COMPONENT_VIEWPORT,
|
||||||
|
{
|
||||||
|
'scenes' : [GameLib.D3.Scene]
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Viewport.prototype = Object.create(GameLib.D3.API.Viewport.prototype);
|
GameLib.D3.Viewport.prototype = Object.create(GameLib.D3.API.Viewport.prototype);
|
||||||
|
|
|
@ -17,7 +17,10 @@ GameLib.DomElement = function (apiDomElement) {
|
||||||
apiDomElement.parentEntity
|
apiDomElement.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_DOM_ELEMENT
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.DomElement.prototype = Object.create(GameLib.API.DomElement.prototype);
|
GameLib.DomElement.prototype = Object.create(GameLib.API.DomElement.prototype);
|
||||||
|
|
|
@ -1,85 +1,38 @@
|
||||||
/**
|
/**
|
||||||
* GameLib.EntityManager
|
* GameLib.EntityManager
|
||||||
* @param graphics GameLib.D3.Graphics
|
|
||||||
* @param apiEntityManager GameLib.API.EntityManager
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.EntityManager = function(
|
GameLib.EntityManager = function() {
|
||||||
graphics,
|
|
||||||
apiEntityManager
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
this.id = GameLib.Utils.RandomId();
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiEntityManager)) {
|
this.name = 'Entity Manager (' + this.id + ')';
|
||||||
apiEntityManager = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (apiEntityManager instanceof GameLib.EntityManager) {
|
this.entities = [];
|
||||||
return apiEntityManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.EntityManager.call(
|
GameLib.Component.call(
|
||||||
this,
|
this,
|
||||||
apiEntityManager.id,
|
GameLib.Component.COMPONENT_ENTITY_MANAGER,
|
||||||
apiEntityManager.name,
|
{
|
||||||
apiEntityManager.entities,
|
'entities' : [GameLib.Entity]
|
||||||
// apiEntityManager.systems,
|
},
|
||||||
apiEntityManager.parentEntity
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
this.entities = this.entities.map(
|
this.loaded = [];
|
||||||
function(apiEntity) {
|
|
||||||
|
|
||||||
if (apiEntity instanceof GameLib.API.Entity) {
|
this.dependencies = {};
|
||||||
return new GameLib.Entity(
|
|
||||||
this.graphics,
|
|
||||||
apiEntity
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
console.warn('Entity not of type API.Entity');
|
|
||||||
throw new Error('Entity not of type API.Entity');
|
|
||||||
}
|
|
||||||
|
|
||||||
}.bind(this)
|
this.subscriptions = [];
|
||||||
);
|
|
||||||
|
|
||||||
// this.systems = this.systems.map(
|
|
||||||
// function(apiSystem) {
|
|
||||||
//
|
|
||||||
// if (apiSystem instanceof GameLib.API.System) {
|
|
||||||
// return new GameLib.System(
|
|
||||||
// this.graphics,
|
|
||||||
// apiSystem
|
|
||||||
// )
|
|
||||||
// } else {
|
|
||||||
// console.warn('System not of type API.System');
|
|
||||||
// throw new Error('System not of type API.System');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }.bind(this)
|
|
||||||
// );
|
|
||||||
|
|
||||||
this.buildIdToObject();
|
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
|
||||||
|
|
||||||
this.registerCallbacks();
|
this.registerCallbacks();
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.EntityManager.prototype = Object.create(GameLib.API.EntityManager.prototype);
|
GameLib.EntityManager.prototype = Object.create(GameLib.Component.prototype);
|
||||||
GameLib.EntityManager.prototype.constructor = GameLib.EntityManager;
|
GameLib.EntityManager.prototype.constructor = GameLib.EntityManager;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an Entity Manager instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.EntityManager.prototype.createInstance = function() {
|
GameLib.EntityManager.prototype.createInstance = function() {
|
||||||
/**
|
return GameLib.EntityManager.Instance;
|
||||||
* Fuck the current ECS bullshit on the internet - both tiny-ecs and ecsjs SUCKS ASS
|
|
||||||
*/
|
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -303,14 +256,11 @@ GameLib.EntityManager.prototype.toApiObject = function() {
|
||||||
* @param objectEntityManager Object
|
* @param objectEntityManager Object
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.EntityManager.FromObject = function(graphics, objectEntityManager) {
|
GameLib.EntityManager.FromObject = function(objectEntityManager) {
|
||||||
|
|
||||||
var apiEntityManager = GameLib.API.EntityManager.FromObject(objectEntityManager);
|
var apiEntityManager = GameLib.API.EntityManager.FromObject(objectEntityManager);
|
||||||
|
|
||||||
var entityManager = new GameLib.EntityManager(
|
var entityManager = new GameLib.EntityManager(apiEntityManager);
|
||||||
graphics,
|
|
||||||
apiEntityManager
|
|
||||||
);
|
|
||||||
|
|
||||||
return entityManager;
|
return entityManager;
|
||||||
};
|
};
|
||||||
|
@ -428,21 +378,108 @@ GameLib.EntityManager.prototype.onParentEntityChange = function(data) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.EntityManager.prototype.componentCreated = function(data) {
|
||||||
|
|
||||||
|
console.log('component created : ' + data.component.name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we notify ourselves - ignore it
|
||||||
|
*/
|
||||||
|
if (data.component === this) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store this component into our 'loaded' list
|
||||||
|
*/
|
||||||
|
this.loaded.push(data.component);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the dependencies too
|
||||||
|
*/
|
||||||
|
data.component.dependencies.map(function(id) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(this.dependencies[id])) {
|
||||||
|
this.dependencies[id] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dependencies[id].push(data.component);
|
||||||
|
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Now find all the dependencies of this component
|
||||||
|
*/
|
||||||
|
var dependencies = this.dependencies[data.component.id];
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(dependencies)) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We have no dependencies, so mark our component as loaded and create an instance
|
||||||
|
*/
|
||||||
|
data.component.loaded = true;
|
||||||
|
data.component.instance = data.component.createInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we have none, we are done and can exit
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Otherwise, now - for each dependency - update 'idToObject' and check if its loaded
|
||||||
|
*/
|
||||||
|
dependencies.map(function(component){
|
||||||
|
component.idToObject[data.component.id] = data.component;
|
||||||
|
|
||||||
|
var loaded = true;
|
||||||
|
|
||||||
|
for (var property in component.idToObject) {
|
||||||
|
if (
|
||||||
|
component.idToObject.hasOwnProperty(property) &&
|
||||||
|
component.idToObject[property] === null
|
||||||
|
) {
|
||||||
|
loaded = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
component.loaded = loaded;
|
||||||
|
|
||||||
|
if (component.loaded) {
|
||||||
|
/**
|
||||||
|
* Our component is fully loaded, time to create an instance of it
|
||||||
|
*/
|
||||||
|
component.instance = component.createInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
GameLib.EntityManager.prototype.registerCallbacks = function() {
|
GameLib.EntityManager.prototype.registerCallbacks = function() {
|
||||||
|
|
||||||
|
this.subscriptions.push(
|
||||||
this.subscribe(
|
this.subscribe(
|
||||||
GameLib.Event.PARENT_SCENE_CHANGE,
|
GameLib.Event.PARENT_SCENE_CHANGE,
|
||||||
this.onParentSceneChange
|
this.onParentSceneChange
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.subscriptions.push(
|
||||||
this.subscribe(
|
this.subscribe(
|
||||||
GameLib.Event.PARENT_ENTITY_CHANGE,
|
GameLib.Event.PARENT_ENTITY_CHANGE,
|
||||||
this.onParentEntityChange
|
this.onParentEntityChange
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.subscriptions.push(
|
||||||
|
this.subscribe(
|
||||||
|
GameLib.Event.COMPONENT_CREATED,
|
||||||
|
this.componentCreated
|
||||||
|
)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,60 +31,14 @@ GameLib.Entity = function (
|
||||||
|
|
||||||
this.componentToCreate = 0;
|
this.componentToCreate = 0;
|
||||||
|
|
||||||
// this.components = this.components.map(
|
GameLib.Component.call(
|
||||||
//
|
this,
|
||||||
// function (apiComponent) {
|
GameLib.Component.COMPONENT_ENTITY,
|
||||||
//
|
{
|
||||||
// if (apiComponent instanceof GameLib.D3.API.PathFollowing) {
|
'components' : [GameLib.Component],
|
||||||
// return new GameLib.D3.PathFollowing(this.graphics, apiComponent);
|
'activeComponent' : GameLib.Component
|
||||||
// }
|
}
|
||||||
//
|
);
|
||||||
// if (apiComponent instanceof GameLib.D3.API.Renderer) {
|
|
||||||
// return new GameLib.D3.Renderer(this.graphics, apiComponent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (apiComponent instanceof GameLib.D3.API.RenderTarget) {
|
|
||||||
// return new GameLib.D3.RenderTarget(this.graphics, apiComponent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (apiComponent instanceof GameLib.D3.API.Pass) {
|
|
||||||
// return new GameLib.D3.Pass(this.graphics, apiComponent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (apiComponent instanceof GameLib.D3.API.Composer) {
|
|
||||||
// return new GameLib.D3.Composer(this.graphics, apiComponent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (apiComponent instanceof GameLib.D3.API.Camera) {
|
|
||||||
// return new GameLib.D3.Camera(this.graphics, apiComponent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (apiComponent instanceof GameLib.D3.API.LookAt) {
|
|
||||||
// return new GameLib.D3.LookAt(this.graphics, apiComponent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (apiComponent instanceof GameLib.D3.API.Follow) {
|
|
||||||
// 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) {
|
|
||||||
// return new GameLib.D3.Input.Drive(this.graphics, apiComponent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (apiComponent instanceof GameLib.D3.API.Spline) {
|
|
||||||
// return new GameLib.D3.Spline(this.graphics, apiComponent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return apiComponent;
|
|
||||||
//
|
|
||||||
// }.bind(this)
|
|
||||||
// );
|
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.Entity.prototype = Object.create(GameLib.API.Entity.prototype);
|
GameLib.Entity.prototype = Object.create(GameLib.API.Entity.prototype);
|
||||||
|
|
|
@ -25,20 +25,17 @@ GameLib.System = function(
|
||||||
apiSystem.id,
|
apiSystem.id,
|
||||||
apiSystem.name,
|
apiSystem.name,
|
||||||
apiSystem.systemType,
|
apiSystem.systemType,
|
||||||
apiSystem.entityManager,
|
|
||||||
apiSystem.parentEntity
|
apiSystem.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.entityManager instanceof GameLib.API.EntityManager) {
|
|
||||||
this.entityManager = new GameLib.EntityManager(
|
|
||||||
this.graphics,
|
|
||||||
this.entityManager
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.saveCallback = null;
|
this.saveCallback = null;
|
||||||
this.loadCallback = null;
|
this.loadCallback = null;
|
||||||
|
|
||||||
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_SYSTEM
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.prototype = Object.create(GameLib.API.System.prototype);
|
GameLib.System.prototype = Object.create(GameLib.API.System.prototype);
|
||||||
|
@ -52,6 +49,10 @@ GameLib.System.SYSTEM_TYPE_STORAGE = 0x8;
|
||||||
GameLib.System.SYSTEM_TYPE_GUI = 0x10;
|
GameLib.System.SYSTEM_TYPE_GUI = 0x10;
|
||||||
GameLib.System.SYSTEM_TYPE_ALL = 0xFFFF;
|
GameLib.System.SYSTEM_TYPE_ALL = 0xFFFF;
|
||||||
|
|
||||||
|
GameLib.System.prototype.createInstance = function() {
|
||||||
|
console.log('GameLib.System.prototype.createInstance();');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @callback
|
* @callback
|
||||||
* @override
|
* @override
|
||||||
|
@ -63,16 +64,16 @@ GameLib.System.prototype.start = function() {
|
||||||
/**
|
/**
|
||||||
* Hookup all editor input capabilities
|
* Hookup all editor input capabilities
|
||||||
*/
|
*/
|
||||||
var entities = this.entityManager.query([GameLib.D3.Input.Editor]);
|
var entities = GameLib.EntityManager.Instance.query([GameLib.D3.Input.Editor]);
|
||||||
|
|
||||||
entities.map(function(entity){
|
entities.map(function(entity){
|
||||||
|
|
||||||
var component = entity.getFirstComponent(GameLib.D3.Input.Editor);
|
var component = entity.getFirstComponent(GameLib.D3.Input.Editor);
|
||||||
|
|
||||||
component.mouseDown = component.onMouseDown(entity, this.entityManager).bind(component);
|
component.mouseDown = component.onMouseDown(entity, GameLib.EntityManager.Instance).bind(component);
|
||||||
component.mouseMove = component.onMouseMove(entity).bind(component);
|
component.mouseMove = component.onMouseMove(entity).bind(component);
|
||||||
component.keyDown = component.onKeyDown(entity, this.entityManager).bind(component);
|
component.keyDown = component.onKeyDown(entity, GameLib.EntityManager.Instance).bind(component);
|
||||||
component.keyUp = component.onKeyUp(entity, this.entityManager).bind(component);
|
component.keyUp = component.onKeyUp(entity, GameLib.EntityManager.Instance).bind(component);
|
||||||
|
|
||||||
component.domElement.instance.addEventListener('mousedown', component.mouseDown, false);
|
component.domElement.instance.addEventListener('mousedown', component.mouseDown, false);
|
||||||
component.domElement.instance.addEventListener('mousemove', component.mouseMove, false);
|
component.domElement.instance.addEventListener('mousemove', component.mouseMove, false);
|
||||||
|
@ -129,7 +130,7 @@ GameLib.System.prototype.start = function() {
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_RENDER) {
|
if (this.systemType === GameLib.System.SYSTEM_TYPE_RENDER) {
|
||||||
|
|
||||||
this.renderEntities = this.entityManager.query(
|
this.renderEntities = GameLib.EntityManager.Instance.query(
|
||||||
[
|
[
|
||||||
GameLib.D3.Viewport,
|
GameLib.D3.Viewport,
|
||||||
GameLib.D3.Scene,
|
GameLib.D3.Scene,
|
||||||
|
@ -149,7 +150,7 @@ GameLib.System.prototype.start = function() {
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_GUI) {
|
if (this.systemType === GameLib.System.SYSTEM_TYPE_GUI) {
|
||||||
|
|
||||||
var guis = this.entityManager.queryComponents(GameLib.GUI);
|
var guis = GameLib.EntityManager.Instance.queryComponents(GameLib.GUI);
|
||||||
|
|
||||||
guis.map(function(gui){
|
guis.map(function(gui){
|
||||||
gui.domElement.instance.parentElement.appendChild(gui.instance.domElement);
|
gui.domElement.instance.parentElement.appendChild(gui.instance.domElement);
|
||||||
|
@ -158,12 +159,12 @@ GameLib.System.prototype.start = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
|
if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
|
||||||
// this.pathFollowingObjects = this.entityManager.query([GameLib.D3.PathFollowing]);
|
// this.pathFollowingObjects = GameLib.EntityManager.Instance.query([GameLib.D3.PathFollowing]);
|
||||||
// this.followObjects = this.entityManager.query([GameLib.D3.Follow]);
|
// this.followObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Follow]);
|
||||||
// this.meshObjects = this.entityManager.query([GameLib.D3.Mesh]);
|
// this.meshObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Mesh]);
|
||||||
// this.lookAtObjects = this.entityManager.query([GameLib.D3.LookAt]);
|
// this.lookAtObjects = GameLib.EntityManager.Instance.query([GameLib.D3.LookAt]);
|
||||||
// this.cameraObjects = this.entityManager.query([GameLib.D3.Camera]);
|
// this.cameraObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Camera]);
|
||||||
// this.lightObjects = this.entityManager.query([GameLib.D3.Light]);
|
// this.lightObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Light]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_STORAGE) {
|
if (this.systemType === GameLib.System.SYSTEM_TYPE_STORAGE) {
|
||||||
|
@ -312,7 +313,7 @@ GameLib.System.prototype.stop = function() {
|
||||||
/**
|
/**
|
||||||
* Now remove all editor input capabilities
|
* Now remove all editor input capabilities
|
||||||
*/
|
*/
|
||||||
var entities = this.entityManager.query([GameLib.D3.Input.Editor]);
|
var entities = GameLib.EntityManager.Instance.query([GameLib.D3.Input.Editor]);
|
||||||
|
|
||||||
entities.map(function(entity){
|
entities.map(function(entity){
|
||||||
var component = entity.getFirstComponent(GameLib.D3.Input.Editor);
|
var component = entity.getFirstComponent(GameLib.D3.Input.Editor);
|
||||||
|
@ -330,7 +331,7 @@ GameLib.System.prototype.stop = function() {
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_GUI) {
|
if (this.systemType === GameLib.System.SYSTEM_TYPE_GUI) {
|
||||||
console.log('stopping GUI system');
|
console.log('stopping GUI system');
|
||||||
var guis = this.entityManager.queryComponents(GameLib.GUI);
|
var guis = GameLib.EntityManager.Instance.queryComponents(GameLib.GUI);
|
||||||
|
|
||||||
guis.map(function(gui){
|
guis.map(function(gui){
|
||||||
gui.domElement.instance.parentElement.removeChild(gui.instance.domElement);
|
gui.domElement.instance.parentElement.removeChild(gui.instance.domElement);
|
||||||
|
@ -383,7 +384,6 @@ GameLib.System.prototype.toApiObject = function() {
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
this.systemType,
|
this.systemType,
|
||||||
GameLib.Utils.IdOrNull(this.entityManager),
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
|
||||||
|
GameLib.EntityManager.Instance = new GameLib.EntityManager();
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = GameLib;
|
module.exports = GameLib;
|
||||||
}
|
}
|
Loading…
Reference in New Issue