@vvfx/ge-ir 0.0.1-beta.5 → 0.0.1-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -8
- package/dist/ge2ir/converter.d.ts +1 -1
- package/dist/ge2ir/parsers/component-parser.d.ts +1 -1
- package/dist/ge2ir/parsers/keyframe-parser.d.ts +1 -1
- package/dist/ge2ir/reverse/blend-mode.d.ts +1 -1
- package/dist/ge2ir/reverse/end-behavior.d.ts +2 -2
- package/dist/ge2ir/types.d.ts +0 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +825 -908
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +821 -909
- package/dist/index.mjs.map +1 -1
- package/dist/ir2ge/assembly/generator.d.ts +7 -9
- package/dist/ir2ge/builders/component.d.ts +4 -4
- package/dist/ir2ge/builders/timing.d.ts +2 -2
- package/dist/ir2ge/index.d.ts +1 -1
- package/dist/ir2ge/ir/anchor-strategy.d.ts +5 -5
- package/dist/ir2ge/ir/layer-dimensions.d.ts +5 -11
- package/dist/ir2ge/ir/layer-utils.d.ts +3 -3
- package/dist/ir2ge/ir/parent-link.d.ts +3 -12
- package/dist/ir2ge/ir/specific.d.ts +2 -4
- package/dist/ir2ge/post-process/ge-mask-remap.d.ts +3 -3
- package/dist/ir2ge/post-process/index.d.ts +1 -1
- package/dist/ir2ge/post-process/visibility.d.ts +5 -5
- package/dist/ir2ge/types.d.ts +1 -1
- package/dist/passthrough.d.ts +15 -0
- package/package.json +2 -2
- package/dist/shared/ge2ir-metadata.d.ts +0 -30
package/dist/index.mjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Description: Galacean Effects and animation IR bidirectional conversion package
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 澄弈
|
|
6
|
-
* Version: v0.0.1-beta.
|
|
6
|
+
* Version: v0.0.1-beta.6
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { IRBlendMode, IRShapePrimitiveType, IRFillType, IRLineCap, IRLineJoin,
|
|
9
|
+
import { IRBlendMode, IRShapePrimitiveType, IRFillType, IRLineCap, IRLineJoin, IREndBehavior, validateIRCompositionOrThrow } from '@vvfx/animation-ir';
|
|
10
10
|
import { v4 } from 'uuid';
|
|
11
11
|
|
|
12
12
|
function _extends() {
|
|
@@ -60,6 +60,92 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
60
60
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/** Read GE layer passthrough data. */ function getEffectsLayerSpecific(ir, layer) {
|
|
64
|
+
var _layer_specific;
|
|
65
|
+
return ir.source === 'effects' ? (_layer_specific = layer.specific) == null ? void 0 : _layer_specific.effects : undefined;
|
|
66
|
+
}
|
|
67
|
+
/** Read GE composition passthrough data. */ function getEffectsCompositionSpecific(ir) {
|
|
68
|
+
var _ir_specific;
|
|
69
|
+
return ir.source === 'effects' ? (_ir_specific = ir.specific) == null ? void 0 : _ir_specific.effects : undefined;
|
|
70
|
+
}
|
|
71
|
+
var EFFECTS_ANIMATION_SPECIFIC_KEYS = [
|
|
72
|
+
'positionOverLifetime',
|
|
73
|
+
'rotationOverLifetime',
|
|
74
|
+
'sizeOverLifetime',
|
|
75
|
+
'colorOverLifetime'
|
|
76
|
+
];
|
|
77
|
+
var KEYS_BY_INVALIDATION_TARGET = {
|
|
78
|
+
position: [
|
|
79
|
+
'positionOverLifetime'
|
|
80
|
+
],
|
|
81
|
+
rotation: [
|
|
82
|
+
'rotationOverLifetime',
|
|
83
|
+
'sourceHierarchy'
|
|
84
|
+
],
|
|
85
|
+
scale: [
|
|
86
|
+
'sizeOverLifetime',
|
|
87
|
+
'sourceHierarchy'
|
|
88
|
+
],
|
|
89
|
+
color: [
|
|
90
|
+
'colorOverLifetime'
|
|
91
|
+
],
|
|
92
|
+
opacity: [
|
|
93
|
+
'colorOverLifetime'
|
|
94
|
+
],
|
|
95
|
+
anchor: [
|
|
96
|
+
'sourceHierarchy'
|
|
97
|
+
],
|
|
98
|
+
mask: [
|
|
99
|
+
'mask'
|
|
100
|
+
],
|
|
101
|
+
precomp: [
|
|
102
|
+
'precompRefId',
|
|
103
|
+
'precompContent'
|
|
104
|
+
]
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Remove raw GE values that would otherwise shadow an edited normalized field.
|
|
108
|
+
* Empty `effects` and `specific` containers are pruned so serialization stays clean.
|
|
109
|
+
*/ function invalidateEffectsLayerSpecific(layer, target) {
|
|
110
|
+
var _layer_specific;
|
|
111
|
+
var effects = (_layer_specific = layer.specific) == null ? void 0 : _layer_specific.effects;
|
|
112
|
+
if (effects == null) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
var removed = [];
|
|
116
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(KEYS_BY_INVALIDATION_TARGET[target]), _step; !(_step = _iterator()).done;){
|
|
117
|
+
var key = _step.value;
|
|
118
|
+
if (key in effects) {
|
|
119
|
+
delete effects[key];
|
|
120
|
+
removed.push(key);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (Object.keys(effects).length === 0 && layer.specific != null) {
|
|
124
|
+
delete layer.specific.effects;
|
|
125
|
+
}
|
|
126
|
+
if (layer.specific != null && Object.keys(layer.specific).length === 0) {
|
|
127
|
+
delete layer.specific;
|
|
128
|
+
}
|
|
129
|
+
return removed;
|
|
130
|
+
}
|
|
131
|
+
/** Whether invalidating opacity would also discard a GE color animation. */ function hasEffectsColorAnimationPassthrough(layer) {
|
|
132
|
+
var _layer_specific_effects, _layer_specific;
|
|
133
|
+
var color = (_layer_specific = layer.specific) == null ? void 0 : (_layer_specific_effects = _layer_specific.effects) == null ? void 0 : _layer_specific_effects.colorOverLifetime;
|
|
134
|
+
if (color == null) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
return Object.keys(color).some(function(channelKey) {
|
|
138
|
+
return channelKey !== 'opacity';
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/** Whether the layer retains any raw GE animation payload. */ function hasEffectsAnimationPassthrough(layer) {
|
|
142
|
+
var _layer_specific;
|
|
143
|
+
var effects = (_layer_specific = layer.specific) == null ? void 0 : _layer_specific.effects;
|
|
144
|
+
return effects != null && EFFECTS_ANIMATION_SPECIFIC_KEYS.some(function(key) {
|
|
145
|
+
return effects[key] != null;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
63
149
|
var DEFAULT_CAMERA_Z = 8;
|
|
64
150
|
var DEFAULT_CAMERA_FOV = 60;
|
|
65
151
|
var DEFAULT_CLIP_MODE = 1;
|
|
@@ -1193,36 +1279,29 @@ function getScalarValue(keyframe, dimensionIndex) {
|
|
|
1193
1279
|
for(var i = 0; i < keyframes.length; i++){
|
|
1194
1280
|
var _kf_outTangent, _kf_inTangent;
|
|
1195
1281
|
var kf = keyframes[i];
|
|
1196
|
-
var normalizedT = normalizeTime(kf.
|
|
1282
|
+
var normalizedT = normalizeTime(kf.frame, timeContext.startFrame, timeContext.endFrame);
|
|
1197
1283
|
timingCurvePoints.push({
|
|
1198
1284
|
t: normalizedT,
|
|
1199
1285
|
outTangent: (_kf_outTangent = kf.outTangent) != null ? _kf_outTangent : DEFAULT_OUT_TANGENT,
|
|
1200
1286
|
inTangent: (_kf_inTangent = kf.inTangent) != null ? _kf_inTangent : DEFAULT_IN_TANGENT
|
|
1201
1287
|
});
|
|
1202
1288
|
if (i < keyframes.length - 1) {
|
|
1203
|
-
var _kf_value,
|
|
1289
|
+
var _kf_value, _ref, _kf_endValue, _startPos_, _startPos_1, _segmentEnd_, _segmentEnd_1;
|
|
1204
1290
|
var nextKf = keyframes[i + 1];
|
|
1205
1291
|
var startPos = (_kf_value = kf.value) != null ? _kf_value : [
|
|
1206
1292
|
0,
|
|
1207
1293
|
0,
|
|
1208
1294
|
0
|
|
1209
1295
|
];
|
|
1210
|
-
|
|
1211
|
-
// nextKf.value is only used later in the path-fixup pass to stitch adjacent segments.
|
|
1212
|
-
var segmentEnd = kf.hold === true ? startPos : (_kf_endValue = kf.endValue) != null ? _kf_endValue : startPos;
|
|
1213
|
-
var stitchEnd = kf.hold === true ? startPos : (_nextKf_value = nextKf.value) != null ? _nextKf_value : [
|
|
1214
|
-
0,
|
|
1215
|
-
0,
|
|
1216
|
-
0
|
|
1217
|
-
];
|
|
1296
|
+
var segmentEnd = kf.hold === true ? startPos : (_ref = (_kf_endValue = kf.endValue) != null ? _kf_endValue : nextKf.value) != null ? _ref : startPos;
|
|
1218
1297
|
pathPoints.push([
|
|
1219
1298
|
[
|
|
1220
1299
|
(_startPos_ = startPos[0]) != null ? _startPos_ : 0,
|
|
1221
1300
|
(_startPos_1 = startPos[1]) != null ? _startPos_1 : 0
|
|
1222
1301
|
],
|
|
1223
1302
|
[
|
|
1224
|
-
(
|
|
1225
|
-
(
|
|
1303
|
+
(_segmentEnd_ = segmentEnd[0]) != null ? _segmentEnd_ : 0,
|
|
1304
|
+
(_segmentEnd_1 = segmentEnd[1]) != null ? _segmentEnd_1 : 0
|
|
1226
1305
|
]
|
|
1227
1306
|
]);
|
|
1228
1307
|
// Spatial control points (per IRKeyframe convention): outgoing CP from
|
|
@@ -1241,11 +1320,11 @@ function getScalarValue(keyframe, dimensionIndex) {
|
|
|
1241
1320
|
(_nextKf_spatialIn_1 = nextKf.spatialIn[1]) != null ? _nextKf_spatialIn_1 : 0
|
|
1242
1321
|
];
|
|
1243
1322
|
} else {
|
|
1244
|
-
var _startPos_2, _startPos_3,
|
|
1323
|
+
var _startPos_2, _startPos_3, _segmentEnd_2, _segmentEnd_3;
|
|
1245
1324
|
var sx = (_startPos_2 = startPos[0]) != null ? _startPos_2 : 0;
|
|
1246
1325
|
var sy = (_startPos_3 = startPos[1]) != null ? _startPos_3 : 0;
|
|
1247
|
-
var ex = (
|
|
1248
|
-
var ey = (
|
|
1326
|
+
var ex = (_segmentEnd_2 = segmentEnd[0]) != null ? _segmentEnd_2 : 0;
|
|
1327
|
+
var ey = (_segmentEnd_3 = segmentEnd[1]) != null ? _segmentEnd_3 : 0;
|
|
1249
1328
|
toPoint = [
|
|
1250
1329
|
-sx / 3 + ex / 3,
|
|
1251
1330
|
-sy / 3 + ey / 3
|
|
@@ -1261,10 +1340,6 @@ function getScalarValue(keyframe, dimensionIndex) {
|
|
|
1261
1340
|
]);
|
|
1262
1341
|
}
|
|
1263
1342
|
}
|
|
1264
|
-
// Fix up path points: adjacent segments should share endpoints
|
|
1265
|
-
for(var i1 = 0; i1 < pathPoints.length - 1; i1++){
|
|
1266
|
-
pathPoints[i1][1] = pathPoints[i1 + 1][0];
|
|
1267
|
-
}
|
|
1268
1343
|
// Prepend a static segment if the first keyframe doesn't start at t=0.
|
|
1269
1344
|
// The bridge segment runs synthetic-at-t=0 → original-kf[0]; for it to be a
|
|
1270
1345
|
// flat hold the END-side tangent (which `buildPositionTimingCurves` reads as
|
|
@@ -1273,7 +1348,7 @@ function getScalarValue(keyframe, dimensionIndex) {
|
|
|
1273
1348
|
// the IR convention leaves a first-kf inTangent undefined, or whatever the
|
|
1274
1349
|
// producer set as a no-op).
|
|
1275
1350
|
if (timingCurvePoints.length > 0 && timingCurvePoints[0].t > 0) {
|
|
1276
|
-
var
|
|
1351
|
+
var _ref1, _ref2;
|
|
1277
1352
|
var _pathPoints_, _pathPoints_1;
|
|
1278
1353
|
timingCurvePoints[0].inTangent = {
|
|
1279
1354
|
x: 1,
|
|
@@ -1291,11 +1366,11 @@ function getScalarValue(keyframe, dimensionIndex) {
|
|
|
1291
1366
|
}
|
|
1292
1367
|
});
|
|
1293
1368
|
pathPoints.unshift([
|
|
1294
|
-
(
|
|
1369
|
+
(_ref1 = (_pathPoints_ = pathPoints[0]) == null ? void 0 : _pathPoints_[0]) != null ? _ref1 : [
|
|
1295
1370
|
0,
|
|
1296
1371
|
0
|
|
1297
1372
|
],
|
|
1298
|
-
(
|
|
1373
|
+
(_ref2 = (_pathPoints_1 = pathPoints[0]) == null ? void 0 : _pathPoints_1[0]) != null ? _ref2 : [
|
|
1299
1374
|
0,
|
|
1300
1375
|
0
|
|
1301
1376
|
]
|
|
@@ -1372,10 +1447,13 @@ function buildCurveForDimension(keyframes, timeContext, dimensionIndex) {
|
|
|
1372
1447
|
var _kf_outTangent, _nextKf_inTangent;
|
|
1373
1448
|
var kf = keyframes[i];
|
|
1374
1449
|
var nextKf = keyframes[i + 1];
|
|
1375
|
-
var t0 = normalizeTime(kf.
|
|
1376
|
-
var t1 = normalizeTime(nextKf.
|
|
1450
|
+
var t0 = normalizeTime(kf.frame, timeContext.startFrame, timeContext.endFrame);
|
|
1451
|
+
var t1 = normalizeTime(nextKf.frame, timeContext.startFrame, timeContext.endFrame);
|
|
1377
1452
|
var v0 = getScalarValue(kf, dimensionIndex);
|
|
1378
|
-
var
|
|
1453
|
+
var endKeyframe = kf.endValue != null ? _extends({}, kf, {
|
|
1454
|
+
value: kf.endValue
|
|
1455
|
+
}) : nextKf;
|
|
1456
|
+
var v1 = kf.hold === true ? v0 : getScalarValue(endKeyframe, dimensionIndex);
|
|
1379
1457
|
var outHandle = kf.hold === true ? {
|
|
1380
1458
|
x: 0,
|
|
1381
1459
|
y: 0
|
|
@@ -1482,20 +1560,11 @@ function buildPositionTimingCurves(points) {
|
|
|
1482
1560
|
}
|
|
1483
1561
|
|
|
1484
1562
|
/**
|
|
1485
|
-
* True when the
|
|
1486
|
-
*
|
|
1487
|
-
|
|
1488
|
-
* Reads `IRLayerReference.linkKind` directly. Producers that don't set the
|
|
1489
|
-
* field (e.g. dsl2ge) effectively get `false` here, which is the correct
|
|
1490
|
-
* default for "full" parent containment.
|
|
1491
|
-
*
|
|
1492
|
-
* Lottie's parser sets `linkKind: 'transform-only'` when a child's parent
|
|
1493
|
-
* relationship comes from `layer.parent` rather than precomp expansion;
|
|
1494
|
-
* `applyPostProcess` consumes this to decide whether to advance the parent's
|
|
1495
|
-
* activation track when the child starts earlier.
|
|
1496
|
-
*/ function isTransformOnlyParentLink(layer) {
|
|
1563
|
+
* True when the child lifetime is independent of its transform parent's
|
|
1564
|
+
* clipping window. An omitted lifetimeMode keeps the legacy clipped default.
|
|
1565
|
+
*/ function hasIndependentParentLifetime(layer) {
|
|
1497
1566
|
var _layer_parent;
|
|
1498
|
-
return ((_layer_parent = layer.parent) == null ? void 0 : _layer_parent.
|
|
1567
|
+
return ((_layer_parent = layer.parent) == null ? void 0 : _layer_parent.lifetimeMode) === 'independent';
|
|
1499
1568
|
}
|
|
1500
1569
|
|
|
1501
1570
|
/**
|
|
@@ -1503,18 +1572,19 @@ function buildPositionTimingCurves(points) {
|
|
|
1503
1572
|
* the time-stretch and offset semantics from `IRTimeContext`.
|
|
1504
1573
|
*
|
|
1505
1574
|
* dsl-source IRs leave `stretch` and `offsetFrame` undefined, in which case
|
|
1506
|
-
* this collapses to `delay = startFrame / fr` and
|
|
1575
|
+
* this collapses to `delay = (startFrame - compositionInPoint) / fr` and
|
|
1507
1576
|
* `duration = (endFrame - startFrame) / fr` — exactly what dsl2ge used to
|
|
1508
1577
|
* compute inline.
|
|
1509
1578
|
*
|
|
1510
1579
|
* Zero/negative durations are clamped to a 0.0001 epsilon so GE keeps the
|
|
1511
1580
|
* activation track alive for the (degenerate) layer.
|
|
1512
|
-
*/ function computeLayerTiming(layer, frameRate) {
|
|
1581
|
+
*/ function computeLayerTiming(layer, frameRate, compositionInPoint) {
|
|
1582
|
+
if (compositionInPoint === void 0) compositionInPoint = 0;
|
|
1513
1583
|
var _time_stretch, _time_offsetFrame;
|
|
1514
1584
|
var time = layer.time;
|
|
1515
1585
|
var stretch = (_time_stretch = time.stretch) != null ? _time_stretch : 1;
|
|
1516
1586
|
var offsetFrame = (_time_offsetFrame = time.offsetFrame) != null ? _time_offsetFrame : 0;
|
|
1517
|
-
var delay = roundNumber((offsetFrame + time.startFrame * stretch) / frameRate, 4);
|
|
1587
|
+
var delay = roundNumber((offsetFrame + time.startFrame * stretch - compositionInPoint) / frameRate, 4);
|
|
1518
1588
|
var rawDuration = (time.endFrame - time.startFrame) * stretch / frameRate;
|
|
1519
1589
|
var layerDuration = rawDuration > 0 ? roundNumber(rawDuration, 4) : 0.0001;
|
|
1520
1590
|
return {
|
|
@@ -1526,37 +1596,29 @@ function buildPositionTimingCurves(points) {
|
|
|
1526
1596
|
function computeStaticPosition(layer, ctx, anchorOffsetX, anchorOffsetY) {
|
|
1527
1597
|
if (anchorOffsetX === void 0) anchorOffsetX = 0;
|
|
1528
1598
|
if (anchorOffsetY === void 0) anchorOffsetY = 0;
|
|
1529
|
-
var _transform_position;
|
|
1599
|
+
var _transform_position, _transform_position1, _transform_position_keyframes_, _transform_position2;
|
|
1530
1600
|
var transform = layer.transform;
|
|
1531
|
-
if (transform == null ? void 0 : (_transform_position = transform.position) == null ? void 0 : _transform_position.keyframed) {
|
|
1601
|
+
if ((transform == null ? void 0 : (_transform_position = transform.position) == null ? void 0 : _transform_position.keyframed) === true && transform.position.keyframes.length !== 1) {
|
|
1532
1602
|
return convert2dTo3dPoint(ctx.width / 2 + anchorOffsetX, ctx.height / 2 + anchorOffsetY, 0, ctx.width, ctx.height);
|
|
1533
1603
|
}
|
|
1534
1604
|
var isNullType = layer.type === 'null' || layer.type === 'precomp';
|
|
1535
|
-
|
|
1605
|
+
var positionValue = (transform == null ? void 0 : (_transform_position1 = transform.position) == null ? void 0 : _transform_position1.keyframed) === true ? (_transform_position_keyframes_ = transform.position.keyframes[0]) == null ? void 0 : _transform_position_keyframes_.value : transform == null ? void 0 : (_transform_position2 = transform.position) == null ? void 0 : _transform_position2.value;
|
|
1606
|
+
if (Array.isArray(positionValue)) {
|
|
1536
1607
|
var _pos_, _pos_1, _pos_2;
|
|
1537
|
-
var pos =
|
|
1608
|
+
var pos = positionValue;
|
|
1538
1609
|
return convert2dTo3dPoint(((_pos_ = pos[0]) != null ? _pos_ : 0) + anchorOffsetX, ((_pos_1 = pos[1]) != null ? _pos_1 : 0) + anchorOffsetY, isNullType ? 0 : (_pos_2 = pos[2]) != null ? _pos_2 : 0, ctx.width, ctx.height);
|
|
1539
1610
|
}
|
|
1540
1611
|
return convert2dTo3dPoint(ctx.width / 2 + anchorOffsetX, ctx.height / 2 + anchorOffsetY, 0, ctx.width, ctx.height);
|
|
1541
1612
|
}
|
|
1542
1613
|
function getStaticAnchor(layer) {
|
|
1543
|
-
var _layer_transform;
|
|
1544
|
-
var
|
|
1545
|
-
if (
|
|
1614
|
+
var _layer_transform_anchor, _layer_transform;
|
|
1615
|
+
var value = (_layer_transform = layer.transform) == null ? void 0 : (_layer_transform_anchor = _layer_transform.anchor) == null ? void 0 : _layer_transform_anchor.value;
|
|
1616
|
+
if (Array.isArray(value) && value.length >= 2) {
|
|
1546
1617
|
return [
|
|
1547
|
-
|
|
1548
|
-
|
|
1618
|
+
value[0],
|
|
1619
|
+
value[1]
|
|
1549
1620
|
];
|
|
1550
1621
|
}
|
|
1551
|
-
if ((anchor == null ? void 0 : anchor.keyframed) && anchor.keyframes != null && anchor.keyframes.length > 0) {
|
|
1552
|
-
var firstVal = anchor.keyframes[0].value;
|
|
1553
|
-
if (Array.isArray(firstVal) && firstVal.length >= 2) {
|
|
1554
|
-
return [
|
|
1555
|
-
firstVal[0],
|
|
1556
|
-
firstVal[1]
|
|
1557
|
-
];
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
1622
|
return [
|
|
1561
1623
|
0,
|
|
1562
1624
|
0
|
|
@@ -1564,15 +1626,21 @@ function getStaticAnchor(layer) {
|
|
|
1564
1626
|
}
|
|
1565
1627
|
function getStaticScaleFromIR(layer) {
|
|
1566
1628
|
var _value_, _value_1;
|
|
1567
|
-
var _layer_transform;
|
|
1629
|
+
var _layer_transform, _scale_keyframes_;
|
|
1568
1630
|
var scale = (_layer_transform = layer.transform) == null ? void 0 : _layer_transform.scale;
|
|
1569
|
-
if (scale == null
|
|
1631
|
+
if (scale == null) {
|
|
1632
|
+
return [
|
|
1633
|
+
1,
|
|
1634
|
+
1
|
|
1635
|
+
];
|
|
1636
|
+
}
|
|
1637
|
+
if (scale.keyframed && scale.keyframes.length !== 1) {
|
|
1570
1638
|
return [
|
|
1571
1639
|
1,
|
|
1572
1640
|
1
|
|
1573
1641
|
];
|
|
1574
1642
|
}
|
|
1575
|
-
var value = scale.value;
|
|
1643
|
+
var value = scale.keyframed ? (_scale_keyframes_ = scale.keyframes[0]) == null ? void 0 : _scale_keyframes_.value : scale.value;
|
|
1576
1644
|
if (!Array.isArray(value)) {
|
|
1577
1645
|
return [
|
|
1578
1646
|
1,
|
|
@@ -1584,14 +1652,15 @@ function getStaticScaleFromIR(layer) {
|
|
|
1584
1652
|
(_value_1 = value[1]) != null ? _value_1 : 1
|
|
1585
1653
|
];
|
|
1586
1654
|
}
|
|
1587
|
-
function applyScalePositionAdjust(position, layer,
|
|
1655
|
+
function applyScalePositionAdjust(position, layer, bounds, ratio) {
|
|
1588
1656
|
var staticScale = getStaticScaleFromIR(layer);
|
|
1589
|
-
|
|
1657
|
+
var x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
|
|
1658
|
+
if (staticScale[0] === 1 && staticScale[1] === 1 || width <= 0 || height <= 0) {
|
|
1590
1659
|
return position;
|
|
1591
1660
|
}
|
|
1592
1661
|
var anchor = getStaticAnchor(layer);
|
|
1593
|
-
var anchorDiffX = anchor[0] -
|
|
1594
|
-
var anchorDiffY = anchor[1] -
|
|
1662
|
+
var anchorDiffX = anchor[0] - (x + width / 2);
|
|
1663
|
+
var anchorDiffY = anchor[1] - (y + height / 2);
|
|
1595
1664
|
if (Math.abs(anchorDiffX) <= 0.5 && Math.abs(anchorDiffY) <= 0.5) {
|
|
1596
1665
|
return position;
|
|
1597
1666
|
}
|
|
@@ -1601,43 +1670,46 @@ function applyScalePositionAdjust(position, layer, layerWidth, layerHeight, rati
|
|
|
1601
1670
|
position[2]
|
|
1602
1671
|
];
|
|
1603
1672
|
}
|
|
1604
|
-
function computeAnchorInfo(layer,
|
|
1673
|
+
function computeAnchorInfo(layer, bounds) {
|
|
1605
1674
|
var anchor = getStaticAnchor(layer);
|
|
1675
|
+
var x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
|
|
1676
|
+
var localAnchorX = anchor[0] - x;
|
|
1677
|
+
var localAnchorY = anchor[1] - y;
|
|
1606
1678
|
var anchorScaleX = 0.5;
|
|
1607
1679
|
var anchorScaleY = 0.5;
|
|
1608
1680
|
var anchorOffsetX = 0;
|
|
1609
1681
|
var anchorOffsetY = 0;
|
|
1610
|
-
if (
|
|
1611
|
-
anchorScaleX =
|
|
1612
|
-
anchorScaleY =
|
|
1613
|
-
anchorOffsetX = -(
|
|
1614
|
-
anchorOffsetY = -(
|
|
1682
|
+
if (width > 0 && height > 0) {
|
|
1683
|
+
anchorScaleX = localAnchorX / width;
|
|
1684
|
+
anchorScaleY = localAnchorY / height;
|
|
1685
|
+
anchorOffsetX = -(localAnchorX - width / 2);
|
|
1686
|
+
anchorOffsetY = -(localAnchorY - height / 2);
|
|
1615
1687
|
}
|
|
1616
|
-
if (layer.type === 'text' && layer.text != null &&
|
|
1688
|
+
if (layer.type === 'text' && layer.text != null && width > 0 && height > 0) {
|
|
1617
1689
|
if (layer.text.anchorAdjust === true) {
|
|
1618
1690
|
if (layer.text.textAlign === 'left') {
|
|
1619
|
-
anchorOffsetX = -(
|
|
1620
|
-
anchorScaleX =
|
|
1691
|
+
anchorOffsetX = -(localAnchorX - width / 2);
|
|
1692
|
+
anchorScaleX = localAnchorX / width - 0.5;
|
|
1621
1693
|
}
|
|
1622
1694
|
if (layer.text.textAlign === 'center') {
|
|
1623
|
-
anchorOffsetX = -
|
|
1624
|
-
anchorScaleX =
|
|
1695
|
+
anchorOffsetX = -localAnchorX;
|
|
1696
|
+
anchorScaleX = localAnchorX / width + 0.5;
|
|
1625
1697
|
}
|
|
1626
1698
|
if (layer.text.textAlign === 'right') {
|
|
1627
|
-
anchorOffsetX = -(
|
|
1628
|
-
anchorScaleX =
|
|
1699
|
+
anchorOffsetX = -(localAnchorX + width / 2);
|
|
1700
|
+
anchorScaleX = localAnchorX / width + 1.5;
|
|
1629
1701
|
}
|
|
1630
1702
|
// GE renders glyphs in the lower half of the quad, so offset by half the
|
|
1631
1703
|
// layer height to align the visible text center with Lottie's anchor.
|
|
1632
|
-
var textHeight =
|
|
1633
|
-
anchorOffsetY = -(
|
|
1634
|
-
anchorScaleY = -
|
|
1704
|
+
var textHeight = height / 2;
|
|
1705
|
+
anchorOffsetY = -(localAnchorY + textHeight);
|
|
1706
|
+
anchorScaleY = -localAnchorY / textHeight;
|
|
1635
1707
|
}
|
|
1636
1708
|
}
|
|
1637
1709
|
var isSpriteForAnchor = layer.type === 'image' || layer.type === 'solid';
|
|
1638
1710
|
var staticRotationZ = getStaticRotationZ(layer);
|
|
1639
1711
|
var hasStaticRotation = staticRotationZ != null;
|
|
1640
|
-
if (isSpriteForAnchor && hasStaticRotation &&
|
|
1712
|
+
if (isSpriteForAnchor && hasStaticRotation && hasIndependentParentLifetime(layer) && (anchorOffsetX !== 0 || anchorOffsetY !== 0)) {
|
|
1641
1713
|
var rotValue = staticRotationZ != null ? staticRotationZ : 0;
|
|
1642
1714
|
if (rotValue !== 0) {
|
|
1643
1715
|
var rad = rotValue * Math.PI / 180;
|
|
@@ -1657,15 +1729,10 @@ function computeAnchorInfo(layer, layerWidth, layerHeight) {
|
|
|
1657
1729
|
};
|
|
1658
1730
|
}
|
|
1659
1731
|
function getStaticRotationZ(layer) {
|
|
1660
|
-
var
|
|
1661
|
-
var
|
|
1662
|
-
if (
|
|
1663
|
-
|
|
1664
|
-
return (_rotation_value_ = rotation.value[2]) != null ? _rotation_value_ : 0;
|
|
1665
|
-
}
|
|
1666
|
-
var separatedRotationZ = (_layer_transform1 = layer.transform) == null ? void 0 : (_layer_transform_separatedRotation = _layer_transform1.separatedRotation) == null ? void 0 : _layer_transform_separatedRotation.z;
|
|
1667
|
-
if (separatedRotationZ != null && !separatedRotationZ.keyframed && typeof separatedRotationZ.value === 'number') {
|
|
1668
|
-
return separatedRotationZ.value;
|
|
1732
|
+
var _layer_transform_rotation, _layer_transform;
|
|
1733
|
+
var rotationZ = (_layer_transform = layer.transform) == null ? void 0 : (_layer_transform_rotation = _layer_transform.rotation) == null ? void 0 : _layer_transform_rotation.z;
|
|
1734
|
+
if (rotationZ != null && !rotationZ.keyframed && typeof rotationZ.value === 'number') {
|
|
1735
|
+
return rotationZ.value;
|
|
1669
1736
|
}
|
|
1670
1737
|
return undefined;
|
|
1671
1738
|
}
|
|
@@ -1676,86 +1743,20 @@ function getTimeContext(layer) {
|
|
|
1676
1743
|
};
|
|
1677
1744
|
}
|
|
1678
1745
|
|
|
1679
|
-
function readGE2IRMetadata(ir, layer) {
|
|
1680
|
-
if (ir.source !== 'ge') {
|
|
1681
|
-
return undefined;
|
|
1682
|
-
}
|
|
1683
|
-
var metadata = layer.metadata;
|
|
1684
|
-
if (metadata == null) {
|
|
1685
|
-
return undefined;
|
|
1686
|
-
}
|
|
1687
|
-
var namespaced = metadata['ge2ir'];
|
|
1688
|
-
if (isRecord$4(namespaced)) {
|
|
1689
|
-
return namespaced;
|
|
1690
|
-
}
|
|
1691
|
-
var legacy = readLegacyGE2IRMetadata(metadata);
|
|
1692
|
-
return Object.keys(legacy).length > 0 ? legacy : undefined;
|
|
1693
|
-
}
|
|
1694
|
-
function readLegacyGE2IRMetadata(metadata) {
|
|
1695
|
-
var legacy = {};
|
|
1696
|
-
var positionOverLifetime = metadata['positionOverLifetime'];
|
|
1697
|
-
var rotationOverLifetime = metadata['rotationOverLifetime'];
|
|
1698
|
-
var sizeOverLifetime = metadata['sizeOverLifetime'];
|
|
1699
|
-
var colorOverLifetime = metadata['colorOverLifetime'];
|
|
1700
|
-
var geComponentId = metadata['geComponentId'];
|
|
1701
|
-
var geMask = metadata['geMask'];
|
|
1702
|
-
var precompRefId = metadata['precompRefId'];
|
|
1703
|
-
var precompContent = metadata['precompContent'];
|
|
1704
|
-
if (isRecord$4(positionOverLifetime)) {
|
|
1705
|
-
legacy.positionOverLifetime = positionOverLifetime;
|
|
1706
|
-
}
|
|
1707
|
-
if (isRecord$4(rotationOverLifetime)) {
|
|
1708
|
-
legacy.rotationOverLifetime = rotationOverLifetime;
|
|
1709
|
-
}
|
|
1710
|
-
if (isRecord$4(sizeOverLifetime)) {
|
|
1711
|
-
legacy.sizeOverLifetime = sizeOverLifetime;
|
|
1712
|
-
}
|
|
1713
|
-
if (isRecord$4(colorOverLifetime)) {
|
|
1714
|
-
legacy.colorOverLifetime = colorOverLifetime;
|
|
1715
|
-
}
|
|
1716
|
-
if (typeof geComponentId === 'string') {
|
|
1717
|
-
legacy.geComponentId = geComponentId;
|
|
1718
|
-
}
|
|
1719
|
-
if (isRecord$4(geMask)) {
|
|
1720
|
-
legacy.geMask = geMask;
|
|
1721
|
-
}
|
|
1722
|
-
if (typeof precompRefId === 'string') {
|
|
1723
|
-
legacy.precompRefId = precompRefId;
|
|
1724
|
-
}
|
|
1725
|
-
if (isRecord$4(precompContent)) {
|
|
1726
|
-
legacy.precompContent = precompContent;
|
|
1727
|
-
}
|
|
1728
|
-
return legacy;
|
|
1729
|
-
}
|
|
1730
|
-
function readGE2IRCompositionMetadata(ir) {
|
|
1731
|
-
if (ir.source !== 'ge') {
|
|
1732
|
-
return undefined;
|
|
1733
|
-
}
|
|
1734
|
-
var metadata = ir.metadata;
|
|
1735
|
-
if (metadata == null) {
|
|
1736
|
-
return undefined;
|
|
1737
|
-
}
|
|
1738
|
-
var namespaced = metadata['ge2ir'];
|
|
1739
|
-
return isRecord$4(namespaced) ? namespaced : undefined;
|
|
1740
|
-
}
|
|
1741
|
-
function isRecord$4(value) {
|
|
1742
|
-
return value != null && (typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && !Array.isArray(value);
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
1746
|
function buildTransformAnimation(layer, ctx) {
|
|
1746
1747
|
var transform = layer.transform;
|
|
1747
1748
|
if (transform == null) {
|
|
1748
1749
|
return {};
|
|
1749
1750
|
}
|
|
1750
1751
|
var timeContext = getTimeContext(layer);
|
|
1751
|
-
// Passthrough: ge2ir stores raw animation data in
|
|
1752
|
+
// Passthrough: ge2ir stores raw animation data in specific.effects to bypass the
|
|
1752
1753
|
// IR keyframe conversion pipeline. Raw GE data is used verbatim when
|
|
1753
1754
|
// available; otherwise the standard IR → GE conversion runs.
|
|
1754
|
-
var
|
|
1755
|
-
var passthroughPosition =
|
|
1756
|
-
var passthroughRotation =
|
|
1757
|
-
var passthroughSize =
|
|
1758
|
-
var positionOverLifetime = passthroughPosition != null ? passthroughPosition : buildPositionAnim(transform, timeContext, ctx);
|
|
1755
|
+
var effectsSpecific = getEffectsLayerSpecific(ctx.ir, layer);
|
|
1756
|
+
var passthroughPosition = effectsSpecific == null ? void 0 : effectsSpecific.positionOverLifetime;
|
|
1757
|
+
var passthroughRotation = effectsSpecific == null ? void 0 : effectsSpecific.rotationOverLifetime;
|
|
1758
|
+
var passthroughSize = effectsSpecific == null ? void 0 : effectsSpecific.sizeOverLifetime;
|
|
1759
|
+
var positionOverLifetime = passthroughPosition != null ? passthroughPosition : buildPositionAnim(layer, transform, timeContext, ctx);
|
|
1759
1760
|
var rotationOverLifetime = passthroughRotation != null ? passthroughRotation : buildRotationAnim(transform, timeContext);
|
|
1760
1761
|
var sizeOverLifetime = passthroughSize != null ? passthroughSize : buildSizeAnim(transform, timeContext);
|
|
1761
1762
|
return {
|
|
@@ -1764,11 +1765,13 @@ function buildTransformAnimation(layer, ctx) {
|
|
|
1764
1765
|
sizeOverLifetime: sizeOverLifetime
|
|
1765
1766
|
};
|
|
1766
1767
|
}
|
|
1767
|
-
function buildPositionAnim(transform, timeContext, ctx) {
|
|
1768
|
+
function buildPositionAnim(layer, transform, timeContext, ctx) {
|
|
1768
1769
|
var _posResult_curves_;
|
|
1770
|
+
var _posResult_pathPoints_;
|
|
1769
1771
|
if (transform.position == null || !transform.position.keyframed) {
|
|
1770
1772
|
return undefined;
|
|
1771
1773
|
}
|
|
1774
|
+
assertContiguousPositionSegments(transform.position, layer);
|
|
1772
1775
|
var posResult = irPositionKeyframesToGE(transform.position, timeContext);
|
|
1773
1776
|
if (posResult == null) {
|
|
1774
1777
|
return undefined;
|
|
@@ -1776,28 +1779,28 @@ function buildPositionAnim(transform, timeContext, ctx) {
|
|
|
1776
1779
|
var pathPoints = [];
|
|
1777
1780
|
var controlPoints = [];
|
|
1778
1781
|
var useKeyframeMode = shouldUseKeyframeMode(transform.position);
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
var point3d = convert2dTo3dPoint(
|
|
1782
|
+
var firstPathPoint = (_posResult_pathPoints_ = posResult.pathPoints[0]) == null ? void 0 : _posResult_pathPoints_[0];
|
|
1783
|
+
if (firstPathPoint != null) {
|
|
1784
|
+
var point3d = convert2dTo3dPoint(firstPathPoint[0], firstPathPoint[1], 0, ctx.width, ctx.height);
|
|
1782
1785
|
pathPoints.push(point3d);
|
|
1783
1786
|
}
|
|
1784
|
-
|
|
1785
|
-
var
|
|
1786
|
-
var
|
|
1787
|
-
pathPoints.push(
|
|
1787
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(posResult.pathPoints), _step; !(_step = _iterator()).done;){
|
|
1788
|
+
var pathPoint = _step.value;
|
|
1789
|
+
var endPoint3d = convert2dTo3dPoint(pathPoint[1][0], pathPoint[1][1], 0, ctx.width, ctx.height);
|
|
1790
|
+
pathPoints.push(endPoint3d);
|
|
1788
1791
|
}
|
|
1789
1792
|
for(var i = 0; i < posResult.controlPoints.length; i++){
|
|
1790
1793
|
var cp = posResult.controlPoints[i];
|
|
1791
|
-
var
|
|
1794
|
+
var pp = posResult.pathPoints[i];
|
|
1792
1795
|
if (useKeyframeMode) {
|
|
1793
|
-
var dx =
|
|
1794
|
-
var dy =
|
|
1795
|
-
var cp1 = convert2dTo3dPoint(dx / 3 +
|
|
1796
|
-
var cp2 = convert2dTo3dPoint(-dx / 3 +
|
|
1796
|
+
var dx = pp[1][0] - pp[0][0];
|
|
1797
|
+
var dy = pp[1][1] - pp[0][1];
|
|
1798
|
+
var cp1 = convert2dTo3dPoint(dx / 3 + pp[0][0], dy / 3 + pp[0][1], 0, ctx.width, ctx.height);
|
|
1799
|
+
var cp2 = convert2dTo3dPoint(-dx / 3 + pp[1][0], -dy / 3 + pp[1][1], 0, ctx.width, ctx.height);
|
|
1797
1800
|
controlPoints.push(cp1, cp2);
|
|
1798
1801
|
} else {
|
|
1799
|
-
var cp11 = convert2dTo3dPoint(cp[0][0] +
|
|
1800
|
-
var cp21 = convert2dTo3dPoint(cp[1][0] +
|
|
1802
|
+
var cp11 = convert2dTo3dPoint(cp[0][0] + pp[0][0], cp[0][1] + pp[0][1], 0, ctx.width, ctx.height);
|
|
1803
|
+
var cp21 = convert2dTo3dPoint(cp[1][0] + pp[1][0], cp[1][1] + pp[1][1], 0, ctx.width, ctx.height);
|
|
1801
1804
|
controlPoints.push(cp11, cp21);
|
|
1802
1805
|
}
|
|
1803
1806
|
}
|
|
@@ -1836,112 +1839,39 @@ function buildPositionAnim(transform, timeContext, ctx) {
|
|
|
1836
1839
|
]
|
|
1837
1840
|
};
|
|
1838
1841
|
}
|
|
1842
|
+
function assertContiguousPositionSegments(position, layer) {
|
|
1843
|
+
var _loop = function(index) {
|
|
1844
|
+
var segmentEnd = position.keyframes[index].endValue;
|
|
1845
|
+
var nextStart = position.keyframes[index + 1].value;
|
|
1846
|
+
if (segmentEnd == null) {
|
|
1847
|
+
return "continue";
|
|
1848
|
+
}
|
|
1849
|
+
var isContiguous = segmentEnd.every(function(value, dimension) {
|
|
1850
|
+
return Math.abs(value - nextStart[dimension]) <= 1e-6;
|
|
1851
|
+
});
|
|
1852
|
+
if (!isContiguous) {
|
|
1853
|
+
throw new Error("[ge-ir] Layer '" + layer.name + "' has a discontiguous position segment at keyframe " + index + "; " + 'GE path animation cannot preserve a segment endValue that differs from the next keyframe value.');
|
|
1854
|
+
}
|
|
1855
|
+
};
|
|
1856
|
+
for(var index = 0; index < position.keyframes.length - 1; index++)_loop(index);
|
|
1857
|
+
}
|
|
1839
1858
|
function buildRotationAnim(transform, timeContext) {
|
|
1840
1859
|
var result = {};
|
|
1841
|
-
var hasZ = false;
|
|
1842
|
-
var hasX = false;
|
|
1843
|
-
var hasY = false;
|
|
1844
1860
|
var rotation = transform.rotation;
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
curves[1]
|
|
1860
|
-
];
|
|
1861
|
-
hasY = true;
|
|
1862
|
-
}
|
|
1863
|
-
if (curves != null && axisHasRotationValue(rotation, 2) && ((_curves_2 = curves[2]) == null ? void 0 : _curves_2.length)) {
|
|
1864
|
-
result['z'] = [
|
|
1865
|
-
ValueType.BEZIER_CURVE,
|
|
1866
|
-
curves[2]
|
|
1867
|
-
];
|
|
1868
|
-
hasZ = true;
|
|
1869
|
-
}
|
|
1870
|
-
} else if (rotation.value != null) {
|
|
1871
|
-
var _rotation_value = rotation.value, tmp = _rotation_value[0], x = tmp === void 0 ? 0 : tmp, tmp1 = _rotation_value[1], y = tmp1 === void 0 ? 0 : tmp1, tmp2 = _rotation_value[2], z = tmp2 === void 0 ? 0 : tmp2;
|
|
1872
|
-
if (Math.abs(x) > 0.0001) {
|
|
1873
|
-
result['x'] = [
|
|
1874
|
-
ValueType.CONSTANT,
|
|
1875
|
-
x
|
|
1876
|
-
];
|
|
1877
|
-
hasX = true;
|
|
1878
|
-
}
|
|
1879
|
-
if (Math.abs(y) > 0.0001) {
|
|
1880
|
-
result['y'] = [
|
|
1881
|
-
ValueType.CONSTANT,
|
|
1882
|
-
y
|
|
1883
|
-
];
|
|
1884
|
-
hasY = true;
|
|
1885
|
-
}
|
|
1886
|
-
if (Math.abs(z) > 0.0001) {
|
|
1887
|
-
result['z'] = [
|
|
1888
|
-
ValueType.CONSTANT,
|
|
1889
|
-
z
|
|
1890
|
-
];
|
|
1891
|
-
hasZ = true;
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
} else {
|
|
1895
|
-
var _separated_x, _separated_x1, _separated_y, _separated_y1, _separated_z, _separated_z1;
|
|
1896
|
-
var separated = transform.separatedRotation;
|
|
1897
|
-
if (separated == null ? void 0 : (_separated_x = separated.x) == null ? void 0 : _separated_x.keyframed) {
|
|
1898
|
-
var curves1 = irScalarKeyframesToGE(separated.x, timeContext);
|
|
1899
|
-
if (curves1 != null) {
|
|
1900
|
-
result['x'] = [
|
|
1901
|
-
ValueType.BEZIER_CURVE,
|
|
1902
|
-
curves1[0]
|
|
1903
|
-
];
|
|
1904
|
-
hasX = true;
|
|
1905
|
-
}
|
|
1906
|
-
} else if ((separated == null ? void 0 : (_separated_x1 = separated.x) == null ? void 0 : _separated_x1.value) != null && separated.x.value !== 0) {
|
|
1907
|
-
result['x'] = [
|
|
1908
|
-
ValueType.CONSTANT,
|
|
1909
|
-
separated.x.value
|
|
1910
|
-
];
|
|
1911
|
-
hasX = true;
|
|
1912
|
-
}
|
|
1913
|
-
if (separated == null ? void 0 : (_separated_y = separated.y) == null ? void 0 : _separated_y.keyframed) {
|
|
1914
|
-
var curves2 = irScalarKeyframesToGE(separated.y, timeContext);
|
|
1915
|
-
if (curves2 != null) {
|
|
1916
|
-
result['y'] = [
|
|
1917
|
-
ValueType.BEZIER_CURVE,
|
|
1918
|
-
curves2[0]
|
|
1919
|
-
];
|
|
1920
|
-
hasY = true;
|
|
1921
|
-
}
|
|
1922
|
-
} else if ((separated == null ? void 0 : (_separated_y1 = separated.y) == null ? void 0 : _separated_y1.value) != null && separated.y.value !== 0) {
|
|
1923
|
-
result['y'] = [
|
|
1924
|
-
ValueType.CONSTANT,
|
|
1925
|
-
separated.y.value
|
|
1926
|
-
];
|
|
1927
|
-
hasY = true;
|
|
1928
|
-
}
|
|
1929
|
-
if (separated == null ? void 0 : (_separated_z = separated.z) == null ? void 0 : _separated_z.keyframed) {
|
|
1930
|
-
var curves3 = irScalarKeyframesToGE(separated.z, timeContext);
|
|
1931
|
-
if (curves3 != null) {
|
|
1932
|
-
result['z'] = [
|
|
1933
|
-
ValueType.BEZIER_CURVE,
|
|
1934
|
-
curves3[0]
|
|
1935
|
-
];
|
|
1936
|
-
hasZ = true;
|
|
1937
|
-
}
|
|
1938
|
-
} else if ((separated == null ? void 0 : (_separated_z1 = separated.z) == null ? void 0 : _separated_z1.value) != null && separated.z.value !== 0) {
|
|
1939
|
-
result['z'] = [
|
|
1940
|
-
ValueType.CONSTANT,
|
|
1941
|
-
separated.z.value
|
|
1942
|
-
];
|
|
1943
|
-
hasZ = true;
|
|
1944
|
-
}
|
|
1861
|
+
var x = buildRotationAxis(rotation == null ? void 0 : rotation.x, timeContext);
|
|
1862
|
+
var y = buildRotationAxis(rotation == null ? void 0 : rotation.y, timeContext);
|
|
1863
|
+
var z = buildRotationAxis(rotation == null ? void 0 : rotation.z, timeContext);
|
|
1864
|
+
var hasX = x != null;
|
|
1865
|
+
var hasY = y != null;
|
|
1866
|
+
var hasZ = z != null;
|
|
1867
|
+
if (x != null) {
|
|
1868
|
+
result['x'] = x;
|
|
1869
|
+
}
|
|
1870
|
+
if (y != null) {
|
|
1871
|
+
result['y'] = y;
|
|
1872
|
+
}
|
|
1873
|
+
if (z != null) {
|
|
1874
|
+
result['z'] = z;
|
|
1945
1875
|
}
|
|
1946
1876
|
if (!hasZ && !hasX && !hasY) {
|
|
1947
1877
|
return undefined;
|
|
@@ -1953,25 +1883,46 @@ function buildRotationAnim(transform, timeContext) {
|
|
|
1953
1883
|
}
|
|
1954
1884
|
return result;
|
|
1955
1885
|
}
|
|
1956
|
-
function
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1886
|
+
function buildRotationAxis(property, timeContext) {
|
|
1887
|
+
if (property == null) {
|
|
1888
|
+
return undefined;
|
|
1889
|
+
}
|
|
1890
|
+
if (!property.keyframed) {
|
|
1891
|
+
return property.value !== 0 ? [
|
|
1892
|
+
ValueType.CONSTANT,
|
|
1893
|
+
property.value
|
|
1894
|
+
] : undefined;
|
|
1895
|
+
}
|
|
1896
|
+
if (property.keyframes.length === 1) {
|
|
1897
|
+
var value = property.keyframes[0].value;
|
|
1898
|
+
return value !== 0 ? [
|
|
1899
|
+
ValueType.CONSTANT,
|
|
1900
|
+
value
|
|
1901
|
+
] : undefined;
|
|
1902
|
+
}
|
|
1903
|
+
if (!axisHasRotationValue(property)) {
|
|
1904
|
+
return undefined;
|
|
1963
1905
|
}
|
|
1964
|
-
|
|
1965
|
-
|
|
1906
|
+
var curves = irScalarKeyframesToGE(property, timeContext);
|
|
1907
|
+
return curves != null ? [
|
|
1908
|
+
ValueType.BEZIER_CURVE,
|
|
1909
|
+
curves[0]
|
|
1910
|
+
] : undefined;
|
|
1911
|
+
}
|
|
1912
|
+
function axisHasRotationValue(rotation) {
|
|
1913
|
+
return rotation.keyframes.some(function(keyframe) {
|
|
1966
1914
|
var _keyframe_endValue;
|
|
1967
|
-
return Math.abs(
|
|
1968
|
-
})
|
|
1915
|
+
return Math.abs(keyframe.value) > 0.0001 || Math.abs((_keyframe_endValue = keyframe.endValue) != null ? _keyframe_endValue : 0) > 0.0001;
|
|
1916
|
+
});
|
|
1969
1917
|
}
|
|
1970
1918
|
function buildSizeAnim(transform, timeContext) {
|
|
1971
1919
|
if (transform.scale == null) {
|
|
1972
1920
|
return undefined;
|
|
1973
1921
|
}
|
|
1974
1922
|
if (transform.scale.keyframed) {
|
|
1923
|
+
if (transform.scale.keyframes.length === 1) {
|
|
1924
|
+
return buildConstantSizeAnimation(transform.scale.keyframes[0].value);
|
|
1925
|
+
}
|
|
1975
1926
|
var curves = irVectorKeyframesToGE(transform.scale, timeContext);
|
|
1976
1927
|
if (curves != null && curves.length >= 2) {
|
|
1977
1928
|
return _extends({
|
|
@@ -1993,30 +1944,31 @@ function buildSizeAnim(transform, timeContext) {
|
|
|
1993
1944
|
}
|
|
1994
1945
|
return undefined;
|
|
1995
1946
|
}
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
x: [
|
|
2002
|
-
ValueType.CONSTANT,
|
|
2003
|
-
scale[0]
|
|
2004
|
-
],
|
|
2005
|
-
y: [
|
|
2006
|
-
ValueType.CONSTANT,
|
|
2007
|
-
scale[1]
|
|
2008
|
-
],
|
|
2009
|
-
z: [
|
|
2010
|
-
ValueType.CONSTANT,
|
|
2011
|
-
(_scale_ = scale[2]) != null ? _scale_ : 1
|
|
2012
|
-
]
|
|
2013
|
-
};
|
|
1947
|
+
return buildConstantSizeAnimation(transform.scale.value);
|
|
1948
|
+
}
|
|
1949
|
+
function buildConstantSizeAnimation(scale) {
|
|
1950
|
+
if (Math.abs(scale[0] - 1) <= 0.0001 && Math.abs(scale[1] - 1) <= 0.0001) {
|
|
1951
|
+
return undefined;
|
|
2014
1952
|
}
|
|
2015
|
-
return
|
|
1953
|
+
return {
|
|
1954
|
+
separateAxes: true,
|
|
1955
|
+
x: [
|
|
1956
|
+
ValueType.CONSTANT,
|
|
1957
|
+
scale[0]
|
|
1958
|
+
],
|
|
1959
|
+
y: [
|
|
1960
|
+
ValueType.CONSTANT,
|
|
1961
|
+
scale[1]
|
|
1962
|
+
],
|
|
1963
|
+
z: [
|
|
1964
|
+
ValueType.CONSTANT,
|
|
1965
|
+
scale[2]
|
|
1966
|
+
]
|
|
1967
|
+
};
|
|
2016
1968
|
}
|
|
2017
1969
|
function buildColorAnimation(layer, ir) {
|
|
2018
|
-
var
|
|
2019
|
-
var passthroughColor = (
|
|
1970
|
+
var _getEffectsLayerSpecific;
|
|
1971
|
+
var passthroughColor = (_getEffectsLayerSpecific = getEffectsLayerSpecific(ir, layer)) == null ? void 0 : _getEffectsLayerSpecific.colorOverLifetime;
|
|
2020
1972
|
if (passthroughColor != null) {
|
|
2021
1973
|
return passthroughColor;
|
|
2022
1974
|
}
|
|
@@ -2034,6 +1986,15 @@ function buildColorAnimation(layer, ir) {
|
|
|
2034
1986
|
};
|
|
2035
1987
|
}
|
|
2036
1988
|
if (transform.opacity.keyframed) {
|
|
1989
|
+
if (transform.opacity.keyframes.length === 1) {
|
|
1990
|
+
var opacityValue = transform.opacity.keyframes[0].value;
|
|
1991
|
+
return opacityValue !== 1 ? {
|
|
1992
|
+
opacity: [
|
|
1993
|
+
ValueType.CONSTANT,
|
|
1994
|
+
opacityValue
|
|
1995
|
+
]
|
|
1996
|
+
} : undefined;
|
|
1997
|
+
}
|
|
2037
1998
|
var curves = irScalarKeyframesToGE(transform.opacity, timeContext);
|
|
2038
1999
|
if (curves != null) {
|
|
2039
2000
|
return {
|
|
@@ -2045,12 +2006,12 @@ function buildColorAnimation(layer, ir) {
|
|
|
2045
2006
|
}
|
|
2046
2007
|
return undefined;
|
|
2047
2008
|
}
|
|
2048
|
-
var
|
|
2049
|
-
if (typeof
|
|
2009
|
+
var opacityValue1 = transform.opacity.value;
|
|
2010
|
+
if (typeof opacityValue1 === 'number' && opacityValue1 !== 1) {
|
|
2050
2011
|
return {
|
|
2051
2012
|
opacity: [
|
|
2052
2013
|
ValueType.CONSTANT,
|
|
2053
|
-
|
|
2014
|
+
opacityValue1
|
|
2054
2015
|
]
|
|
2055
2016
|
};
|
|
2056
2017
|
}
|
|
@@ -2132,18 +2093,20 @@ function mapBlendingMode(blendMode) {
|
|
|
2132
2093
|
return GE_BLENDING_BY_IR_MODE[blendMode];
|
|
2133
2094
|
}
|
|
2134
2095
|
|
|
2135
|
-
var
|
|
2096
|
+
var DEFAULT_LOCAL_BOUNDS = {
|
|
2097
|
+
x: 0,
|
|
2098
|
+
y: 0,
|
|
2136
2099
|
width: 1,
|
|
2137
2100
|
height: 1
|
|
2138
2101
|
};
|
|
2139
2102
|
/**
|
|
2140
|
-
* Read
|
|
2141
|
-
* did not resolve one, returns `fallback` (defaults to
|
|
2142
|
-
*
|
|
2143
|
-
*/ function
|
|
2144
|
-
if (fallback === void 0) fallback =
|
|
2145
|
-
var
|
|
2146
|
-
return (
|
|
2103
|
+
* Read source-neutral local bounds from an IR layer. When the producer
|
|
2104
|
+
* did not resolve one, returns `fallback` (defaults to bounds at the origin
|
|
2105
|
+
* with a one-pixel width and height).
|
|
2106
|
+
*/ function getLayerLocalBounds(layer, fallback) {
|
|
2107
|
+
if (fallback === void 0) fallback = DEFAULT_LOCAL_BOUNDS;
|
|
2108
|
+
var _layer_localBounds;
|
|
2109
|
+
return (_layer_localBounds = layer.localBounds) != null ? _layer_localBounds : fallback;
|
|
2147
2110
|
}
|
|
2148
2111
|
|
|
2149
2112
|
function buildComponent(layer, itemId, anchorScaleX, anchorScaleY, ctx) {
|
|
@@ -2160,21 +2123,20 @@ function buildComponent(layer, itemId, anchorScaleX, anchorScaleY, ctx) {
|
|
|
2160
2123
|
}
|
|
2161
2124
|
}
|
|
2162
2125
|
/**
|
|
2163
|
-
* Copy the raw GE mask object (from
|
|
2126
|
+
* Copy the raw GE mask object (from specific.effects passthrough) onto a freshly
|
|
2164
2127
|
* built component, as a top-level `mask` field matching GE's structure. For a
|
|
2165
2128
|
* mask SOURCE this carries `{isMask:true, alphaMaskEnabled}`; for a TARGET it
|
|
2166
2129
|
* carries `{isMask:false, reference, inverted}` where `reference.id` is still
|
|
2167
|
-
* the stale GE1 component id — `
|
|
2168
|
-
* No-op for non-
|
|
2169
|
-
*/ function
|
|
2170
|
-
var
|
|
2171
|
-
var
|
|
2172
|
-
if (
|
|
2173
|
-
component['mask'] = _extends({},
|
|
2130
|
+
* the stale GE1 component id — `applyGEMaskRemap` rewrites it in post-process.
|
|
2131
|
+
* No-op for non-GE sources (Lottie masks go through the IRLayerNode.mask path).
|
|
2132
|
+
*/ function applyGEMask(ir, layer, component) {
|
|
2133
|
+
var _getEffectsLayerSpecific;
|
|
2134
|
+
var effectsMask = (_getEffectsLayerSpecific = getEffectsLayerSpecific(ir, layer)) == null ? void 0 : _getEffectsLayerSpecific.mask;
|
|
2135
|
+
if (effectsMask != null && component['mask'] == null) {
|
|
2136
|
+
component['mask'] = _extends({}, effectsMask);
|
|
2174
2137
|
}
|
|
2175
2138
|
}
|
|
2176
2139
|
function buildSpriteComponent(layer, itemId, anchorScaleX, anchorScaleY, ctx) {
|
|
2177
|
-
var _ref;
|
|
2178
2140
|
var _layer_asset, _layer_asset1;
|
|
2179
2141
|
var componentId = createId();
|
|
2180
2142
|
var blending = mapBlendingMode(layer.blendMode);
|
|
@@ -2190,7 +2152,8 @@ function buildSpriteComponent(layer, itemId, anchorScaleX, anchorScaleY, ctx) {
|
|
|
2190
2152
|
1
|
|
2191
2153
|
];
|
|
2192
2154
|
var textureDataPath;
|
|
2193
|
-
var
|
|
2155
|
+
var assetUrl = (_layer_asset = layer.asset) == null ? void 0 : _layer_asset.url;
|
|
2156
|
+
var textureUrl = assetUrl != null && assetUrl !== '' ? assetUrl : (_layer_asset1 = layer.asset) == null ? void 0 : _layer_asset1.refId;
|
|
2194
2157
|
if (textureUrl != null && textureUrl !== '' && textureUrl !== 'mask://placeholder') {
|
|
2195
2158
|
textureDataPath = registerTexture(ctx.collector, textureUrl, ctx.textureCache);
|
|
2196
2159
|
}
|
|
@@ -2216,7 +2179,7 @@ function buildSpriteComponent(layer, itemId, anchorScaleX, anchorScaleY, ctx) {
|
|
|
2216
2179
|
roundNumber(anchorScaleY, 4)
|
|
2217
2180
|
];
|
|
2218
2181
|
}
|
|
2219
|
-
|
|
2182
|
+
applyGEMask(ctx.ir, layer, component);
|
|
2220
2183
|
ctx.collector.components.push(component);
|
|
2221
2184
|
return componentId;
|
|
2222
2185
|
}
|
|
@@ -2237,7 +2200,7 @@ function buildTextComponent(layer, itemId, anchorScaleX, anchorScaleY, ctx) {
|
|
|
2237
2200
|
var textWidth = (_textInfo_width = textInfo.width) != null ? _textInfo_width : estimateTextWidth(textInfo.content, textInfo.fontSize, textInfo.letterSpacing);
|
|
2238
2201
|
var lineHeight = typeof textInfo.lineHeight === 'number' && textInfo.lineHeight > 0 ? textInfo.lineHeight : textInfo.fontSize;
|
|
2239
2202
|
var textHeight = Math.max((_textInfo_height = textInfo.height) != null ? _textInfo_height : textInfo.fontSize * 1.2, lineHeight);
|
|
2240
|
-
var
|
|
2203
|
+
var _getLayerLocalBounds = getLayerLocalBounds(layer), layerWidth = _getLayerLocalBounds.width, layerHeight = _getLayerLocalBounds.height;
|
|
2241
2204
|
var textSizeW = roundNumber(ctx.ratio * layerWidth, 4);
|
|
2242
2205
|
var textSizeH = roundNumber(ctx.ratio * layerHeight, 4);
|
|
2243
2206
|
var component = {
|
|
@@ -2272,7 +2235,7 @@ function buildTextComponent(layer, itemId, anchorScaleX, anchorScaleY, ctx) {
|
|
|
2272
2235
|
blending: blending
|
|
2273
2236
|
})
|
|
2274
2237
|
};
|
|
2275
|
-
|
|
2238
|
+
applyGEMask(ctx.ir, layer, component);
|
|
2276
2239
|
ctx.collector.components.push(component);
|
|
2277
2240
|
return componentId;
|
|
2278
2241
|
}
|
|
@@ -2294,7 +2257,7 @@ function buildShapeComponent(layer, itemId, ctx) {
|
|
|
2294
2257
|
blending: blending
|
|
2295
2258
|
})
|
|
2296
2259
|
});
|
|
2297
|
-
|
|
2260
|
+
applyGEMask(ctx.ir, layer, component);
|
|
2298
2261
|
ctx.collector.components.push(component);
|
|
2299
2262
|
return componentId;
|
|
2300
2263
|
}
|
|
@@ -2302,21 +2265,35 @@ function buildShapeOptions(shapeData, ratio, ctx) {
|
|
|
2302
2265
|
var options = {
|
|
2303
2266
|
type: mapShapePrimitiveType(shapeData.primitiveType)
|
|
2304
2267
|
};
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2268
|
+
switch(shapeData.primitiveType){
|
|
2269
|
+
case IRShapePrimitiveType.Custom:
|
|
2270
|
+
Object.assign(options, mapCustomPaths(shapeData.customPaths, ratio));
|
|
2271
|
+
break;
|
|
2272
|
+
case IRShapePrimitiveType.Rectangle:
|
|
2273
|
+
var _shapeData_roundness;
|
|
2274
|
+
options['width'] = roundNumber(shapeData.width * ratio, 4);
|
|
2275
|
+
options['height'] = roundNumber(shapeData.height * ratio, 4);
|
|
2276
|
+
options['roundness'] = (_shapeData_roundness = shapeData.roundness) != null ? _shapeData_roundness : 0;
|
|
2277
|
+
break;
|
|
2278
|
+
case IRShapePrimitiveType.Ellipse:
|
|
2279
|
+
options['xRadius'] = roundNumber(shapeData.xRadius * ratio, 4);
|
|
2280
|
+
options['yRadius'] = roundNumber(shapeData.yRadius * ratio, 4);
|
|
2281
|
+
break;
|
|
2282
|
+
case IRShapePrimitiveType.Polygon:
|
|
2283
|
+
var _shapeData_roundness1;
|
|
2284
|
+
options['pointCount'] = shapeData.pointCount;
|
|
2285
|
+
options['radius'] = roundNumber(shapeData.radius * ratio, 4);
|
|
2286
|
+
options['roundness'] = (_shapeData_roundness1 = shapeData.roundness) != null ? _shapeData_roundness1 : 0;
|
|
2287
|
+
break;
|
|
2288
|
+
case IRShapePrimitiveType.Star:
|
|
2289
|
+
var _shapeData_innerRoundness, _shapeData_outerRoundness;
|
|
2290
|
+
options['pointCount'] = shapeData.pointCount;
|
|
2291
|
+
options['innerRadius'] = roundNumber(shapeData.innerRadius * ratio, 4);
|
|
2292
|
+
options['outerRadius'] = roundNumber(shapeData.outerRadius * ratio, 4);
|
|
2293
|
+
options['innerRoundness'] = (_shapeData_innerRoundness = shapeData.innerRoundness) != null ? _shapeData_innerRoundness : 0;
|
|
2294
|
+
options['outerRoundness'] = (_shapeData_outerRoundness = shapeData.outerRoundness) != null ? _shapeData_outerRoundness : 0;
|
|
2295
|
+
break;
|
|
2296
|
+
}
|
|
2320
2297
|
if (shapeData.fills != null && shapeData.fills.length > 0) {
|
|
2321
2298
|
options['fills'] = shapeData.fills.map(function(fill) {
|
|
2322
2299
|
return mapShapePaint(fill, ratio, ctx);
|
|
@@ -2344,18 +2321,6 @@ function buildShapeOptions(shapeData, ratio, ctx) {
|
|
|
2344
2321
|
if (shapeData.strokeJoin != null) {
|
|
2345
2322
|
options['strokeJoin'] = mapLineJoin(shapeData.strokeJoin);
|
|
2346
2323
|
}
|
|
2347
|
-
if (shapeData.fillRule != null) {
|
|
2348
|
-
options['fillRule'] = mapShapeFillRule(shapeData.fillRule);
|
|
2349
|
-
}
|
|
2350
|
-
if (shapeData.customPaths != null && shapeData.customPaths.length > 0) {
|
|
2351
|
-
Object.assign(options, mapCustomPaths(shapeData.customPaths, ratio));
|
|
2352
|
-
}
|
|
2353
|
-
if (shapeData.trimPath != null) {
|
|
2354
|
-
options['trimPath'] = shapeData.trimPath;
|
|
2355
|
-
}
|
|
2356
|
-
if (shapeData.repeater != null) {
|
|
2357
|
-
options['repeater'] = shapeData.repeater;
|
|
2358
|
-
}
|
|
2359
2324
|
return options;
|
|
2360
2325
|
}
|
|
2361
2326
|
var _obj;
|
|
@@ -2366,8 +2331,6 @@ var _obj2;
|
|
|
2366
2331
|
var LINE_CAP_TO_GE = (_obj2 = {}, _obj2[IRLineCap.Butt] = 0, _obj2[IRLineCap.Round] = 1, _obj2[IRLineCap.Square] = 2, _obj2);
|
|
2367
2332
|
var _obj3;
|
|
2368
2333
|
var LINE_JOIN_TO_GE = (_obj3 = {}, _obj3[IRLineJoin.Round] = 0, _obj3[IRLineJoin.Bevel] = 1, _obj3[IRLineJoin.Miter] = 2, _obj3);
|
|
2369
|
-
var _obj4;
|
|
2370
|
-
var SHAPE_FILL_RULE_TO_GE = (_obj4 = {}, _obj4[IRShapeFillRule.NonZero] = 0, _obj4[IRShapeFillRule.EvenOdd] = 1, _obj4);
|
|
2371
2334
|
function mapShapePrimitiveType(primitiveType) {
|
|
2372
2335
|
return SHAPE_PRIMITIVE_TYPE_TO_GE[primitiveType];
|
|
2373
2336
|
}
|
|
@@ -2379,10 +2342,6 @@ function mapLineJoin(lineJoin) {
|
|
|
2379
2342
|
var _LINE_JOIN_TO_GE_lineJoin;
|
|
2380
2343
|
return (_LINE_JOIN_TO_GE_lineJoin = LINE_JOIN_TO_GE[lineJoin]) != null ? _LINE_JOIN_TO_GE_lineJoin : 2;
|
|
2381
2344
|
}
|
|
2382
|
-
function mapShapeFillRule(fillRule) {
|
|
2383
|
-
var _SHAPE_FILL_RULE_TO_GE_fillRule;
|
|
2384
|
-
return (_SHAPE_FILL_RULE_TO_GE_fillRule = SHAPE_FILL_RULE_TO_GE[fillRule]) != null ? _SHAPE_FILL_RULE_TO_GE_fillRule : 0;
|
|
2385
|
-
}
|
|
2386
2345
|
function mapShapePaint(paint, ratio, ctx) {
|
|
2387
2346
|
if (paint.type === IRFillType.Solid) {
|
|
2388
2347
|
return {
|
|
@@ -2391,7 +2350,7 @@ function mapShapePaint(paint, ratio, ctx) {
|
|
|
2391
2350
|
};
|
|
2392
2351
|
}
|
|
2393
2352
|
if (paint.type === IRFillType.LinearGradient || paint.type === IRFillType.RadialGradient || paint.type === IRFillType.AngularGradient) {
|
|
2394
|
-
return
|
|
2353
|
+
return {
|
|
2395
2354
|
type: FILL_TYPE_TO_GE[paint.type],
|
|
2396
2355
|
gradientStops: [
|
|
2397
2356
|
ValueType.GRADIENT_COLOR,
|
|
@@ -2399,13 +2358,12 @@ function mapShapePaint(paint, ratio, ctx) {
|
|
|
2399
2358
|
],
|
|
2400
2359
|
startPoint: vec2ToGE(paint.gradientStart, ratio),
|
|
2401
2360
|
endPoint: vec2ToGE(paint.gradientEnd, ratio)
|
|
2402
|
-
}
|
|
2403
|
-
color: colorToGE(paint.color)
|
|
2404
|
-
});
|
|
2361
|
+
};
|
|
2405
2362
|
}
|
|
2406
2363
|
if (paint.type === IRFillType.Texture) {
|
|
2407
|
-
var
|
|
2408
|
-
var
|
|
2364
|
+
var _paint_scaleMode;
|
|
2365
|
+
var textureAssetUrl = paint.texture.url;
|
|
2366
|
+
var textureUrl = textureAssetUrl != null && textureAssetUrl !== '' ? textureAssetUrl : paint.texture.refId;
|
|
2409
2367
|
var texture = textureUrl != null && ctx != null ? registerTexture(ctx.collector, textureUrl, ctx.textureCache) : undefined;
|
|
2410
2368
|
return _extends({
|
|
2411
2369
|
type: FILL_TYPE_TO_GE[paint.type]
|
|
@@ -2443,8 +2401,8 @@ function mapCustomPaths(paths, ratio) {
|
|
|
2443
2401
|
for(var index = 0; index < path.points.length; index++){
|
|
2444
2402
|
var _ref, _ref1, _ref2, _ref3;
|
|
2445
2403
|
var point = path.points[index];
|
|
2446
|
-
var easingIn = path.
|
|
2447
|
-
var easingOut = path.
|
|
2404
|
+
var easingIn = path.inTangents[index];
|
|
2405
|
+
var easingOut = path.outTangents[index];
|
|
2448
2406
|
var pointIndex = points.length;
|
|
2449
2407
|
points.push({
|
|
2450
2408
|
x: roundNumber(point.x * ratio, 4),
|
|
@@ -2465,7 +2423,7 @@ function mapCustomPaths(paths, ratio) {
|
|
|
2465
2423
|
});
|
|
2466
2424
|
}
|
|
2467
2425
|
shapes.push({
|
|
2468
|
-
close: path.
|
|
2426
|
+
close: path.closed,
|
|
2469
2427
|
indexes: indexes
|
|
2470
2428
|
});
|
|
2471
2429
|
}
|
|
@@ -2476,100 +2434,54 @@ function mapCustomPaths(paths, ratio) {
|
|
|
2476
2434
|
shapes: shapes
|
|
2477
2435
|
};
|
|
2478
2436
|
}
|
|
2479
|
-
function setScaledNumber(options, shapeData, key, ratio) {
|
|
2480
|
-
var value = shapeData[key];
|
|
2481
|
-
if (typeof value === 'number') {
|
|
2482
|
-
options[key] = roundNumber(value * ratio, 4);
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
|
-
function setRawNumber(options, shapeData, key) {
|
|
2486
|
-
var value = shapeData[key];
|
|
2487
|
-
if (typeof value === 'number') {
|
|
2488
|
-
options[key] = value;
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
2437
|
|
|
2492
|
-
function
|
|
2493
|
-
|
|
2438
|
+
function planGELayerLowering(ir, layer) {
|
|
2439
|
+
var _getEffectsLayerSpecific;
|
|
2440
|
+
var sourceHierarchy = (_getEffectsLayerSpecific = getEffectsLayerSpecific(ir, layer)) == null ? void 0 : _getEffectsLayerSpecific.sourceHierarchy;
|
|
2441
|
+
if (sourceHierarchy === 'null-sprite-pair') {
|
|
2494
2442
|
return {
|
|
2495
2443
|
kind: 'split-null-sprite'
|
|
2496
2444
|
};
|
|
2497
2445
|
}
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
// full input set (text anchorAdjust, static-rotation anchor rotation, display
|
|
2501
|
-
// size fallback) into the producer, at high cost with no readability benefit.
|
|
2502
|
-
// The split gate itself is already pre-baked via `transformSplit` above.
|
|
2503
|
-
//
|
|
2504
|
-
// ge source shares the lottie inline-anchor math: ge2ir reverses GE's
|
|
2505
|
-
// `renderer.anchor` into IRLayerNode.transform.anchor (px) + displaySize, so
|
|
2506
|
-
// computeAnchorInfo reproduces the exact anchorScale/anchorOffset that GE had.
|
|
2507
|
-
// Without this, ge layers fall through to the centered [0.5,0.5] default and
|
|
2508
|
-
// their authored anchor (e.g. a top-anchored sweep) is lost on round-trip.
|
|
2509
|
-
// ge never reaches the lottieNeedsTransformSplit geometry check — its split
|
|
2510
|
-
// decision is pre-baked via `transformSplit` by the ge2ir null+sprite merger.
|
|
2511
|
-
if (ir.source === 'lottie' || ir.source === 'ge') {
|
|
2512
|
-
if (ir.source === 'lottie' && lottieNeedsTransformSplit(layer)) {
|
|
2513
|
-
return {
|
|
2514
|
-
kind: 'split-null-sprite'
|
|
2515
|
-
};
|
|
2516
|
-
}
|
|
2517
|
-
// The inline-anchor math needs non-zero dimensions to avoid divide-by-zero
|
|
2518
|
-
// in `computeAnchorInfo`; substitute the legacy {1, 1} fallback at the call site
|
|
2519
|
-
// so the field-level default stays neutral.
|
|
2520
|
-
var _getLayerDisplaySize = getLayerDisplaySize(layer), width = _getLayerDisplaySize.width, height = _getLayerDisplaySize.height;
|
|
2521
|
-
var info = computeAnchorInfo(layer, width, height);
|
|
2446
|
+
var bounds = getLayerLocalBounds(layer);
|
|
2447
|
+
if (sourceHierarchy !== 'single-item' && needsPivotContainer(layer, bounds)) {
|
|
2522
2448
|
return {
|
|
2523
|
-
kind: '
|
|
2524
|
-
anchorScale: [
|
|
2525
|
-
info.anchorScaleX,
|
|
2526
|
-
info.anchorScaleY
|
|
2527
|
-
],
|
|
2528
|
-
anchorOffset: [
|
|
2529
|
-
info.anchorOffsetX,
|
|
2530
|
-
info.anchorOffsetY
|
|
2531
|
-
]
|
|
2449
|
+
kind: 'split-null-sprite'
|
|
2532
2450
|
};
|
|
2533
2451
|
}
|
|
2534
|
-
|
|
2535
|
-
// producer, caught by the guard at the top. Any layer reaching here is
|
|
2536
|
-
// centered — return the default inline-anchor.
|
|
2452
|
+
var info = computeAnchorInfo(layer, bounds);
|
|
2537
2453
|
return {
|
|
2538
2454
|
kind: 'inline-anchor',
|
|
2539
2455
|
anchorScale: [
|
|
2540
|
-
|
|
2541
|
-
|
|
2456
|
+
info.anchorScaleX,
|
|
2457
|
+
info.anchorScaleY
|
|
2542
2458
|
],
|
|
2543
2459
|
anchorOffset: [
|
|
2544
|
-
|
|
2545
|
-
|
|
2460
|
+
info.anchorOffsetX,
|
|
2461
|
+
info.anchorOffsetY
|
|
2546
2462
|
]
|
|
2547
2463
|
};
|
|
2548
2464
|
}
|
|
2549
|
-
function
|
|
2550
|
-
var
|
|
2465
|
+
function needsPivotContainer(layer, bounds) {
|
|
2466
|
+
var _rotation_x, _rotation_y, _rotation_z, _transform_scale;
|
|
2551
2467
|
if (layer.type !== 'image' && layer.type !== 'solid') {
|
|
2552
2468
|
return false;
|
|
2553
2469
|
}
|
|
2554
|
-
|
|
2555
|
-
// fall through to inline-anchor (matches the pre-displaySize behavior
|
|
2556
|
-
// where missing dimensions returned the {1, 1} default and never split).
|
|
2557
|
-
var size = layer.displaySize;
|
|
2558
|
-
if (size == null) {
|
|
2470
|
+
if (layer.localBounds == null) {
|
|
2559
2471
|
return false;
|
|
2560
2472
|
}
|
|
2561
|
-
var width =
|
|
2473
|
+
var x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
|
|
2562
2474
|
if (width <= 0 || height <= 0) {
|
|
2563
2475
|
return false;
|
|
2564
2476
|
}
|
|
2565
2477
|
var anchor = getStaticAnchor(layer);
|
|
2566
|
-
var anchorOffCenter = Math.abs(anchor[0] - width / 2) > 0.5 || Math.abs(anchor[1] - height / 2) > 0.5;
|
|
2478
|
+
var anchorOffCenter = Math.abs(anchor[0] - (x + width / 2)) > 0.5 || Math.abs(anchor[1] - (y + height / 2)) > 0.5;
|
|
2567
2479
|
if (!anchorOffCenter) {
|
|
2568
2480
|
return false;
|
|
2569
2481
|
}
|
|
2570
2482
|
var transform = layer.transform;
|
|
2571
|
-
var
|
|
2572
|
-
var hasRotationAnim = (
|
|
2483
|
+
var rotation = transform == null ? void 0 : transform.rotation;
|
|
2484
|
+
var hasRotationAnim = (rotation == null ? void 0 : (_rotation_x = rotation.x) == null ? void 0 : _rotation_x.keyframed) === true || (rotation == null ? void 0 : (_rotation_y = rotation.y) == null ? void 0 : _rotation_y.keyframed) === true || (rotation == null ? void 0 : (_rotation_z = rotation.z) == null ? void 0 : _rotation_z.keyframed) === true;
|
|
2573
2485
|
var hasScaleAnim = (transform == null ? void 0 : (_transform_scale = transform.scale) == null ? void 0 : _transform_scale.keyframed) === true;
|
|
2574
2486
|
return hasRotationAnim || hasScaleAnim;
|
|
2575
2487
|
}
|
|
@@ -2578,7 +2490,7 @@ function processNullLayer(layer, ctx) {
|
|
|
2578
2490
|
var itemId = createId();
|
|
2579
2491
|
var layerIndex = layer.index;
|
|
2580
2492
|
ctx.layerToItemId[layerIndex] = itemId;
|
|
2581
|
-
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2493
|
+
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate, ctx.ir.inPoint), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2582
2494
|
var animation = buildTransformAnimation(layer, ctx);
|
|
2583
2495
|
var position = computeStaticPosition(layer, ctx);
|
|
2584
2496
|
var objectBindingTrackId = buildTimelineTracks(ctx.collector, delay, layerDuration, 4, animation, 'null');
|
|
@@ -2588,7 +2500,7 @@ function processNullLayer(layer, ctx) {
|
|
|
2588
2500
|
name: layer.name,
|
|
2589
2501
|
duration: layerDuration,
|
|
2590
2502
|
type: '3',
|
|
2591
|
-
visible: layer.
|
|
2503
|
+
visible: layer.visible,
|
|
2592
2504
|
endBehavior: 4,
|
|
2593
2505
|
delay: delay,
|
|
2594
2506
|
renderLevel: 'B+',
|
|
@@ -2624,19 +2536,19 @@ function processPrecompLayer(layer, ctx) {
|
|
|
2624
2536
|
var itemId = createId();
|
|
2625
2537
|
var layerIndex = layer.index;
|
|
2626
2538
|
ctx.layerToItemId[layerIndex] = itemId;
|
|
2627
|
-
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2539
|
+
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate, ctx.ir.inPoint), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2628
2540
|
var animation = buildTransformAnimation(layer, ctx);
|
|
2629
2541
|
var position = computeStaticPosition(layer, ctx);
|
|
2630
2542
|
var objectBindingTrackId = buildTimelineTracks(ctx.collector, delay, layerDuration, 4, animation, 'precomp');
|
|
2631
|
-
var
|
|
2632
|
-
var content = buildPrecompContent(
|
|
2543
|
+
var effectsSpecific = getEffectsLayerSpecific(ctx.ir, layer);
|
|
2544
|
+
var content = buildPrecompContent(effectsSpecific == null ? void 0 : effectsSpecific.precompContent, effectsSpecific == null ? void 0 : effectsSpecific.precompRefId);
|
|
2633
2545
|
var item = {
|
|
2634
2546
|
id: itemId,
|
|
2635
2547
|
dataType: 'VFXItemData',
|
|
2636
2548
|
name: layer.name,
|
|
2637
2549
|
duration: layerDuration,
|
|
2638
2550
|
type: '7',
|
|
2639
|
-
visible: layer.
|
|
2551
|
+
visible: layer.visible,
|
|
2640
2552
|
endBehavior: 4,
|
|
2641
2553
|
delay: delay,
|
|
2642
2554
|
renderLevel: 'B+',
|
|
@@ -2680,14 +2592,13 @@ function isRecord$3(value) {
|
|
|
2680
2592
|
* the layer's logical position; the sprite/text child carries the visual
|
|
2681
2593
|
* content offset by the anchor so the pivot is at the right point.
|
|
2682
2594
|
*
|
|
2683
|
-
* Used by both `processParentLayer`
|
|
2684
|
-
*
|
|
2685
|
-
|
|
2686
|
-
* while transformSplit always uses `[1, 1, 1]`.
|
|
2687
|
-
*/ function emitNullSpritePair(layer, ctx, childScale) {
|
|
2595
|
+
* Used by both `processParentLayer` and GE lowering for layers that require a
|
|
2596
|
+
* pivot container.
|
|
2597
|
+
*/ function emitNullSpritePair(layer, ctx) {
|
|
2688
2598
|
var layerIndex = layer.index;
|
|
2689
|
-
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2690
|
-
var
|
|
2599
|
+
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate, ctx.ir.inPoint), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2600
|
+
var bounds = getLayerLocalBounds(layer);
|
|
2601
|
+
var x = bounds.x, y = bounds.y, layerWidth = bounds.width, layerHeight = bounds.height;
|
|
2691
2602
|
var nullItemId = createId();
|
|
2692
2603
|
ctx.layerToItemId[layerIndex] = nullItemId;
|
|
2693
2604
|
var nullAnimation = buildTransformAnimation(layer, ctx);
|
|
@@ -2732,9 +2643,11 @@ function isRecord$3(value) {
|
|
|
2732
2643
|
});
|
|
2733
2644
|
var childItemId = createId();
|
|
2734
2645
|
var anchor = getStaticAnchor(layer);
|
|
2646
|
+
var centerX = x + layerWidth / 2;
|
|
2647
|
+
var centerY = y + layerHeight / 2;
|
|
2735
2648
|
var childPosition = [
|
|
2736
|
-
-ctx.ratio * (anchor[0] -
|
|
2737
|
-
ctx.ratio * (anchor[1] -
|
|
2649
|
+
-ctx.ratio * (anchor[0] - centerX),
|
|
2650
|
+
ctx.ratio * (anchor[1] - centerY),
|
|
2738
2651
|
0
|
|
2739
2652
|
];
|
|
2740
2653
|
var childColorAnim = buildColorAnimation(layer, ctx.ir);
|
|
@@ -2747,13 +2660,22 @@ function isRecord$3(value) {
|
|
|
2747
2660
|
}
|
|
2748
2661
|
var scaledW = roundNumber(ctx.ratio * layerWidth, 4);
|
|
2749
2662
|
var scaledH = roundNumber(ctx.ratio * layerHeight, 4);
|
|
2663
|
+
var childScale = layer.type === 'text' ? [
|
|
2664
|
+
scaledW,
|
|
2665
|
+
scaledH,
|
|
2666
|
+
1
|
|
2667
|
+
] : [
|
|
2668
|
+
1,
|
|
2669
|
+
1,
|
|
2670
|
+
1
|
|
2671
|
+
];
|
|
2750
2672
|
var childItem = {
|
|
2751
2673
|
id: childItemId,
|
|
2752
2674
|
dataType: 'VFXItemData',
|
|
2753
2675
|
name: layer.name,
|
|
2754
2676
|
duration: layerDuration,
|
|
2755
2677
|
type: getGEItemTypeCode(layer.type),
|
|
2756
|
-
visible: layer.
|
|
2678
|
+
visible: layer.visible,
|
|
2757
2679
|
endBehavior: 0,
|
|
2758
2680
|
delay: delay,
|
|
2759
2681
|
renderLevel: 'B+',
|
|
@@ -2784,35 +2706,24 @@ function isRecord$3(value) {
|
|
|
2784
2706
|
});
|
|
2785
2707
|
}
|
|
2786
2708
|
function processParentLayer(layer, ctx) {
|
|
2787
|
-
|
|
2788
|
-
var scaledW = roundNumber(ctx.ratio * layerWidth, 4);
|
|
2789
|
-
var scaledH = roundNumber(ctx.ratio * layerHeight, 4);
|
|
2790
|
-
var childScale = layer.type === 'text' ? [
|
|
2791
|
-
scaledW,
|
|
2792
|
-
scaledH,
|
|
2793
|
-
1
|
|
2794
|
-
] : [
|
|
2795
|
-
1,
|
|
2796
|
-
1,
|
|
2797
|
-
1
|
|
2798
|
-
];
|
|
2799
|
-
emitNullSpritePair(layer, ctx, childScale);
|
|
2709
|
+
emitNullSpritePair(layer, ctx);
|
|
2800
2710
|
}
|
|
2801
2711
|
function processVisualLayer(layer, ctx) {
|
|
2802
|
-
|
|
2803
|
-
|
|
2712
|
+
var strategy = planGELayerLowering(ctx.ir, layer);
|
|
2713
|
+
if (strategy.kind === 'split-null-sprite') {
|
|
2714
|
+
processPivotContainerLayer(layer, ctx);
|
|
2804
2715
|
return;
|
|
2805
2716
|
}
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
processTransformSplitLayer(layer, ctx);
|
|
2717
|
+
if (layer.type === 'shape' && layer.shapes != null && layer.shapes.length > 0) {
|
|
2718
|
+
processShapeLayerMultiItem(layer, ctx);
|
|
2809
2719
|
return;
|
|
2810
2720
|
}
|
|
2811
2721
|
var itemId = createId();
|
|
2812
2722
|
var layerIndex = layer.index;
|
|
2813
2723
|
ctx.layerToItemId[layerIndex] = itemId;
|
|
2814
|
-
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2815
|
-
var
|
|
2724
|
+
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate, ctx.ir.inPoint), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2725
|
+
var bounds = getLayerLocalBounds(layer);
|
|
2726
|
+
var layerWidth = bounds.width, layerHeight = bounds.height;
|
|
2816
2727
|
var scaledW = ctx.ratio * layerWidth;
|
|
2817
2728
|
var scaledH = ctx.ratio * layerHeight;
|
|
2818
2729
|
var _strategy_anchorScale = strategy.anchorScale, anchorScaleX = _strategy_anchorScale[0], anchorScaleY = _strategy_anchorScale[1];
|
|
@@ -2823,7 +2734,7 @@ function processVisualLayer(layer, ctx) {
|
|
|
2823
2734
|
colorOverLifetime: colorAnimation
|
|
2824
2735
|
});
|
|
2825
2736
|
var rawPosition = computeStaticPosition(layer, ctx, anchorOffsetX, anchorOffsetY);
|
|
2826
|
-
var position = applyScalePositionAdjust(rawPosition, layer,
|
|
2737
|
+
var position = applyScalePositionAdjust(rawPosition, layer, bounds, ctx.ratio);
|
|
2827
2738
|
var itemType = getGEItemType(layer.type);
|
|
2828
2739
|
var objectBindingTrackId = buildTimelineTracks(ctx.collector, delay, layerDuration, 0, fullAnimation, itemType);
|
|
2829
2740
|
var componentId = buildComponent(layer, itemId, anchorScaleX, anchorScaleY, ctx);
|
|
@@ -2850,7 +2761,7 @@ function processVisualLayer(layer, ctx) {
|
|
|
2850
2761
|
name: layer.name,
|
|
2851
2762
|
duration: layerDuration,
|
|
2852
2763
|
type: getGEItemTypeCode(layer.type),
|
|
2853
|
-
visible: layer.
|
|
2764
|
+
visible: layer.visible,
|
|
2854
2765
|
endBehavior: 0,
|
|
2855
2766
|
delay: delay,
|
|
2856
2767
|
renderLevel: 'B+',
|
|
@@ -2879,19 +2790,24 @@ function processVisualLayer(layer, ctx) {
|
|
|
2879
2790
|
layerIndex: layerIndex
|
|
2880
2791
|
});
|
|
2881
2792
|
}
|
|
2882
|
-
function
|
|
2883
|
-
emitNullSpritePair(layer, ctx
|
|
2884
|
-
1,
|
|
2885
|
-
1,
|
|
2886
|
-
1
|
|
2887
|
-
]);
|
|
2793
|
+
function processPivotContainerLayer(layer, ctx) {
|
|
2794
|
+
emitNullSpritePair(layer, ctx);
|
|
2888
2795
|
}
|
|
2889
2796
|
function processShapeLayerMultiItem(layer, ctx) {
|
|
2890
2797
|
var layerIndex = layer.index;
|
|
2891
|
-
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2892
|
-
|
|
2798
|
+
var _computeLayerTiming = computeLayerTiming(layer, ctx.frameRate, ctx.ir.inPoint), delay = _computeLayerTiming.delay, layerDuration = _computeLayerTiming.layerDuration;
|
|
2799
|
+
// A GE Shape item commonly has no transform.size, so ge2ir cannot recover
|
|
2800
|
+
// layer-local bounds. Treat missing bounds as empty here: the generic 1×1
|
|
2801
|
+
// fallback would invent a half-pixel anchor offset and shift every rebuilt
|
|
2802
|
+
// shape (notably mask sources) away from its authored position.
|
|
2803
|
+
var bounds = getLayerLocalBounds(layer, {
|
|
2804
|
+
x: 0,
|
|
2805
|
+
y: 0,
|
|
2806
|
+
width: 0,
|
|
2807
|
+
height: 0
|
|
2808
|
+
});
|
|
2893
2809
|
var anchor = getStaticAnchor(layer);
|
|
2894
|
-
var _computeAnchorInfo = computeAnchorInfo(layer,
|
|
2810
|
+
var _computeAnchorInfo = computeAnchorInfo(layer, bounds), anchorOffsetX = _computeAnchorInfo.anchorOffsetX, anchorOffsetY = _computeAnchorInfo.anchorOffsetY;
|
|
2895
2811
|
var animation = buildTransformAnimation(layer, ctx);
|
|
2896
2812
|
var colorAnimation = buildColorAnimation(layer, ctx.ir);
|
|
2897
2813
|
var fullAnimation = _extends({}, animation, {
|
|
@@ -2926,7 +2842,7 @@ function processShapeLayerMultiItem(layer, ctx) {
|
|
|
2926
2842
|
});
|
|
2927
2843
|
// Mask source shape (isMask:true) — copy onto the first shape item only.
|
|
2928
2844
|
if (shapeIdx === 0) {
|
|
2929
|
-
|
|
2845
|
+
applyGEMask(ctx.ir, layer, component);
|
|
2930
2846
|
}
|
|
2931
2847
|
ctx.collector.components.push(component);
|
|
2932
2848
|
if (shapeIdx === 0) {
|
|
@@ -2939,7 +2855,7 @@ function processShapeLayerMultiItem(layer, ctx) {
|
|
|
2939
2855
|
name: shapeIdx === 0 ? layer.name : layer.name + "_shape_" + shapeIdx,
|
|
2940
2856
|
duration: layerDuration,
|
|
2941
2857
|
type: 'shape',
|
|
2942
|
-
visible: layer.
|
|
2858
|
+
visible: layer.visible,
|
|
2943
2859
|
endBehavior: 0,
|
|
2944
2860
|
delay: delay,
|
|
2945
2861
|
renderLevel: 'B+',
|
|
@@ -3072,16 +2988,20 @@ function deriveDuration(ir) {
|
|
|
3072
2988
|
}
|
|
3073
2989
|
/**
|
|
3074
2990
|
* Map IR composition end behavior to GE's numeric end-behavior.
|
|
3075
|
-
*
|
|
3076
|
-
*
|
|
2991
|
+
* Undefined defaults to Restart (5) for backward compatibility. DSL's boolean
|
|
2992
|
+
* loop flag maps to either Restart or Destroy at the adapter boundary.
|
|
3077
2993
|
*/ function mapCompositionEndBehavior(eb) {
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
2994
|
+
switch(eb){
|
|
2995
|
+
case undefined:
|
|
2996
|
+
case IREndBehavior.Restart:
|
|
2997
|
+
return 5;
|
|
2998
|
+
case IREndBehavior.Forward:
|
|
2999
|
+
return 2;
|
|
3000
|
+
case IREndBehavior.Freeze:
|
|
3001
|
+
return 4;
|
|
3002
|
+
case IREndBehavior.Destroy:
|
|
3003
|
+
return 0;
|
|
3083
3004
|
}
|
|
3084
|
-
return 0;
|
|
3085
3005
|
}
|
|
3086
3006
|
function colorToRoundedRgba(color) {
|
|
3087
3007
|
return [
|
|
@@ -3152,13 +3072,10 @@ function applyMasks(ir, collector, processedItems, ratio, width, height, frameRa
|
|
|
3152
3072
|
continue;
|
|
3153
3073
|
}
|
|
3154
3074
|
var layerComponentId = lookup.getComponentId(layer.index);
|
|
3155
|
-
buildMaskForLayer(layer, layerItemId, layerComponentId, collector, processedItems, ratio, width, height, frameRate, lookup, maskSlotMeta, componentById, maskData);
|
|
3075
|
+
buildMaskForLayer(layer, layerItemId, layerComponentId, collector, processedItems, ratio, width, height, frameRate, ir.inPoint, lookup, maskSlotMeta, componentById, maskData);
|
|
3156
3076
|
}
|
|
3157
3077
|
}
|
|
3158
|
-
function
|
|
3159
|
-
return mask.paths[0];
|
|
3160
|
-
}
|
|
3161
|
-
function buildMaskForLayer(layer, layerItemId, layerComponentId, collector, processedItems, ratio, width, height, frameRate, lookup, maskSlotMeta, componentById, maskData) {
|
|
3078
|
+
function buildMaskForLayer(layer, layerItemId, layerComponentId, collector, processedItems, ratio, width, height, frameRate, compositionInPoint, lookup, maskSlotMeta, componentById, maskData) {
|
|
3162
3079
|
var mask = maskData != null ? maskData : layer.mask;
|
|
3163
3080
|
var maskItemId = createId();
|
|
3164
3081
|
var maskComponentId = createId();
|
|
@@ -3166,7 +3083,7 @@ function buildMaskForLayer(layer, layerItemId, layerComponentId, collector, proc
|
|
|
3166
3083
|
var _getStaticAnchor = getStaticAnchor(layer), anchorX = _getStaticAnchor[0], anchorY = _getStaticAnchor[1];
|
|
3167
3084
|
var maskPosX = roundNumber((maskBounds.cx - anchorX) * ratio, 4);
|
|
3168
3085
|
var maskPosY = roundNumber(-(maskBounds.cy - anchorY) * ratio, 4);
|
|
3169
|
-
var timing = computeLayerTiming(layer, frameRate);
|
|
3086
|
+
var timing = computeLayerTiming(layer, frameRate, compositionInPoint);
|
|
3170
3087
|
var delay = timing.delay;
|
|
3171
3088
|
var maskDuration = timing.layerDuration;
|
|
3172
3089
|
var layerIsParent = lookup.isParentLayer(layer.index) || layer.type === 'null' || layer.type === 'precomp';
|
|
@@ -3358,8 +3275,8 @@ function computePointBounds(points) {
|
|
|
3358
3275
|
};
|
|
3359
3276
|
}
|
|
3360
3277
|
function isMaskExactCrop(mask, layer, width, height, lookup) {
|
|
3361
|
-
var path =
|
|
3362
|
-
if (path
|
|
3278
|
+
var path = mask.path;
|
|
3279
|
+
if (path.points.length === 0) {
|
|
3363
3280
|
return true;
|
|
3364
3281
|
}
|
|
3365
3282
|
var _computePointBounds = computePointBounds(path.points), minX = _computePointBounds.minX, minY = _computePointBounds.minY, maxX = _computePointBounds.maxX, maxY = _computePointBounds.maxY;
|
|
@@ -3384,8 +3301,8 @@ function isMaskExactCrop(mask, layer, width, height, lookup) {
|
|
|
3384
3301
|
return false;
|
|
3385
3302
|
}
|
|
3386
3303
|
function getMaskBounds(mask) {
|
|
3387
|
-
var path =
|
|
3388
|
-
if (path
|
|
3304
|
+
var path = mask.path;
|
|
3305
|
+
if (path.points.length === 0) {
|
|
3389
3306
|
return {
|
|
3390
3307
|
cx: 0,
|
|
3391
3308
|
cy: 0,
|
|
@@ -3402,47 +3319,41 @@ function getMaskBounds(mask) {
|
|
|
3402
3319
|
};
|
|
3403
3320
|
}
|
|
3404
3321
|
function isSimpleRectMask(mask) {
|
|
3405
|
-
var path =
|
|
3406
|
-
|
|
3407
|
-
return
|
|
3408
|
-
}
|
|
3409
|
-
|
|
3410
|
-
return Math.abs(e.x) < 0.01 && Math.abs(e.y) < 0.01;
|
|
3411
|
-
}) && path.easingOuts.every(function(e) {
|
|
3412
|
-
return Math.abs(e.x) < 0.01 && Math.abs(e.y) < 0.01;
|
|
3322
|
+
var path = mask.path;
|
|
3323
|
+
return path.points.length === 4 && path.inTangents.every(function(tangent) {
|
|
3324
|
+
return Math.abs(tangent.x) < 0.01 && Math.abs(tangent.y) < 0.01;
|
|
3325
|
+
}) && path.outTangents.every(function(tangent) {
|
|
3326
|
+
return Math.abs(tangent.x) < 0.01 && Math.abs(tangent.y) < 0.01;
|
|
3413
3327
|
});
|
|
3414
3328
|
}
|
|
3415
3329
|
function buildPolygonMaskComponent(maskComponentId, maskItemId, mask, bounds, ratio) {
|
|
3416
|
-
var
|
|
3417
|
-
var path = getPrimaryPath(mask);
|
|
3330
|
+
var path = mask.path;
|
|
3418
3331
|
var customPoints = [];
|
|
3419
3332
|
var customEasingIns = [];
|
|
3420
3333
|
var customEasingOuts = [];
|
|
3421
3334
|
var customIndexes = [];
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
});
|
|
3445
|
-
}
|
|
3335
|
+
for(var idx = 0; idx < path.points.length; idx++){
|
|
3336
|
+
var _ref, _ref1, _ref2, _ref3;
|
|
3337
|
+
var pt = path.points[idx];
|
|
3338
|
+
var ei = path.inTangents[idx];
|
|
3339
|
+
var eo = path.outTangents[idx];
|
|
3340
|
+
customPoints.push({
|
|
3341
|
+
x: roundNumber((pt.x - bounds.cx) * ratio, 4),
|
|
3342
|
+
y: roundNumber(-(pt.y - bounds.cy) * ratio, 4)
|
|
3343
|
+
});
|
|
3344
|
+
customEasingIns.push({
|
|
3345
|
+
x: roundNumber(((_ref = ei == null ? void 0 : ei.x) != null ? _ref : 0) * ratio, 4),
|
|
3346
|
+
y: roundNumber(-((_ref1 = ei == null ? void 0 : ei.y) != null ? _ref1 : 0) * ratio, 4)
|
|
3347
|
+
});
|
|
3348
|
+
customEasingOuts.push({
|
|
3349
|
+
x: roundNumber(((_ref2 = eo == null ? void 0 : eo.x) != null ? _ref2 : 0) * ratio, 4),
|
|
3350
|
+
y: roundNumber(-((_ref3 = eo == null ? void 0 : eo.y) != null ? _ref3 : 0) * ratio, 4)
|
|
3351
|
+
});
|
|
3352
|
+
customIndexes.push({
|
|
3353
|
+
point: idx,
|
|
3354
|
+
easingIn: idx,
|
|
3355
|
+
easingOut: idx
|
|
3356
|
+
});
|
|
3446
3357
|
}
|
|
3447
3358
|
return {
|
|
3448
3359
|
id: maskComponentId,
|
|
@@ -3454,7 +3365,7 @@ function buildPolygonMaskComponent(maskComponentId, maskItemId, mask, bounds, ra
|
|
|
3454
3365
|
easingOuts: customEasingOuts,
|
|
3455
3366
|
shapes: [
|
|
3456
3367
|
{
|
|
3457
|
-
close:
|
|
3368
|
+
close: path.closed,
|
|
3458
3369
|
indexes: customIndexes
|
|
3459
3370
|
}
|
|
3460
3371
|
],
|
|
@@ -3487,10 +3398,10 @@ function buildPolygonMaskComponent(maskComponentId, maskItemId, mask, bounds, ra
|
|
|
3487
3398
|
* Remap GE mask references after ge2ir round-trip.
|
|
3488
3399
|
*
|
|
3489
3400
|
* ge2ir carries each masked component's raw `mask` object verbatim (via
|
|
3490
|
-
* `IRLayerNode.
|
|
3401
|
+
* `IRLayerNode.specific.effects.mask`), but `mask.reference.id` still points at the
|
|
3491
3402
|
* ORIGINAL (GE1) mask-source component id, which ir2ge has regenerated. This
|
|
3492
3403
|
* pass rewrites every target's `reference.id` from the stale GE1 id to the
|
|
3493
|
-
* freshly-minted GE2 component id, using the `
|
|
3404
|
+
* freshly-minted GE2 component id, using the `GEComponentId → newId` map built
|
|
3494
3405
|
* during the layer walk.
|
|
3495
3406
|
*
|
|
3496
3407
|
* Mirrors `applyParenting`: an IR-side reference (here the stale id stored in
|
|
@@ -3498,7 +3409,7 @@ function buildPolygonMaskComponent(maskComponentId, maskItemId, mask, bounds, ra
|
|
|
3498
3409
|
* no `reference` and are skipped. Dangling references (source not regenerated —
|
|
3499
3410
|
* e.g. dropped by the null+sprite merger) have their `mask` removed so the GE
|
|
3500
3411
|
* runtime doesn't choke on an id that resolves to nothing.
|
|
3501
|
-
*/ function
|
|
3412
|
+
*/ function applyGEMaskRemap(collector, GEComponentIdToNewId) {
|
|
3502
3413
|
for(var _iterator = _create_for_of_iterator_helper_loose(collector.components), _step; !(_step = _iterator()).done;){
|
|
3503
3414
|
var component = _step.value;
|
|
3504
3415
|
var mask = component['mask'];
|
|
@@ -3510,7 +3421,7 @@ function buildPolygonMaskComponent(maskComponentId, maskItemId, mask, bounds, ra
|
|
|
3510
3421
|
if (oldId == null) {
|
|
3511
3422
|
continue;
|
|
3512
3423
|
}
|
|
3513
|
-
var newId =
|
|
3424
|
+
var newId = GEComponentIdToNewId[oldId];
|
|
3514
3425
|
if (newId == null) {
|
|
3515
3426
|
// Dangling: the referenced source was not regenerated. Drop the mask so
|
|
3516
3427
|
// the target renders unmasked rather than referencing a nonexistent id.
|
|
@@ -3525,15 +3436,15 @@ function buildPolygonMaskComponent(maskComponentId, maskItemId, mask, bounds, ra
|
|
|
3525
3436
|
* Normalize child visibility delays so children never appear before their parent.
|
|
3526
3437
|
*
|
|
3527
3438
|
* Topologically sorts items (parent-first) so by the time we process any child
|
|
3528
|
-
* its parent's delay/duration are already finalized. For
|
|
3529
|
-
*
|
|
3439
|
+
* its parent's delay/duration are already finalized. For children with an
|
|
3440
|
+
* independent lifetime, we instead advance the parent's delay/duration so the
|
|
3530
3441
|
* child can render from its own start time (GE requires the parent to be active
|
|
3531
3442
|
* for transform inheritance, but the parent-link relationship does not propagate
|
|
3532
3443
|
* visibility). Only the ActivationTrack clip is updated; TransformTrack
|
|
3533
3444
|
* keyframes are normalized to the original time range and would hold their
|
|
3534
3445
|
* first frame value if the track started earlier.
|
|
3535
3446
|
*/ function normalizeChildVisibilityByParentDelays(param) {
|
|
3536
|
-
var items = param.items, miscs = param.miscs, processedItems = param.processedItems,
|
|
3447
|
+
var items = param.items, miscs = param.miscs, processedItems = param.processedItems, _param_independentLifetimeChildItemIds = param.independentLifetimeChildItemIds, independentLifetimeChildItemIds = _param_independentLifetimeChildItemIds === void 0 ? new Set() : _param_independentLifetimeChildItemIds, roundNumber = param.roundNumber;
|
|
3537
3448
|
var itemById = new Map();
|
|
3538
3449
|
for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
|
|
3539
3450
|
var item = _step.value;
|
|
@@ -3549,9 +3460,9 @@ function buildPolygonMaskComponent(maskComponentId, maskItemId, mask, bounds, ra
|
|
|
3549
3460
|
var misc = _step2.value;
|
|
3550
3461
|
miscById.set(misc['id'], misc);
|
|
3551
3462
|
}
|
|
3552
|
-
// Phase 1: Advance transform
|
|
3463
|
+
// Phase 1: Advance transform parents so independent-lifetime children can
|
|
3553
3464
|
// render from the child's own start time.
|
|
3554
|
-
|
|
3465
|
+
advanceIndependentLifetimeParents(items, itemById, processedByItemId, miscById, independentLifetimeChildItemIds, roundNumber);
|
|
3555
3466
|
// Phase 2: Normalize precomp child visibility (unchanged).
|
|
3556
3467
|
var effectiveDelayCache = new Map();
|
|
3557
3468
|
function getEffectiveDelay(itemId, visited) {
|
|
@@ -3613,8 +3524,8 @@ function buildPolygonMaskComponent(maskComponentId, maskItemId, mask, bounds, ra
|
|
|
3613
3524
|
syncTimelineClips(itemId, effectiveDelay, newDuration, processedByItemId, miscById, roundNumber);
|
|
3614
3525
|
}
|
|
3615
3526
|
}
|
|
3616
|
-
function
|
|
3617
|
-
if (
|
|
3527
|
+
function advanceIndependentLifetimeParents(items, itemById, processedByItemId, miscById, independentLifetimeChildItemIds, roundNumber) {
|
|
3528
|
+
if (independentLifetimeChildItemIds.size === 0) {
|
|
3618
3529
|
return;
|
|
3619
3530
|
}
|
|
3620
3531
|
// Collect the maximum advance (head) and extension (tail) needed per parent.
|
|
@@ -3623,7 +3534,7 @@ function advanceTransformOnlyParentLinkParents(items, itemById, processedByItemI
|
|
|
3623
3534
|
for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
|
|
3624
3535
|
var item = _step.value;
|
|
3625
3536
|
var _item_delay, _item_duration, _parentItem_delay, _parentItem_duration;
|
|
3626
|
-
if (!
|
|
3537
|
+
if (!independentLifetimeChildItemIds.has(item['id'])) {
|
|
3627
3538
|
continue;
|
|
3628
3539
|
}
|
|
3629
3540
|
var parentId = item['parentId'];
|
|
@@ -3759,18 +3670,18 @@ function syncTimelineClips(itemId, delay, duration, processedByItemId, miscById,
|
|
|
3759
3670
|
*/ function applyPostProcess(ir, state) {
|
|
3760
3671
|
applyParentingStep(ir, state);
|
|
3761
3672
|
applySharedMaskPostProcess(ir, state);
|
|
3762
|
-
|
|
3673
|
+
applyGEMaskRemapStep(ir, state);
|
|
3763
3674
|
applyVisibilityStep(ir, state);
|
|
3764
3675
|
}
|
|
3765
|
-
function
|
|
3766
|
-
// Only
|
|
3676
|
+
function applyGEMaskRemapStep(ir, state) {
|
|
3677
|
+
// Only Effects-sourced compositions carry passthrough mask references that need
|
|
3767
3678
|
// remapping. Lottie/dsl masks are built with correct ids by applyMasks and
|
|
3768
|
-
// must not be touched (their reference ids are absent from the
|
|
3679
|
+
// must not be touched (their reference ids are absent from the GE map, so a
|
|
3769
3680
|
// blind remap would wrongly delete them).
|
|
3770
|
-
if (ir.source !== '
|
|
3681
|
+
if (ir.source !== 'effects' || state.GEComponentIdToNewId == null) {
|
|
3771
3682
|
return;
|
|
3772
3683
|
}
|
|
3773
|
-
|
|
3684
|
+
applyGEMaskRemap(state.collector, state.GEComponentIdToNewId);
|
|
3774
3685
|
}
|
|
3775
3686
|
function applySharedMaskPostProcess(ir, state) {
|
|
3776
3687
|
if (state.maskLookup == null || state.ratio == null || state.width == null || state.height == null || state.frameRate == null) {
|
|
@@ -3790,13 +3701,13 @@ function applyVisibilityStep(ir, state) {
|
|
|
3790
3701
|
if (layerToItemId == null) {
|
|
3791
3702
|
return;
|
|
3792
3703
|
}
|
|
3793
|
-
var
|
|
3704
|
+
var independentLifetimeChildItemIds = new Set();
|
|
3794
3705
|
for(var _iterator = _create_for_of_iterator_helper_loose(ir.layers), _step; !(_step = _iterator()).done;){
|
|
3795
3706
|
var layer = _step.value;
|
|
3796
|
-
if (
|
|
3707
|
+
if (hasIndependentParentLifetime(layer)) {
|
|
3797
3708
|
var itemId = layerToItemId[layer.index];
|
|
3798
3709
|
if (itemId != null) {
|
|
3799
|
-
|
|
3710
|
+
independentLifetimeChildItemIds.add(itemId);
|
|
3800
3711
|
}
|
|
3801
3712
|
}
|
|
3802
3713
|
}
|
|
@@ -3804,7 +3715,7 @@ function applyVisibilityStep(ir, state) {
|
|
|
3804
3715
|
items: collector.items,
|
|
3805
3716
|
miscs: collector.miscs,
|
|
3806
3717
|
processedItems: processedItems,
|
|
3807
|
-
|
|
3718
|
+
independentLifetimeChildItemIds: independentLifetimeChildItemIds,
|
|
3808
3719
|
roundNumber: roundNumber
|
|
3809
3720
|
});
|
|
3810
3721
|
}
|
|
@@ -3861,16 +3772,15 @@ function normalize(value, path, inArray) {
|
|
|
3861
3772
|
* Convert an IR composition to a GE JSONScene.
|
|
3862
3773
|
*
|
|
3863
3774
|
* All IR sources (lottie, dsl, future) go through this single unified
|
|
3864
|
-
* pipeline.
|
|
3865
|
-
*
|
|
3866
|
-
*
|
|
3867
|
-
* that cannot be expressed via data existence.
|
|
3775
|
+
* pipeline. Normalized animation semantics select the GE lowering plan;
|
|
3776
|
+
* source-specific payloads may preserve authored GE hierarchy or restore
|
|
3777
|
+
* mask and precomp graphs.
|
|
3868
3778
|
*
|
|
3869
3779
|
* The optional `duration` arg is a caller override; lottie2ge currently passes
|
|
3870
3780
|
* the duration computed from the raw json upstream. When omitted, the
|
|
3871
3781
|
* canonical assembler derives it from `(outPoint - inPoint) / frameRate`.
|
|
3872
3782
|
*/ function convertIRToGE(ir, duration) {
|
|
3873
|
-
|
|
3783
|
+
validateIRCompositionOrThrow(ir);
|
|
3874
3784
|
var width = ir.width, height = ir.height, frameRate = ir.frameRate;
|
|
3875
3785
|
var ratio = get2dTo3dRatio(width, height);
|
|
3876
3786
|
var collector = {
|
|
@@ -3913,15 +3823,15 @@ function normalize(value, path, inArray) {
|
|
|
3913
3823
|
}
|
|
3914
3824
|
// Build GE1-component-id → regenerated-component-id map for mask reference
|
|
3915
3825
|
// remapping (ge2ir round-trip). Keyed by the original GE component id that
|
|
3916
|
-
// ge2ir stored in
|
|
3917
|
-
var
|
|
3826
|
+
// ge2ir stored in specific.effects; value is the component id this layer minted.
|
|
3827
|
+
var GEComponentIdToNewId = {};
|
|
3918
3828
|
for(var _iterator2 = _create_for_of_iterator_helper_loose(workingIR.layers), _step2; !(_step2 = _iterator2()).done;){
|
|
3919
3829
|
var layer2 = _step2.value;
|
|
3920
|
-
var
|
|
3921
|
-
var
|
|
3830
|
+
var _getEffectsLayerSpecific;
|
|
3831
|
+
var GEComponentId = (_getEffectsLayerSpecific = getEffectsLayerSpecific(workingIR, layer2)) == null ? void 0 : _getEffectsLayerSpecific.sourceComponentId;
|
|
3922
3832
|
var newId = layerToComponentId[layer2.index];
|
|
3923
|
-
if (
|
|
3924
|
-
|
|
3833
|
+
if (GEComponentId != null && newId != null) {
|
|
3834
|
+
GEComponentIdToNewId[GEComponentId] = newId;
|
|
3925
3835
|
}
|
|
3926
3836
|
}
|
|
3927
3837
|
applyPostProcess(workingIR, {
|
|
@@ -3932,7 +3842,7 @@ function normalize(value, path, inArray) {
|
|
|
3932
3842
|
width: width,
|
|
3933
3843
|
height: height,
|
|
3934
3844
|
frameRate: frameRate,
|
|
3935
|
-
|
|
3845
|
+
GEComponentIdToNewId: GEComponentIdToNewId,
|
|
3936
3846
|
maskLookup: {
|
|
3937
3847
|
getItemId: function getItemId(idx) {
|
|
3938
3848
|
return layerToItemId[idx];
|
|
@@ -3965,16 +3875,16 @@ function processLayer(layer, ctx) {
|
|
|
3965
3875
|
}
|
|
3966
3876
|
}
|
|
3967
3877
|
function hasGEPrecompMetadata(ir, layer) {
|
|
3968
|
-
var
|
|
3969
|
-
return (
|
|
3878
|
+
var specific = getEffectsLayerSpecific(ir, layer);
|
|
3879
|
+
return (specific == null ? void 0 : specific.precompRefId) != null || (specific == null ? void 0 : specific.precompContent) != null;
|
|
3970
3880
|
}
|
|
3971
3881
|
/**
|
|
3972
|
-
* Extend parent layers' endFrame to cover
|
|
3882
|
+
* Extend parent layers' endFrame to cover independent child lifetimes.
|
|
3973
3883
|
*
|
|
3974
3884
|
* In Lottie, child layers (linked via layer.parent) inherit the parent's transform
|
|
3975
3885
|
* even after the parent becomes invisible. GE requires the parent item to be active
|
|
3976
3886
|
* for transform inheritance to work, so we extend the parent's endFrame to cover
|
|
3977
|
-
* the full lifetime of
|
|
3887
|
+
* the full lifetime of children whose lifetime is independent.
|
|
3978
3888
|
*
|
|
3979
3889
|
* Keyframes beyond the extended endFrame are NOT included — they represent animation
|
|
3980
3890
|
* that never plays in Lottie (layer is invisible and has no child needing it).
|
|
@@ -3993,7 +3903,7 @@ function hasGEPrecompMetadata(ir, layer) {
|
|
|
3993
3903
|
for(var _iterator1 = _create_for_of_iterator_helper_loose(clonedLayers), _step1; !(_step1 = _iterator1()).done;){
|
|
3994
3904
|
var child = _step1.value;
|
|
3995
3905
|
var _child_parent;
|
|
3996
|
-
if (((_child_parent = child.parent) == null ? void 0 : _child_parent.index) === layer.index && child.parent.
|
|
3906
|
+
if (((_child_parent = child.parent) == null ? void 0 : _child_parent.index) === layer.index && child.parent.lifetimeMode === 'independent') {
|
|
3997
3907
|
if (child.time.endFrame > maxEnd) {
|
|
3998
3908
|
maxEnd = child.time.endFrame;
|
|
3999
3909
|
}
|
|
@@ -4012,13 +3922,13 @@ function mergePreservedPrecompScene(generated, ir) {
|
|
|
4012
3922
|
return !isExcludedPoolEntry(pool, entry, excluded);
|
|
4013
3923
|
}));
|
|
4014
3924
|
};
|
|
4015
|
-
var
|
|
4016
|
-
var sourceScene =
|
|
3925
|
+
var specific = getEffectsCompositionSpecific(ir);
|
|
3926
|
+
var sourceScene = specific == null ? void 0 : specific.sourceScene;
|
|
4017
3927
|
if (sourceScene == null) {
|
|
4018
3928
|
return generated;
|
|
4019
3929
|
}
|
|
4020
3930
|
var result = _extends({}, generated);
|
|
4021
|
-
var sourceCompositionId =
|
|
3931
|
+
var sourceCompositionId = specific == null ? void 0 : specific.sourceCompositionId;
|
|
4022
3932
|
var excluded = collectRootCompositionIds(sourceScene, sourceCompositionId);
|
|
4023
3933
|
var pools = [
|
|
4024
3934
|
'images',
|
|
@@ -4238,23 +4148,25 @@ function resolveDataPathId(ref) {
|
|
|
4238
4148
|
return typeof id === 'string' ? id : undefined;
|
|
4239
4149
|
}
|
|
4240
4150
|
|
|
4241
|
-
function reverseEndBehavior(
|
|
4242
|
-
if (
|
|
4151
|
+
function reverseEndBehavior(GEBehavior) {
|
|
4152
|
+
if (GEBehavior == null) {
|
|
4243
4153
|
return undefined;
|
|
4244
4154
|
}
|
|
4245
|
-
switch(
|
|
4155
|
+
switch(GEBehavior){
|
|
4246
4156
|
case 0:
|
|
4247
|
-
return IREndBehavior.
|
|
4157
|
+
return IREndBehavior.Destroy;
|
|
4158
|
+
case 2:
|
|
4159
|
+
return IREndBehavior.Forward;
|
|
4248
4160
|
case 4:
|
|
4249
|
-
return IREndBehavior.
|
|
4161
|
+
return IREndBehavior.Freeze;
|
|
4250
4162
|
case 5:
|
|
4251
|
-
return IREndBehavior.
|
|
4163
|
+
return IREndBehavior.Restart;
|
|
4252
4164
|
default:
|
|
4253
4165
|
return undefined;
|
|
4254
4166
|
}
|
|
4255
4167
|
}
|
|
4256
|
-
function reverseCompositionEndBehavior(
|
|
4257
|
-
return reverseEndBehavior(
|
|
4168
|
+
function reverseCompositionEndBehavior(GEBehavior) {
|
|
4169
|
+
return reverseEndBehavior(GEBehavior);
|
|
4258
4170
|
}
|
|
4259
4171
|
|
|
4260
4172
|
function buildSceneContext(scene, options) {
|
|
@@ -4274,7 +4186,10 @@ function buildSceneContext(scene, options) {
|
|
|
4274
4186
|
var frameRate = options.frameRate;
|
|
4275
4187
|
var ratio = get2dTo3dRatio(width, height);
|
|
4276
4188
|
var inPoint = 0;
|
|
4277
|
-
|
|
4189
|
+
// GE durations are expressed in seconds and are not guaranteed to land on
|
|
4190
|
+
// an integer frame. Preserve the fractional frame so GE → IR → GE does not
|
|
4191
|
+
// shorten or extend the composition at the tail.
|
|
4192
|
+
var outPoint = duration * frameRate;
|
|
4278
4193
|
var endBehavior = reverseCompositionEndBehavior(composition['endBehavior']);
|
|
4279
4194
|
var backgroundColor;
|
|
4280
4195
|
var bg = composition['background'];
|
|
@@ -4482,16 +4397,26 @@ function parseStaticTransform(itemTransform, ctx) {
|
|
|
4482
4397
|
}
|
|
4483
4398
|
var eulerHint = itemTransform['eulerHint'];
|
|
4484
4399
|
if (eulerHint != null) {
|
|
4485
|
-
var
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4400
|
+
var x = Math.abs(eulerHint.x) > 1e-6 ? {
|
|
4401
|
+
keyframed: false,
|
|
4402
|
+
value: eulerHint.x
|
|
4403
|
+
} : undefined;
|
|
4404
|
+
var y = Math.abs(eulerHint.y) > 1e-6 ? {
|
|
4405
|
+
keyframed: false,
|
|
4406
|
+
value: eulerHint.y
|
|
4407
|
+
} : undefined;
|
|
4408
|
+
var z = Math.abs(eulerHint.z) > 1e-6 ? {
|
|
4409
|
+
keyframed: false,
|
|
4410
|
+
value: eulerHint.z
|
|
4411
|
+
} : undefined;
|
|
4412
|
+
if (x != null || y != null || z != null) {
|
|
4413
|
+
channels.rotation = _extends({}, x != null && {
|
|
4414
|
+
x: x
|
|
4415
|
+
}, y != null && {
|
|
4416
|
+
y: y
|
|
4417
|
+
}, z != null && {
|
|
4418
|
+
z: z
|
|
4419
|
+
});
|
|
4495
4420
|
}
|
|
4496
4421
|
}
|
|
4497
4422
|
return channels;
|
|
@@ -4540,7 +4465,7 @@ function parseBezierKeyframes(curves, startFrame, endFrame) {
|
|
|
4540
4465
|
};
|
|
4541
4466
|
if (i === 0) {
|
|
4542
4467
|
keyframes.push(_extends({
|
|
4543
|
-
|
|
4468
|
+
frame: frameTime,
|
|
4544
4469
|
value: v0
|
|
4545
4470
|
}, isHold ? {
|
|
4546
4471
|
hold: true
|
|
@@ -4560,7 +4485,7 @@ function parseBezierKeyframes(curves, startFrame, endFrame) {
|
|
|
4560
4485
|
y: inverseLerp(prevV0, prevV1, prevInCpY)
|
|
4561
4486
|
};
|
|
4562
4487
|
keyframes.push(_extends({
|
|
4563
|
-
|
|
4488
|
+
frame: frameTime,
|
|
4564
4489
|
value: v0,
|
|
4565
4490
|
inTangent: inTangent
|
|
4566
4491
|
}, isHold ? {
|
|
@@ -4579,7 +4504,7 @@ function parseBezierKeyframes(curves, startFrame, endFrame) {
|
|
|
4579
4504
|
y: inverseLerp(lastSeg[1], lastSeg[7], lastSeg[5])
|
|
4580
4505
|
};
|
|
4581
4506
|
keyframes.push({
|
|
4582
|
-
|
|
4507
|
+
frame: lastFrameTime,
|
|
4583
4508
|
value: lastV1,
|
|
4584
4509
|
inTangent: lastInTangent
|
|
4585
4510
|
});
|
|
@@ -4675,7 +4600,7 @@ function parsePositionTimingKeyframes(curves, startFrame, endFrame) {
|
|
|
4675
4600
|
};
|
|
4676
4601
|
if (i === 0) {
|
|
4677
4602
|
result.push({
|
|
4678
|
-
|
|
4603
|
+
frame: frameTime,
|
|
4679
4604
|
outTangent: outTangent
|
|
4680
4605
|
});
|
|
4681
4606
|
} else {
|
|
@@ -4685,7 +4610,7 @@ function parsePositionTimingKeyframes(curves, startFrame, endFrame) {
|
|
|
4685
4610
|
y: inverseLerp(prevSeg[0], prevSeg[6], prevSeg[5])
|
|
4686
4611
|
};
|
|
4687
4612
|
result.push({
|
|
4688
|
-
|
|
4613
|
+
frame: frameTime,
|
|
4689
4614
|
outTangent: outTangent,
|
|
4690
4615
|
inTangent: inTangent
|
|
4691
4616
|
});
|
|
@@ -4698,7 +4623,7 @@ function parsePositionTimingKeyframes(curves, startFrame, endFrame) {
|
|
|
4698
4623
|
y: inverseLerp(lastSeg[0], lastSeg[6], lastSeg[5])
|
|
4699
4624
|
};
|
|
4700
4625
|
result.push({
|
|
4701
|
-
|
|
4626
|
+
frame: lastFrameTime,
|
|
4702
4627
|
inTangent: lastInTangent
|
|
4703
4628
|
});
|
|
4704
4629
|
return result;
|
|
@@ -4715,12 +4640,9 @@ function parseTransformAnimation(asset, startFrame, endFrame, ctx) {
|
|
|
4715
4640
|
}
|
|
4716
4641
|
var rotOverLifetime = asset['rotationOverLifetime'];
|
|
4717
4642
|
if (rotOverLifetime != null) {
|
|
4718
|
-
var
|
|
4719
|
-
if (
|
|
4720
|
-
channels.rotation =
|
|
4721
|
-
}
|
|
4722
|
-
if (rotResult.separatedRotation != null) {
|
|
4723
|
-
channels.separatedRotation = rotResult.separatedRotation;
|
|
4643
|
+
var rotation = parseRotationAnimation(rotOverLifetime, startFrame, endFrame);
|
|
4644
|
+
if (rotation != null) {
|
|
4645
|
+
channels.rotation = rotation;
|
|
4724
4646
|
}
|
|
4725
4647
|
}
|
|
4726
4648
|
var sizeOverLifetime = asset['sizeOverLifetime'];
|
|
@@ -4800,7 +4722,7 @@ function parsePositionAnimation(posOverLifetime, startFrame, endFrame, ctx) {
|
|
|
4800
4722
|
var pp = pathPoints[Math.min(i, pathPoints.length - 1)];
|
|
4801
4723
|
var pos2d = convert3dTo2dPoint(pp[0], pp[1], (_pp_ = pp[2]) != null ? _pp_ : 0, ctx.width, ctx.height);
|
|
4802
4724
|
var kf = {
|
|
4803
|
-
|
|
4725
|
+
frame: timing.frame,
|
|
4804
4726
|
value: pos2d
|
|
4805
4727
|
};
|
|
4806
4728
|
if (i > startIdx && timing.inTangent != null) {
|
|
@@ -4849,83 +4771,26 @@ function parsePositionAnimation(posOverLifetime, startFrame, endFrame, ctx) {
|
|
|
4849
4771
|
};
|
|
4850
4772
|
}
|
|
4851
4773
|
function parseRotationAnimation(rotOverLifetime, startFrame, endFrame) {
|
|
4852
|
-
var separateAxes = rotOverLifetime['separateAxes'];
|
|
4774
|
+
var separateAxes = rotOverLifetime['separateAxes'] === true;
|
|
4853
4775
|
var xData = rotOverLifetime['x'];
|
|
4854
4776
|
var yData = rotOverLifetime['y'];
|
|
4855
4777
|
var zData = rotOverLifetime['z'];
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
var hasXOrY = x != null || y != null;
|
|
4862
|
-
if (hasMultiAxis || hasXOrY) {
|
|
4863
|
-
return {
|
|
4864
|
-
separatedRotation: _extends({}, x != null && {
|
|
4865
|
-
x: x
|
|
4866
|
-
}, y != null && {
|
|
4867
|
-
y: y
|
|
4868
|
-
}, z != null && {
|
|
4869
|
-
z: z
|
|
4870
|
-
})
|
|
4871
|
-
};
|
|
4872
|
-
}
|
|
4873
|
-
if (z != null) {
|
|
4874
|
-
return {
|
|
4875
|
-
separatedRotation: {
|
|
4876
|
-
z: z
|
|
4877
|
-
}
|
|
4878
|
-
};
|
|
4879
|
-
}
|
|
4880
|
-
}
|
|
4881
|
-
// Single-axis z rotation (non-separated)
|
|
4882
|
-
if (zData != null) {
|
|
4883
|
-
var z1 = parseScalarChannel(zData, startFrame, endFrame);
|
|
4884
|
-
if (z1 != null) {
|
|
4885
|
-
if (z1.keyframed) {
|
|
4886
|
-
var vecKeyframes = z1.keyframes.map(function(kf) {
|
|
4887
|
-
var result = {
|
|
4888
|
-
t: kf.t,
|
|
4889
|
-
value: [
|
|
4890
|
-
0,
|
|
4891
|
-
0,
|
|
4892
|
-
kf.value
|
|
4893
|
-
]
|
|
4894
|
-
};
|
|
4895
|
-
if (kf.hold != null) {
|
|
4896
|
-
result.hold = kf.hold;
|
|
4897
|
-
}
|
|
4898
|
-
if (kf.inTangent != null) {
|
|
4899
|
-
result.inTangent = kf.inTangent;
|
|
4900
|
-
}
|
|
4901
|
-
if (kf.outTangent != null) {
|
|
4902
|
-
result.outTangent = kf.outTangent;
|
|
4903
|
-
}
|
|
4904
|
-
return result;
|
|
4905
|
-
});
|
|
4906
|
-
return {
|
|
4907
|
-
rotation: {
|
|
4908
|
-
keyframed: true,
|
|
4909
|
-
keyframes: vecKeyframes
|
|
4910
|
-
}
|
|
4911
|
-
};
|
|
4912
|
-
}
|
|
4913
|
-
return {
|
|
4914
|
-
rotation: {
|
|
4915
|
-
keyframed: false,
|
|
4916
|
-
value: [
|
|
4917
|
-
0,
|
|
4918
|
-
0,
|
|
4919
|
-
z1.value
|
|
4920
|
-
]
|
|
4921
|
-
}
|
|
4922
|
-
};
|
|
4923
|
-
}
|
|
4778
|
+
var x = separateAxes ? parseScalarChannel(xData, startFrame, endFrame) : undefined;
|
|
4779
|
+
var y = separateAxes ? parseScalarChannel(yData, startFrame, endFrame) : undefined;
|
|
4780
|
+
var z = parseScalarChannel(zData, startFrame, endFrame);
|
|
4781
|
+
if (x == null && y == null && z == null) {
|
|
4782
|
+
return undefined;
|
|
4924
4783
|
}
|
|
4925
|
-
return {}
|
|
4784
|
+
return _extends({}, x != null && {
|
|
4785
|
+
x: x
|
|
4786
|
+
}, y != null && {
|
|
4787
|
+
y: y
|
|
4788
|
+
}, z != null && {
|
|
4789
|
+
z: z
|
|
4790
|
+
});
|
|
4926
4791
|
}
|
|
4927
4792
|
function parseScaleAnimation(sizeOverLifetime, startFrame, endFrame) {
|
|
4928
|
-
var _ref, _ref1, _ref2
|
|
4793
|
+
var _ref, _ref1, _ref2;
|
|
4929
4794
|
var xData = sizeOverLifetime['x'];
|
|
4930
4795
|
var yData = sizeOverLifetime['y'];
|
|
4931
4796
|
var zData = sizeOverLifetime['z'];
|
|
@@ -4938,71 +4803,72 @@ function parseScaleAnimation(sizeOverLifetime, startFrame, endFrame) {
|
|
|
4938
4803
|
var xKeyframed = (x == null ? void 0 : x.keyframed) === true;
|
|
4939
4804
|
var yKeyframed = (y == null ? void 0 : y.keyframed) === true;
|
|
4940
4805
|
var zKeyframed = (z == null ? void 0 : z.keyframed) === true;
|
|
4806
|
+
var xStaticValue = (x == null ? void 0 : x.keyframed) === false ? x.value : 1;
|
|
4807
|
+
var yStaticValue = (y == null ? void 0 : y.keyframed) === false ? y.value : 1;
|
|
4808
|
+
var zStaticValue = (z == null ? void 0 : z.keyframed) === false ? z.value : 1;
|
|
4941
4809
|
if (!xKeyframed && !yKeyframed && !zKeyframed) {
|
|
4942
|
-
var _ref9, _ref10, _ref11;
|
|
4943
4810
|
return {
|
|
4944
4811
|
keyframed: false,
|
|
4945
4812
|
value: [
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4813
|
+
xStaticValue,
|
|
4814
|
+
yStaticValue,
|
|
4815
|
+
zStaticValue
|
|
4949
4816
|
]
|
|
4950
4817
|
};
|
|
4951
4818
|
}
|
|
4952
4819
|
var xKfs = (_ref = x == null ? void 0 : x.keyframes) != null ? _ref : [
|
|
4953
4820
|
{
|
|
4954
|
-
|
|
4955
|
-
value:
|
|
4821
|
+
frame: startFrame,
|
|
4822
|
+
value: xStaticValue
|
|
4956
4823
|
},
|
|
4957
4824
|
{
|
|
4958
|
-
|
|
4959
|
-
value:
|
|
4825
|
+
frame: endFrame,
|
|
4826
|
+
value: xStaticValue
|
|
4960
4827
|
}
|
|
4961
4828
|
];
|
|
4962
|
-
var yKfs = (
|
|
4829
|
+
var yKfs = (_ref1 = y == null ? void 0 : y.keyframes) != null ? _ref1 : [
|
|
4963
4830
|
{
|
|
4964
|
-
|
|
4965
|
-
value:
|
|
4831
|
+
frame: startFrame,
|
|
4832
|
+
value: yStaticValue
|
|
4966
4833
|
},
|
|
4967
4834
|
{
|
|
4968
|
-
|
|
4969
|
-
value:
|
|
4835
|
+
frame: endFrame,
|
|
4836
|
+
value: yStaticValue
|
|
4970
4837
|
}
|
|
4971
4838
|
];
|
|
4972
|
-
var zKfs = (
|
|
4839
|
+
var zKfs = (_ref2 = z == null ? void 0 : z.keyframes) != null ? _ref2 : [
|
|
4973
4840
|
{
|
|
4974
|
-
|
|
4975
|
-
value:
|
|
4841
|
+
frame: startFrame,
|
|
4842
|
+
value: zStaticValue
|
|
4976
4843
|
},
|
|
4977
4844
|
{
|
|
4978
|
-
|
|
4979
|
-
value:
|
|
4845
|
+
frame: endFrame,
|
|
4846
|
+
value: zStaticValue
|
|
4980
4847
|
}
|
|
4981
4848
|
];
|
|
4982
|
-
var
|
|
4849
|
+
var allFrames = new Set();
|
|
4983
4850
|
for(var _iterator = _create_for_of_iterator_helper_loose(xKfs), _step; !(_step = _iterator()).done;){
|
|
4984
4851
|
var kf = _step.value;
|
|
4985
|
-
|
|
4852
|
+
allFrames.add(kf.frame);
|
|
4986
4853
|
}
|
|
4987
4854
|
for(var _iterator1 = _create_for_of_iterator_helper_loose(yKfs), _step1; !(_step1 = _iterator1()).done;){
|
|
4988
4855
|
var kf1 = _step1.value;
|
|
4989
|
-
|
|
4856
|
+
allFrames.add(kf1.frame);
|
|
4990
4857
|
}
|
|
4991
4858
|
for(var _iterator2 = _create_for_of_iterator_helper_loose(zKfs), _step2; !(_step2 = _iterator2()).done;){
|
|
4992
4859
|
var kf2 = _step2.value;
|
|
4993
|
-
|
|
4860
|
+
allFrames.add(kf2.frame);
|
|
4994
4861
|
}
|
|
4995
4862
|
// Keep Array.from: loose SWC array-spread lowering does not expand Set in dist.
|
|
4996
|
-
var
|
|
4863
|
+
var sortedFrames = Array.from(allFrames).sort(function(a, b) {
|
|
4997
4864
|
return a - b;
|
|
4998
4865
|
});
|
|
4999
|
-
var keyframes =
|
|
5000
|
-
var
|
|
5001
|
-
var
|
|
5002
|
-
var
|
|
5003
|
-
var zv = findValueAtTime(zKfs, t, (_ref2 = z == null ? void 0 : z.value) != null ? _ref2 : 1);
|
|
4866
|
+
var keyframes = sortedFrames.map(function(frame) {
|
|
4867
|
+
var xv = findValueAtFrame(xKfs, frame, xStaticValue);
|
|
4868
|
+
var yv = findValueAtFrame(yKfs, frame, yStaticValue);
|
|
4869
|
+
var zv = findValueAtFrame(zKfs, frame, zStaticValue);
|
|
5004
4870
|
var kf = {
|
|
5005
|
-
|
|
4871
|
+
frame: frame,
|
|
5006
4872
|
value: [
|
|
5007
4873
|
xv.value,
|
|
5008
4874
|
yv.value,
|
|
@@ -5048,10 +4914,10 @@ function parseScalarChannel(data, startFrame, endFrame) {
|
|
|
5048
4914
|
}
|
|
5049
4915
|
return undefined;
|
|
5050
4916
|
}
|
|
5051
|
-
function
|
|
4917
|
+
function findValueAtFrame(keyframes, frame, defaultValue) {
|
|
5052
4918
|
for(var _iterator = _create_for_of_iterator_helper_loose(keyframes), _step; !(_step = _iterator()).done;){
|
|
5053
4919
|
var kf = _step.value;
|
|
5054
|
-
if (Math.abs(kf.
|
|
4920
|
+
if (Math.abs(kf.frame - frame) < 1e-6) {
|
|
5055
4921
|
return {
|
|
5056
4922
|
value: kf.value,
|
|
5057
4923
|
outTangent: kf.outTangent,
|
|
@@ -5083,11 +4949,11 @@ var IR_BLEND_MODE_BY_GE = {
|
|
|
5083
4949
|
15: IRBlendMode.SoftLight,
|
|
5084
4950
|
16: IRBlendMode.Luminosity
|
|
5085
4951
|
};
|
|
5086
|
-
function reverseBlendMode(
|
|
5087
|
-
if (
|
|
4952
|
+
function reverseBlendMode(GECode) {
|
|
4953
|
+
if (GECode == null) {
|
|
5088
4954
|
return undefined;
|
|
5089
4955
|
}
|
|
5090
|
-
return IR_BLEND_MODE_BY_GE[
|
|
4956
|
+
return IR_BLEND_MODE_BY_GE[GECode];
|
|
5091
4957
|
}
|
|
5092
4958
|
|
|
5093
4959
|
function parseComponent(item, ctx) {
|
|
@@ -5117,7 +4983,7 @@ function parseComponent(item, ctx) {
|
|
|
5117
4983
|
if (result == null) {
|
|
5118
4984
|
continue;
|
|
5119
4985
|
}
|
|
5120
|
-
result.
|
|
4986
|
+
result.GEComponentId = component['id'];
|
|
5121
4987
|
var mask = component['mask'];
|
|
5122
4988
|
if (mask != null) {
|
|
5123
4989
|
result.rawMask = mask;
|
|
@@ -5241,7 +5107,7 @@ function parseShapeComponent(component, ctx) {
|
|
|
5241
5107
|
if (renderer != null) {
|
|
5242
5108
|
blendMode = reverseBlendMode(renderer['blending']);
|
|
5243
5109
|
}
|
|
5244
|
-
var shapeData = parseShapeOptions(component, ctx
|
|
5110
|
+
var shapeData = parseShapeOptions(component, ctx);
|
|
5245
5111
|
return {
|
|
5246
5112
|
type: 'shape',
|
|
5247
5113
|
shapes: shapeData != null ? [
|
|
@@ -5250,85 +5116,100 @@ function parseShapeComponent(component, ctx) {
|
|
|
5250
5116
|
blendMode: blendMode
|
|
5251
5117
|
};
|
|
5252
5118
|
}
|
|
5253
|
-
function parseShapeOptions(component,
|
|
5254
|
-
var
|
|
5255
|
-
var primitiveType = reverseShapePrimitiveType(
|
|
5256
|
-
var
|
|
5257
|
-
var ySize = component['ySize'];
|
|
5258
|
-
var size = [
|
|
5259
|
-
xSize != null ? xSize / ratio : 0,
|
|
5260
|
-
ySize != null ? ySize / ratio : 0
|
|
5261
|
-
];
|
|
5262
|
-
var shape = {
|
|
5263
|
-
primitiveType: primitiveType,
|
|
5119
|
+
function parseShapeOptions(component, ctx) {
|
|
5120
|
+
var GEType = component['type'];
|
|
5121
|
+
var primitiveType = reverseShapePrimitiveType(GEType != null ? GEType : 0);
|
|
5122
|
+
var style = {
|
|
5264
5123
|
position: [
|
|
5265
5124
|
0,
|
|
5266
5125
|
0
|
|
5267
5126
|
],
|
|
5268
|
-
size: size,
|
|
5269
5127
|
fills: [],
|
|
5270
5128
|
strokes: []
|
|
5271
5129
|
};
|
|
5272
|
-
var
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
reverseScaledNumber(shapeRec, component, 'height', ratio);
|
|
5277
|
-
reverseScaledNumber(shapeRec, component, 'innerRadius', ratio);
|
|
5278
|
-
reverseScaledNumber(shapeRec, component, 'outerRadius', ratio);
|
|
5279
|
-
reverseScaledNumber(shapeRec, component, 'radius', ratio);
|
|
5280
|
-
reverseRawNumber(shapeRec, component, 'roundness');
|
|
5281
|
-
reverseRawNumber(shapeRec, component, 'pointCount');
|
|
5282
|
-
reverseRawNumber(shapeRec, component, 'innerRoundness');
|
|
5283
|
-
reverseRawNumber(shapeRec, component, 'outerRoundness');
|
|
5284
|
-
var geFills = component['fills'];
|
|
5285
|
-
if (geFills != null) {
|
|
5286
|
-
shape.fills = geFills.map(function(f) {
|
|
5287
|
-
return reverseShapePaint(f, ratio);
|
|
5130
|
+
var GEFills = component['fills'];
|
|
5131
|
+
if (GEFills != null) {
|
|
5132
|
+
style.fills = GEFills.map(function(f) {
|
|
5133
|
+
return reverseShapePaint(f, ctx);
|
|
5288
5134
|
}).filter(function(f) {
|
|
5289
5135
|
return f != null;
|
|
5290
5136
|
});
|
|
5291
5137
|
}
|
|
5292
|
-
var
|
|
5293
|
-
if (
|
|
5294
|
-
|
|
5295
|
-
return reverseShapePaint(s,
|
|
5138
|
+
var GEStrokes = component['strokes'];
|
|
5139
|
+
if (GEStrokes != null) {
|
|
5140
|
+
style.strokes = GEStrokes.map(function(s) {
|
|
5141
|
+
return reverseShapePaint(s, ctx);
|
|
5296
5142
|
}).filter(function(s) {
|
|
5297
5143
|
return s != null;
|
|
5298
5144
|
});
|
|
5299
5145
|
}
|
|
5300
|
-
var
|
|
5301
|
-
if (
|
|
5302
|
-
|
|
5303
|
-
}
|
|
5304
|
-
var geStrokeCap = component['strokeCap'];
|
|
5305
|
-
if (geStrokeCap != null) {
|
|
5306
|
-
shape.strokeCap = reverseLineCap(geStrokeCap);
|
|
5307
|
-
}
|
|
5308
|
-
var geStrokeJoin = component['strokeJoin'];
|
|
5309
|
-
if (geStrokeJoin != null) {
|
|
5310
|
-
shape.strokeJoin = reverseLineJoin(geStrokeJoin);
|
|
5311
|
-
}
|
|
5312
|
-
var geFillRule = component['fillRule'];
|
|
5313
|
-
if (geFillRule != null) {
|
|
5314
|
-
shape.fillRule = reverseShapeFillRule(geFillRule);
|
|
5146
|
+
var GEStrokeWidth = component['strokeWidth'];
|
|
5147
|
+
if (typeof GEStrokeWidth === 'number' && Number.isFinite(GEStrokeWidth) && GEStrokeWidth >= 0) {
|
|
5148
|
+
style.strokeWidth = GEStrokeWidth / ctx.ratio;
|
|
5315
5149
|
}
|
|
5316
|
-
var
|
|
5317
|
-
if (
|
|
5318
|
-
|
|
5319
|
-
if (paths.length > 0) {
|
|
5320
|
-
shape.customPaths = paths;
|
|
5321
|
-
}
|
|
5150
|
+
var GEStrokeCap = component['strokeCap'];
|
|
5151
|
+
if (GEStrokeCap != null) {
|
|
5152
|
+
style.strokeCap = reverseLineCap(GEStrokeCap);
|
|
5322
5153
|
}
|
|
5323
|
-
var
|
|
5324
|
-
if (
|
|
5325
|
-
|
|
5154
|
+
var GEStrokeJoin = component['strokeJoin'];
|
|
5155
|
+
if (GEStrokeJoin != null) {
|
|
5156
|
+
style.strokeJoin = reverseLineJoin(GEStrokeJoin);
|
|
5326
5157
|
}
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5158
|
+
switch(primitiveType){
|
|
5159
|
+
case IRShapePrimitiveType.Custom:
|
|
5160
|
+
{
|
|
5161
|
+
var customPaths = reverseCustomPaths(component, ctx.ratio);
|
|
5162
|
+
var firstPath = customPaths[0];
|
|
5163
|
+
return firstPath != null ? _extends({}, style, {
|
|
5164
|
+
primitiveType: primitiveType,
|
|
5165
|
+
customPaths: [].concat([
|
|
5166
|
+
firstPath
|
|
5167
|
+
], customPaths.slice(1))
|
|
5168
|
+
}) : undefined;
|
|
5169
|
+
}
|
|
5170
|
+
case IRShapePrimitiveType.Rectangle:
|
|
5171
|
+
{
|
|
5172
|
+
var width = readScaledNumber(component, 'width', ctx.ratio);
|
|
5173
|
+
var height = readScaledNumber(component, 'height', ctx.ratio);
|
|
5174
|
+
return width != null && height != null ? _extends({}, style, {
|
|
5175
|
+
primitiveType: primitiveType,
|
|
5176
|
+
width: width,
|
|
5177
|
+
height: height
|
|
5178
|
+
}, readOptionalNumberField(component, 'roundness')) : undefined;
|
|
5179
|
+
}
|
|
5180
|
+
case IRShapePrimitiveType.Ellipse:
|
|
5181
|
+
{
|
|
5182
|
+
var xRadius = readScaledNumber(component, 'xRadius', ctx.ratio);
|
|
5183
|
+
var yRadius = readScaledNumber(component, 'yRadius', ctx.ratio);
|
|
5184
|
+
return xRadius != null && yRadius != null ? _extends({}, style, {
|
|
5185
|
+
primitiveType: primitiveType,
|
|
5186
|
+
xRadius: xRadius,
|
|
5187
|
+
yRadius: yRadius
|
|
5188
|
+
}) : undefined;
|
|
5189
|
+
}
|
|
5190
|
+
case IRShapePrimitiveType.Polygon:
|
|
5191
|
+
{
|
|
5192
|
+
var pointCount = readPointCount(component);
|
|
5193
|
+
var radius = readScaledNumber(component, 'radius', ctx.ratio);
|
|
5194
|
+
return pointCount != null && radius != null ? _extends({}, style, {
|
|
5195
|
+
primitiveType: primitiveType,
|
|
5196
|
+
pointCount: pointCount,
|
|
5197
|
+
radius: radius
|
|
5198
|
+
}, readOptionalNumberField(component, 'roundness')) : undefined;
|
|
5199
|
+
}
|
|
5200
|
+
case IRShapePrimitiveType.Star:
|
|
5201
|
+
{
|
|
5202
|
+
var pointCount1 = readPointCount(component);
|
|
5203
|
+
var innerRadius = readScaledNumber(component, 'innerRadius', ctx.ratio);
|
|
5204
|
+
var outerRadius = readScaledNumber(component, 'outerRadius', ctx.ratio);
|
|
5205
|
+
return pointCount1 != null && innerRadius != null && outerRadius != null ? _extends({}, style, {
|
|
5206
|
+
primitiveType: primitiveType,
|
|
5207
|
+
pointCount: pointCount1,
|
|
5208
|
+
innerRadius: innerRadius,
|
|
5209
|
+
outerRadius: outerRadius
|
|
5210
|
+
}, readOptionalNumberField(component, 'innerRoundness'), readOptionalNumberField(component, 'outerRoundness')) : undefined;
|
|
5211
|
+
}
|
|
5330
5212
|
}
|
|
5331
|
-
return shape;
|
|
5332
5213
|
}
|
|
5333
5214
|
var GE_TO_SHAPE_PRIMITIVE_TYPE = {
|
|
5334
5215
|
0: IRShapePrimitiveType.Custom,
|
|
@@ -5337,13 +5218,13 @@ var GE_TO_SHAPE_PRIMITIVE_TYPE = {
|
|
|
5337
5218
|
3: IRShapePrimitiveType.Polygon,
|
|
5338
5219
|
4: IRShapePrimitiveType.Star
|
|
5339
5220
|
};
|
|
5340
|
-
function reverseShapePrimitiveType(
|
|
5341
|
-
var
|
|
5342
|
-
return (
|
|
5221
|
+
function reverseShapePrimitiveType(GEType) {
|
|
5222
|
+
var _GE_TO_SHAPE_PRIMITIVE_TYPE_GEType;
|
|
5223
|
+
return (_GE_TO_SHAPE_PRIMITIVE_TYPE_GEType = GE_TO_SHAPE_PRIMITIVE_TYPE[GEType]) != null ? _GE_TO_SHAPE_PRIMITIVE_TYPE_GEType : IRShapePrimitiveType.Custom;
|
|
5343
5224
|
}
|
|
5344
|
-
function reverseShapePaint(paint,
|
|
5345
|
-
var
|
|
5346
|
-
if (
|
|
5225
|
+
function reverseShapePaint(paint, ctx) {
|
|
5226
|
+
var GEType = paint['type'];
|
|
5227
|
+
if (GEType === 0) {
|
|
5347
5228
|
var color = paint['color'];
|
|
5348
5229
|
if (color == null) {
|
|
5349
5230
|
return undefined;
|
|
@@ -5358,7 +5239,7 @@ function reverseShapePaint(paint, ratio) {
|
|
|
5358
5239
|
]
|
|
5359
5240
|
};
|
|
5360
5241
|
}
|
|
5361
|
-
if (
|
|
5242
|
+
if (GEType === 1 || GEType === 2 || GEType === 3) {
|
|
5362
5243
|
var typeMap = {
|
|
5363
5244
|
1: IRFillType.LinearGradient,
|
|
5364
5245
|
2: IRFillType.RadialGradient,
|
|
@@ -5369,45 +5250,50 @@ function reverseShapePaint(paint, ratio) {
|
|
|
5369
5250
|
var startPoint = paint['startPoint'];
|
|
5370
5251
|
var endPoint = paint['endPoint'];
|
|
5371
5252
|
return {
|
|
5372
|
-
type: typeMap[
|
|
5253
|
+
type: typeMap[GEType],
|
|
5373
5254
|
gradientStops: stops,
|
|
5374
5255
|
gradientStart: startPoint != null ? [
|
|
5375
|
-
startPoint.x / ratio,
|
|
5376
|
-
-startPoint.y / ratio
|
|
5256
|
+
startPoint.x / ctx.ratio,
|
|
5257
|
+
-startPoint.y / ctx.ratio
|
|
5377
5258
|
] : undefined,
|
|
5378
5259
|
gradientEnd: endPoint != null ? [
|
|
5379
|
-
endPoint.x / ratio,
|
|
5380
|
-
-endPoint.y / ratio
|
|
5260
|
+
endPoint.x / ctx.ratio,
|
|
5261
|
+
-endPoint.y / ctx.ratio
|
|
5381
5262
|
] : undefined
|
|
5382
5263
|
};
|
|
5383
5264
|
}
|
|
5265
|
+
if (GEType === 4) {
|
|
5266
|
+
var texture = resolveTextureAsset(paint['texture'], ctx);
|
|
5267
|
+
if (texture == null) {
|
|
5268
|
+
return undefined;
|
|
5269
|
+
}
|
|
5270
|
+
var scaleMode = paint['scaleMode'];
|
|
5271
|
+
return _extends({
|
|
5272
|
+
type: IRFillType.Texture,
|
|
5273
|
+
texture: texture
|
|
5274
|
+
}, isTextureScaleMode(scaleMode) && {
|
|
5275
|
+
scaleMode: scaleMode
|
|
5276
|
+
});
|
|
5277
|
+
}
|
|
5384
5278
|
return undefined;
|
|
5385
5279
|
}
|
|
5386
|
-
function reverseLineCap(
|
|
5387
|
-
var
|
|
5280
|
+
function reverseLineCap(GECode) {
|
|
5281
|
+
var _map_GECode;
|
|
5388
5282
|
var map = {
|
|
5389
5283
|
0: IRLineCap.Butt,
|
|
5390
5284
|
1: IRLineCap.Round,
|
|
5391
5285
|
2: IRLineCap.Square
|
|
5392
5286
|
};
|
|
5393
|
-
return (
|
|
5287
|
+
return (_map_GECode = map[GECode]) != null ? _map_GECode : IRLineCap.Butt;
|
|
5394
5288
|
}
|
|
5395
|
-
function reverseLineJoin(
|
|
5396
|
-
var
|
|
5289
|
+
function reverseLineJoin(GECode) {
|
|
5290
|
+
var _map_GECode;
|
|
5397
5291
|
var map = {
|
|
5398
5292
|
0: IRLineJoin.Round,
|
|
5399
5293
|
1: IRLineJoin.Bevel,
|
|
5400
5294
|
2: IRLineJoin.Miter
|
|
5401
5295
|
};
|
|
5402
|
-
return (
|
|
5403
|
-
}
|
|
5404
|
-
function reverseShapeFillRule(geCode) {
|
|
5405
|
-
var _map_geCode;
|
|
5406
|
-
var map = {
|
|
5407
|
-
0: IRShapeFillRule.NonZero,
|
|
5408
|
-
1: IRShapeFillRule.EvenOdd
|
|
5409
|
-
};
|
|
5410
|
-
return (_map_geCode = map[geCode]) != null ? _map_geCode : IRShapeFillRule.NonZero;
|
|
5296
|
+
return (_map_GECode = map[GECode]) != null ? _map_GECode : IRLineJoin.Miter;
|
|
5411
5297
|
}
|
|
5412
5298
|
function reverseCustomPaths(component, ratio) {
|
|
5413
5299
|
var points = component['points'];
|
|
@@ -5419,8 +5305,8 @@ function reverseCustomPaths(component, ratio) {
|
|
|
5419
5305
|
}
|
|
5420
5306
|
return shapes.map(function(shape) {
|
|
5421
5307
|
var pathPoints = [];
|
|
5422
|
-
var
|
|
5423
|
-
var
|
|
5308
|
+
var pathInTangents = [];
|
|
5309
|
+
var pathOutTangents = [];
|
|
5424
5310
|
for(var _iterator = _create_for_of_iterator_helper_loose(shape.indexes), _step; !(_step = _iterator()).done;){
|
|
5425
5311
|
var idx = _step.value;
|
|
5426
5312
|
var _ref, _ref1, _ref2, _ref3;
|
|
@@ -5431,34 +5317,50 @@ function reverseCustomPaths(component, ratio) {
|
|
|
5431
5317
|
x: pt.x / ratio,
|
|
5432
5318
|
y: -pt.y / ratio
|
|
5433
5319
|
});
|
|
5434
|
-
|
|
5320
|
+
pathInTangents.push({
|
|
5435
5321
|
x: ((_ref = ei == null ? void 0 : ei.x) != null ? _ref : 0) / ratio,
|
|
5436
5322
|
y: -((_ref1 = ei == null ? void 0 : ei.y) != null ? _ref1 : 0) / ratio
|
|
5437
5323
|
});
|
|
5438
|
-
|
|
5324
|
+
pathOutTangents.push({
|
|
5439
5325
|
x: ((_ref2 = eo == null ? void 0 : eo.x) != null ? _ref2 : 0) / ratio,
|
|
5440
5326
|
y: -((_ref3 = eo == null ? void 0 : eo.y) != null ? _ref3 : 0) / ratio
|
|
5441
5327
|
});
|
|
5442
5328
|
}
|
|
5443
5329
|
return {
|
|
5444
5330
|
points: pathPoints,
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5331
|
+
inTangents: pathInTangents,
|
|
5332
|
+
outTangents: pathOutTangents,
|
|
5333
|
+
closed: shape.close
|
|
5448
5334
|
};
|
|
5449
5335
|
});
|
|
5450
5336
|
}
|
|
5451
|
-
function
|
|
5337
|
+
function readScaledNumber(component, key, ratio) {
|
|
5452
5338
|
var value = component[key];
|
|
5453
|
-
if (typeof value
|
|
5454
|
-
|
|
5339
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) {
|
|
5340
|
+
return undefined;
|
|
5455
5341
|
}
|
|
5342
|
+
return value / ratio;
|
|
5456
5343
|
}
|
|
5457
|
-
function
|
|
5344
|
+
function readOptionalNumberField(component, key) {
|
|
5458
5345
|
var value = component[key];
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5346
|
+
var _obj;
|
|
5347
|
+
return typeof value === 'number' && Number.isFinite(value) ? (_obj = {}, _obj[key] = value, _obj) : {};
|
|
5348
|
+
}
|
|
5349
|
+
function readPointCount(component) {
|
|
5350
|
+
var value = component['pointCount'];
|
|
5351
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= 2 ? value : undefined;
|
|
5352
|
+
}
|
|
5353
|
+
function resolveTextureAsset(textureRef, ctx) {
|
|
5354
|
+
var texture = resolveDataPath(ctx.textureById, textureRef);
|
|
5355
|
+
var sourceRef = texture == null ? void 0 : texture['source'];
|
|
5356
|
+
var image = sourceRef != null ? resolveDataPath(ctx.imageById, sourceRef) : undefined;
|
|
5357
|
+
var url = image == null ? void 0 : image['url'];
|
|
5358
|
+
return typeof url === 'string' && url.trim() !== '' ? {
|
|
5359
|
+
url: url
|
|
5360
|
+
} : undefined;
|
|
5361
|
+
}
|
|
5362
|
+
function isTextureScaleMode(value) {
|
|
5363
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= 0 && value <= 3;
|
|
5462
5364
|
}
|
|
5463
5365
|
|
|
5464
5366
|
function reverseLayerTiming(delay, duration, frameRate) {
|
|
@@ -5499,7 +5401,7 @@ function mergeNullSpritePairs(descriptors, ctx) {
|
|
|
5499
5401
|
// child is exactly one same-name visual sprite. ir2ge's emitNullSpritePair
|
|
5500
5402
|
// produces precisely this shape (null + one same-name child). If the null
|
|
5501
5403
|
// has any OTHER children, it is a genuine Lottie parent null — merging it
|
|
5502
|
-
// into a
|
|
5404
|
+
// into a single semantic layer would change the anchor those other children are
|
|
5503
5405
|
// parented against, shifting them. Leave such nulls intact.
|
|
5504
5406
|
if (children.length !== 1) {
|
|
5505
5407
|
continue;
|
|
@@ -5613,19 +5515,17 @@ function isRecord$1(value) {
|
|
|
5613
5515
|
return value != null && (typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && !Array.isArray(value);
|
|
5614
5516
|
}
|
|
5615
5517
|
function mergeNullAndSprite(nullDesc, childDesc, ctx) {
|
|
5616
|
-
var _childDesc_layer_transform;
|
|
5518
|
+
var _childDesc_layer_transform, _merged_specific;
|
|
5617
5519
|
var merged = _extends({}, nullDesc.layer);
|
|
5618
5520
|
// Take type from child
|
|
5619
5521
|
merged.type = childDesc.layer.type;
|
|
5620
5522
|
merged.asset = childDesc.layer.asset;
|
|
5621
5523
|
merged.text = childDesc.layer.text;
|
|
5622
5524
|
merged.shapes = childDesc.layer.shapes;
|
|
5623
|
-
merged.shapeLayer = childDesc.layer.shapeLayer;
|
|
5624
5525
|
merged.solidColor = childDesc.layer.solidColor;
|
|
5625
5526
|
merged.blendMode = childDesc.layer.blendMode;
|
|
5626
|
-
merged.transformSplit = true;
|
|
5627
5527
|
// Visibility from child
|
|
5628
|
-
merged.
|
|
5528
|
+
merged.visible = childDesc.layer.visible;
|
|
5629
5529
|
// Compute anchor from child position offset
|
|
5630
5530
|
var childTransform = childDesc.item['transform'];
|
|
5631
5531
|
var childPosition = childTransform == null ? void 0 : childTransform['position'];
|
|
@@ -5646,7 +5546,9 @@ function mergeNullAndSprite(nullDesc, childDesc, ctx) {
|
|
|
5646
5546
|
0
|
|
5647
5547
|
]
|
|
5648
5548
|
};
|
|
5649
|
-
merged.
|
|
5549
|
+
merged.localBounds = {
|
|
5550
|
+
x: 0,
|
|
5551
|
+
y: 0,
|
|
5650
5552
|
width: layerWidth,
|
|
5651
5553
|
height: layerHeight
|
|
5652
5554
|
};
|
|
@@ -5659,17 +5561,21 @@ function mergeNullAndSprite(nullDesc, childDesc, ctx) {
|
|
|
5659
5561
|
merged.transform.opacity = childDesc.layer.transform.opacity;
|
|
5660
5562
|
}
|
|
5661
5563
|
// The merged layer renders the child's visual component, but the parent owns
|
|
5662
|
-
// transform animation passthrough. Deep-merge
|
|
5663
|
-
//
|
|
5664
|
-
if (childDesc.layer.
|
|
5665
|
-
var
|
|
5666
|
-
var
|
|
5667
|
-
var
|
|
5668
|
-
merged.
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
}
|
|
5564
|
+
// transform animation passthrough. Deep-merge specific.effects so neither side
|
|
5565
|
+
// loses GE reconstruction data.
|
|
5566
|
+
if (childDesc.layer.specific != null) {
|
|
5567
|
+
var _merged_specific1;
|
|
5568
|
+
var parentEffects = (_merged_specific1 = merged.specific) == null ? void 0 : _merged_specific1.effects;
|
|
5569
|
+
var childEffects = childDesc.layer.specific.effects;
|
|
5570
|
+
merged.specific = _extends({}, merged.specific, childDesc.layer.specific, (parentEffects != null || childEffects != null) && {
|
|
5571
|
+
effects: _extends({}, parentEffects != null ? parentEffects : {}, childEffects != null ? childEffects : {})
|
|
5572
|
+
});
|
|
5672
5573
|
}
|
|
5574
|
+
merged.specific = _extends({}, merged.specific, {
|
|
5575
|
+
effects: _extends({}, (_merged_specific = merged.specific) == null ? void 0 : _merged_specific.effects, {
|
|
5576
|
+
sourceHierarchy: 'null-sprite-pair'
|
|
5577
|
+
})
|
|
5578
|
+
});
|
|
5673
5579
|
return {
|
|
5674
5580
|
itemId: nullDesc.itemId,
|
|
5675
5581
|
item: nullDesc.item,
|
|
@@ -5698,7 +5604,7 @@ function resolveHierarchy(descriptors, ctx) {
|
|
|
5698
5604
|
}
|
|
5699
5605
|
desc1.layer.parent = {
|
|
5700
5606
|
index: parentIndex,
|
|
5701
|
-
|
|
5607
|
+
lifetimeMode: 'clipped'
|
|
5702
5608
|
};
|
|
5703
5609
|
var parentAnchor = getAnchorFromDesc(parentDesc);
|
|
5704
5610
|
var pos = (_desc_layer_transform = desc1.layer.transform) == null ? void 0 : _desc_layer_transform.position;
|
|
@@ -5763,7 +5669,7 @@ function convertGEToIR(scene, options) {
|
|
|
5763
5669
|
return d.layer;
|
|
5764
5670
|
});
|
|
5765
5671
|
return normalizeJsonValue({
|
|
5766
|
-
source: '
|
|
5672
|
+
source: 'effects',
|
|
5767
5673
|
name: ctx.compositionName,
|
|
5768
5674
|
width: ctx.width,
|
|
5769
5675
|
height: ctx.height,
|
|
@@ -5773,14 +5679,14 @@ function convertGEToIR(scene, options) {
|
|
|
5773
5679
|
backgroundColor: ctx.backgroundColor,
|
|
5774
5680
|
endBehavior: ctx.endBehavior,
|
|
5775
5681
|
layers: layers,
|
|
5776
|
-
|
|
5682
|
+
specific: buildCompositionSpecific(scene, ctx.compositionId, itemIds, ctx)
|
|
5777
5683
|
});
|
|
5778
5684
|
}
|
|
5779
5685
|
function parseItemToLayer(item, itemId, index, ctx) {
|
|
5780
|
-
var _item_name, _item_visible, _ref, _item_delay, _ref1, _item_duration;
|
|
5686
|
+
var _item_name, _item_visible, _ref, _item_delay, _ref1, _item_duration, _ref2;
|
|
5781
5687
|
var _item_transform;
|
|
5782
5688
|
var name = (_item_name = item['name']) != null ? _item_name : "layer_" + index;
|
|
5783
|
-
var
|
|
5689
|
+
var GEType = item['type'];
|
|
5784
5690
|
var visible = (_item_visible = item['visible']) != null ? _item_visible : true;
|
|
5785
5691
|
var rawTransformPassthrough;
|
|
5786
5692
|
var timeline = parseTimeline(itemId, ctx);
|
|
@@ -5789,19 +5695,19 @@ function parseItemToLayer(item, itemId, index, ctx) {
|
|
|
5789
5695
|
var time = reverseLayerTiming(delay, duration, ctx.frameRate);
|
|
5790
5696
|
var componentData = parseComponent(item, ctx);
|
|
5791
5697
|
var type;
|
|
5792
|
-
if (
|
|
5698
|
+
if (GEType === '3') {
|
|
5793
5699
|
type = 'null';
|
|
5794
|
-
} else if ((componentData == null ? void 0 : componentData.type) === 'text' ||
|
|
5700
|
+
} else if ((componentData == null ? void 0 : componentData.type) === 'text' || GEType === 'text') {
|
|
5795
5701
|
type = 'text';
|
|
5796
|
-
} else if ((componentData == null ? void 0 : componentData.type) === 'shape' ||
|
|
5702
|
+
} else if ((componentData == null ? void 0 : componentData.type) === 'shape' || GEType === 'shape') {
|
|
5797
5703
|
type = 'shape';
|
|
5798
5704
|
} else if ((componentData == null ? void 0 : componentData.type) === 'image') {
|
|
5799
5705
|
type = 'image';
|
|
5800
|
-
} else if (
|
|
5706
|
+
} else if (GEType === '7') {
|
|
5801
5707
|
type = 'precomp';
|
|
5802
5708
|
} else if ((componentData == null ? void 0 : componentData.solidColor) != null) {
|
|
5803
5709
|
type = 'solid';
|
|
5804
|
-
} else if (
|
|
5710
|
+
} else if (GEType === '1') {
|
|
5805
5711
|
type = 'solid';
|
|
5806
5712
|
} else {
|
|
5807
5713
|
type = 'null';
|
|
@@ -5813,18 +5719,18 @@ function parseItemToLayer(item, itemId, index, ctx) {
|
|
|
5813
5719
|
var staticChannels = parseStaticTransform(itemTransform, ctx);
|
|
5814
5720
|
transform = _extends({}, staticChannels);
|
|
5815
5721
|
// Text layers carry their pixel-sizing scale on transform.scale
|
|
5816
|
-
// (scale = ratio ×
|
|
5817
|
-
//
|
|
5722
|
+
// (scale = ratio × local bounds). ir2ge RECOMPUTES this item scale from
|
|
5723
|
+
// localBounds in processVisualLayer, so keeping it in the IR scale channel
|
|
5818
5724
|
// would make buildSizeAnim emit a duplicate sizeOverLifetime constant that
|
|
5819
5725
|
// double-scales the glyphs (garbled/stretched text). Drop the static scale
|
|
5820
5726
|
// for text; genuine text scale animation still rides through
|
|
5821
|
-
//
|
|
5727
|
+
// specific.effects.sizeOverLifetime passthrough.
|
|
5822
5728
|
if (type === 'text') {
|
|
5823
5729
|
delete transform.scale;
|
|
5824
5730
|
}
|
|
5825
5731
|
}
|
|
5826
5732
|
// Parse animation from timeline tracks — passthrough raw GE animation data
|
|
5827
|
-
// via
|
|
5733
|
+
// via specific.effects. Converting to IR keyframes and back would lose data (ir2ge
|
|
5828
5734
|
// only handles specific ValueType variants and makes assumptions about
|
|
5829
5735
|
// static positions). The raw data is injected verbatim by ir2ge.
|
|
5830
5736
|
if ((timeline == null ? void 0 : timeline.transformAsset) != null) {
|
|
@@ -5838,10 +5744,6 @@ function parseItemToLayer(item, itemId, index, ctx) {
|
|
|
5838
5744
|
if (animChannels.rotation != null) {
|
|
5839
5745
|
transform.rotation = animChannels.rotation;
|
|
5840
5746
|
}
|
|
5841
|
-
if (animChannels.separatedRotation != null) {
|
|
5842
|
-
transform.separatedRotation = animChannels.separatedRotation;
|
|
5843
|
-
delete transform.rotation;
|
|
5844
|
-
}
|
|
5845
5747
|
if (animChannels.scale != null) {
|
|
5846
5748
|
transform.scale = animChannels.scale;
|
|
5847
5749
|
}
|
|
@@ -5883,10 +5785,10 @@ function parseItemToLayer(item, itemId, index, ctx) {
|
|
|
5883
5785
|
var _item_transform1;
|
|
5884
5786
|
var itemSize = (_item_transform1 = item['transform']) == null ? void 0 : _item_transform1['size'];
|
|
5885
5787
|
if (itemSize != null) {
|
|
5886
|
-
var
|
|
5788
|
+
var _ref3;
|
|
5887
5789
|
var layerWidth = itemSize.x / ctx.ratio;
|
|
5888
5790
|
var layerHeight = itemSize.y / ctx.ratio;
|
|
5889
|
-
var anchorScale = (
|
|
5791
|
+
var anchorScale = (_ref3 = componentData == null ? void 0 : componentData.anchorScale) != null ? _ref3 : [
|
|
5890
5792
|
0.5,
|
|
5891
5793
|
0.5
|
|
5892
5794
|
];
|
|
@@ -5951,35 +5853,46 @@ function parseItemToLayer(item, itemId, index, ctx) {
|
|
|
5951
5853
|
}
|
|
5952
5854
|
}
|
|
5953
5855
|
}
|
|
5954
|
-
//
|
|
5955
|
-
var
|
|
5856
|
+
// Layer-local bounds from item transform.size
|
|
5857
|
+
var localBounds;
|
|
5956
5858
|
var itemSize1 = (_item_transform = item['transform']) == null ? void 0 : _item_transform['size'];
|
|
5957
|
-
if (itemSize1 != null) {
|
|
5958
|
-
|
|
5859
|
+
if (itemSize1 != null && itemSize1.x > 0 && itemSize1.y > 0) {
|
|
5860
|
+
localBounds = {
|
|
5861
|
+
x: 0,
|
|
5862
|
+
y: 0,
|
|
5959
5863
|
width: itemSize1.x / ctx.ratio,
|
|
5960
5864
|
height: itemSize1.y / ctx.ratio
|
|
5961
5865
|
};
|
|
5962
5866
|
}
|
|
5867
|
+
var text = (componentData == null ? void 0 : componentData.text) == null ? undefined : _extends({}, componentData.text);
|
|
5868
|
+
var solidColor = type === 'solid' ? (_ref2 = componentData == null ? void 0 : componentData.solidColor) != null ? _ref2 : [
|
|
5869
|
+
1,
|
|
5870
|
+
1,
|
|
5871
|
+
1,
|
|
5872
|
+
1
|
|
5873
|
+
] : componentData == null ? void 0 : componentData.solidColor;
|
|
5874
|
+
if ((text == null ? void 0 : text.autoWidth) === false) {
|
|
5875
|
+
var _text, _width, _text1, _height;
|
|
5876
|
+
(_width = (_text = text).width) != null ? _width : _text.width = localBounds == null ? void 0 : localBounds.width;
|
|
5877
|
+
(_height = (_text1 = text).height) != null ? _height : _text1.height = localBounds == null ? void 0 : localBounds.height;
|
|
5878
|
+
}
|
|
5963
5879
|
var layer = {
|
|
5964
5880
|
index: index,
|
|
5965
5881
|
name: name,
|
|
5966
5882
|
type: type,
|
|
5967
5883
|
time: time,
|
|
5968
|
-
|
|
5969
|
-
hidden: !visible,
|
|
5970
|
-
enabled: visible
|
|
5971
|
-
},
|
|
5884
|
+
visible: visible,
|
|
5972
5885
|
transform: transform,
|
|
5973
|
-
|
|
5886
|
+
localBounds: localBounds
|
|
5974
5887
|
};
|
|
5975
5888
|
if ((componentData == null ? void 0 : componentData.asset) != null) {
|
|
5976
5889
|
layer.asset = componentData.asset;
|
|
5977
5890
|
}
|
|
5978
|
-
if (
|
|
5979
|
-
layer.solidColor =
|
|
5891
|
+
if (solidColor != null) {
|
|
5892
|
+
layer.solidColor = solidColor;
|
|
5980
5893
|
}
|
|
5981
|
-
if (
|
|
5982
|
-
layer.text =
|
|
5894
|
+
if (text != null) {
|
|
5895
|
+
layer.text = text;
|
|
5983
5896
|
}
|
|
5984
5897
|
if ((componentData == null ? void 0 : componentData.shapes) != null) {
|
|
5985
5898
|
layer.shapes = componentData.shapes;
|
|
@@ -5987,38 +5900,39 @@ function parseItemToLayer(item, itemId, index, ctx) {
|
|
|
5987
5900
|
if ((componentData == null ? void 0 : componentData.blendMode) != null) {
|
|
5988
5901
|
layer.blendMode = componentData.blendMode;
|
|
5989
5902
|
}
|
|
5990
|
-
var
|
|
5903
|
+
var GEComponentId = componentData == null ? void 0 : componentData.GEComponentId;
|
|
5991
5904
|
var rawMask = componentData == null ? void 0 : componentData.rawMask;
|
|
5992
|
-
var precompContent =
|
|
5905
|
+
var precompContent = GEType === '7' ? item['content'] : undefined;
|
|
5993
5906
|
var precompRefId = isRecord(precompContent == null ? void 0 : precompContent['options']) ? precompContent['options']['refId'] : undefined;
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
5907
|
+
// Mask round-trip: GEComponentId is the rendezvous key linking a target's
|
|
5908
|
+
// mask.reference.id (a GE1 component id) to the regenerated GE2 component id.
|
|
5909
|
+
// ir2ge copies specific.effects.mask onto the rebuilt component and a post-process pass
|
|
5910
|
+
// remaps the stale reference id. sourceHierarchy records the pre-merge shape;
|
|
5911
|
+
// mergeNullSpritePairs replaces it when a pair collapses into one semantic layer.
|
|
5912
|
+
var effectsSpecific = _extends({
|
|
5913
|
+
sourceHierarchy: 'single-item'
|
|
5914
|
+
}, rawTransformPassthrough != null ? rawTransformPassthrough : {}, rawColorOverLifetime != null && {
|
|
5915
|
+
colorOverLifetime: rawColorOverLifetime
|
|
5916
|
+
}, GEComponentId != null && {
|
|
5917
|
+
sourceComponentId: GEComponentId
|
|
5918
|
+
}, rawMask != null && {
|
|
5919
|
+
mask: rawMask
|
|
5920
|
+
}, typeof precompRefId === 'string' && {
|
|
5921
|
+
precompRefId: precompRefId
|
|
5922
|
+
}, precompContent != null && {
|
|
5923
|
+
precompContent: cloneJson(precompContent)
|
|
5924
|
+
});
|
|
5925
|
+
layer.specific = _extends({}, layer.specific, {
|
|
5926
|
+
effects: effectsSpecific
|
|
5927
|
+
});
|
|
6014
5928
|
return layer;
|
|
6015
5929
|
}
|
|
6016
|
-
function
|
|
5930
|
+
function buildCompositionSpecific(scene, compositionId, itemIds, ctx) {
|
|
6017
5931
|
if (!hasPrecompItem(itemIds, ctx)) {
|
|
6018
5932
|
return undefined;
|
|
6019
5933
|
}
|
|
6020
5934
|
return {
|
|
6021
|
-
|
|
5935
|
+
effects: {
|
|
6022
5936
|
sourceCompositionId: compositionId,
|
|
6023
5937
|
sourceScene: cloneJson(scene)
|
|
6024
5938
|
}
|
|
@@ -6041,16 +5955,14 @@ function isRecord(value) {
|
|
|
6041
5955
|
* Read-side accessors for the `IRLayerNode.specific.lottie` slot.
|
|
6042
5956
|
*
|
|
6043
5957
|
* The shared generator must not branch on lottie semantics directly — every
|
|
6044
|
-
*
|
|
5958
|
+
* Lottie-specific reads go through these helpers so the rest of ir2ge stays
|
|
6045
5959
|
* agnostic to the producing tool.
|
|
6046
5960
|
*
|
|
6047
|
-
*
|
|
6048
|
-
* `specific.lottie.explicitParent`. It was promoted to a generic IR field
|
|
6049
|
-
* (`IRLayerReference.linkKind`); the accessor now lives at `./parent-link.ts`.
|
|
5961
|
+
* Parent lifetime semantics are represented directly by the generic IR relation.
|
|
6050
5962
|
*/ function readLottieSpecific(layer) {
|
|
6051
5963
|
var _layer_specific;
|
|
6052
5964
|
return (_layer_specific = layer.specific) == null ? void 0 : _layer_specific.lottie;
|
|
6053
5965
|
}
|
|
6054
5966
|
|
|
6055
|
-
export { DEFAULT_CAMERA_FOV, DEFAULT_CAMERA_Z, DEFAULT_CLIP_MODE, assembleScene, buildTimelineTracks, convert2dTo3dPoint, convertGEToIR, convertIRToGE, createId, estimateTextWidth, get2dTo3dRatio, irPositionKeyframesToGE, irScalarKeyframesToGE, irVectorKeyframesToGE,
|
|
5967
|
+
export { DEFAULT_CAMERA_FOV, DEFAULT_CAMERA_Z, DEFAULT_CLIP_MODE, assembleScene, buildTimelineTracks, convert2dTo3dPoint, convertGEToIR, convertIRToGE, createId, estimateTextWidth, get2dTo3dRatio, getEffectsCompositionSpecific, getEffectsLayerSpecific, hasEffectsAnimationPassthrough, hasEffectsColorAnimationPassthrough, hasIndependentParentLifetime, invalidateEffectsLayerSpecific, irPositionKeyframesToGE, irScalarKeyframesToGE, irVectorKeyframesToGE, lerp, normalizeChildVisibilityByParentDelays, readLottieSpecific, roundNumber, shouldUseKeyframeMode, toDataPath };
|
|
6056
5968
|
//# sourceMappingURL=index.mjs.map
|