diff --git a/src/game-lib-d3-api-z-animation.js b/src/game-lib-d3-api-z-animation.js index af0f3ce..abcec93 100644 --- a/src/game-lib-d3-api-z-animation.js +++ b/src/game-lib-d3-api-z-animation.js @@ -97,11 +97,10 @@ GameLib.D3.Animation.prototype.createInstance = function() { /** * Updates the instance with the current state */ -GameLib.D3.Animation.prototype.updateInstance = function() { +GameLib.D3.Animation.prototype.updateInstance = function(property, item) { - try { - - if (this.rotationFn) { + if (property === 'rotationFn') { + try { this.instance.rotation = new Function('data', this.rotationFn).bind(this); this.publish( GameLib.Event.ANIMATION_COMPILE_SUCCESS, @@ -110,9 +109,19 @@ GameLib.D3.Animation.prototype.updateInstance = function() { type : GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION } ) + } catch (error) { + console.error(error); + this.publish( + GameLib.Event.ANIMATION_COMPILE_FAILED, + { + component : this + } + ) } + } - if (this.translationFn) { + if (property === 'translationFn') { + try { this.instance.translation = new Function('data', this.translationFn).bind(this); this.publish( GameLib.Event.ANIMATION_COMPILE_SUCCESS, @@ -120,10 +129,20 @@ GameLib.D3.Animation.prototype.updateInstance = function() { component : this, type : GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_TRANSLATION } + ); + } catch (error) { + console.error(error); + this.publish( + GameLib.Event.ANIMATION_COMPILE_FAILED, + { + component : this + } ) } + } - if (this.scaleFn) { + if (property === 'scaleFn') { + try { this.instance.scale = new Function('data', this.scaleFn).bind(this); this.publish( GameLib.Event.ANIMATION_COMPILE_SUCCESS, @@ -132,17 +151,27 @@ GameLib.D3.Animation.prototype.updateInstance = function() { type : GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_SCALE } ) + } catch (error) { + console.error(error); + this.publish( + GameLib.Event.ANIMATION_COMPILE_FAILED, + { + component : this + } + ) } + } + + if (property === 'meshes') { + GameLib.Event.Emit( + GameLib.Event.ANIMATION_MESH_ADDED, + { + animation : this, + mesh : item + } + ) + } - } catch (error) { - console.error(error); - this.publish( - GameLib.Event.ANIMATION_COMPILE_FAILED, - { - component : this - } - ) - } }; /** diff --git a/src/game-lib-system-gui.js b/src/game-lib-system-gui.js index fb3e4dc..fff5f95 100644 --- a/src/game-lib-system-gui.js +++ b/src/game-lib-system-gui.js @@ -411,7 +411,7 @@ GameLib.System.GUI.prototype.buildQuaternionControl = function(folder, component GameLib.System.GUI.prototype.buildVectorControl = function(folder, componentTemplate, property) { - var step = 0.01; + var step = 0.00001; var object = componentTemplate.template; @@ -616,7 +616,7 @@ GameLib.System.GUI.prototype.buildArrayManagerControl = function( } ); - component.updateInstance(property); + component.updateInstance(property, activeSelection.component); // addArrayItem(activeSelection.component, component[property].length - 1); }