parentCanvas update instance

beta.r3js.org
-=yb4f310 2018-01-17 15:28:37 +01:00
parent c064185fd4
commit a8c8ef507d
5 changed files with 30 additions and 2 deletions

View File

@ -222,6 +222,10 @@ GameLib.D3.Light.prototype.updateInstance = function(property) {
if (property === 'color') {
this.instance.color.set(this.color.toHex());
}
/**
* 'parentScene' is handled by LinkingSystem
*/
};
/**

View File

@ -623,6 +623,10 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) {
this.createHelper();
}
/**
* 'parentScene' is handled by LinkingSystem
*/
};
/**

View File

@ -73,7 +73,27 @@ GameLib.D3.Text.prototype.updateInstance = function(property) {
this.parentCanvas.updateInstance('texts');
}
if (property === 'parentCanvas') {
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.CANVAS).map(
function(canvas) {
var index = canvas.texts.indexOf(this);
if (index !== -1) {
canvas.texts.splice(index, 1);
canvas.texts.updateInstance('texts');
}
}.bind(this)
);
if (this.parentCanvas) {
GameLib.Utils.PushUnique(this.parentCanvas.texts, this);
this.parentCanvas.updateInstance('texts');
}
}
};
/**

View File

@ -488,6 +488,7 @@ GameLib.System.GUI.prototype.buildParentSelectionControl = function(folder, comp
function(component) {
component[property] = newComponent;
component.updateInstance(property);
if (property === 'parentEntity') {
GameLib.Event.Emit(

View File

@ -787,7 +787,6 @@ GameLib.System.Linking.prototype.onParentWorldChange = function(data) {
data.object instanceof GameLib.D3.RigidBody
) {
if (data.originalWorld instanceof GameLib.D3.PhysicsWorld) {
data.originalWorld.removeRigidBody(data.object);
}