render scenes for viewports if defined
parent
a676543121
commit
e2faf5be25
|
@ -24,11 +24,14 @@ GameLib.API.Entity = function(
|
|||
}
|
||||
this.parentEntityManager = parentEntityManager;
|
||||
|
||||
this.activeComponent = null;
|
||||
|
||||
GameLib.Component.call(
|
||||
this,
|
||||
GameLib.Component.COMPONENT_ENTITY,
|
||||
{
|
||||
'components' : [GameLib.Component]
|
||||
'components' : [GameLib.Component],
|
||||
'activeComponent' : GameLib.Component
|
||||
},
|
||||
null,
|
||||
parentEntity
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* @param height
|
||||
* @param x
|
||||
* @param y
|
||||
* @param scenes
|
||||
* @param parentEntity
|
||||
* @constructor
|
||||
*/
|
||||
|
@ -16,12 +17,15 @@ GameLib.D3.API.Viewport = function(
|
|||
height,
|
||||
x,
|
||||
y,
|
||||
scenes,
|
||||
parentEntity
|
||||
) {
|
||||
GameLib.Component.call(
|
||||
this,
|
||||
GameLib.Component.COMPONENT_VIEWPORT,
|
||||
null,
|
||||
{
|
||||
'scenes' : [GameLib.D3.Scene]
|
||||
},
|
||||
null,
|
||||
parentEntity
|
||||
);
|
||||
|
@ -55,6 +59,11 @@ GameLib.D3.API.Viewport = function(
|
|||
y = 0;
|
||||
}
|
||||
this.y = y;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(scenes)) {
|
||||
scenes = [];
|
||||
}
|
||||
this.scenes = scenes;
|
||||
};
|
||||
|
||||
GameLib.D3.API.Viewport.prototype = Object.create(GameLib.Component.prototype);
|
||||
|
@ -65,7 +74,7 @@ GameLib.D3.API.Viewport.prototype.constructor = GameLib.D3.API.Viewport;
|
|||
* @param objectViewport
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.API.Viewport.FromObjectViewport = function(objectViewport) {
|
||||
GameLib.D3.API.Viewport.FromObjectComponent = function(objectViewport) {
|
||||
return new GameLib.D3.API.Viewport(
|
||||
objectViewport.id,
|
||||
objectViewport.name,
|
||||
|
@ -73,6 +82,7 @@ GameLib.D3.API.Viewport.FromObjectViewport = function(objectViewport) {
|
|||
objectViewport.height,
|
||||
objectViewport.x,
|
||||
objectViewport.y,
|
||||
objectViewport.scenes,
|
||||
objectViewport.parentEntity
|
||||
);
|
||||
};
|
||||
|
|
|
@ -28,6 +28,7 @@ GameLib.D3.Viewport = function (
|
|||
apiViewport.height,
|
||||
apiViewport.x,
|
||||
apiViewport.y,
|
||||
apiViewport.scenes,
|
||||
apiViewport.parentEntity
|
||||
);
|
||||
|
||||
|
@ -77,6 +78,9 @@ GameLib.D3.Viewport.prototype.toApiObject = function() {
|
|||
this.height,
|
||||
this.x,
|
||||
this.y,
|
||||
this.scenes.map(function(scene){
|
||||
return GameLib.Utils.IdOrNull(scene);
|
||||
}),
|
||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||
);
|
||||
|
||||
|
|
|
@ -170,6 +170,10 @@ GameLib.Entity.prototype.hasComponent = function(constructor) {
|
|||
*/
|
||||
GameLib.Entity.prototype.removeComponent = function(component) {
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(component)) {
|
||||
component = this.activeComponent;
|
||||
}
|
||||
|
||||
component.parentEntity = null;
|
||||
|
||||
var index = this.components.indexOf(component);
|
||||
|
|
|
@ -770,6 +770,8 @@ GameLib.GUI.prototype.buildSelectControl = function(folder, object, property, en
|
|||
entityManager: entityManager
|
||||
}
|
||||
);
|
||||
|
||||
gui.build(entityManager);
|
||||
} else {
|
||||
/**
|
||||
* Old way of doing things
|
||||
|
@ -781,7 +783,7 @@ GameLib.GUI.prototype.buildSelectControl = function(folder, object, property, en
|
|||
/**
|
||||
* Properties changed - rebuild GUI
|
||||
*/
|
||||
gui.build(entityManager);
|
||||
|
||||
};
|
||||
|
||||
}(this)
|
||||
|
@ -841,8 +843,15 @@ GameLib.GUI.prototype.buildEntitySelectionControlFromArray = function(
|
|||
);
|
||||
|
||||
folder.add(object, property, options).name(property).listen().onChange(
|
||||
function(entityManager) {
|
||||
function(entityManager, gui) {
|
||||
return function(value) {
|
||||
|
||||
if (value !== 'null') {
|
||||
object[property] = entityManager.findEntityById(value);
|
||||
} else {
|
||||
object[property] = null;
|
||||
}
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.PARENT_ENTITY_CHANGE,
|
||||
{
|
||||
|
@ -851,9 +860,15 @@ GameLib.GUI.prototype.buildEntitySelectionControlFromArray = function(
|
|||
object : object
|
||||
}
|
||||
);
|
||||
|
||||
this.initialValue = entityManager.findEntityById(value);
|
||||
};
|
||||
}(entityManager)
|
||||
);
|
||||
}(entityManager, this)
|
||||
).onFinishChange(function(gui, entityManager){
|
||||
return function() {
|
||||
gui.build(entityManager);
|
||||
}
|
||||
}(this, entityManager));
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -252,8 +252,7 @@ GameLib.System.prototype.update = function(deltaTime) {
|
|||
viewport.height * renderer.height
|
||||
);
|
||||
|
||||
scenes.map(function(scene){
|
||||
|
||||
function renderScene(scene) {
|
||||
if (scene.activeCamera) {
|
||||
renderer.instance.render(
|
||||
scene.instance,
|
||||
|
@ -264,9 +263,14 @@ GameLib.System.prototype.update = function(deltaTime) {
|
|||
scene.instance,
|
||||
camera.instance
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
if (viewport.scenes && viewport.scenes.length > 0) {
|
||||
viewport.scenes.map(renderScene);
|
||||
} else {
|
||||
scenes.map(renderScene);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue