@galacean/effects-threejs 1.3.0 → 1.4.0-beta.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.mjs 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: v1.3.0
6
+ * Version: v1.4.0-beta.0
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -684,7 +684,7 @@ function asserts(condition, msg) {
684
684
  * Name: @galacean/effects-specification
685
685
  * Description: Galacean Effects JSON Specification
686
686
  * Author: Ant Group CO., Ltd.
687
- * Version: v1.1.0
687
+ * Version: v1.2.0-beta.0
688
688
  */
689
689
 
690
690
  /*********************************************/
@@ -7128,9 +7128,9 @@ var Float16ArrayWrapper = /** @class */ (function () {
7128
7128
  this.data = new Uint16Array(num);
7129
7129
  }
7130
7130
  else if (num && typeof num === 'object' && Number.isInteger(num.length)) {
7131
- var data_1 = this.data = new Uint16Array(num.length);
7132
- for (var i = 0; i < data_1.length; i++) {
7133
- data_1[i] = toHalf(num[i]);
7131
+ var data = this.data = new Uint16Array(num.length);
7132
+ for (var i = 0; i < data.length; i++) {
7133
+ data[i] = toHalf(num[i]);
7134
7134
  }
7135
7135
  }
7136
7136
  }
@@ -7301,6 +7301,448 @@ function trianglesFromRect(position, halfWidth, halfHeight) {
7301
7301
  { p0: p0.clone(), p1: p2.clone(), p2: p3 },
7302
7302
  ];
7303
7303
  }
7304
+ function decimalEqual(a, b, epsilon) {
7305
+ if (epsilon === void 0) { epsilon = 0.000001; }
7306
+ return Math.abs(a - b) < epsilon;
7307
+ }
7308
+ function numberToFix(a, fixed) {
7309
+ if (fixed === void 0) { fixed = 2; }
7310
+ var base = Math.pow(10, fixed);
7311
+ return Math.floor(a * base) / base;
7312
+ }
7313
+ function pointOnLine(x1, y1, x2, y2, x3, y3) {
7314
+ var det1 = (x1 * y2) + (y1 * x3) + (x2 * y3) - (x3 * y2) - (y3 * x1) - (x2 * y1);
7315
+ return det1 > -0.001 && det1 < 0.001;
7316
+ }
7317
+
7318
+ var keyframeInfo = {
7319
+ /**
7320
+ * 根据不同关键帧类型,获取位于曲线上的点
7321
+ */
7322
+ getPointInCurve: function (keyframe) {
7323
+ var _a = __read$3(keyframe, 2); _a[0]; var data = _a[1];
7324
+ var _b = this.getPointIndexInCurve(keyframe), xIndex = _b.xIndex, yIndex = _b.yIndex;
7325
+ var time = data[xIndex];
7326
+ var value = data[yIndex];
7327
+ return new Vector2(time, value);
7328
+ },
7329
+ /**
7330
+ * 根据不同关键帧类型,获取位于曲线上的点的索引
7331
+ */
7332
+ getPointIndexInCurve: function (keyframe) {
7333
+ var _a = __read$3(keyframe, 3), type = _a[0], markType = _a[2];
7334
+ // 不同类型,存放的时间不同
7335
+ var index = type === BezierKeyframeType$1.LINE ? 0
7336
+ : type === BezierKeyframeType$1.EASE_OUT ? 0
7337
+ : type === BezierKeyframeType$1.EASE_IN ? 2
7338
+ : type === BezierKeyframeType$1.EASE ? 2
7339
+ : type === BezierKeyframeType$1.HOLD ? (markType === BezierKeyframeType$1.EASE_IN ? 2 : 0)
7340
+ : 0;
7341
+ return { xIndex: index, yIndex: index + 1 };
7342
+ },
7343
+ /**
7344
+ * 关键帧左侧是否为缓动类型(否则为线段)
7345
+ */
7346
+ isLeftSideEase: function (keyframe) {
7347
+ var _a = __read$3(keyframe, 3), keyframeType = _a[0]; _a[1]; var markType = _a[2];
7348
+ // 定格关键帧的左侧类型,需要借助markType判断
7349
+ if (keyframeType === BezierKeyframeType$1.HOLD && this.isKeyframeTypeLeftSideEase(markType)) {
7350
+ return true;
7351
+ }
7352
+ return this.isKeyframeTypeLeftSideEase(keyframeType);
7353
+ },
7354
+ /**
7355
+ * 关键帧右侧是否为缓动类型(否则为线段)
7356
+ */
7357
+ isRightSideEase: function (keyframe) {
7358
+ var _a = __read$3(keyframe, 3), keyframeType = _a[0]; _a[1]; var markType = _a[2];
7359
+ // 定格关键帧的右侧类型,需要借助markType判断
7360
+ if (keyframeType === BezierKeyframeType$1.HOLD && this.isKeyframeTypeRightSideEase(markType)) {
7361
+ return true;
7362
+ }
7363
+ return this.isKeyframeTypeRightSideEase(keyframeType);
7364
+ },
7365
+ /**
7366
+ * 关键帧左侧是否为缓动类型(否则为线段)
7367
+ */
7368
+ isKeyframeTypeLeftSideEase: function (keyframeType) {
7369
+ return [BezierKeyframeType$1.EASE, BezierKeyframeType$1.EASE_IN, BezierKeyframeType$1.AUTO].includes(keyframeType);
7370
+ },
7371
+ /**
7372
+ * 关键帧右侧是否为缓动类型(否则为线段)
7373
+ */
7374
+ isKeyframeTypeRightSideEase: function (keyframeType) {
7375
+ return [BezierKeyframeType$1.EASE, BezierKeyframeType$1.EASE_OUT, BezierKeyframeType$1.AUTO].includes(keyframeType);
7376
+ },
7377
+ /**
7378
+ * 是否为定格进关键帧
7379
+ */
7380
+ isHoldInKeyframe: function (keyframe) {
7381
+ var _a = __read$3(keyframe, 3), keyframeType = _a[0]; _a[1]; var leftSubType = _a[2];
7382
+ return keyframeType === BezierKeyframeType$1.HOLD && [BezierKeyframeType$1.HOLD, BezierKeyframeType$1.LINE_OUT, BezierKeyframeType$1.EASE_OUT].includes(leftSubType);
7383
+ },
7384
+ /**
7385
+ * 是否为定格出关键帧
7386
+ */
7387
+ isHoldOutKeyframe: function (keyframe) {
7388
+ var _a = __read$3(keyframe, 3), keyframeType = _a[0]; _a[1]; var leftSubType = _a[2];
7389
+ return keyframeType === BezierKeyframeType$1.HOLD && [BezierKeyframeType$1.HOLD, BezierKeyframeType$1.LINE, BezierKeyframeType$1.EASE_IN].includes(leftSubType);
7390
+ },
7391
+ };
7392
+
7393
+ var BezierLengthData = /** @class */ (function () {
7394
+ function BezierLengthData(points, totalLength) {
7395
+ this.points = points;
7396
+ this.totalLength = totalLength;
7397
+ }
7398
+ return BezierLengthData;
7399
+ }());
7400
+ var BezierMap = {};
7401
+ var BezierDataMap = {};
7402
+ var NEWTON_ITERATIONS = 4;
7403
+ var NEWTON_MIN_SLOPE = 0.001;
7404
+ var SUBDIVISION_PRECISION = 0.0000001;
7405
+ var SUBDIVISION_MAX_ITERATIONS = 10;
7406
+ var CURVE_SEGMENTS = 300;
7407
+ var kSplineTableSize = 11;
7408
+ var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
7409
+ function A(a1, a2) { return 1.0 - 3.0 * a2 + 3.0 * a1; }
7410
+ function B(a1, a2) { return 3.0 * a2 - 6.0 * a1; }
7411
+ function C(a1) { return 3.0 * a1; }
7412
+ // A * t ^ 3 + B * t ^ 2 + C * t
7413
+ // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
7414
+ function calcBezier(t, a1, a2) {
7415
+ return ((A(a1, a2) * t + B(a1, a2)) * t + C(a1)) * t;
7416
+ }
7417
+ // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
7418
+ function getSlope(t, a1, a2) {
7419
+ return 3.0 * A(a1, a2) * t * t + 2.0 * B(a1, a2) * t + C(a1);
7420
+ }
7421
+ function binarySubdivide(aX, aA, aB, mX1, mX2) {
7422
+ var currentX, currentT, i = 0;
7423
+ do {
7424
+ currentT = aA + (aB - aA) / 2.0;
7425
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
7426
+ if (currentX > 0.0) {
7427
+ aB = currentT;
7428
+ }
7429
+ else {
7430
+ aA = currentT;
7431
+ }
7432
+ } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
7433
+ return currentT;
7434
+ }
7435
+ function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
7436
+ for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
7437
+ var currentSlope = getSlope(aGuessT, mX1, mX2);
7438
+ if (currentSlope === 0.0) {
7439
+ return aGuessT;
7440
+ }
7441
+ var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
7442
+ aGuessT -= currentX / currentSlope;
7443
+ }
7444
+ return aGuessT;
7445
+ }
7446
+ // de Casteljau算法构建曲线
7447
+ /**
7448
+ * @param p1 起始点
7449
+ * @param p2 终点
7450
+ * @param p3 起始控制点
7451
+ * @param p4 终止控制点
7452
+ * @returns
7453
+ */
7454
+ function buildBezierData(p1, p2, p3, p4) {
7455
+ // 使用平移后的终点、控制点作为key
7456
+ var s1 = numberToFix(p2.x - p1.x, 3) + '_' + numberToFix(p2.y - p1.y, 3) + '_' + numberToFix(p2.z - p1.z, 3);
7457
+ var s2 = numberToFix(p3.x - p1.x, 3) + '_' + numberToFix(p3.y - p1.y, 3) + '_' + numberToFix(p3.z - p1.z, 3);
7458
+ var s3 = numberToFix(p4.x - p1.x, 3) + '_' + numberToFix(p4.y - p1.y, 3) + '_' + numberToFix(p4.z - p1.z, 3);
7459
+ var str = s1 + '&' + s2 + '&' + s3;
7460
+ if (BezierDataMap[str]) {
7461
+ return {
7462
+ data: BezierDataMap[str],
7463
+ interval: p1,
7464
+ };
7465
+ }
7466
+ else {
7467
+ var samples = [];
7468
+ var lastPoint = null, addedLength = 0, ptDistance = 0;
7469
+ var curveSegments = CURVE_SEGMENTS;
7470
+ for (var k = 0; k < curveSegments; k += 1) {
7471
+ var point = new Vector3();
7472
+ var perc = k / (curveSegments - 1);
7473
+ ptDistance = 0;
7474
+ point.x = 3 * Math.pow(1 - perc, 2) * perc * (p3.x - p1.x) + 3 * (1 - perc) * Math.pow(perc, 2) * (p4.x - p1.x) + Math.pow(perc, 3) * (p2.x - p1.x);
7475
+ point.y = 3 * Math.pow(1 - perc, 2) * perc * (p3.y - p1.y) + 3 * (1 - perc) * Math.pow(perc, 2) * (p4.y - p1.y) + Math.pow(perc, 3) * (p2.y - p1.y);
7476
+ point.z = 3 * Math.pow(1 - perc, 2) * perc * (p3.z - p1.z) + 3 * (1 - perc) * Math.pow(perc, 2) * (p4.z - p1.z) + Math.pow(perc, 3) * (p2.z - p1.z);
7477
+ if (lastPoint !== null) {
7478
+ ptDistance += Math.pow(point.x - lastPoint.x, 2);
7479
+ ptDistance += Math.pow(point.y - lastPoint.y, 2);
7480
+ ptDistance += Math.pow(point.z - lastPoint.z, 2);
7481
+ }
7482
+ lastPoint = point;
7483
+ ptDistance = Math.sqrt(ptDistance);
7484
+ addedLength += ptDistance;
7485
+ samples[k] = {
7486
+ partialLength: ptDistance,
7487
+ point: point,
7488
+ };
7489
+ }
7490
+ var data = new BezierLengthData(samples, addedLength);
7491
+ BezierDataMap[str] = data;
7492
+ return {
7493
+ data: data,
7494
+ interval: new Vector3(p1.x, p1.y, p1.z),
7495
+ };
7496
+ }
7497
+ }
7498
+ var BezierPath = /** @class */ (function () {
7499
+ function BezierPath(p1, p2, p3, p4) {
7500
+ this.p1 = p1;
7501
+ this.p2 = p2;
7502
+ this.p3 = p3;
7503
+ this.p4 = p4;
7504
+ this.catching = {
7505
+ lastPoint: 0,
7506
+ lastAddedLength: 0,
7507
+ };
7508
+ var _a = buildBezierData(p1, p2, p3, p4), data = _a.data, interval = _a.interval;
7509
+ this.lengthData = data;
7510
+ this.interval = interval;
7511
+ this.totalLength = data.totalLength;
7512
+ }
7513
+ /**
7514
+ * 获取路径在指定比例长度上点的坐标
7515
+ * @param percent 路径长度的比例
7516
+ */
7517
+ BezierPath.prototype.getPointInPercent = function (percent) {
7518
+ var bezierData = this.lengthData;
7519
+ if (percent === 0) {
7520
+ return bezierData.points[0].point.clone().add(this.interval);
7521
+ }
7522
+ if (decimalEqual(1 - percent, 0)) {
7523
+ return bezierData.points[CURVE_SEGMENTS - 1].point.clone().add(this.interval);
7524
+ }
7525
+ if (decimalEqual(bezierData.totalLength, 0)) {
7526
+ return this.p1.clone();
7527
+ }
7528
+ var point = new Vector3();
7529
+ var segmentLength = numberToFix(bezierData.totalLength * percent, 4);
7530
+ var addedLength = this.catching.lastAddedLength;
7531
+ var j = this.catching.lastPoint;
7532
+ if (decimalEqual(addedLength, segmentLength)) {
7533
+ return bezierData.points[j].point.clone().add(this.interval);
7534
+ }
7535
+ var flag = true;
7536
+ var dir = 1;
7537
+ if (segmentLength < addedLength) {
7538
+ dir = -1;
7539
+ }
7540
+ while (flag) {
7541
+ if (segmentLength >= addedLength) {
7542
+ if (j === CURVE_SEGMENTS - 1) {
7543
+ point.x = bezierData.points[j].point.x;
7544
+ point.y = bezierData.points[j].point.y;
7545
+ point.z = bezierData.points[j].point.z;
7546
+ break;
7547
+ }
7548
+ if (segmentLength < addedLength + bezierData.points[j + 1].partialLength) {
7549
+ var segmentPerc = (segmentLength - addedLength) / bezierData.points[j + 1].partialLength;
7550
+ point.x = bezierData.points[j].point.x + (bezierData.points[j + 1].point.x - bezierData.points[j].point.x) * segmentPerc;
7551
+ point.y = bezierData.points[j].point.y + (bezierData.points[j + 1].point.y - bezierData.points[j].point.y) * segmentPerc;
7552
+ point.z = bezierData.points[j].point.z + (bezierData.points[j + 1].point.z - bezierData.points[j].point.z) * segmentPerc;
7553
+ break;
7554
+ }
7555
+ }
7556
+ if (dir > 0 && j < (CURVE_SEGMENTS - 1)) {
7557
+ j += dir;
7558
+ addedLength += numberToFix(bezierData.points[j].partialLength, 5);
7559
+ }
7560
+ else if (dir < 0 && j > 0) {
7561
+ addedLength -= numberToFix(bezierData.points[j].partialLength, 5);
7562
+ j += dir;
7563
+ }
7564
+ else {
7565
+ flag = false;
7566
+ }
7567
+ }
7568
+ this.catching.lastPoint = j;
7569
+ this.catching.lastAddedLength = addedLength;
7570
+ point.add(this.interval);
7571
+ return point;
7572
+ };
7573
+ return BezierPath;
7574
+ }());
7575
+ var BezierEasing = /** @class */ (function () {
7576
+ function BezierEasing(mX1, mY1, mX2, mY2) {
7577
+ this.mX1 = mX1;
7578
+ this.mY1 = mY1;
7579
+ this.mX2 = mX2;
7580
+ this.mY2 = mY2;
7581
+ this.precomputed = false;
7582
+ this.mSampleValues = new Array(kSplineTableSize);
7583
+ this.cachingValue = {};
7584
+ }
7585
+ BezierEasing.prototype.precompute = function () {
7586
+ this.precomputed = true;
7587
+ if (this.mX1 !== this.mY1 || this.mX2 !== this.mY2) {
7588
+ this.calcSampleValues();
7589
+ }
7590
+ };
7591
+ BezierEasing.prototype.getValue = function (x) {
7592
+ if (this.mX1 === this.mY1 && this.mX2 === this.mY2) {
7593
+ return x;
7594
+ }
7595
+ if (isNaN(this.mY1) || isNaN(this.mY2)) {
7596
+ return 0;
7597
+ }
7598
+ if (x === 0 || x === 1) {
7599
+ return x;
7600
+ }
7601
+ if (!this.precomputed) {
7602
+ this.precompute();
7603
+ }
7604
+ var keys = Object.keys(this.cachingValue);
7605
+ var index = keys.findIndex(function (key) { return decimalEqual(Number(key), x, 0.005); });
7606
+ if (index !== -1) {
7607
+ return this.cachingValue[keys[index]];
7608
+ }
7609
+ var value = calcBezier(this.getTForX(x), this.mY1, this.mY2);
7610
+ if (keys.length < 300) {
7611
+ this.cachingValue[x] = value;
7612
+ }
7613
+ return value;
7614
+ };
7615
+ BezierEasing.prototype.calcSampleValues = function () {
7616
+ for (var i = 0; i < kSplineTableSize; ++i) {
7617
+ this.mSampleValues[i] = calcBezier(i * kSampleStepSize, this.mX1, this.mX2);
7618
+ }
7619
+ };
7620
+ BezierEasing.prototype.getTForX = function (aX) {
7621
+ var mSampleValues = this.mSampleValues, lastSample = kSplineTableSize - 1;
7622
+ var intervalStart = 0, currentSample = 1;
7623
+ for (; currentSample !== lastSample && mSampleValues[currentSample] <= aX; ++currentSample) {
7624
+ intervalStart += kSampleStepSize;
7625
+ }
7626
+ --currentSample;
7627
+ // Interpolate to provide an initial guess for t
7628
+ var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample + 1] - mSampleValues[currentSample]);
7629
+ var guessForT = intervalStart + dist * kSampleStepSize;
7630
+ var initialSlope = getSlope(guessForT, this.mX1, this.mX2);
7631
+ if (initialSlope >= NEWTON_MIN_SLOPE) {
7632
+ return newtonRaphsonIterate(aX, guessForT, this.mX1, this.mX2);
7633
+ }
7634
+ if (initialSlope === 0.0) {
7635
+ return guessForT;
7636
+ }
7637
+ return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, this.mX1, this.mX2);
7638
+ };
7639
+ return BezierEasing;
7640
+ }());
7641
+ function buildEasingCurve(leftKeyframe, rightKeyframe) {
7642
+ // 获取控制点和曲线类型
7643
+ var _a = getControlPoints(leftKeyframe, rightKeyframe, true), p0 = _a.p0, p1 = _a.p1, p2 = _a.p2, p3 = _a.p3;
7644
+ assertExist(p2);
7645
+ assertExist(p3);
7646
+ var timeInterval = p3.x - p0.x;
7647
+ var valueInterval = p3.y - p0.y;
7648
+ var y1, y2;
7649
+ var x1 = numberToFix((p1.x - p0.x) / timeInterval, 5);
7650
+ var x2 = numberToFix((p2.x - p0.x) / timeInterval, 5);
7651
+ if (decimalEqual(valueInterval, 0)) {
7652
+ y1 = y2 = NaN;
7653
+ }
7654
+ else {
7655
+ y1 = numberToFix((p1.y - p0.y) / valueInterval, 5);
7656
+ y2 = numberToFix((p2.y - p0.y) / valueInterval, 5);
7657
+ }
7658
+ if (x1 < 0) {
7659
+ console.error('invalid bezier points, x1 < 0', p0, p1, p2, p3);
7660
+ x1 = 0;
7661
+ }
7662
+ if (x2 < 0) {
7663
+ console.error('invalid bezier points, x2 < 0', p0, p1, p2, p3);
7664
+ x2 = 0;
7665
+ }
7666
+ if (x1 > 1) {
7667
+ console.error('invalid bezier points, x1 >= 1', p0, p1, p2, p3);
7668
+ x1 = 1;
7669
+ }
7670
+ if (x2 > 1) {
7671
+ console.error('invalid bezier points, x2 >= 1', p0, p1, p2, p3);
7672
+ x2 = 1;
7673
+ }
7674
+ var str = ('bez_' + x1 + '_' + y1 + '_' + x2 + '_' + y2).replace(/\./g, 'p');
7675
+ var bezEasing;
7676
+ if (BezierMap[str]) {
7677
+ bezEasing = BezierMap[str];
7678
+ }
7679
+ else {
7680
+ bezEasing = new BezierEasing(x1, y1, x2, y2);
7681
+ BezierMap[str] = bezEasing;
7682
+ }
7683
+ return {
7684
+ points: [p0, p1, p2, p3],
7685
+ timeInterval: timeInterval,
7686
+ valueInterval: valueInterval,
7687
+ curve: bezEasing,
7688
+ };
7689
+ }
7690
+ /**
7691
+ * 根据关键帧类型获取贝塞尔曲线上的关键点
7692
+ */
7693
+ function getControlPoints(leftKeyframe, rightKeyframe, lineToBezier) {
7694
+ var _a = __read$3(leftKeyframe, 2), leftValue = _a[1];
7695
+ var leftHoldLine = keyframeInfo.isHoldOutKeyframe(leftKeyframe);
7696
+ var rightHoldLine = keyframeInfo.isHoldInKeyframe(rightKeyframe);
7697
+ var leftEase = !rightHoldLine && keyframeInfo.isRightSideEase(leftKeyframe);
7698
+ var rightEase = !leftHoldLine && keyframeInfo.isLeftSideEase(rightKeyframe);
7699
+ // 1. 左边为ease,右边为line(补充右边的控制点,该点在曲线上的点的偏左边位置)
7700
+ if (leftEase && !rightEase && !rightHoldLine) {
7701
+ var p0_1 = new Vector2(leftValue[leftValue.length - 4], leftValue[leftValue.length - 3]);
7702
+ var p1_1 = new Vector2(leftValue[leftValue.length - 2], leftValue[leftValue.length - 1]);
7703
+ var rightPoint = keyframeInfo.getPointInCurve(rightKeyframe);
7704
+ var p3 = new Vector2(rightPoint.x, rightPoint.y);
7705
+ var p2 = new Vector2(p3.x - (p3.x - p0_1.x) / 10, p3.y);
7706
+ return { type: 'ease', p0: p0_1, p1: p1_1, p2: p2, p3: p3 };
7707
+ }
7708
+ // 2. 左边为line,右边为ease(补充左边的控制点,该点在曲线上的点的偏右边位置)
7709
+ if (!leftEase && rightEase && !leftHoldLine) {
7710
+ var _b = __read$3(rightKeyframe, 2), rightValue = _b[1];
7711
+ var leftPoint = keyframeInfo.getPointInCurve(leftKeyframe);
7712
+ var p0_2 = new Vector2(leftPoint.x, leftPoint.y);
7713
+ var p2 = new Vector2(rightValue[0], rightValue[1]);
7714
+ var p3 = new Vector2(rightValue[2], rightValue[3]);
7715
+ var p1_2 = new Vector2(p0_2.x + (p3.x - p0_2.x) / 10, p0_2.y);
7716
+ return { type: 'ease', p0: p0_2, p1: p1_2, p2: p2, p3: p3 };
7717
+ }
7718
+ // 3. 左边为ease,右边为ease
7719
+ if (leftEase && rightEase) {
7720
+ var _c = __read$3(rightKeyframe, 2), rightValue = _c[1];
7721
+ var p0_3 = new Vector2(leftValue[leftValue.length - 4], leftValue[leftValue.length - 3]);
7722
+ var p1_3 = new Vector2(leftValue[leftValue.length - 2], leftValue[leftValue.length - 1]);
7723
+ var p2 = new Vector2(rightValue[0], rightValue[1]);
7724
+ var p3 = new Vector2(rightValue[2], rightValue[3]);
7725
+ return { type: 'ease', p0: p0_3, p1: p1_3, p2: p2, p3: p3 };
7726
+ }
7727
+ // 4. 左边为line,右边为line
7728
+ var p0 = keyframeInfo.getPointInCurve(leftKeyframe);
7729
+ var p1 = keyframeInfo.getPointInCurve(rightKeyframe);
7730
+ if (leftHoldLine) {
7731
+ p1.y = p0.y; // 定格关键帧使用相同的点
7732
+ }
7733
+ else if (rightHoldLine) {
7734
+ p0.y = p1.y;
7735
+ }
7736
+ if (lineToBezier) {
7737
+ // 补上两个在直线上的控制点
7738
+ var p2 = new Vector2((p1.x - p0.x) / 3 + p0.x, (p1.y - p0.y) / 3 + p0.y);
7739
+ var p3 = new Vector2((p1.x - p0.x) / 3 * 2 + p0.x, (p1.y - p0.y) / 3 * 2 + p0.y);
7740
+ return { type: 'ease', p0: p0, p1: p2, p2: p3, p3: p1, isHold: leftHoldLine || rightHoldLine, leftHoldLine: leftHoldLine, rightHoldLine: rightHoldLine };
7741
+ }
7742
+ else {
7743
+ return { type: 'line', p0: p0, p1: p1, isHold: leftHoldLine || rightHoldLine, leftHoldLine: leftHoldLine, rightHoldLine: rightHoldLine };
7744
+ }
7745
+ }
7304
7746
 
7305
7747
  var _a$5;
7306
7748
  var NOT_IMPLEMENT = 'not_implement';
