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