* @function LevelRenderer.Animation.Animator.prototype.start * @description 开始执行动画 * @param {(string|function)} easing - 动画缓动函数。详见: 。 * @returns {LevelRenderer.Animation.Animator} Animator
(easing)
| 447 | * @returns {LevelRenderer.Animation.Animator} Animator |
| 448 | */ |
| 449 | start(easing) { |
| 450 | var self = this; |
| 451 | var setter = this._setter; |
| 452 | var getter = this._getter; |
| 453 | var onFrameListLen = self._onframeList.length; |
| 454 | var useSpline = easing === 'spline'; |
| 455 | |
| 456 | var ondestroy = function () { |
| 457 | self._clipCount--; |
| 458 | if (self._clipCount === 0) { |
| 459 | // Clear all tracks |
| 460 | self._tracks = {}; |
| 461 | |
| 462 | var len = self._doneList.length; |
| 463 | for (var i = 0; i < len; i++) { |
| 464 | self._doneList[i].call(self); |
| 465 | } |
| 466 | } |
| 467 | }; |
| 468 | |
| 469 | var createTrackClip = function (keyframes, propName) { |
| 470 | var trackLen = keyframes.length; |
| 471 | if (!trackLen) { |
| 472 | return; |
| 473 | } |
| 474 | // Guess data type |
| 475 | var firstVal = keyframes[0].value; |
| 476 | var isValueArray = Animation._isArrayLike(firstVal); |
| 477 | var isValueColor = false; |
| 478 | |
| 479 | // For vertices morphing |
| 480 | var arrDim = ( |
| 481 | isValueArray |
| 482 | && Animation._isArrayLike(firstVal[0]) |
| 483 | ) |
| 484 | ? 2 : 1; |
| 485 | // Sort keyframe as ascending |
| 486 | keyframes.sort(function (a, b) { |
| 487 | return a.time - b.time; |
| 488 | }); |
| 489 | var trackMaxTime = keyframes[trackLen - 1].time; |
| 490 | // Percents of each keyframe |
| 491 | var kfPercents = []; |
| 492 | // Value of each keyframe |
| 493 | var kfValues = []; |
| 494 | for (let i = 0; i < trackLen; i++) { |
| 495 | kfPercents.push(keyframes[i].time / trackMaxTime); |
| 496 | // Assume value is a color when it is a string |
| 497 | var value = keyframes[i].value; |
| 498 | if (typeof(value) == 'string') { |
| 499 | value = SUtil.Util_color.toArray(value); |
| 500 | if (value.length === 0) { // Invalid color |
| 501 | value[0] = value[1] = value[2] = 0; |
| 502 | value[3] = 1; |
| 503 | } |
| 504 | isValueColor = true; |
| 505 | } |
| 506 | kfValues.push(value); |
no test coverage detected