2017-09-17 19:12:45 +02:00
|
|
|
/**
|
|
|
|
* Animation Component
|
|
|
|
* @param id
|
|
|
|
* @param name
|
|
|
|
* @param rotationSpeed
|
|
|
|
* @param translationSpeed
|
|
|
|
* @param scaleSpeed
|
|
|
|
* @param rotationFn
|
|
|
|
* @param translationFn
|
|
|
|
* @param scaleFn
|
|
|
|
* @param blocking
|
2017-09-18 15:39:40 +02:00
|
|
|
* @param applyToMeshWhenDone
|
2017-09-17 19:12:45 +02:00
|
|
|
* @param parentMesh
|
|
|
|
* @param parentEntity
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.Animation = function (
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
rotationSpeed,
|
|
|
|
translationSpeed,
|
|
|
|
scaleSpeed,
|
|
|
|
rotationFn,
|
|
|
|
translationFn,
|
|
|
|
scaleFn,
|
|
|
|
blocking,
|
2017-09-18 15:39:40 +02:00
|
|
|
applyToMeshWhenDone,
|
2017-09-17 19:12:45 +02:00
|
|
|
parentMesh,
|
|
|
|
parentEntity
|
|
|
|
) {
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
|
|
id = GameLib.Utils.RandomId();
|
|
|
|
}
|
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
|
|
name = 'Animation (' + this.id + ')';
|
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(rotationSpeed)) {
|
|
|
|
rotationSpeed = 0;
|
|
|
|
}
|
|
|
|
this.rotationSpeed = rotationSpeed;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(translationSpeed)) {
|
|
|
|
translationSpeed = 0;
|
|
|
|
}
|
|
|
|
this.translationSpeed = translationSpeed;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(scaleSpeed)) {
|
|
|
|
scaleSpeed = 0;
|
|
|
|
}
|
|
|
|
this.scaleSpeed = scaleSpeed;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(rotationFn)) {
|
|
|
|
rotationFn = null;
|
|
|
|
}
|
|
|
|
this.rotationFn = rotationFn;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(translationFn)) {
|
|
|
|
translationFn = null;
|
|
|
|
}
|
|
|
|
this.translationFn = translationFn;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(scaleFn)) {
|
|
|
|
scaleFn = null;
|
|
|
|
}
|
|
|
|
this.scaleFn = scaleFn;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(blocking)) {
|
|
|
|
blocking = true;
|
|
|
|
}
|
|
|
|
this.blocking = blocking;
|
|
|
|
|
2017-09-18 15:39:40 +02:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(applyToMeshWhenDone)) {
|
|
|
|
applyToMeshWhenDone = true;
|
|
|
|
}
|
|
|
|
this.applyToMeshWhenDone = applyToMeshWhenDone;
|
|
|
|
|
2017-09-17 19:12:45 +02:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(parentMesh)) {
|
|
|
|
parentMesh = null;
|
|
|
|
}
|
|
|
|
this.parentMesh = parentMesh;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
|
|
|
parentEntity = null;
|
|
|
|
}
|
|
|
|
this.parentEntity = parentEntity;
|
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.D3.API.Animation.prototype = Object.create(GameLib.Component.prototype);
|
|
|
|
GameLib.D3.API.Animation.prototype.constructor = GameLib.D3.API.Animation;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object to GameLib.D3.API.Animation
|
|
|
|
* @param objectComponent
|
|
|
|
* @returns {GameLib.D3.API.Animation}
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.Animation.FromObject = function(objectComponent) {
|
|
|
|
return new GameLib.D3.API.Animation(
|
|
|
|
objectComponent.id,
|
|
|
|
objectComponent.name,
|
|
|
|
objectComponent.rotationSpeed,
|
|
|
|
objectComponent.translationSpeed,
|
|
|
|
objectComponent.scaleSpeed,
|
|
|
|
objectComponent.rotationFn,
|
|
|
|
objectComponent.translationFn,
|
|
|
|
objectComponent.scaleFn,
|
|
|
|
objectComponent.blocking,
|
2017-09-18 15:39:40 +02:00
|
|
|
objectComponent.applyToMeshWhenDone,
|
2017-09-17 19:12:45 +02:00
|
|
|
objectComponent.parentMesh,
|
|
|
|
objectComponent.parentEntity
|
|
|
|
);
|
|
|
|
};
|