changed component signature of offsettor, rotator
parent
3aca24eb87
commit
52af3c1f3d
|
@ -4,13 +4,15 @@
|
||||||
* @param name
|
* @param name
|
||||||
* @param axis {GameLib.D3.Vector3}
|
* @param axis {GameLib.D3.Vector3}
|
||||||
* @param getOffsetFunc
|
* @param getOffsetFunc
|
||||||
|
* @param userData
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.ComponentOffsettor = function ComponentOffsettor(
|
GameLib.D3.ComponentOffsettor = function ComponentOffsettor(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
axis,
|
axis,
|
||||||
getOffsetFunc
|
getOffsetFunc,
|
||||||
|
userData
|
||||||
) {
|
) {
|
||||||
this.id = id || GameLib.D3.Tools.RandomId();
|
this.id = id || GameLib.D3.Tools.RandomId();
|
||||||
|
|
||||||
|
@ -21,7 +23,8 @@ GameLib.D3.ComponentOffsettor = function ComponentOffsettor(
|
||||||
this.parentEntity = null;
|
this.parentEntity = null;
|
||||||
|
|
||||||
this.axis = axis || new GameLib.D3.Vector3();
|
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);
|
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.z,
|
||||||
parentEntity.quaternion.w
|
parentEntity.quaternion.w
|
||||||
)
|
)
|
||||||
).multiplyScalar(this.getOffsetFunc());
|
).multiplyScalar(this.getOffsetFunc(
|
||||||
|
parentEntity,
|
||||||
|
this,
|
||||||
|
this.userData
|
||||||
|
));
|
||||||
|
|
||||||
parentEntity.position.x += pos.x;
|
parentEntity.position.x += pos.x;
|
||||||
parentEntity.position.y += pos.y;
|
parentEntity.position.y += pos.y;
|
||||||
|
|
|
@ -10,7 +10,8 @@ GameLib.D3.ComponentRotator = function ComponentRotator(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
axis,
|
axis,
|
||||||
getRotationFunc
|
getRotationFunc,
|
||||||
|
userData
|
||||||
) {
|
) {
|
||||||
this.id = id || GameLib.D3.Tools.RandomId();
|
this.id = id || GameLib.D3.Tools.RandomId();
|
||||||
|
|
||||||
|
@ -21,7 +22,8 @@ GameLib.D3.ComponentRotator = function ComponentRotator(
|
||||||
this.parentEntity = null;
|
this.parentEntity = null;
|
||||||
|
|
||||||
this.axis = axis || new GameLib.D3.Vector3();
|
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);
|
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.y,
|
||||||
this.axis.z
|
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.x = quat.x;
|
||||||
parentEntity.quaternion.y = quat.y;
|
parentEntity.quaternion.y = quat.y;
|
||||||
parentEntity.quaternion.z = quat.z;
|
parentEntity.quaternion.z = quat.z;
|
||||||
|
|
Loading…
Reference in New Issue