first commit
This commit is contained in:
28
node_modules/lottie-web/player/js/utils/expressions/CompInterface.js
generated
vendored
Normal file
28
node_modules/lottie-web/player/js/utils/expressions/CompInterface.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
const CompExpressionInterface = (function () {
|
||||
return function (comp) {
|
||||
function _thisLayerFunction(name) {
|
||||
var i = 0;
|
||||
var len = comp.layers.length;
|
||||
while (i < len) {
|
||||
if (comp.layers[i].nm === name || comp.layers[i].ind === name) {
|
||||
return comp.elements[i].layerInterface;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return null;
|
||||
// return {active:false};
|
||||
}
|
||||
Object.defineProperty(_thisLayerFunction, '_name', { value: comp.data.nm });
|
||||
_thisLayerFunction.layer = _thisLayerFunction;
|
||||
_thisLayerFunction.pixelAspect = 1;
|
||||
_thisLayerFunction.height = comp.data.h || comp.globalData.compSize.h;
|
||||
_thisLayerFunction.width = comp.data.w || comp.globalData.compSize.w;
|
||||
_thisLayerFunction.pixelAspect = 1;
|
||||
_thisLayerFunction.frameDuration = 1 / comp.globalData.frameRate;
|
||||
_thisLayerFunction.displayStartTime = 0;
|
||||
_thisLayerFunction.numLayers = comp.layers.length;
|
||||
return _thisLayerFunction;
|
||||
};
|
||||
}());
|
||||
|
||||
export default CompExpressionInterface;
|
111
node_modules/lottie-web/player/js/utils/expressions/EffectInterface.js
generated
vendored
Normal file
111
node_modules/lottie-web/player/js/utils/expressions/EffectInterface.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
import ExpressionPropertyInterface from './ExpressionValueFactory';
|
||||
import propertyGroupFactory from './PropertyGroupFactory';
|
||||
import PropertyInterface from './PropertyInterface';
|
||||
|
||||
const EffectsExpressionInterface = (function () {
|
||||
var ob = {
|
||||
createEffectsInterface: createEffectsInterface,
|
||||
};
|
||||
|
||||
function createEffectsInterface(elem, propertyGroup) {
|
||||
if (elem.effectsManager) {
|
||||
var effectElements = [];
|
||||
var effectsData = elem.data.ef;
|
||||
var i;
|
||||
var len = elem.effectsManager.effectElements.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
effectElements.push(createGroupInterface(effectsData[i], elem.effectsManager.effectElements[i], propertyGroup, elem));
|
||||
}
|
||||
|
||||
var effects = elem.data.ef || [];
|
||||
var groupInterface = function (name) {
|
||||
i = 0;
|
||||
len = effects.length;
|
||||
while (i < len) {
|
||||
if (name === effects[i].nm || name === effects[i].mn || name === effects[i].ix) {
|
||||
return effectElements[i];
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Object.defineProperty(groupInterface, 'numProperties', {
|
||||
get: function () {
|
||||
return effects.length;
|
||||
},
|
||||
});
|
||||
return groupInterface;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function createGroupInterface(data, elements, propertyGroup, elem) {
|
||||
function groupInterface(name) {
|
||||
var effects = data.ef;
|
||||
var i = 0;
|
||||
var len = effects.length;
|
||||
while (i < len) {
|
||||
if (name === effects[i].nm || name === effects[i].mn || name === effects[i].ix) {
|
||||
if (effects[i].ty === 5) {
|
||||
return effectElements[i];
|
||||
}
|
||||
return effectElements[i]();
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
throw new Error();
|
||||
}
|
||||
var _propertyGroup = propertyGroupFactory(groupInterface, propertyGroup);
|
||||
|
||||
var effectElements = [];
|
||||
var i;
|
||||
var len = data.ef.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
if (data.ef[i].ty === 5) {
|
||||
effectElements.push(createGroupInterface(data.ef[i], elements.effectElements[i], elements.effectElements[i].propertyGroup, elem));
|
||||
} else {
|
||||
effectElements.push(createValueInterface(elements.effectElements[i], data.ef[i].ty, elem, _propertyGroup));
|
||||
}
|
||||
}
|
||||
|
||||
if (data.mn === 'ADBE Color Control') {
|
||||
Object.defineProperty(groupInterface, 'color', {
|
||||
get: function () {
|
||||
return effectElements[0]();
|
||||
},
|
||||
});
|
||||
}
|
||||
Object.defineProperties(groupInterface, {
|
||||
numProperties: {
|
||||
get: function () {
|
||||
return data.np;
|
||||
},
|
||||
},
|
||||
_name: { value: data.nm },
|
||||
propertyGroup: { value: _propertyGroup },
|
||||
});
|
||||
groupInterface.enabled = data.en !== 0;
|
||||
groupInterface.active = groupInterface.enabled;
|
||||
return groupInterface;
|
||||
}
|
||||
|
||||
function createValueInterface(element, type, elem, propertyGroup) {
|
||||
var expressionProperty = ExpressionPropertyInterface(element.p);
|
||||
function interfaceFunction() {
|
||||
if (type === 10) {
|
||||
return elem.comp.compInterface(element.p.v);
|
||||
}
|
||||
return expressionProperty();
|
||||
}
|
||||
|
||||
if (element.p.setGroupProperty) {
|
||||
element.p.setGroupProperty(PropertyInterface('', propertyGroup));
|
||||
}
|
||||
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
return ob;
|
||||
}());
|
||||
|
||||
export default EffectsExpressionInterface;
|
751
node_modules/lottie-web/player/js/utils/expressions/ExpressionManager.js
generated
vendored
Normal file
751
node_modules/lottie-web/player/js/utils/expressions/ExpressionManager.js
generated
vendored
Normal file
@@ -0,0 +1,751 @@
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
import {
|
||||
degToRads,
|
||||
BMMath,
|
||||
} from '../common';
|
||||
import {
|
||||
createTypedArray,
|
||||
} from '../helpers/arrays';
|
||||
import BezierFactory from '../../3rd_party/BezierEaser';
|
||||
import shapePool from '../pooling/shape_pool';
|
||||
import seedrandom from '../../3rd_party/seedrandom';
|
||||
import propTypes from '../helpers/propTypes';
|
||||
|
||||
const ExpressionManager = (function () {
|
||||
'use strict';
|
||||
|
||||
var ob = {};
|
||||
var Math = BMMath;
|
||||
var window = null;
|
||||
var document = null;
|
||||
var XMLHttpRequest = null;
|
||||
var fetch = null;
|
||||
var frames = null;
|
||||
var _lottieGlobal = {};
|
||||
seedrandom(BMMath);
|
||||
|
||||
function resetFrame() {
|
||||
_lottieGlobal = {};
|
||||
}
|
||||
|
||||
function $bm_isInstanceOfArray(arr) {
|
||||
return arr.constructor === Array || arr.constructor === Float32Array;
|
||||
}
|
||||
|
||||
function isNumerable(tOfV, v) {
|
||||
return tOfV === 'number' || v instanceof Number || tOfV === 'boolean' || tOfV === 'string';
|
||||
}
|
||||
|
||||
function $bm_neg(a) {
|
||||
var tOfA = typeof a;
|
||||
if (tOfA === 'number' || a instanceof Number || tOfA === 'boolean') {
|
||||
return -a;
|
||||
}
|
||||
if ($bm_isInstanceOfArray(a)) {
|
||||
var i;
|
||||
var lenA = a.length;
|
||||
var retArr = [];
|
||||
for (i = 0; i < lenA; i += 1) {
|
||||
retArr[i] = -a[i];
|
||||
}
|
||||
return retArr;
|
||||
}
|
||||
if (a.propType) {
|
||||
return a.v;
|
||||
}
|
||||
return -a;
|
||||
}
|
||||
|
||||
var easeInBez = BezierFactory.getBezierEasing(0.333, 0, 0.833, 0.833, 'easeIn').get;
|
||||
var easeOutBez = BezierFactory.getBezierEasing(0.167, 0.167, 0.667, 1, 'easeOut').get;
|
||||
var easeInOutBez = BezierFactory.getBezierEasing(0.33, 0, 0.667, 1, 'easeInOut').get;
|
||||
|
||||
function sum(a, b) {
|
||||
var tOfA = typeof a;
|
||||
var tOfB = typeof b;
|
||||
if ((isNumerable(tOfA, a) && isNumerable(tOfB, b)) || tOfA === 'string' || tOfB === 'string') {
|
||||
return a + b;
|
||||
}
|
||||
if ($bm_isInstanceOfArray(a) && isNumerable(tOfB, b)) {
|
||||
a = a.slice(0);
|
||||
a[0] += b;
|
||||
return a;
|
||||
}
|
||||
if (isNumerable(tOfA, a) && $bm_isInstanceOfArray(b)) {
|
||||
b = b.slice(0);
|
||||
b[0] = a + b[0];
|
||||
return b;
|
||||
}
|
||||
if ($bm_isInstanceOfArray(a) && $bm_isInstanceOfArray(b)) {
|
||||
var i = 0;
|
||||
var lenA = a.length;
|
||||
var lenB = b.length;
|
||||
var retArr = [];
|
||||
while (i < lenA || i < lenB) {
|
||||
if ((typeof a[i] === 'number' || a[i] instanceof Number) && (typeof b[i] === 'number' || b[i] instanceof Number)) {
|
||||
retArr[i] = a[i] + b[i];
|
||||
} else {
|
||||
retArr[i] = b[i] === undefined ? a[i] : a[i] || b[i];
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return retArr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
var add = sum;
|
||||
|
||||
function sub(a, b) {
|
||||
var tOfA = typeof a;
|
||||
var tOfB = typeof b;
|
||||
if (isNumerable(tOfA, a) && isNumerable(tOfB, b)) {
|
||||
if (tOfA === 'string') {
|
||||
a = parseInt(a, 10);
|
||||
}
|
||||
if (tOfB === 'string') {
|
||||
b = parseInt(b, 10);
|
||||
}
|
||||
return a - b;
|
||||
}
|
||||
if ($bm_isInstanceOfArray(a) && isNumerable(tOfB, b)) {
|
||||
a = a.slice(0);
|
||||
a[0] -= b;
|
||||
return a;
|
||||
}
|
||||
if (isNumerable(tOfA, a) && $bm_isInstanceOfArray(b)) {
|
||||
b = b.slice(0);
|
||||
b[0] = a - b[0];
|
||||
return b;
|
||||
}
|
||||
if ($bm_isInstanceOfArray(a) && $bm_isInstanceOfArray(b)) {
|
||||
var i = 0;
|
||||
var lenA = a.length;
|
||||
var lenB = b.length;
|
||||
var retArr = [];
|
||||
while (i < lenA || i < lenB) {
|
||||
if ((typeof a[i] === 'number' || a[i] instanceof Number) && (typeof b[i] === 'number' || b[i] instanceof Number)) {
|
||||
retArr[i] = a[i] - b[i];
|
||||
} else {
|
||||
retArr[i] = b[i] === undefined ? a[i] : a[i] || b[i];
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return retArr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function mul(a, b) {
|
||||
var tOfA = typeof a;
|
||||
var tOfB = typeof b;
|
||||
var arr;
|
||||
if (isNumerable(tOfA, a) && isNumerable(tOfB, b)) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
var i;
|
||||
var len;
|
||||
if ($bm_isInstanceOfArray(a) && isNumerable(tOfB, b)) {
|
||||
len = a.length;
|
||||
arr = createTypedArray('float32', len);
|
||||
for (i = 0; i < len; i += 1) {
|
||||
arr[i] = a[i] * b;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
if (isNumerable(tOfA, a) && $bm_isInstanceOfArray(b)) {
|
||||
len = b.length;
|
||||
arr = createTypedArray('float32', len);
|
||||
for (i = 0; i < len; i += 1) {
|
||||
arr[i] = a * b[i];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function div(a, b) {
|
||||
var tOfA = typeof a;
|
||||
var tOfB = typeof b;
|
||||
var arr;
|
||||
if (isNumerable(tOfA, a) && isNumerable(tOfB, b)) {
|
||||
return a / b;
|
||||
}
|
||||
var i;
|
||||
var len;
|
||||
if ($bm_isInstanceOfArray(a) && isNumerable(tOfB, b)) {
|
||||
len = a.length;
|
||||
arr = createTypedArray('float32', len);
|
||||
for (i = 0; i < len; i += 1) {
|
||||
arr[i] = a[i] / b;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
if (isNumerable(tOfA, a) && $bm_isInstanceOfArray(b)) {
|
||||
len = b.length;
|
||||
arr = createTypedArray('float32', len);
|
||||
for (i = 0; i < len; i += 1) {
|
||||
arr[i] = a / b[i];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function mod(a, b) {
|
||||
if (typeof a === 'string') {
|
||||
a = parseInt(a, 10);
|
||||
}
|
||||
if (typeof b === 'string') {
|
||||
b = parseInt(b, 10);
|
||||
}
|
||||
return a % b;
|
||||
}
|
||||
var $bm_sum = sum;
|
||||
var $bm_sub = sub;
|
||||
var $bm_mul = mul;
|
||||
var $bm_div = div;
|
||||
var $bm_mod = mod;
|
||||
|
||||
function clamp(num, min, max) {
|
||||
if (min > max) {
|
||||
var mm = max;
|
||||
max = min;
|
||||
min = mm;
|
||||
}
|
||||
return Math.min(Math.max(num, min), max);
|
||||
}
|
||||
|
||||
function radiansToDegrees(val) {
|
||||
return val / degToRads;
|
||||
}
|
||||
var radians_to_degrees = radiansToDegrees;
|
||||
|
||||
function degreesToRadians(val) {
|
||||
return val * degToRads;
|
||||
}
|
||||
var degrees_to_radians = radiansToDegrees;
|
||||
|
||||
var helperLengthArray = [0, 0, 0, 0, 0, 0];
|
||||
|
||||
function length(arr1, arr2) {
|
||||
if (typeof arr1 === 'number' || arr1 instanceof Number) {
|
||||
arr2 = arr2 || 0;
|
||||
return Math.abs(arr1 - arr2);
|
||||
}
|
||||
if (!arr2) {
|
||||
arr2 = helperLengthArray;
|
||||
}
|
||||
var i;
|
||||
var len = Math.min(arr1.length, arr2.length);
|
||||
var addedLength = 0;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
addedLength += Math.pow(arr2[i] - arr1[i], 2);
|
||||
}
|
||||
return Math.sqrt(addedLength);
|
||||
}
|
||||
|
||||
function normalize(vec) {
|
||||
return div(vec, length(vec));
|
||||
}
|
||||
|
||||
function rgbToHsl(val) {
|
||||
var r = val[0]; var g = val[1]; var b = val[2];
|
||||
var max = Math.max(r, g, b);
|
||||
var min = Math.min(r, g, b);
|
||||
var h;
|
||||
var s;
|
||||
var l = (max + min) / 2;
|
||||
|
||||
if (max === min) {
|
||||
h = 0; // achromatic
|
||||
s = 0; // achromatic
|
||||
} else {
|
||||
var d = max - min;
|
||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||
switch (max) {
|
||||
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||
case g: h = (b - r) / d + 2; break;
|
||||
case b: h = (r - g) / d + 4; break;
|
||||
default: break;
|
||||
}
|
||||
h /= 6;
|
||||
}
|
||||
|
||||
return [h, s, l, val[3]];
|
||||
}
|
||||
|
||||
function hue2rgb(p, q, t) {
|
||||
if (t < 0) t += 1;
|
||||
if (t > 1) t -= 1;
|
||||
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
||||
if (t < 1 / 2) return q;
|
||||
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
||||
return p;
|
||||
}
|
||||
|
||||
function hslToRgb(val) {
|
||||
var h = val[0];
|
||||
var s = val[1];
|
||||
var l = val[2];
|
||||
|
||||
var r;
|
||||
var g;
|
||||
var b;
|
||||
|
||||
if (s === 0) {
|
||||
r = l; // achromatic
|
||||
b = l; // achromatic
|
||||
g = l; // achromatic
|
||||
} else {
|
||||
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
||||
var p = 2 * l - q;
|
||||
r = hue2rgb(p, q, h + 1 / 3);
|
||||
g = hue2rgb(p, q, h);
|
||||
b = hue2rgb(p, q, h - 1 / 3);
|
||||
}
|
||||
|
||||
return [r, g, b, val[3]];
|
||||
}
|
||||
|
||||
function linear(t, tMin, tMax, value1, value2) {
|
||||
if (value1 === undefined || value2 === undefined) {
|
||||
value1 = tMin;
|
||||
value2 = tMax;
|
||||
tMin = 0;
|
||||
tMax = 1;
|
||||
}
|
||||
if (tMax < tMin) {
|
||||
var _tMin = tMax;
|
||||
tMax = tMin;
|
||||
tMin = _tMin;
|
||||
}
|
||||
if (t <= tMin) {
|
||||
return value1;
|
||||
} if (t >= tMax) {
|
||||
return value2;
|
||||
}
|
||||
var perc = tMax === tMin ? 0 : (t - tMin) / (tMax - tMin);
|
||||
if (!value1.length) {
|
||||
return value1 + (value2 - value1) * perc;
|
||||
}
|
||||
var i;
|
||||
var len = value1.length;
|
||||
var arr = createTypedArray('float32', len);
|
||||
for (i = 0; i < len; i += 1) {
|
||||
arr[i] = value1[i] + (value2[i] - value1[i]) * perc;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
function random(min, max) {
|
||||
if (max === undefined) {
|
||||
if (min === undefined) {
|
||||
min = 0;
|
||||
max = 1;
|
||||
} else {
|
||||
max = min;
|
||||
min = undefined;
|
||||
}
|
||||
}
|
||||
if (max.length) {
|
||||
var i;
|
||||
var len = max.length;
|
||||
if (!min) {
|
||||
min = createTypedArray('float32', len);
|
||||
}
|
||||
var arr = createTypedArray('float32', len);
|
||||
var rnd = BMMath.random();
|
||||
for (i = 0; i < len; i += 1) {
|
||||
arr[i] = min[i] + rnd * (max[i] - min[i]);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
if (min === undefined) {
|
||||
min = 0;
|
||||
}
|
||||
var rndm = BMMath.random();
|
||||
return min + rndm * (max - min);
|
||||
}
|
||||
|
||||
function createPath(points, inTangents, outTangents, closed) {
|
||||
var i;
|
||||
var len = points.length;
|
||||
var path = shapePool.newElement();
|
||||
path.setPathData(!!closed, len);
|
||||
var arrPlaceholder = [0, 0];
|
||||
var inVertexPoint;
|
||||
var outVertexPoint;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
inVertexPoint = (inTangents && inTangents[i]) ? inTangents[i] : arrPlaceholder;
|
||||
outVertexPoint = (outTangents && outTangents[i]) ? outTangents[i] : arrPlaceholder;
|
||||
path.setTripleAt(points[i][0], points[i][1], outVertexPoint[0] + points[i][0], outVertexPoint[1] + points[i][1], inVertexPoint[0] + points[i][0], inVertexPoint[1] + points[i][1], i, true);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
function initiateExpression(elem, data, property) {
|
||||
// Bail out if we don't want expressions
|
||||
function noOp(_value) {
|
||||
return _value;
|
||||
}
|
||||
if (!elem.globalData.renderConfig.runExpressions) {
|
||||
return noOp;
|
||||
}
|
||||
|
||||
var val = data.x;
|
||||
var needsVelocity = /velocity(?![\w\d])/.test(val);
|
||||
var _needsRandom = val.indexOf('random') !== -1;
|
||||
var elemType = elem.data.ty;
|
||||
var transform;
|
||||
var $bm_transform;
|
||||
var content;
|
||||
var effect;
|
||||
var thisProperty = property;
|
||||
thisProperty.valueAtTime = thisProperty.getValueAtTime;
|
||||
Object.defineProperty(thisProperty, 'value', {
|
||||
get: function () {
|
||||
return thisProperty.v;
|
||||
},
|
||||
});
|
||||
elem.comp.frameDuration = 1 / elem.comp.globalData.frameRate;
|
||||
elem.comp.displayStartTime = 0;
|
||||
var inPoint = elem.data.ip / elem.comp.globalData.frameRate;
|
||||
var outPoint = elem.data.op / elem.comp.globalData.frameRate;
|
||||
var width = elem.data.sw ? elem.data.sw : 0;
|
||||
var height = elem.data.sh ? elem.data.sh : 0;
|
||||
var name = elem.data.nm;
|
||||
var loopIn;
|
||||
var loop_in;
|
||||
var loopOut;
|
||||
var loop_out;
|
||||
var smooth;
|
||||
var toWorld;
|
||||
var fromWorld;
|
||||
var fromComp;
|
||||
var toComp;
|
||||
var fromCompToSurface;
|
||||
var position;
|
||||
var rotation;
|
||||
var anchorPoint;
|
||||
var scale;
|
||||
var thisLayer;
|
||||
var thisComp;
|
||||
var mask;
|
||||
var valueAtTime;
|
||||
var velocityAtTime;
|
||||
|
||||
var scoped_bm_rt;
|
||||
// val = val.replace(/(\\?"|')((http)(s)?(:\/))?\/.*?(\\?"|')/g, "\"\""); // deter potential network calls
|
||||
var expression_function = eval('[function _expression_function(){' + val + ';scoped_bm_rt=$bm_rt}]')[0]; // eslint-disable-line no-eval
|
||||
var numKeys = property.kf ? data.k.length : 0;
|
||||
|
||||
var active = !this.data || this.data.hd !== true;
|
||||
|
||||
var wiggle = function wiggle(freq, amp) {
|
||||
var iWiggle;
|
||||
var j;
|
||||
var lenWiggle = this.pv.length ? this.pv.length : 1;
|
||||
var addedAmps = createTypedArray('float32', lenWiggle);
|
||||
freq = 5;
|
||||
var iterations = Math.floor(time * freq);
|
||||
iWiggle = 0;
|
||||
j = 0;
|
||||
while (iWiggle < iterations) {
|
||||
// var rnd = BMMath.random();
|
||||
for (j = 0; j < lenWiggle; j += 1) {
|
||||
addedAmps[j] += -amp + amp * 2 * BMMath.random();
|
||||
// addedAmps[j] += -amp + amp*2*rnd;
|
||||
}
|
||||
iWiggle += 1;
|
||||
}
|
||||
// var rnd2 = BMMath.random();
|
||||
var periods = time * freq;
|
||||
var perc = periods - Math.floor(periods);
|
||||
var arr = createTypedArray('float32', lenWiggle);
|
||||
if (lenWiggle > 1) {
|
||||
for (j = 0; j < lenWiggle; j += 1) {
|
||||
arr[j] = this.pv[j] + addedAmps[j] + (-amp + amp * 2 * BMMath.random()) * perc;
|
||||
// arr[j] = this.pv[j] + addedAmps[j] + (-amp + amp*2*rnd)*perc;
|
||||
// arr[i] = this.pv[i] + addedAmp + amp1*perc + amp2*(1-perc);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
return this.pv + addedAmps[0] + (-amp + amp * 2 * BMMath.random()) * perc;
|
||||
}.bind(this);
|
||||
|
||||
if (thisProperty.loopIn) {
|
||||
loopIn = thisProperty.loopIn.bind(thisProperty);
|
||||
loop_in = loopIn;
|
||||
}
|
||||
|
||||
if (thisProperty.loopOut) {
|
||||
loopOut = thisProperty.loopOut.bind(thisProperty);
|
||||
loop_out = loopOut;
|
||||
}
|
||||
|
||||
if (thisProperty.smooth) {
|
||||
smooth = thisProperty.smooth.bind(thisProperty);
|
||||
}
|
||||
|
||||
function loopInDuration(type, duration) {
|
||||
return loopIn(type, duration, true);
|
||||
}
|
||||
|
||||
function loopOutDuration(type, duration) {
|
||||
return loopOut(type, duration, true);
|
||||
}
|
||||
|
||||
if (this.getValueAtTime) {
|
||||
valueAtTime = this.getValueAtTime.bind(this);
|
||||
}
|
||||
|
||||
if (this.getVelocityAtTime) {
|
||||
velocityAtTime = this.getVelocityAtTime.bind(this);
|
||||
}
|
||||
|
||||
var comp = elem.comp.globalData.projectInterface.bind(elem.comp.globalData.projectInterface);
|
||||
|
||||
function lookAt(elem1, elem2) {
|
||||
var fVec = [elem2[0] - elem1[0], elem2[1] - elem1[1], elem2[2] - elem1[2]];
|
||||
var pitch = Math.atan2(fVec[0], Math.sqrt(fVec[1] * fVec[1] + fVec[2] * fVec[2])) / degToRads;
|
||||
var yaw = -Math.atan2(fVec[1], fVec[2]) / degToRads;
|
||||
return [yaw, pitch, 0];
|
||||
}
|
||||
|
||||
function easeOut(t, tMin, tMax, val1, val2) {
|
||||
return applyEase(easeOutBez, t, tMin, tMax, val1, val2);
|
||||
}
|
||||
|
||||
function easeIn(t, tMin, tMax, val1, val2) {
|
||||
return applyEase(easeInBez, t, tMin, tMax, val1, val2);
|
||||
}
|
||||
|
||||
function ease(t, tMin, tMax, val1, val2) {
|
||||
return applyEase(easeInOutBez, t, tMin, tMax, val1, val2);
|
||||
}
|
||||
|
||||
function applyEase(fn, t, tMin, tMax, val1, val2) {
|
||||
if (val1 === undefined) {
|
||||
val1 = tMin;
|
||||
val2 = tMax;
|
||||
} else {
|
||||
t = (t - tMin) / (tMax - tMin);
|
||||
}
|
||||
if (t > 1) {
|
||||
t = 1;
|
||||
} else if (t < 0) {
|
||||
t = 0;
|
||||
}
|
||||
var mult = fn(t);
|
||||
if ($bm_isInstanceOfArray(val1)) {
|
||||
var iKey;
|
||||
var lenKey = val1.length;
|
||||
var arr = createTypedArray('float32', lenKey);
|
||||
for (iKey = 0; iKey < lenKey; iKey += 1) {
|
||||
arr[iKey] = (val2[iKey] - val1[iKey]) * mult + val1[iKey];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
return (val2 - val1) * mult + val1;
|
||||
}
|
||||
|
||||
function nearestKey(time) {
|
||||
var iKey;
|
||||
var lenKey = data.k.length;
|
||||
var index;
|
||||
var keyTime;
|
||||
if (!data.k.length || typeof (data.k[0]) === 'number') {
|
||||
index = 0;
|
||||
keyTime = 0;
|
||||
} else {
|
||||
index = -1;
|
||||
time *= elem.comp.globalData.frameRate;
|
||||
if (time < data.k[0].t) {
|
||||
index = 1;
|
||||
keyTime = data.k[0].t;
|
||||
} else {
|
||||
for (iKey = 0; iKey < lenKey - 1; iKey += 1) {
|
||||
if (time === data.k[iKey].t) {
|
||||
index = iKey + 1;
|
||||
keyTime = data.k[iKey].t;
|
||||
break;
|
||||
} else if (time > data.k[iKey].t && time < data.k[iKey + 1].t) {
|
||||
if (time - data.k[iKey].t > data.k[iKey + 1].t - time) {
|
||||
index = iKey + 2;
|
||||
keyTime = data.k[iKey + 1].t;
|
||||
} else {
|
||||
index = iKey + 1;
|
||||
keyTime = data.k[iKey].t;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index === -1) {
|
||||
index = iKey + 1;
|
||||
keyTime = data.k[iKey].t;
|
||||
}
|
||||
}
|
||||
}
|
||||
var obKey = {};
|
||||
obKey.index = index;
|
||||
obKey.time = keyTime / elem.comp.globalData.frameRate;
|
||||
return obKey;
|
||||
}
|
||||
|
||||
function key(ind) {
|
||||
var obKey;
|
||||
var iKey;
|
||||
var lenKey;
|
||||
if (!data.k.length || typeof (data.k[0]) === 'number') {
|
||||
throw new Error('The property has no keyframe at index ' + ind);
|
||||
}
|
||||
ind -= 1;
|
||||
obKey = {
|
||||
time: data.k[ind].t / elem.comp.globalData.frameRate,
|
||||
value: [],
|
||||
};
|
||||
var arr = Object.prototype.hasOwnProperty.call(data.k[ind], 's') ? data.k[ind].s : data.k[ind - 1].e;
|
||||
|
||||
lenKey = arr.length;
|
||||
for (iKey = 0; iKey < lenKey; iKey += 1) {
|
||||
obKey[iKey] = arr[iKey];
|
||||
obKey.value[iKey] = arr[iKey];
|
||||
}
|
||||
return obKey;
|
||||
}
|
||||
|
||||
function framesToTime(fr, fps) {
|
||||
if (!fps) {
|
||||
fps = elem.comp.globalData.frameRate;
|
||||
}
|
||||
return fr / fps;
|
||||
}
|
||||
|
||||
function timeToFrames(t, fps) {
|
||||
if (!t && t !== 0) {
|
||||
t = time;
|
||||
}
|
||||
if (!fps) {
|
||||
fps = elem.comp.globalData.frameRate;
|
||||
}
|
||||
return t * fps;
|
||||
}
|
||||
|
||||
function seedRandom(seed) {
|
||||
BMMath.seedrandom(randSeed + seed);
|
||||
}
|
||||
|
||||
function sourceRectAtTime() {
|
||||
return elem.sourceRectAtTime();
|
||||
}
|
||||
|
||||
function substring(init, end) {
|
||||
if (typeof value === 'string') {
|
||||
if (end === undefined) {
|
||||
return value.substring(init);
|
||||
}
|
||||
return value.substring(init, end);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function substr(init, end) {
|
||||
if (typeof value === 'string') {
|
||||
if (end === undefined) {
|
||||
return value.substr(init);
|
||||
}
|
||||
return value.substr(init, end);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function posterizeTime(framesPerSecond) {
|
||||
time = framesPerSecond === 0 ? 0 : Math.floor(time * framesPerSecond) / framesPerSecond;
|
||||
value = valueAtTime(time);
|
||||
}
|
||||
|
||||
var time;
|
||||
var velocity;
|
||||
var value;
|
||||
var text;
|
||||
var textIndex;
|
||||
var textTotal;
|
||||
var selectorValue;
|
||||
var index = elem.data.ind;
|
||||
var hasParent = !!(elem.hierarchy && elem.hierarchy.length);
|
||||
var parent;
|
||||
var randSeed = Math.floor(Math.random() * 1000000);
|
||||
var globalData = elem.globalData;
|
||||
|
||||
function executeExpression(_value) {
|
||||
// globalData.pushExpression();
|
||||
value = _value;
|
||||
if (this.frameExpressionId === elem.globalData.frameId && this.propType !== 'textSelector') {
|
||||
return value;
|
||||
}
|
||||
if (this.propType === 'textSelector') {
|
||||
textIndex = this.textIndex;
|
||||
textTotal = this.textTotal;
|
||||
selectorValue = this.selectorValue;
|
||||
}
|
||||
if (!thisLayer) {
|
||||
text = elem.layerInterface.text;
|
||||
thisLayer = elem.layerInterface;
|
||||
thisComp = elem.comp.compInterface;
|
||||
toWorld = thisLayer.toWorld.bind(thisLayer);
|
||||
fromWorld = thisLayer.fromWorld.bind(thisLayer);
|
||||
fromComp = thisLayer.fromComp.bind(thisLayer);
|
||||
toComp = thisLayer.toComp.bind(thisLayer);
|
||||
mask = thisLayer.mask ? thisLayer.mask.bind(thisLayer) : null;
|
||||
fromCompToSurface = fromComp;
|
||||
}
|
||||
if (!transform) {
|
||||
transform = elem.layerInterface('ADBE Transform Group');
|
||||
$bm_transform = transform;
|
||||
if (transform) {
|
||||
anchorPoint = transform.anchorPoint;
|
||||
/* position = transform.position;
|
||||
rotation = transform.rotation;
|
||||
scale = transform.scale; */
|
||||
}
|
||||
}
|
||||
|
||||
if (elemType === 4 && !content) {
|
||||
content = thisLayer('ADBE Root Vectors Group');
|
||||
}
|
||||
if (!effect) {
|
||||
effect = thisLayer(4);
|
||||
}
|
||||
hasParent = !!(elem.hierarchy && elem.hierarchy.length);
|
||||
if (hasParent && !parent) {
|
||||
parent = elem.hierarchy[0].layerInterface;
|
||||
}
|
||||
time = this.comp.renderedFrame / this.comp.globalData.frameRate;
|
||||
if (_needsRandom) {
|
||||
seedRandom(randSeed + time);
|
||||
}
|
||||
if (needsVelocity) {
|
||||
velocity = velocityAtTime(time);
|
||||
}
|
||||
expression_function();
|
||||
this.frameExpressionId = elem.globalData.frameId;
|
||||
|
||||
// TODO: Check if it's possible to return on ShapeInterface the .v value
|
||||
// Changed this to a ternary operation because Rollup failed compiling it correctly
|
||||
scoped_bm_rt = scoped_bm_rt.propType === propTypes.SHAPE
|
||||
? scoped_bm_rt.v
|
||||
: scoped_bm_rt;
|
||||
return scoped_bm_rt;
|
||||
}
|
||||
// Bundlers will see these as dead code and unless we reference them
|
||||
executeExpression.__preventDeadCodeRemoval = [$bm_transform, anchorPoint, time, velocity, inPoint, outPoint, width, height, name, loop_in, loop_out, smooth, toComp, fromCompToSurface, toWorld, fromWorld, mask, position, rotation, scale, thisComp, numKeys, active, wiggle, loopInDuration, loopOutDuration, comp, lookAt, easeOut, easeIn, ease, nearestKey, key, text, textIndex, textTotal, selectorValue, framesToTime, timeToFrames, sourceRectAtTime, substring, substr, posterizeTime, index, globalData];
|
||||
return executeExpression;
|
||||
}
|
||||
|
||||
ob.initiateExpression = initiateExpression;
|
||||
ob.__preventDeadCodeRemoval = [window, document, XMLHttpRequest, fetch, frames, $bm_neg, add, $bm_sum, $bm_sub, $bm_mul, $bm_div, $bm_mod, clamp, radians_to_degrees, degreesToRadians, degrees_to_radians, normalize, rgbToHsl, hslToRgb, linear, random, createPath, _lottieGlobal];
|
||||
ob.resetFrame = resetFrame;
|
||||
return ob;
|
||||
}());
|
||||
|
||||
export default ExpressionManager;
|
463
node_modules/lottie-web/player/js/utils/expressions/ExpressionPropertyDecorator.js
generated
vendored
Normal file
463
node_modules/lottie-web/player/js/utils/expressions/ExpressionPropertyDecorator.js
generated
vendored
Normal file
@@ -0,0 +1,463 @@
|
||||
import {
|
||||
extendPrototype,
|
||||
} from '../functionExtensions';
|
||||
import {
|
||||
createSizedArray,
|
||||
createTypedArray,
|
||||
} from '../helpers/arrays';
|
||||
import ShapePropertyFactory from '../shapes/ShapeProperty';
|
||||
import PropertyFactory from '../PropertyFactory';
|
||||
import shapePool from '../pooling/shape_pool';
|
||||
import {
|
||||
initialDefaultFrame,
|
||||
} from '../../main';
|
||||
import bez from '../bez';
|
||||
import Matrix from '../../3rd_party/transformation-matrix';
|
||||
import TransformPropertyFactory from '../TransformProperty';
|
||||
import expressionHelpers from './expressionHelpers';
|
||||
import ExpressionManager from './ExpressionManager';
|
||||
|
||||
function addPropertyDecorator() {
|
||||
function loopOut(type, duration, durationFlag) {
|
||||
if (!this.k || !this.keyframes) {
|
||||
return this.pv;
|
||||
}
|
||||
type = type ? type.toLowerCase() : '';
|
||||
var currentFrame = this.comp.renderedFrame;
|
||||
var keyframes = this.keyframes;
|
||||
var lastKeyFrame = keyframes[keyframes.length - 1].t;
|
||||
if (currentFrame <= lastKeyFrame) {
|
||||
return this.pv;
|
||||
}
|
||||
var cycleDuration;
|
||||
var firstKeyFrame;
|
||||
if (!durationFlag) {
|
||||
if (!duration || duration > keyframes.length - 1) {
|
||||
duration = keyframes.length - 1;
|
||||
}
|
||||
firstKeyFrame = keyframes[keyframes.length - 1 - duration].t;
|
||||
cycleDuration = lastKeyFrame - firstKeyFrame;
|
||||
} else {
|
||||
if (!duration) {
|
||||
cycleDuration = Math.max(0, lastKeyFrame - this.elem.data.ip);
|
||||
} else {
|
||||
cycleDuration = Math.abs(lastKeyFrame - this.elem.comp.globalData.frameRate * duration);
|
||||
}
|
||||
firstKeyFrame = lastKeyFrame - cycleDuration;
|
||||
}
|
||||
var i;
|
||||
var len;
|
||||
var ret;
|
||||
if (type === 'pingpong') {
|
||||
var iterations = Math.floor((currentFrame - firstKeyFrame) / cycleDuration);
|
||||
if (iterations % 2 !== 0) {
|
||||
return this.getValueAtTime(((cycleDuration - (currentFrame - firstKeyFrame) % cycleDuration + firstKeyFrame)) / this.comp.globalData.frameRate, 0); // eslint-disable-line
|
||||
}
|
||||
} else if (type === 'offset') {
|
||||
var initV = this.getValueAtTime(firstKeyFrame / this.comp.globalData.frameRate, 0);
|
||||
var endV = this.getValueAtTime(lastKeyFrame / this.comp.globalData.frameRate, 0);
|
||||
var current = this.getValueAtTime(((currentFrame - firstKeyFrame) % cycleDuration + firstKeyFrame) / this.comp.globalData.frameRate, 0); // eslint-disable-line
|
||||
var repeats = Math.floor((currentFrame - firstKeyFrame) / cycleDuration);
|
||||
if (this.pv.length) {
|
||||
ret = new Array(initV.length);
|
||||
len = ret.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
ret[i] = (endV[i] - initV[i]) * repeats + current[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return (endV - initV) * repeats + current;
|
||||
} else if (type === 'continue') {
|
||||
var lastValue = this.getValueAtTime(lastKeyFrame / this.comp.globalData.frameRate, 0);
|
||||
var nextLastValue = this.getValueAtTime((lastKeyFrame - 0.001) / this.comp.globalData.frameRate, 0);
|
||||
if (this.pv.length) {
|
||||
ret = new Array(lastValue.length);
|
||||
len = ret.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
ret[i] = lastValue[i] + (lastValue[i] - nextLastValue[i]) * ((currentFrame - lastKeyFrame) / this.comp.globalData.frameRate) / 0.0005; // eslint-disable-line
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return lastValue + (lastValue - nextLastValue) * (((currentFrame - lastKeyFrame)) / 0.001);
|
||||
}
|
||||
return this.getValueAtTime((((currentFrame - firstKeyFrame) % cycleDuration + firstKeyFrame)) / this.comp.globalData.frameRate, 0); // eslint-disable-line
|
||||
|
||||
}
|
||||
|
||||
function loopIn(type, duration, durationFlag) {
|
||||
if (!this.k) {
|
||||
return this.pv;
|
||||
}
|
||||
type = type ? type.toLowerCase() : '';
|
||||
var currentFrame = this.comp.renderedFrame;
|
||||
var keyframes = this.keyframes;
|
||||
var firstKeyFrame = keyframes[0].t;
|
||||
if (currentFrame >= firstKeyFrame) {
|
||||
return this.pv;
|
||||
}
|
||||
var cycleDuration;
|
||||
var lastKeyFrame;
|
||||
if (!durationFlag) {
|
||||
if (!duration || duration > keyframes.length - 1) {
|
||||
duration = keyframes.length - 1;
|
||||
}
|
||||
lastKeyFrame = keyframes[duration].t;
|
||||
cycleDuration = lastKeyFrame - firstKeyFrame;
|
||||
} else {
|
||||
if (!duration) {
|
||||
cycleDuration = Math.max(0, this.elem.data.op - firstKeyFrame);
|
||||
} else {
|
||||
cycleDuration = Math.abs(this.elem.comp.globalData.frameRate * duration);
|
||||
}
|
||||
lastKeyFrame = firstKeyFrame + cycleDuration;
|
||||
}
|
||||
var i;
|
||||
var len;
|
||||
var ret;
|
||||
if (type === 'pingpong') {
|
||||
var iterations = Math.floor((firstKeyFrame - currentFrame) / cycleDuration);
|
||||
if (iterations % 2 === 0) {
|
||||
return this.getValueAtTime((((firstKeyFrame - currentFrame) % cycleDuration + firstKeyFrame)) / this.comp.globalData.frameRate, 0); // eslint-disable-line
|
||||
}
|
||||
} else if (type === 'offset') {
|
||||
var initV = this.getValueAtTime(firstKeyFrame / this.comp.globalData.frameRate, 0);
|
||||
var endV = this.getValueAtTime(lastKeyFrame / this.comp.globalData.frameRate, 0);
|
||||
var current = this.getValueAtTime((cycleDuration - ((firstKeyFrame - currentFrame) % cycleDuration) + firstKeyFrame) / this.comp.globalData.frameRate, 0);
|
||||
var repeats = Math.floor((firstKeyFrame - currentFrame) / cycleDuration) + 1;
|
||||
if (this.pv.length) {
|
||||
ret = new Array(initV.length);
|
||||
len = ret.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
ret[i] = current[i] - (endV[i] - initV[i]) * repeats;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return current - (endV - initV) * repeats;
|
||||
} else if (type === 'continue') {
|
||||
var firstValue = this.getValueAtTime(firstKeyFrame / this.comp.globalData.frameRate, 0);
|
||||
var nextFirstValue = this.getValueAtTime((firstKeyFrame + 0.001) / this.comp.globalData.frameRate, 0);
|
||||
if (this.pv.length) {
|
||||
ret = new Array(firstValue.length);
|
||||
len = ret.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
ret[i] = firstValue[i] + ((firstValue[i] - nextFirstValue[i]) * (firstKeyFrame - currentFrame)) / 0.001;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return firstValue + ((firstValue - nextFirstValue) * (firstKeyFrame - currentFrame)) / 0.001;
|
||||
}
|
||||
return this.getValueAtTime(((cycleDuration - ((firstKeyFrame - currentFrame) % cycleDuration + firstKeyFrame))) / this.comp.globalData.frameRate, 0); // eslint-disable-line
|
||||
|
||||
}
|
||||
|
||||
function smooth(width, samples) {
|
||||
if (!this.k) {
|
||||
return this.pv;
|
||||
}
|
||||
width = (width || 0.4) * 0.5;
|
||||
samples = Math.floor(samples || 5);
|
||||
if (samples <= 1) {
|
||||
return this.pv;
|
||||
}
|
||||
var currentTime = this.comp.renderedFrame / this.comp.globalData.frameRate;
|
||||
var initFrame = currentTime - width;
|
||||
var endFrame = currentTime + width;
|
||||
var sampleFrequency = samples > 1 ? (endFrame - initFrame) / (samples - 1) : 1;
|
||||
var i = 0;
|
||||
var j = 0;
|
||||
var value;
|
||||
if (this.pv.length) {
|
||||
value = createTypedArray('float32', this.pv.length);
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
var sampleValue;
|
||||
while (i < samples) {
|
||||
sampleValue = this.getValueAtTime(initFrame + i * sampleFrequency);
|
||||
if (this.pv.length) {
|
||||
for (j = 0; j < this.pv.length; j += 1) {
|
||||
value[j] += sampleValue[j];
|
||||
}
|
||||
} else {
|
||||
value += sampleValue;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if (this.pv.length) {
|
||||
for (j = 0; j < this.pv.length; j += 1) {
|
||||
value[j] /= samples;
|
||||
}
|
||||
} else {
|
||||
value /= samples;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function getTransformValueAtTime(time) {
|
||||
if (!this._transformCachingAtTime) {
|
||||
this._transformCachingAtTime = {
|
||||
v: new Matrix(),
|
||||
};
|
||||
}
|
||||
/// /
|
||||
var matrix = this._transformCachingAtTime.v;
|
||||
matrix.cloneFromProps(this.pre.props);
|
||||
if (this.appliedTransformations < 1) {
|
||||
var anchor = this.a.getValueAtTime(time);
|
||||
matrix.translate(
|
||||
-anchor[0] * this.a.mult,
|
||||
-anchor[1] * this.a.mult,
|
||||
anchor[2] * this.a.mult
|
||||
);
|
||||
}
|
||||
if (this.appliedTransformations < 2) {
|
||||
var scale = this.s.getValueAtTime(time);
|
||||
matrix.scale(
|
||||
scale[0] * this.s.mult,
|
||||
scale[1] * this.s.mult,
|
||||
scale[2] * this.s.mult
|
||||
);
|
||||
}
|
||||
if (this.sk && this.appliedTransformations < 3) {
|
||||
var skew = this.sk.getValueAtTime(time);
|
||||
var skewAxis = this.sa.getValueAtTime(time);
|
||||
matrix.skewFromAxis(-skew * this.sk.mult, skewAxis * this.sa.mult);
|
||||
}
|
||||
if (this.r && this.appliedTransformations < 4) {
|
||||
var rotation = this.r.getValueAtTime(time);
|
||||
matrix.rotate(-rotation * this.r.mult);
|
||||
} else if (!this.r && this.appliedTransformations < 4) {
|
||||
var rotationZ = this.rz.getValueAtTime(time);
|
||||
var rotationY = this.ry.getValueAtTime(time);
|
||||
var rotationX = this.rx.getValueAtTime(time);
|
||||
var orientation = this.or.getValueAtTime(time);
|
||||
matrix.rotateZ(-rotationZ * this.rz.mult)
|
||||
.rotateY(rotationY * this.ry.mult)
|
||||
.rotateX(rotationX * this.rx.mult)
|
||||
.rotateZ(-orientation[2] * this.or.mult)
|
||||
.rotateY(orientation[1] * this.or.mult)
|
||||
.rotateX(orientation[0] * this.or.mult);
|
||||
}
|
||||
if (this.data.p && this.data.p.s) {
|
||||
var positionX = this.px.getValueAtTime(time);
|
||||
var positionY = this.py.getValueAtTime(time);
|
||||
if (this.data.p.z) {
|
||||
var positionZ = this.pz.getValueAtTime(time);
|
||||
matrix.translate(
|
||||
positionX * this.px.mult,
|
||||
positionY * this.py.mult,
|
||||
-positionZ * this.pz.mult
|
||||
);
|
||||
} else {
|
||||
matrix.translate(positionX * this.px.mult, positionY * this.py.mult, 0);
|
||||
}
|
||||
} else {
|
||||
var position = this.p.getValueAtTime(time);
|
||||
matrix.translate(
|
||||
position[0] * this.p.mult,
|
||||
position[1] * this.p.mult,
|
||||
-position[2] * this.p.mult
|
||||
);
|
||||
}
|
||||
return matrix;
|
||||
/// /
|
||||
}
|
||||
|
||||
function getTransformStaticValueAtTime() {
|
||||
return this.v.clone(new Matrix());
|
||||
}
|
||||
|
||||
var getTransformProperty = TransformPropertyFactory.getTransformProperty;
|
||||
TransformPropertyFactory.getTransformProperty = function (elem, data, container) {
|
||||
var prop = getTransformProperty(elem, data, container);
|
||||
if (prop.dynamicProperties.length) {
|
||||
prop.getValueAtTime = getTransformValueAtTime.bind(prop);
|
||||
} else {
|
||||
prop.getValueAtTime = getTransformStaticValueAtTime.bind(prop);
|
||||
}
|
||||
prop.setGroupProperty = expressionHelpers.setGroupProperty;
|
||||
return prop;
|
||||
};
|
||||
|
||||
var propertyGetProp = PropertyFactory.getProp;
|
||||
PropertyFactory.getProp = function (elem, data, type, mult, container) {
|
||||
var prop = propertyGetProp(elem, data, type, mult, container);
|
||||
// prop.getVelocityAtTime = getVelocityAtTime;
|
||||
// prop.loopOut = loopOut;
|
||||
// prop.loopIn = loopIn;
|
||||
if (prop.kf) {
|
||||
prop.getValueAtTime = expressionHelpers.getValueAtTime.bind(prop);
|
||||
} else {
|
||||
prop.getValueAtTime = expressionHelpers.getStaticValueAtTime.bind(prop);
|
||||
}
|
||||
prop.setGroupProperty = expressionHelpers.setGroupProperty;
|
||||
prop.loopOut = loopOut;
|
||||
prop.loopIn = loopIn;
|
||||
prop.smooth = smooth;
|
||||
prop.getVelocityAtTime = expressionHelpers.getVelocityAtTime.bind(prop);
|
||||
prop.getSpeedAtTime = expressionHelpers.getSpeedAtTime.bind(prop);
|
||||
prop.numKeys = data.a === 1 ? data.k.length : 0;
|
||||
prop.propertyIndex = data.ix;
|
||||
var value = 0;
|
||||
if (type !== 0) {
|
||||
value = createTypedArray('float32', data.a === 1 ? data.k[0].s.length : data.k.length);
|
||||
}
|
||||
prop._cachingAtTime = {
|
||||
lastFrame: initialDefaultFrame,
|
||||
lastIndex: 0,
|
||||
value: value,
|
||||
};
|
||||
expressionHelpers.searchExpressions(elem, data, prop);
|
||||
if (prop.k) {
|
||||
container.addDynamicProperty(prop);
|
||||
}
|
||||
|
||||
return prop;
|
||||
};
|
||||
|
||||
function getShapeValueAtTime(frameNum) {
|
||||
// For now this caching object is created only when needed instead of creating it when the shape is initialized.
|
||||
if (!this._cachingAtTime) {
|
||||
this._cachingAtTime = {
|
||||
shapeValue: shapePool.clone(this.pv),
|
||||
lastIndex: 0,
|
||||
lastTime: initialDefaultFrame,
|
||||
};
|
||||
}
|
||||
|
||||
frameNum *= this.elem.globalData.frameRate;
|
||||
frameNum -= this.offsetTime;
|
||||
if (frameNum !== this._cachingAtTime.lastTime) {
|
||||
this._cachingAtTime.lastIndex = this._cachingAtTime.lastTime < frameNum ? this._caching.lastIndex : 0;
|
||||
this._cachingAtTime.lastTime = frameNum;
|
||||
this.interpolateShape(frameNum, this._cachingAtTime.shapeValue, this._cachingAtTime);
|
||||
}
|
||||
return this._cachingAtTime.shapeValue;
|
||||
}
|
||||
|
||||
var ShapePropertyConstructorFunction = ShapePropertyFactory.getConstructorFunction();
|
||||
var KeyframedShapePropertyConstructorFunction = ShapePropertyFactory.getKeyframedConstructorFunction();
|
||||
|
||||
function ShapeExpressions() {}
|
||||
ShapeExpressions.prototype = {
|
||||
vertices: function (prop, time) {
|
||||
if (this.k) {
|
||||
this.getValue();
|
||||
}
|
||||
var shapePath = this.v;
|
||||
if (time !== undefined) {
|
||||
shapePath = this.getValueAtTime(time, 0);
|
||||
}
|
||||
var i;
|
||||
var len = shapePath._length;
|
||||
var vertices = shapePath[prop];
|
||||
var points = shapePath.v;
|
||||
var arr = createSizedArray(len);
|
||||
for (i = 0; i < len; i += 1) {
|
||||
if (prop === 'i' || prop === 'o') {
|
||||
arr[i] = [vertices[i][0] - points[i][0], vertices[i][1] - points[i][1]];
|
||||
} else {
|
||||
arr[i] = [vertices[i][0], vertices[i][1]];
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
},
|
||||
points: function (time) {
|
||||
return this.vertices('v', time);
|
||||
},
|
||||
inTangents: function (time) {
|
||||
return this.vertices('i', time);
|
||||
},
|
||||
outTangents: function (time) {
|
||||
return this.vertices('o', time);
|
||||
},
|
||||
isClosed: function () {
|
||||
return this.v.c;
|
||||
},
|
||||
pointOnPath: function (perc, time) {
|
||||
var shapePath = this.v;
|
||||
if (time !== undefined) {
|
||||
shapePath = this.getValueAtTime(time, 0);
|
||||
}
|
||||
if (!this._segmentsLength) {
|
||||
this._segmentsLength = bez.getSegmentsLength(shapePath);
|
||||
}
|
||||
|
||||
var segmentsLength = this._segmentsLength;
|
||||
var lengths = segmentsLength.lengths;
|
||||
var lengthPos = segmentsLength.totalLength * perc;
|
||||
var i = 0;
|
||||
var len = lengths.length;
|
||||
var accumulatedLength = 0;
|
||||
var pt;
|
||||
while (i < len) {
|
||||
if (accumulatedLength + lengths[i].addedLength > lengthPos) {
|
||||
var initIndex = i;
|
||||
var endIndex = (shapePath.c && i === len - 1) ? 0 : i + 1;
|
||||
var segmentPerc = (lengthPos - accumulatedLength) / lengths[i].addedLength;
|
||||
pt = bez.getPointInSegment(shapePath.v[initIndex], shapePath.v[endIndex], shapePath.o[initIndex], shapePath.i[endIndex], segmentPerc, lengths[i]);
|
||||
break;
|
||||
} else {
|
||||
accumulatedLength += lengths[i].addedLength;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if (!pt) {
|
||||
pt = shapePath.c ? [shapePath.v[0][0], shapePath.v[0][1]] : [shapePath.v[shapePath._length - 1][0], shapePath.v[shapePath._length - 1][1]];
|
||||
}
|
||||
return pt;
|
||||
},
|
||||
vectorOnPath: function (perc, time, vectorType) {
|
||||
// perc doesn't use triple equality because it can be a Number object as well as a primitive.
|
||||
if (perc == 1) { // eslint-disable-line eqeqeq
|
||||
perc = this.v.c;
|
||||
} else if (perc == 0) { // eslint-disable-line eqeqeq
|
||||
perc = 0.999;
|
||||
}
|
||||
var pt1 = this.pointOnPath(perc, time);
|
||||
var pt2 = this.pointOnPath(perc + 0.001, time);
|
||||
var xLength = pt2[0] - pt1[0];
|
||||
var yLength = pt2[1] - pt1[1];
|
||||
var magnitude = Math.sqrt(Math.pow(xLength, 2) + Math.pow(yLength, 2));
|
||||
if (magnitude === 0) {
|
||||
return [0, 0];
|
||||
}
|
||||
var unitVector = vectorType === 'tangent' ? [xLength / magnitude, yLength / magnitude] : [-yLength / magnitude, xLength / magnitude];
|
||||
return unitVector;
|
||||
},
|
||||
tangentOnPath: function (perc, time) {
|
||||
return this.vectorOnPath(perc, time, 'tangent');
|
||||
},
|
||||
normalOnPath: function (perc, time) {
|
||||
return this.vectorOnPath(perc, time, 'normal');
|
||||
},
|
||||
setGroupProperty: expressionHelpers.setGroupProperty,
|
||||
getValueAtTime: expressionHelpers.getStaticValueAtTime,
|
||||
};
|
||||
extendPrototype([ShapeExpressions], ShapePropertyConstructorFunction);
|
||||
extendPrototype([ShapeExpressions], KeyframedShapePropertyConstructorFunction);
|
||||
KeyframedShapePropertyConstructorFunction.prototype.getValueAtTime = getShapeValueAtTime;
|
||||
KeyframedShapePropertyConstructorFunction.prototype.initiateExpression = ExpressionManager.initiateExpression;
|
||||
|
||||
var propertyGetShapeProp = ShapePropertyFactory.getShapeProp;
|
||||
ShapePropertyFactory.getShapeProp = function (elem, data, type, arr, trims) {
|
||||
var prop = propertyGetShapeProp(elem, data, type, arr, trims);
|
||||
prop.propertyIndex = data.ix;
|
||||
prop.lock = false;
|
||||
if (type === 3) {
|
||||
expressionHelpers.searchExpressions(elem, data.pt, prop);
|
||||
} else if (type === 4) {
|
||||
expressionHelpers.searchExpressions(elem, data.ks, prop);
|
||||
}
|
||||
if (prop.k) {
|
||||
elem.addDynamicProperty(prop);
|
||||
}
|
||||
return prop;
|
||||
};
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
addPropertyDecorator();
|
||||
}
|
||||
|
||||
export default initialize;
|
40
node_modules/lottie-web/player/js/utils/expressions/ExpressionTextPropertyDecorator.js
generated
vendored
Normal file
40
node_modules/lottie-web/player/js/utils/expressions/ExpressionTextPropertyDecorator.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import TextProperty from '../text/TextProperty';
|
||||
import ExpressionManager from './ExpressionManager';
|
||||
|
||||
function addDecorator() {
|
||||
function searchExpressions() {
|
||||
if (this.data.d.x) {
|
||||
this.calculateExpression = ExpressionManager.initiateExpression.bind(this)(this.elem, this.data.d, this);
|
||||
this.addEffect(this.getExpressionValue.bind(this));
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
TextProperty.prototype.getExpressionValue = function (currentValue, text) {
|
||||
var newValue = this.calculateExpression(text);
|
||||
if (currentValue.t !== newValue) {
|
||||
var newData = {};
|
||||
this.copyData(newData, currentValue);
|
||||
newData.t = newValue.toString();
|
||||
newData.__complete = false;
|
||||
return newData;
|
||||
}
|
||||
return currentValue;
|
||||
};
|
||||
|
||||
TextProperty.prototype.searchProperty = function () {
|
||||
var isKeyframed = this.searchKeyframes();
|
||||
var hasExpressions = this.searchExpressions();
|
||||
this.kf = isKeyframed || hasExpressions;
|
||||
return this.kf;
|
||||
};
|
||||
|
||||
TextProperty.prototype.searchExpressions = searchExpressions;
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
addDecorator();
|
||||
}
|
||||
|
||||
export default initialize;
|
61
node_modules/lottie-web/player/js/utils/expressions/ExpressionValue.js
generated
vendored
Normal file
61
node_modules/lottie-web/player/js/utils/expressions/ExpressionValue.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
import {
|
||||
createTypedArray,
|
||||
} from '../helpers/arrays';
|
||||
|
||||
function ExpressionValue(elementProp, mult, type) {
|
||||
mult = mult || 1;
|
||||
var expressionValue;
|
||||
|
||||
if (elementProp.k) {
|
||||
elementProp.getValue();
|
||||
}
|
||||
var i;
|
||||
var len;
|
||||
var arrValue;
|
||||
var val;
|
||||
if (type) {
|
||||
if (type === 'color') {
|
||||
len = 4;
|
||||
expressionValue = createTypedArray('float32', len);
|
||||
arrValue = createTypedArray('float32', len);
|
||||
for (i = 0; i < len; i += 1) {
|
||||
arrValue[i] = (i < 3) ? elementProp.v[i] * mult : 1;
|
||||
expressionValue[i] = arrValue[i];
|
||||
}
|
||||
expressionValue.value = arrValue;
|
||||
}
|
||||
} else if (elementProp.propType === 'unidimensional') {
|
||||
val = elementProp.v * mult;
|
||||
expressionValue = new Number(val); // eslint-disable-line no-new-wrappers
|
||||
expressionValue.value = val;
|
||||
} else {
|
||||
len = elementProp.pv.length;
|
||||
expressionValue = createTypedArray('float32', len);
|
||||
arrValue = createTypedArray('float32', len);
|
||||
for (i = 0; i < len; i += 1) {
|
||||
arrValue[i] = elementProp.v[i] * mult;
|
||||
expressionValue[i] = arrValue[i];
|
||||
}
|
||||
expressionValue.value = arrValue;
|
||||
}
|
||||
|
||||
expressionValue.numKeys = elementProp.keyframes ? elementProp.keyframes.length : 0;
|
||||
expressionValue.key = function (pos) {
|
||||
if (!expressionValue.numKeys) {
|
||||
return 0;
|
||||
}
|
||||
return elementProp.keyframes[pos - 1].t;
|
||||
};
|
||||
expressionValue.valueAtTime = elementProp.getValueAtTime;
|
||||
expressionValue.speedAtTime = elementProp.getSpeedAtTime;
|
||||
expressionValue.velocityAtTime = elementProp.getVelocityAtTime;
|
||||
expressionValue.propertyGroup = elementProp.propertyGroup;
|
||||
Object.defineProperty(expressionValue, 'velocity', {
|
||||
get: function () {
|
||||
return elementProp.getVelocityAtTime(elementProp.comp.currentFrame);
|
||||
},
|
||||
});
|
||||
return expressionValue;
|
||||
}
|
||||
|
||||
export default ExpressionValue;
|
101
node_modules/lottie-web/player/js/utils/expressions/ExpressionValueFactory.js
generated
vendored
Normal file
101
node_modules/lottie-web/player/js/utils/expressions/ExpressionValueFactory.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
import {
|
||||
createTypedArray,
|
||||
} from '../helpers/arrays';
|
||||
|
||||
const ExpressionPropertyInterface = (function () {
|
||||
var defaultUnidimensionalValue = { pv: 0, v: 0, mult: 1 };
|
||||
var defaultMultidimensionalValue = { pv: [0, 0, 0], v: [0, 0, 0], mult: 1 };
|
||||
|
||||
function completeProperty(expressionValue, property, type) {
|
||||
Object.defineProperty(expressionValue, 'velocity', {
|
||||
get: function () {
|
||||
return property.getVelocityAtTime(property.comp.currentFrame);
|
||||
},
|
||||
});
|
||||
expressionValue.numKeys = property.keyframes ? property.keyframes.length : 0;
|
||||
expressionValue.key = function (pos) {
|
||||
if (!expressionValue.numKeys) {
|
||||
return 0;
|
||||
}
|
||||
var value = '';
|
||||
if ('s' in property.keyframes[pos - 1]) {
|
||||
value = property.keyframes[pos - 1].s;
|
||||
} else if ('e' in property.keyframes[pos - 2]) {
|
||||
value = property.keyframes[pos - 2].e;
|
||||
} else {
|
||||
value = property.keyframes[pos - 2].s;
|
||||
}
|
||||
var valueProp = type === 'unidimensional' ? new Number(value) : Object.assign({}, value); // eslint-disable-line no-new-wrappers
|
||||
valueProp.time = property.keyframes[pos - 1].t / property.elem.comp.globalData.frameRate;
|
||||
valueProp.value = type === 'unidimensional' ? value[0] : value;
|
||||
return valueProp;
|
||||
};
|
||||
expressionValue.valueAtTime = property.getValueAtTime;
|
||||
expressionValue.speedAtTime = property.getSpeedAtTime;
|
||||
expressionValue.velocityAtTime = property.getVelocityAtTime;
|
||||
expressionValue.propertyGroup = property.propertyGroup;
|
||||
}
|
||||
|
||||
function UnidimensionalPropertyInterface(property) {
|
||||
if (!property || !('pv' in property)) {
|
||||
property = defaultUnidimensionalValue;
|
||||
}
|
||||
var mult = 1 / property.mult;
|
||||
var val = property.pv * mult;
|
||||
var expressionValue = new Number(val); // eslint-disable-line no-new-wrappers
|
||||
expressionValue.value = val;
|
||||
completeProperty(expressionValue, property, 'unidimensional');
|
||||
|
||||
return function () {
|
||||
if (property.k) {
|
||||
property.getValue();
|
||||
}
|
||||
val = property.v * mult;
|
||||
if (expressionValue.value !== val) {
|
||||
expressionValue = new Number(val); // eslint-disable-line no-new-wrappers
|
||||
expressionValue.value = val;
|
||||
completeProperty(expressionValue, property, 'unidimensional');
|
||||
}
|
||||
return expressionValue;
|
||||
};
|
||||
}
|
||||
|
||||
function MultidimensionalPropertyInterface(property) {
|
||||
if (!property || !('pv' in property)) {
|
||||
property = defaultMultidimensionalValue;
|
||||
}
|
||||
var mult = 1 / property.mult;
|
||||
var len = (property.data && property.data.l) || property.pv.length;
|
||||
var expressionValue = createTypedArray('float32', len);
|
||||
var arrValue = createTypedArray('float32', len);
|
||||
expressionValue.value = arrValue;
|
||||
completeProperty(expressionValue, property, 'multidimensional');
|
||||
|
||||
return function () {
|
||||
if (property.k) {
|
||||
property.getValue();
|
||||
}
|
||||
for (var i = 0; i < len; i += 1) {
|
||||
arrValue[i] = property.v[i] * mult;
|
||||
expressionValue[i] = arrValue[i];
|
||||
}
|
||||
return expressionValue;
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: try to avoid using this getter
|
||||
function defaultGetter() {
|
||||
return defaultUnidimensionalValue;
|
||||
}
|
||||
|
||||
return function (property) {
|
||||
if (!property) {
|
||||
return defaultGetter;
|
||||
} if (property.propType === 'unidimensional') {
|
||||
return UnidimensionalPropertyInterface(property);
|
||||
}
|
||||
return MultidimensionalPropertyInterface(property);
|
||||
};
|
||||
}());
|
||||
|
||||
export default ExpressionPropertyInterface;
|
48
node_modules/lottie-web/player/js/utils/expressions/Expressions.js
generated
vendored
Normal file
48
node_modules/lottie-web/player/js/utils/expressions/Expressions.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import CompExpressionInterface from './CompInterface';
|
||||
import ExpressionManager from './ExpressionManager';
|
||||
|
||||
const Expressions = (function () {
|
||||
var ob = {};
|
||||
ob.initExpressions = initExpressions;
|
||||
ob.resetFrame = ExpressionManager.resetFrame;
|
||||
|
||||
function initExpressions(animation) {
|
||||
var stackCount = 0;
|
||||
var registers = [];
|
||||
|
||||
function pushExpression() {
|
||||
stackCount += 1;
|
||||
}
|
||||
|
||||
function popExpression() {
|
||||
stackCount -= 1;
|
||||
if (stackCount === 0) {
|
||||
releaseInstances();
|
||||
}
|
||||
}
|
||||
|
||||
function registerExpressionProperty(expression) {
|
||||
if (registers.indexOf(expression) === -1) {
|
||||
registers.push(expression);
|
||||
}
|
||||
}
|
||||
|
||||
function releaseInstances() {
|
||||
var i;
|
||||
var len = registers.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
registers[i].release();
|
||||
}
|
||||
registers.length = 0;
|
||||
}
|
||||
|
||||
animation.renderer.compInterface = CompExpressionInterface(animation.renderer);
|
||||
animation.renderer.globalData.projectInterface.registerComposition(animation.renderer);
|
||||
animation.renderer.globalData.pushExpression = pushExpression;
|
||||
animation.renderer.globalData.popExpression = popExpression;
|
||||
animation.renderer.globalData.registerExpressionProperty = registerExpressionProperty;
|
||||
}
|
||||
return ob;
|
||||
}());
|
||||
|
||||
export default Expressions;
|
60
node_modules/lottie-web/player/js/utils/expressions/FootageInterface.js
generated
vendored
Normal file
60
node_modules/lottie-web/player/js/utils/expressions/FootageInterface.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
const FootageInterface = (function () {
|
||||
var outlineInterfaceFactory = (function (elem) {
|
||||
var currentPropertyName = '';
|
||||
var currentProperty = elem.getFootageData();
|
||||
function init() {
|
||||
currentPropertyName = '';
|
||||
currentProperty = elem.getFootageData();
|
||||
return searchProperty;
|
||||
}
|
||||
function searchProperty(value) {
|
||||
if (currentProperty[value]) {
|
||||
currentPropertyName = value;
|
||||
currentProperty = currentProperty[value];
|
||||
if (typeof currentProperty === 'object') {
|
||||
return searchProperty;
|
||||
}
|
||||
return currentProperty;
|
||||
}
|
||||
var propertyNameIndex = value.indexOf(currentPropertyName);
|
||||
if (propertyNameIndex !== -1) {
|
||||
var index = parseInt(value.substr(propertyNameIndex + currentPropertyName.length), 10);
|
||||
currentProperty = currentProperty[index];
|
||||
if (typeof currentProperty === 'object') {
|
||||
return searchProperty;
|
||||
}
|
||||
return currentProperty;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
return init;
|
||||
});
|
||||
|
||||
var dataInterfaceFactory = function (elem) {
|
||||
function interfaceFunction(value) {
|
||||
if (value === 'Outline') {
|
||||
return interfaceFunction.outlineInterface();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
interfaceFunction._name = 'Outline';
|
||||
interfaceFunction.outlineInterface = outlineInterfaceFactory(elem);
|
||||
return interfaceFunction;
|
||||
};
|
||||
|
||||
return function (elem) {
|
||||
function _interfaceFunction(value) {
|
||||
if (value === 'Data') {
|
||||
return _interfaceFunction.dataInterface;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
_interfaceFunction._name = 'Data';
|
||||
_interfaceFunction.dataInterface = dataInterfaceFactory(elem);
|
||||
return _interfaceFunction;
|
||||
};
|
||||
}());
|
||||
|
||||
export default FootageInterface;
|
21
node_modules/lottie-web/player/js/utils/expressions/InterfacesProvider.js
generated
vendored
Normal file
21
node_modules/lottie-web/player/js/utils/expressions/InterfacesProvider.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import LayerExpressionInterface from './LayerInterface';
|
||||
import EffectsExpressionInterface from './EffectInterface';
|
||||
import CompExpressionInterface from './CompInterface';
|
||||
import ShapeExpressionInterface from './ShapeInterface';
|
||||
import TextExpressionInterface from './TextInterface';
|
||||
import FootageInterface from './FootageInterface';
|
||||
|
||||
var interfaces = {
|
||||
layer: LayerExpressionInterface,
|
||||
effects: EffectsExpressionInterface,
|
||||
comp: CompExpressionInterface,
|
||||
shape: ShapeExpressionInterface,
|
||||
text: TextExpressionInterface,
|
||||
footage: FootageInterface,
|
||||
};
|
||||
|
||||
function getInterface(type) {
|
||||
return interfaces[type] || null;
|
||||
}
|
||||
|
||||
export default getInterface;
|
179
node_modules/lottie-web/player/js/utils/expressions/LayerInterface.js
generated
vendored
Normal file
179
node_modules/lottie-web/player/js/utils/expressions/LayerInterface.js
generated
vendored
Normal file
@@ -0,0 +1,179 @@
|
||||
import {
|
||||
getDescriptor,
|
||||
} from '../functionExtensions';
|
||||
import Matrix from '../../3rd_party/transformation-matrix';
|
||||
import MaskManagerInterface from './MaskInterface';
|
||||
import TransformExpressionInterface from './TransformInterface';
|
||||
|
||||
const LayerExpressionInterface = (function () {
|
||||
function getMatrix(time) {
|
||||
var toWorldMat = new Matrix();
|
||||
if (time !== undefined) {
|
||||
var propMatrix = this._elem.finalTransform.mProp.getValueAtTime(time);
|
||||
propMatrix.clone(toWorldMat);
|
||||
} else {
|
||||
var transformMat = this._elem.finalTransform.mProp;
|
||||
transformMat.applyToMatrix(toWorldMat);
|
||||
}
|
||||
return toWorldMat;
|
||||
}
|
||||
|
||||
function toWorldVec(arr, time) {
|
||||
var toWorldMat = this.getMatrix(time);
|
||||
toWorldMat.props[12] = 0;
|
||||
toWorldMat.props[13] = 0;
|
||||
toWorldMat.props[14] = 0;
|
||||
return this.applyPoint(toWorldMat, arr);
|
||||
}
|
||||
|
||||
function toWorld(arr, time) {
|
||||
var toWorldMat = this.getMatrix(time);
|
||||
return this.applyPoint(toWorldMat, arr);
|
||||
}
|
||||
|
||||
function fromWorldVec(arr, time) {
|
||||
var toWorldMat = this.getMatrix(time);
|
||||
toWorldMat.props[12] = 0;
|
||||
toWorldMat.props[13] = 0;
|
||||
toWorldMat.props[14] = 0;
|
||||
return this.invertPoint(toWorldMat, arr);
|
||||
}
|
||||
|
||||
function fromWorld(arr, time) {
|
||||
var toWorldMat = this.getMatrix(time);
|
||||
return this.invertPoint(toWorldMat, arr);
|
||||
}
|
||||
|
||||
function applyPoint(matrix, arr) {
|
||||
if (this._elem.hierarchy && this._elem.hierarchy.length) {
|
||||
var i;
|
||||
var len = this._elem.hierarchy.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
this._elem.hierarchy[i].finalTransform.mProp.applyToMatrix(matrix);
|
||||
}
|
||||
}
|
||||
return matrix.applyToPointArray(arr[0], arr[1], arr[2] || 0);
|
||||
}
|
||||
|
||||
function invertPoint(matrix, arr) {
|
||||
if (this._elem.hierarchy && this._elem.hierarchy.length) {
|
||||
var i;
|
||||
var len = this._elem.hierarchy.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
this._elem.hierarchy[i].finalTransform.mProp.applyToMatrix(matrix);
|
||||
}
|
||||
}
|
||||
return matrix.inversePoint(arr);
|
||||
}
|
||||
|
||||
function fromComp(arr) {
|
||||
var toWorldMat = new Matrix();
|
||||
toWorldMat.reset();
|
||||
this._elem.finalTransform.mProp.applyToMatrix(toWorldMat);
|
||||
if (this._elem.hierarchy && this._elem.hierarchy.length) {
|
||||
var i;
|
||||
var len = this._elem.hierarchy.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
this._elem.hierarchy[i].finalTransform.mProp.applyToMatrix(toWorldMat);
|
||||
}
|
||||
return toWorldMat.inversePoint(arr);
|
||||
}
|
||||
return toWorldMat.inversePoint(arr);
|
||||
}
|
||||
|
||||
function sampleImage() {
|
||||
return [1, 1, 1, 1];
|
||||
}
|
||||
|
||||
return function (elem) {
|
||||
var transformInterface;
|
||||
|
||||
function _registerMaskInterface(maskManager) {
|
||||
_thisLayerFunction.mask = new MaskManagerInterface(maskManager, elem);
|
||||
}
|
||||
function _registerEffectsInterface(effects) {
|
||||
_thisLayerFunction.effect = effects;
|
||||
}
|
||||
|
||||
function _thisLayerFunction(name) {
|
||||
switch (name) {
|
||||
case 'ADBE Root Vectors Group':
|
||||
case 'Contents':
|
||||
case 2:
|
||||
return _thisLayerFunction.shapeInterface;
|
||||
case 1:
|
||||
case 6:
|
||||
case 'Transform':
|
||||
case 'transform':
|
||||
case 'ADBE Transform Group':
|
||||
return transformInterface;
|
||||
case 4:
|
||||
case 'ADBE Effect Parade':
|
||||
case 'effects':
|
||||
case 'Effects':
|
||||
return _thisLayerFunction.effect;
|
||||
case 'ADBE Text Properties':
|
||||
return _thisLayerFunction.textInterface;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
_thisLayerFunction.getMatrix = getMatrix;
|
||||
_thisLayerFunction.invertPoint = invertPoint;
|
||||
_thisLayerFunction.applyPoint = applyPoint;
|
||||
_thisLayerFunction.toWorld = toWorld;
|
||||
_thisLayerFunction.toWorldVec = toWorldVec;
|
||||
_thisLayerFunction.fromWorld = fromWorld;
|
||||
_thisLayerFunction.fromWorldVec = fromWorldVec;
|
||||
_thisLayerFunction.toComp = toWorld;
|
||||
_thisLayerFunction.fromComp = fromComp;
|
||||
_thisLayerFunction.sampleImage = sampleImage;
|
||||
_thisLayerFunction.sourceRectAtTime = elem.sourceRectAtTime.bind(elem);
|
||||
_thisLayerFunction._elem = elem;
|
||||
transformInterface = TransformExpressionInterface(elem.finalTransform.mProp);
|
||||
var anchorPointDescriptor = getDescriptor(transformInterface, 'anchorPoint');
|
||||
Object.defineProperties(_thisLayerFunction, {
|
||||
hasParent: {
|
||||
get: function () {
|
||||
return elem.hierarchy.length;
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
get: function () {
|
||||
return elem.hierarchy[0].layerInterface;
|
||||
},
|
||||
},
|
||||
rotation: getDescriptor(transformInterface, 'rotation'),
|
||||
scale: getDescriptor(transformInterface, 'scale'),
|
||||
position: getDescriptor(transformInterface, 'position'),
|
||||
opacity: getDescriptor(transformInterface, 'opacity'),
|
||||
anchorPoint: anchorPointDescriptor,
|
||||
anchor_point: anchorPointDescriptor,
|
||||
transform: {
|
||||
get: function () {
|
||||
return transformInterface;
|
||||
},
|
||||
},
|
||||
active: {
|
||||
get: function () {
|
||||
return elem.isInRange;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
_thisLayerFunction.startTime = elem.data.st;
|
||||
_thisLayerFunction.index = elem.data.ind;
|
||||
_thisLayerFunction.source = elem.data.refId;
|
||||
_thisLayerFunction.height = elem.data.ty === 0 ? elem.data.h : 100;
|
||||
_thisLayerFunction.width = elem.data.ty === 0 ? elem.data.w : 100;
|
||||
_thisLayerFunction.inPoint = elem.data.ip / elem.comp.globalData.frameRate;
|
||||
_thisLayerFunction.outPoint = elem.data.op / elem.comp.globalData.frameRate;
|
||||
_thisLayerFunction._name = elem.data.nm;
|
||||
|
||||
_thisLayerFunction.registerMaskInterface = _registerMaskInterface;
|
||||
_thisLayerFunction.registerEffectsInterface = _registerEffectsInterface;
|
||||
return _thisLayerFunction;
|
||||
};
|
||||
}());
|
||||
|
||||
export default LayerExpressionInterface;
|
50
node_modules/lottie-web/player/js/utils/expressions/MaskInterface.js
generated
vendored
Normal file
50
node_modules/lottie-web/player/js/utils/expressions/MaskInterface.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
createSizedArray,
|
||||
} from '../helpers/arrays';
|
||||
|
||||
const MaskManagerInterface = (function () {
|
||||
function MaskInterface(mask, data) {
|
||||
this._mask = mask;
|
||||
this._data = data;
|
||||
}
|
||||
Object.defineProperty(MaskInterface.prototype, 'maskPath', {
|
||||
get: function () {
|
||||
if (this._mask.prop.k) {
|
||||
this._mask.prop.getValue();
|
||||
}
|
||||
return this._mask.prop;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(MaskInterface.prototype, 'maskOpacity', {
|
||||
get: function () {
|
||||
if (this._mask.op.k) {
|
||||
this._mask.op.getValue();
|
||||
}
|
||||
return this._mask.op.v * 100;
|
||||
},
|
||||
});
|
||||
|
||||
var MaskManager = function (maskManager) {
|
||||
var _masksInterfaces = createSizedArray(maskManager.viewData.length);
|
||||
var i;
|
||||
var len = maskManager.viewData.length;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
_masksInterfaces[i] = new MaskInterface(maskManager.viewData[i], maskManager.masksProperties[i]);
|
||||
}
|
||||
|
||||
var maskFunction = function (name) {
|
||||
i = 0;
|
||||
while (i < len) {
|
||||
if (maskManager.masksProperties[i].nm === name) {
|
||||
return _masksInterfaces[i];
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
return maskFunction;
|
||||
};
|
||||
return MaskManager;
|
||||
}());
|
||||
|
||||
export default MaskManagerInterface;
|
31
node_modules/lottie-web/player/js/utils/expressions/ProjectInterface.js
generated
vendored
Normal file
31
node_modules/lottie-web/player/js/utils/expressions/ProjectInterface.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
const ProjectInterface = (function () {
|
||||
function registerComposition(comp) {
|
||||
this.compositions.push(comp);
|
||||
}
|
||||
|
||||
return function () {
|
||||
function _thisProjectFunction(name) {
|
||||
var i = 0;
|
||||
var len = this.compositions.length;
|
||||
while (i < len) {
|
||||
if (this.compositions[i].data && this.compositions[i].data.nm === name) {
|
||||
if (this.compositions[i].prepareFrame && this.compositions[i].data.xt) {
|
||||
this.compositions[i].prepareFrame(this.currentFrame);
|
||||
}
|
||||
return this.compositions[i].compInterface;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
_thisProjectFunction.compositions = [];
|
||||
_thisProjectFunction.currentFrame = 0;
|
||||
|
||||
_thisProjectFunction.registerComposition = registerComposition;
|
||||
|
||||
return _thisProjectFunction;
|
||||
};
|
||||
}());
|
||||
|
||||
export default ProjectInterface;
|
13
node_modules/lottie-web/player/js/utils/expressions/PropertyGroupFactory.js
generated
vendored
Normal file
13
node_modules/lottie-web/player/js/utils/expressions/PropertyGroupFactory.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
const propertyGroupFactory = (function () {
|
||||
return function (interfaceFunction, parentPropertyGroup) {
|
||||
return function (val) {
|
||||
val = val === undefined ? 1 : val;
|
||||
if (val <= 0) {
|
||||
return interfaceFunction;
|
||||
}
|
||||
return parentPropertyGroup(val - 1);
|
||||
};
|
||||
};
|
||||
}());
|
||||
|
||||
export default propertyGroupFactory;
|
19
node_modules/lottie-web/player/js/utils/expressions/PropertyInterface.js
generated
vendored
Normal file
19
node_modules/lottie-web/player/js/utils/expressions/PropertyInterface.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
const PropertyInterface = (function () {
|
||||
return function (propertyName, propertyGroup) {
|
||||
var interfaceFunction = {
|
||||
_name: propertyName,
|
||||
};
|
||||
|
||||
function _propertyGroup(val) {
|
||||
val = val === undefined ? 1 : val;
|
||||
if (val <= 0) {
|
||||
return interfaceFunction;
|
||||
}
|
||||
return propertyGroup(val - 1);
|
||||
}
|
||||
|
||||
return _propertyGroup;
|
||||
};
|
||||
}());
|
||||
|
||||
export default PropertyInterface;
|
543
node_modules/lottie-web/player/js/utils/expressions/ShapeInterface.js
generated
vendored
Normal file
543
node_modules/lottie-web/player/js/utils/expressions/ShapeInterface.js
generated
vendored
Normal file
@@ -0,0 +1,543 @@
|
||||
import ExpressionPropertyInterface from './ExpressionValueFactory';
|
||||
import propertyGroupFactory from './PropertyGroupFactory';
|
||||
import PropertyInterface from './PropertyInterface';
|
||||
import ShapePathInterface from './shapes/ShapePathInterface';
|
||||
|
||||
const ShapeExpressionInterface = (function () {
|
||||
function iterateElements(shapes, view, propertyGroup) {
|
||||
var arr = [];
|
||||
var i;
|
||||
var len = shapes ? shapes.length : 0;
|
||||
for (i = 0; i < len; i += 1) {
|
||||
if (shapes[i].ty === 'gr') {
|
||||
arr.push(groupInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'fl') {
|
||||
arr.push(fillInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'st') {
|
||||
arr.push(strokeInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'tm') {
|
||||
arr.push(trimInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'tr') {
|
||||
// arr.push(transformInterfaceFactory(shapes[i],view[i],propertyGroup));
|
||||
} else if (shapes[i].ty === 'el') {
|
||||
arr.push(ellipseInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'sr') {
|
||||
arr.push(starInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'sh') {
|
||||
arr.push(ShapePathInterface(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'rc') {
|
||||
arr.push(rectInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'rd') {
|
||||
arr.push(roundedInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'rp') {
|
||||
arr.push(repeaterInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else if (shapes[i].ty === 'gf') {
|
||||
arr.push(gradientFillInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
} else {
|
||||
arr.push(defaultInterfaceFactory(shapes[i], view[i], propertyGroup));
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function contentsInterfaceFactory(shape, view, propertyGroup) {
|
||||
var interfaces;
|
||||
var interfaceFunction = function _interfaceFunction(value) {
|
||||
var i = 0;
|
||||
var len = interfaces.length;
|
||||
while (i < len) {
|
||||
if (interfaces[i]._name === value || interfaces[i].mn === value || interfaces[i].propertyIndex === value || interfaces[i].ix === value || interfaces[i].ind === value) {
|
||||
return interfaces[i];
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
return interfaces[value - 1];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
interfaceFunction.propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
interfaces = iterateElements(shape.it, view.it, interfaceFunction.propertyGroup);
|
||||
interfaceFunction.numProperties = interfaces.length;
|
||||
var transformInterface = transformInterfaceFactory(shape.it[shape.it.length - 1], view.it[view.it.length - 1], interfaceFunction.propertyGroup);
|
||||
interfaceFunction.transform = transformInterface;
|
||||
interfaceFunction.propertyIndex = shape.cix;
|
||||
interfaceFunction._name = shape.nm;
|
||||
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function groupInterfaceFactory(shape, view, propertyGroup) {
|
||||
var interfaceFunction = function _interfaceFunction(value) {
|
||||
switch (value) {
|
||||
case 'ADBE Vectors Group':
|
||||
case 'Contents':
|
||||
case 2:
|
||||
return interfaceFunction.content;
|
||||
// Not necessary for now. Keeping them here in case a new case appears
|
||||
// case 'ADBE Vector Transform Group':
|
||||
// case 3:
|
||||
default:
|
||||
return interfaceFunction.transform;
|
||||
}
|
||||
};
|
||||
interfaceFunction.propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
var content = contentsInterfaceFactory(shape, view, interfaceFunction.propertyGroup);
|
||||
var transformInterface = transformInterfaceFactory(shape.it[shape.it.length - 1], view.it[view.it.length - 1], interfaceFunction.propertyGroup);
|
||||
interfaceFunction.content = content;
|
||||
interfaceFunction.transform = transformInterface;
|
||||
Object.defineProperty(interfaceFunction, '_name', {
|
||||
get: function () {
|
||||
return shape.nm;
|
||||
},
|
||||
});
|
||||
// interfaceFunction.content = interfaceFunction;
|
||||
interfaceFunction.numProperties = shape.np;
|
||||
interfaceFunction.propertyIndex = shape.ix;
|
||||
interfaceFunction.nm = shape.nm;
|
||||
interfaceFunction.mn = shape.mn;
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function fillInterfaceFactory(shape, view, propertyGroup) {
|
||||
function interfaceFunction(val) {
|
||||
if (val === 'Color' || val === 'color') {
|
||||
return interfaceFunction.color;
|
||||
} if (val === 'Opacity' || val === 'opacity') {
|
||||
return interfaceFunction.opacity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
color: {
|
||||
get: ExpressionPropertyInterface(view.c),
|
||||
},
|
||||
opacity: {
|
||||
get: ExpressionPropertyInterface(view.o),
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
mn: { value: shape.mn },
|
||||
});
|
||||
|
||||
view.c.setGroupProperty(PropertyInterface('Color', propertyGroup));
|
||||
view.o.setGroupProperty(PropertyInterface('Opacity', propertyGroup));
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function gradientFillInterfaceFactory(shape, view, propertyGroup) {
|
||||
function interfaceFunction(val) {
|
||||
if (val === 'Start Point' || val === 'start point') {
|
||||
return interfaceFunction.startPoint;
|
||||
}
|
||||
if (val === 'End Point' || val === 'end point') {
|
||||
return interfaceFunction.endPoint;
|
||||
}
|
||||
if (val === 'Opacity' || val === 'opacity') {
|
||||
return interfaceFunction.opacity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
startPoint: {
|
||||
get: ExpressionPropertyInterface(view.s),
|
||||
},
|
||||
endPoint: {
|
||||
get: ExpressionPropertyInterface(view.e),
|
||||
},
|
||||
opacity: {
|
||||
get: ExpressionPropertyInterface(view.o),
|
||||
},
|
||||
type: {
|
||||
get: function () {
|
||||
return 'a';
|
||||
},
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
mn: { value: shape.mn },
|
||||
});
|
||||
|
||||
view.s.setGroupProperty(PropertyInterface('Start Point', propertyGroup));
|
||||
view.e.setGroupProperty(PropertyInterface('End Point', propertyGroup));
|
||||
view.o.setGroupProperty(PropertyInterface('Opacity', propertyGroup));
|
||||
return interfaceFunction;
|
||||
}
|
||||
function defaultInterfaceFactory() {
|
||||
function interfaceFunction() {
|
||||
return null;
|
||||
}
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function strokeInterfaceFactory(shape, view, propertyGroup) {
|
||||
var _propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
var _dashPropertyGroup = propertyGroupFactory(dashOb, _propertyGroup);
|
||||
function addPropertyToDashOb(i) {
|
||||
Object.defineProperty(dashOb, shape.d[i].nm, {
|
||||
get: ExpressionPropertyInterface(view.d.dataProps[i].p),
|
||||
});
|
||||
}
|
||||
var i;
|
||||
var len = shape.d ? shape.d.length : 0;
|
||||
var dashOb = {};
|
||||
for (i = 0; i < len; i += 1) {
|
||||
addPropertyToDashOb(i);
|
||||
view.d.dataProps[i].p.setGroupProperty(_dashPropertyGroup);
|
||||
}
|
||||
|
||||
function interfaceFunction(val) {
|
||||
if (val === 'Color' || val === 'color') {
|
||||
return interfaceFunction.color;
|
||||
} if (val === 'Opacity' || val === 'opacity') {
|
||||
return interfaceFunction.opacity;
|
||||
} if (val === 'Stroke Width' || val === 'stroke width') {
|
||||
return interfaceFunction.strokeWidth;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
color: {
|
||||
get: ExpressionPropertyInterface(view.c),
|
||||
},
|
||||
opacity: {
|
||||
get: ExpressionPropertyInterface(view.o),
|
||||
},
|
||||
strokeWidth: {
|
||||
get: ExpressionPropertyInterface(view.w),
|
||||
},
|
||||
dash: {
|
||||
get: function () {
|
||||
return dashOb;
|
||||
},
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
mn: { value: shape.mn },
|
||||
});
|
||||
|
||||
view.c.setGroupProperty(PropertyInterface('Color', _propertyGroup));
|
||||
view.o.setGroupProperty(PropertyInterface('Opacity', _propertyGroup));
|
||||
view.w.setGroupProperty(PropertyInterface('Stroke Width', _propertyGroup));
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function trimInterfaceFactory(shape, view, propertyGroup) {
|
||||
function interfaceFunction(val) {
|
||||
if (val === shape.e.ix || val === 'End' || val === 'end') {
|
||||
return interfaceFunction.end;
|
||||
}
|
||||
if (val === shape.s.ix) {
|
||||
return interfaceFunction.start;
|
||||
}
|
||||
if (val === shape.o.ix) {
|
||||
return interfaceFunction.offset;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var _propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
interfaceFunction.propertyIndex = shape.ix;
|
||||
|
||||
view.s.setGroupProperty(PropertyInterface('Start', _propertyGroup));
|
||||
view.e.setGroupProperty(PropertyInterface('End', _propertyGroup));
|
||||
view.o.setGroupProperty(PropertyInterface('Offset', _propertyGroup));
|
||||
interfaceFunction.propertyIndex = shape.ix;
|
||||
interfaceFunction.propertyGroup = propertyGroup;
|
||||
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
start: {
|
||||
get: ExpressionPropertyInterface(view.s),
|
||||
},
|
||||
end: {
|
||||
get: ExpressionPropertyInterface(view.e),
|
||||
},
|
||||
offset: {
|
||||
get: ExpressionPropertyInterface(view.o),
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
});
|
||||
interfaceFunction.mn = shape.mn;
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function transformInterfaceFactory(shape, view, propertyGroup) {
|
||||
function interfaceFunction(value) {
|
||||
if (shape.a.ix === value || value === 'Anchor Point') {
|
||||
return interfaceFunction.anchorPoint;
|
||||
}
|
||||
if (shape.o.ix === value || value === 'Opacity') {
|
||||
return interfaceFunction.opacity;
|
||||
}
|
||||
if (shape.p.ix === value || value === 'Position') {
|
||||
return interfaceFunction.position;
|
||||
}
|
||||
if (shape.r.ix === value || value === 'Rotation' || value === 'ADBE Vector Rotation') {
|
||||
return interfaceFunction.rotation;
|
||||
}
|
||||
if (shape.s.ix === value || value === 'Scale') {
|
||||
return interfaceFunction.scale;
|
||||
}
|
||||
if ((shape.sk && shape.sk.ix === value) || value === 'Skew') {
|
||||
return interfaceFunction.skew;
|
||||
}
|
||||
if ((shape.sa && shape.sa.ix === value) || value === 'Skew Axis') {
|
||||
return interfaceFunction.skewAxis;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var _propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
view.transform.mProps.o.setGroupProperty(PropertyInterface('Opacity', _propertyGroup));
|
||||
view.transform.mProps.p.setGroupProperty(PropertyInterface('Position', _propertyGroup));
|
||||
view.transform.mProps.a.setGroupProperty(PropertyInterface('Anchor Point', _propertyGroup));
|
||||
view.transform.mProps.s.setGroupProperty(PropertyInterface('Scale', _propertyGroup));
|
||||
view.transform.mProps.r.setGroupProperty(PropertyInterface('Rotation', _propertyGroup));
|
||||
if (view.transform.mProps.sk) {
|
||||
view.transform.mProps.sk.setGroupProperty(PropertyInterface('Skew', _propertyGroup));
|
||||
view.transform.mProps.sa.setGroupProperty(PropertyInterface('Skew Angle', _propertyGroup));
|
||||
}
|
||||
view.transform.op.setGroupProperty(PropertyInterface('Opacity', _propertyGroup));
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
opacity: {
|
||||
get: ExpressionPropertyInterface(view.transform.mProps.o),
|
||||
},
|
||||
position: {
|
||||
get: ExpressionPropertyInterface(view.transform.mProps.p),
|
||||
},
|
||||
anchorPoint: {
|
||||
get: ExpressionPropertyInterface(view.transform.mProps.a),
|
||||
},
|
||||
scale: {
|
||||
get: ExpressionPropertyInterface(view.transform.mProps.s),
|
||||
},
|
||||
rotation: {
|
||||
get: ExpressionPropertyInterface(view.transform.mProps.r),
|
||||
},
|
||||
skew: {
|
||||
get: ExpressionPropertyInterface(view.transform.mProps.sk),
|
||||
},
|
||||
skewAxis: {
|
||||
get: ExpressionPropertyInterface(view.transform.mProps.sa),
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
});
|
||||
interfaceFunction.ty = 'tr';
|
||||
interfaceFunction.mn = shape.mn;
|
||||
interfaceFunction.propertyGroup = propertyGroup;
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function ellipseInterfaceFactory(shape, view, propertyGroup) {
|
||||
function interfaceFunction(value) {
|
||||
if (shape.p.ix === value) {
|
||||
return interfaceFunction.position;
|
||||
}
|
||||
if (shape.s.ix === value) {
|
||||
return interfaceFunction.size;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var _propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
interfaceFunction.propertyIndex = shape.ix;
|
||||
var prop = view.sh.ty === 'tm' ? view.sh.prop : view.sh;
|
||||
prop.s.setGroupProperty(PropertyInterface('Size', _propertyGroup));
|
||||
prop.p.setGroupProperty(PropertyInterface('Position', _propertyGroup));
|
||||
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
size: {
|
||||
get: ExpressionPropertyInterface(prop.s),
|
||||
},
|
||||
position: {
|
||||
get: ExpressionPropertyInterface(prop.p),
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
});
|
||||
interfaceFunction.mn = shape.mn;
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function starInterfaceFactory(shape, view, propertyGroup) {
|
||||
function interfaceFunction(value) {
|
||||
if (shape.p.ix === value) {
|
||||
return interfaceFunction.position;
|
||||
}
|
||||
if (shape.r.ix === value) {
|
||||
return interfaceFunction.rotation;
|
||||
}
|
||||
if (shape.pt.ix === value) {
|
||||
return interfaceFunction.points;
|
||||
}
|
||||
if (shape.or.ix === value || value === 'ADBE Vector Star Outer Radius') {
|
||||
return interfaceFunction.outerRadius;
|
||||
}
|
||||
if (shape.os.ix === value) {
|
||||
return interfaceFunction.outerRoundness;
|
||||
}
|
||||
if (shape.ir && (shape.ir.ix === value || value === 'ADBE Vector Star Inner Radius')) {
|
||||
return interfaceFunction.innerRadius;
|
||||
}
|
||||
if (shape.is && shape.is.ix === value) {
|
||||
return interfaceFunction.innerRoundness;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var _propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
var prop = view.sh.ty === 'tm' ? view.sh.prop : view.sh;
|
||||
interfaceFunction.propertyIndex = shape.ix;
|
||||
prop.or.setGroupProperty(PropertyInterface('Outer Radius', _propertyGroup));
|
||||
prop.os.setGroupProperty(PropertyInterface('Outer Roundness', _propertyGroup));
|
||||
prop.pt.setGroupProperty(PropertyInterface('Points', _propertyGroup));
|
||||
prop.p.setGroupProperty(PropertyInterface('Position', _propertyGroup));
|
||||
prop.r.setGroupProperty(PropertyInterface('Rotation', _propertyGroup));
|
||||
if (shape.ir) {
|
||||
prop.ir.setGroupProperty(PropertyInterface('Inner Radius', _propertyGroup));
|
||||
prop.is.setGroupProperty(PropertyInterface('Inner Roundness', _propertyGroup));
|
||||
}
|
||||
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
position: {
|
||||
get: ExpressionPropertyInterface(prop.p),
|
||||
},
|
||||
rotation: {
|
||||
get: ExpressionPropertyInterface(prop.r),
|
||||
},
|
||||
points: {
|
||||
get: ExpressionPropertyInterface(prop.pt),
|
||||
},
|
||||
outerRadius: {
|
||||
get: ExpressionPropertyInterface(prop.or),
|
||||
},
|
||||
outerRoundness: {
|
||||
get: ExpressionPropertyInterface(prop.os),
|
||||
},
|
||||
innerRadius: {
|
||||
get: ExpressionPropertyInterface(prop.ir),
|
||||
},
|
||||
innerRoundness: {
|
||||
get: ExpressionPropertyInterface(prop.is),
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
});
|
||||
interfaceFunction.mn = shape.mn;
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function rectInterfaceFactory(shape, view, propertyGroup) {
|
||||
function interfaceFunction(value) {
|
||||
if (shape.p.ix === value) {
|
||||
return interfaceFunction.position;
|
||||
}
|
||||
if (shape.r.ix === value) {
|
||||
return interfaceFunction.roundness;
|
||||
}
|
||||
if (shape.s.ix === value || value === 'Size' || value === 'ADBE Vector Rect Size') {
|
||||
return interfaceFunction.size;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var _propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
|
||||
var prop = view.sh.ty === 'tm' ? view.sh.prop : view.sh;
|
||||
interfaceFunction.propertyIndex = shape.ix;
|
||||
prop.p.setGroupProperty(PropertyInterface('Position', _propertyGroup));
|
||||
prop.s.setGroupProperty(PropertyInterface('Size', _propertyGroup));
|
||||
prop.r.setGroupProperty(PropertyInterface('Rotation', _propertyGroup));
|
||||
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
position: {
|
||||
get: ExpressionPropertyInterface(prop.p),
|
||||
},
|
||||
roundness: {
|
||||
get: ExpressionPropertyInterface(prop.r),
|
||||
},
|
||||
size: {
|
||||
get: ExpressionPropertyInterface(prop.s),
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
});
|
||||
interfaceFunction.mn = shape.mn;
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function roundedInterfaceFactory(shape, view, propertyGroup) {
|
||||
function interfaceFunction(value) {
|
||||
if (shape.r.ix === value || value === 'Round Corners 1') {
|
||||
return interfaceFunction.radius;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var _propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
var prop = view;
|
||||
interfaceFunction.propertyIndex = shape.ix;
|
||||
prop.rd.setGroupProperty(PropertyInterface('Radius', _propertyGroup));
|
||||
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
radius: {
|
||||
get: ExpressionPropertyInterface(prop.rd),
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
});
|
||||
interfaceFunction.mn = shape.mn;
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
function repeaterInterfaceFactory(shape, view, propertyGroup) {
|
||||
function interfaceFunction(value) {
|
||||
if (shape.c.ix === value || value === 'Copies') {
|
||||
return interfaceFunction.copies;
|
||||
} if (shape.o.ix === value || value === 'Offset') {
|
||||
return interfaceFunction.offset;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var _propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
var prop = view;
|
||||
interfaceFunction.propertyIndex = shape.ix;
|
||||
prop.c.setGroupProperty(PropertyInterface('Copies', _propertyGroup));
|
||||
prop.o.setGroupProperty(PropertyInterface('Offset', _propertyGroup));
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
copies: {
|
||||
get: ExpressionPropertyInterface(prop.c),
|
||||
},
|
||||
offset: {
|
||||
get: ExpressionPropertyInterface(prop.o),
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
});
|
||||
interfaceFunction.mn = shape.mn;
|
||||
return interfaceFunction;
|
||||
}
|
||||
|
||||
return function (shapes, view, propertyGroup) {
|
||||
var interfaces;
|
||||
function _interfaceFunction(value) {
|
||||
if (typeof value === 'number') {
|
||||
value = value === undefined ? 1 : value;
|
||||
if (value === 0) {
|
||||
return propertyGroup;
|
||||
}
|
||||
return interfaces[value - 1];
|
||||
}
|
||||
var i = 0;
|
||||
var len = interfaces.length;
|
||||
while (i < len) {
|
||||
if (interfaces[i]._name === value) {
|
||||
return interfaces[i];
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function parentGroupWrapper() {
|
||||
return propertyGroup;
|
||||
}
|
||||
_interfaceFunction.propertyGroup = propertyGroupFactory(_interfaceFunction, parentGroupWrapper);
|
||||
interfaces = iterateElements(shapes, view, _interfaceFunction.propertyGroup);
|
||||
_interfaceFunction.numProperties = interfaces.length;
|
||||
_interfaceFunction._name = 'Contents';
|
||||
return _interfaceFunction;
|
||||
};
|
||||
}());
|
||||
|
||||
export default ShapeExpressionInterface;
|
35
node_modules/lottie-web/player/js/utils/expressions/TextInterface.js
generated
vendored
Normal file
35
node_modules/lottie-web/player/js/utils/expressions/TextInterface.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
const TextExpressionInterface = (function () {
|
||||
return function (elem) {
|
||||
var _sourceText;
|
||||
function _thisLayerFunction(name) {
|
||||
switch (name) {
|
||||
case 'ADBE Text Document':
|
||||
return _thisLayerFunction.sourceText;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Object.defineProperty(_thisLayerFunction, 'sourceText', {
|
||||
get: function () {
|
||||
elem.textProperty.getValue();
|
||||
var stringValue = elem.textProperty.currentData.t;
|
||||
if (!_sourceText || stringValue !== _sourceText.value) {
|
||||
_sourceText = new String(stringValue); // eslint-disable-line no-new-wrappers
|
||||
// If stringValue is an empty string, eval returns undefined, so it has to be returned as a String primitive
|
||||
_sourceText.value = stringValue || new String(stringValue); // eslint-disable-line no-new-wrappers
|
||||
Object.defineProperty(_sourceText, 'style', {
|
||||
get: function () {
|
||||
return {
|
||||
fillColor: elem.textProperty.currentData.fc,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
return _sourceText;
|
||||
},
|
||||
});
|
||||
return _thisLayerFunction;
|
||||
};
|
||||
}());
|
||||
|
||||
export default TextExpressionInterface;
|
44
node_modules/lottie-web/player/js/utils/expressions/TextSelectorPropertyDecorator.js
generated
vendored
Normal file
44
node_modules/lottie-web/player/js/utils/expressions/TextSelectorPropertyDecorator.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import ExpressionManager from './ExpressionManager';
|
||||
import expressionHelpers from './expressionHelpers';
|
||||
import TextSelectorProp from '../text/TextSelectorProperty';
|
||||
|
||||
const TextExpressionSelectorPropFactory = (function () { // eslint-disable-line no-unused-vars
|
||||
function getValueProxy(index, total) {
|
||||
this.textIndex = index + 1;
|
||||
this.textTotal = total;
|
||||
this.v = this.getValue() * this.mult;
|
||||
return this.v;
|
||||
}
|
||||
|
||||
return function (elem, data) {
|
||||
this.pv = 1;
|
||||
this.comp = elem.comp;
|
||||
this.elem = elem;
|
||||
this.mult = 0.01;
|
||||
this.propType = 'textSelector';
|
||||
this.textTotal = data.totalChars;
|
||||
this.selectorValue = 100;
|
||||
this.lastValue = [1, 1, 1];
|
||||
this.k = true;
|
||||
this.x = true;
|
||||
this.getValue = ExpressionManager.initiateExpression.bind(this)(elem, data, this);
|
||||
this.getMult = getValueProxy;
|
||||
this.getVelocityAtTime = expressionHelpers.getVelocityAtTime;
|
||||
if (this.kf) {
|
||||
this.getValueAtTime = expressionHelpers.getValueAtTime.bind(this);
|
||||
} else {
|
||||
this.getValueAtTime = expressionHelpers.getStaticValueAtTime.bind(this);
|
||||
}
|
||||
this.setGroupProperty = expressionHelpers.setGroupProperty;
|
||||
};
|
||||
}());
|
||||
|
||||
var propertyGetTextProp = TextSelectorProp.getTextSelectorProp;
|
||||
TextSelectorProp.getTextSelectorProp = function (elem, data, arr) {
|
||||
if (data.t === 1) {
|
||||
return new TextExpressionSelectorPropFactory(elem, data, arr); // eslint-disable-line no-undef
|
||||
}
|
||||
return propertyGetTextProp(elem, data, arr);
|
||||
};
|
||||
|
||||
export default TextExpressionSelectorPropFactory;
|
126
node_modules/lottie-web/player/js/utils/expressions/TransformInterface.js
generated
vendored
Normal file
126
node_modules/lottie-web/player/js/utils/expressions/TransformInterface.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
import ExpressionPropertyInterface from './ExpressionValueFactory';
|
||||
|
||||
const TransformExpressionInterface = (function () {
|
||||
return function (transform) {
|
||||
function _thisFunction(name) {
|
||||
switch (name) {
|
||||
case 'scale':
|
||||
case 'Scale':
|
||||
case 'ADBE Scale':
|
||||
case 6:
|
||||
return _thisFunction.scale;
|
||||
case 'rotation':
|
||||
case 'Rotation':
|
||||
case 'ADBE Rotation':
|
||||
case 'ADBE Rotate Z':
|
||||
case 10:
|
||||
return _thisFunction.rotation;
|
||||
case 'ADBE Rotate X':
|
||||
return _thisFunction.xRotation;
|
||||
case 'ADBE Rotate Y':
|
||||
return _thisFunction.yRotation;
|
||||
case 'position':
|
||||
case 'Position':
|
||||
case 'ADBE Position':
|
||||
case 2:
|
||||
return _thisFunction.position;
|
||||
case 'ADBE Position_0':
|
||||
return _thisFunction.xPosition;
|
||||
case 'ADBE Position_1':
|
||||
return _thisFunction.yPosition;
|
||||
case 'ADBE Position_2':
|
||||
return _thisFunction.zPosition;
|
||||
case 'anchorPoint':
|
||||
case 'AnchorPoint':
|
||||
case 'Anchor Point':
|
||||
case 'ADBE AnchorPoint':
|
||||
case 1:
|
||||
return _thisFunction.anchorPoint;
|
||||
case 'opacity':
|
||||
case 'Opacity':
|
||||
case 11:
|
||||
return _thisFunction.opacity;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Object.defineProperty(_thisFunction, 'rotation', {
|
||||
get: ExpressionPropertyInterface(transform.r || transform.rz),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'zRotation', {
|
||||
get: ExpressionPropertyInterface(transform.rz || transform.r),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'xRotation', {
|
||||
get: ExpressionPropertyInterface(transform.rx),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'yRotation', {
|
||||
get: ExpressionPropertyInterface(transform.ry),
|
||||
});
|
||||
Object.defineProperty(_thisFunction, 'scale', {
|
||||
get: ExpressionPropertyInterface(transform.s),
|
||||
});
|
||||
var _px;
|
||||
var _py;
|
||||
var _pz;
|
||||
var _transformFactory;
|
||||
if (transform.p) {
|
||||
_transformFactory = ExpressionPropertyInterface(transform.p);
|
||||
} else {
|
||||
_px = ExpressionPropertyInterface(transform.px);
|
||||
_py = ExpressionPropertyInterface(transform.py);
|
||||
if (transform.pz) {
|
||||
_pz = ExpressionPropertyInterface(transform.pz);
|
||||
}
|
||||
}
|
||||
Object.defineProperty(_thisFunction, 'position', {
|
||||
get: function () {
|
||||
if (transform.p) {
|
||||
return _transformFactory();
|
||||
}
|
||||
return [
|
||||
_px(),
|
||||
_py(),
|
||||
_pz ? _pz() : 0];
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'xPosition', {
|
||||
get: ExpressionPropertyInterface(transform.px),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'yPosition', {
|
||||
get: ExpressionPropertyInterface(transform.py),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'zPosition', {
|
||||
get: ExpressionPropertyInterface(transform.pz),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'anchorPoint', {
|
||||
get: ExpressionPropertyInterface(transform.a),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'opacity', {
|
||||
get: ExpressionPropertyInterface(transform.o),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'skew', {
|
||||
get: ExpressionPropertyInterface(transform.sk),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'skewAxis', {
|
||||
get: ExpressionPropertyInterface(transform.sa),
|
||||
});
|
||||
|
||||
Object.defineProperty(_thisFunction, 'orientation', {
|
||||
get: ExpressionPropertyInterface(transform.or),
|
||||
});
|
||||
|
||||
return _thisFunction;
|
||||
};
|
||||
}());
|
||||
|
||||
export default TransformExpressionInterface;
|
86
node_modules/lottie-web/player/js/utils/expressions/expressionHelpers.js
generated
vendored
Normal file
86
node_modules/lottie-web/player/js/utils/expressions/expressionHelpers.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
import {
|
||||
createTypedArray,
|
||||
} from '../helpers/arrays';
|
||||
import ExpressionManager from './ExpressionManager';
|
||||
|
||||
const expressionHelpers = (function () {
|
||||
function searchExpressions(elem, data, prop) {
|
||||
if (data.x) {
|
||||
prop.k = true;
|
||||
prop.x = true;
|
||||
prop.initiateExpression = ExpressionManager.initiateExpression;
|
||||
prop.effectsSequence.push(prop.initiateExpression(elem, data, prop).bind(prop));
|
||||
}
|
||||
}
|
||||
|
||||
function getValueAtTime(frameNum) {
|
||||
frameNum *= this.elem.globalData.frameRate;
|
||||
frameNum -= this.offsetTime;
|
||||
if (frameNum !== this._cachingAtTime.lastFrame) {
|
||||
this._cachingAtTime.lastIndex = this._cachingAtTime.lastFrame < frameNum ? this._cachingAtTime.lastIndex : 0;
|
||||
this._cachingAtTime.value = this.interpolateValue(frameNum, this._cachingAtTime);
|
||||
this._cachingAtTime.lastFrame = frameNum;
|
||||
}
|
||||
return this._cachingAtTime.value;
|
||||
}
|
||||
|
||||
function getSpeedAtTime(frameNum) {
|
||||
var delta = -0.01;
|
||||
var v1 = this.getValueAtTime(frameNum);
|
||||
var v2 = this.getValueAtTime(frameNum + delta);
|
||||
var speed = 0;
|
||||
if (v1.length) {
|
||||
var i;
|
||||
for (i = 0; i < v1.length; i += 1) {
|
||||
speed += Math.pow(v2[i] - v1[i], 2);
|
||||
}
|
||||
speed = Math.sqrt(speed) * 100;
|
||||
} else {
|
||||
speed = 0;
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
function getVelocityAtTime(frameNum) {
|
||||
if (this.vel !== undefined) {
|
||||
return this.vel;
|
||||
}
|
||||
var delta = -0.001;
|
||||
// frameNum += this.elem.data.st;
|
||||
var v1 = this.getValueAtTime(frameNum);
|
||||
var v2 = this.getValueAtTime(frameNum + delta);
|
||||
var velocity;
|
||||
if (v1.length) {
|
||||
velocity = createTypedArray('float32', v1.length);
|
||||
var i;
|
||||
for (i = 0; i < v1.length; i += 1) {
|
||||
// removing frameRate
|
||||
// if needed, don't add it here
|
||||
// velocity[i] = this.elem.globalData.frameRate*((v2[i] - v1[i])/delta);
|
||||
velocity[i] = (v2[i] - v1[i]) / delta;
|
||||
}
|
||||
} else {
|
||||
velocity = (v2 - v1) / delta;
|
||||
}
|
||||
return velocity;
|
||||
}
|
||||
|
||||
function getStaticValueAtTime() {
|
||||
return this.pv;
|
||||
}
|
||||
|
||||
function setGroupProperty(propertyGroup) {
|
||||
this.propertyGroup = propertyGroup;
|
||||
}
|
||||
|
||||
return {
|
||||
searchExpressions: searchExpressions,
|
||||
getSpeedAtTime: getSpeedAtTime,
|
||||
getVelocityAtTime: getVelocityAtTime,
|
||||
getValueAtTime: getValueAtTime,
|
||||
getStaticValueAtTime: getStaticValueAtTime,
|
||||
setGroupProperty: setGroupProperty,
|
||||
};
|
||||
}());
|
||||
|
||||
export default expressionHelpers;
|
47
node_modules/lottie-web/player/js/utils/expressions/shapes/ShapePathInterface.js
generated
vendored
Normal file
47
node_modules/lottie-web/player/js/utils/expressions/shapes/ShapePathInterface.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import propertyGroupFactory from '../PropertyGroupFactory';
|
||||
import PropertyInterface from '../PropertyInterface';
|
||||
|
||||
const ShapePathInterface = (
|
||||
|
||||
function () {
|
||||
return function pathInterfaceFactory(shape, view, propertyGroup) {
|
||||
var prop = view.sh;
|
||||
|
||||
function interfaceFunction(val) {
|
||||
if (val === 'Shape' || val === 'shape' || val === 'Path' || val === 'path' || val === 'ADBE Vector Shape' || val === 2) {
|
||||
return interfaceFunction.path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var _propertyGroup = propertyGroupFactory(interfaceFunction, propertyGroup);
|
||||
prop.setGroupProperty(PropertyInterface('Path', _propertyGroup));
|
||||
Object.defineProperties(interfaceFunction, {
|
||||
path: {
|
||||
get: function () {
|
||||
if (prop.k) {
|
||||
prop.getValue();
|
||||
}
|
||||
return prop;
|
||||
},
|
||||
},
|
||||
shape: {
|
||||
get: function () {
|
||||
if (prop.k) {
|
||||
prop.getValue();
|
||||
}
|
||||
return prop;
|
||||
},
|
||||
},
|
||||
_name: { value: shape.nm },
|
||||
ix: { value: shape.ix },
|
||||
propertyIndex: { value: shape.ix },
|
||||
mn: { value: shape.mn },
|
||||
propertyGroup: { value: propertyGroup },
|
||||
});
|
||||
return interfaceFunction;
|
||||
};
|
||||
}()
|
||||
);
|
||||
|
||||
export default ShapePathInterface;
|
Reference in New Issue
Block a user