From a8c8ef507de8a83676e7b72f16d4d590a4b53c44 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Wed, 17 Jan 2018 15:28:37 +0100 Subject: [PATCH] parentCanvas update instance --- src/game-lib-d3-light.js | 4 ++++ src/game-lib-d3-mesh-0.js | 4 ++++ src/game-lib-d3-text.js | 22 +++++++++++++++++++++- src/game-lib-system-gui.js | 1 + src/game-lib-system-linking.js | 1 - 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/game-lib-d3-light.js b/src/game-lib-d3-light.js index 21c77df..12e3045 100644 --- a/src/game-lib-d3-light.js +++ b/src/game-lib-d3-light.js @@ -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 + */ }; /** diff --git a/src/game-lib-d3-mesh-0.js b/src/game-lib-d3-mesh-0.js index 6c83667..6ce0272 100644 --- a/src/game-lib-d3-mesh-0.js +++ b/src/game-lib-d3-mesh-0.js @@ -623,6 +623,10 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) { this.createHelper(); } + /** + * 'parentScene' is handled by LinkingSystem + */ + }; /** diff --git a/src/game-lib-d3-text.js b/src/game-lib-d3-text.js index 9a3f844..1ae62a1 100644 --- a/src/game-lib-d3-text.js +++ b/src/game-lib-d3-text.js @@ -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'); + } + } + }; /** diff --git a/src/game-lib-system-gui.js b/src/game-lib-system-gui.js index fff5f95..f35d5b7 100644 --- a/src/game-lib-system-gui.js +++ b/src/game-lib-system-gui.js @@ -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( diff --git a/src/game-lib-system-linking.js b/src/game-lib-system-linking.js index 0d875df..3b139b7 100644 --- a/src/game-lib-system-linking.js +++ b/src/game-lib-system-linking.js @@ -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); }