entities have renderers, sometimes

beta.r3js.org
-=yb4f310 2017-12-30 19:49:04 +01:00
parent 9c73e39298
commit e8ee24a12a
3 changed files with 20 additions and 75 deletions

View File

@ -3,16 +3,16 @@
* @param id
* @param name
* @param components GameLib.Component[]
* @param renderer
* @param parentEntity GameLib.Entity
* @param parentEntityManager
* @constructor
*/
GameLib.API.Entity = function(
id,
name,
components,
parentEntity,
parentEntityManager
renderer,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
@ -29,18 +29,16 @@ GameLib.API.Entity = function(
}
this.components = components;
if (GameLib.Utils.UndefinedOrNull(renderer)) {
renderer = null;
}
this.renderer = renderer;
GameLib.API.Component.call(
this,
GameLib.Component.ENTITY,
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(parentEntityManager)) {
parentEntityManager = null;
}
this.parentEntityManager = parentEntityManager;
this.activeComponent = null;
};
GameLib.API.Entity.prototype = Object.create(GameLib.Component.prototype);
@ -56,7 +54,7 @@ GameLib.API.Entity.FromObject = function(objectEntity) {
objectEntity.id,
objectEntity.name,
objectEntity.components,
objectEntity.parentEntity,
objectEntity.parentEntityManager
objectEntity.renderer,
objectEntity.parentEntity
)
};

View File

@ -19,15 +19,15 @@ GameLib.Entity = function (
apiEntity.id,
apiEntity.name,
apiEntity.components,
apiEntity.parentEntity,
apiEntity.parentEntityManager
apiEntity.renderer,
apiEntity.parentEntity
);
GameLib.Component.call(
this,
{
'components' : [GameLib.Component],
'activeComponent' : GameLib.Component
'renderer' : GameLib.D3.Renderer
}
);
};
@ -195,8 +195,8 @@ GameLib.Entity.prototype.toApiObject = function() {
this.id,
this.name,
apiComponents,
GameLib.Utils.IdOrNull(this.parentEntity),
GameLib.Utils.IdOrNull(this.parentEntityManager)
GameLib.Utils.IdOrNull(this.renderer),
GameLib.Utils.IdOrNull(this.parentEntity)
);
};
@ -204,11 +204,10 @@ GameLib.Entity.prototype.toApiObject = function() {
/**
* Entity from Object
* @param objectEntity Object
* @param parentEntityManager GameLib.D3.EntityManager
* @returns {GameLib.Entity}
* @constructor
*/
GameLib.Entity.FromObject = function(objectEntity, parentEntityManager) {
GameLib.Entity.FromObject = function(objectEntity) {
var apiEntity = GameLib.API.Entity.FromObject(objectEntity);
@ -216,11 +215,7 @@ GameLib.Entity.FromObject = function(objectEntity, parentEntityManager) {
apiEntity
);
if (GameLib.Utils.UndefinedOrNull(parentEntityManager)) {
return entity;
}
parentEntityManager.addEntity(entity);
GameLib.EntityManager.Instance.addEntity(entity);
return entity;
};

View File

@ -244,11 +244,6 @@ GameLib.System.GUI.prototype.start = function() {
this.meshDeslected
);
this.newEntitySubscription = this.subscribe(
GameLib.Event.NEW_ENTITY,
this.newEntity
);
this.componentRemovedSubscription = this.subscribe(
GameLib.Event.REMOVE_COMPONENT,
this.removeComponent
@ -452,7 +447,7 @@ GameLib.System.GUI.prototype.buildVectorControl = function(folder, componentTemp
};
/**
* Builds an Entity Selection control
* Builds a Paren Selection control
* @param folder
* @param componentTemplate
* @param property
@ -1869,10 +1864,7 @@ GameLib.System.GUI.prototype.buildGUI = function(data) {
}
if (
templateProperty === 'parentEntity' ||
templateProperty === 'parentPhysicsWorld' ||
templateProperty === 'parentMesh' ||
templateProperty === 'parentScene'
templateProperty.indexOf('parent') === 0
) {
this.buildParentSelectionControl(folder, componentTemplate, templateProperty);
continue;
@ -1919,42 +1911,7 @@ GameLib.System.GUI.prototype.buildGUI = function(data) {
}
this.buildControl(folder, componentTemplate, templateProperty);
// if (
// component.linkedObjects &&
// component.linkedObjects[property]
// ) {
// if (property === 'parentEntity') {
// this.buildEntitySelectionControlFromArray(
// folder,
// component,
// property,
// entityManager
// )
// } else if (component.linkedObjects[property] instanceof Array) {
// this.buildArrayManager(
// folder,
// component,
// property,
// component.linkedObjects[property],
// entityManager
// )
// } else {
// this.buildSelectControl(folder, component, property, entityManager, component.linkedObjects[property]);
// }
//
// } else if (typeof (component[property]) === 'object') {
//
// if (this.isColor(component[property])) {
// this.buildControl(folder, component, property);
// } else {
// //console.log('ignored: ' + property);
// }
// } else {
// this.buildControl(folder, component, property, entityManager);
// }
}
}
}
}.bind(this)
);
@ -1987,11 +1944,6 @@ GameLib.System.GUI.prototype.removeComponent = function(data) {
};
GameLib.System.GUI.prototype.newEntity = function(data) {
};
GameLib.System.GUI.prototype.castSourceChanged = function(data) {
this.buildGUI(null);
};