UNPKG

@awayjs/graphics

Version:
74 lines (73 loc) 2.86 kB
import { __extends } from "tslib"; import { Vector3D } from '@awayjs/core'; import { VertexClipState } from '../states/VertexClipState'; import { AnimationClipNodeBase } from './AnimationClipNodeBase'; /** * A vertex animation node containing time-based animation data as individual geometry obejcts. */ var VertexClipNode = /** @class */ (function (_super) { __extends(VertexClipNode, _super); /** * Creates a new <code>VertexClipNode</code> object. */ function VertexClipNode() { var _this = _super.call(this) || this; _this._frames = new Array(); _this._translations = new Array(); _this._pStateClass = VertexClipState; return _this; } Object.defineProperty(VertexClipNode.prototype, "frames", { /** * Returns a vector of geometry frames representing the vertex values of each animation frame in the clip. */ get: function () { return this._frames; }, enumerable: false, configurable: true }); /** * Adds a geometry object to the internal timeline of the animation node. * * @param geometry The geometry object to add to the timeline of the node. * @param duration The specified duration of the frame in milliseconds. * @param translation The absolute translation of the frame, used in root delta calculations for sprite movement. */ VertexClipNode.prototype.addFrame = function (elements, duration, translation) { if (translation === void 0) { translation = null; } this._frames.push(elements); this._pDurations.push(duration); this._translations.push(translation || new Vector3D()); this._pNumFrames = this._pDurations.length; this._pStitchDirty = true; }; /** * @inheritDoc */ VertexClipNode.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._translations[i]; p2 = this._translations[i + 1]; delta = p2.subtract(p1); this._pTotalDelta.x += delta.x; this._pTotalDelta.y += delta.y; this._pTotalDelta.z += delta.z; } if (this._pNumFrames > 1 && (this._pStitchFinalFrame || !this._pLooping)) { this._pTotalDuration += this._pDurations[this._pNumFrames - 1]; p1 = this._translations[0]; p2 = this._translations[1]; delta = p2.subtract(p1); this._pTotalDelta.x += delta.x; this._pTotalDelta.y += delta.y; this._pTotalDelta.z += delta.z; } }; return VertexClipNode; }(AnimationClipNodeBase)); export { VertexClipNode };