@awayjs/graphics
Version:
AwayJS graphics classes
80 lines (79 loc) • 3 kB
JavaScript
import { __extends } from "tslib";
import { SkeletonClipState } from '../states/SkeletonClipState';
import { AnimationClipNodeBase } from './AnimationClipNodeBase';
/**
* A skeleton animation node containing time-based animation data as individual skeleton poses.
*/
var SkeletonClipNode = /** @class */ (function (_super) {
__extends(SkeletonClipNode, _super);
/**
* Creates a new <code>SkeletonClipNode</code> object.
*/
function SkeletonClipNode() {
var _this = _super.call(this) || this;
_this._frames = new Array();
/**
* Determines whether to use SLERP equations (true) or LERP equations (false) in the calculation
* of the output skeleton pose. Defaults to false.
*/
_this.highQuality = false;
_this._pStateClass = SkeletonClipState;
return _this;
}
Object.defineProperty(SkeletonClipNode.prototype, "frames", {
/**
* Returns a vector of skeleton poses representing the pose of each animation frame in the clip.
*/
get: function () {
return this._frames;
},
enumerable: false,
configurable: true
});
/**
* Adds a skeleton pose frame to the internal timeline of the animation node.
*
* @param skeletonPose The skeleton pose object to add to the timeline of the node.
* @param duration The specified duration of the frame in milliseconds.
*/
SkeletonClipNode.prototype.addFrame = function (skeletonPose, duration) {
this._frames.push(skeletonPose);
this._pDurations.push(duration);
this._pNumFrames = this._pDurations.length;
this._pStitchDirty = true;
};
/**
* @inheritDoc
*/
SkeletonClipNode.prototype.getAnimationState = function (animator) {
return animator.getAnimationState(this);
};
/**
* @inheritDoc
*/
SkeletonClipNode.prototype._pUpdateStitch = function () {
_super.prototype._pUpdateStitch.call(this);
var i = this._pNumFrames - 1;
var p1, p2, delta;
while (i--) {
this._pTotalDuration += this._pDurations[i];
p1 = this._frames[i].jointPoses[0].translation;
p2 = this._frames[i + 1].jointPoses[0].translation;
delta = p2.subtract(p1);
this._pTotalDelta.x += delta.x;
this._pTotalDelta.y += delta.y;
this._pTotalDelta.z += delta.z;
}
if (this._pStitchFinalFrame || !this._pLooping) {
this._pTotalDuration += this._pDurations[this._pNumFrames - 1];
p1 = this._frames[0].jointPoses[0].translation;
p2 = this._frames[1].jointPoses[0].translation;
delta = p2.subtract(p1);
this._pTotalDelta.x += delta.x;
this._pTotalDelta.y += delta.y;
this._pTotalDelta.z += delta.z;
}
};
return SkeletonClipNode;
}(AnimationClipNodeBase));
export { SkeletonClipNode };