@galacean/effects-threejs 2.5.0-alpha.5 → 2.5.0

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/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.5.0-alpha.5
6
+ * Version: v2.5.0
7
7
  */
8
8
 
9
9
  'use strict';
@@ -14192,40 +14192,60 @@ var BezierQuat = /*#__PURE__*/ function() {
14192
14192
  return BezierQuat;
14193
14193
  }();
14194
14194
  var BezierEasing = /*#__PURE__*/ function() {
14195
- function BezierEasing(mX1, mY1, mX2, mY2) {
14196
- this.mX1 = mX1;
14197
- this.mY1 = mY1;
14198
- this.mX2 = mX2;
14199
- this.mY2 = mY2;
14195
+ function BezierEasing(control1YOrControl1X, control2YOrControl1Y, control2X, control2Y) {
14200
14196
  this.precomputed = false;
14197
+ this.control1 = new Vector2();
14198
+ this.control2 = new Vector2();
14199
+ this.weighted = false;
14200
+ this.isConstant = false;
14201
14201
  this.mSampleValues = new Array(kSplineTableSize);
14202
+ if (control1YOrControl1X !== undefined && control2YOrControl1Y !== undefined && control2X !== undefined && control2Y !== undefined) {
14203
+ this.control1.x = control1YOrControl1X;
14204
+ this.control1.y = control2YOrControl1Y;
14205
+ this.control2.x = control2X;
14206
+ this.control2.y = control2Y;
14207
+ this.weighted = true;
14208
+ } else if (control1YOrControl1X !== undefined && control2YOrControl1Y !== undefined) {
14209
+ this.control1.x = 1 / 3;
14210
+ this.control1.y = control1YOrControl1X;
14211
+ this.control2.x = 2 / 3;
14212
+ this.control2.y = control2YOrControl1Y;
14213
+ } else {
14214
+ this.isConstant = true;
14215
+ }
14202
14216
  }
14203
14217
  var _proto = BezierEasing.prototype;
14204
- _proto.precompute = function precompute() {
14205
- this.precomputed = true;
14206
- if (this.mX1 !== this.mY1 || this.mX2 !== this.mY2) {
14207
- this.calcSampleValues();
14208
- }
14209
- };
14210
14218
  _proto.getValue = function getValue(x) {
14211
- if (this.mX1 === this.mY1 && this.mX2 === this.mY2) {
14212
- return x;
14213
- }
14214
- if (isNaN(this.mY1) || isNaN(this.mY2)) {
14219
+ if (this.isConstant) {
14215
14220
  return 0;
14216
14221
  }
14222
+ if (this.control1.x === this.control1.y && this.control2.x === this.control2.y) {
14223
+ return x;
14224
+ }
14217
14225
  if (x === 0 || x === 1) {
14218
14226
  return x;
14219
14227
  }
14228
+ if (!this.weighted) {
14229
+ return this.bezierInterpolate(0, this.control1.y, this.control2.y, 1, x);
14230
+ }
14220
14231
  if (!this.precomputed) {
14221
14232
  this.precompute();
14222
14233
  }
14223
- var value = calcBezier(this.getTForX(x), this.mY1, this.mY2);
14234
+ var value = calcBezier(this.getTForX(x), this.control1.y, this.control2.y);
14224
14235
  return value;
14225
14236
  };
14237
+ _proto.bezierInterpolate = function bezierInterpolate(pStart, pControl1, pControl2, pEnd, t) {
14238
+ // Formula from Wikipedia article on Bezier curves
14239
+ var omt = 1.0 - t;
14240
+ var omt2 = omt * omt;
14241
+ var omt3 = omt2 * omt;
14242
+ var t2 = t * t;
14243
+ var t3 = t2 * t;
14244
+ return pStart * omt3 + pControl1 * omt2 * t * 3.0 + pControl2 * omt * t2 * 3.0 + pEnd * t3;
14245
+ };
14226
14246
  _proto.calcSampleValues = function calcSampleValues() {
14227
14247
  for(var i = 0; i < kSplineTableSize; ++i){
14228
- this.mSampleValues[i] = calcBezier(i * kSampleStepSize, this.mX1, this.mX2);
14248
+ this.mSampleValues[i] = calcBezier(i * kSampleStepSize, this.control1.x, this.control2.x);
14229
14249
  }
14230
14250
  };
14231
14251
  _proto.getTForX = function getTForX(aX) {
@@ -14238,14 +14258,20 @@ var BezierEasing = /*#__PURE__*/ function() {
14238
14258
  // Interpolate to provide an initial guess for t
14239
14259
  var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample + 1] - mSampleValues[currentSample]);
14240
14260
  var guessForT = intervalStart + dist * kSampleStepSize;
14241
- var initialSlope = getSlope(guessForT, this.mX1, this.mX2);
14261
+ var initialSlope = getSlope(guessForT, this.control1.x, this.control2.x);
14242
14262
  if (initialSlope >= NEWTON_MIN_SLOPE) {
14243
- return newtonRaphsonIterate(aX, guessForT, this.mX1, this.mX2);
14263
+ return newtonRaphsonIterate(aX, guessForT, this.control1.x, this.control2.x);
14244
14264
  }
14245
14265
  if (initialSlope === 0.0) {
14246
14266
  return guessForT;
14247
14267
  }
14248
- return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, this.mX1, this.mX2);
14268
+ return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, this.control1.x, this.control2.x);
14269
+ };
14270
+ _proto.precompute = function precompute() {
14271
+ this.precomputed = true;
14272
+ if (this.control1.x !== this.control1.y || this.control2.x !== this.control2.y) {
14273
+ this.calcSampleValues();
14274
+ }
14249
14275
  };
