@awayjs/graphics
Version:
AwayJS graphics classes
152 lines (151 loc) • 5.39 kB
JavaScript
import { __extends } from "tslib";
import { AssetBase, AbstractMethodError } from '@awayjs/core';
import { AnimationSetError } from '../errors/AnimationSetError';
/**
* Provides an abstract base class for data set classes that hold animation data for use in animator classes.
*
* @see away.animators.AnimatorBase
*/
var AnimationSetBase = /** @class */ (function (_super) {
__extends(AnimationSetBase, _super);
function AnimationSetBase() {
var _this = _super.call(this) || this;
_this._animations = new Array();
_this._animationNames = new Array();
_this._animationDictionary = new Object();
return _this;
}
/**
* Retrieves a temporary GPU register that's still free.
*
* @param exclude An array of non-free temporary registers.
* @param excludeAnother An additional register that's not free.
* @return A temporary register that can be used.
*/
AnimationSetBase.prototype._pFindTempReg = function (exclude, excludeAnother) {
if (excludeAnother === void 0) { excludeAnother = null; }
var i = 0;
var reg;
while (true) {
reg = 'vt' + i;
if (exclude.indexOf(reg) == -1 && excludeAnother != reg)
return reg;
++i;
}
};
Object.defineProperty(AnimationSetBase.prototype, "usesCPU", {
/**
* Indicates whether the properties of the animation data contained within the set combined with
* the vertex registers already in use on shading materials allows the animation data to utilise
* GPU calls.
*/
get: function () {
return this._usesCPU;
},
enumerable: false,
configurable: true
});
/**
* Called by the material to reset the GPU indicator before testing whether register space in the shader
* is available for running GPU-based animation code.
*
* @private
*/
AnimationSetBase.prototype.resetGPUCompatibility = function () {
this._usesCPU = false;
};
AnimationSetBase.prototype.cancelGPUCompatibility = function () {
this._usesCPU = true;
};
/**
* @inheritDoc
*/
AnimationSetBase.prototype.getAGALVertexCode = function (shader, registerCache, sharedRegisters) {
throw new AbstractMethodError();
};
/**
* @inheritDoc
*/
AnimationSetBase.prototype.getAGALFragmentCode = function (shader, registerCache, shadedTarget) {
throw new AbstractMethodError();
};
/**
* @inheritDoc
*/
AnimationSetBase.prototype.getAGALUVCode = function (shader, registerCache, sharedRegisters) {
throw new AbstractMethodError();
};
/**
* @inheritDoc
*/
AnimationSetBase.prototype.doneAGALCode = function (shader) {
throw new AbstractMethodError();
};
Object.defineProperty(AnimationSetBase.prototype, "assetType", {
/**
* @inheritDoc
*/
get: function () {
return AnimationSetBase.assetType;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AnimationSetBase.prototype, "animations", {
/**
* Returns a vector of animation state objects that make up the contents of the animation data set.
*/
get: function () {
return this._animations;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AnimationSetBase.prototype, "animationNames", {
/**
* Returns a vector of animation state objects that make up the contents of the animation data set.
*/
get: function () {
return this._animationNames;
},
enumerable: false,
configurable: true
});
/**
* Check to determine whether a state is registered in the animation set under the given name.
*
* @param stateName The name of the animation state object to be checked.
*/
AnimationSetBase.prototype.hasAnimation = function (name) {
return this._animationDictionary[name] != null;
};
/**
* Retrieves the animation state object registered in the animation data set under the given name.
*
* @param stateName The name of the animation state object to be retrieved.
*/
AnimationSetBase.prototype.getAnimation = function (name) {
return this._animationDictionary[name];
};
/**
* Adds an animation state object to the aniamtion data set under the given name.
*
* @param stateName The name under which the animation state object will be stored.
* @param animationState The animation state object to be staored in the set.
*/
AnimationSetBase.prototype.addAnimation = function (node) {
if (this._animationDictionary[node.name])
throw new AnimationSetError('root node name \'' + node.name + '\' already exists in the set');
this._animationDictionary[node.name] = node;
this._animations.push(node);
this._animationNames.push(node.name);
};
/**
* Cleans up any resources used by the current object.
*/
AnimationSetBase.prototype.dispose = function () {
};
AnimationSetBase.assetType = '[asset AnimationSet]';
return AnimationSetBase;
}(AssetBase));
export { AnimationSetBase };