diff --git a/src/game-lib-system-animation.js b/src/game-lib-system-animation.js index dd290d7..af0f34a 100644 --- a/src/game-lib-system-animation.js +++ b/src/game-lib-system-animation.js @@ -106,6 +106,15 @@ GameLib.System.Animation.prototype.instanceCreated = function(data) { this.textures[data.component.id] = data.component; this.textureIds = Object.keys(this.textures); } + + if (data.component instanceof GameLib.D3.Animation) { + this.animations[data.component.id] = data.component; + data.component.meshes.map( + function(mesh){ + this.attachAnimation(data.component, mesh) + }.bind(this) + ); + } }; GameLib.System.Animation.prototype.removeComponent = function(data) { @@ -120,6 +129,17 @@ GameLib.System.Animation.prototype.removeComponent = function(data) { this.textureIds = Object.keys(this.textures); } } + + if (data.component instanceof GameLib.D3.Animation) { + + data.component.meshes.map( + function(mesh){ + this.detachAnimation(mesh) + }.bind(this) + ); + + delete this.animations[data.component.id]; + } }; GameLib.System.Animation.prototype.textureAnimatedChange = function(data) {