diff --git a/src/game-lib-component-offsettor.js b/src/game-lib-component-offsettor.js index 24f0663..c449854 100644 --- a/src/game-lib-component-offsettor.js +++ b/src/game-lib-component-offsettor.js @@ -4,13 +4,15 @@ * @param name * @param axis {GameLib.D3.Vector3} * @param getOffsetFunc + * @param userData * @constructor */ GameLib.D3.ComponentOffsettor = function ComponentOffsettor( id, name, axis, - getOffsetFunc + getOffsetFunc, + userData ) { this.id = id || GameLib.D3.Tools.RandomId(); @@ -21,7 +23,8 @@ GameLib.D3.ComponentOffsettor = function ComponentOffsettor( this.parentEntity = null; this.axis = axis || new GameLib.D3.Vector3(); - this.getOffsetFunc = getOffsetFunc || function(){ return 1; }; + this.getOffsetFunc = getOffsetFunc || function(entity, component, userData){ return 1; }; + this.userData = userData; GameLib.D3.Utils.Extend(GameLib.D3.ComponentOffsettor, GameLib.D3.ComponentInterface); }; @@ -46,7 +49,11 @@ GameLib.D3.ComponentOffsettor.prototype.onLateUpdate = function( parentEntity.quaternion.z, parentEntity.quaternion.w ) - ).multiplyScalar(this.getOffsetFunc()); + ).multiplyScalar(this.getOffsetFunc( + parentEntity, + this, + this.userData + )); parentEntity.position.x += pos.x; parentEntity.position.y += pos.y; diff --git a/src/game-lib-component-rotator.js b/src/game-lib-component-rotator.js index 65e1e7a..288a65f 100644 --- a/src/game-lib-component-rotator.js +++ b/src/game-lib-component-rotator.js @@ -10,7 +10,8 @@ GameLib.D3.ComponentRotator = function ComponentRotator( id, name, axis, - getRotationFunc + getRotationFunc, + userData ) { this.id = id || GameLib.D3.Tools.RandomId(); @@ -21,7 +22,8 @@ GameLib.D3.ComponentRotator = function ComponentRotator( this.parentEntity = null; this.axis = axis || new GameLib.D3.Vector3(); - this.getRotationFunc = getRotationFunc || function(){} ; + this.getRotationFunc = getRotationFunc || function(entity, component, userData){ return 1; }; + this.userData = userData; GameLib.D3.Utils.Extend(GameLib.D3.ComponentRotator, GameLib.D3.ComponentInterface); }; @@ -47,20 +49,14 @@ GameLib.D3.ComponentRotator.prototype.onLateUpdate = function( this.axis.y, this.axis.z ), - this.getRotationFunc() + this.getRotationFunc( + parentEntity, + this, + this.userData + ) ) ); - - /* var quat = new THREE.Quaternion().setFromAxisAngle( - new THREE.Vector3( - this.axis.x, - this.axis.y, - this.axis.z - ), - this.getRotationFunc() - );*/ - parentEntity.quaternion.x = quat.x; parentEntity.quaternion.y = quat.y; parentEntity.quaternion.z = quat.z;