/** * Animation Component * @param id * @param name * @param rotationSpeed * @param translationSpeed * @param scaleSpeed * @param rotationFn * @param translationFn * @param scaleFn * @param blocking * @param applyToMeshWhenDone * @param parentMesh * @param parentEntity * @constructor */ GameLib.D3.API.Animation = function ( id, name, rotationSpeed, translationSpeed, scaleSpeed, rotationFn, translationFn, scaleFn, blocking, applyToMeshWhenDone, 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; if (GameLib.Utils.UndefinedOrNull(applyToMeshWhenDone)) { applyToMeshWhenDone = true; } this.applyToMeshWhenDone = applyToMeshWhenDone; 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, objectComponent.applyToMeshWhenDone, objectComponent.parentMesh, objectComponent.parentEntity ); };