multiple viewports (finally) - start with clone

beta.r3js.org
-=yb4f310 2017-06-05 12:00:54 +02:00
parent 8d481843fd
commit a676543121
4 changed files with 56 additions and 26 deletions

View File

@ -221,3 +221,15 @@ GameLib.Component.prototype.linkObjects = function(idToObject) {
}
}
};
GameLib.Component.prototype.clone = function() {
var apiObject = this.toApiObject();
apiObject.id = GameLib.Utils.RandomId();
apiObject.name = apiObject.name + ' Clone (' + apiObject.id + ')';
//TODO - create runtime object - add to parent entity -
//var object = apiObject.
};

View File

@ -380,6 +380,12 @@ GameLib.EntityManager.prototype.onParentSceneChange = function(data) {
}
};
GameLib.EntityManager.prototype.onParentEntityChange = function(data) {
data.originalEntity.removeComponent(data.object);
data.newEntity.addComponent(data.object);
};
/**
*
*/
@ -388,7 +394,12 @@ GameLib.EntityManager.prototype.registerCallbacks = function() {
this.subscribe(
GameLib.Event.PARENT_SCENE_CHANGE,
this.onParentSceneChange
)
);
this.subscribe(
GameLib.Event.PARENT_ENTITY_CHANGE,
this.onParentEntityChange
);
};

View File

@ -843,7 +843,6 @@ GameLib.GUI.prototype.buildEntitySelectionControlFromArray = function(
folder.add(object, property, options).name(property).listen().onChange(
function(entityManager) {
return function(value) {
GameLib.Event.Emit(
GameLib.Event.PARENT_ENTITY_CHANGE,
{
@ -852,7 +851,6 @@ GameLib.GUI.prototype.buildEntitySelectionControlFromArray = function(
object : object
}
);
};
}(entityManager)
);

View File

@ -229,7 +229,21 @@ GameLib.System.prototype.update = function(deltaTime) {
var renderer = renderEntity.getFirstComponent(GameLib.D3.Renderer);
var camera = renderEntity.getFirstComponent(GameLib.D3.Camera);
var viewport = renderEntity.getFirstComponent(GameLib.D3.Viewport);
var viewports = renderEntity.getComponents(GameLib.D3.Viewport);
var scenes = renderEntity.getComponents(GameLib.D3.Scene);
if (viewports.length > 1) {
renderer.instance.autoClear = false;
}
if (scenes.length > 1) {
renderer.instance.autoClear = false;
}
renderer.instance.clear();
viewports.map(
function(viewport){
renderer.instance.setViewport(
viewport.x * renderer.width,
@ -238,14 +252,6 @@ GameLib.System.prototype.update = function(deltaTime) {
viewport.height * renderer.height
);
var scenes = renderEntity.getComponents(GameLib.D3.Scene);
if (scenes.length > 1) {
renderer.instance.autoClear = false;
}
renderer.instance.clear();
scenes.map(function(scene){
if (scene.activeCamera) {
@ -261,6 +267,9 @@ GameLib.System.prototype.update = function(deltaTime) {
}
});
}
);
stats.instance.end();
}