@@ -7308,6 +7750,15 @@ var ValueGetter = /** @class */ (function () {
7308
7750
  function ValueGetter(arg) {
7309
7751
  this.onCreate(arg);
7310
7752
  }
7753
+ ValueGetter.getAllData = function (meta, halfFloat) {
7754
+ var ret = new (halfFloat ? Float16ArrayWrapper : Float32Array)(meta.index * 4);
7755
+ for (var i = 0, cursor = 0, curves = meta.curves; i < curves.length; i++) {
7756
+ var data = curves[i].toData();
7757
+ ret.set(data, cursor);
7758
+ cursor += data.length;
7759
+ }
7760
+ return halfFloat ? ret.data : ret;
7761
+ };
7311
7762
  ValueGetter.prototype.onCreate = function (props) {
7312
7763
  throw Error(NOT_IMPLEMENT);
7313
7764
  };
@@ -7329,6 +7780,9 @@ var ValueGetter = /** @class */ (function () {
7329
7780
  ValueGetter.prototype.scaleXCoord = function (scale) {
7330
7781
  return this;
7331
7782
  };
7783
+ ValueGetter.prototype.toData = function () {
7784
+ throw Error(NOT_IMPLEMENT);
7785
+ };
7332
7786
  return ValueGetter;
7333
7787
  }());
7334
7788
  var StaticValue = /** @class */ (function (_super) {
@@ -7491,153 +7945,6 @@ var GradientValue = /** @class */ (function (_super) {
7491
7945
  };
7492
7946
  return GradientValue;
7493
7947
  }(ValueGetter));
7494
- var CURVE_PRO_TIME = 0;
7495
- var CURVE_PRO_VALUE = 1;
7496
- var CURVE_PRO_IN_TANGENT = 2;
7497
- var CURVE_PRO_OUT_TANGENT = 3;
7498
- var CurveValue = /** @class */ (function (_super) {
7499
- __extends(CurveValue, _super);
7500
- function CurveValue() {
7501
- return _super !== null && _super.apply(this, arguments) || this;
7502
- }
7503
- CurveValue.getAllData = function (meta, halfFloat) {
7504
- var ret = new (halfFloat ? Float16ArrayWrapper : Float32Array)(meta.index * 4);
7505
- for (var i = 0, cursor = 0, curves = meta.curves; i < curves.length; i++) {
7506
- var data_1 = curves[i].toData();
7507
- ret.set(data_1, cursor);
7508
- cursor += data_1.length;
7509
- }
7510
- return halfFloat ? ret.data : ret;
7511
- };
7512
- CurveValue.prototype.onCreate = function (props) {
7513
- var min = Infinity;
7514
- var max = -Infinity;
7515
- //formatted number
7516
- if (Number.isFinite(props[0]) && Number.isFinite(props[1])) {
7517
- var keys_1 = [];
7518
- for (var i = 2; i < props.length; i++) {
7519
- // FIXME
7520
- keys_1.push(props[i].slice(0, 4));
7521
- }
7522
- this.keys = keys_1;
7523
- this.min = props[0];
7524
- this.dist = props[1] - props[0];
7525
- }
7526
- else {
7527
- var keys_2 = props.map(function (item) {
7528
- if (isArray(item)) {
7529
- min = Math.min(min, item[1]);
7530
- max = Math.max(max, item[1]);
7531
- return item.slice(0, 4);
7532
- }
7533
- else if (typeof item === 'object' && item) {
7534
- var _a = item, time = _a.time, value = _a.value, _b = _a.inTangent, inTangent = _b === void 0 ? 0 : _b, _c = _a.outTangent, outTangent = _c === void 0 ? 0 : _c;
7535
- min = Math.min(min, value);
7536
- max = Math.max(max, value);
7537
- return [time, value, inTangent, outTangent];
7538
- }
7539
- throw new Error('invalid keyframe');
7540
- });
7541
- var dist = max - min;
7542
- this.keys = keys_2;
7543
- if (dist !== 0) {
7544
- for (var i = 0; i < keys_2.length; i++) {
7545
- var key = keys_2[i];
7546
- key[1] = (key[1] - min) / dist;
7547
- }
7548
- }
7549
- var key0 = keys_2[0];
7550
- if (key0[0] > 0) {
7551
- key0[2] = 0;
7552
- keys_2.unshift([0, key0[1], 0, 0]);
7553
- }
7554
- var key1 = keys_2[keys_2.length - 1];
7555
- if (key1[0] < 1) {
7556
- key1[3] = 0;
7557
- keys_2.push([1, key1[1], 0, 0]);
7558
- }
7559
- this.min = min;
7560
- this.dist = dist;
7561
- }
7562
- this.isCurveValue = true;
7563
- };
7564
- CurveValue.prototype.getValue = function (time) {
7565
- var _a = this, keys = _a.keys, min = _a.min, dist = _a.dist;
7566
- var keysNumerArray = keys;
7567
- if (time <= keysNumerArray[0][CURVE_PRO_TIME]) {
7568
- return keysNumerArray[0][CURVE_PRO_VALUE] * dist + min;
7569
- }
7570
- var end = keysNumerArray.length - 1;
7571
- for (var i = 0; i < end; i++) {
7572
- var key = keysNumerArray[i];
7573
- var k2 = keysNumerArray[i + 1];
7574
- if (time > key[CURVE_PRO_TIME] && time <= k2[CURVE_PRO_TIME]) {
7575
- return curveValueEvaluate(time, key, k2) * dist + min;
7576
- }
7577
- }
7578
- return keysNumerArray[end][CURVE_PRO_VALUE] * dist + min;
7579
- };
7580
- CurveValue.prototype.getIntegrateByTime = function (t0, t1) {
7581
- var d = this.integrate(t1, true) - this.integrate(t0, true);
7582
- return this.min * 0.5 * (t1 - t0) * (t1 - t0) + d * this.dist;
7583
- };
7584
- CurveValue.prototype.getIntegrateValue = function (t0, t1, ts) {
7585
- ts = ts || 1;
7586
- var d = (this.integrate(t1 / ts, false) - this.integrate(t0 / ts, false)) * ts;
7587
- var dt = (t1 - t0) / ts;
7588
- return this.min * dt + d * this.dist;
7589
- };
7590
- CurveValue.prototype.integrate = function (time, byTime) {
7591
- var keys = this.keys;
7592
- if (time <= keys[0][CURVE_PRO_TIME]) {
7593
- return 0;
7594
- }
7595
- var ret = 0;
7596
- var end = keys.length - 1;
7597
- var func = byTime ? curveValueIntegrateByTime : curveValueIntegrate;
7598
- for (var i = 0; i < end; i++) {
7599
- var key = keys[i];
7600
- var k2 = keys[i + 1];
7601
- var t1 = key[CURVE_PRO_TIME];
7602
- var t2 = k2[CURVE_PRO_TIME];
7603
- if (time > t1 && time <= t2) {
7604
- return ret + func(time, key, k2);
7605
- }
7606
- else {
7607
- ret += func(t2, key, k2);
7608
- }
7609
- }
7610
- return ret;
7611
- };
7612
- CurveValue.prototype.toData = function () {
7613
- var keys = this.keys;
7614
- var data = new Float32Array(keys.length * 4);
7615
- for (var i = 0, cursor = 0; i < keys.length; i++, cursor += 4) {
7616
- data.set(keys[i], cursor);
7617
- }
7618
- return data;
7619
- };
7620
- CurveValue.prototype.toUniform = function (meta) {
7621
- var index = meta.index;
7622
- var keys = this.keys;
7623
- meta.curves.push(this);
7624
- meta.index += keys.length;
7625
- meta.max = Math.max(meta.max, keys.length);
7626
- meta.curveCount += keys.length;
7627
- return new Float32Array([2, index + 1 / keys.length, this.min, this.dist]);
7628
- };
7629
- CurveValue.prototype.map = function (func) {
7630
- this.keys.forEach(function (k) {
7631
- k[CURVE_PRO_VALUE] = func(k[CURVE_PRO_VALUE]);
7632
- });
7633
- return this;
7634
- };
7635
- CurveValue.prototype.scaleXCoord = function (scale) {
7636
- this.keys.forEach(function (k) { return k[CURVE_PRO_TIME] = scale * k[CURVE_PRO_TIME]; });
7637
- return this;
7638
- };
7639
- return CurveValue;
7640
- }(ValueGetter));
7641
7948
  var LineSegments = /** @class */ (function (_super) {
7642
7949
  __extends(LineSegments, _super);
7643
7950
  function LineSegments() {
@@ -7739,77 +8046,247 @@ var LineSegments = /** @class */ (function (_super) {
7739
8046
  };
7740
8047
  return LineSegments;
7741
8048
  }(ValueGetter));
7742
- var PathSegments = /** @class */ (function (_super) {
7743
- __extends(PathSegments, _super);
7744
- function PathSegments() {
8049
+ // export class PathSegments extends ValueGetter<number[]> {
8050
+ // keys: number[][];
8051
+ // values: number[][];
8052
+ //
8053
+ // override onCreate (props: number[][][]) {
8054
+ // this.keys = props[0];
8055
+ // this.values = props[1];
8056
+ // }
8057
+ //
8058
+ // override getValue (time: number) {
8059
+ // const keys = this.keys;
8060
+ // const values = this.values;
8061
+ //
8062
+ // for (let i = 0; i < keys.length - 1; i++) {
8063
+ // const k0 = keys[i];
8064
+ // const k1 = keys[i + 1];
8065
+ //
8066
+ // if (k0[0] <= time && k1[0] >= time) {
8067
+ // const dis = k1[1] - k0[1];
8068
+ // let dt;
8069
+ //
8070
+ // if (dis === 0) {
8071
+ // dt = (time - k0[0]) / (k1[0] - k0[0]);
8072
+ // } else {
8073
+ // const val = curveValueEvaluate(time, k0, k1);
8074
+ //
8075
+ // dt = (val - k0[1]) / dis;
8076
+ // }
8077
+ //
8078
+ // return this.calculateVec(i, dt);
8079
+ // }
8080
+ // }
8081
+ // if (time <= keys[0][0]) {
8082
+ // return values[0].slice();
8083
+ // }
8084
+ //
8085
+ // return values[values.length - 1].slice();
8086
+ // }
8087
+ //
8088
+ // calculateVec (i: number, dt: number) {
8089
+ // const vec0 = this.values[i];
8090
+ // const vec1 = this.values[i + 1];
8091
+ // const ret = [0, 0, 0];
8092
+ //
8093
+ // for (let j = 0; j < vec0.length; j++) {
8094
+ // ret[j] = vec0[j] * (1 - dt) + vec1[j] * dt;
8095
+ // }
8096
+ //
8097
+ // return ret;
8098
+ // }
8099
+ // }
8100
+ var BezierCurve = /** @class */ (function (_super) {
8101
+ __extends(BezierCurve, _super);
8102
+ function BezierCurve() {
7745
8103
  return _super !== null && _super.apply(this, arguments) || this;
7746
8104
  }
7747
- PathSegments.prototype.onCreate = function (props) {
7748
- this.keys = props[0];
7749
- this.values = props[1];
8105
+ BezierCurve.prototype.onCreate = function (props) {
8106
+ var keyframes = props;
8107
+ this.curveMap = {};
8108
+ this.keys = [];
8109
+ for (var i = 0; i < keyframes.length - 1; i++) {
8110
+ var leftKeyframe = keyframes[i];
8111
+ var rightKeyframe = keyframes[i + 1];
8112
+ var _a = buildEasingCurve(leftKeyframe, rightKeyframe), points = _a.points, curve = _a.curve, timeInterval = _a.timeInterval, valueInterval = _a.valueInterval;
8113
+ var s = points[0];
8114
+ var e = points[points.length - 1];
8115
+ this.keys.push(__spreadArray$2(__spreadArray$2([], __read$3(s.toArray()), false), __read$3(points[1].toArray()), false));
8116
+ this.keys.push(__spreadArray$2(__spreadArray$2([], __read$3(e.toArray()), false), __read$3(points[2].toArray()), false));
8117
+ this.curveMap["".concat(s.x, "&").concat(e.x)] = {
8118
+ points: points,
8119
+ timeInterval: timeInterval,
8120
+ valueInterval: valueInterval,
8121
+ curve: curve,
8122
+ };
8123
+ }
7750
8124
  };
7751
- PathSegments.prototype.getValue = function (time) {
7752
- var keys = this.keys;
7753
- var values = this.values;
7754
- for (var i = 0; i < keys.length - 1; i++) {
7755
- var k0 = keys[i];
7756
- var k1 = keys[i + 1];
7757
- if (k0[0] <= time && k1[0] >= time) {
7758
- var dis = k1[1] - k0[1];
7759
- var dt = void 0;
7760
- if (dis === 0) {
7761
- dt = (time - k0[0]) / (k1[0] - k0[0]);
7762
- }
7763
- else {
7764
- var val = curveValueEvaluate(time, k0, k1);
7765
- dt = (val - k0[1]) / dis;
7766
- }
7767
- return this.calculateVec(i, dt);
8125
+ BezierCurve.prototype.getValue = function (time) {
8126
+ var result = 0;
8127
+ var keyTimeData = Object.keys(this.curveMap);
8128
+ var keyTimeStart = Number(keyTimeData[0].split('&')[0]);
8129
+ var keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split('&')[1]);
8130
+ if (time <= keyTimeStart) {
8131
+ return this.getCurveValue(keyTimeData[0], keyTimeStart);
8132
+ }
8133
+ if (time >= keyTimeEnd) {
8134
+ return this.getCurveValue(keyTimeData[keyTimeData.length - 1], keyTimeEnd);
8135
+ }
8136
+ for (var i = 0; i < keyTimeData.length; i++) {
8137
+ var _a = __read$3(keyTimeData[i].split('&'), 2), xMin = _a[0], xMax = _a[1];
8138
+ if (time >= Number(xMin) && time < Number(xMax)) {
8139
+ result = this.getCurveValue(keyTimeData[i], time);
8140
+ break;
7768
8141
  }
7769
8142
  }
7770
- if (time <= keys[0][0]) {
7771
- return values[0].slice();
8143
+ return result;
8144
+ };
8145
+ BezierCurve.prototype.getIntegrateValue = function (t0, t1, ts) {
8146
+ if (ts === void 0) { ts = 1; }
8147
+ var time = (t1 - t0);
8148
+ var result = 0;
8149
+ var keyTimeData = Object.keys(this.curveMap);
8150
+ var keyTimeStart = Number(keyTimeData[0].split('&')[0]);
8151
+ if (time <= keyTimeStart) {
8152
+ return 0;
8153
+ }
8154
+ for (var i = 0; i < keyTimeData.length; i++) {
8155
+ var _a = __read$3(keyTimeData[i].split('&'), 2), xMin = _a[0], xMax = _a[1];
8156
+ if (time >= Number(xMax)) {
8157
+ result += ts * this.getCurveIntegrateValue(keyTimeData[i], Number(xMax));
8158
+ }
8159
+ if (time >= Number(xMin) && time < Number(xMax)) {
8160
+ result += ts * this.getCurveIntegrateValue(keyTimeData[i], time);
8161
+ break;
8162
+ }
7772
8163
  }
7773
- return values[values.length - 1].slice();
8164
+ return result;
7774
8165
  };
7775
- PathSegments.prototype.calculateVec = function (i, dt) {
7776
- var vec0 = this.values[i];
7777
- var vec1 = this.values[i + 1];
7778
- var ret = [0, 0, 0];
7779
- for (var j = 0; j < vec0.length; j++) {
7780
- ret[j] = vec0[j] * (1 - dt) + vec1[j] * dt;
8166
+ // 速度变化曲线面板移除后下线
8167
+ BezierCurve.prototype.getCurveIntegrateValue = function (curveKey, time) {
8168
+ var curveInfo = this.curveMap[curveKey];
8169
+ var _a = __read$3(curveInfo.points, 1), p0 = _a[0];
8170
+ var timeInterval = curveInfo.timeInterval;
8171
+ var valueInterval = curveInfo.valueInterval;
8172
+ var segments = 100;
8173
+ var total = 0;
8174
+ var h = (time - p0.x) / segments;
8175
+ for (var i = 0; i <= segments; i++) {
8176
+ var t = i * h;
8177
+ var normalizeTime = t / timeInterval;
8178
+ var y = p0.y + valueInterval * curveInfo.curve.getValue(normalizeTime);
8179
+ if (i === 0 || i === segments) {
8180
+ total += y;
8181
+ }
8182
+ else if (i % 2 === 1) {
8183
+ total += 4 * y;
8184
+ }
8185
+ else {
8186
+ total += 2 * y;
8187
+ }
7781
8188
  }
7782
- return ret;
8189
+ total *= h / 3;
8190
+ return total;
8191
+ };
8192
+ BezierCurve.prototype.getCurveValue = function (curveKey, time) {
8193
+ var curveInfo = this.curveMap[curveKey];
8194
+ var _a = __read$3(curveInfo.points, 1), p0 = _a[0];
8195
+ var timeInterval = curveInfo.timeInterval;
8196
+ var valueInterval = curveInfo.valueInterval;
8197
+ var normalizeTime = (time - p0.x) / timeInterval;
8198
+ var value = curveInfo.curve.getValue(normalizeTime);
8199
+ return p0.y + valueInterval * value;
8200
+ };
8201
+ BezierCurve.prototype.toUniform = function (meta) {
8202
+ var index = meta.index;
8203
+ var count = this.keys.length;
8204
+ meta.curves.push(this);
8205
+ meta.index = index + count;
8206
+ // 兼容 WebGL1
8207
+ meta.max = Math.max(meta.max, count);
8208
+ meta.curveCount += count;
8209
+ return new Float32Array([5, index + 1 / count, index, count]);
8210
+ };
8211
+ BezierCurve.prototype.toData = function () {
8212
+ var keys = this.keys;
8213
+ var data = new Float32Array(keys.length * 4);
8214
+ for (var i = 0, cursor = 0; i < keys.length; i++, cursor += 4) {
8215
+ data.set(keys[i], cursor);
8216
+ }
8217
+ return data;
7783
8218
  };
7784
- return PathSegments;
8219
+ return BezierCurve;
7785
8220
  }(ValueGetter));
7786
- var BezierSegments = /** @class */ (function (_super) {
7787
- __extends(BezierSegments, _super);
7788
- function BezierSegments() {
8221
+ var BezierCurvePath = /** @class */ (function (_super) {
8222
+ __extends(BezierCurvePath, _super);
8223
+ function BezierCurvePath() {
7789
8224
  return _super !== null && _super.apply(this, arguments) || this;
7790
8225
  }
7791
- BezierSegments.prototype.onCreate = function (props) {
7792
- _super.prototype.onCreate.call(this, props);
7793
- this.cps = props[2];
7794
- };
7795
- BezierSegments.prototype.calculateVec = function (i, t) {
7796
- var vec0 = this.values[i];
7797
- var vec1 = this.values[i + 1];
7798
- var outCp = this.cps[i + i];
7799
- var inCp = this.cps[i + i + 1];
7800
- var ret = [0, 0, 0];
7801
- var ddt = 1 - t;
7802
- var a = ddt * ddt * ddt;
7803
- var b = 3 * t * ddt * ddt;
7804
- var c = 3 * t * t * ddt;
7805
- var d = t * t * t;
7806
- for (var j = 0; j < vec0.length; j++) {
7807
- ret[j] = a * vec0[j] + b * outCp[j] + c * inCp[j] + d * vec1[j];
8226
+ BezierCurvePath.prototype.onCreate = function (props) {
8227
+ var _a = __read$3(props, 3), keyframes = _a[0], points = _a[1], controlPoints = _a[2];
8228
+ this.curveSegments = {};
8229
+ if (!controlPoints.length) {
8230
+ return;
8231
+ }
8232
+ for (var i = 0; i < keyframes.length - 1; i++) {
8233
+ var leftKeyframe = keyframes[i];
8234
+ var rightKeyframe = keyframes[i + 1];
8235
+ var ps1 = new Vector3(points[i][0], points[i][1], points[i][2]), ps2 = new Vector3(points[i + 1][0], points[i + 1][1], points[i + 1][2]);
8236
+ var cp1 = new Vector3(controlPoints[2 * i][0], controlPoints[2 * i][1], controlPoints[2 * i][2]), cp2 = new Vector3(controlPoints[2 * i + 1][0], controlPoints[2 * i + 1][1], controlPoints[2 * i + 1][2]);
8237
+ var _b = buildEasingCurve(leftKeyframe, rightKeyframe), ps = _b.points, easingCurve = _b.curve, timeInterval = _b.timeInterval, valueInterval = _b.valueInterval;
8238
+ var s = ps[0];
8239
+ var e = ps[ps.length - 1];
8240
+ var pathCurve = new BezierPath(ps1, ps2, cp1, cp2);
8241
+ this.curveSegments["".concat(s.x, "&").concat(e.x)] = {
8242
+ points: ps,
8243
+ timeInterval: timeInterval,
8244
+ valueInterval: valueInterval,
8245
+ easingCurve: easingCurve,
8246
+ pathCurve: pathCurve,
8247
+ };
7808
8248
  }
7809
- return ret;
7810
8249
  };
7811
- return BezierSegments;
7812
- }(PathSegments));
8250
+ BezierCurvePath.prototype.getValue = function (time) {
8251
+ var t = numberToFix(time, 5);
8252
+ var perc = 0, point = new Vector3();
8253
+ var keyTimeData = Object.keys(this.curveSegments);
8254
+ if (!keyTimeData.length) {
8255
+ return point;
8256
+ }
8257
+ var keyTimeStart = Number(keyTimeData[0].split('&')[0]);
8258
+ var keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split('&')[1]);
8259
+ if (t <= keyTimeStart) {
8260
+ var pathCurve = this.curveSegments[keyTimeData[0]].pathCurve;
8261
+ point = pathCurve.getPointInPercent(0);
8262
+ return point;
8263
+ }
8264
+ if (t >= keyTimeEnd) {
8265
+ var pathCurve = this.curveSegments[keyTimeData[keyTimeData.length - 1]].pathCurve;
8266
+ point = pathCurve.getPointInPercent(1);
8267
+ return point;
8268
+ }
8269
+ for (var i = 0; i < keyTimeData.length; i++) {
8270
+ var _a = __read$3(keyTimeData[i].split('&'), 2), xMin = _a[0], xMax = _a[1];
8271
+ if (t >= Number(xMin) && t < Number(xMax)) {
8272
+ var bezierPath = this.curveSegments[keyTimeData[i]].pathCurve;
8273
+ perc = this.getPercValue(keyTimeData[i], t);
8274
+ point = bezierPath.getPointInPercent(perc);
8275
+ }
8276
+ }
8277
+ return point;
8278
+ };
8279
+ BezierCurvePath.prototype.getPercValue = function (curveKey, time) {
8280
+ var curveInfo = this.curveSegments[curveKey];
8281
+ var _a = __read$3(curveInfo.points, 1), p0 = _a[0];
8282
+ var timeInterval = curveInfo.timeInterval;
8283
+ var normalizeTime = numberToFix((time - p0.x) / timeInterval, 4);
8284
+ var value = curveInfo.easingCurve.getValue(normalizeTime);
8285
+ // TODO 测试用 编辑器限制值域后移除clamp
8286
+ return clamp$1(value, 0, 1);
8287
+ };
8288
+ return BezierCurvePath;
8289
+ }(ValueGetter));
7813
8290
  var map$1 = (_a$5 = {},
7814
8291
  _a$5[ValueType$1.RANDOM] = function (props) {
7815
8292
  if (props[0] instanceof Array) {
@@ -7829,9 +8306,6 @@ var map$1 = (_a$5 = {},
7829
8306
  _a$5[ValueType$1.CONSTANT_VEC4] = function (props) {
7830
8307
  return new StaticValue(props);
7831
8308
  },
7832
- _a$5[ValueType$1.CURVE] = function (props) {
7833
- return new CurveValue(props);
7834
- },
7835
8309
  _a$5[ValueType$1.RGBA_COLOR] = function (props) {
7836
8310
  return new StaticValue(props);
7837
8311
  },
@@ -7847,11 +8321,20 @@ var map$1 = (_a$5 = {},
7847
8321
  _a$5[ValueType$1.GRADIENT_COLOR] = function (props) {
7848
8322
  return new GradientValue(props);
7849
8323
  },
7850
- _a$5[ValueType$1.LINEAR_PATH] = function (pros) {
7851
- return new PathSegments(pros);
8324
+ // [spec.ValueType.LINEAR_PATH] (pros: number[][][]) {
8325
+ // return new PathSegments(pros);
8326
+ // },
8327
+ _a$5[ValueType$1.BEZIER_CURVE] = function (props) {
8328
+ if (props.length === 1) {
8329
+ return new StaticValue(props[0][1][1]);
8330
+ }
8331
+ return new BezierCurve(props);
7852
8332
  },
7853
- _a$5[ValueType$1.BEZIER_PATH] = function (pros) {
7854
- return new BezierSegments(pros);
8333
+ _a$5[ValueType$1.BEZIER_CURVE_PATH] = function (props) {
8334
+ if (props[0].length === 1) {
8335
+ return new StaticValue(new Vector3(props[0][0][1][1], props[1][0][1][1], props[2][0][1][1]));
8336
+ }
8337
+ return new BezierCurvePath(props);
7855
8338
  },
7856
8339
  _a$5);
7857
8340
  function createValueGetter(args) {
@@ -7879,64 +8362,17 @@ function lineSegIntegrateByTime(t, t0, t1, y0, y1) {
7879
8362
  var t03 = t02 * t0;
7880
8363
  return (2 * t3 * (y0 - y1) + 3 * t2 * (t0 * y1 - t1 * y0) - t03 * (2 * y0 + y1) + 3 * t02 * t1 * y0) / (6 * (t0 - t1));
7881
8364
  }
7882
- function curveValueEvaluate(time, keyframe0, keyframe1) {
7883
- var dt = keyframe1[CURVE_PRO_TIME] - keyframe0[CURVE_PRO_TIME];
7884
- var m0 = keyframe0[CURVE_PRO_OUT_TANGENT] * dt;
7885
- var m1 = keyframe1[CURVE_PRO_IN_TANGENT] * dt;
7886
- var t = (time - keyframe0[CURVE_PRO_TIME]) / dt;
7887
- var t2 = t * t;
7888
- var t3 = t2 * t;
7889
- var a = 2 * t3 - 3 * t2 + 1;
7890
- var b = t3 - 2 * t2 + t;
7891
- var c = t3 - t2;
7892
- var d = -2 * t3 + 3 * t2;
7893
- //(2*v0+m0+m1-2*v1)*(t-t0)^3/k^3+(3*v1-3*v0-2*m0-m1)*(t-t0)^2/k^2+m0 *(t-t0)/k+v0
7894
- return a * keyframe0[CURVE_PRO_VALUE] + b * m0 + c * m1 + d * keyframe1[CURVE_PRO_VALUE];
7895
- }
7896
- function curveValueIntegrate(time, keyframe0, keyframe1) {
7897
- var k = keyframe1[CURVE_PRO_TIME] - keyframe0[CURVE_PRO_TIME];
7898
- var m0 = keyframe0[CURVE_PRO_OUT_TANGENT] * k;
7899
- var m1 = keyframe1[CURVE_PRO_IN_TANGENT] * k;
7900
- var t0 = keyframe0[CURVE_PRO_TIME];
7901
- var v0 = keyframe0[CURVE_PRO_VALUE];
7902
- var v1 = keyframe1[CURVE_PRO_VALUE];
7903
- var dt = t0 - time;
7904
- var dt2 = dt * dt;
7905
- var dt3 = dt2 * dt;
7906
- return (m0 + m1 + 2 * v0 - 2 * v1) * dt3 * dt / (4 * k * k * k) +
7907
- (2 * m0 + m1 + 3 * v0 - 3 * v1) * dt3 / (3 * k * k) +
7908
- m0 * dt2 / 2 / k - v0 * dt;
7909
- }
7910
- function curveValueIntegrateByTime(t1, keyframe0, keyframe1) {
7911
- var k = keyframe1[CURVE_PRO_TIME] - keyframe0[CURVE_PRO_TIME];
7912
- var m0 = keyframe0[CURVE_PRO_OUT_TANGENT] * k;
7913
- var m1 = keyframe1[CURVE_PRO_IN_TANGENT] * k;
7914
- var t0 = keyframe0[CURVE_PRO_TIME];
7915
- var v0 = keyframe0[CURVE_PRO_VALUE];
7916
- var v1 = keyframe1[CURVE_PRO_VALUE];
7917
- var dt = t0 - t1;
7918
- var dt2 = dt * dt;
7919
- var dt3 = dt2 * dt;
7920
- var k2 = k * k;
7921
- var k3 = k2 * k;
7922
- //(30 k^3 v0 (t1^2 - t0^2) + 10 k^2 m0 (t0 + 2 t1) (t0 - t1)^2 + 5 k (t0 + 3 t1) (t0 - t1)^3 (2 m0 + m1 + 3 v0 - 3 v1) + 3 (t0 + 4 t1) (t0 - t1)^4 (m0 + m1 + 2 v0 - 2 v1))/(60 k^3)
7923
- var ret = -30 * k3 * v0 * (t0 + t1) * dt +
7924
- 10 * k2 * m0 * (t0 + 2 * t1) * dt2 +
7925
- 5 * k * (t0 + 3 * t1) * (2 * m0 + m1 + 3 * v0 - 3 * v1) * dt3 +
7926
- 3 * (t0 + 4 * t1) * (m0 + m1 + 2 * v0 - 2 * v1) * dt3 * dt;
7927
- return ret / 60 / k3;
7928
- }
7929
8365
  function getKeyFrameMetaByRawValue(meta, value) {
7930
8366
  if (value) {
7931
8367
  var type = value[0];
7932
- var keys_3 = value[1];
8368
+ var keys = value[1];
7933
8369
  if (type === ValueType$1.CURVE) {
7934
- meta.curves.push(keys_3);
7935
- var keyLen = keys_3.length;
7936
- if (keys_3[0][0] > 0) {
8370
+ meta.curves.push(keys);
8371
+ var keyLen = keys.length;
8372
+ if (keys[0][0] > 0) {
7937
8373
  keyLen++;
7938
8374
  }
7939
- if (keys_3[keys_3.length - 1][0] < 1) {
8375
+ if (keys[keys.length - 1][0] < 1) {
7940
8376
  keyLen++;
7941
8377
  }
7942
8378
  meta.index += keyLen;
@@ -7944,22 +8380,29 @@ function getKeyFrameMetaByRawValue(meta, value) {
7944
8380
  meta.curveCount += keyLen;
7945
8381
  }
7946
8382
  else if (type === ValueType$1.LINE) {
7947
- var keyLen = keys_3.length;
7948
- if (keyLen === 2 && keys_3[0][0] === 0 && keys_3[1][0] === 1) {
8383
+ var keyLen = keys.length;
8384
+ if (keyLen === 2 && keys[0][0] === 0 && keys[1][0] === 1) {
7949
8385
  return;
7950
8386
  }
7951
- if (keys_3[0][0] > 0) {
8387
+ if (keys[0][0] > 0) {
7952
8388
  keyLen++;
7953
8389
  }
7954
- if (keys_3[keys_3.length - 1][0] < 1) {
8390
+ if (keys[keys.length - 1][0] < 1) {
7955
8391
  keyLen++;
7956
8392
  }
7957
8393
  var uniformCount = Math.ceil(keyLen / 2);
7958
8394
  meta.lineSegCount += uniformCount;
7959
- meta.curves.push(keys_3);
8395
+ meta.curves.push(keys);
7960
8396
  meta.index += uniformCount;
7961
8397
  meta.max = Math.max(meta.max, uniformCount);
7962
8398
  }
8399
+ else if (type === ValueType$1.BEZIER_CURVE) {
8400
+ var keyLen = keys.length - 1;
8401
+ meta.index += 2 * keyLen;
8402
+ meta.curves.push(keys);
8403
+ meta.max = Math.max(meta.max, 2 * keyLen);
8404
+ meta.curveCount += 2 * keyLen;
8405
+ }
7963
8406
  }
7964
8407
  }
7965
8408
  function createKeyFrameMeta() {
@@ -10437,9 +10880,9 @@ var KTXTexture = /** @class */ (function () {
10437
10880
  for (var level = 0; level < mipmapCount; level++) {
10438
10881
  var imageSize = new Int32Array(this.arrayBuffer, this.baseOffset + dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
10439
10882
  for (var face = 0; face < this.numberOfFaces; face++) {
10440
- var data_1 = new Uint8Array(this.arrayBuffer, this.baseOffset + dataOffset + 4, imageSize);
10883
+ var data = new Uint8Array(this.arrayBuffer, this.baseOffset + dataOffset + 4, imageSize);
10441
10884
  mipmaps.push({
10442
- data: data_1,
10885
+ data: data,
10443
10886
  width: width,
10444
10887
  height: height,
10445
10888
  });
@@ -11690,21 +12133,19 @@ var compatible_vert = "#version 300 es\n#ifdef WEBGL2\n#define texture2D texture
11690
12133
 
11691
12134
  var itemFrameFrag = "#version 300 es\nprecision highp float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}in vec4 vColor;in vec4 vTexCoord;in highp vec2 vParams;uniform vec3 uFrameColor;void main(){fragColor=vec4(uFrameColor.xyz,1.0);}";
11692
12135
 
11693
- var integrate = "float integrateCurveFrames(float t1,vec4 k0,vec4 k1){float k=k1.x-k0.x;float m0=k0.w*k;float m1=k1.z*k;float t0=k0.x;float v0=k0.y;float v1=k1.y;float dt=t0-t1;float dt2=dt*dt;float dt3=dt2*dt;vec4 a=vec4(dt3*dt,dt3,dt2,dt)/vec4(4.*k*k*k,3.*k*k,2.*k,1.);vec4 b=vec4(m0+m1+2.*v0-2.*v1,2.*m0+m1+3.*v0-3.*v1,m0,-v0);return dot(a,b);}float integrateByTimeCurveFrames(float t1,vec4 k0,vec4 k1){float k=k1.x-k0.x;float m0=k0.w*k;float m1=k1.z*k;float t0=k0.x;float v0=k0.y;float v1=k1.y;float dt=t0-t1;float dt2=dt*dt;float dt3=dt2*dt;float k2=k*k;float k3=k2*k;vec4 a=vec4(-30.*k3,10.*k2,5.*k,3.)*vec4(dt,dt2,dt3,dt3*dt);vec4 b=vec4(v0,m0,2.*m0+m1+3.*v0-3.*v1,m0+m1+2.*v0-2.*v1)*vec4(t0+t1,t0+2.*t1,t0+3.*t1,t0+4.*t1);return dot(a,b)/60./k3;}float integrateByTimeFromCurveFrames(float t1,float frameStart,float frameCount){if(t1==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i==count){return ret;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(t1>k0.x&&t1<=k1.x){return ret+integrateByTimeCurveFrames(t1,k0,k1);}ret+=integrateByTimeCurveFrames(k1.x,k0,k1);}return ret;}float integrateFromCurveFrames(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i==count){return ret;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(time>k0.x&&time<=k1.x){return ret+integrateCurveFrames(time,k0,k1);}ret+=integrateCurveFrames(k1.x,k0,k1);}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==2.){float idx=floor(value.y);float ilen=floor(1./fract(value.y)+0.5);float d=integrateFromCurveFrames(t1,idx,ilen);return d*value.w+value.z*t1;}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==2.){float idx=floor(value.y);float ilen=floor(1./fract(value.y)+0.5);float d=integrateByTimeFromCurveFrames(t1,idx,ilen)-integrateByTimeFromCurveFrames(t0,idx,ilen);return d*value.w+value.z*pow(t1-t0,2.)*0.5;}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}return 0.;}";
12136
+ var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4){float movement=0.0;float h=(t-p1.x)*0.1;float delta=1./(p4.x-p1.x);for(int i=0;i<=10;i++){float t=float(i)*h*delta;float nt=binarySearchT(t,p1.x,p2.x,p3.x,p4.x);float y=cubicBezier(nt,p1.y,p2.y,p3.y,p4.y);float weight=(i==0||i==10)? 1.0 :(mod(float(i),2.)!=0.)? 4.0 : 2.0;movement+=weight*y;}movement*=h/3.;return movement;}float integrateFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i+=2){vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return ret;}vec2 p1=vec2(k0.x,k0.y);vec2 p2=vec2(k0.z,k0.w);vec2 p3=vec2(k1.z,k1.w);vec2 p4=vec2(k1.x,k1.y);if(time>=k1.x){ret+=calculateMovement(k1.x,p1,p2,p3,p4);}if(time>=k0.x&&time<k1.x){return ret+calculateMovement(time,p1,p2,p3,p4);}}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w);}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w)-integrateFromBezierCurveFrames(t0,value.z,value.w);}return 0.;}";
11694
12137
 
11695
12138
  var itemVert = "#version 300 es\nprecision highp float;\n#define SHADER_VERTEX 1\n#define SPRITE_SHADER 1\nin vec4 aPoint;in vec2 aIndex;uniform mat4 uMainData[MAX_ITEM_COUNT];uniform vec4 uTexParams[MAX_ITEM_COUNT];uniform vec4 uTexOffset[MAX_ITEM_COUNT];uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixInvV;uniform mat4 effects_MatrixVP;out vec4 vColor;out vec4 vTexCoord;\n#ifdef ADJUST_LAYER\nout vec2 vFeatherCoord;\n#endif\nout highp vec3 vParams;const float d2r=3.141592653589793/180.;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvec4 filterMain(float t,vec4 position);\n#pragma FILTER_VERT\nvec3 rotateByQuat(vec3 a,vec4 quat){vec3 qvec=quat.xyz;vec3 uv=cross(qvec,a);vec3 uuv=cross(qvec,uv)*2.;return a+(uv*2.*quat.w+uuv);}void main(){int index=int(aIndex.x);vec4 texParams=uTexParams[index];mat4 mainData=uMainData[index];float life=mainData[1].z;if(life<0.||life>1.){gl_Position=vec4(3.,3.,3.,1.);}else{vec4 _pos=mainData[0];vec2 size=mainData[1].xy;vec3 point=rotateByQuat(vec3(aPoint.xy*size,0.),mainData[2]);vec4 pos=vec4(_pos.xyz,1.0);float renderMode=texParams.z;if(renderMode==0.){pos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixInvV[0].xyz*point.x+effects_MatrixInvV[1].xyz*point.y;}else if(renderMode==1.){pos.xyz+=point;pos=effects_ObjectToWorld*pos;}else if(renderMode==2.){pos=effects_ObjectToWorld*pos;pos.xy+=point.xy;}else if(renderMode==3.){pos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixInvV[0].xyz*point.x+effects_MatrixInvV[2].xyz*point.y;}gl_Position=effects_MatrixVP*pos;\n#ifdef ADJUST_LAYER\nvec4 filter_Position=filterMain(life,pos);\n#endif\ngl_PointSize=6.0;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#ifdef ADJUST_LAYER\nfilter_Position=vec4(filter_Position.xy*uEditorTransform.xy+uEditorTransform.zw*filter_Position.w,filter_Position.zw);\n#endif\n#endif\n#ifdef ADJUST_LAYER\nvTexCoord=vec4(filter_Position.xy/filter_Position.w+1.,gl_Position.xy/gl_Position.w+1.)/2.;vFeatherCoord=aPoint.zw;\n#else\nvec4 texOffset=uTexOffset[index];vTexCoord=vec4(aPoint.zw*texOffset.zw+texOffset.xy,texParams.xy);\n#endif\nvColor=mainData[3];vParams=vec3(aIndex.y,texParams.y,texParams.x);}}";
11696
12139
 
11697
- var item_define = "uniform mat4 uMainData[MAX_ITEM_COUNT];uniform vec4 uTexParams[MAX_ITEM_COUNT];uniform vec4 uTexOffset[MAX_ITEM_COUNT];";
11698
-
11699
12140
  var itemFrag = "#version 300 es\nprecision highp float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}\n#define SPRITE_SHADER 1\nin vec4 vColor;in vec4 vTexCoord;in highp vec3 vParams;\n#ifdef ADJUST_LAYER\nuniform sampler2D uSamplerPre;vec4 filterMain(vec2 coord,sampler2D tex);in vec2 vFeatherCoord;uniform sampler2D uFeatherSampler;\n#endif\nuniform sampler2D uSampler0;uniform sampler2D uSampler1;uniform sampler2D uSampler2;uniform sampler2D uSampler3;uniform sampler2D uSampler4;uniform sampler2D uSampler5;uniform sampler2D uSampler6;uniform sampler2D uSampler7;\n#if MAX_FRAG_TEX == 16\nuniform sampler2D uSampler8;uniform sampler2D uSampler9;uniform sampler2D uSampler10;uniform sampler2D uSampler11;uniform sampler2D uSampler12;uniform sampler2D uSampler13;uniform sampler2D uSampler14;uniform sampler2D uSampler15;\n#endif\nvec4 texture2DbyIndex(float index,vec2 coord);\n#pragma FILTER_FRAG\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\nvoid main(){vec4 color=vec4(0.);\n#ifdef ADJUST_LAYER\nvec2 featherCoord=abs(vFeatherCoord-vec2(0.5))/0.5;float cc=sqrt(max(featherCoord.x,featherCoord.y));float blend=vColor.a*texture2D(uFeatherSampler,vec2(cc,0.)).r;if(blend>=1.){color=filterMain(vTexCoord.xy,uSamplerPre);}else if(blend<=0.){color=texture2D(uSamplerPre,vTexCoord.zw);}else{color=mix(texture2D(uSamplerPre,vTexCoord.zw),filterMain(vTexCoord.xy,uSamplerPre),blend);}\n#else\nvec4 texColor=texture2DbyIndex(round(vParams.x),vTexCoord.xy);color=blendColor(texColor,vColor,round(vParams.y));if(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);fragColor=color;}vec4 texture2DbyIndex(float index,vec2 coord){\n#ifndef ADJUST_LAYER\nif(index==0.){return texture2D(uSampler0,coord);}if(index==1.){return texture2D(uSampler1,coord);}if(index==2.){return texture2D(uSampler2,coord);}if(index==3.){return texture2D(uSampler3,coord);}if(index==4.){return texture2D(uSampler4,coord);}if(index==5.){return texture2D(uSampler5,coord);}if(index==6.){return texture2D(uSampler6,coord);}if(index==7.){return texture2D(uSampler7,coord);}\n#if MAX_FRAG_TEX == 16\nif(index==8.){return texture2D(uSampler8,coord);}if(index==9.){return texture2D(uSampler9,coord);}if(index==10.){return texture2D(uSampler10,coord);}if(index==11.){return texture2D(uSampler11,coord);}if(index==12.){return texture2D(uSampler12,coord);}if(index==13.){return texture2D(uSampler13,coord);}if(index==14.){return texture2D(uSampler14,coord);}if(index==15.){return texture2D(uSampler15,coord);}\n#endif\nreturn texture2D(uSampler0,coord);\n#else\nreturn vec4(0.);\n#endif\n}";
11700
12141
 
11701
- var particleFrag = "#version 300 es\nprecision mediump float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}\n#define PATICLE_SHADER 1\nin float vLife;in vec2 vTexCoord;in vec4 vColor;uniform vec3 emissionColor;uniform float emissionIntensity;uniform sampler2D uMaskTex;uniform vec4 uColorParams;uniform vec2 uTexOffset;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#ifdef USE_SPRITE\nin vec4 vTexCoordBlend;\n#ifdef USE_FILTER\nuniform vec4 uFSprite;\n#endif\n#endif\nin float vSeed;\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\n#ifdef USE_SPRITE\nvec4 getTextureColor(sampler2D tex,vec2 texCoord){if(vTexCoordBlend.w>0.){return mix(texture2D(tex,texCoord),texture2D(tex,vTexCoordBlend.xy+texCoord),vTexCoordBlend.z);}return texture2D(tex,texCoord);}\n#else\n#define getTextureColor texture2D\n#endif\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\n#ifdef PREVIEW_BORDER\nvoid main(){fragColor=uPreviewColor;}\n#else\n#pragma FILTER_FRAG\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}\n#ifdef USE_FILTER\n#ifdef USE_SPRITE\ntexOffset=uTexOffset/uFSprite.xy;\n#endif\ncolor=filterMain(vTexCoord,uMaskTex);\n#else\nif(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#endif\n#ifdef COLOR_OVER_LIFETIME\n#ifndef ENABLE_VERTEX_TEXTURE\ntempColor*=texture2D(uColorOverLifetime,vec2(vLife,0.));\n#endif\n#endif\ncolor=blendColor(color,tempColor,round(uColorParams.y));if(color.a<=0.01&&uColorParams.w>0.){float _at=texture2D(uMaskTex,vTexCoord+texOffset).a+texture2D(uMaskTex,vTexCoord+texOffset*-1.).a;if(_at<=0.02){discard;}}vec3 emission=emissionColor*pow(2.0,emissionIntensity);color=vec4(pow(pow(color.rgb,vec3(2.2))+emission,vec3(1.0/2.2)),color.a);fragColor=color;}\n#endif\n";
12142
+ var particleFrag = "#version 300 es\nprecision highp float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}\n#define PATICLE_SHADER 1\nin float vLife;in vec2 vTexCoord;in vec4 vColor;uniform vec3 emissionColor;uniform float emissionIntensity;uniform sampler2D uMaskTex;uniform vec4 uColorParams;uniform vec2 uTexOffset;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#ifdef USE_SPRITE\nin vec4 vTexCoordBlend;\n#ifdef USE_FILTER\nuniform vec4 uFSprite;\n#endif\n#endif\nin float vSeed;\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\n#ifdef USE_SPRITE\nvec4 getTextureColor(sampler2D tex,vec2 texCoord){if(vTexCoordBlend.w>0.){return mix(texture2D(tex,texCoord),texture2D(tex,vTexCoordBlend.xy+texCoord),vTexCoordBlend.z);}return texture2D(tex,texCoord);}\n#else\n#define getTextureColor texture2D\n#endif\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\n#ifdef PREVIEW_BORDER\nvoid main(){fragColor=uPreviewColor;}\n#else\n#pragma FILTER_FRAG\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}\n#ifdef USE_FILTER\n#ifdef USE_SPRITE\ntexOffset=uTexOffset/uFSprite.xy;\n#endif\ncolor=filterMain(vTexCoord,uMaskTex);\n#else\nif(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#endif\n#ifdef COLOR_OVER_LIFETIME\n#ifndef ENABLE_VERTEX_TEXTURE\ntempColor*=texture2D(uColorOverLifetime,vec2(vLife,0.));\n#endif\n#endif\ncolor=blendColor(color,tempColor,round(uColorParams.y));if(color.a<=0.01&&uColorParams.w>0.){float _at=texture2D(uMaskTex,vTexCoord+texOffset).a+texture2D(uMaskTex,vTexCoord+texOffset*-1.).a;if(_at<=0.02){discard;}}vec3 emission=emissionColor*pow(2.0,emissionIntensity);color=vec4(pow(pow(color.rgb,vec3(2.2))+emission,vec3(1.0/2.2)),color.a);fragColor=color;}\n#endif\n";
11702
12143
 
11703
- var particleVert = "#version 300 es\nprecision highp float;\n#define SHADER_VERTEX 1\n#define PATICLE_SHADER 1\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#define NONE_CONST_INDEX 1\n#else\n#if LOOKUP_TEXTURE_CURVE\n#define NONE_CONST_INDEX 1\n#endif\n#endif\n#ifdef NONE_CONST_INDEX\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\n#else\n#define MAX_C CURVE_VALUE_COUNT\n#endif\nfloat evaluateCurveFrames(float time,vec4 keyframe0,vec4 keyframe1){float dt=keyframe1.x-keyframe0.x;float m0=keyframe0.w*dt;float m1=keyframe1.z*dt;float t=(time-keyframe0.x)/dt;float t2=t*t;float t3=t2*t;return dot(vec4(dot(vec3(2.,-3.,1.),vec3(t3,t2,1.)),dot(vec3(1,-2.,1),vec3(t3,t2,t)),t3-t2,dot(vec2(-2,3),vec2(t3,t2))),vec4(keyframe0.y,m0,m1,keyframe1.y));}float valueFromCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){\n#ifdef NONE_CONST_INDEX\nif(i==count){return lookup_curve(count).y;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);\n#else\nif(i<start){continue;}vec4 k0=lookup_curve(i);vec4 k1=lookup_curve(i+1);if(i==end){return k0.y;}\n#endif\nif(time>=k0.x&&time<=k1.x){return evaluateCurveFrames(time,k0,k1);}}return lookup_curve(0).y;}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){\n#ifdef NONE_CONST_INDEX\nif(i>count){return lookup_curve(i).w;}\n#else\nif(i<start){continue;}if(i>end){return lookup_curve(i-2).w;}\n#endif\n#ifdef NONE_CONST_INDEX\nvec4 seg=lookup_curve(i+start);\n#else\nvec4 seg=lookup_curve(i);\n#endif\nvec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}\n#ifdef NONE_CONST_INDEX\nvec2 p2=lookup_curve(i+start+1).xy;\n#else\nvec2 p2=lookup_curve(i+1).xy;\n#endif\nif(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}else if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==2.){return valueFromCurveFrames(time,floor(value.y),floor(1./fract(value.y)+0.5))*value.w+value.z;}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){\n#ifdef SHADER_VERTEX\nfloat seed=aSeed;\n#else\nfloat seed=vSeed;\n#endif\nreturn mix(value.y,value.z,seed);}return 0.;}float integrateCurveFrames(float t1,vec4 k0,vec4 k1){float k=k1.x-k0.x;float m0=k0.w*k;float m1=k1.z*k;float t0=k0.x;float v0=k0.y;float v1=k1.y;float dt=t0-t1;float dt2=dt*dt;float dt3=dt2*dt;vec4 a=vec4(dt3*dt,dt3,dt2,dt)/vec4(4.*k*k*k,3.*k*k,2.*k,1.);vec4 b=vec4(m0+m1+2.*v0-2.*v1,2.*m0+m1+3.*v0-3.*v1,m0,-v0);return dot(a,b);}float integrateByTimeCurveFrames(float t1,vec4 k0,vec4 k1){float k=k1.x-k0.x;float m0=k0.w*k;float m1=k1.z*k;float t0=k0.x;float v0=k0.y;float v1=k1.y;float dt=t0-t1;float dt2=dt*dt;float dt3=dt2*dt;float k2=k*k;float k3=k2*k;vec4 a=vec4(-30.*k3,10.*k2,5.*k,3.)*vec4(dt,dt2,dt3,dt3*dt);vec4 b=vec4(v0,m0,2.*m0+m1+3.*v0-3.*v1,m0+m1+2.*v0-2.*v1)*vec4(t0+t1,t0+2.*t1,t0+3.*t1,t0+4.*t1);return dot(a,b)/60./k3;}float integrateByTimeFromCurveFrames(float t1,float frameStart,float frameCount){if(t1==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i==count){return ret;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(t1>k0.x&&t1<=k1.x){return ret+integrateByTimeCurveFrames(t1,k0,k1);}ret+=integrateByTimeCurveFrames(k1.x,k0,k1);}return ret;}float integrateFromCurveFrames(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i==count){return ret;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(time>k0.x&&time<=k1.x){return ret+integrateCurveFrames(time,k0,k1);}ret+=integrateCurveFrames(k1.x,k0,k1);}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==2.){float idx=floor(value.y);float ilen=floor(1./fract(value.y)+0.5);float d=integrateFromCurveFrames(t1,idx,ilen);return d*value.w+value.z*t1;}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==2.){float idx=floor(value.y);float ilen=floor(1./fract(value.y)+0.5);float d=integrateByTimeFromCurveFrames(t1,idx,ilen)-integrateByTimeFromCurveFrames(t0,idx,ilen);return d*value.w+value.z*pow(t1-t0,2.)*0.5;}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}return 0.;}const float d2r=3.141592653589793/180.;in vec3 aPos;in vec4 aOffset;in vec3 aVel;in vec3 aRot;in vec4 aColor;in vec3 aDirX;in vec3 aDirY;\n#ifdef USE_SPRITE\nin vec3 aSprite;uniform vec4 uSprite;struct UVDetail{vec2 uv0;vec3 uv1;};UVDetail getSpriteUV(vec2 uv,float lifeTime);out vec4 vTexCoordBlend;\n#endif\n#pragma EDITOR_VERT_DEFINE\n#ifdef FINAL_TARGET\nuniform vec3 uFinalTarget;uniform vec4 uForceCurve;\n#endif\nuniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;uniform mat4 effects_MatrixVP;uniform vec4 uParams;uniform vec4 uAcceleration;uniform vec4 uGravityModifierValue;uniform vec4 uOpacityOverLifetimeValue;\n#ifdef ROT_X_LIFETIME\nuniform vec4 uRXByLifeTimeValue;\n#endif\n#ifdef ROT_Y_LIFETIME\nuniform vec4 uRYByLifeTimeValue;\n#endif\n#ifdef ROT_Z_LIFETIME\nuniform vec4 uRZByLifeTimeValue;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n#if LINEAR_VEL_X\nuniform vec4 uLinearXByLifetimeValue;\n#endif\n#if LINEAR_VEL_Y\nuniform vec4 uLinearYByLifetimeValue;\n#endif\n#if LINEAR_VEL_Z\nuniform vec4 uLinearZByLifetimeValue;\n#endif\n#endif\n#ifdef SPEED_OVER_LIFETIME\nuniform vec4 uSpeedLifetimeValue;\n#endif\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n#if ORB_VEL_X\nuniform vec4 uOrbXByLifetimeValue;\n#endif\n#if ORB_VEL_Y\nuniform vec4 uOrbYByLifetimeValue;\n#endif\n#if ORB_VEL_Z\nuniform vec4 uOrbZByLifetimeValue;\n#endif\nuniform vec3 uOrbCenter;\n#endif\nuniform vec4 uSizeByLifetimeValue;\n#ifdef SIZE_Y_BY_LIFE\nuniform vec4 uSizeYByLifetimeValue;\n#endif\nout float vLife;out vec4 vColor;out vec2 vTexCoord;\n#ifdef USE_FILTER\n#pragma FILTER_VERT\n#endif\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvec3 calOrbitalMov(float _life,float _dur){vec3 orb=vec3(0.0);\n#ifdef AS_ORBITAL_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if ORB_VEL_X\norb.x=FUNC(uOrbXByLifetimeValue);\n#endif\n#if ORB_VEL_Y\norb.y=FUNC(uOrbYByLifetimeValue);\n#endif\n#if ORB_VEL_Z\norb.z=FUNC(uOrbZByLifetimeValue);\n#endif\n#undef FUNC\nreturn orb;}vec3 calLinearMov(float _life,float _dur){vec3 mov=vec3(0.0);\n#ifdef AS_LINEAR_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if LINEAR_VEL_X\nmov.x=FUNC(uLinearXByLifetimeValue);\n#endif\n#if LINEAR_VEL_Y\nmov.y=FUNC(uLinearYByLifetimeValue);\n#endif\n#if LINEAR_VEL_Z\nmov.z=FUNC(uLinearZByLifetimeValue);\n#endif\n#undef FUNC\nreturn mov;}mat3 mat3FromRotation(vec3 rotation){vec3 sinR=sin(rotation*d2r);vec3 cosR=cos(rotation*d2r);return mat3(cosR.z,-sinR.z,0.,sinR.z,cosR.z,0.,0.,0.,1.)*mat3(cosR.y,0.,sinR.y,0.,1.,0.,-sinR.y,0,cosR.y)*mat3(1.,0.,0.,0,cosR.x,-sinR.x,0.,sinR.x,cosR.x);}\n#ifdef USE_SPRITE\nUVDetail getSpriteUV(vec2 uv,float lifeTime){float t=fract(clamp((lifeTime-aSprite.x)/aSprite.y,0.0,1.)*aSprite.z);float frame=uSprite.z*t;float frameIndex=max(ceil(frame)-1.,0.);float row=floor((frameIndex+0.1)/uSprite.x);float col=frameIndex-row*uSprite.x;vec2 retUV=(vec2(col,row)+uv)/uSprite.xy;UVDetail ret;if(uSprite.w>0.){float blend=frame-frameIndex;float frameIndex1=min(ceil(frame),uSprite.z-1.);float row1=floor((frameIndex1+0.1)/uSprite.x);float col1=frameIndex1-row1*uSprite.x;vec2 coord=(vec2(col1,row1)+uv)/uSprite.xy-retUV;ret.uv1=vec3(coord.x,1.-coord.y,blend);}ret.uv0=vec2(retUV.x,1.-retUV.y);return ret;}\n#endif\nvec3 calculateTranslation(vec3 vel,float t0,float t1,float dur){float dt=t1-t0;float d=getIntegrateByTimeFromTime(0.,dt,uGravityModifierValue);vec3 acc=uAcceleration.xyz*d;\n#ifdef SPEED_OVER_LIFETIME\nreturn vel*getIntegrateFromTime0(dt/dur,uSpeedLifetimeValue)*dur+acc;\n#endif\nreturn vel*dt+acc;}mat3 transformFromRotation(vec3 rot,float _life,float _dur){vec3 rotation=rot;\n#ifdef ROT_LIFETIME_AS_MOVEMENT\n#define FUNC1(a) getValueFromTime(_life,a)\n#else\n#define FUNC1(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#ifdef ROT_X_LIFETIME\nrotation.x+=FUNC1(uRXByLifeTimeValue);\n#endif\n#ifdef ROT_Y_LIFETIME\nrotation.y+=FUNC1(uRYByLifeTimeValue);\n#endif\n#ifdef ROT_Z_LIFETIME\nrotation.z+=FUNC1(uRZByLifeTimeValue);\n#endif\nif(dot(rotation,rotation)==0.0){return mat3(1.0);}\n#undef FUNC1\nreturn mat3FromRotation(rotation);}void main(){float time=uParams.x-aOffset.z;float dur=aOffset.w;if(time<0.||time>dur){gl_Position=vec4(-3.,-3.,-3.,1.);}else{float life=clamp(time/dur,0.0,1.0);vLife=life;\n#ifdef USE_SPRITE\nUVDetail uvD=getSpriteUV(aOffset.xy,time);vTexCoord=uvD.uv0;vTexCoordBlend=vec4(uvD.uv1,uSprite.w);\n#else\nvTexCoord=aOffset.xy;\n#endif\nvColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(life,0.));\n#endif\n#endif\nvColor.a*=clamp(getValueFromTime(life,uOpacityOverLifetimeValue),0.,1.);vec3 size=vec3(vec2(getValueFromTime(life,uSizeByLifetimeValue)),1.0);\n#ifdef SIZE_Y_BY_LIFE\nsize.y=getValueFromTime(life,uSizeYByLifetimeValue);\n#endif\nvec3 point=transformFromRotation(aRot,life,dur)*(aDirX*size.x+aDirY*size.y);vec3 pt=calculateTranslation(aVel,aOffset.z,uParams.x,dur);vec3 _pos=aPos+pt;\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n_pos=mat3FromRotation(calOrbitalMov(life,dur))*(_pos-uOrbCenter);_pos+=uOrbCenter;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n_pos.xyz+=calLinearMov(life,dur);\n#endif\n#ifdef FINAL_TARGET\nfloat force=getValueFromTime(life,uForceCurve);vec4 pos=vec4(mix(_pos,uFinalTarget,force),1.);\n#else\nvec4 pos=vec4(_pos,1.0);\n#endif\n#if RENDER_MODE == 1\npos.xyz+=point;pos=effects_ObjectToWorld*pos;\n#elif RENDER_MODE == 3\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[2].xyz*point.y;\n#elif RENDER_MODE == 2\npos=effects_ObjectToWorld*pos;pos.xy+=point.xy;\n#elif RENDER_MODE == 0\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[1].xyz*point.y;\n#endif\ngl_Position=effects_MatrixVP*pos;vSeed=aSeed;gl_PointSize=6.0;\n#ifdef USE_FILTER\nfilterMain(life);\n#endif\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n#pragma EDITOR_VERT_TRANSFORM\n}}";
12144
+ var particleVert = "#version 300 es\nprecision mediump float;\n#define SHADER_VERTEX 1\n#define PATICLE_SHADER 1\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<12;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4){float movement=0.0;float h=(t-p1.x)*0.1;float delta=1./(p4.x-p1.x);for(int i=0;i<=10;i++){float t=float(i)*h*delta;float nt=binarySearchT(t,p1.x,p2.x,p3.x,p4.x);float y=cubicBezier(nt,p1.y,p2.y,p3.y,p4.y);float weight=(i==0||i==10)? 1.0 :(mod(float(i),2.)!=0.)? 4.0 : 2.0;movement+=weight*y;}movement*=h/3.;return movement;}float integrateFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i+=2){vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return ret;}vec2 p1=vec2(k0.x,k0.y);vec2 p2=vec2(k0.z,k0.w);vec2 p3=vec2(k1.z,k1.w);vec2 p4=vec2(k1.x,k1.y);if(time>=k1.x){ret+=calculateMovement(k1.x,p1,p2,p3,p4);}if(time>=k0.x&&time<k1.x){return ret+calculateMovement(time,p1,p2,p3,p4);}}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w);}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w)-integrateFromBezierCurveFrames(t0,value.z,value.w);}return 0.;}const float d2r=3.141592653589793/180.;in vec3 aPos;in vec4 aOffset;in vec3 aVel;in vec3 aRot;in vec4 aColor;in vec3 aDirX;in vec3 aDirY;\n#ifdef USE_SPRITE\nin vec3 aSprite;uniform vec4 uSprite;struct UVDetail{vec2 uv0;vec3 uv1;};UVDetail getSpriteUV(vec2 uv,float lifeTime);out vec4 vTexCoordBlend;\n#endif\n#ifdef FINAL_TARGET\nuniform vec3 uFinalTarget;uniform vec4 uForceCurve;\n#endif\nuniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;uniform mat4 effects_MatrixVP;uniform vec4 uParams;uniform vec4 uAcceleration;uniform vec4 uGravityModifierValue;uniform vec4 uOpacityOverLifetimeValue;\n#ifdef ROT_X_LIFETIME\nuniform vec4 uRXByLifeTimeValue;\n#endif\n#ifdef ROT_Y_LIFETIME\nuniform vec4 uRYByLifeTimeValue;\n#endif\n#ifdef ROT_Z_LIFETIME\nuniform vec4 uRZByLifeTimeValue;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n#if LINEAR_VEL_X\nuniform vec4 uLinearXByLifetimeValue;\n#endif\n#if LINEAR_VEL_Y\nuniform vec4 uLinearYByLifetimeValue;\n#endif\n#if LINEAR_VEL_Z\nuniform vec4 uLinearZByLifetimeValue;\n#endif\n#endif\n#ifdef SPEED_OVER_LIFETIME\nuniform vec4 uSpeedLifetimeValue;\n#endif\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n#if ORB_VEL_X\nuniform vec4 uOrbXByLifetimeValue;\n#endif\n#if ORB_VEL_Y\nuniform vec4 uOrbYByLifetimeValue;\n#endif\n#if ORB_VEL_Z\nuniform vec4 uOrbZByLifetimeValue;\n#endif\nuniform vec3 uOrbCenter;\n#endif\nuniform vec4 uSizeByLifetimeValue;\n#ifdef SIZE_Y_BY_LIFE\nuniform vec4 uSizeYByLifetimeValue;\n#endif\nout float vLife;out vec4 vColor;out vec2 vTexCoord;\n#ifdef USE_FILTER\n#pragma FILTER_VERT\n#endif\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvec3 calOrbitalMov(float _life,float _dur){vec3 orb=vec3(0.0);\n#ifdef AS_ORBITAL_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if ORB_VEL_X\norb.x=FUNC(uOrbXByLifetimeValue);\n#endif\n#if ORB_VEL_Y\norb.y=FUNC(uOrbYByLifetimeValue);\n#endif\n#if ORB_VEL_Z\norb.z=FUNC(uOrbZByLifetimeValue);\n#endif\n#undef FUNC\nreturn orb;}vec3 calLinearMov(float _life,float _dur){vec3 mov=vec3(0.0);\n#ifdef AS_LINEAR_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if LINEAR_VEL_X\nmov.x=FUNC(uLinearXByLifetimeValue);\n#endif\n#if LINEAR_VEL_Y\nmov.y=FUNC(uLinearYByLifetimeValue);\n#endif\n#if LINEAR_VEL_Z\nmov.z=FUNC(uLinearZByLifetimeValue);\n#endif\n#undef FUNC\nreturn mov;}mat3 mat3FromRotation(vec3 rotation){vec3 sinR=sin(rotation*d2r);vec3 cosR=cos(rotation*d2r);return mat3(cosR.z,-sinR.z,0.,sinR.z,cosR.z,0.,0.,0.,1.)*mat3(cosR.y,0.,sinR.y,0.,1.,0.,-sinR.y,0,cosR.y)*mat3(1.,0.,0.,0,cosR.x,-sinR.x,0.,sinR.x,cosR.x);}\n#ifdef USE_SPRITE\nUVDetail getSpriteUV(vec2 uv,float lifeTime){float t=fract(clamp((lifeTime-aSprite.x)/aSprite.y,0.0,1.)*aSprite.z);float frame=uSprite.z*t;float frameIndex=max(ceil(frame)-1.,0.);float row=floor((frameIndex+0.1f)/uSprite.x);float col=frameIndex-row*uSprite.x;vec2 retUV=(vec2(col,row)+uv)/uSprite.xy;UVDetail ret;if(uSprite.w>0.){float blend=frame-frameIndex;float frameIndex1=min(ceil(frame),uSprite.z-1.);float row1=floor((frameIndex1+0.1f)/uSprite.x);float col1=frameIndex1-row1*uSprite.x;vec2 coord=(vec2(col1,row1)+uv)/uSprite.xy-retUV;ret.uv1=vec3(coord.x,1.-coord.y,blend);}ret.uv0=vec2(retUV.x,1.-retUV.y);return ret;}\n#endif\nvec3 calculateTranslation(vec3 vel,float t0,float t1,float dur){float dt=t1-t0;float d=getIntegrateByTimeFromTime(0.,dt,uGravityModifierValue);vec3 acc=uAcceleration.xyz*d;\n#ifdef SPEED_OVER_LIFETIME\nreturn vel*getIntegrateFromTime0(dt/dur,uSpeedLifetimeValue)*dur+acc;\n#endif\nreturn vel*dt+acc;}mat3 transformFromRotation(vec3 rot,float _life,float _dur){vec3 rotation=rot;\n#ifdef ROT_LIFETIME_AS_MOVEMENT\n#define FUNC1(a) getValueFromTime(_life,a)\n#else\n#define FUNC1(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#ifdef ROT_X_LIFETIME\nrotation.x+=FUNC1(uRXByLifeTimeValue);\n#endif\n#ifdef ROT_Y_LIFETIME\nrotation.y+=FUNC1(uRYByLifeTimeValue);\n#endif\n#ifdef ROT_Z_LIFETIME\nrotation.z+=FUNC1(uRZByLifeTimeValue);\n#endif\nif(dot(rotation,rotation)==0.0){return mat3(1.0);}\n#undef FUNC1\nreturn mat3FromRotation(rotation);}void main(){float time=uParams.x-aOffset.z;float dur=aOffset.w;if(time<0.||time>dur){gl_Position=vec4(-3.,-3.,-3.,1.);}else{float life=clamp(time/dur,0.0,1.0);vLife=life;\n#ifdef USE_SPRITE\nUVDetail uvD=getSpriteUV(aOffset.xy,time);vTexCoord=uvD.uv0;vTexCoordBlend=vec4(uvD.uv1,uSprite.w);\n#else\nvTexCoord=aOffset.xy;\n#endif\nvColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(life,0.));\n#endif\n#endif\nvColor.a*=clamp(getValueFromTime(life,uOpacityOverLifetimeValue),0.,1.);vec3 size=vec3(vec2(getValueFromTime(life,uSizeByLifetimeValue)),1.0);\n#ifdef SIZE_Y_BY_LIFE\nsize.y=getValueFromTime(life,uSizeYByLifetimeValue);\n#endif\nvec3 point=transformFromRotation(aRot,life,dur)*(aDirX*size.x+aDirY*size.y);vec3 pt=calculateTranslation(aVel,aOffset.z,uParams.x,dur);vec3 _pos=aPos+pt;\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n_pos=mat3FromRotation(calOrbitalMov(life,dur))*(_pos-uOrbCenter);_pos+=uOrbCenter;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n_pos.xyz+=calLinearMov(life,dur);\n#endif\n#ifdef FINAL_TARGET\nfloat force=getValueFromTime(life,uForceCurve);vec4 pos=vec4(mix(_pos,uFinalTarget,force),1.);\n#else\nvec4 pos=vec4(_pos,1.0);\n#endif\n#if RENDER_MODE == 1\npos.xyz+=point;pos=effects_ObjectToWorld*pos;\n#elif RENDER_MODE == 3\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[2].xyz*point.y;\n#elif RENDER_MODE == 2\npos=effects_ObjectToWorld*pos;pos.xy+=point.xy;\n#elif RENDER_MODE == 0\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[1].xyz*point.y;\n#endif\ngl_Position=effects_MatrixVP*pos;vSeed=aSeed;gl_PointSize=6.0;\n#ifdef USE_FILTER\nfilterMain(life);\n#endif\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}}";
11704
12145
 
11705
- var trailVert = "#version 300 es\nprecision mediump float;\n#define SHADER_VERTEX 1\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#define NONE_CONST_INDEX 1\n#else\n#if LOOKUP_TEXTURE_CURVE\n#define NONE_CONST_INDEX 1\n#endif\n#endif\n#ifdef NONE_CONST_INDEX\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\n#else\n#define MAX_C CURVE_VALUE_COUNT\n#endif\nfloat evaluateCurveFrames(float time,vec4 keyframe0,vec4 keyframe1){float dt=keyframe1.x-keyframe0.x;float m0=keyframe0.w*dt;float m1=keyframe1.z*dt;float t=(time-keyframe0.x)/dt;float t2=t*t;float t3=t2*t;return dot(vec4(dot(vec3(2.,-3.,1.),vec3(t3,t2,1.)),dot(vec3(1,-2.,1),vec3(t3,t2,t)),t3-t2,dot(vec2(-2,3),vec2(t3,t2))),vec4(keyframe0.y,m0,m1,keyframe1.y));}float valueFromCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){\n#ifdef NONE_CONST_INDEX\nif(i==count){return lookup_curve(count).y;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);\n#else\nif(i<start){continue;}vec4 k0=lookup_curve(i);vec4 k1=lookup_curve(i+1);if(i==end){return k0.y;}\n#endif\nif(time>=k0.x&&time<=k1.x){return evaluateCurveFrames(time,k0,k1);}}return lookup_curve(0).y;}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){\n#ifdef NONE_CONST_INDEX\nif(i>count){return lookup_curve(i).w;}\n#else\nif(i<start){continue;}if(i>end){return lookup_curve(i-2).w;}\n#endif\n#ifdef NONE_CONST_INDEX\nvec4 seg=lookup_curve(i+start);\n#else\nvec4 seg=lookup_curve(i);\n#endif\nvec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}\n#ifdef NONE_CONST_INDEX\nvec2 p2=lookup_curve(i+start+1).xy;\n#else\nvec2 p2=lookup_curve(i+1).xy;\n#endif\nif(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}else if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==2.){return valueFromCurveFrames(time,floor(value.y),floor(1./fract(value.y)+0.5))*value.w+value.z;}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){\n#ifdef SHADER_VERTEX\nfloat seed=aSeed;\n#else\nfloat seed=vSeed;\n#endif\nreturn mix(value.y,value.z,seed);}return 0.;}in vec4 aPos;in vec3 aDir;in vec3 aInfo;in vec4 aColor;in float aTime;\n#ifdef ATTR_TRAIL_START\nin float aTrailStart;\n#else\nuniform float uTrailStart[64];in float aTrailStartIndex;\n#endif\nuniform mat4 effects_MatrixInvV;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixVP;uniform vec4 uTextureMap;uniform float uTime;uniform vec4 uParams;uniform vec4 uColorParams;uniform vec4 uOpacityOverLifetimeValue;uniform vec4 uWidthOverTrail;\n#ifdef COLOR_OVER_TRAIL\nuniform sampler2D uColorOverTrail;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\nout float vLife;out vec2 vTexCoord;out vec4 vColor;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 _pa=effects_MatrixVP*vec4(aPos.xyz,1.);vec4 _pb=effects_MatrixVP*vec4(aPos.xyz+aDir,1.);vec2 dir=normalize(_pb.xy/_pb.w-_pa.xy/_pa.w);vec2 screen_xy=vec2(-dir.y,dir.x);vec4 pos=effects_ObjectToWorld*vec4(aPos.xyz,1.);\n#ifdef ATTR_TRAIL_START\nfloat ts=aTrailStart;\n#else\nfloat ts=uTrailStart[int(aTrailStartIndex)];\n#endif\nfloat trail=(ts-aInfo.y)/uParams.y;float width=aPos.w*getValueFromTime(trail,uWidthOverTrail)/max(abs(screen_xy.x),abs(screen_xy.y));pos.xyz+=(effects_MatrixInvV[0].xyz*screen_xy.x+effects_MatrixInvV[1].xyz*screen_xy.y)*width;float time=min((uTime-aTime)/aInfo.x,1.0);gl_Position=effects_MatrixVP*pos;vColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(time,0.));\n#endif\n#endif\n#ifdef COLOR_OVER_TRAIL\nvColor*=texture2D(uColorOverTrail,vec2(trail,0.));\n#endif\nvColor.a*=clamp(getValueFromTime(time,uOpacityOverLifetimeValue),0.,1.);vLife=time;vTexCoord=uTextureMap.xy+vec2(trail,aInfo.z)*uTextureMap.zw;vSeed=aSeed;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
12146
+ var trailVert = "#version 300 es\nprecision mediump float;\n#define SHADER_VERTEX 1\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<12;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}in vec4 aPos;in vec3 aDir;in vec3 aInfo;in vec4 aColor;in float aTime;\n#ifdef ATTR_TRAIL_START\nin float aTrailStart;\n#else\nuniform float uTrailStart[64];in float aTrailStartIndex;\n#endif\nuniform mat4 effects_MatrixInvV;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixVP;uniform vec4 uTextureMap;uniform float uTime;uniform vec4 uParams;uniform vec4 uColorParams;uniform vec4 uOpacityOverLifetimeValue;uniform vec4 uWidthOverTrail;\n#ifdef COLOR_OVER_TRAIL\nuniform sampler2D uColorOverTrail;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\nout float vLife;out vec2 vTexCoord;out vec4 vColor;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 _pa=effects_MatrixVP*vec4(aPos.xyz,1.);vec4 _pb=effects_MatrixVP*vec4(aPos.xyz+aDir,1.);vec2 dir=normalize(_pb.xy/_pb.w-_pa.xy/_pa.w);vec2 screen_xy=vec2(-dir.y,dir.x);vec4 pos=effects_ObjectToWorld*vec4(aPos.xyz,1.);\n#ifdef ATTR_TRAIL_START\nfloat ts=aTrailStart;\n#else\nfloat ts=uTrailStart[int(aTrailStartIndex)];\n#endif\nfloat trail=(ts-aInfo.y)/uParams.y;float width=aPos.w*getValueFromTime(trail,uWidthOverTrail)/max(abs(screen_xy.x),abs(screen_xy.y));pos.xyz+=(effects_MatrixInvV[0].xyz*screen_xy.x+effects_MatrixInvV[1].xyz*screen_xy.y)*width;float time=min((uTime-aTime)/aInfo.x,1.0);gl_Position=effects_MatrixVP*pos;vColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(time,0.));\n#endif\n#endif\n#ifdef COLOR_OVER_TRAIL\nvColor*=texture2D(uColorOverTrail,vec2(trail,0.));\n#endif\nvColor.a*=clamp(getValueFromTime(time,uOpacityOverLifetimeValue),0.,1.);vLife=time;vTexCoord=uTextureMap.xy+vec2(trail,aInfo.z)*uTextureMap.zw;vSeed=aSeed;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
11706
12147
 
11707
- var value = "#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#define NONE_CONST_INDEX 1\n#else\n#if LOOKUP_TEXTURE_CURVE\n#define NONE_CONST_INDEX 1\n#endif\n#endif\n#ifdef NONE_CONST_INDEX\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\n#else\n#define MAX_C CURVE_VALUE_COUNT\n#endif\nfloat evaluateCurveFrames(float time,vec4 keyframe0,vec4 keyframe1){float dt=keyframe1.x-keyframe0.x;float m0=keyframe0.w*dt;float m1=keyframe1.z*dt;float t=(time-keyframe0.x)/dt;float t2=t*t;float t3=t2*t;return dot(vec4(dot(vec3(2.,-3.,1.),vec3(t3,t2,1.)),dot(vec3(1,-2.,1),vec3(t3,t2,t)),t3-t2,dot(vec2(-2,3),vec2(t3,t2))),vec4(keyframe0.y,m0,m1,keyframe1.y));}float valueFromCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){\n#ifdef NONE_CONST_INDEX\nif(i==count){return lookup_curve(count).y;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);\n#else\nif(i<start){continue;}vec4 k0=lookup_curve(i);vec4 k1=lookup_curve(i+1);if(i==end){return k0.y;}\n#endif\nif(time>=k0.x&&time<=k1.x){return evaluateCurveFrames(time,k0,k1);}}return lookup_curve(0).y;}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){\n#ifdef NONE_CONST_INDEX\nif(i>count){return lookup_curve(i).w;}\n#else\nif(i<start){continue;}if(i>end){return lookup_curve(i-2).w;}\n#endif\n#ifdef NONE_CONST_INDEX\nvec4 seg=lookup_curve(i+start);\n#else\nvec4 seg=lookup_curve(i);\n#endif\nvec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}\n#ifdef NONE_CONST_INDEX\nvec2 p2=lookup_curve(i+start+1).xy;\n#else\nvec2 p2=lookup_curve(i+1).xy;\n#endif\nif(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}else if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==2.){return valueFromCurveFrames(time,floor(value.y),floor(1./fract(value.y)+0.5))*value.w+value.z;}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){\n#ifdef SHADER_VERTEX\nfloat seed=aSeed;\n#else\nfloat seed=vSeed;\n#endif\nreturn mix(value.y,value.z,seed);}return 0.;}";
12148
+ var value = "#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<12;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}";
11708
12149
 
11709
12150
  var valueDefine = "#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n";
11710
12151
 
@@ -13268,16 +13709,16 @@ var InteractVFXItem = /** @class */ (function (_super) {
13268
13709
  var nx = position[0] - width;
13269
13710
  var ny = position[1] - height;
13270
13711
  if (options.dxRange) {
13271
- var _d = __read$3(options.dxRange, 2), min_1 = _d[0], max_1 = _d[1];
13272
- nx = clamp$1(nx, min_1, max_1);
13273
- if (nx !== min_1 && nx !== max_1 && min_1 !== max_1) {
13712
+ var _d = __read$3(options.dxRange, 2), min = _d[0], max = _d[1];
13713
+ nx = clamp$1(nx, min, max);
13714
+ if (nx !== min && nx !== max && min !== max) {
13274
13715
  (_a = event.origin) === null || _a === void 0 ? void 0 : _a.preventDefault();
13275
13716
  }
13276
13717
  }
13277
13718
  if (options.dyRange) {
13278
- var _e = __read$3(options.dyRange, 2), min_2 = _e[0], max_2 = _e[1];
13279
- ny = clamp$1(ny, min_2, max_2);
13280
- if (ny !== min_2 && ny !== max_2 && min_2 !== max_2) {
13719
+ var _e = __read$3(options.dyRange, 2), min = _e[0], max = _e[1];
13720
+ ny = clamp$1(ny, min, max);
13721
+ if (ny !== min && ny !== max && min !== max) {
13281
13722
  (_b = event.origin) === null || _b === void 0 ? void 0 : _b.preventDefault();
13282
13723
  }
13283
13724
  }
@@ -13391,11 +13832,11 @@ var SpriteMesh = /** @class */ (function () {
13391
13832
  var item = items[i];
13392
13833
  var texture = item === null || item === void 0 ? void 0 : item.renderer.texture;
13393
13834
  var textureIndex = texture ? textures.indexOf(texture) : -1;
13394
- var data_1 = this.getItemInitData(item, i, pointCount, textureIndex);
13395
- aPointLen += data_1.aPoint.length;
13396
- indexLen += data_1.index.length;
13397
- datas.push(data_1);
13398
- pointCount += data_1.aPoint.length / 6;
13835
+ var data = this.getItemInitData(item, i, pointCount, textureIndex);
13836
+ aPointLen += data.aPoint.length;
13837
+ indexLen += data.index.length;
13838
+ datas.push(data);
13839
+ pointCount += data.aPoint.length / 6;
13399
13840
  this.updateItem(item, true);
13400
13841
  }
13401
13842
  var bundle = {
@@ -13407,10 +13848,10 @@ var SpriteMesh = /** @class */ (function () {
13407
13848
  index: 0,
13408
13849
  };
13409
13850
  var _loop_1 = function (i) {
13410
- var data_2 = datas[i];
13851
+ var data = datas[i];
13411
13852
  Object.keys(bundle).forEach(function (name) {
13412
13853
  var arr = bundle[name];
13413
- var ta = data_2[name];
13854
+ var ta = data[name];
13414
13855
  arr.set(ta, cursor[name]);
13415
13856
  cursor[name] += ta.length;
13416
13857
  });
@@ -13677,14 +14118,14 @@ var SpriteMesh = /** @class */ (function () {
13677
14118
  for (var y = 0; y < row; y++) {
13678
14119
  var base = (y * 2 + x) * 4;
13679
14120
  // @ts-expect-error
13680
- var split_1 = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y * 2 + x];
13681
- var texOffset = split_1[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
14121
+ var split = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y * 2 + x];
14122
+ var texOffset = split[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
13682
14123
  var dw = ((x + x + 1) / col - 1) / 2;
13683
14124
  var dh = ((y + y + 1) / row - 1) / 2;
13684
- var tox = split_1[0];
13685
- var toy = split_1[1];
13686
- var tsx = split_1[4] ? split_1[3] : split_1[2];
13687
- var tsy = split_1[4] ? split_1[2] : split_1[3];
14125
+ var tox = split[0];
14126
+ var toy = split[1];
14127
+ var tsx = split[4] ? split[3] : split[2];
14128
+ var tsy = split[4] ? split[2] : split[3];
13688
14129
  var origin_1 = [
13689
14130
  originData[0] / col + dw,
13690
14131
  originData[1] / row + dh,
@@ -13781,13 +14222,13 @@ function generateFeatureTexture(engine, feather) {
13781
14222
  }
13782
14223
  else {
13783
14224
  var len = 128;
13784
- var data_3 = new Uint8Array(len);
14225
+ var data = new Uint8Array(len);
13785
14226
  for (var i = 0, s = len - 1; i < len; i++) {
13786
14227
  var p = i / s;
13787
14228
  var val = feather.getValue(p);
13788
- data_3[i] = Math.round(val * 255);
14229
+ data[i] = Math.round(val * 255);
13789
14230
  }
13790
- tex = Texture.createWithData(engine, { width: len, height: 1, data: data_3 }, {
14231
+ tex = Texture.createWithData(engine, { width: len, height: 1, data: data }, {
13791
14232
  name: 'feather',
13792
14233
  format: glContext.LUMINANCE,
13793
14234
  minFilter: glContext.LINEAR,
@@ -13945,22 +14386,22 @@ var SpriteGroup = /** @class */ (function () {
13945
14386
  * 需要则添加到meshToModify数组
13946
14387
  */
13947
14388
  for (var i = 0; i < splits.length; i++) {
13948
- var split_1 = splits[i];
14389
+ var split = splits[i];
13949
14390
  // @ts-expect-error
13950
- var spriteMesh = split_1.spriteMesh;
13951
- if (split_1.items.length === 0) {
14391
+ var spriteMesh = split.spriteMesh;
14392
+ if (split.items.length === 0) {
13952
14393
  throw new Error('split not combined');
13953
14394
  }
13954
- if (split_1.dirty) {
13955
- var priority = split_1.indexStart;
14395
+ if (split.dirty) {
14396
+ var priority = split.indexStart;
13956
14397
  if (spriteMesh.mesh.priority !== priority) {
13957
14398
  spriteMesh.mesh.priority = priority;
13958
14399
  meshToModify.push(spriteMesh.mesh);
13959
14400
  }
13960
- spriteMesh.setItems(split_1.items.map(function (item) { return item.content; }));
14401
+ spriteMesh.setItems(split.items.map(function (item) { return item.content; }));
13961
14402
  }
13962
14403
  spriteMesh.applyChange();
13963
- split_1.dirty = false;
14404
+ split.dirty = false;
13964
14405
  }
13965
14406
  /**
13966
14407
  * 有需要移除的meshSplit 则废弃对应的mesh 保留material
@@ -13968,8 +14409,8 @@ var SpriteGroup = /** @class */ (function () {
13968
14409
  */
13969
14410
  if (splitsToRemove.length) {
13970
14411
  for (var i = 0; i < splitsToRemove.length; i++) {
13971
- var split_2 = splitsToRemove[i];
13972
- var sp = split_2.spriteMesh;
14412
+ var split = splitsToRemove[i];
14413
+ var sp = split.spriteMesh;
13973
14414
  // @ts-expect-error
13974
14415
  var mesh = sp.mesh;
13975
14416
  mesh.dispose({ material: { textures: DestroyOptions.keep } });
@@ -14086,7 +14527,7 @@ var SpriteGroup = /** @class */ (function () {
14086
14527
  addItemWithOrder(items, item, itemSortProperty);
14087
14528
  if (isSprite(item)) {
14088
14529
  var content = item.createContent();
14089
- var split_4 = {
14530
+ var split = {
14090
14531
  indexStart: item.listIndex,
14091
14532
  indexEnd: item.listIndex,
14092
14533
  items: [item],
@@ -14094,21 +14535,21 @@ var SpriteGroup = /** @class */ (function () {
14094
14535
  cacheId: content.renderInfo.cacheId,
14095
14536
  textures: [item.content.renderer.texture],
14096
14537
  };
14097
- splits.unshift(split_4);
14098
- return [split_4];
14538
+ splits.unshift(split);
14539
+ return [split];
14099
14540
  }
14100
14541
  return [];
14101
14542
  }
14102
14543
  var _loop_2 = function (i) {
14103
- var split_5 = splits[i];
14544
+ var split = splits[i];
14104
14545
  var listIndex = item.listIndex;
14105
14546
  if (isSprite(item)) {
14106
14547
  // @ts-expect-error
14107
- if (listIndex <= split_5.indexEnd) {
14548
+ if (listIndex <= split.indexEnd) {
14108
14549
  addItemWithOrder(items, item, itemSortProperty);
14109
14550
  var itemIndex_1 = items.indexOf(item);
14110
- var indexStart = Math.min(itemIndex_1, items.indexOf(split_5.items[0]));
14111
- var indexEnd = Math.max(itemIndex_1, items.indexOf(split_5.items[split_5.items.length - 1]));
14551
+ var indexStart = Math.min(itemIndex_1, items.indexOf(split.items[0]));
14552
+ var indexEnd = Math.max(itemIndex_1, items.indexOf(split.items[split.items.length - 1]));
14112
14553
  var neoSplits_1 = this_2.getMeshSplits(items, indexStart, indexEnd);
14113
14554
  var neoSplitIndex_1 = neoSplits_1.findIndex(function (split) { return split.items.includes(item); });
14114
14555
  if (neoSplits_1.length === 2) {
@@ -14116,14 +14557,14 @@ var SpriteGroup = /** @class */ (function () {
14116
14557
  //1 or 0
14117
14558
  Object.keys(neoSplits_1[1 - neoSplitIndex_1]).forEach(function (key) {
14118
14559
  // @ts-expect-error
14119
- split_5[key] = neoSplits_1[1 - neoSplitIndex_1][key];
14560
+ split[key] = neoSplits_1[1 - neoSplitIndex_1][key];
14120
14561
  });
14121
14562
  return { value: [neoSplits_1[neoSplitIndex_1]] };
14122
14563
  }
14123
14564
  else if (neoSplits_1.length === 3) {
14124
14565
  Object.keys(neoSplits_1[0]).forEach(function (key) {
14125
14566
  // @ts-expect-error
14126
- split_5[key] = neoSplits_1[0][key];
14567
+ split[key] = neoSplits_1[0][key];
14127
14568
  });
14128
14569
  splits.splice(i + 1, 0, neoSplits_1[1], neoSplits_1[2]);
14129
14570
  if (neoSplitIndex_1 !== 1) {
@@ -14137,25 +14578,25 @@ var SpriteGroup = /** @class */ (function () {
14137
14578
  //todo add case
14138
14579
  Object.keys(neoSplits_1[0]).forEach(function (key) {
14139
14580
  // @ts-expect-error
14140
- split_5[key] = neoSplits_1[0][key];
14581
+ split[key] = neoSplits_1[0][key];
14141
14582
  });
14142
14583
  return { value: [] };
14143
14584
  }
14144
14585
  }
14145
14586
  else {
14146
- if (listIndex < split_5.indexStart || listIndex === split_5.indexEnd) {
14587
+ if (listIndex < split.indexStart || listIndex === split.indexEnd) {
14147
14588
  addItemWithOrder(items, item, itemSortProperty);
14148
14589
  return { value: [] };
14149
14590
  // @ts-expect-error
14150
14591
  }
14151
- else if (listIndex < split_5.indexEnd) {
14592
+ else if (listIndex < split.indexEnd) {
14152
14593
  addItemWithOrder(items, item, itemSortProperty);
14153
- var lastItem = split_5.items[split_5.items.length - 1];
14594
+ var lastItem = split.items[split.items.length - 1];
14154
14595
  var endIndex = items.indexOf(lastItem);
14155
- var neoSplits_2 = this_2.getMeshSplits(items, items.indexOf(split_5.items[0]), endIndex);
14596
+ var neoSplits_2 = this_2.getMeshSplits(items, items.indexOf(split.items[0]), endIndex);
14156
14597
  Object.keys(neoSplits_2[0]).forEach(function (key) {
14157
14598
  // @ts-expect-error
14158
- split_5[key] = neoSplits_2[0][key];
14599
+ split[key] = neoSplits_2[0][key];
14159
14600
  });
14160
14601
  if (neoSplits_2.length === 2) {
14161
14602
  splits.splice(i + 1, 0, neoSplits_2[1]);
@@ -14216,10 +14657,10 @@ var SpriteGroup = /** @class */ (function () {
14216
14657
  * 遍历this.meshSplits,找到元素的listIndex在split的indexStart和indexEnd范围内的第一个meshSplit
14217
14658
  */
14218
14659
  for (var i = 0; i < splits.length; i++) {
14219
- var split_6 = splits[i];
14660
+ var split = splits[i];
14220
14661
  // @ts-expect-error
14221
- if (split_6.indexStart <= item.listIndex && split_6.indexEnd >= item.listIndex) {
14222
- targetSplit = split_6;
14662
+ if (split.indexStart <= item.listIndex && split.indexEnd >= item.listIndex) {
14663
+ targetSplit = split;
14223
14664
  targetSplitIndex = i;
14224
14665
  break;
14225
14666
  }
@@ -14329,8 +14770,8 @@ var SpriteGroup = /** @class */ (function () {
14329
14770
  // FIXME: 可选性
14330
14771
  var targetSplitIndex = void 0;
14331
14772
  for (var i = 0; i < splits.length; i++) {
14332
- var split_7 = splits[i];
14333
- if (split_7.items.includes(item)) {
14773
+ var split = splits[i];
14774
+ if (split.items.includes(item)) {
14334
14775
  targetSplitIndex = i;
14335
14776
  break;
14336
14777
  }
@@ -15140,819 +15581,146 @@ var FilterSpriteVFXItem = /** @class */ (function (_super) {
15140
15581
  return FilterSpriteVFXItem;
15141
15582
  }(SpriteVFXItem));
15142
15583
 
15143
- var ParticleMesh = /** @class */ (function () {
15144
- function ParticleMesh(props, rendererOptions) {
15145
- var _a, _b, _c, _d;
15146
- this.particleCount = 0;
15147
- var engine = rendererOptions.composition.getEngine();
15148
- var env = ((_a = engine.renderer) !== null && _a !== void 0 ? _a : {}).env;
15149
- var speedOverLifetime = props.speedOverLifetime, colorOverLifetime = props.colorOverLifetime, linearVelOverLifetime = props.linearVelOverLifetime, orbitalVelOverLifetime = props.orbitalVelOverLifetime, sizeOverLifetime = props.sizeOverLifetime, rotationOverLifetime = props.rotationOverLifetime, sprite = props.sprite, gravityModifier = props.gravityModifier, maxCount = props.maxCount, duration = props.duration, textureFlip = props.textureFlip, useSprite = props.useSprite, name = props.name, filter = props.filter, gravity = props.gravity, forceTarget = props.forceTarget, side = props.side, occlusion = props.occlusion, anchor = props.anchor, blending = props.blending, maskMode = props.maskMode, mask = props.mask, transparentOcclusion = props.transparentOcclusion, listIndex = props.listIndex, meshSlots = props.meshSlots, _e = props.renderMode, renderMode = _e === void 0 ? 0 : _e, _f = props.diffuse, diffuse = _f === void 0 ? Texture.createWithData(engine) : _f;
15150
- var detail = engine.gpuCapability.detail;
15151
- var halfFloatTexture = detail.halfFloatTexture, maxVertexUniforms = detail.maxVertexUniforms;
15152
- var marcos = [
15153
- ['RENDER_MODE', +renderMode],
15154
- ['PRE_MULTIPLY_ALPHA', false],
15155
- ['ENV_EDITOR', env === PLAYER_OPTIONS_ENV_EDITOR],
15156
- ];
15157
- var level = engine.gpuCapability.level;
15158
- var vertexKeyFrameMeta = createKeyFrameMeta();
15159
- var fragmentKeyFrameMeta = createKeyFrameMeta();
15160
- var enableVertexTexture = maxVertexUniforms > 0;
15161
- var uniformValues = {};
15162
- var vertex_lookup_texture = 0;
15163
- var shaderCacheId = 0;
15164
- var particleDefine;
15165
- var useOrbitalVel;
15166
- this.useSprite = useSprite;
15167
- if (enableVertexTexture) {
15168
- marcos.push(['ENABLE_VERTEX_TEXTURE', true]);
15169
- }
15170
- if (speedOverLifetime) {
15171
- marcos.push(['SPEED_OVER_LIFETIME', true]);
15172
- shaderCacheId |= 1 << 1;
15173
- uniformValues.uSpeedLifetimeValue = speedOverLifetime.toUniform(vertexKeyFrameMeta);
15174
- }
15175
- if (sprite === null || sprite === void 0 ? void 0 : sprite.animate) {
15176
- marcos.push(['USE_SPRITE', true]);
15177
- shaderCacheId |= 1 << 2;
15178
- uniformValues.uFSprite = uniformValues.uSprite = new Float32Array([sprite.col, sprite.row, sprite.total, sprite.blend ? 1 : 0]);
15179
- this.useSprite = true;
15180
- }
15181
- if (filter && filter.name !== FILTER_NAME_NONE) {
15182
- marcos.push(['USE_FILTER', true]);
15183
- shaderCacheId |= 1 << 3;
15184
- var filterDefine = createFilter(filter, rendererOptions.composition);
15185
- if (!filterDefine.particle) {
15186
- throw new Error("particle filter ".concat(filter.name, " not implement"));
15187
- }
15188
- particleDefine = filterDefine.particle;
15189
- Object.keys((_b = particleDefine.uniforms) !== null && _b !== void 0 ? _b : {}).forEach(function (uName) {
15190
- var _a;
15191
- var getter = (_a = particleDefine.uniforms) === null || _a === void 0 ? void 0 : _a[uName];
15192
- if (uniformValues[uName]) {
15193
- throw new Error('conflict uniform name:' + uName);
15194
- }
15195
- uniformValues[uName] = getter === null || getter === void 0 ? void 0 : getter.toUniform(vertexKeyFrameMeta);
15196
- });
15197
- Object.keys((_c = particleDefine.uniformValues) !== null && _c !== void 0 ? _c : {}).forEach(function (uName) {
15198
- var _a;
15199
- var val = (_a = particleDefine.uniformValues) === null || _a === void 0 ? void 0 : _a[uName];
15200
- if (uniformValues[uName]) {
15201
- throw new Error('conflict uniform name:' + uName);
15584
+ var LinkNode = /** @class */ (function () {
15585
+ function LinkNode(content) {
15586
+ this.content = content;
15587
+ }
15588
+ return LinkNode;
15589
+ }());
15590
+ var Link = /** @class */ (function () {
15591
+ function Link(sort) {
15592
+ this.sort = sort;
15593
+ this.length = 0;
15594
+ }
15595
+ Link.prototype.findNodeByContent = function (filter) {
15596
+ var node = this.first;
15597
+ if (node) {
15598
+ do {
15599
+ if (filter(node.content)) {
15600
+ return node;
15202
15601
  }
15203
- uniformValues[uName] = val;
15204
- });
15205
- }
15206
- if (colorOverLifetime === null || colorOverLifetime === void 0 ? void 0 : colorOverLifetime.color) {
15207
- marcos.push(['COLOR_OVER_LIFETIME', true]);
15208
- shaderCacheId |= 1 << 4;
15209
- uniformValues.uColorOverLifetime = colorOverLifetime.color instanceof Texture ? colorOverLifetime.color : Texture.createWithData(engine, imageDataFromGradient(colorOverLifetime.color));
15602
+ // @ts-expect-error
15603
+ // eslint-disable-next-line no-cond-assign
15604
+ } while (node = node.next);
15210
15605
  }
15211
- if (colorOverLifetime === null || colorOverLifetime === void 0 ? void 0 : colorOverLifetime.opacity) {
15212
- uniformValues.uOpacityOverLifetimeValue = colorOverLifetime.opacity.toUniform(vertexKeyFrameMeta);
15606
+ };
15607
+ Link.prototype.insertNode = function (a, next) {
15608
+ var b = a.next;
15609
+ a.next = next;
15610
+ next.pre = a;
15611
+ next.next = b;
15612
+ if (b) {
15613
+ b.pre = next;
15213
15614
  }
15214
- else {
15215
- uniformValues.uOpacityOverLifetimeValue = createValueGetter(1).toUniform(vertexKeyFrameMeta);
15615
+ // a -> next -> b
15616
+ };
15617
+ Link.prototype.shiftNode = function (content) {
15618
+ var node = new LinkNode(content);
15619
+ this.length++;
15620
+ if (this.length === 1) {
15621
+ return this.first = this.last = node;
15216
15622
  }
15217
- ['x', 'y', 'z'].forEach(function (pro, i) {
15218
- var defL = 0;
15219
- var defO = 0;
15220
- if (linearVelOverLifetime === null || linearVelOverLifetime === void 0 ? void 0 : linearVelOverLifetime[pro]) {
15221
- uniformValues["uLinear".concat(pro.toUpperCase(), "ByLifetimeValue")] = linearVelOverLifetime[pro].toUniform(vertexKeyFrameMeta);
15222
- defL = 1;
15223
- shaderCacheId |= 1 << (7 + i);
15224
- linearVelOverLifetime.enabled = true;
15225
- }
15226
- marcos.push(["LINEAR_VEL_".concat(pro.toUpperCase()), defL]);
15227
- if (orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime[pro]) {
15228
- uniformValues["uOrb".concat(pro.toUpperCase(), "ByLifetimeValue")] = orbitalVelOverLifetime[pro].toUniform(vertexKeyFrameMeta);
15229
- defO = 1;
15230
- shaderCacheId |= 1 << (10 + i);
15231
- useOrbitalVel = true;
15232
- orbitalVelOverLifetime.enabled = true;
15623
+ var current = this.first;
15624
+ while (current) {
15625
+ if (this.sort(current.content, node.content) <= 0) {
15626
+ if (current.next) {
15627
+ current = current.next;
15628
+ }
15629
+ else {
15630
+ this.insertNode(current, node);
15631
+ return this.last = node;
15632
+ }
15233
15633
  }
15234
- marcos.push(["ORB_VEL_".concat(pro.toUpperCase()), defO]);
15235
- });
15236
- if (linearVelOverLifetime === null || linearVelOverLifetime === void 0 ? void 0 : linearVelOverLifetime.asMovement) {
15237
- marcos.push(['AS_LINEAR_MOVEMENT', true]);
15238
- shaderCacheId |= 1 << 5;
15239
- }
15240
- if (useOrbitalVel) {
15241
- if (orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime.asRotation) {
15242
- marcos.push(['AS_ORBITAL_MOVEMENT', true]);
15243
- shaderCacheId |= 1 << 6;
15634
+ else {
15635
+ if (current.pre) {
15636
+ this.insertNode(current.pre, node);
15637
+ }
15638
+ else {
15639
+ this.first = node;
15640
+ node.next = current;
15641
+ current.pre = node;
15642
+ }
15643
+ return node;
15244
15644
  }
15245
- uniformValues.uOrbCenter = new Float32Array((orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime.center) || [0, 0, 0]);
15246
- }
15247
- uniformValues.uSizeByLifetimeValue = sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.x.toUniform(vertexKeyFrameMeta);
15248
- if (sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.separateAxes) {
15249
- marcos.push(['SIZE_Y_BY_LIFE', 1]);
15250
- shaderCacheId |= 1 << 14;
15251
- uniformValues.uSizeYByLifetimeValue = (_d = sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.y) === null || _d === void 0 ? void 0 : _d.toUniform(vertexKeyFrameMeta);
15252
- }
15253
- if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.z) {
15254
- uniformValues.uRZByLifeTimeValue = rotationOverLifetime.z.toUniform(vertexKeyFrameMeta);
15255
- shaderCacheId |= 1 << 15;
15256
- marcos.push(['ROT_Z_LIFETIME', 1]);
15257
- }
15258
- if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.x) {
15259
- uniformValues.uRXByLifeTimeValue = rotationOverLifetime.x.toUniform(vertexKeyFrameMeta);
15260
- shaderCacheId |= 1 << 16;
15261
- marcos.push(['ROT_X_LIFETIME', 1]);
15262
15645
  }
15263
- if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.y) {
15264
- uniformValues.uRYByLifeTimeValue = rotationOverLifetime.y.toUniform(vertexKeyFrameMeta);
15265
- shaderCacheId |= 1 << 17;
15266
- marcos.push(['ROT_Y_LIFETIME', 1]);
15267
- }
15268
- if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.asRotation) {
15269
- marcos.push(['ROT_LIFETIME_AS_MOVEMENT', 1]);
15270
- shaderCacheId |= 1 << 18;
15271
- }
15272
- uniformValues.uGravityModifierValue = gravityModifier.toUniform(vertexKeyFrameMeta);
15273
- if (forceTarget) {
15274
- marcos.push(['FINAL_TARGET', true]);
15275
- shaderCacheId |= 1 << 19;
15276
- uniformValues.uFinalTarget = new Float32Array(forceTarget.target || [0, 0, 0]);
15277
- uniformValues.uForceCurve = forceTarget.curve.toUniform(vertexKeyFrameMeta);
15646
+ };
15647
+ Link.prototype.pushNode = function (content) {
15648
+ var node = new LinkNode(content);
15649
+ this.length++;
15650
+ if (this.length === 1) {
15651
+ return this.last = this.first = node;
15278
15652
  }
15279
- if (halfFloatTexture && fragmentKeyFrameMeta.max) {
15280
- shaderCacheId |= 1 << 20;
15281
- uniformValues.uFCurveValueTexture = generateHalfFloatTexture(engine, CurveValue.getAllData(fragmentKeyFrameMeta, true), fragmentKeyFrameMeta.index, 1);
15653
+ var current = this.last;
15654
+ while (current) {
15655
+ if (this.sort(node.content, current.content) <= 0) {
15656
+ if (this.first === current) {
15657
+ current.pre = node;
15658
+ node.next = current;
15659
+ return this.first = node;
15660
+ }
15661
+ else {
15662
+ // @ts-expect-error
15663
+ current = current.pre;
15664
+ }
15665
+ }
15666
+ else {
15667
+ this.insertNode(current, node);
15668
+ if (current === this.last) {
15669
+ this.last = node;
15670
+ }
15671
+ return node;
15672
+ }
15282
15673
  }
15283
- else {
15284
- uniformValues.uFCurveValues = CurveValue.getAllData(fragmentKeyFrameMeta);
15674
+ };
15675
+ Link.prototype.removeNode = function (node) {
15676
+ var current = this.first;
15677
+ this.length--;
15678
+ if (current === node) {
15679
+ // @ts-expect-error
15680
+ var a = this.first = current.next;
15681
+ if (a) {
15682
+ a.pre = null;
15683
+ }
15285
15684
  }
15286
- var vertexCurveTexture = vertexKeyFrameMeta.max + vertexKeyFrameMeta.curves.length - 32 > maxVertexUniforms;
15287
- // if (getConfig(RENDER_PREFER_LOOKUP_TEXTURE)) {
15288
- // vertexCurveTexture = true;
15289
- // }
15290
- if (level === 2) {
15291
- vertexKeyFrameMeta.max = -1;
15292
- vertexKeyFrameMeta.index = meshSlots ? meshSlots[0] : getSlot(vertexKeyFrameMeta.index);
15293
- if (fragmentKeyFrameMeta.index > 0) {
15294
- fragmentKeyFrameMeta.max = -1;
15295
- fragmentKeyFrameMeta.index = meshSlots ? meshSlots[1] : getSlot(fragmentKeyFrameMeta.index);
15685
+ else if ((current = this.last) === node) {
15686
+ // @ts-expect-error
15687
+ var a = this.last = current.pre;
15688
+ if (a) {
15689
+ a.next = null;
15296
15690
  }
15297
15691
  }
15298
- if (vertexCurveTexture && halfFloatTexture && enableVertexTexture) {
15299
- var tex = generateHalfFloatTexture(engine, CurveValue.getAllData(vertexKeyFrameMeta, true), vertexKeyFrameMeta.index, 1);
15300
- uniformValues.uVCurveValueTexture = tex;
15301
- vertex_lookup_texture = 1;
15692
+ else if (node) {
15693
+ var pre = node.pre;
15694
+ var next = node.next;
15695
+ // @ts-expect-error
15696
+ pre.next = next;
15697
+ if (next) {
15698
+ next.pre = pre;
15699
+ }
15302
15700
  }
15303
- else {
15304
- uniformValues.uVCurveValues = CurveValue.getAllData(vertexKeyFrameMeta);
15701
+ node.pre = null;
15702
+ node.next = null;
15703
+ };
15704
+ Link.prototype.forEach = function (func, thisObj) {
15705
+ var node = this.first;
15706
+ var i = 0;
15707
+ if (node) {
15708
+ do {
15709
+ func.call(thisObj || this, node.content, i++);
15710
+ // @ts-expect-error
15711
+ // eslint-disable-next-line no-cond-assign
15712
+ } while (node = node.next);
15305
15713
  }
15306
- var shaderCache = ['-p:', renderMode, shaderCacheId, vertexKeyFrameMeta.index, vertexKeyFrameMeta.max, fragmentKeyFrameMeta.index, fragmentKeyFrameMeta.max].join('+');
15307
- marcos.push(['VERT_CURVE_VALUE_COUNT', vertexKeyFrameMeta.index], ['FRAG_CURVE_VALUE_COUNT', fragmentKeyFrameMeta.index], ['VERT_MAX_KEY_FRAME_COUNT', vertexKeyFrameMeta.max], ['FRAG_MAX_KEY_FRAME_COUNT', fragmentKeyFrameMeta.max]);
15308
- var fragment = filter ? particleFrag.replace(/#pragma\s+FILTER_FRAG/, particleDefine.fragment) : particleFrag;
15309
- var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
15310
- var vertex = filter ? originalVertex.replace(/#pragma\s+FILTER_VERT/, particleDefine.vertex || 'void filterMain(float t){}\n') : originalVertex;
15311
- var shader = {
15312
- fragment: createShaderWithMarcos(marcos, fragment, ShaderType.fragment, level),
15313
- vertex: createShaderWithMarcos(marcos, vertex, ShaderType.vertex, level),
15314
- glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
15315
- shared: true,
15316
- cacheId: shaderCache,
15317
- marcos: marcos,
15318
- name: "particle#".concat(name),
15319
- };
15320
- if (filter) {
15321
- shader.cacheId += filter.name;
15322
- }
15323
- var mtlOptions = {
15324
- shader: shader,
15325
- uniformSemantics: {
15326
- effects_MatrixV: 'VIEW',
15327
- effects_MatrixVP: 'VIEWPROJECTION',
15328
- uEditorTransform: 'EDITOR_TRANSFORM',
15329
- effects_ObjectToWorld: 'MODEL',
15330
- },
15331
- };
15332
- var preMulAlpha = getPreMultiAlpha(blending);
15333
- uniformValues.uTexOffset = new Float32Array(diffuse ? [1 / diffuse.getWidth(), 1 / diffuse.getHeight()] : [0, 0]);
15334
- uniformValues.uMaskTex = diffuse;
15335
- uniformValues.uColorParams = new Float32Array([diffuse ? 1 : 0, +preMulAlpha, 0, +(!!occlusion && !transparentOcclusion)]);
15336
- uniformValues.uParams = [0, duration, 0, 0];
15337
- uniformValues.uAcceleration = [(gravity === null || gravity === void 0 ? void 0 : gravity[0]) || 0, (gravity === null || gravity === void 0 ? void 0 : gravity[1]) || 0, (gravity === null || gravity === void 0 ? void 0 : gravity[2]) || 0, 0];
15338
- // mtlOptions.uniformValues = uniformValues;
15339
- var material = Material.create(engine, mtlOptions);
15340
- material.blending = true;
15341
- material.depthTest = true;
15342
- material.depthMask = !!(occlusion);
15343
- material.stencilRef = mask ? [mask, mask] : undefined;
15344
- setMaskMode(material, maskMode);
15345
- setBlendMode(material, blending);
15346
- setSideMode(material, side);
15347
- var typeMap = {
15348
- 'uSprite': 'vec4',
15349
- 'uParams': 'vec4',
15350
- 'uAcceleration': 'vec4',
15351
- 'uGravityModifierValue': 'vec4',
15352
- 'uOpacityOverLifetimeValue': 'vec4',
15353
- 'uRXByLifeTimeValue': 'vec4',
15354
- 'uRYByLifeTimeValue': 'vec4',
15355
- 'uRZByLifeTimeValue': 'vec4',
15356
- 'uLinearXByLifetimeValue': 'vec4',
15357
- 'uLinearYByLifetimeValue': 'vec4',
15358
- 'uLinearZByLifetimeValue': 'vec4',
15359
- 'uSpeedLifetimeValue': 'vec4',
15360
- 'uOrbXByLifetimeValue': 'vec4',
15361
- 'uOrbYByLifetimeValue': 'vec4',
15362
- 'uOrbZByLifetimeValue': 'vec4',
15363
- 'uSizeByLifetimeValue': 'vec4',
15364
- 'uSizeYByLifetimeValue': 'vec4',
15365
- 'uColorParams': 'vec4',
15366
- 'uFSprite': 'vec4',
15367
- 'uPreviewColor': 'vec4',
15368
- 'uVCurveValues': 'vec4Array',
15369
- 'uFCurveValues': 'vec4',
15370
- 'uFinalTarget': 'vec3',
15371
- 'uForceCurve': 'vec4',
15372
- 'uOrbCenter': 'vec3',
15373
- 'uTexOffset': 'vec2',
15374
- 'uPeriodValue': 'vec4',
15375
- 'uMovementValue': 'vec4',
15376
- 'uStrengthValue': 'vec4',
15377
- 'uWaveParams': 'vec4',
15378
- };
15379
- Object.keys(uniformValues).map(function (name) {
15380
- var value = uniformValues[name];
15381
- if (value instanceof Texture) {
15382
- material.setTexture(name, value);
15383
- return;
15384
- }
15385
- var res = [];
15386
- switch (typeMap[name]) {
15387
- case 'vec4':
15388
- material.setVector4(name, Vector4.fromArray(value));
15389
- break;
15390
- case 'vec3':
15391
- material.setVector3(name, Vector3.fromArray(value));
15392
- break;
15393
- case 'vec2':
15394
- material.setVector2(name, Vector2.fromArray(value));
15395
- break;
15396
- case 'vec4Array':
15397
- for (var i = 0; i < value.length; i = i + 4) {
15398
- var v = new Vector4(value[i], value[i + 1], value[i + 2], value[i + 3]);
15399
- res.push(v);
15400
- }
15401
- material.setVector4Array(name, res);
15402
- res.length = 0;
15403
- break;
15404
- default:
15405
- console.warn("uniform ".concat(name, "'s type not in typeMap"));
15406
- }
15407
- });
15408
- material.setVector3('emissionColor', new Vector3(0, 0, 0));
15409
- material.setFloat('emissionIntensity', 0.0);
15410
- var geometry = Geometry.create(engine, generateGeometryProps(maxCount * 4, this.useSprite, "particle#".concat(name)));
15411
- var mesh = Mesh.create(engine, {
15412
- name: "MParticle_".concat(name),
15413
- priority: listIndex,
15414
- material: material,
15415
- geometry: geometry,
15416
- });
15417
- this.anchor = anchor;
15418
- this.mesh = mesh;
15419
- this.geometry = mesh.firstGeometry();
15420
- this.forceTarget = forceTarget;
15421
- this.sizeOverLifetime = sizeOverLifetime;
15422
- this.speedOverLifetime = speedOverLifetime;
15423
- this.linearVelOverLifetime = linearVelOverLifetime;
15424
- this.orbitalVelOverLifetime = orbitalVelOverLifetime;
15425
- this.orbitalVelOverLifetime = orbitalVelOverLifetime;
15426
- this.gravityModifier = gravityModifier;
15427
- this.maxCount = maxCount;
15428
- this.duration = duration;
15429
- this.textureOffsets = textureFlip ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
15430
- }
15431
- Object.defineProperty(ParticleMesh.prototype, "time", {
15432
- get: function () {
15433
- var value = this.mesh.material.getVector4('uParams');
15434
- return value.x;
15435
- },
15436
- set: function (v) {
15437
- this.mesh.material.setVector4('uParams', new Vector4(+v, this.duration, 0, 0));
15438
- },
15439
- enumerable: false,
15440
- configurable: true
15441
- });
15442
- ParticleMesh.prototype.getPointColor = function (index) {
15443
- var data = this.geometry.getAttributeData('aRot');
15444
- var i = index * 32 + 4;
15445
- return [data[i], data[i + 1], data[i + 2], data[i + 3]];
15446
- };
15447
- /**
15448
- * 待废弃
15449
- * @deprecated - 使用 `particle-system.getPointPosition` 替代
15450
- */
15451
- ParticleMesh.prototype.getPointPosition = function (index) {
15452
- var geo = this.geometry;
15453
- var posIndex = index * 48;
15454
- var posData = geo.getAttributeData('aPos');
15455
- var offsetData = geo.getAttributeData('aOffset');
15456
- var time = this.time - offsetData[index * 16 + 2];
15457
- var pointDur = offsetData[index * 16 + 3];
15458
- var mtl = this.mesh.material;
15459
- var acc = mtl.getVector4('uAcceleration').toVector3();
15460
- var pos = Vector3.fromArray(posData, posIndex);
15461
- var vel = Vector3.fromArray(posData, posIndex + 3);
15462
- var ret = calculateTranslation(new Vector3(), this, acc, time, pointDur, pos, vel);
15463
- if (this.forceTarget) {
15464
- var target = mtl.getVector3('uFinalTarget');
15465
- var life = this.forceTarget.curve.getValue(time / pointDur);
15466
- var dl = 1 - life;
15467
- ret.x = ret.x * dl + target.x * life;
15468
- ret.y = ret.y * dl + target.y * life;
15469
- ret.z = ret.z * dl + target.z * life;
15470
- }
15471
- return ret;
15472
- };
15473
- ParticleMesh.prototype.clearPoints = function () {
15474
- this.resetGeometryData(this.geometry);
15475
- this.particleCount = 0;
15476
- this.geometry.setDrawCount(0);
15477
- this.maxParticleBufferCount = 0;
15478
- };
15479
- ParticleMesh.prototype.resetGeometryData = function (geometry) {
15480
- var names = geometry.getAttributeNames();
15481
- var index = geometry.getIndexData();
15482
- for (var i = 0; i < names.length; i++) {
15483
- var name_1 = names[i];
15484
- var data_1 = geometry.getAttributeData(name_1);
15485
- if (data_1) {
15486
- // @ts-expect-error
15487
- geometry.setAttributeData(name_1, new data_1.constructor(0));
15488
- }
15489
- }
15490
- // @ts-expect-error
15491
- geometry.setIndexData(new index.constructor(0));
15492
- };
15493
- ParticleMesh.prototype.minusTime = function (time) {
15494
- var data = this.geometry.getAttributeData('aOffset');
15495
- for (var i = 0; i < data.length; i += 4) {
15496
- data[i + 2] -= time;
15497
- }
15498
- this.geometry.setAttributeData('aOffset', data);
15499
- this.time -= time;
15500
- };
15501
- ParticleMesh.prototype.removePoint = function (index) {
15502
- if (index < this.particleCount) {
15503
- this.geometry.setAttributeSubData('aOffset', index * 16, new Float32Array(16));
15504
- }
15505
- };
15506
- ParticleMesh.prototype.setPoint = function (point, index) {
15507
- var maxCount = this.maxCount;
15508
- if (index < maxCount) {
15509
- var particleCount = index + 1;
15510
- var vertexCount_1 = particleCount * 4;
15511
- var geometry_1 = this.geometry;
15512
- var increaseBuffer_1 = particleCount > this.maxParticleBufferCount;
15513
- var inc_1 = 1;
15514
- if (this.particleCount > 300) {
15515
- inc_1 = (this.particleCount + 100) / this.particleCount;
15516
- }
15517
- else if (this.particleCount > 100) {
15518
- inc_1 = 1.4;
15519
- }
15520
- else if (this.particleCount > 0) {
15521
- inc_1 = 2;
15522
- }
15523
- var pointData_1 = {
15524
- aPos: new Float32Array(48),
15525
- aRot: new Float32Array(32),
15526
- aOffset: new Float32Array(16),
15527
- };
15528
- var useSprite = this.useSprite;
15529
- if (useSprite) {
15530
- pointData_1.aSprite = new Float32Array(12);
15531
- }
15532
- var tempPos = new Vector3();
15533
- var tempQuat = new Quaternion();
15534
- var scale = new Vector3(1, 1, 1);
15535
- point.transform.assignWorldTRS(tempPos, tempQuat, scale);
15536
- var tempEuler = Transform.getRotation(tempQuat, new Euler());
15537
- var position = tempPos.toArray();
15538
- var rotation = tempEuler.toArray();
15539
- var offsets = this.textureOffsets;
15540
- var off = [0, 0, point.delay, point.lifetime];
15541
- var wholeUV = [0, 0, 1, 1];
15542
- var vel = point.vel;
15543
- var color = point.color;
15544
- var sizeOffsets = [-.5, .5, -.5, -.5, .5, .5, .5, -.5];
15545
- var seed = Math.random();
15546
- var sprite = void 0;
15547
- if (useSprite) {
15548
- sprite = point.sprite;
15549
- }
15550
- for (var j = 0; j < 4; j++) {
15551
- var offset = j * 2;
15552
- var j3 = j * 3;
15553
- var j4 = j * 4;
15554
- var j12 = j * 12;
15555
- var j8 = j * 8;
15556
- pointData_1.aPos.set(position, j12);
15557
- vel.fill(pointData_1.aPos, j12 + 3);
15558
- pointData_1.aRot.set(rotation, j8);
15559
- pointData_1.aRot[j8 + 3] = seed;
15560
- pointData_1.aRot.set(color, j8 + 4);
15561
- if (useSprite) {
15562
- // @ts-expect-error
15563
- pointData_1.aSprite.set(sprite, j3);
15564
- }
15565
- var uv = point.uv || wholeUV;
15566
- if (uv) {
15567
- var uvy = useSprite ? (1 - offsets[offset + 1]) : offsets[offset + 1];
15568
- off[0] = uv[0] + offsets[offset] * uv[2];
15569
- off[1] = uv[1] + uvy * uv[3];
15570
- }
15571
- pointData_1.aOffset.set(off, j4);
15572
- var ji = (j + j);
15573
- var sx = (sizeOffsets[ji] - this.anchor.x) * scale.x;
15574
- var sy = (sizeOffsets[ji + 1] - this.anchor.y) * scale.y;
15575
- for (var k = 0; k < 3; k++) {
15576
- pointData_1.aPos[j12 + 6 + k] = point.dirX.getElement(k) * sx;
15577
- pointData_1.aPos[j12 + 9 + k] = point.dirY.getElement(k) * sy;
15578
- }
15579
- }
15580
- var indexData = new Uint16Array([0, 1, 2, 2, 1, 3].map(function (x) { return x + index * 4; }));
15581
- if (increaseBuffer_1) {
15582
- var baseIndexData = geometry_1.getIndexData();
15583
- var idx = enlargeBuffer(baseIndexData, particleCount * 6, inc_1, maxCount * 6);
15584
- idx.set(indexData, index * 6);
15585
- geometry_1.setIndexData(idx);
15586
- this.maxParticleBufferCount = idx.length / 6;
15587
- }
15588
- else {
15589
- geometry_1.setIndexSubData(index * 6, indexData);
15590
- }
15591
- Object.keys(pointData_1).forEach(function (name) {
15592
- var data = pointData_1[name];
15593
- var attrSize = geometry_1.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
15594
- if (increaseBuffer_1) {
15595
- var baseData = geometry_1.getAttributeData(name);
15596
- var geoData = enlargeBuffer(baseData, vertexCount_1 * attrSize, inc_1, maxCount * 4 * attrSize);
15597
- geoData.set(data, data.length * index);
15598
- geometry_1.setAttributeData(name, geoData);
15599
- }
15600
- else {
15601
- geometry_1.setAttributeSubData(name, data.length * index, data);
15602
- }
15603
- });
15604
- this.particleCount = Math.max(particleCount, this.particleCount);
15605
- geometry_1.setDrawCount(this.particleCount * 6);
15606
- }
15607
- };
15608
- return ParticleMesh;
15609
- }());
15610
- var gl2UniformSlots = [10, 32, 64, 160];
15611
- function getSlot(count) {
15612
- for (var w = 0; w < gl2UniformSlots.length; w++) {
15613
- var slot = gl2UniformSlots[w];
15614
- if (slot > count) {
15615
- return slot;
15616
- }
15617
- }
15618
- return count || gl2UniformSlots[0];
15619
- }
15620
- function generateGeometryProps(maxVertex, useSprite, name) {
15621
- var bpe = Float32Array.BYTES_PER_ELEMENT;
15622
- var j12 = bpe * 12;
15623
- var attributes = {
15624
- aPos: { size: 3, offset: 0, stride: j12, data: new Float32Array(0) },
15625
- aVel: { size: 3, offset: 3 * bpe, stride: j12, dataSource: 'aPos' },
15626
- aDirX: { size: 3, offset: 6 * bpe, stride: j12, dataSource: 'aPos' },
15627
- aDirY: { size: 3, offset: 9 * bpe, stride: j12, dataSource: 'aPos' },
15628
- //
15629
- aRot: { size: 3, offset: 0, stride: 8 * bpe, data: new Float32Array(0) },
15630
- aSeed: { size: 1, offset: 3 * bpe, stride: 8 * bpe, dataSource: 'aRot' },
15631
- aColor: { size: 4, offset: 4 * bpe, stride: 8 * bpe, dataSource: 'aRot' },
15632
- //
15633
- aOffset: { size: 4, stride: 4 * bpe, data: new Float32Array(0) },
15634
- };
15635
- if (useSprite) {
15636
- attributes['aSprite'] = { size: 3, data: new Float32Array(0) };
15637
- }
15638
- return { attributes: attributes, indices: { data: new Uint16Array(0) }, name: name, maxVertex: maxVertex };
15639
- }
15640
- function getParticleMeshShader(item, env, gpuCapability) {
15641
- var _a, _b, _c, _d, _e;
15642
- if (env === void 0) { env = ''; }
15643
- var props = item.content;
15644
- var renderMode = +(((_a = props.renderer) === null || _a === void 0 ? void 0 : _a.renderMode) || 0);
15645
- var marcos = [
15646
- ['RENDER_MODE', renderMode],
15647
- ['PRE_MULTIPLY_ALPHA', false],
15648
- ['ENV_EDITOR', env === PLAYER_OPTIONS_ENV_EDITOR],
15649
- ];
15650
- var level = gpuCapability.level, detail = gpuCapability.detail;
15651
- var vertexKeyFrameMeta = createKeyFrameMeta();
15652
- var fragmentKeyFrameMeta = createKeyFrameMeta();
15653
- var enableVertexTexture = detail.maxVertexUniforms > 0;
15654
- var speedOverLifetime = ((_b = props.positionOverLifetime) !== null && _b !== void 0 ? _b : {}).speedOverLifetime;
15655
- var vertex_lookup_texture = 0;
15656
- var shaderCacheId = 0;
15657
- if (enableVertexTexture) {
15658
- marcos.push(['ENABLE_VERTEX_TEXTURE', true]);
15659
- }
15660
- if (speedOverLifetime) {
15661
- marcos.push(['SPEED_OVER_LIFETIME', true]);
15662
- shaderCacheId |= 1 << 1;
15663
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, speedOverLifetime);
15664
- }
15665
- var sprite = props.textureSheetAnimation;
15666
- if (sprite && sprite.animate) {
15667
- marcos.push(['USE_SPRITE', true]);
15668
- shaderCacheId |= 1 << 2;
15669
- }
15670
- var filter = undefined;
15671
- if (props.filter && props.filter.name !== FILTER_NAME_NONE) {
15672
- marcos.push(['USE_FILTER', true]);
15673
- shaderCacheId |= 1 << 3;
15674
- var f = createFilterShaders(props.filter).find(function (f) { return f.isParticle; });
15675
- if (!f) {
15676
- throw Error("particle filter ".concat(props.filter.name, " not implement"));
15677
- }
15678
- filter = f;
15679
- (_c = f.uniforms) === null || _c === void 0 ? void 0 : _c.forEach(function (val) { return getKeyFrameMetaByRawValue(vertexKeyFrameMeta, val); });
15680
- // filter = processFilter(props.filter, fragmentKeyFrameMeta, vertexKeyFrameMeta, options);
15681
- }
15682
- var colorOverLifetime = props.colorOverLifetime;
15683
- if (colorOverLifetime && colorOverLifetime.color) {
15684
- marcos.push(['COLOR_OVER_LIFETIME', true]);
15685
- shaderCacheId |= 1 << 4;
15686
- }
15687
- var opacity = colorOverLifetime && colorOverLifetime.opacity;
15688
- if (opacity) {
15689
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, opacity);
15690
- }
15691
- var positionOverLifetime = props.positionOverLifetime;
15692
- var useOrbitalVel;
15693
- ['x', 'y', 'z'].forEach(function (pro, i) {
15694
- var defL = 0;
15695
- var linearPro = 'linear' + pro.toUpperCase();
15696
- var orbitalPro = 'orbital' + pro.toUpperCase();
15697
- if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime[linearPro]) {
15698
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime[linearPro]);
15699
- defL = 1;
15700
- shaderCacheId |= 1 << (7 + i);
15701
- }
15702
- marcos.push(["LINEAR_VEL_".concat(pro.toUpperCase()), defL]);
15703
- var defO = 0;
15704
- if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime[orbitalPro]) {
15705
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime[orbitalPro]);
15706
- defO = 1;
15707
- shaderCacheId |= 1 << (10 + i);
15708
- useOrbitalVel = true;
15709
- }
15710
- marcos.push(["ORB_VEL_".concat(pro.toUpperCase()), defO]);
15711
- });
15712
- if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.asMovement) {
15713
- marcos.push(['AS_LINEAR_MOVEMENT', true]);
15714
- shaderCacheId |= 1 << 5;
15715
- }
15716
- if (useOrbitalVel) {
15717
- if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.asRotation) {
15718
- marcos.push(['AS_ORBITAL_MOVEMENT', true]);
15719
- shaderCacheId |= 1 << 6;
15720
- }
15721
- }
15722
- var sizeOverLifetime = props.sizeOverLifetime;
15723
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.x);
15724
- if (sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.separateAxes) {
15725
- marcos.push(['SIZE_Y_BY_LIFE', 1]);
15726
- shaderCacheId |= 1 << 14;
15727
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.y);
15728
- }
15729
- var rot = props.rotationOverLifetime;
15730
- if (rot === null || rot === void 0 ? void 0 : rot.z) {
15731
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot === null || rot === void 0 ? void 0 : rot.z);
15732
- shaderCacheId |= 1 << 15;
15733
- marcos.push(['ROT_Z_LIFETIME', 1]);
15734
- }
15735
- if (rot === null || rot === void 0 ? void 0 : rot.separateAxes) {
15736
- if (rot.x) {
15737
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.x);
15738
- shaderCacheId |= 1 << 16;
15739
- marcos.push(['ROT_X_LIFETIME', 1]);
15740
- }
15741
- if (rot.y) {
15742
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.y);
15743
- shaderCacheId |= 1 << 17;
15744
- marcos.push(['ROT_Y_LIFETIME', 1]);
15745
- }
15746
- }
15747
- if (rot === null || rot === void 0 ? void 0 : rot.asRotation) {
15748
- marcos.push(['ROT_LIFETIME_AS_MOVEMENT', 1]);
15749
- shaderCacheId |= 1 << 18;
15750
- }
15751
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravityOverLifetime);
15752
- var forceOpt = positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.forceTarget;
15753
- if (forceOpt) {
15754
- marcos.push(['FINAL_TARGET', true]);
15755
- shaderCacheId |= 1 << 19;
15756
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime.forceCurve);
15757
- }
15758
- var HALF_FLOAT = detail.halfFloatTexture;
15759
- if (HALF_FLOAT && fragmentKeyFrameMeta.max) {
15760
- shaderCacheId |= 1 << 20;
15761
- }
15762
- var maxVertexUniforms = detail.maxVertexUniforms;
15763
- var vertexCurveTexture = vertexKeyFrameMeta.max + vertexKeyFrameMeta.curves.length - 32 > maxVertexUniforms;
15764
- if (getConfig(RENDER_PREFER_LOOKUP_TEXTURE)) {
15765
- vertexCurveTexture = true;
15766
- }
15767
- if (level === 2) {
15768
- vertexKeyFrameMeta.max = -1;
15769
- // vertexKeyFrameMeta.index = getSlot(vertexKeyFrameMeta.index);
15770
- if (fragmentKeyFrameMeta.index > 0) {
15771
- fragmentKeyFrameMeta.max = -1;
15772
- // fragmentKeyFrameMeta.index = getSlot(fragmentKeyFrameMeta.index);
15773
- }
15774
- }
15775
- if (vertexCurveTexture && HALF_FLOAT && enableVertexTexture) {
15776
- vertex_lookup_texture = 1;
15777
- }
15778
- var shaderCache = ['-p:', renderMode, shaderCacheId, vertexKeyFrameMeta.index, vertexKeyFrameMeta.max, fragmentKeyFrameMeta.index, fragmentKeyFrameMeta.max].join('+');
15779
- var shader = {
15780
- fragment: particleFrag,
15781
- vertex: "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert),
15782
- shared: true,
15783
- cacheId: shaderCache,
15784
- marcos: marcos,
15785
- name: "particle#".concat(item.name),
15786
- };
15787
- if (filter) {
15788
- shader.fragment = shader.fragment.replace(/#pragma\s+FILTER_FRAG/, (_d = filter.fragment) !== null && _d !== void 0 ? _d : '');
15789
- shader.vertex = shader.vertex.replace(/#pragma\s+FILTER_VERT/, filter.vertex || 'void filterMain(float t){}\n');
15790
- shader.cacheId += '+' + ((_e = props.filter) === null || _e === void 0 ? void 0 : _e.name);
15791
- }
15792
- marcos.push(['VERT_CURVE_VALUE_COUNT', vertexKeyFrameMeta.index], ['FRAG_CURVE_VALUE_COUNT', fragmentKeyFrameMeta.index], ['VERT_MAX_KEY_FRAME_COUNT', vertexKeyFrameMeta.max], ['FRAG_MAX_KEY_FRAME_COUNT', fragmentKeyFrameMeta.max]);
15793
- return { shader: shader, vertex: vertexKeyFrameMeta.index, fragment: fragmentKeyFrameMeta.index };
15794
- }
15795
- function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
15796
- var _a;
15797
- var shaderIds = (_a = shader.cacheId) === null || _a === void 0 ? void 0 : _a.split('+');
15798
- shaderIds[3] = maxVertex;
15799
- shaderIds[5] = maxFrag;
15800
- shader.cacheId = shaderIds.join('+');
15801
- if (!shader.marcos) {
15802
- return;
15803
- }
15804
- for (var i = 0; i < shader.marcos.length; i++) {
15805
- var marco = shader.marcos[i];
15806
- if (marco[0] === 'VERT_CURVE_VALUE_COUNT') {
15807
- marco[1] = maxVertex;
15808
- }
15809
- else if (marco[0] === 'FRAG_CURVE_VALUE_COUNT') {
15810
- marco[1] = maxFrag;
15811
- break;
15812
- }
15813
- }
15814
- }
15815
-
15816
- var LinkNode = /** @class */ (function () {
15817
- function LinkNode(content) {
15818
- this.content = content;
15819
- }
15820
- return LinkNode;
15821
- }());
15822
- var Link = /** @class */ (function () {
15823
- function Link(sort) {
15824
- this.sort = sort;
15825
- this.length = 0;
15826
- }
15827
- Link.prototype.findNodeByContent = function (filter) {
15828
- var node = this.first;
15829
- if (node) {
15830
- do {
15831
- if (filter(node.content)) {
15832
- return node;
15833
- }
15834
- // @ts-expect-error
15835
- // eslint-disable-next-line no-cond-assign
15836
- } while (node = node.next);
15837
- }
15838
- };
15839
- Link.prototype.insertNode = function (a, next) {
15840
- var b = a.next;
15841
- a.next = next;
15842
- next.pre = a;
15843
- next.next = b;
15844
- if (b) {
15845
- b.pre = next;
15846
- }
15847
- // a -> next -> b
15848
- };
15849
- Link.prototype.shiftNode = function (content) {
15850
- var node = new LinkNode(content);
15851
- this.length++;
15852
- if (this.length === 1) {
15853
- return this.first = this.last = node;
15854
- }
15855
- var current = this.first;
15856
- while (current) {
15857
- if (this.sort(current.content, node.content) <= 0) {
15858
- if (current.next) {
15859
- current = current.next;
15860
- }
15861
- else {
15862
- this.insertNode(current, node);
15863
- return this.last = node;
15864
- }
15865
- }
15866
- else {
15867
- if (current.pre) {
15868
- this.insertNode(current.pre, node);
15869
- }
15870
- else {
15871
- this.first = node;
15872
- node.next = current;
15873
- current.pre = node;
15874
- }
15875
- return node;
15876
- }
15877
- }
15878
- };
15879
- Link.prototype.pushNode = function (content) {
15880
- var node = new LinkNode(content);
15881
- this.length++;
15882
- if (this.length === 1) {
15883
- return this.last = this.first = node;
15884
- }
15885
- var current = this.last;
15886
- while (current) {
15887
- if (this.sort(node.content, current.content) <= 0) {
15888
- if (this.first === current) {
15889
- current.pre = node;
15890
- node.next = current;
15891
- return this.first = node;
15892
- }
15893
- else {
15894
- // @ts-expect-error
15895
- current = current.pre;
15896
- }
15897
- }
15898
- else {
15899
- this.insertNode(current, node);
15900
- if (current === this.last) {
15901
- this.last = node;
15902
- }
15903
- return node;
15904
- }
15905
- }
15906
- };
15907
- Link.prototype.removeNode = function (node) {
15908
- var current = this.first;
15909
- this.length--;
15910
- if (current === node) {
15911
- // @ts-expect-error
15912
- var a = this.first = current.next;
15913
- if (a) {
15914
- a.pre = null;
15915
- }
15916
- }
15917
- else if ((current = this.last) === node) {
15918
- // @ts-expect-error
15919
- var a = this.last = current.pre;
15920
- if (a) {
15921
- a.next = null;
15922
- }
15923
- }
15924
- else if (node) {
15925
- var pre = node.pre;
15926
- var next = node.next;
15927
- // @ts-expect-error
15928
- pre.next = next;
15929
- if (next) {
15930
- next.pre = pre;
15931
- }
15932
- }
15933
- node.pre = null;
15934
- node.next = null;
15935
- };
15936
- Link.prototype.forEach = function (func, thisObj) {
15937
- var node = this.first;
15938
- var i = 0;
15939
- if (node) {
15940
- do {
15941
- func.call(thisObj || this, node.content, i++);
15942
- // @ts-expect-error
15943
- // eslint-disable-next-line no-cond-assign
15944
- } while (node = node.next);
15945
- }
15946
- };
15947
- Link.prototype.forEachReverse = function (func, thisObj) {
15948
- var node = this.last;
15949
- var i = this.length - 1;
15950
- if (node) {
15951
- do {
15952
- func.call(thisObj || this, node.content, i--);
15953
- // @ts-expect-error
15954
- // eslint-disable-next-line no-cond-assign
15955
- } while (node = node.pre);
15714
+ };
15715
+ Link.prototype.forEachReverse = function (func, thisObj) {
15716
+ var node = this.last;
15717
+ var i = this.length - 1;
15718
+ if (node) {
15719
+ do {
15720
+ func.call(thisObj || this, node.content, i--);
15721
+ // @ts-expect-error
15722
+ // eslint-disable-next-line no-cond-assign
15723
+ } while (node = node.pre);
15956
15724
  }
15957
15725
  };
15958
15726
  return Link;
@@ -16859,10 +16627,10 @@ function getGeometryTriangles(geometry, options) {
16859
16627
  var segment = segments[i];
16860
16628
  var p0 = points[i];
16861
16629
  var p1 = points[i + 1] || points[0];
16862
- var keys_1 = segment;
16630
+ var keys = segment;
16863
16631
  var point = [0, 0];
16864
- for (var j = 0; j < keys_1.length - 1; j++) {
16865
- var key = keys_1[j];
16632
+ for (var j = 0; j < keys.length - 1; j++) {
16633
+ var key = keys[j];
16866
16634
  getBezier2DValue(point, key, p0, p1, p0[4], p0[5], p1[2], p1[3]);
16867
16635
  setPoint(point[0], point[1]);
16868
16636
  }
@@ -16921,11 +16689,11 @@ function getGeometryByShape(shape, uvTransform) {
16921
16689
  var index = 0;
16922
16690
  for (var i = 0; i < geometries.length; i++) {
16923
16691
  var geometry = geometries[i];
16924
- var data_1 = getGeometryTriangles(geometry, { indexBase: indexBase, uvTransform: uvTransform });
16925
- indexBase += data_1.aPoint.length / 5;
16926
- datas.push(data_1);
16927
- aPoint += data_1.aPoint.length;
16928
- index += data_1.index.length;
16692
+ var data = getGeometryTriangles(geometry, { indexBase: indexBase, uvTransform: uvTransform });
16693
+ indexBase += data.aPoint.length / 5;
16694
+ datas.push(data);
16695
+ aPoint += data.aPoint.length;
16696
+ index += data.index.length;
16929
16697
  }
16930
16698
  if (datas.length === 1) {
16931
16699
  return datas[0];
@@ -16934,11 +16702,11 @@ function getGeometryByShape(shape, uvTransform) {
16934
16702
  var indexData = new Uint16Array(index);
16935
16703
  // @ts-expect-error
16936
16704
  for (var i = 0, pointIndex = 0, idx = 0; i < datas[i]; i++) {
16937
- var data_2 = datas[i];
16938
- aPointData.set(data_2.aPoint, pointIndex);
16939
- pointIndex += data_2.aPoint.length;
16940
- indexData.set(data_2.index, idx);
16941
- idx += data_2.index.length;
16705
+ var data = datas[i];
16706
+ aPointData.set(data.aPoint, pointIndex);
16707
+ pointIndex += data.aPoint.length;
16708
+ indexData.set(data.index, idx);
16709
+ idx += data.index.length;
16942
16710
  }
16943
16711
  return {
16944
16712
  aPoint: aPointData,
@@ -17043,11 +16811,11 @@ var TrailMesh = /** @class */ (function () {
17043
16811
  var uWidthOverTrail = widthOverTrail.toUniform(keyFrameMeta);
17044
16812
  marcos.push(['VERT_CURVE_VALUE_COUNT', keyFrameMeta.index], ['VERT_MAX_KEY_FRAME_COUNT', keyFrameMeta.max]);
17045
16813
  if (enableVertexTexture && lookUpTexture) {
17046
- var tex = generateHalfFloatTexture(engine, CurveValue.getAllData(keyFrameMeta, true), keyFrameMeta.index, 1);
16814
+ var tex = generateHalfFloatTexture(engine, ValueGetter.getAllData(keyFrameMeta, true), keyFrameMeta.index, 1);
17047
16815
  uniformValues.uVCurveValueTexture = tex;
17048
16816
  }
17049
16817
  else {
17050
- uniformValues.uVCurveValues = CurveValue.getAllData(keyFrameMeta);
16818
+ uniformValues.uVCurveValues = ValueGetter.getAllData(keyFrameMeta);
17051
16819
  }
17052
16820
  var vertex = createShaderWithMarcos(marcos, trailVert, ShaderType.vertex, level);
17053
16821
  var fragment = createShaderWithMarcos(marcos, particleFrag, ShaderType.fragment, level);
@@ -17126,8 +16894,10 @@ var TrailMesh = /** @class */ (function () {
17126
16894
  }
17127
16895
  else if (name === 'uVCurveValues') {
17128
16896
  var array = [];
17129
- array.push(new Vector4(value[0], value[1], value[2], value[3]));
17130
- array.push(new Vector4(value[4], value[5], value[6], value[7]));
16897
+ for (var i = 0; i < value.length; i = i + 4) {
16898
+ var v = new Vector4(value[i], value[i + 1], value[i + 2], value[i + 3]);
16899
+ array.push(v);
16900
+ }
17131
16901
  material.setVector4Array(name, array);
17132
16902
  }
17133
16903
  else {
@@ -17249,10 +17019,10 @@ var TrailMesh = /** @class */ (function () {
17249
17019
  var pointCountPerTrail = this.pointCountPerTrail;
17250
17020
  if (index >= 0 && index < pointCountPerTrail) {
17251
17021
  var startIndex = (trail * pointCountPerTrail + index) * 24 + 8;
17252
- var data_1 = this.geometry.getAttributeData('aColor');
17253
- out.x = data_1[startIndex];
17254
- out.y = data_1[1 + startIndex];
17255
- out.z = data_1[2 + startIndex];
17022
+ var data = this.geometry.getAttributeData('aColor');
17023
+ out.x = data[startIndex];
17024
+ out.y = data[1 + startIndex];
17025
+ out.z = data[2 + startIndex];
17256
17026
  return out;
17257
17027
  }
17258
17028
  };
@@ -17875,456 +17645,1129 @@ var ParticleSystem = /** @class */ (function () {
17875
17645
  this.onIterate(this);
17876
17646
  }
17877
17647
  else {
17878
- this.ended = true;
17879
- this.onEnd(this);
17880
- var endBehavior = options.endBehavior;
17881
- if (endBehavior === END_BEHAVIOR_FREEZE$1) {
17882
- this.frozen = true;
17883
- }
17648
+ this.ended = true;
17649
+ this.onEnd(this);
17650
+ var endBehavior = options.endBehavior;
17651
+ if (endBehavior === END_BEHAVIOR_FREEZE$1) {
17652
+ this.frozen = true;
17653
+ }
17654
+ }
17655
+ }
17656
+ else if (!options.looping) {
17657
+ if (this.reusable) ;
17658
+ else if (END_BEHAVIOR_DESTROY$1 === options.endBehavior) {
17659
+ var node = link_1.last;
17660
+ if (node && (node.content[0] - loopStartTime_1) < timePassed_1) {
17661
+ this.onUpdate = function () { return _this.onDestroy(); };
17662
+ }
17663
+ }
17664
+ }
17665
+ updateTrail();
17666
+ }
17667
+ };
17668
+ ParticleSystem.prototype.onDestroy = function () {
17669
+ };
17670
+ ParticleSystem.prototype.getParticleBoxes = function () {
17671
+ var link = this.particleLink;
17672
+ var mesh = this.particleMesh;
17673
+ var res = [];
17674
+ var maxCount = this.particleCount;
17675
+ var counter = 0;
17676
+ if (!(link && mesh)) {
17677
+ return res;
17678
+ }
17679
+ var node = link.last;
17680
+ var finish = false;
17681
+ while (!finish) {
17682
+ var currentTime = node.content[0];
17683
+ var point = node.content[3];
17684
+ if (currentTime > this.timePassed) {
17685
+ var pos = this.getPointPosition(point);
17686
+ res.push({
17687
+ center: pos,
17688
+ size: point.transform.scale,
17689
+ });
17690
+ if (node.pre) {
17691
+ node = node.pre;
17692
+ }
17693
+ else {
17694
+ finish = true;
17695
+ }
17696
+ }
17697
+ counter++;
17698
+ if (counter > maxCount) {
17699
+ finish = true;
17700
+ }
17701
+ }
17702
+ return res;
17703
+ };
17704
+ ParticleSystem.prototype.raycast = function (options) {
17705
+ var link = this.particleLink;
17706
+ var mesh = this.particleMesh;
17707
+ if (!(link && mesh)) {
17708
+ return;
17709
+ }
17710
+ var node = link.last;
17711
+ var hitPositions = [];
17712
+ var temp = new Vector3();
17713
+ var finish = false;
17714
+ if (node && node.content) {
17715
+ do {
17716
+ var _a = __read$3(node.content, 4), currentTime = _a[0], pointIndex = _a[1]; _a[2]; var point = _a[3];
17717
+ if (currentTime > this.timePassed) {
17718
+ var pos = this.getPointPosition(point);
17719
+ var ray = options.ray;
17720
+ var pass = false;
17721
+ if (ray) {
17722
+ pass = !!ray.intersectSphere({
17723
+ center: pos,
17724
+ radius: options.radius,
17725
+ }, temp);
17726
+ }
17727
+ if (pass) {
17728
+ if (options.removeParticle) {
17729
+ mesh.removePoint(pointIndex);
17730
+ this.clearPointTrail(pointIndex);
17731
+ node.content[0] = 0;
17732
+ }
17733
+ hitPositions.push(pos);
17734
+ if (!options.multiple) {
17735
+ finish = true;
17736
+ }
17737
+ }
17738
+ }
17739
+ else {
17740
+ break;
17741
+ }
17742
+ // @ts-expect-error
17743
+ } while ((node = node.pre) && !finish);
17744
+ }
17745
+ return hitPositions;
17746
+ };
17747
+ ParticleSystem.prototype.clearPointTrail = function (pointIndex) {
17748
+ var _a;
17749
+ if (this.trails && this.trails.dieWithParticles) {
17750
+ (_a = this.trailMesh) === null || _a === void 0 ? void 0 : _a.clearTrail(pointIndex);
17751
+ }
17752
+ };
17753
+ ParticleSystem.prototype.updatePointTrail = function (pointIndex, emitterLifetime, point, startTime) {
17754
+ if (!this.trailMesh) {
17755
+ return;
17756
+ }
17757
+ var trails = this.trails;
17758
+ var particleMesh = this.particleMesh;
17759
+ var position = this.getPointPosition(point);
17760
+ var color = trails.inheritParticleColor ? particleMesh.getPointColor(pointIndex) : [1, 1, 1, 1];
17761
+ var size = point.transform.getWorldScale().toArray();
17762
+ var width = 1;
17763
+ var lifetime = trails.lifetime.getValue(emitterLifetime);
17764
+ if (trails.sizeAffectsWidth) {
17765
+ width *= size[0];
17766
+ }
17767
+ if (trails.sizeAffectsLifetime) {
17768
+ lifetime *= size[0];
17769
+ }
17770
+ if (trails.parentAffectsPosition && this.transform.parentTransform) {
17771
+ position.add(this.transform.parentTransform.position);
17772
+ var pos = this.trailMesh.getPointStartPos(pointIndex);
17773
+ if (pos) {
17774
+ position.subtract(pos);
17775
+ }
17776
+ }
17777
+ this.trailMesh.addPoint(pointIndex, position, {
17778
+ color: color,
17779
+ lifetime: lifetime,
17780
+ size: width,
17781
+ time: startTime,
17782
+ });
17783
+ };
17784
+ ParticleSystem.prototype.getPointPosition = function (point) {
17785
+ var transform = point.transform, vel = point.vel, lifetime = point.lifetime, delay = point.delay, _a = point.gravity, gravity = _a === void 0 ? [] : _a;
17786
+ var forceTarget = this.options.forceTarget;
17787
+ var time = this.lastUpdate - delay;
17788
+ var tempPos = new Vector3();
17789
+ var acc = Vector3.fromArray(gravity);
17790
+ transform.assignWorldTRS(tempPos);
17791
+ var ret = calculateTranslation(new Vector3(), this.options, acc, time, lifetime, tempPos, vel);
17792
+ if (forceTarget) {
17793
+ var target = forceTarget.target || [0, 0, 0];
17794
+ var life = forceTarget.curve.getValue(time / lifetime);
17795
+ var dl = 1 - life;
17796
+ ret.x = ret.x * dl + target[0] * life;
17797
+ ret.y = ret.y * dl + target[1] * life;
17798
+ ret.z = ret.z * dl + target[2] * life;
17799
+ }
17800
+ return ret;
17801
+ };
17802
+ ParticleSystem.prototype.onEnd = function (particle) {
17803
+ };
17804
+ ParticleSystem.prototype.onIterate = function (particle) {
17805
+ };
17806
+ ParticleSystem.prototype.initPoint = function (data) {
17807
+ var options = this.options;
17808
+ var lifetime = this.lifetime;
17809
+ var shape = this.shape;
17810
+ var speed = options.startSpeed.getValue(lifetime);
17811
+ var matrix4 = options.particleFollowParent ? this.transform.getMatrix() : this.transform.getWorldMatrix();
17812
+ // 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
17813
+ var position = matrix4.transformPoint(data.position, new Vector3());
17814
+ var transform = new Transform({
17815
+ position: position,
17816
+ valid: true,
17817
+ });
17818
+ var direction = data.direction;
17819
+ direction = matrix4.transformNormal(direction, tempDir).normalize();
17820
+ if (options.startTurbulence && options.turbulence) {
17821
+ for (var i = 0; i < 3; i++) {
17822
+ tempVec3.setElement(i, options.turbulence[i].getValue(lifetime));
17823
+ }
17824
+ tempEuler.setFromVector3(tempVec3.negate());
17825
+ var mat4 = tempMat4.setFromEuler(tempEuler);
17826
+ mat4.transformNormal(direction).normalize();
17827
+ }
17828
+ var dirX = tmpDirX;
17829
+ var dirY = tmpDirY;
17830
+ if (shape.alignSpeedDirection) {
17831
+ dirY.copyFrom(direction);
17832
+ if (!this.upDirectionWorld) {
17833
+ if (shape.upDirection) {
17834
+ this.upDirectionWorld = shape.upDirection.clone();
17835
+ }
17836
+ else {
17837
+ this.upDirectionWorld = Vector3.Z.clone();
17884
17838
  }
17839
+ matrix4.transformNormal(this.upDirectionWorld);
17885
17840
  }
17886
- else if (!options.looping) {
17887
- if (this.reusable) ;
17888
- else if (END_BEHAVIOR_DESTROY$1 === options.endBehavior) {
17889
- var node = link_1.last;
17890
- if (node && (node.content[0] - loopStartTime_1) < timePassed_1) {
17891
- this.onUpdate = function () { return _this.onDestroy(); };
17892
- }
17893
- }
17841
+ dirX.crossVectors(dirY, this.upDirectionWorld).normalize();
17842
+ // FIXME: 原先因为有精度问题,这里dirX不是0向量
17843
+ if (dirX.isZero()) {
17844
+ dirX.set(1, 0, 0);
17894
17845
  }
17895
- updateTrail();
17896
17846
  }
17847
+ else {
17848
+ dirX.set(1, 0, 0);
17849
+ dirY.set(0, 1, 0);
17850
+ }
17851
+ var sprite;
17852
+ var tsa = this.textureSheetAnimation;
17853
+ if (tsa && tsa.animate) {
17854
+ sprite = tempSprite;
17855
+ sprite[0] = tsa.animationDelay.getValue(lifetime);
17856
+ sprite[1] = tsa.animationDuration.getValue(lifetime);
17857
+ sprite[2] = tsa.cycles.getValue(lifetime);
17858
+ }
17859
+ var rot = tempRot;
17860
+ if (options.start3DRotation) {
17861
+ // @ts-expect-error
17862
+ rot.set(options.startRotationX.getValue(lifetime), options.startRotationY.getValue(lifetime), options.startRotationZ.getValue(lifetime));
17863
+ }
17864
+ else if (options.startRotation) {
17865
+ rot.set(0, 0, options.startRotation.getValue(lifetime));
17866
+ }
17867
+ else {
17868
+ rot.set(0, 0, 0);
17869
+ }
17870
+ transform.setRotation(rot.x, rot.y, rot.z);
17871
+ var color = options.startColor.getValue(lifetime);
17872
+ if (color.length === 3) {
17873
+ color[3] = 1;
17874
+ }
17875
+ var size = tempSize;
17876
+ if (options.start3DSize) {
17877
+ size.x = options.startSizeX.getValue(lifetime);
17878
+ size.y = options.startSizeY.getValue(lifetime);
17879
+ }
17880
+ else {
17881
+ var n = options.startSize.getValue(lifetime);
17882
+ var aspect = options.sizeAspect.getValue(lifetime);
17883
+ size.x = n;
17884
+ // 兼容aspect为0的情况
17885
+ size.y = aspect === 0 ? 0 : n / aspect;
17886
+ // size[1] = n / aspect;
17887
+ }
17888
+ var vel = direction.clone();
17889
+ vel.multiply(speed);
17890
+ // 粒子的大小受发射器父节点的影响
17891
+ if (!options.particleFollowParent) {
17892
+ var tempScale = new Vector3();
17893
+ this.transform.assignWorldTRS(undefined, undefined, tempScale);
17894
+ size.x *= tempScale.x;
17895
+ size.y *= tempScale.y;
17896
+ }
17897
+ transform.setScale(size.x, size.y, 1);
17898
+ return {
17899
+ size: size,
17900
+ vel: vel,
17901
+ color: color,
17902
+ delay: options.startDelay.getValue(lifetime),
17903
+ lifetime: options.startLifetime.getValue(lifetime),
17904
+ uv: randomArrItem(this.uvs, true),
17905
+ gravity: options.gravity,
17906
+ sprite: sprite,
17907
+ dirY: dirY,
17908
+ dirX: dirX,
17909
+ transform: transform,
17910
+ };
17897
17911
  };
17898
- ParticleSystem.prototype.onDestroy = function () {
17912
+ ParticleSystem.prototype.addBurst = function (burst, offsets) {
17913
+ var willAdd = false;
17914
+ if (!this.emission.bursts.includes(burst)) {
17915
+ this.emission.bursts.push(burst);
17916
+ willAdd = true;
17917
+ }
17918
+ if (willAdd && offsets instanceof Array) {
17919
+ var index = this.emission.bursts.indexOf(burst);
17920
+ this.emission.burstOffsets[index] = offsets;
17921
+ return index;
17922
+ }
17923
+ return -1;
17899
17924
  };
17900
- ParticleSystem.prototype.getParticleBoxes = function () {
17901
- var link = this.particleLink;
17902
- var mesh = this.particleMesh;
17903
- var res = [];
17904
- var maxCount = this.particleCount;
17905
- var counter = 0;
17906
- if (!(link && mesh)) {
17907
- return res;
17925
+ ParticleSystem.prototype.removeBurst = function (index) {
17926
+ if (index < this.emission.bursts.length) {
17927
+ this.emission.burstOffsets[index] = null;
17928
+ this.emission.bursts.splice(index, 1);
17908
17929
  }
17909
- var node = link.last;
17910
- var finish = false;
17911
- while (!finish) {
17912
- var currentTime = node.content[0];
17913
- var point = node.content[3];
17914
- if (currentTime > this.timePassed) {
17915
- var pos = this.getPointPosition(point);
17916
- res.push({
17917
- center: pos,
17918
- size: point.transform.scale,
17919
- });
17920
- if (node.pre) {
17921
- node = node.pre;
17922
- }
17923
- else {
17924
- finish = true;
17925
- }
17930
+ };
17931
+ ParticleSystem.prototype.createPoint = function (lifetime) {
17932
+ var generator = {
17933
+ total: this.emission.rateOverTime.getValue(lifetime),
17934
+ index: this.generatedCount,
17935
+ burstIndex: 0,
17936
+ burstCount: 0,
17937
+ };
17938
+ this.generatedCount++;
17939
+ return this.initPoint(this.shape.generate(generator));
17940
+ };
17941
+ return ParticleSystem;
17942
+ }());
17943
+ // array performance better for small memory than Float32Array
17944
+ var tempDir = new Vector3();
17945
+ var tempSize = new Vector2();
17946
+ var tempRot = new Euler();
17947
+ var tmpDirX = new Vector3();
17948
+ var tmpDirY = new Vector3();
17949
+ var tempVec3 = new Vector3();
17950
+ var tempEuler = new Euler();
17951
+ var tempSprite = [0, 0, 0];
17952
+ var tempMat4 = new Matrix4();
17953
+ function getBurstOffsets(burstOffsets) {
17954
+ var ret = {};
17955
+ if (Array.isArray(burstOffsets)) {
17956
+ burstOffsets.forEach(function (arr) {
17957
+ var isArr = arr instanceof Array;
17958
+ var index = isArr ? arr[0] : arr.index;
17959
+ var offsets = ret[index];
17960
+ if (!offsets) {
17961
+ offsets = ret[index] = [];
17926
17962
  }
17927
- counter++;
17928
- if (counter > maxCount) {
17929
- finish = true;
17963
+ if (isArr) {
17964
+ offsets.push(arr.slice(1, 4));
17930
17965
  }
17931
- }
17932
- return res;
17966
+ else {
17967
+ offsets.push([+arr.x, +arr.y, +arr.z]);
17968
+ }
17969
+ });
17970
+ }
17971
+ return ret;
17972
+ }
17973
+ function randomArrItem(arr, keepArr) {
17974
+ var index = Math.floor(Math.random() * arr.length);
17975
+ var item = arr[index];
17976
+ if (!keepArr) {
17977
+ arr.splice(index, 1);
17978
+ }
17979
+ return item;
17980
+ }
17981
+
17982
+ var ParticleVFXItem = /** @class */ (function (_super) {
17983
+ __extends(ParticleVFXItem, _super);
17984
+ function ParticleVFXItem() {
17985
+ var _this = _super !== null && _super.apply(this, arguments) || this;
17986
+ _this.destroyed = false;
17987
+ return _this;
17988
+ }
17989
+ Object.defineProperty(ParticleVFXItem.prototype, "type", {
17990
+ get: function () {
17991
+ return ItemType$1.particle;
17992
+ },
17993
+ enumerable: false,
17994
+ configurable: true
17995
+ });
17996
+ ParticleVFXItem.prototype.onConstructed = function (props) {
17997
+ this.particle = props.content;
17933
17998
  };
17934
- ParticleSystem.prototype.raycast = function (options) {
17935
- var link = this.particleLink;
17936
- var mesh = this.particleMesh;
17937
- if (!(link && mesh)) {
17938
- return;
17999
+ ParticleVFXItem.prototype.onLifetimeBegin = function (composition, particleSystem) {
18000
+ var _this = this;
18001
+ if (particleSystem) {
18002
+ particleSystem.name = this.name;
18003
+ particleSystem.start();
18004
+ particleSystem.onDestroy = function () {
18005
+ _this.destroyed = true;
18006
+ };
17939
18007
  }
17940
- var node = link.last;
17941
- var hitPositions = [];
17942
- var temp = new Vector3();
17943
- var finish = false;
17944
- if (node && node.content) {
17945
- do {
17946
- var _a = __read$3(node.content, 4), currentTime = _a[0], pointIndex = _a[1]; _a[2]; var point = _a[3];
17947
- if (currentTime > this.timePassed) {
17948
- var pos = this.getPointPosition(point);
17949
- var ray = options.ray;
17950
- var pass = false;
17951
- if (ray) {
17952
- pass = !!ray.intersectSphere({
17953
- center: pos,
17954
- radius: options.radius,
17955
- }, temp);
17956
- }
17957
- if (pass) {
17958
- if (options.removeParticle) {
17959
- mesh.removePoint(pointIndex);
17960
- this.clearPointTrail(pointIndex);
17961
- node.content[0] = 0;
17962
- }
17963
- hitPositions.push(pos);
17964
- if (!options.multiple) {
17965
- finish = true;
17966
- }
18008
+ return particleSystem;
18009
+ };
18010
+ ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
18011
+ var _a;
18012
+ if (this.content) {
18013
+ var hide = !this.visible;
18014
+ var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
18015
+ if (!hide && parentItem) {
18016
+ var parentData = parentItem.getRenderData();
18017
+ if (parentData) {
18018
+ if (!parentData.visible) {
18019
+ hide = false;
17967
18020
  }
17968
18021
  }
17969
- else {
17970
- break;
17971
- }
17972
- // @ts-expect-error
17973
- } while ((node = node.pre) && !finish);
18022
+ }
18023
+ if (hide) {
18024
+ this.content.setVisible(false);
18025
+ }
18026
+ else {
18027
+ this.content.setVisible(true);
18028
+ this.content.onUpdate(dt);
18029
+ }
17974
18030
  }
17975
- return hitPositions;
17976
18031
  };
17977
- ParticleSystem.prototype.clearPointTrail = function (pointIndex) {
17978
- var _a;
17979
- if (this.trails && this.trails.dieWithParticles) {
17980
- (_a = this.trailMesh) === null || _a === void 0 ? void 0 : _a.clearTrail(pointIndex);
18032
+ ParticleVFXItem.prototype.onItemRemoved = function (composition, content) {
18033
+ if (content) {
18034
+ composition.destroyTextures(content.getTextures());
18035
+ content.meshes.forEach(function (mesh) { return mesh.dispose({ material: { textures: DestroyOptions.keep } }); });
17981
18036
  }
17982
18037
  };
17983
- ParticleSystem.prototype.updatePointTrail = function (pointIndex, emitterLifetime, point, startTime) {
17984
- if (!this.trailMesh) {
17985
- return;
18038
+ /**
18039
+ * @internal
18040
+ */
18041
+ ParticleVFXItem.prototype.setColor = function (r, g, b, a) {
18042
+ this.content.setColor(r, g, b, a);
18043
+ };
18044
+ ParticleVFXItem.prototype.setOpacity = function (opacity) {
18045
+ this.content.setOpacity(opacity);
18046
+ };
18047
+ ParticleVFXItem.prototype.stopParticleEmission = function () {
18048
+ if (this.content) {
18049
+ this.content.emissionStopped = true;
17986
18050
  }
17987
- var trails = this.trails;
17988
- var particleMesh = this.particleMesh;
17989
- var position = this.getPointPosition(point);
17990
- var color = trails.inheritParticleColor ? particleMesh.getPointColor(pointIndex) : [1, 1, 1, 1];
17991
- var size = point.transform.getWorldScale().toArray();
17992
- var width = 1;
17993
- var lifetime = trails.lifetime.getValue(emitterLifetime);
17994
- if (trails.sizeAffectsWidth) {
17995
- width *= size[0];
18051
+ };
18052
+ ParticleVFXItem.prototype.resumeParticleEmission = function () {
18053
+ if (this.content) {
18054
+ this.content.emissionStopped = false;
17996
18055
  }
17997
- if (trails.sizeAffectsLifetime) {
17998
- lifetime *= size[0];
18056
+ };
18057
+ ParticleVFXItem.prototype.doCreateContent = function (composition) {
18058
+ assertExist(this.particle);
18059
+ return new ParticleSystem(this.particle, composition.getRendererOptions(), this);
18060
+ };
18061
+ ParticleVFXItem.prototype.isEnded = function (now) {
18062
+ return _super.prototype.isEnded.call(this, now) && this.destroyed;
18063
+ };
18064
+ ParticleVFXItem.prototype.getBoundingBox = function () {
18065
+ var pt = this.content;
18066
+ if (!pt) {
18067
+ return;
17999
18068
  }
18000
- if (trails.parentAffectsPosition && this.transform.parentTransform) {
18001
- position.add(this.transform.parentTransform.position);
18002
- var pos = this.trailMesh.getPointStartPos(pointIndex);
18003
- if (pos) {
18004
- position.subtract(pos);
18005
- }
18069
+ else {
18070
+ var area = pt.getParticleBoxes();
18071
+ return {
18072
+ type: HitTestType.sphere,
18073
+ area: area,
18074
+ };
18006
18075
  }
18007
- this.trailMesh.addPoint(pointIndex, position, {
18008
- color: color,
18009
- lifetime: lifetime,
18010
- size: width,
18011
- time: startTime,
18012
- });
18013
18076
  };
18014
- ParticleSystem.prototype.getPointPosition = function (point) {
18015
- var transform = point.transform, vel = point.vel, lifetime = point.lifetime, delay = point.delay, _a = point.gravity, gravity = _a === void 0 ? [] : _a;
18016
- var forceTarget = this.options.forceTarget;
18017
- var time = this.lastUpdate - delay;
18018
- var tempPos = new Vector3();
18019
- var acc = Vector3.fromArray(gravity);
18020
- transform.assignWorldTRS(tempPos);
18021
- var ret = calculateTranslation(new Vector3(), this.options, acc, time, lifetime, tempPos, vel);
18022
- if (forceTarget) {
18023
- var target = forceTarget.target || [0, 0, 0];
18024
- var life = forceTarget.curve.getValue(time / lifetime);
18025
- var dl = 1 - life;
18026
- ret.x = ret.x * dl + target[0] * life;
18027
- ret.y = ret.y * dl + target[1] * life;
18028
- ret.z = ret.z * dl + target[2] * life;
18077
+ ParticleVFXItem.prototype.getHitTestParams = function (force) {
18078
+ var _this = this;
18079
+ var _a;
18080
+ var interactParams = (_a = this.content) === null || _a === void 0 ? void 0 : _a.interaction;
18081
+ if (force || interactParams) {
18082
+ return {
18083
+ type: HitTestType.custom,
18084
+ collect: function (ray) {
18085
+ var _a;
18086
+ return (_a = _this.content) === null || _a === void 0 ? void 0 : _a.raycast({
18087
+ radius: (interactParams === null || interactParams === void 0 ? void 0 : interactParams.radius) || 0.4,
18088
+ multiple: !!(interactParams === null || interactParams === void 0 ? void 0 : interactParams.multiple),
18089
+ removeParticle: (interactParams === null || interactParams === void 0 ? void 0 : interactParams.behavior) === ParticleInteractionBehavior$1.removeParticle,
18090
+ ray: ray,
18091
+ });
18092
+ },
18093
+ };
18029
18094
  }
18030
- return ret;
18031
- };
18032
- ParticleSystem.prototype.onEnd = function (particle) {
18033
- };
18034
- ParticleSystem.prototype.onIterate = function (particle) {
18035
18095
  };
18036
- ParticleSystem.prototype.initPoint = function (data) {
18037
- var options = this.options;
18038
- var lifetime = this.lifetime;
18039
- var shape = this.shape;
18040
- var speed = options.startSpeed.getValue(lifetime);
18041
- var matrix4 = options.particleFollowParent ? this.transform.getMatrix() : this.transform.getWorldMatrix();
18042
- // 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
18043
- var position = matrix4.transformPoint(data.position, new Vector3());
18044
- var transform = new Transform({
18045
- position: position,
18046
- valid: true,
18047
- });
18048
- var direction = data.direction;
18049
- direction = matrix4.transformNormal(direction, tempDir).normalize();
18050
- if (options.startTurbulence && options.turbulence) {
18051
- for (var i = 0; i < 3; i++) {
18052
- tempVec3.setElement(i, options.turbulence[i].getValue(lifetime));
18053
- }
18054
- tempEuler.setFromVector3(tempVec3.negate());
18055
- var mat4 = tempMat4.setFromEuler(tempEuler);
18056
- mat4.transformNormal(direction).normalize();
18096
+ return ParticleVFXItem;
18097
+ }(VFXItem));
18098
+ var particleUniformTypeMap = {
18099
+ 'uSprite': 'vec4',
18100
+ 'uParams': 'vec4',
18101
+ 'uAcceleration': 'vec4',
18102
+ 'uGravityModifierValue': 'vec4',
18103
+ 'uOpacityOverLifetimeValue': 'vec4',
18104
+ 'uRXByLifeTimeValue': 'vec4',
18105
+ 'uRYByLifeTimeValue': 'vec4',
18106
+ 'uRZByLifeTimeValue': 'vec4',
18107
+ 'uLinearXByLifetimeValue': 'vec4',
18108
+ 'uLinearYByLifetimeValue': 'vec4',
18109
+ 'uLinearZByLifetimeValue': 'vec4',
18110
+ 'uSpeedLifetimeValue': 'vec4',
18111
+ 'uOrbXByLifetimeValue': 'vec4',
18112
+ 'uOrbYByLifetimeValue': 'vec4',
18113
+ 'uOrbZByLifetimeValue': 'vec4',
18114
+ 'uSizeByLifetimeValue': 'vec4',
18115
+ 'uSizeYByLifetimeValue': 'vec4',
18116
+ 'uColorParams': 'vec4',
18117
+ 'uFSprite': 'vec4',
18118
+ 'uPreviewColor': 'vec4',
18119
+ 'uVCurveValues': 'vec4Array',
18120
+ 'uFCurveValues': 'vec4',
18121
+ 'uFinalTarget': 'vec3',
18122
+ 'uForceCurve': 'vec4',
18123
+ 'uOrbCenter': 'vec3',
18124
+ 'uTexOffset': 'vec2',
18125
+ 'uPeriodValue': 'vec4',
18126
+ 'uMovementValue': 'vec4',
18127
+ 'uStrengthValue': 'vec4',
18128
+ 'uWaveParams': 'vec4',
18129
+ };
18130
+
18131
+ var ParticleMesh = /** @class */ (function () {
18132
+ function ParticleMesh(props, rendererOptions) {
18133
+ var _a, _b, _c, _d;
18134
+ this.particleCount = 0;
18135
+ var engine = rendererOptions.composition.getEngine();
18136
+ var env = ((_a = engine.renderer) !== null && _a !== void 0 ? _a : {}).env;
18137
+ var speedOverLifetime = props.speedOverLifetime, colorOverLifetime = props.colorOverLifetime, linearVelOverLifetime = props.linearVelOverLifetime, orbitalVelOverLifetime = props.orbitalVelOverLifetime, sizeOverLifetime = props.sizeOverLifetime, rotationOverLifetime = props.rotationOverLifetime, sprite = props.sprite, gravityModifier = props.gravityModifier, maxCount = props.maxCount, duration = props.duration, textureFlip = props.textureFlip, useSprite = props.useSprite, name = props.name, filter = props.filter, gravity = props.gravity, forceTarget = props.forceTarget, side = props.side, occlusion = props.occlusion, anchor = props.anchor, blending = props.blending, maskMode = props.maskMode, mask = props.mask, transparentOcclusion = props.transparentOcclusion, listIndex = props.listIndex, meshSlots = props.meshSlots, _e = props.renderMode, renderMode = _e === void 0 ? 0 : _e, _f = props.diffuse, diffuse = _f === void 0 ? Texture.createWithData(engine) : _f;
18138
+ var detail = engine.gpuCapability.detail;
18139
+ var halfFloatTexture = detail.halfFloatTexture, maxVertexUniforms = detail.maxVertexUniforms;
18140
+ var marcos = [
18141
+ ['RENDER_MODE', +renderMode],
18142
+ ['PRE_MULTIPLY_ALPHA', false],
18143
+ ['ENV_EDITOR', env === PLAYER_OPTIONS_ENV_EDITOR],
18144
+ ];
18145
+ var level = engine.gpuCapability.level;
18146
+ var vertexKeyFrameMeta = createKeyFrameMeta();
18147
+ var fragmentKeyFrameMeta = createKeyFrameMeta();
18148
+ var enableVertexTexture = maxVertexUniforms > 0;
18149
+ var uniformValues = {};
18150
+ var vertex_lookup_texture = 0;
18151
+ var shaderCacheId = 0;
18152
+ var particleDefine;
18153
+ var useOrbitalVel;
18154
+ this.useSprite = useSprite;
18155
+ if (enableVertexTexture) {
18156
+ marcos.push(['ENABLE_VERTEX_TEXTURE', true]);
18057
18157
  }
18058
- var dirX = tmpDirX;
18059
- var dirY = tmpDirY;
18060
- if (shape.alignSpeedDirection) {
18061
- dirY.copyFrom(direction);
18062
- if (!this.upDirectionWorld) {
18063
- if (shape.upDirection) {
18064
- this.upDirectionWorld = shape.upDirection.clone();
18158
+ if (speedOverLifetime) {
18159
+ marcos.push(['SPEED_OVER_LIFETIME', true]);
18160
+ shaderCacheId |= 1 << 1;
18161
+ uniformValues.uSpeedLifetimeValue = speedOverLifetime.toUniform(vertexKeyFrameMeta);
18162
+ }
18163
+ if (sprite === null || sprite === void 0 ? void 0 : sprite.animate) {
18164
+ marcos.push(['USE_SPRITE', true]);
18165
+ shaderCacheId |= 1 << 2;
18166
+ uniformValues.uFSprite = uniformValues.uSprite = new Float32Array([sprite.col, sprite.row, sprite.total, sprite.blend ? 1 : 0]);
18167
+ this.useSprite = true;
18168
+ }
18169
+ if (filter && filter.name !== FILTER_NAME_NONE) {
18170
+ marcos.push(['USE_FILTER', true]);
18171
+ shaderCacheId |= 1 << 3;
18172
+ var filterDefine = createFilter(filter, rendererOptions.composition);
18173
+ if (!filterDefine.particle) {
18174
+ throw new Error("particle filter ".concat(filter.name, " not implement"));
18175
+ }
18176
+ particleDefine = filterDefine.particle;
18177
+ Object.keys((_b = particleDefine.uniforms) !== null && _b !== void 0 ? _b : {}).forEach(function (uName) {
18178
+ var _a;
18179
+ var getter = (_a = particleDefine.uniforms) === null || _a === void 0 ? void 0 : _a[uName];
18180
+ if (uniformValues[uName]) {
18181
+ throw new Error('conflict uniform name:' + uName);
18065
18182
  }
18066
- else {
18067
- this.upDirectionWorld = Vector3.Z.clone();
18183
+ uniformValues[uName] = getter === null || getter === void 0 ? void 0 : getter.toUniform(vertexKeyFrameMeta);
18184
+ });
18185
+ Object.keys((_c = particleDefine.uniformValues) !== null && _c !== void 0 ? _c : {}).forEach(function (uName) {
18186
+ var _a;
18187
+ var val = (_a = particleDefine.uniformValues) === null || _a === void 0 ? void 0 : _a[uName];
18188
+ if (uniformValues[uName]) {
18189
+ throw new Error('conflict uniform name:' + uName);
18068
18190
  }
18069
- matrix4.transformNormal(this.upDirectionWorld);
18191
+ uniformValues[uName] = val;
18192
+ });
18193
+ }
18194
+ if (colorOverLifetime === null || colorOverLifetime === void 0 ? void 0 : colorOverLifetime.color) {
18195
+ marcos.push(['COLOR_OVER_LIFETIME', true]);
18196
+ shaderCacheId |= 1 << 4;
18197
+ uniformValues.uColorOverLifetime = colorOverLifetime.color instanceof Texture ? colorOverLifetime.color : Texture.createWithData(engine, imageDataFromGradient(colorOverLifetime.color));
18198
+ }
18199
+ if (colorOverLifetime === null || colorOverLifetime === void 0 ? void 0 : colorOverLifetime.opacity) {
18200
+ uniformValues.uOpacityOverLifetimeValue = colorOverLifetime.opacity.toUniform(vertexKeyFrameMeta);
18201
+ }
18202
+ else {
18203
+ uniformValues.uOpacityOverLifetimeValue = createValueGetter(1).toUniform(vertexKeyFrameMeta);
18204
+ }
18205
+ ['x', 'y', 'z'].forEach(function (pro, i) {
18206
+ var defL = 0;
18207
+ var defO = 0;
18208
+ if (linearVelOverLifetime === null || linearVelOverLifetime === void 0 ? void 0 : linearVelOverLifetime[pro]) {
18209
+ uniformValues["uLinear".concat(pro.toUpperCase(), "ByLifetimeValue")] = linearVelOverLifetime[pro].toUniform(vertexKeyFrameMeta);
18210
+ defL = 1;
18211
+ shaderCacheId |= 1 << (7 + i);
18212
+ linearVelOverLifetime.enabled = true;
18070
18213
  }
18071
- dirX.crossVectors(dirY, this.upDirectionWorld).normalize();
18072
- // FIXME: 原先因为有精度问题,这里dirX不是0向量
18073
- if (dirX.isZero()) {
18074
- dirX.set(1, 0, 0);
18214
+ marcos.push(["LINEAR_VEL_".concat(pro.toUpperCase()), defL]);
18215
+ if (orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime[pro]) {
18216
+ uniformValues["uOrb".concat(pro.toUpperCase(), "ByLifetimeValue")] = orbitalVelOverLifetime[pro].toUniform(vertexKeyFrameMeta);
18217
+ defO = 1;
18218
+ shaderCacheId |= 1 << (10 + i);
18219
+ useOrbitalVel = true;
18220
+ orbitalVelOverLifetime.enabled = true;
18221
+ }
18222
+ marcos.push(["ORB_VEL_".concat(pro.toUpperCase()), defO]);
18223
+ });
18224
+ if (linearVelOverLifetime === null || linearVelOverLifetime === void 0 ? void 0 : linearVelOverLifetime.asMovement) {
18225
+ marcos.push(['AS_LINEAR_MOVEMENT', true]);
18226
+ shaderCacheId |= 1 << 5;
18227
+ }
18228
+ if (useOrbitalVel) {
18229
+ if (orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime.asRotation) {
18230
+ marcos.push(['AS_ORBITAL_MOVEMENT', true]);
18231
+ shaderCacheId |= 1 << 6;
18075
18232
  }
18233
+ uniformValues.uOrbCenter = new Float32Array((orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime.center) || [0, 0, 0]);
18076
18234
  }
18077
- else {
18078
- dirX.set(1, 0, 0);
18079
- dirY.set(0, 1, 0);
18235
+ uniformValues.uSizeByLifetimeValue = sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.x.toUniform(vertexKeyFrameMeta);
18236
+ if (sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.separateAxes) {
18237
+ marcos.push(['SIZE_Y_BY_LIFE', 1]);
18238
+ shaderCacheId |= 1 << 14;
18239
+ uniformValues.uSizeYByLifetimeValue = (_d = sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.y) === null || _d === void 0 ? void 0 : _d.toUniform(vertexKeyFrameMeta);
18080
18240
  }
18081
- var sprite;
18082
- var tsa = this.textureSheetAnimation;
18083
- if (tsa && tsa.animate) {
18084
- sprite = tempSprite;
18085
- sprite[0] = tsa.animationDelay.getValue(lifetime);
18086
- sprite[1] = tsa.animationDuration.getValue(lifetime);
18087
- sprite[2] = tsa.cycles.getValue(lifetime);
18241
+ if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.z) {
18242
+ uniformValues.uRZByLifeTimeValue = rotationOverLifetime.z.toUniform(vertexKeyFrameMeta);
18243
+ shaderCacheId |= 1 << 15;
18244
+ marcos.push(['ROT_Z_LIFETIME', 1]);
18088
18245
  }
18089
- var rot = tempRot;
18090
- if (options.start3DRotation) {
18091
- // @ts-expect-error
18092
- rot.set(options.startRotationX.getValue(lifetime), options.startRotationY.getValue(lifetime), options.startRotationZ.getValue(lifetime));
18246
+ if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.x) {
18247
+ uniformValues.uRXByLifeTimeValue = rotationOverLifetime.x.toUniform(vertexKeyFrameMeta);
18248
+ shaderCacheId |= 1 << 16;
18249
+ marcos.push(['ROT_X_LIFETIME', 1]);
18093
18250
  }
18094
- else if (options.startRotation) {
18095
- rot.set(0, 0, options.startRotation.getValue(lifetime));
18251
+ if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.y) {
18252
+ uniformValues.uRYByLifeTimeValue = rotationOverLifetime.y.toUniform(vertexKeyFrameMeta);
18253
+ shaderCacheId |= 1 << 17;
18254
+ marcos.push(['ROT_Y_LIFETIME', 1]);
18096
18255
  }
18097
- else {
18098
- rot.set(0, 0, 0);
18256
+ if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.asRotation) {
18257
+ marcos.push(['ROT_LIFETIME_AS_MOVEMENT', 1]);
18258
+ shaderCacheId |= 1 << 18;
18099
18259
  }
18100
- transform.setRotation(rot.x, rot.y, rot.z);
18101
- var color = options.startColor.getValue(lifetime);
18102
- if (color.length === 3) {
18103
- color[3] = 1;
18260
+ uniformValues.uGravityModifierValue = gravityModifier.toUniform(vertexKeyFrameMeta);
18261
+ if (forceTarget) {
18262
+ marcos.push(['FINAL_TARGET', true]);
18263
+ shaderCacheId |= 1 << 19;
18264
+ uniformValues.uFinalTarget = new Float32Array(forceTarget.target || [0, 0, 0]);
18265
+ uniformValues.uForceCurve = forceTarget.curve.toUniform(vertexKeyFrameMeta);
18104
18266
  }
18105
- var size = tempSize;
18106
- if (options.start3DSize) {
18107
- size.x = options.startSizeX.getValue(lifetime);
18108
- size.y = options.startSizeY.getValue(lifetime);
18267
+ if (halfFloatTexture && fragmentKeyFrameMeta.max) {
18268
+ shaderCacheId |= 1 << 20;
18269
+ uniformValues.uFCurveValueTexture = generateHalfFloatTexture(engine, ValueGetter.getAllData(fragmentKeyFrameMeta, true), fragmentKeyFrameMeta.index, 1);
18109
18270
  }
18110
18271
  else {
18111
- var n = options.startSize.getValue(lifetime);
18112
- var aspect = options.sizeAspect.getValue(lifetime);
18113
- size.x = n;
18114
- // 兼容aspect为0的情况
18115
- size.y = aspect === 0 ? 0 : n / aspect;
18116
- // size[1] = n / aspect;
18272
+ uniformValues.uFCurveValues = ValueGetter.getAllData(fragmentKeyFrameMeta);
18117
18273
  }
18118
- var vel = direction.clone();
18119
- vel.multiply(speed);
18120
- // 粒子的大小受发射器父节点的影响
18121
- if (!options.particleFollowParent) {
18122
- var tempScale = new Vector3();
18123
- this.transform.assignWorldTRS(undefined, undefined, tempScale);
18124
- size.x *= tempScale.x;
18125
- size.y *= tempScale.y;
18274
+ var vertexCurveTexture = vertexKeyFrameMeta.max + vertexKeyFrameMeta.curves.length - 32 > maxVertexUniforms;
18275
+ // if (getConfig(RENDER_PREFER_LOOKUP_TEXTURE)) {
18276
+ // vertexCurveTexture = true;
18277
+ // }
18278
+ if (level === 2) {
18279
+ vertexKeyFrameMeta.max = -1;
18280
+ vertexKeyFrameMeta.index = meshSlots ? meshSlots[0] : getSlot(vertexKeyFrameMeta.index);
18281
+ if (fragmentKeyFrameMeta.index > 0) {
18282
+ fragmentKeyFrameMeta.max = -1;
18283
+ fragmentKeyFrameMeta.index = meshSlots ? meshSlots[1] : getSlot(fragmentKeyFrameMeta.index);
18284
+ }
18126
18285
  }
18127
- transform.setScale(size.x, size.y, 1);
18128
- return {
18129
- size: size,
18130
- vel: vel,
18131
- color: color,
18132
- delay: options.startDelay.getValue(lifetime),
18133
- lifetime: options.startLifetime.getValue(lifetime),
18134
- uv: randomArrItem(this.uvs, true),
18135
- gravity: options.gravity,
18136
- sprite: sprite,
18137
- dirY: dirY,
18138
- dirX: dirX,
18139
- transform: transform,
18140
- };
18141
- };
18142
- ParticleSystem.prototype.addBurst = function (burst, offsets) {
18143
- var willAdd = false;
18144
- if (!this.emission.bursts.includes(burst)) {
18145
- this.emission.bursts.push(burst);
18146
- willAdd = true;
18286
+ if (vertexCurveTexture && halfFloatTexture && enableVertexTexture) {
18287
+ var tex = generateHalfFloatTexture(engine, ValueGetter.getAllData(vertexKeyFrameMeta, true), vertexKeyFrameMeta.index, 1);
18288
+ uniformValues.uVCurveValueTexture = tex;
18289
+ vertex_lookup_texture = 1;
18147
18290
  }
18148
- if (willAdd && offsets instanceof Array) {
18149
- var index = this.emission.bursts.indexOf(burst);
18150
- this.emission.burstOffsets[index] = offsets;
18151
- return index;
18291
+ else {
18292
+ uniformValues.uVCurveValues = ValueGetter.getAllData(vertexKeyFrameMeta);
18152
18293
  }
18153
- return -1;
18154
- };
18155
- ParticleSystem.prototype.removeBurst = function (index) {
18156
- if (index < this.emission.bursts.length) {
18157
- this.emission.burstOffsets[index] = null;
18158
- this.emission.bursts.splice(index, 1);
18294
+ var shaderCache = ['-p:', renderMode, shaderCacheId, vertexKeyFrameMeta.index, vertexKeyFrameMeta.max, fragmentKeyFrameMeta.index, fragmentKeyFrameMeta.max].join('+');
18295
+ marcos.push(['VERT_CURVE_VALUE_COUNT', vertexKeyFrameMeta.index], ['FRAG_CURVE_VALUE_COUNT', fragmentKeyFrameMeta.index], ['VERT_MAX_KEY_FRAME_COUNT', vertexKeyFrameMeta.max], ['FRAG_MAX_KEY_FRAME_COUNT', fragmentKeyFrameMeta.max]);
18296
+ var fragment = filter ? particleFrag.replace(/#pragma\s+FILTER_FRAG/, particleDefine.fragment) : particleFrag;
18297
+ var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
18298
+ var vertex = filter ? originalVertex.replace(/#pragma\s+FILTER_VERT/, particleDefine.vertex || 'void filterMain(float t){}\n') : originalVertex;
18299
+ var shader = {
18300
+ fragment: createShaderWithMarcos(marcos, fragment, ShaderType.fragment, level),
18301
+ vertex: createShaderWithMarcos(marcos, vertex, ShaderType.vertex, level),
18302
+ glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
18303
+ shared: true,
18304
+ cacheId: shaderCache,
18305
+ marcos: marcos,
18306
+ name: "particle#".concat(name),
18307
+ };
18308
+ if (filter) {
18309
+ shader.cacheId += filter.name;
18159
18310
  }
18160
- };
18161
- ParticleSystem.prototype.createPoint = function (lifetime) {
18162
- var generator = {
18163
- total: this.emission.rateOverTime.getValue(lifetime),
18164
- index: this.generatedCount,
18165
- burstIndex: 0,
18166
- burstCount: 0,
18311
+ var mtlOptions = {
18312
+ shader: shader,
18313
+ uniformSemantics: {
18314
+ effects_MatrixV: 'VIEW',
18315
+ effects_MatrixVP: 'VIEWPROJECTION',
18316
+ uEditorTransform: 'EDITOR_TRANSFORM',
18317
+ effects_ObjectToWorld: 'MODEL',
18318
+ },
18167
18319
  };
18168
- this.generatedCount++;
18169
- return this.initPoint(this.shape.generate(generator));
18170
- };
18171
- return ParticleSystem;
18172
- }());
18173
- // array performance better for small memory than Float32Array
18174
- var tempDir = new Vector3();
18175
- var tempSize = new Vector2();
18176
- var tempRot = new Euler();
18177
- var tmpDirX = new Vector3();
18178
- var tmpDirY = new Vector3();
18179
- var tempVec3 = new Vector3();
18180
- var tempEuler = new Euler();
18181
- var tempSprite = [0, 0, 0];
18182
- var tempMat4 = new Matrix4();
18183
- function getBurstOffsets(burstOffsets) {
18184
- var ret = {};
18185
- if (Array.isArray(burstOffsets)) {
18186
- burstOffsets.forEach(function (arr) {
18187
- var isArr = arr instanceof Array;
18188
- var index = isArr ? arr[0] : arr.index;
18189
- var offsets = ret[index];
18190
- if (!offsets) {
18191
- offsets = ret[index] = [];
18192
- }
18193
- if (isArr) {
18194
- offsets.push(arr.slice(1, 4));
18320
+ var preMulAlpha = getPreMultiAlpha(blending);
18321
+ uniformValues.uTexOffset = new Float32Array(diffuse ? [1 / diffuse.getWidth(), 1 / diffuse.getHeight()] : [0, 0]);
18322
+ uniformValues.uMaskTex = diffuse;
18323
+ uniformValues.uColorParams = new Float32Array([diffuse ? 1 : 0, +preMulAlpha, 0, +(!!occlusion && !transparentOcclusion)]);
18324
+ uniformValues.uParams = [0, duration, 0, 0];
18325
+ uniformValues.uAcceleration = [(gravity === null || gravity === void 0 ? void 0 : gravity[0]) || 0, (gravity === null || gravity === void 0 ? void 0 : gravity[1]) || 0, (gravity === null || gravity === void 0 ? void 0 : gravity[2]) || 0, 0];
18326
+ // mtlOptions.uniformValues = uniformValues;
18327
+ var material = Material.create(engine, mtlOptions);
18328
+ material.blending = true;
18329
+ material.depthTest = true;
18330
+ material.depthMask = !!(occlusion);
18331
+ material.stencilRef = mask ? [mask, mask] : undefined;
18332
+ setMaskMode(material, maskMode);
18333
+ setBlendMode(material, blending);
18334
+ setSideMode(material, side);
18335
+ Object.keys(uniformValues).map(function (name) {
18336
+ var value = uniformValues[name];
18337
+ if (value instanceof Texture) {
18338
+ material.setTexture(name, value);
18339
+ return;
18195
18340
  }
18196
- else {
18197
- offsets.push([+arr.x, +arr.y, +arr.z]);
18341
+ var res = [];
18342
+ switch (particleUniformTypeMap[name]) {
18343
+ case 'vec4':
18344
+ material.setVector4(name, Vector4.fromArray(value));
18345
+ break;
18346
+ case 'vec3':
18347
+ material.setVector3(name, Vector3.fromArray(value));
18348
+ break;
18349
+ case 'vec2':
18350
+ material.setVector2(name, Vector2.fromArray(value));
18351
+ break;
18352
+ case 'vec4Array':
18353
+ for (var i = 0; i < value.length; i = i + 4) {
18354
+ var v = new Vector4(value[i], value[i + 1], value[i + 2], value[i + 3]);
18355
+ res.push(v);
18356
+ }
18357
+ material.setVector4Array(name, res);
18358
+ res.length = 0;
18359
+ break;
18360
+ default:
18361
+ console.warn("uniform ".concat(name, "'s type not in typeMap"));
18198
18362
  }
18199
18363
  });
18364
+ material.setVector3('emissionColor', new Vector3(0, 0, 0));
18365
+ material.setFloat('emissionIntensity', 0.0);
18366
+ var geometry = Geometry.create(engine, generateGeometryProps(maxCount * 4, this.useSprite, "particle#".concat(name)));
18367
+ var mesh = Mesh.create(engine, {
18368
+ name: "MParticle_".concat(name),
18369
+ priority: listIndex,
18370
+ material: material,
18371
+ geometry: geometry,
18372
+ });
18373
+ this.anchor = anchor;
18374
+ this.mesh = mesh;
18375
+ this.geometry = mesh.firstGeometry();
18376
+ this.forceTarget = forceTarget;
18377
+ this.sizeOverLifetime = sizeOverLifetime;
18378
+ this.speedOverLifetime = speedOverLifetime;
18379
+ this.linearVelOverLifetime = linearVelOverLifetime;
18380
+ this.orbitalVelOverLifetime = orbitalVelOverLifetime;
18381
+ this.orbitalVelOverLifetime = orbitalVelOverLifetime;
18382
+ this.gravityModifier = gravityModifier;
18383
+ this.maxCount = maxCount;
18384
+ this.duration = duration;
18385
+ this.textureOffsets = textureFlip ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
18200
18386
  }
18201
- return ret;
18202
- }
18203
- function randomArrItem(arr, keepArr) {
18204
- var index = Math.floor(Math.random() * arr.length);
18205
- var item = arr[index];
18206
- if (!keepArr) {
18207
- arr.splice(index, 1);
18208
- }
18209
- return item;
18210
- }
18211
-
18212
- var ParticleVFXItem = /** @class */ (function (_super) {
18213
- __extends(ParticleVFXItem, _super);
18214
- function ParticleVFXItem() {
18215
- var _this = _super !== null && _super.apply(this, arguments) || this;
18216
- _this.destroyed = false;
18217
- return _this;
18218
- }
18219
- Object.defineProperty(ParticleVFXItem.prototype, "type", {
18387
+ Object.defineProperty(ParticleMesh.prototype, "time", {
18220
18388
  get: function () {
18221
- return ItemType$1.particle;
18389
+ var value = this.mesh.material.getVector4('uParams');
18390
+ return value.x;
18391
+ },
18392
+ set: function (v) {
18393
+ this.mesh.material.setVector4('uParams', new Vector4(+v, this.duration, 0, 0));
18222
18394
  },
18223
18395
  enumerable: false,
18224
18396
  configurable: true
18225
18397
  });
18226
- ParticleVFXItem.prototype.onConstructed = function (props) {
18227
- this.particle = props.content;
18398
+ ParticleMesh.prototype.getPointColor = function (index) {
18399
+ var data = this.geometry.getAttributeData('aRot');
18400
+ var i = index * 32 + 4;
18401
+ return [data[i], data[i + 1], data[i + 2], data[i + 3]];
18228
18402
  };
18229
- ParticleVFXItem.prototype.onLifetimeBegin = function (composition, particleSystem) {
18230
- var _this = this;
18231
- if (particleSystem) {
18232
- particleSystem.name = this.name;
18233
- particleSystem.start();
18234
- particleSystem.onDestroy = function () {
18235
- _this.destroyed = true;
18236
- };
18403
+ /**
18404
+ * 待废弃
18405
+ * @deprecated - 使用 `particle-system.getPointPosition` 替代
18406
+ */
18407
+ ParticleMesh.prototype.getPointPosition = function (index) {
18408
+ var geo = this.geometry;
18409
+ var posIndex = index * 48;
18410
+ var posData = geo.getAttributeData('aPos');
18411
+ var offsetData = geo.getAttributeData('aOffset');
18412
+ var time = this.time - offsetData[index * 16 + 2];
18413
+ var pointDur = offsetData[index * 16 + 3];
18414
+ var mtl = this.mesh.material;
18415
+ var acc = mtl.getVector4('uAcceleration').toVector3();
18416
+ var pos = Vector3.fromArray(posData, posIndex);
18417
+ var vel = Vector3.fromArray(posData, posIndex + 3);
18418
+ var ret = calculateTranslation(new Vector3(), this, acc, time, pointDur, pos, vel);
18419
+ if (this.forceTarget) {
18420
+ var target = mtl.getVector3('uFinalTarget');
18421
+ var life = this.forceTarget.curve.getValue(time / pointDur);
18422
+ var dl = 1 - life;
18423
+ ret.x = ret.x * dl + target.x * life;
18424
+ ret.y = ret.y * dl + target.y * life;
18425
+ ret.z = ret.z * dl + target.z * life;
18237
18426
  }
18238
- return particleSystem;
18427
+ return ret;
18239
18428
  };
18240
- ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
18241
- var _a;
18242
- if (this.content) {
18243
- var hide = !this.visible;
18244
- var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
18245
- if (!hide && parentItem) {
18246
- var parentData = parentItem.getRenderData();
18247
- if (parentData) {
18248
- if (!parentData.visible) {
18249
- hide = false;
18250
- }
18429
+ ParticleMesh.prototype.clearPoints = function () {
18430
+ this.resetGeometryData(this.geometry);
18431
+ this.particleCount = 0;
18432
+ this.geometry.setDrawCount(0);
18433
+ this.maxParticleBufferCount = 0;
18434
+ };
18435
+ ParticleMesh.prototype.resetGeometryData = function (geometry) {
18436
+ var names = geometry.getAttributeNames();
18437
+ var index = geometry.getIndexData();
18438
+ for (var i = 0; i < names.length; i++) {
18439
+ var name_1 = names[i];
18440
+ var data = geometry.getAttributeData(name_1);
18441
+ if (data) {
18442
+ // @ts-expect-error
18443
+ geometry.setAttributeData(name_1, new data.constructor(0));
18444
+ }
18445
+ }
18446
+ // @ts-expect-error
18447
+ geometry.setIndexData(new index.constructor(0));
18448
+ };
18449
+ ParticleMesh.prototype.minusTime = function (time) {
18450
+ var data = this.geometry.getAttributeData('aOffset');
18451
+ for (var i = 0; i < data.length; i += 4) {
18452
+ data[i + 2] -= time;
18453
+ }
18454
+ this.geometry.setAttributeData('aOffset', data);
18455
+ this.time -= time;
18456
+ };
18457
+ ParticleMesh.prototype.removePoint = function (index) {
18458
+ if (index < this.particleCount) {
18459
+ this.geometry.setAttributeSubData('aOffset', index * 16, new Float32Array(16));
18460
+ }
18461
+ };
18462
+ ParticleMesh.prototype.setPoint = function (point, index) {
18463
+ var maxCount = this.maxCount;
18464
+ if (index < maxCount) {
18465
+ var particleCount = index + 1;
18466
+ var vertexCount_1 = particleCount * 4;
18467
+ var geometry_1 = this.geometry;
18468
+ var increaseBuffer_1 = particleCount > this.maxParticleBufferCount;
18469
+ var inc_1 = 1;
18470
+ if (this.particleCount > 300) {
18471
+ inc_1 = (this.particleCount + 100) / this.particleCount;
18472
+ }
18473
+ else if (this.particleCount > 100) {
18474
+ inc_1 = 1.4;
18475
+ }
18476
+ else if (this.particleCount > 0) {
18477
+ inc_1 = 2;
18478
+ }
18479
+ var pointData_1 = {
18480
+ aPos: new Float32Array(48),
18481
+ aRot: new Float32Array(32),
18482
+ aOffset: new Float32Array(16),
18483
+ };
18484
+ var useSprite = this.useSprite;
18485
+ if (useSprite) {
18486
+ pointData_1.aSprite = new Float32Array(12);
18487
+ }
18488
+ var tempPos = new Vector3();
18489
+ var tempQuat = new Quaternion();
18490
+ var scale = new Vector3(1, 1, 1);
18491
+ point.transform.assignWorldTRS(tempPos, tempQuat, scale);
18492
+ var tempEuler = Transform.getRotation(tempQuat, new Euler());
18493
+ var position = tempPos.toArray();
18494
+ var rotation = tempEuler.toArray();
18495
+ var offsets = this.textureOffsets;
18496
+ var off = [0, 0, point.delay, point.lifetime];
18497
+ var wholeUV = [0, 0, 1, 1];
18498
+ var vel = point.vel;
18499
+ var color = point.color;
18500
+ var sizeOffsets = [-.5, .5, -.5, -.5, .5, .5, .5, -.5];
18501
+ var seed = Math.random();
18502
+ var sprite = void 0;
18503
+ if (useSprite) {
18504
+ sprite = point.sprite;
18505
+ }
18506
+ for (var j = 0; j < 4; j++) {
18507
+ var offset = j * 2;
18508
+ var j3 = j * 3;
18509
+ var j4 = j * 4;
18510
+ var j12 = j * 12;
18511
+ var j8 = j * 8;
18512
+ pointData_1.aPos.set(position, j12);
18513
+ vel.fill(pointData_1.aPos, j12 + 3);
18514
+ pointData_1.aRot.set(rotation, j8);
18515
+ pointData_1.aRot[j8 + 3] = seed;
18516
+ pointData_1.aRot.set(color, j8 + 4);
18517
+ if (useSprite) {
18518
+ // @ts-expect-error
18519
+ pointData_1.aSprite.set(sprite, j3);
18520
+ }
18521
+ var uv = point.uv || wholeUV;
18522
+ if (uv) {
18523
+ var uvy = useSprite ? (1 - offsets[offset + 1]) : offsets[offset + 1];
18524
+ off[0] = uv[0] + offsets[offset] * uv[2];
18525
+ off[1] = uv[1] + uvy * uv[3];
18526
+ }
18527
+ pointData_1.aOffset.set(off, j4);
18528
+ var ji = (j + j);
18529
+ var sx = (sizeOffsets[ji] - this.anchor.x) * scale.x;
18530
+ var sy = (sizeOffsets[ji + 1] - this.anchor.y) * scale.y;
18531
+ for (var k = 0; k < 3; k++) {
18532
+ pointData_1.aPos[j12 + 6 + k] = point.dirX.getElement(k) * sx;
18533
+ pointData_1.aPos[j12 + 9 + k] = point.dirY.getElement(k) * sy;
18251
18534
  }
18252
18535
  }
18253
- if (hide) {
18254
- this.content.setVisible(false);
18536
+ var indexData = new Uint16Array([0, 1, 2, 2, 1, 3].map(function (x) { return x + index * 4; }));
18537
+ if (increaseBuffer_1) {
18538
+ var baseIndexData = geometry_1.getIndexData();
18539
+ var idx = enlargeBuffer(baseIndexData, particleCount * 6, inc_1, maxCount * 6);
18540
+ idx.set(indexData, index * 6);
18541
+ geometry_1.setIndexData(idx);
18542
+ this.maxParticleBufferCount = idx.length / 6;
18255
18543
  }
18256
18544
  else {
18257
- this.content.setVisible(true);
18258
- this.content.onUpdate(dt);
18545
+ geometry_1.setIndexSubData(index * 6, indexData);
18259
18546
  }
18547
+ Object.keys(pointData_1).forEach(function (name) {
18548
+ var data = pointData_1[name];
18549
+ var attrSize = geometry_1.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
18550
+ if (increaseBuffer_1) {
18551
+ var baseData = geometry_1.getAttributeData(name);
18552
+ var geoData = enlargeBuffer(baseData, vertexCount_1 * attrSize, inc_1, maxCount * 4 * attrSize);
18553
+ geoData.set(data, data.length * index);
18554
+ geometry_1.setAttributeData(name, geoData);
18555
+ }
18556
+ else {
18557
+ geometry_1.setAttributeSubData(name, data.length * index, data);
18558
+ }
18559
+ });
18560
+ this.particleCount = Math.max(particleCount, this.particleCount);
18561
+ geometry_1.setDrawCount(this.particleCount * 6);
18562
+ }
18563
+ };
18564
+ return ParticleMesh;
18565
+ }());
18566
+ var gl2UniformSlots = [10, 32, 64, 160];
18567
+ function getSlot(count) {
18568
+ for (var w = 0; w < gl2UniformSlots.length; w++) {
18569
+ var slot = gl2UniformSlots[w];
18570
+ if (slot > count) {
18571
+ return slot;
18572
+ }
18573
+ }
18574
+ return count || gl2UniformSlots[0];
18575
+ }
18576
+ function generateGeometryProps(maxVertex, useSprite, name) {
18577
+ var bpe = Float32Array.BYTES_PER_ELEMENT;
18578
+ var j12 = bpe * 12;
18579
+ var attributes = {
18580
+ aPos: { size: 3, offset: 0, stride: j12, data: new Float32Array(0) },
18581
+ aVel: { size: 3, offset: 3 * bpe, stride: j12, dataSource: 'aPos' },
18582
+ aDirX: { size: 3, offset: 6 * bpe, stride: j12, dataSource: 'aPos' },
18583
+ aDirY: { size: 3, offset: 9 * bpe, stride: j12, dataSource: 'aPos' },
18584
+ //
18585
+ aRot: { size: 3, offset: 0, stride: 8 * bpe, data: new Float32Array(0) },
18586
+ aSeed: { size: 1, offset: 3 * bpe, stride: 8 * bpe, dataSource: 'aRot' },
18587
+ aColor: { size: 4, offset: 4 * bpe, stride: 8 * bpe, dataSource: 'aRot' },
18588
+ //
18589
+ aOffset: { size: 4, stride: 4 * bpe, data: new Float32Array(0) },
18590
+ };
18591
+ if (useSprite) {
18592
+ attributes['aSprite'] = { size: 3, data: new Float32Array(0) };
18593
+ }
18594
+ return { attributes: attributes, indices: { data: new Uint16Array(0) }, name: name, maxVertex: maxVertex };
18595
+ }
18596
+ function getParticleMeshShader(item, env, gpuCapability) {
18597
+ var _a, _b, _c, _d, _e;
18598
+ if (env === void 0) { env = ''; }
18599
+ var props = item.content;
18600
+ var renderMode = +(((_a = props.renderer) === null || _a === void 0 ? void 0 : _a.renderMode) || 0);
18601
+ var marcos = [
18602
+ ['RENDER_MODE', renderMode],
18603
+ ['PRE_MULTIPLY_ALPHA', false],
18604
+ ['ENV_EDITOR', env === PLAYER_OPTIONS_ENV_EDITOR],
18605
+ ];
18606
+ var level = gpuCapability.level, detail = gpuCapability.detail;
18607
+ var vertexKeyFrameMeta = createKeyFrameMeta();
18608
+ var fragmentKeyFrameMeta = createKeyFrameMeta();
18609
+ var enableVertexTexture = detail.maxVertexUniforms > 0;
18610
+ var speedOverLifetime = ((_b = props.positionOverLifetime) !== null && _b !== void 0 ? _b : {}).speedOverLifetime;
18611
+ var vertex_lookup_texture = 0;
18612
+ var shaderCacheId = 0;
18613
+ if (enableVertexTexture) {
18614
+ marcos.push(['ENABLE_VERTEX_TEXTURE', true]);
18615
+ }
18616
+ if (speedOverLifetime) {
18617
+ marcos.push(['SPEED_OVER_LIFETIME', true]);
18618
+ shaderCacheId |= 1 << 1;
18619
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, speedOverLifetime);
18620
+ }
18621
+ var sprite = props.textureSheetAnimation;
18622
+ if (sprite && sprite.animate) {
18623
+ marcos.push(['USE_SPRITE', true]);
18624
+ shaderCacheId |= 1 << 2;
18625
+ }
18626
+ var filter = undefined;
18627
+ if (props.filter && props.filter.name !== FILTER_NAME_NONE) {
18628
+ marcos.push(['USE_FILTER', true]);
18629
+ shaderCacheId |= 1 << 3;
18630
+ var f = createFilterShaders(props.filter).find(function (f) { return f.isParticle; });
18631
+ if (!f) {
18632
+ throw Error("particle filter ".concat(props.filter.name, " not implement"));
18260
18633
  }
18261
- };
18262
- ParticleVFXItem.prototype.onItemRemoved = function (composition, content) {
18263
- if (content) {
18264
- composition.destroyTextures(content.getTextures());
18265
- content.meshes.forEach(function (mesh) { return mesh.dispose({ material: { textures: DestroyOptions.keep } }); });
18634
+ filter = f;
18635
+ (_c = f.uniforms) === null || _c === void 0 ? void 0 : _c.forEach(function (val) { return getKeyFrameMetaByRawValue(vertexKeyFrameMeta, val); });
18636
+ // filter = processFilter(props.filter, fragmentKeyFrameMeta, vertexKeyFrameMeta, options);
18637
+ }
18638
+ var colorOverLifetime = props.colorOverLifetime;
18639
+ if (colorOverLifetime && colorOverLifetime.color) {
18640
+ marcos.push(['COLOR_OVER_LIFETIME', true]);
18641
+ shaderCacheId |= 1 << 4;
18642
+ }
18643
+ var opacity = colorOverLifetime && colorOverLifetime.opacity;
18644
+ if (opacity) {
18645
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, opacity);
18646
+ }
18647
+ var positionOverLifetime = props.positionOverLifetime;
18648
+ var useOrbitalVel;
18649
+ ['x', 'y', 'z'].forEach(function (pro, i) {
18650
+ var defL = 0;
18651
+ var linearPro = 'linear' + pro.toUpperCase();
18652
+ var orbitalPro = 'orbital' + pro.toUpperCase();
18653
+ if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime[linearPro]) {
18654
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime[linearPro]);
18655
+ defL = 1;
18656
+ shaderCacheId |= 1 << (7 + i);
18266
18657
  }
18267
- };
18268
- /**
18269
- * @internal
18270
- */
18271
- ParticleVFXItem.prototype.setColor = function (r, g, b, a) {
18272
- this.content.setColor(r, g, b, a);
18273
- };
18274
- ParticleVFXItem.prototype.setOpacity = function (opacity) {
18275
- this.content.setOpacity(opacity);
18276
- };
18277
- ParticleVFXItem.prototype.stopParticleEmission = function () {
18278
- if (this.content) {
18279
- this.content.emissionStopped = true;
18658
+ marcos.push(["LINEAR_VEL_".concat(pro.toUpperCase()), defL]);
18659
+ var defO = 0;
18660
+ if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime[orbitalPro]) {
18661
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime[orbitalPro]);
18662
+ defO = 1;
18663
+ shaderCacheId |= 1 << (10 + i);
18664
+ useOrbitalVel = true;
18280
18665
  }
18281
- };
18282
- ParticleVFXItem.prototype.resumeParticleEmission = function () {
18283
- if (this.content) {
18284
- this.content.emissionStopped = false;
18666
+ marcos.push(["ORB_VEL_".concat(pro.toUpperCase()), defO]);
18667
+ });
18668
+ if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.asMovement) {
18669
+ marcos.push(['AS_LINEAR_MOVEMENT', true]);
18670
+ shaderCacheId |= 1 << 5;
18671
+ }
18672
+ if (useOrbitalVel) {
18673
+ if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.asRotation) {
18674
+ marcos.push(['AS_ORBITAL_MOVEMENT', true]);
18675
+ shaderCacheId |= 1 << 6;
18285
18676
  }
18286
- };
18287
- ParticleVFXItem.prototype.doCreateContent = function (composition) {
18288
- assertExist(this.particle);
18289
- return new ParticleSystem(this.particle, composition.getRendererOptions(), this);
18290
- };
18291
- ParticleVFXItem.prototype.isEnded = function (now) {
18292
- return _super.prototype.isEnded.call(this, now) && this.destroyed;
18293
- };
18294
- ParticleVFXItem.prototype.getBoundingBox = function () {
18295
- var pt = this.content;
18296
- if (!pt) {
18297
- return;
18677
+ }
18678
+ var sizeOverLifetime = props.sizeOverLifetime;
18679
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.x);
18680
+ if (sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.separateAxes) {
18681
+ marcos.push(['SIZE_Y_BY_LIFE', 1]);
18682
+ shaderCacheId |= 1 << 14;
18683
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.y);
18684
+ }
18685
+ var rot = props.rotationOverLifetime;
18686
+ if (rot === null || rot === void 0 ? void 0 : rot.z) {
18687
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot === null || rot === void 0 ? void 0 : rot.z);
18688
+ shaderCacheId |= 1 << 15;
18689
+ marcos.push(['ROT_Z_LIFETIME', 1]);
18690
+ }
18691
+ if (rot === null || rot === void 0 ? void 0 : rot.separateAxes) {
18692
+ if (rot.x) {
18693
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.x);
18694
+ shaderCacheId |= 1 << 16;
18695
+ marcos.push(['ROT_X_LIFETIME', 1]);
18298
18696
  }
18299
- else {
18300
- var area = pt.getParticleBoxes();
18301
- return {
18302
- type: HitTestType.sphere,
18303
- area: area,
18304
- };
18697
+ if (rot.y) {
18698
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.y);
18699
+ shaderCacheId |= 1 << 17;
18700
+ marcos.push(['ROT_Y_LIFETIME', 1]);
18305
18701
  }
18306
- };
18307
- ParticleVFXItem.prototype.getHitTestParams = function (force) {
18308
- var _this = this;
18309
- var _a;
18310
- var interactParams = (_a = this.content) === null || _a === void 0 ? void 0 : _a.interaction;
18311
- if (force || interactParams) {
18312
- return {
18313
- type: HitTestType.custom,
18314
- collect: function (ray) {
18315
- var _a;
18316
- return (_a = _this.content) === null || _a === void 0 ? void 0 : _a.raycast({
18317
- radius: (interactParams === null || interactParams === void 0 ? void 0 : interactParams.radius) || 0.4,
18318
- multiple: !!(interactParams === null || interactParams === void 0 ? void 0 : interactParams.multiple),
18319
- removeParticle: (interactParams === null || interactParams === void 0 ? void 0 : interactParams.behavior) === ParticleInteractionBehavior$1.removeParticle,
18320
- ray: ray,
18321
- });
18322
- },
18323
- };
18702
+ }
18703
+ if (rot === null || rot === void 0 ? void 0 : rot.asRotation) {
18704
+ marcos.push(['ROT_LIFETIME_AS_MOVEMENT', 1]);
18705
+ shaderCacheId |= 1 << 18;
18706
+ }
18707
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravityOverLifetime);
18708
+ var forceOpt = positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.forceTarget;
18709
+ if (forceOpt) {
18710
+ marcos.push(['FINAL_TARGET', true]);
18711
+ shaderCacheId |= 1 << 19;
18712
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime.forceCurve);
18713
+ }
18714
+ var HALF_FLOAT = detail.halfFloatTexture;
18715
+ if (HALF_FLOAT && fragmentKeyFrameMeta.max) {
18716
+ shaderCacheId |= 1 << 20;
18717
+ }
18718
+ var maxVertexUniforms = detail.maxVertexUniforms;
18719
+ var vertexCurveTexture = vertexKeyFrameMeta.max + vertexKeyFrameMeta.curves.length - 32 > maxVertexUniforms;
18720
+ if (getConfig(RENDER_PREFER_LOOKUP_TEXTURE)) {
18721
+ vertexCurveTexture = true;
18722
+ }
18723
+ if (level === 2) {
18724
+ vertexKeyFrameMeta.max = -1;
18725
+ // vertexKeyFrameMeta.index = getSlot(vertexKeyFrameMeta.index);
18726
+ if (fragmentKeyFrameMeta.index > 0) {
18727
+ fragmentKeyFrameMeta.max = -1;
18728
+ // fragmentKeyFrameMeta.index = getSlot(fragmentKeyFrameMeta.index);
18324
18729
  }
18730
+ }
18731
+ if (vertexCurveTexture && HALF_FLOAT && enableVertexTexture) {
18732
+ vertex_lookup_texture = 1;
18733
+ }
18734
+ var shaderCache = ['-p:', renderMode, shaderCacheId, vertexKeyFrameMeta.index, vertexKeyFrameMeta.max, fragmentKeyFrameMeta.index, fragmentKeyFrameMeta.max].join('+');
18735
+ var shader = {
18736
+ fragment: particleFrag,
18737
+ vertex: "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert),
18738
+ shared: true,
18739
+ cacheId: shaderCache,
18740
+ marcos: marcos,
18741
+ name: "particle#".concat(item.name),
18325
18742
  };
18326
- return ParticleVFXItem;
18327
- }(VFXItem));
18743
+ if (filter) {
18744
+ shader.fragment = shader.fragment.replace(/#pragma\s+FILTER_FRAG/, (_d = filter.fragment) !== null && _d !== void 0 ? _d : '');
18745
+ shader.vertex = shader.vertex.replace(/#pragma\s+FILTER_VERT/, filter.vertex || 'void filterMain(float t){}\n');
18746
+ shader.cacheId += '+' + ((_e = props.filter) === null || _e === void 0 ? void 0 : _e.name);
18747
+ }
18748
+ marcos.push(['VERT_CURVE_VALUE_COUNT', vertexKeyFrameMeta.index], ['FRAG_CURVE_VALUE_COUNT', fragmentKeyFrameMeta.index], ['VERT_MAX_KEY_FRAME_COUNT', vertexKeyFrameMeta.max], ['FRAG_MAX_KEY_FRAME_COUNT', fragmentKeyFrameMeta.max]);
18749
+ return { shader: shader, vertex: vertexKeyFrameMeta.index, fragment: fragmentKeyFrameMeta.index };
18750
+ }
18751
+ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
18752
+ var _a;
18753
+ var shaderIds = (_a = shader.cacheId) === null || _a === void 0 ? void 0 : _a.split('+');
18754
+ shaderIds[3] = maxVertex;
18755
+ shaderIds[5] = maxFrag;
18756
+ shader.cacheId = shaderIds.join('+');
18757
+ if (!shader.marcos) {
18758
+ return;
18759
+ }
18760
+ for (var i = 0; i < shader.marcos.length; i++) {
18761
+ var marco = shader.marcos[i];
18762
+ if (marco[0] === 'VERT_CURVE_VALUE_COUNT') {
18763
+ marco[1] = maxVertex;
18764
+ }
18765
+ else if (marco[0] === 'FRAG_CURVE_VALUE_COUNT') {
18766
+ marco[1] = maxFrag;
18767
+ break;
18768
+ }
18769
+ }
18770
+ }
18328
18771
 
18329
18772
  var ParticleLoader = /** @class */ (function (_super) {
18330
18773
  __extends(ParticleLoader, _super);
@@ -18658,14 +19101,14 @@ var TextMesh = /** @class */ (function (_super) {
18658
19101
  for (var y_1 = 0; y_1 < row; y_1++) {
18659
19102
  var base = (y_1 * 2 + x_1) * 4;
18660
19103
  // @ts-expect-error
18661
- var split_1 = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y_1 * 2 + x_1];
18662
- var texOffset = split_1[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
19104
+ var split = textureSheetAnimation ? [0, 0, 1, 1, splits[0][4]] : splits[y_1 * 2 + x_1];
19105
+ var texOffset = split[4] ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
18663
19106
  var dw = ((x_1 + x_1 + 1) / col - 1) / 2;
18664
19107
  var dh = ((y_1 + y_1 + 1) / row - 1) / 2;
18665
- var tox = split_1[0];
18666
- var toy = split_1[1];
18667
- var tsx = split_1[4] ? split_1[3] : split_1[2];
18668
- var tsy = split_1[4] ? split_1[2] : split_1[3];
19108
+ var tox = split[0];
19109
+ var toy = split[1];
19110
+ var tsx = split[4] ? split[3] : split[2];
19111
+ var tsy = split[4] ? split[2] : split[3];
18669
19112
  var origin_1 = [
18670
19113
  originData[0] / col + dw,
18671
19114
  originData[1] / row + dh,
@@ -21575,7 +22018,7 @@ var filters = {
21575
22018
  * Name: @galacean/effects-specification
21576
22019
  * Description: Galacean Effects JSON Specification
21577
22020
  * Author: Ant Group CO., Ltd.
21578
- * Version: v1.1.0
22021
+ * Version: v1.2.0-beta.0
21579
22022
  */
21580
22023
 
21581
22024
  /*********************************************/
@@ -22336,15 +22779,27 @@ function ensureFixedNumber(a) {
22336
22779
  return [ValueType.CONSTANT, a];
22337
22780
  }
22338
22781
  if (a) {
22339
- if (a[0] === 'lines') {
22782
+ var valueType = a[0];
22783
+ var valueData = a[1];
22784
+ if (Array.isArray(valueType)) {
22785
+ // 没有数据类型的数据
22786
+ return;
22787
+ }
22788
+ if (valueType === 'static' || valueType === ValueType.CONSTANT) {
22789
+ return [ValueType.CONSTANT, a[1]];
22790
+ }
22791
+ if (valueType === 'lines') {
22340
22792
  return [ValueType.LINE, a[1]];
22341
22793
  }
22342
- if (a[0] === 'curve') {
22343
- return [ValueType.CURVE, a[1]];
22794
+ if (valueType === ValueType.LINE) {
22795
+ // @ts-expect-error
22796
+ var keyframes = valueData.map(function (data) { return [BezierKeyframeType.LINE, data]; });
22797
+ return [ValueType.BEZIER_CURVE, keyframes];
22344
22798
  }
22345
- if (a[0] === 'static') {
22346
- return [ValueType.CONSTANT, a[1]];
22799
+ if (valueType === 'curve' || valueType === ValueType.CURVE) {
22800
+ return [ValueType.BEZIER_CURVE, getBezierCurveFromHermiteInGE(valueData)];
22347
22801
  }
22802
+ return a;
22348
22803
  }
22349
22804
  }
22350
22805
  function ensureFixedNumberWithRandom(a, p) {
@@ -22370,6 +22825,7 @@ function ensureColorExpression(a, normalized) {
22370
22825
  else if (a[0] === 'color') {
22371
22826
  return [ValueType.RGBA_COLOR, colorToArr(a[1], normalized)];
22372
22827
  }
22828
+ return a;
22373
22829
  }
22374
22830
  }
22375
22831
  function ensureNumberExpression(a) {
@@ -22437,6 +22893,9 @@ function parsePercent(c) {
22437
22893
  }
22438
22894
  function getGradientColor(color, normalized) {
22439
22895
  if (Array.isArray(color)) {
22896
+ if (color[0] === ValueType.GRADIENT_COLOR) {
22897
+ return color;
22898
+ }
22440
22899
  // @ts-expect-error
22441
22900
  return (color[0] === 'gradient' || color[0] === 'color') && ensureGradient(color[1], normalized);
22442
22901
  }
@@ -22449,12 +22908,36 @@ function ensureFixedVec3(a) {
22449
22908
  if (a.length === 3) {
22450
22909
  return [ValueType.CONSTANT_VEC3, a];
22451
22910
  }
22452
- if (a[0] === 'path') {
22453
- return [ValueType.LINEAR_PATH, a[1]];
22454
- }
22455
- if (a[0] === 'bezier') {
22456
- return [ValueType.BEZIER_PATH, a[1]];
22911
+ var valueType = a[0];
22912
+ if (valueType === 'path' ||
22913
+ valueType === 'bezier' ||
22914
+ valueType === ValueType.BEZIER_PATH ||
22915
+ valueType === ValueType.LINEAR_PATH) {
22916
+ var valueData = a[1];
22917
+ var easing = valueData[0];
22918
+ var points = valueData[1];
22919
+ var controlPoints = valueData[2];
22920
+ var bezierEasing = getBezierCurveFromHermiteInGE(easing);
22921
+ // linear path没有controlPoints
22922
+ if (!controlPoints) {
22923
+ controlPoints = [];
22924
+ for (var keyframeIndex = 0; keyframeIndex < points.length; keyframeIndex++) {
22925
+ var point = points[keyframeIndex].slice();
22926
+ if (keyframeIndex === 0) {
22927
+ controlPoints.push(point);
22928
+ }
22929
+ else if (keyframeIndex < points.length - 1) {
22930
+ controlPoints.push(point);
22931
+ controlPoints.push(point);
22932
+ }
22933
+ else {
22934
+ controlPoints.push(point);
22935
+ }
22936
+ }
22937
+ }
22938
+ return [ValueType.BEZIER_CURVE_PATH, [bezierEasing, points, controlPoints]];
22457
22939
  }
22940
+ return a;
22458
22941
  }
22459
22942
  }
22460
22943
  function objectValueToNumber(o) {
@@ -22544,6 +23027,50 @@ function rotationZYXFromQuat(out, quat) {
22544
23027
  }
22545
23028
  return out;
22546
23029
  }
23030
+ function getBezierCurveFromHermite(m0, m1, p0, p3) {
23031
+ var xStart = p0[0];
23032
+ var yStart = p0[1];
23033
+ var xEnd = p3[0];
23034
+ var yEnd = p3[1];
23035
+ var dt = xEnd - xStart;
23036
+ m0 = m0 * dt;
23037
+ m1 = m1 * dt;
23038
+ var bezierControlPoints = [[xStart + (xEnd - xStart) / 3, yStart + m0 / 3], [xEnd - (xEnd - xStart) / 3, yEnd - m1 / 3]];
23039
+ return bezierControlPoints;
23040
+ }
23041
+ function getBezierCurveFromHermiteInGE(geHermiteCurves) {
23042
+ var ymax = -1000000;
23043
+ var ymin = 1000000;
23044
+ for (var i = 0; i < geHermiteCurves.length; i++) {
23045
+ ymax = Math.max(ymax, geHermiteCurves[i][1]);
23046
+ ymin = Math.min(ymin, geHermiteCurves[i][1]);
23047
+ }
23048
+ var geBezierCurves = [[geHermiteCurves[0][0], geHermiteCurves[0][1]]];
23049
+ for (var i = 0; i < geHermiteCurves.length - 1; i++) {
23050
+ var m0 = geHermiteCurves[i][3] * (ymax - ymin);
23051
+ var m1 = geHermiteCurves[i + 1][2] * (ymax - ymin);
23052
+ var p0 = [geHermiteCurves[i][0], geHermiteCurves[i][1]];
23053
+ var p3 = [geHermiteCurves[i + 1][0], geHermiteCurves[i + 1][1]];
23054
+ if (p0[0] != p3[0]) {
23055
+ var bezierControlPoints = getBezierCurveFromHermite(m0, m1, p0, p3);
23056
+ var p1 = bezierControlPoints[0];
23057
+ var p2 = bezierControlPoints[1];
23058
+ geBezierCurves[geBezierCurves.length - 1].push(p1[0]);
23059
+ geBezierCurves[geBezierCurves.length - 1].push(p1[1]);
23060
+ geBezierCurves.push([p2[0], p2[1], p3[0], p3[1]]);
23061
+ }
23062
+ else {
23063
+ geBezierCurves[geBezierCurves.length - 1].push(p3[0]);
23064
+ geBezierCurves[geBezierCurves.length - 1].push(p3[1]);
23065
+ }
23066
+ }
23067
+ // 添加关键帧类型
23068
+ return geBezierCurves.map(function (curve, index) {
23069
+ return index === 0 ? [BezierKeyframeType.EASE_OUT, curve]
23070
+ : index === geBezierCurves.length - 1 ? [BezierKeyframeType.EASE_IN, curve]
23071
+ : [BezierKeyframeType.EASE, curve];
23072
+ });
23073
+ }
22547
23074
 
22548
23075
  function getStandardParticleContent(particle) {
22549
23076
  var _a;
@@ -22955,12 +23482,63 @@ function version22Migration(json) {
22955
23482
  });
22956
23483
  return json;
22957
23484
  }
23485
+ /**
23486
+ * 2.5 以下版本 赫尔米特数据转换成贝塞尔数据
23487
+ */
23488
+ function version24Migration(json) {
23489
+ // 曲线转换成贝塞尔
23490
+ json.compositions.map(function (comp) {
23491
+ var e_1, _a;
23492
+ try {
23493
+ for (var _b = __values(comp.items), _c = _b.next(); !_c.done; _c = _b.next()) {
23494
+ var item = _c.value;
23495
+ convertParam(item.content);
23496
+ }
23497
+ }
23498
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
23499
+ finally {
23500
+ try {
23501
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
23502
+ }
23503
+ finally { if (e_1) throw e_1.error; }
23504
+ }
23505
+ });
23506
+ return json;
23507
+ }
23508
+ function convertParam(content) {
23509
+ var e_2, _a;
23510
+ try {
23511
+ for (var _b = __values(Object.keys(content)), _c = _b.next(); !_c.done; _c = _b.next()) {
23512
+ var key = _c.value;
23513
+ var value = content[key];
23514
+ var isArray = Array.isArray(value);
23515
+ if (isArray && value.length === 2 && Array.isArray(value[1])) {
23516
+ if (key === 'path') {
23517
+ content[key] = ensureFixedVec3(value);
23518
+ }
23519
+ else {
23520
+ content[key] = ensureFixedNumber(value);
23521
+ }
23522
+ }
23523
+ else if (!isArray && typeof value === 'object') {
23524
+ convertParam(value);
23525
+ }
23526
+ }
23527
+ }
23528
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
23529
+ finally {
23530
+ try {
23531
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
23532
+ }
23533
+ finally { if (e_2) throw e_2.error; }
23534
+ }
23535
+ }
22958
23536
 
22959
23537
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
22960
23538
  var standardVersion = /^(\d+)\.(\d+)$/;
22961
23539
  var reverseParticle = false;
22962
23540
  function getStandardJSON(json) {
22963
- var _a, _b;
23541
+ var _a;
22964
23542
  if (!json || typeof json !== 'object') {
22965
23543
  throw Error('expect a json object');
22966
23544
  }
@@ -22970,9 +23548,14 @@ function getStandardJSON(json) {
22970
23548
  reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
22971
23549
  return version21Migration(getStandardJSONFromV0(json));
22972
23550
  }
22973
- var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
23551
+ var vs = standardVersion.exec(json.version) || [];
23552
+ var mainVersion = Number(vs[1]);
23553
+ var minorVersion = Number(vs[2]);
22974
23554
  if (mainVersion) {
22975
- if (Number(mainVersion) < 2) {
23555
+ if (mainVersion < 2 || (mainVersion === 2 && minorVersion < 4)) {
23556
+ version24Migration(json);
23557
+ }
23558
+ if (mainVersion < 2) {
22976
23559
  return version21Migration(json);
22977
23560
  }
22978
23561
  return json;
@@ -23345,13 +23928,13 @@ var CompositionSourceManager = /** @class */ (function () {
23345
23928
  if (renderContent.renderer) {
23346
23929
  renderContent.renderer = _this.changeTex(renderContent.renderer);
23347
23930
  _this.processMask(renderContent.renderer);
23348
- var split_1 = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
23931
+ var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
23349
23932
  if (Number.isInteger(renderContent.renderer.shape)) {
23350
23933
  // TODO: scene.shapes 类型问题?
23351
- renderContent.renderer.shape = getGeometryByShape((_a = _this.jsonScene) === null || _a === void 0 ? void 0 : _a.shapes[renderContent.renderer.shape], split_1);
23934
+ renderContent.renderer.shape = getGeometryByShape((_a = _this.jsonScene) === null || _a === void 0 ? void 0 : _a.shapes[renderContent.renderer.shape], split);
23352
23935
  }
23353
23936
  else if (renderContent.renderer.shape && isObject(renderContent.renderer.shape)) {
23354
- renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split_1);
23937
+ renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split);
23355
23938
  }
23356
23939
  }
23357
23940
  else {
@@ -23363,14 +23946,14 @@ var CompositionSourceManager = /** @class */ (function () {
23363
23946
  if (renderContent.filter) {
23364
23947
  renderContent.filter = __assign$1({}, renderContent.filter);
23365
23948
  }
23366
- var name_1 = item.name, _b = item.delay, delay = _b === void 0 ? 0 : _b, id_1 = item.id, parentId = item.parentId, duration = item.duration, endBehavior = item.endBehavior, pluginName = item.pluginName, pn = item.pn, transform = item.transform;
23949
+ var name_1 = item.name, _b = item.delay, delay = _b === void 0 ? 0 : _b, id = item.id, parentId = item.parentId, duration = item.duration, endBehavior = item.endBehavior, pluginName = item.pluginName, pn = item.pn, transform = item.transform;
23367
23950
  // FIXME: specification 下定义的 Item 不存在 refCount 类型定义
23368
23951
  // @ts-expect-error
23369
23952
  var refCount = item.refCount;
23370
23953
  var _c = _this.jsonScene.plugins, plugins = _c === void 0 ? [] : _c;
23371
23954
  option.name = name_1;
23372
23955
  option.delay = delay;
23373
- option.id = id_1;
23956
+ option.id = id;
23374
23957
  if (parentId) {
23375
23958
  option.parentId = parentId;
23376
23959
  }
@@ -23832,8 +24415,8 @@ var AssetManager = /** @class */ (function () {
23832
24415
  return [2 /*return*/, resultImage];
23833
24416
  case 3:
23834
24417
  // 如果是加载图片且是数组,设置变量,视频情况下不需要
23835
- if (background && !Array.isArray(url_1) && variables) {
23836
- variables[background.name] = url_1;
24418
+ if (background && Array.isArray(url_1) && variables) {
24419
+ variables[background.name] = resultImage.src;
23837
24420
  }
23838
24421
  return [4 /*yield*/, combineImageTemplate(resultImage, template, variables, this.options, img.oriY === -1)];
23839
24422
  case 4: return [2 /*return*/, _b.sent()];
@@ -23981,14 +24564,14 @@ var AssetManager = /** @class */ (function () {
23981
24564
  }());
23982
24565
  function fixOldImageUsage(usedImages, compositions, imgUsage, images, renderLevel) {
23983
24566
  for (var i = 0; i < compositions.length; i++) {
23984
- var id_1 = compositions[i].id;
23985
- var ids = imgUsage[id_1];
24567
+ var id = compositions[i].id;
24568
+ var ids = imgUsage[id];
23986
24569
  if (ids) {
23987
24570
  for (var j = 0; j < ids.length; j++) {
23988
- var id_2 = ids[j];
23989
- var tag = images[id_2].renderLevel;
24571
+ var id_1 = ids[j];
24572
+ var tag = images[id_1].renderLevel;
23990
24573
  if (passRenderLevel(tag, renderLevel)) {
23991
- usedImages[id_2] = true;
24574
+ usedImages[id_1] = true;
23992
24575
  }
23993
24576
  }
23994
24577
  }
@@ -26269,10 +26852,10 @@ var ThreeTexture = /** @class */ (function (_super) {
26269
26852
  var texture = undefined;
26270
26853
  this.sourceType = sourceType;
26271
26854
  if (sourceType === TextureSourceType.data) {
26272
- var data_1 = options.data;
26273
- texture = new THREE.DataTexture(data_1.data, data_1.width, data_1.height, format, type, mapping, wrapS, wrapT, magFilter, minFilter);
26274
- this.width = data_1.width;
26275
- this.height = data_1.height;
26855
+ var data = options.data;
26856
+ texture = new THREE.DataTexture(data.data, data.width, data.height, format, type, mapping, wrapS, wrapT, magFilter, minFilter);
26857
+ this.width = data.width;
26858
+ this.height = data.height;
26276
26859
  }
26277
26860
  else if (sourceType === TextureSourceType.image) {
26278
26861
  var image = options.image;
@@ -26304,10 +26887,10 @@ var ThreeTexture = /** @class */ (function (_super) {
26304
26887
  texture = new THREE.VideoTexture(options.video, mapping, wrapS, wrapT, magFilter, minFilter, format, type);
26305
26888
  }
26306
26889
  else if (sourceType === TextureSourceType.framebuffer) {
26307
- var data_2 = options.data;
26308
- if (data_2) {
26309
- var width = (_a = data_2.width) !== null && _a !== void 0 ? _a : 0;
26310
- var height = (_b = data_2.height) !== null && _b !== void 0 ? _b : 0;
26890
+ var data = options.data;
26891
+ if (data) {
26892
+ var width = (_a = data.width) !== null && _a !== void 0 ? _a : 0;
26893
+ var height = (_b = data.height) !== null && _b !== void 0 ? _b : 0;
26311
26894
  texture = new THREE.FramebufferTexture(width, height, format);
26312
26895
  this.width = width;
26313
26896
  this.height = height;
@@ -26443,11 +27026,11 @@ var ThreeGeometry = /** @class */ (function (_super) {
26443
27026
  if (attributes[dataSource] === undefined) {
26444
27027
  _this.setAttributeType(dataSource, attr, geometry, attributes, props.maxVertex);
26445
27028
  }
26446
- var size = attr.size, offset = attr.offset, normalize_1 = attr.normalize;
27029
+ var size = attr.size, offset = attr.offset, normalize = attr.normalize;
26447
27030
  var dataSourceAttribute = attributes[dataSource];
26448
27031
  var buffer = dataSourceAttribute.buffer;
26449
27032
  var dataLength = dataSourceAttribute.dataLength;
26450
- var attribute = new THREE.InterleavedBufferAttribute(buffer, size, (offset !== null && offset !== void 0 ? offset : 0) / dataLength, normalize_1);
27033
+ var attribute = new THREE.InterleavedBufferAttribute(buffer, size, (offset !== null && offset !== void 0 ? offset : 0) / dataLength, normalize);
26451
27034
  geometry.setAttribute(name, attribute);
26452
27035
  attributes[name] = {
26453
27036
  buffer: buffer,
@@ -26938,8 +27521,8 @@ Geometry.create = function (engine, options) {
26938
27521
  Mesh.create = function (engine, props) {
26939
27522
  return new ThreeMesh(engine, props);
26940
27523
  };
26941
- var version = "1.3.0";
27524
+ var version = "1.4.0-beta.0";
26942
27525
  logger.info('THREEJS plugin version: ' + version);
26943
27526
 
26944
- export { AbstractPlugin, AssetManager, BYTES_TYPE_MAP, BezierSegments, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateItem, CalculateLoader, CalculateVFXItem, Camera, CameraController, CameraVFXItem, CameraVFXItemLoader, Composition, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, FilterSpriteVFXItem, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractItem, InteractLoader, InteractMesh, InteractVFXItem, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleLoader, ParticleMesh, ParticleSystem, ParticleVFXItem, PassTextureCache, PathSegments, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, Shader, ShaderCompileResultStatus, ShaderType, SpriteItem, SpriteLoader, SpriteMesh, SpriteVFXItem, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextItem, TextLoader, TextMesh, TextVFXItem, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeMaterial, ThreeTexture, Ticker, TimelineComponent, Transform, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrameFrag, alphaMaskFrag, assertExist, asserts, blend, bloomMixVert, bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, convertAnchor, copyFrag, createCopyShader, createFilter, createFilterShaders, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delayFrag, deserializeMipmapTexture, distortionFrag, distortionVert, earcut, enlargeBuffer, ensureVec3, filters, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isFunction, isIOS, isObject, isScene, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isWebGL2, item_define as itemDefine, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleVert, pluginLoaderMap, random, registerFilter, registerFilters, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };
27527
+ export { AbstractPlugin, AssetManager, BYTES_TYPE_MAP, BezierCurve, BezierCurvePath, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateItem, CalculateLoader, CalculateVFXItem, Camera, CameraController, CameraVFXItem, CameraVFXItemLoader, Composition, CompositionSourceManager, DEFAULT_FONTS, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, FilterSpriteVFXItem, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractItem, InteractLoader, InteractMesh, InteractVFXItem, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleLoader, ParticleMesh, ParticleSystem, ParticleVFXItem, PassTextureCache, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, Shader, ShaderCompileResultStatus, ShaderType, SpriteItem, SpriteLoader, SpriteMesh, SpriteVFXItem, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextItem, TextLoader, TextMesh, TextVFXItem, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeMaterial, ThreeTexture, Ticker, TimelineComponent, Transform, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrameFrag, alphaMaskFrag, assertExist, asserts, blend, bloomMixVert, bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, convertAnchor, copyFrag, createCopyShader, createFilter, createFilterShaders, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, decimalEqual, deepClone, defaultGlobalVolume, defaultPlugins, delayFrag, deserializeMipmapTexture, distortionFrag, distortionVert, earcut, enlargeBuffer, ensureVec3, filters, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isFunction, isIOS, isObject, isScene, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isWebGL2, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, pointOnLine, random, registerFilter, registerFilters, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };
26945
27528
  //# sourceMappingURL=index.mjs.map