14250
14276
  return BezierEasing;
14251
14277
  }();
@@ -14804,148 +14830,6 @@ var LineSegments = /*#__PURE__*/ function(ValueGetter) {
14804
14830
  };
14805
14831
  return LineSegments;
14806
14832
  }(ValueGetter);
14807
- var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
14808
- _inherits(BezierCurve, ValueGetter);
14809
- function BezierCurve() {
14810
- return ValueGetter.apply(this, arguments);
14811
- }
14812
- var _proto = BezierCurve.prototype;
14813
- _proto.onCreate = function onCreate(props) {
14814
- var keyframes = props;
14815
- this.curveMap = {};
14816
- this.keys = [];
14817
- for(var i = 0; i < keyframes.length - 1; i++){
14818
- var leftKeyframe = keyframes[i];
14819
- var rightKeyframe = keyframes[i + 1];
14820
- var _buildEasingCurve = buildEasingCurve(leftKeyframe, rightKeyframe), points = _buildEasingCurve.points, curve = _buildEasingCurve.curve, timeInterval = _buildEasingCurve.timeInterval, valueInterval = _buildEasingCurve.valueInterval;
14821
- var s = points[0];
14822
- var e = points[points.length - 1];
14823
- this.keys.push([].concat(s.toArray(), points[1].toArray()));
14824
- this.keys.push([].concat(e.toArray(), points[2].toArray()));
14825
- this.curveMap[s.x + "&" + e.x] = {
14826
- points: points,
14827
- timeInterval: timeInterval,
14828
- valueInterval: valueInterval,
14829
- curve: curve,
14830
- timeStart: Number(s.x),
14831
- timeEnd: Number(e.x)
14832
- };
14833
- }
14834
- this.startKeyframe = keyframes[0];
14835
- this.endKeyframe = keyframes[keyframes.length - 1];
14836
- this.keyTimeData = Object.keys(this.curveMap);
14837
- };
14838
- _proto.getValue = function getValue(time) {
14839
- var result = 0;
14840
- var keyTimeData = this.keyTimeData;
14841
- var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
14842
- var keyTimeEnd = this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
14843
- if (time <= keyTimeStart) {
14844
- keyframeInfo.getPointIndexInCurve(this.startKeyframe, keyframeInfo.pointIndexCache);
14845
- return this.startKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
14846
- }
14847
- if (time >= keyTimeEnd) {
14848
- keyframeInfo.getPointIndexInCurve(this.endKeyframe, keyframeInfo.pointIndexCache);
14849
- return this.endKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
14850
- }
14851
- for(var i = 0; i < keyTimeData.length; i++){
14852
- var xMin = this.curveMap[keyTimeData[i]].timeStart;
14853
- var xMax = this.curveMap[keyTimeData[i]].timeEnd;
14854
- // const [xMin, xMax] = keyTimeData[i].split('&');
14855
- if (time >= Number(xMin) && time < Number(xMax)) {
14856
- result = this.getCurveValue(keyTimeData[i], time);
14857
- break;
14858
- }
14859
- }
14860
- return result;
14861
- };
14862
- _proto.getIntegrateValue = function getIntegrateValue(t0, t1, ts) {
14863
- if (ts === void 0) ts = 1;
14864
- var time = (t1 - t0) / ts;
14865
- var result = 0;
14866
- var keyTimeData = Object.keys(this.curveMap);
14867
- var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
14868
- if (time <= keyTimeStart) {
14869
- return 0;
14870
- }
14871
- for(var i = 0; i < keyTimeData.length; i++){
14872
- var xMin = this.curveMap[keyTimeData[i]].timeStart;
14873
- var xMax = this.curveMap[keyTimeData[i]].timeEnd;
14874
- if (time >= Number(xMax)) {
14875
- result += ts * this.getCurveIntegrateValue(keyTimeData[i], Number(xMax));
14876
- }
14877
- if (time >= Number(xMin) && time < Number(xMax)) {
14878
- result += ts * this.getCurveIntegrateValue(keyTimeData[i], time);
14879
- break;
14880
- }
14881
- }
14882
- return result;
14883
- };
14884
- _proto.getIntegrateByTime = function getIntegrateByTime(t0, t1) {
14885
- return this.getIntegrateValue(0, t1) - this.getIntegrateValue(0, t0);
14886
- };
14887
- // 速度变化曲线面板移除后下线
14888
- _proto.getCurveIntegrateValue = function getCurveIntegrateValue(curveKey, time) {
14889
- var curveInfo = this.curveMap[curveKey];
14890
- var _curveInfo_points = curveInfo.points, p0 = _curveInfo_points[0];
14891
- var timeInterval = curveInfo.timeInterval;
14892
- var valueInterval = curveInfo.valueInterval;
14893
- var segments = 20;
14894
- var total = 0;
14895
- var h = (time - p0.x) / segments;
14896
- for(var i = 0; i <= segments; i++){
14897
- var t = i * h;
14898
- var normalizeTime = t / timeInterval;
14899
- var y = p0.y + valueInterval * curveInfo.curve.getValue(normalizeTime);
14900
- if (i === 0 || i === segments) {
14901
- total += y;
14902
- } else if (i % 2 === 1) {
14903
- total += 4 * y;
14904
- } else {
14905
- total += 2 * y;
14906
- }
14907
- }
14908
- total *= h / 3;
14909
- return total;
14910
- };
14911
- _proto.getCurveValue = function getCurveValue(curveKey, time) {
14912
- var curveInfo = this.curveMap[curveKey];
14913
- var _curveInfo_points = curveInfo.points, p0 = _curveInfo_points[0];
14914
- var timeInterval = curveInfo.timeInterval;
14915
- var valueInterval = curveInfo.valueInterval;
14916
- var normalizeTime = (time - p0.x) / timeInterval;
14917
- var value = curveInfo.curve.getValue(normalizeTime);
14918
- return p0.y + valueInterval * value;
14919
- };
14920
- _proto.toUniform = function toUniform(meta) {
14921
- var index = meta.index;
14922
- var count = this.keys.length;
14923
- meta.curves.push(this);
14924
- meta.index = index + count;
14925
- // 兼容 WebGL1
14926
- meta.max = Math.max(meta.max, count);
14927
- meta.curveCount += count;
14928
- return new Float32Array([
14929
- 5,
14930
- index + 1 / count,
14931
- index,
14932
- count
14933
- ]);
14934
- };
14935
- _proto.toData = function toData() {
14936
- var keys = this.keys;
14937
- var data = new Float32Array(keys.length * 4);
14938
- for(var i = 0, cursor = 0; i < keys.length; i++, cursor += 4){
14939
- data.set(keys[i], cursor);
14940
- }
14941
- return data;
14942
- };
14943
- _proto.getMaxTime = function getMaxTime() {
14944
- var keyTimeData = this.keyTimeData;
14945
- return this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
14946
- };
14947
- return BezierCurve;
14948
- }(ValueGetter);
14949
14833
  var PathSegments = /*#__PURE__*/ function(ValueGetter) {
14950
14834
  _inherits(PathSegments, ValueGetter);
14951
14835
  function PathSegments() {
@@ -15299,6 +15183,292 @@ var Vector2Curve = /*#__PURE__*/ function(ValueGetter) {
15299
15183
  return Vector2Curve;
15300
15184
  }(ValueGetter);
15301
15185
 
15186
+ exports.TangentMode = void 0;
15187
+ (function(TangentMode) {
15188
+ TangentMode[TangentMode["Cubic"] = 0] = "Cubic";
15189
+ TangentMode[TangentMode["Linear"] = 1] = "Linear";
15190
+ TangentMode[TangentMode["Constant"] = 2] = "Constant";
15191
+ })(exports.TangentMode || (exports.TangentMode = {}));
15192
+ exports.WeightedMode = void 0;
15193
+ (function(WeightedMode) {
15194
+ WeightedMode[WeightedMode["None"] = 0] = "None";
15195
+ WeightedMode[WeightedMode["In"] = 1] = "In";
15196
+ WeightedMode[WeightedMode["Out"] = 2] = "Out";
15197
+ WeightedMode[WeightedMode["Both"] = 3] = "Both";
15198
+ })(exports.WeightedMode || (exports.WeightedMode = {}));
15199
+ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
15200
+ _inherits(BezierCurve, ValueGetter);
15201
+ function BezierCurve() {
15202
+ return ValueGetter.apply(this, arguments);
15203
+ }
15204
+ var _proto = BezierCurve.prototype;
15205
+ _proto.onCreate = function onCreate(props) {
15206
+ this.keyFrames = props;
15207
+ var keyframes = this.keyFrames;
15208
+ this.curveMap = {};
15209
+ this.keys = [];
15210
+ this.curveInfos = [];
15211
+ for(var i = 0; i < keyframes.length - 1; i++){
15212
+ var leftKeyframe = keyframes[i];
15213
+ var rightKeyframe = keyframes[i + 1];
15214
+ var _buildBezierEasing = buildBezierEasing(leftKeyframe, rightKeyframe), points = _buildBezierEasing.points, curve = _buildBezierEasing.curve, timeInterval = _buildBezierEasing.timeInterval, valueInterval = _buildBezierEasing.valueInterval;
15215
+ var s = points[0];
15216
+ var e = points[points.length - 1];
15217
+ this.keys.push([].concat(s.toArray(), points[1].toArray()));
15218
+ this.keys.push([].concat(e.toArray(), points[2].toArray()));
15219
+ var curveInfo = {
15220
+ points: points,
15221
+ timeInterval: timeInterval,
15222
+ valueInterval: valueInterval,
15223
+ curve: curve,
15224
+ timeStart: Number(s.x),
15225
+ timeEnd: Number(e.x)
15226
+ };
15227
+ this.curveMap[s.x + "&" + e.x] = curveInfo;
15228
+ this.curveInfos.push(curveInfo);
15229
+ }
15230
+ };
15231
+ _proto.getValue = function getValue(time) {
15232
+ var result = 0;
15233
+ var keysNumber = this.keyFrames.length;
15234
+ if (time <= this.keyFrames[0].time) {
15235
+ result = this.keyFrames[0].value;
15236
+ } else if (time < this.keyFrames[keysNumber - 1].time) {
15237
+ for(var i = 0; i < this.keyFrames.length - 1; i++){
15238
+ var xMin = this.keyFrames[i].time;
15239
+ var xMax = this.keyFrames[i + 1].time;
15240
+ if (time >= xMin && time < xMax) {
15241
+ var curveInfo = this.curveInfos[i];
15242
+ var p0 = curveInfo.points[0];
15243
+ var timeInterval = curveInfo.timeInterval;
15244
+ var valueInterval = curveInfo.valueInterval;
15245
+ var normalizeTime = (time - p0.x) / timeInterval;
15246
+ var value = curveInfo.curve.getValue(normalizeTime);
15247
+ result = p0.y + valueInterval * value;
15248
+ break;
15249
+ }
15250
+ }
15251
+ } else if (time >= this.keyFrames[keysNumber - 1].time) {
15252
+ result = this.keyFrames[keysNumber - 1].value;
15253
+ }
15254
+ return result;
15255
+ };
15256
+ _proto.getIntegrateValue = function getIntegrateValue(t0, t1, ts) {
15257
+ if (ts === void 0) ts = 1;
15258
+ var time = (t1 - t0) / ts;
15259
+ var result = 0;
15260
+ var keyTimeData = Object.keys(this.curveMap);
15261
+ var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
15262
+ if (time <= keyTimeStart) {
15263
+ return 0;
15264
+ }
15265
+ for(var i = 0; i < keyTimeData.length; i++){
15266
+ var xMin = this.curveMap[keyTimeData[i]].timeStart;
15267
+ var xMax = this.curveMap[keyTimeData[i]].timeEnd;
15268
+ if (time >= Number(xMax)) {
15269
+ result += ts * this.getCurveIntegrateValue(keyTimeData[i], Number(xMax));
15270
+ }
15271
+ if (time >= Number(xMin) && time < Number(xMax)) {
15272
+ result += ts * this.getCurveIntegrateValue(keyTimeData[i], time);
15273
+ break;
15274
+ }
15275
+ }
15276
+ return result;
15277
+ };
15278
+ _proto.getIntegrateByTime = function getIntegrateByTime(t0, t1) {
15279
+ return this.getIntegrateValue(0, t1) - this.getIntegrateValue(0, t0);
15280
+ };
15281
+ // 速度变化曲线面板移除后下线
15282
+ _proto.getCurveIntegrateValue = function getCurveIntegrateValue(curveKey, time) {
15283
+ var curveInfo = this.curveMap[curveKey];
15284
+ var _curveInfo_points = curveInfo.points, p0 = _curveInfo_points[0];
15285
+ var timeInterval = curveInfo.timeInterval;
15286
+ var valueInterval = curveInfo.valueInterval;
15287
+ var segments = 20;
15288
+ var total = 0;
15289
+ var h = (time - p0.x) / segments;
15290
+ for(var i = 0; i <= segments; i++){
15291
+ var t = i * h;
15292
+ var normalizeTime = t / timeInterval;
15293
+ var y = p0.y + valueInterval * curveInfo.curve.getValue(normalizeTime);
15294
+ if (i === 0 || i === segments) {
15295
+ total += y;
15296
+ } else if (i % 2 === 1) {
15297
+ total += 4 * y;
15298
+ } else {
15299
+ total += 2 * y;
15300
+ }
15301
+ }
15302
+ total *= h / 3;
15303
+ return total;
15304
+ };
15305
+ _proto.toUniform = function toUniform(meta) {
15306
+ var index = meta.index;
15307
+ var count = this.keys.length;
15308
+ meta.curves.push(this);
15309
+ meta.index = index + count;
15310
+ // 兼容 WebGL1
15311
+ meta.max = Math.max(meta.max, count);
15312
+ meta.curveCount += count;
15313
+ return new Float32Array([
15314
+ 5,
15315
+ index + 1 / count,
15316
+ index,
15317
+ count
15318
+ ]);
15319
+ };
15320
+ _proto.toData = function toData() {
15321
+ var keys = this.keys;
15322
+ var data = new Float32Array(keys.length * 4);
15323
+ for(var i = 0, cursor = 0; i < keys.length; i++, cursor += 4){
15324
+ data.set(keys[i], cursor);
15325
+ }
15326
+ return data;
15327
+ };
15328
+ _proto.getMaxTime = function getMaxTime() {
15329
+ return this.keyFrames[this.keyFrames.length - 1].time;
15330
+ };
15331
+ return BezierCurve;
15332
+ }(ValueGetter);
15333
+ function buildBezierEasing(leftKeyframe, rightKeyframe) {
15334
+ var p0 = new Vector2(leftKeyframe.time, leftKeyframe.value);
15335
+ var p1 = new Vector2();
15336
+ var p2 = new Vector2();
15337
+ var p3 = new Vector2();
15338
+ var isWeighted = leftKeyframe.weightedMode === 2 || leftKeyframe.weightedMode === 3 || rightKeyframe.weightedMode === 1 || rightKeyframe.weightedMode === 3;
15339
+ var isConstant = leftKeyframe.tangentMode === 2;
15340
+ var rightDeltaX = (isWeighted ? leftKeyframe.outWeight : 1) * (rightKeyframe.time - leftKeyframe.time) / 3;
15341
+ p1.x = leftKeyframe.time + rightDeltaX;
15342
+ p1.y = leftKeyframe.value + rightDeltaX * (isConstant ? 0 : leftKeyframe.outSlope);
15343
+ var leftDeltaX = (isWeighted ? rightKeyframe.inWeight : 1) * (rightKeyframe.time - leftKeyframe.time) / 3;
15344
+ p2.x = rightKeyframe.time - leftDeltaX;
15345
+ p2.y = rightKeyframe.value - leftDeltaX * (isConstant ? 0 : rightKeyframe.inSlope);
15346
+ p3.x = rightKeyframe.time;
15347
+ p3.y = isConstant ? leftKeyframe.value : rightKeyframe.value;
15348
+ assertExist(p2);
15349
+ assertExist(p3);
15350
+ var timeInterval = p3.x - p0.x;
15351
+ var valueInterval = p3.y - p0.y;
15352
+ var y1, y2;
15353
+ var x1 = numberToFix((p1.x - p0.x) / timeInterval, 5);
15354
+ var x2 = numberToFix((p2.x - p0.x) / timeInterval, 5);
15355
+ if (decimalEqual(valueInterval, 0)) {
15356
+ y1 = y2 = NaN;
15357
+ } else {
15358
+ y1 = numberToFix((p1.y - p0.y) / valueInterval, 5);
15359
+ y2 = numberToFix((p2.y - p0.y) / valueInterval, 5);
15360
+ }
15361
+ if (x1 < 0) {
15362
+ console.error("Invalid bezier points, x1 < 0", p0, p1, p2, p3);
15363
+ x1 = 0;
15364
+ }
15365
+ if (x2 < 0) {
15366
+ console.error("Invalid bezier points, x2 < 0", p0, p1, p2, p3);
15367
+ x2 = 0;
15368
+ }
15369
+ if (x1 > 1) {
15370
+ console.error("Invalid bezier points, x1 >= 1", p0, p1, p2, p3);
15371
+ x1 = 1;
15372
+ }
15373
+ if (x2 > 1) {
15374
+ console.error("Invalid bezier points, x2 >= 1", p0, p1, p2, p3);
15375
+ x2 = 1;
15376
+ }
15377
+ var str = ("bez_" + x1 + "_" + y1 + "_" + x2 + "_" + y2).replace(/\./g, "p");
15378
+ var bezEasing;
15379
+ if (BezierMap[str]) {
15380
+ bezEasing = BezierMap[str];
15381
+ } else {
15382
+ if (decimalEqual(valueInterval, 0)) {
15383
+ bezEasing = new BezierEasing();
15384
+ } else if (isWeighted) {
15385
+ bezEasing = new BezierEasing(x1, y1, x2, y2);
15386
+ } else {
15387
+ bezEasing = new BezierEasing(y1, y2);
15388
+ }
15389
+ BezierMap[str] = bezEasing;
15390
+ }
15391
+ return {
15392
+ points: [
15393
+ p0,
15394
+ p1,
15395
+ p2,
15396
+ p3
15397
+ ],
15398
+ timeInterval: timeInterval,
15399
+ valueInterval: valueInterval,
15400
+ curve: bezEasing
15401
+ };
15402
+ }
15403
+ function oldBezierKeyFramesToNew(props) {
15404
+ var oldKeyframes = props;
15405
+ var keyframes = [];
15406
+ var keyDatas = [];
15407
+ var lastControl = {
15408
+ x: 0,
15409
+ y: 0
15410
+ };
15411
+ for(var i = 0; i < oldKeyframes.length - 1; i++){
15412
+ var leftKeyframe = oldKeyframes[i];
15413
+ var rightKeyframe = oldKeyframes[i + 1];
15414
+ var _getControlPoints = getControlPoints(leftKeyframe, rightKeyframe, true), p0 = _getControlPoints.p0, p1 = _getControlPoints.p1, p2 = _getControlPoints.p2, p3 = _getControlPoints.p3;
15415
+ assertExist(p2);
15416
+ assertExist(p3);
15417
+ var keyData = {
15418
+ leftControl: lastControl,
15419
+ value: p0,
15420
+ rightControl: p1,
15421
+ tangentMode: 0
15422
+ };
15423
+ if (leftKeyframe[0] === BezierKeyframeType.HOLD) {
15424
+ keyData.tangentMode = 2;
15425
+ }
15426
+ keyDatas.push(keyData);
15427
+ lastControl = p2;
15428
+ if (i === oldKeyframes.length - 2) {
15429
+ var res = getControlPoints(rightKeyframe, rightKeyframe, true);
15430
+ assertExist(res.p3);
15431
+ keyDatas.push({
15432
+ leftControl: p2,
15433
+ value: res.p3,
15434
+ rightControl: {
15435
+ x: 0,
15436
+ y: 0
15437
+ },
15438
+ tangentMode: rightKeyframe[0] === BezierKeyframeType.HOLD ? 2 : 0
15439
+ });
15440
+ }
15441
+ }
15442
+ var calculateSlop = function(p0, p1) {
15443
+ return (p1.y - p0.y) / (p1.x - p0.x + NumberEpsilon);
15444
+ };
15445
+ for(var i1 = 0; i1 < keyDatas.length; i1++){
15446
+ var leftControl = keyDatas[i1].leftControl;
15447
+ var value = keyDatas[i1].value;
15448
+ var rightControl = keyDatas[i1].rightControl;
15449
+ var outSlop = calculateSlop(value, rightControl);
15450
+ var inSlop = calculateSlop(leftControl, value);
15451
+ var keyframe = {
15452
+ time: value.x,
15453
+ value: value.y,
15454
+ inSlope: inSlop,
15455
+ outSlope: outSlop,
15456
+ inWeight: 0,
15457
+ outWeight: 0,
15458
+ tangentMode: keyDatas[i1].tangentMode,
15459
+ weightedMode: 3
15460
+ };
15461
+ keyframes.push(keyframe);
15462
+ if (i1 > 0) {
15463
+ keyframe.inWeight = (value.x - leftControl.x) / ((value.x - keyDatas[i1 - 1].value.x) / 3);
15464
+ }
15465
+ if (i1 + 1 < keyDatas.length) {
15466
+ keyframe.outWeight = (rightControl.x - value.x) / ((keyDatas[i1 + 1].value.x - value.x) / 3);
15467
+ }
15468
+ }
15469
+ return keyframes;
15470
+ }
15471
+
15302
15472
  var _obj$3;
15303
15473
  var map = (_obj$3 = {}, _obj$3[ValueType.RANDOM] = function(props) {
15304
15474
  if (_instanceof1(props[0], Array)) {
@@ -15335,7 +15505,8 @@ var map = (_obj$3 = {}, _obj$3[ValueType.RANDOM] = function(props) {
15335
15505
  if (props.length === 1) {
15336
15506
  return new StaticValue(props[0][1][1]);
15337
15507
  }
15338
- return new BezierCurve(props);
15508
+ // TODO: Move to migration.
15509
+ return new BezierCurve(oldBezierKeyFramesToNew(props));
15339
15510
  }, _obj$3[ValueType.BEZIER_CURVE_PATH] = function(props) {
15340
15511
  if (props[0].length === 1) {
15341
15512
  return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
@@ -26230,10 +26401,14 @@ var TextComponentBase = /*#__PURE__*/ function() {
26230
26401
  _proto.getLineCount = function getLineCount(text, init) {
26231
26402
  var context = this.context;
26232
26403
  var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
26233
- var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
26404
+ var fontScale = init ? this.textStyle.fontSize / 10 : this.textStyle.fontScale;
26234
26405
  var width = this.textLayout.width + this.textStyle.fontOffset;
26235
26406
  var lineCount = 1;
26236
26407
  var x = 0;
26408
+ //设置context.font的字号
26409
+ if (context) {
26410
+ context.font = this.getFontDesc(this.textStyle.fontSize);
26411
+ }
26237
26412
  for(var i = 0; i < text.length; i++){
26238
26413
  var _context_measureText;
26239
26414
  var str = text[i];
@@ -28422,7 +28597,7 @@ function getStandardSpriteContent(sprite, transform) {
28422
28597
  return ret;
28423
28598
  }
28424
28599
 
28425
- var version$2 = "2.5.0-alpha.5";
28600
+ var version$2 = "2.5.0";
28426
28601
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
28427
28602
  var standardVersion = /^(\d+)\.(\d+)$/;
28428
28603
  var reverseParticle = false;
@@ -31672,7 +31847,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
31672
31847
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
31673
31848
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
31674
31849
  registerPlugin("interact", InteractLoader, exports.VFXItem);
31675
- var version$1 = "2.5.0-alpha.5";
31850
+ var version$1 = "2.5.0";
31676
31851
  logger.info("Core version: " + version$1 + ".");
31677
31852
 
31678
31853
  var _obj;
@@ -33274,7 +33449,7 @@ setMaxSpriteMeshItemCount(8);
33274
33449
  */ Mesh.create = function(engine, props) {
33275
33450
  return new ThreeMesh(engine, props);
33276
33451
  };
33277
- var version = "2.5.0-alpha.5";
33452
+ var version = "2.5.0";
33278
33453
  logger.info("THREEJS plugin version: " + version + ".");
33279
33454
 
33280
33455
  exports.AbstractPlugin = AbstractPlugin;
@@ -33502,6 +33677,7 @@ exports.nearestPowerOfTwo = nearestPowerOfTwo;
33502
33677
  exports.noop = noop;
33503
33678
  exports.normalizeColor = normalizeColor;
33504
33679
  exports.numberToFix = numberToFix;
33680
+ exports.oldBezierKeyFramesToNew = oldBezierKeyFramesToNew;
33505
33681
  exports.parsePercent = parsePercent$1;
33506
33682
  exports.particleFrag = particleFrag;
33507
33683
  exports.particleOriginTranslateMap = particleOriginTranslateMap$1;