@galacean/effects 1.3.1 → 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/weapp.mjs CHANGED
@@ -676,7 +676,7 @@ function asserts(condition, msg) {
676
676
  * Name: @galacean/effects-specification
677
677
  * Description: Galacean Effects JSON Specification
678
678
  * Author: Ant Group CO., Ltd.
679
- * Version: v1.1.0
679
+ * Version: v1.2.0-beta.0
680
680
  */
681
681
 
682
682
  /*********************************************/
@@ -7293,6 +7293,448 @@ function trianglesFromRect(position, halfWidth, halfHeight) {
7293
7293
  { p0: p0.clone(), p1: p2.clone(), p2: p3 },
7294
7294
  ];
7295
7295
  }
7296
+ function decimalEqual(a, b, epsilon) {
7297
+ if (epsilon === void 0) { epsilon = 0.000001; }
7298
+ return Math.abs(a - b) < epsilon;
7299
+ }
7300
+ function numberToFix(a, fixed) {
7301
+ if (fixed === void 0) { fixed = 2; }
7302
+ var base = Math.pow(10, fixed);
7303
+ return Math.floor(a * base) / base;
7304
+ }
7305
+ function pointOnLine(x1, y1, x2, y2, x3, y3) {
7306
+ var det1 = (x1 * y2) + (y1 * x3) + (x2 * y3) - (x3 * y2) - (y3 * x1) - (x2 * y1);
7307
+ return det1 > -0.001 && det1 < 0.001;
7308
+ }
7309
+
7310
+ var keyframeInfo = {
7311
+ /**
7312
+ * 根据不同关键帧类型,获取位于曲线上的点
7313
+ */
7314
+ getPointInCurve: function (keyframe) {
7315
+ var _a = __read$3(keyframe, 2); _a[0]; var data = _a[1];
7316
+ var _b = this.getPointIndexInCurve(keyframe), xIndex = _b.xIndex, yIndex = _b.yIndex;
7317
+ var time = data[xIndex];
7318
+ var value = data[yIndex];
7319
+ return new Vector2(time, value);
7320
+ },
7321
+ /**
7322
+ * 根据不同关键帧类型,获取位于曲线上的点的索引
7323
+ */
7324
+ getPointIndexInCurve: function (keyframe) {
7325
+ var _a = __read$3(keyframe, 3), type = _a[0], markType = _a[2];
7326
+ // 不同类型,存放的时间不同
7327
+ var index = type === BezierKeyframeType$1.LINE ? 0
7328
+ : type === BezierKeyframeType$1.EASE_OUT ? 0
7329
+ : type === BezierKeyframeType$1.EASE_IN ? 2
7330
+ : type === BezierKeyframeType$1.EASE ? 2
7331
+ : type === BezierKeyframeType$1.HOLD ? (markType === BezierKeyframeType$1.EASE_IN ? 2 : 0)
7332
+ : 0;
7333
+ return { xIndex: index, yIndex: index + 1 };
7334
+ },
7335
+ /**
7336
+ * 关键帧左侧是否为缓动类型(否则为线段)
7337
+ */
7338
+ isLeftSideEase: function (keyframe) {
7339
+ var _a = __read$3(keyframe, 3), keyframeType = _a[0]; _a[1]; var markType = _a[2];
7340
+ // 定格关键帧的左侧类型,需要借助markType判断
7341
+ if (keyframeType === BezierKeyframeType$1.HOLD && this.isKeyframeTypeLeftSideEase(markType)) {
7342
+ return true;
7343
+ }
7344
+ return this.isKeyframeTypeLeftSideEase(keyframeType);
7345
+ },
7346
+ /**
7347
+ * 关键帧右侧是否为缓动类型(否则为线段)
7348
+ */
7349
+ isRightSideEase: function (keyframe) {
7350
+ var _a = __read$3(keyframe, 3), keyframeType = _a[0]; _a[1]; var markType = _a[2];
7351
+ // 定格关键帧的右侧类型,需要借助markType判断
7352
+ if (keyframeType === BezierKeyframeType$1.HOLD && this.isKeyframeTypeRightSideEase(markType)) {
7353
+ return true;
7354
+ }
7355
+ return this.isKeyframeTypeRightSideEase(keyframeType);
7356
+ },
7357
+ /**
7358
+ * 关键帧左侧是否为缓动类型(否则为线段)
7359
+ */
7360
+ isKeyframeTypeLeftSideEase: function (keyframeType) {
7361
+ return [BezierKeyframeType$1.EASE, BezierKeyframeType$1.EASE_IN, BezierKeyframeType$1.AUTO].includes(keyframeType);
7362
+ },
7363
+ /**
7364
+ * 关键帧右侧是否为缓动类型(否则为线段)
7365
+ */
7366
+ isKeyframeTypeRightSideEase: function (keyframeType) {
7367
+ return [BezierKeyframeType$1.EASE, BezierKeyframeType$1.EASE_OUT, BezierKeyframeType$1.AUTO].includes(keyframeType);
7368
+ },
7369
+ /**
7370
+ * 是否为定格进关键帧
7371
+ */
7372
+ isHoldInKeyframe: function (keyframe) {
7373
+ var _a = __read$3(keyframe, 3), keyframeType = _a[0]; _a[1]; var leftSubType = _a[2];
7374
+ return keyframeType === BezierKeyframeType$1.HOLD && [BezierKeyframeType$1.HOLD, BezierKeyframeType$1.LINE_OUT, BezierKeyframeType$1.EASE_OUT].includes(leftSubType);
7375
+ },
7376
+ /**
7377
+ * 是否为定格出关键帧
7378
+ */
7379
+ isHoldOutKeyframe: function (keyframe) {
7380
+ var _a = __read$3(keyframe, 3), keyframeType = _a[0]; _a[1]; var leftSubType = _a[2];
7381
+ return keyframeType === BezierKeyframeType$1.HOLD && [BezierKeyframeType$1.HOLD, BezierKeyframeType$1.LINE, BezierKeyframeType$1.EASE_IN].includes(leftSubType);
7382
+ },
7383
+ };
7384
+
7385
+ var BezierLengthData = /** @class */ (function () {
7386
+ function BezierLengthData(points, totalLength) {
7387
+ this.points = points;
7388
+ this.totalLength = totalLength;
7389
+ }
7390
+ return BezierLengthData;
7391
+ }());
7392
+ var BezierMap = {};
7393
+ var BezierDataMap = {};
7394
+ var NEWTON_ITERATIONS = 4;
7395
+ var NEWTON_MIN_SLOPE = 0.001;
7396
+ var SUBDIVISION_PRECISION = 0.0000001;
7397
+ var SUBDIVISION_MAX_ITERATIONS = 10;
7398
+ var CURVE_SEGMENTS = 300;
7399
+ var kSplineTableSize = 11;
7400
+ var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
7401
+ function A(a1, a2) { return 1.0 - 3.0 * a2 + 3.0 * a1; }
7402
+ function B(a1, a2) { return 3.0 * a2 - 6.0 * a1; }
7403
+ function C(a1) { return 3.0 * a1; }
7404
+ // A * t ^ 3 + B * t ^ 2 + C * t
7405
+ // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
7406
+ function calcBezier(t, a1, a2) {
7407
+ return ((A(a1, a2) * t + B(a1, a2)) * t + C(a1)) * t;
7408
+ }
7409
+ // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
7410
+ function getSlope(t, a1, a2) {
7411
+ return 3.0 * A(a1, a2) * t * t + 2.0 * B(a1, a2) * t + C(a1);
7412
+ }
7413
+ function binarySubdivide(aX, aA, aB, mX1, mX2) {
7414
+ var currentX, currentT, i = 0;
7415
+ do {
7416
+ currentT = aA + (aB - aA) / 2.0;
7417
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
7418
+ if (currentX > 0.0) {
7419
+ aB = currentT;
7420
+ }
7421
+ else {
7422
+ aA = currentT;
7423
+ }
7424
+ } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
7425
+ return currentT;
7426
+ }
7427
+ function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
7428
+ for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
7429
+ var currentSlope = getSlope(aGuessT, mX1, mX2);
7430
+ if (currentSlope === 0.0) {
7431
+ return aGuessT;
7432
+ }
7433
+ var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
7434
+ aGuessT -= currentX / currentSlope;
7435
+ }
7436
+ return aGuessT;
7437
+ }
7438
+ // de Casteljau算法构建曲线
7439
+ /**
7440
+ * @param p1 起始点
7441
+ * @param p2 终点
7442
+ * @param p3 起始控制点
7443
+ * @param p4 终止控制点
7444
+ * @returns
7445
+ */
7446
+ function buildBezierData(p1, p2, p3, p4) {
7447
+ // 使用平移后的终点、控制点作为key
7448
+ var s1 = numberToFix(p2.x - p1.x, 3) + '_' + numberToFix(p2.y - p1.y, 3) + '_' + numberToFix(p2.z - p1.z, 3);
7449
+ var s2 = numberToFix(p3.x - p1.x, 3) + '_' + numberToFix(p3.y - p1.y, 3) + '_' + numberToFix(p3.z - p1.z, 3);
7450
+ var s3 = numberToFix(p4.x - p1.x, 3) + '_' + numberToFix(p4.y - p1.y, 3) + '_' + numberToFix(p4.z - p1.z, 3);
7451
+ var str = s1 + '&' + s2 + '&' + s3;
7452
+ if (BezierDataMap[str]) {
7453
+ return {
7454
+ data: BezierDataMap[str],
7455
+ interval: p1,
7456
+ };
7457
+ }
7458
+ else {
7459
+ var samples = [];
7460
+ var lastPoint = null, addedLength = 0, ptDistance = 0;
7461
+ var curveSegments = CURVE_SEGMENTS;
7462
+ for (var k = 0; k < curveSegments; k += 1) {
7463
+ var point = new Vector3();
7464
+ var perc = k / (curveSegments - 1);
7465
+ ptDistance = 0;
7466
+ 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);
7467
+ 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);
7468
+ 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);
7469
+ if (lastPoint !== null) {
7470
+ ptDistance += Math.pow(point.x - lastPoint.x, 2);
7471
+ ptDistance += Math.pow(point.y - lastPoint.y, 2);
7472
+ ptDistance += Math.pow(point.z - lastPoint.z, 2);
7473
+ }
7474
+ lastPoint = point;
7475
+ ptDistance = Math.sqrt(ptDistance);
7476
+ addedLength += ptDistance;
7477
+ samples[k] = {
7478
+ partialLength: ptDistance,
7479
+ point: point,
7480
+ };
7481
+ }
7482
+ var data = new BezierLengthData(samples, addedLength);
7483
+ BezierDataMap[str] = data;
7484
+ return {
7485
+ data: data,
7486
+ interval: new Vector3(p1.x, p1.y, p1.z),
7487
+ };
7488
+ }
7489
+ }
7490
+ var BezierPath = /** @class */ (function () {
7491
+ function BezierPath(p1, p2, p3, p4) {
7492
+ this.p1 = p1;
7493
+ this.p2 = p2;
7494
+ this.p3 = p3;
7495
+ this.p4 = p4;
7496
+ this.catching = {
7497
+ lastPoint: 0,
7498
+ lastAddedLength: 0,
7499
+ };
7500
+ var _a = buildBezierData(p1, p2, p3, p4), data = _a.data, interval = _a.interval;
7501
+ this.lengthData = data;
7502
+ this.interval = interval;
7503
+ this.totalLength = data.totalLength;
7504
+ }
7505
+ /**
7506
+ * 获取路径在指定比例长度上点的坐标
7507
+ * @param percent 路径长度的比例
7508
+ */
7509
+ BezierPath.prototype.getPointInPercent = function (percent) {
7510
+ var bezierData = this.lengthData;
7511
+ if (percent === 0) {
7512
+ return bezierData.points[0].point.clone().add(this.interval);
7513
+ }
7514
+ if (decimalEqual(1 - percent, 0)) {
7515
+ return bezierData.points[CURVE_SEGMENTS - 1].point.clone().add(this.interval);
7516
+ }
7517
+ if (decimalEqual(bezierData.totalLength, 0)) {
7518
+ return this.p1.clone();
7519
+ }
7520
+ var point = new Vector3();
7521
+ var segmentLength = numberToFix(bezierData.totalLength * percent, 4);
7522
+ var addedLength = this.catching.lastAddedLength;
7523
+ var j = this.catching.lastPoint;
7524
+ if (decimalEqual(addedLength, segmentLength)) {
7525
+ return bezierData.points[j].point.clone().add(this.interval);
7526
+ }
7527
+ var flag = true;
7528
+ var dir = 1;
7529
+ if (segmentLength < addedLength) {
7530
+ dir = -1;
7531
+ }
7532
+ while (flag) {
7533
+ if (segmentLength >= addedLength) {
7534
+ if (j === CURVE_SEGMENTS - 1) {
7535
+ point.x = bezierData.points[j].point.x;
7536
+ point.y = bezierData.points[j].point.y;
7537
+ point.z = bezierData.points[j].point.z;
7538
+ break;
7539
+ }
7540
+ if (segmentLength < addedLength + bezierData.points[j + 1].partialLength) {
7541
+ var segmentPerc = (segmentLength - addedLength) / bezierData.points[j + 1].partialLength;
7542
+ point.x = bezierData.points[j].point.x + (bezierData.points[j + 1].point.x - bezierData.points[j].point.x) * segmentPerc;
7543
+ point.y = bezierData.points[j].point.y + (bezierData.points[j + 1].point.y - bezierData.points[j].point.y) * segmentPerc;
7544
+ point.z = bezierData.points[j].point.z + (bezierData.points[j + 1].point.z - bezierData.points[j].point.z) * segmentPerc;
7545
+ break;
7546
+ }
7547
+ }
7548
+ if (dir > 0 && j < (CURVE_SEGMENTS - 1)) {
7549
+ j += dir;
7550
+ addedLength += numberToFix(bezierData.points[j].partialLength, 5);
7551
+ }
7552
+ else if (dir < 0 && j > 0) {
7553
+ addedLength -= numberToFix(bezierData.points[j].partialLength, 5);
7554
+ j += dir;
7555
+ }
7556
+ else {
7557
+ flag = false;
7558
+ }
7559
+ }
7560
+ this.catching.lastPoint = j;
7561
+ this.catching.lastAddedLength = addedLength;
7562
+ point.add(this.interval);
7563
+ return point;
7564
+ };
7565
+ return BezierPath;
7566
+ }());
7567
+ var BezierEasing = /** @class */ (function () {
7568
+ function BezierEasing(mX1, mY1, mX2, mY2) {
7569
+ this.mX1 = mX1;
7570
+ this.mY1 = mY1;
7571
+ this.mX2 = mX2;
7572
+ this.mY2 = mY2;
7573
+ this.precomputed = false;
7574
+ this.mSampleValues = new Array(kSplineTableSize);
7575
+ this.cachingValue = {};
7576
+ }
7577
+ BezierEasing.prototype.precompute = function () {
7578
+ this.precomputed = true;
7579
+ if (this.mX1 !== this.mY1 || this.mX2 !== this.mY2) {
7580
+ this.calcSampleValues();
7581
+ }
7582
+ };
7583
+ BezierEasing.prototype.getValue = function (x) {
7584
+ if (this.mX1 === this.mY1 && this.mX2 === this.mY2) {
7585
+ return x;
7586
+ }
7587
+ if (isNaN(this.mY1) || isNaN(this.mY2)) {
7588
+ return 0;
7589
+ }
7590
+ if (x === 0 || x === 1) {
7591
+ return x;
7592
+ }
7593
+ if (!this.precomputed) {
7594
+ this.precompute();
7595
+ }
7596
+ var keys = Object.keys(this.cachingValue);
7597
+ var index = keys.findIndex(function (key) { return decimalEqual(Number(key), x, 0.005); });
7598
+ if (index !== -1) {
7599
+ return this.cachingValue[keys[index]];
7600
+ }
7601
+ var value = calcBezier(this.getTForX(x), this.mY1, this.mY2);
7602
+ if (keys.length < 300) {
7603
+ this.cachingValue[x] = value;
7604
+ }
7605
+ return value;
7606
+ };
7607
+ BezierEasing.prototype.calcSampleValues = function () {
7608
+ for (var i = 0; i < kSplineTableSize; ++i) {
7609
+ this.mSampleValues[i] = calcBezier(i * kSampleStepSize, this.mX1, this.mX2);
7610
+ }
7611
+ };
7612
+ BezierEasing.prototype.getTForX = function (aX) {
7613
+ var mSampleValues = this.mSampleValues, lastSample = kSplineTableSize - 1;
7614
+ var intervalStart = 0, currentSample = 1;
7615
+ for (; currentSample !== lastSample && mSampleValues[currentSample] <= aX; ++currentSample) {
7616
+ intervalStart += kSampleStepSize;
7617
+ }
7618
+ --currentSample;
7619
+ // Interpolate to provide an initial guess for t
7620
+ var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample + 1] - mSampleValues[currentSample]);
7621
+ var guessForT = intervalStart + dist * kSampleStepSize;
7622
+ var initialSlope = getSlope(guessForT, this.mX1, this.mX2);
7623
+ if (initialSlope >= NEWTON_MIN_SLOPE) {
7624
+ return newtonRaphsonIterate(aX, guessForT, this.mX1, this.mX2);
7625
+ }
7626
+ if (initialSlope === 0.0) {
7627
+ return guessForT;
7628
+ }
7629
+ return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, this.mX1, this.mX2);
7630
+ };
7631
+ return BezierEasing;
7632
+ }());
7633
+ function buildEasingCurve(leftKeyframe, rightKeyframe) {
7634
+ // 获取控制点和曲线类型
7635
+ var _a = getControlPoints(leftKeyframe, rightKeyframe, true), p0 = _a.p0, p1 = _a.p1, p2 = _a.p2, p3 = _a.p3;
7636
+ assertExist(p2);
7637
+ assertExist(p3);
7638
+ var timeInterval = p3.x - p0.x;
7639
+ var valueInterval = p3.y - p0.y;
7640
+ var y1, y2;
7641
+ var x1 = numberToFix((p1.x - p0.x) / timeInterval, 5);
7642
+ var x2 = numberToFix((p2.x - p0.x) / timeInterval, 5);
7643
+ if (decimalEqual(valueInterval, 0)) {
7644
+ y1 = y2 = NaN;
7645
+ }
7646
+ else {
7647
+ y1 = numberToFix((p1.y - p0.y) / valueInterval, 5);
7648
+ y2 = numberToFix((p2.y - p0.y) / valueInterval, 5);
7649
+ }
7650
+ if (x1 < 0) {
7651
+ console.error('invalid bezier points, x1 < 0', p0, p1, p2, p3);
7652
+ x1 = 0;
7653
+ }
7654
+ if (x2 < 0) {
7655
+ console.error('invalid bezier points, x2 < 0', p0, p1, p2, p3);
7656
+ x2 = 0;
7657
+ }
7658
+ if (x1 > 1) {
7659
+ console.error('invalid bezier points, x1 >= 1', p0, p1, p2, p3);
7660
+ x1 = 1;
7661
+ }
7662
+ if (x2 > 1) {
7663
+ console.error('invalid bezier points, x2 >= 1', p0, p1, p2, p3);
7664
+ x2 = 1;
7665
+ }
7666
+ var str = ('bez_' + x1 + '_' + y1 + '_' + x2 + '_' + y2).replace(/\./g, 'p');
7667
+ var bezEasing;
7668
+ if (BezierMap[str]) {
7669
+ bezEasing = BezierMap[str];
7670
+ }
7671
+ else {
7672
+ bezEasing = new BezierEasing(x1, y1, x2, y2);
7673
+ BezierMap[str] = bezEasing;
7674
+ }
7675
+ return {
7676
+ points: [p0, p1, p2, p3],
7677
+ timeInterval: timeInterval,
7678
+ valueInterval: valueInterval,
7679
+ curve: bezEasing,
7680
+ };
7681
+ }
7682
+ /**
7683
+ * 根据关键帧类型获取贝塞尔曲线上的关键点
7684
+ */
7685
+ function getControlPoints(leftKeyframe, rightKeyframe, lineToBezier) {
7686
+ var _a = __read$3(leftKeyframe, 2), leftValue = _a[1];
7687
+ var leftHoldLine = keyframeInfo.isHoldOutKeyframe(leftKeyframe);
7688
+ var rightHoldLine = keyframeInfo.isHoldInKeyframe(rightKeyframe);
7689
+ var leftEase = !rightHoldLine && keyframeInfo.isRightSideEase(leftKeyframe);
7690
+ var rightEase = !leftHoldLine && keyframeInfo.isLeftSideEase(rightKeyframe);
7691
+ // 1. 左边为ease,右边为line(补充右边的控制点,该点在曲线上的点的偏左边位置)
7692
+ if (leftEase && !rightEase && !rightHoldLine) {
7693
+ var p0_1 = new Vector2(leftValue[leftValue.length - 4], leftValue[leftValue.length - 3]);
7694
+ var p1_1 = new Vector2(leftValue[leftValue.length - 2], leftValue[leftValue.length - 1]);
7695
+ var rightPoint = keyframeInfo.getPointInCurve(rightKeyframe);
7696
+ var p3 = new Vector2(rightPoint.x, rightPoint.y);
7697
+ var p2 = new Vector2(p3.x - (p3.x - p0_1.x) / 10, p3.y);
7698
+ return { type: 'ease', p0: p0_1, p1: p1_1, p2: p2, p3: p3 };
7699
+ }
7700
+ // 2. 左边为line,右边为ease(补充左边的控制点,该点在曲线上的点的偏右边位置)
7701
+ if (!leftEase && rightEase && !leftHoldLine) {
7702
+ var _b = __read$3(rightKeyframe, 2), rightValue = _b[1];
7703
+ var leftPoint = keyframeInfo.getPointInCurve(leftKeyframe);
7704
+ var p0_2 = new Vector2(leftPoint.x, leftPoint.y);
7705
+ var p2 = new Vector2(rightValue[0], rightValue[1]);
7706
+ var p3 = new Vector2(rightValue[2], rightValue[3]);
7707
+ var p1_2 = new Vector2(p0_2.x + (p3.x - p0_2.x) / 10, p0_2.y);
7708
+ return { type: 'ease', p0: p0_2, p1: p1_2, p2: p2, p3: p3 };
7709
+ }
7710
+ // 3. 左边为ease,右边为ease
7711
+ if (leftEase && rightEase) {
7712
+ var _c = __read$3(rightKeyframe, 2), rightValue = _c[1];
7713
+ var p0_3 = new Vector2(leftValue[leftValue.length - 4], leftValue[leftValue.length - 3]);
7714
+ var p1_3 = new Vector2(leftValue[leftValue.length - 2], leftValue[leftValue.length - 1]);
7715
+ var p2 = new Vector2(rightValue[0], rightValue[1]);
7716
+ var p3 = new Vector2(rightValue[2], rightValue[3]);
7717
+ return { type: 'ease', p0: p0_3, p1: p1_3, p2: p2, p3: p3 };
7718
+ }
7719
+ // 4. 左边为line,右边为line
7720
+ var p0 = keyframeInfo.getPointInCurve(leftKeyframe);
7721
+ var p1 = keyframeInfo.getPointInCurve(rightKeyframe);
7722
+ if (leftHoldLine) {
7723
+ p1.y = p0.y; // 定格关键帧使用相同的点
7724
+ }
7725
+ else if (rightHoldLine) {
7726
+ p0.y = p1.y;
7727
+ }
7728
+ if (lineToBezier) {
7729
+ // 补上两个在直线上的控制点
7730
+ var p2 = new Vector2((p1.x - p0.x) / 3 + p0.x, (p1.y - p0.y) / 3 + p0.y);
7731
+ var p3 = new Vector2((p1.x - p0.x) / 3 * 2 + p0.x, (p1.y - p0.y) / 3 * 2 + p0.y);
7732
+ return { type: 'ease', p0: p0, p1: p2, p2: p3, p3: p1, isHold: leftHoldLine || rightHoldLine, leftHoldLine: leftHoldLine, rightHoldLine: rightHoldLine };
7733
+ }
7734
+ else {
7735
+ return { type: 'line', p0: p0, p1: p1, isHold: leftHoldLine || rightHoldLine, leftHoldLine: leftHoldLine, rightHoldLine: rightHoldLine };
7736
+ }
7737
+ }
7296
7738
 
7297
7739
  var _a$8;
7298
7740
  var NOT_IMPLEMENT = 'not_implement';
@@ -7300,6 +7742,15 @@ var ValueGetter = /** @class */ (function () {
7300
7742
  function ValueGetter(arg) {
7301
7743
  this.onCreate(arg);
7302
7744
  }
7745
+ ValueGetter.getAllData = function (meta, halfFloat) {
7746
+ var ret = new (halfFloat ? Float16ArrayWrapper : Float32Array)(meta.index * 4);
7747
+ for (var i = 0, cursor = 0, curves = meta.curves; i < curves.length; i++) {
7748
+ var data = curves[i].toData();
7749
+ ret.set(data, cursor);
7750
+ cursor += data.length;
7751
+ }
7752
+ return halfFloat ? ret.data : ret;
7753
+ };
7303
7754
  ValueGetter.prototype.onCreate = function (props) {
7304
7755
  throw Error(NOT_IMPLEMENT);
7305
7756
  };
@@ -7321,6 +7772,9 @@ var ValueGetter = /** @class */ (function () {
7321
7772
  ValueGetter.prototype.scaleXCoord = function (scale) {
7322
7773
  return this;
7323
7774
  };
7775
+ ValueGetter.prototype.toData = function () {
7776
+ throw Error(NOT_IMPLEMENT);
7777
+ };
7324
7778
  return ValueGetter;
7325
7779
  }());
7326
7780
  var StaticValue = /** @class */ (function (_super) {
@@ -7483,153 +7937,6 @@ var GradientValue = /** @class */ (function (_super) {
7483
7937
  };
7484
7938
  return GradientValue;
7485
7939
  }(ValueGetter));
7486
- var CURVE_PRO_TIME = 0;
7487
- var CURVE_PRO_VALUE = 1;
7488
- var CURVE_PRO_IN_TANGENT = 2;
7489
- var CURVE_PRO_OUT_TANGENT = 3;
7490
- var CurveValue = /** @class */ (function (_super) {
7491
- __extends(CurveValue, _super);
7492
- function CurveValue() {
7493
- return _super !== null && _super.apply(this, arguments) || this;
7494
- }
7495
- CurveValue.getAllData = function (meta, halfFloat) {
7496
- var ret = new (halfFloat ? Float16ArrayWrapper : Float32Array)(meta.index * 4);
7497
- for (var i = 0, cursor = 0, curves = meta.curves; i < curves.length; i++) {
7498
- var data = curves[i].toData();
7499
- ret.set(data, cursor);
7500
- cursor += data.length;
7501
- }
7502
- return halfFloat ? ret.data : ret;
7503
- };
7504
- CurveValue.prototype.onCreate = function (props) {
7505
- var min = Infinity;
7506
- var max = -Infinity;
7507
- //formatted number
7508
- if (Number.isFinite(props[0]) && Number.isFinite(props[1])) {
7509
- var keys = [];
7510
- for (var i = 2; i < props.length; i++) {
7511
- // FIXME
7512
- keys.push(props[i].slice(0, 4));
7513
- }
7514
- this.keys = keys;
7515
- this.min = props[0];
7516
- this.dist = props[1] - props[0];
7517
- }
7518
- else {
7519
- var keys = props.map(function (item) {
7520
- if (isArray(item)) {
7521
- min = Math.min(min, item[1]);
7522
- max = Math.max(max, item[1]);
7523
- return item.slice(0, 4);
7524
- }
7525
- else if (typeof item === 'object' && item) {
7526
- 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;
7527
- min = Math.min(min, value);
7528
- max = Math.max(max, value);
7529
- return [time, value, inTangent, outTangent];
7530
- }
7531
- throw new Error('invalid keyframe');
7532
- });
7533
- var dist = max - min;
7534
- this.keys = keys;
7535
- if (dist !== 0) {
7536
- for (var i = 0; i < keys.length; i++) {
7537
- var key = keys[i];
7538
- key[1] = (key[1] - min) / dist;
7539
- }
7540
- }
7541
- var key0 = keys[0];
7542
- if (key0[0] > 0) {
7543
- key0[2] = 0;
7544
- keys.unshift([0, key0[1], 0, 0]);
7545
- }
7546
- var key1 = keys[keys.length - 1];
7547
- if (key1[0] < 1) {
7548
- key1[3] = 0;
7549
- keys.push([1, key1[1], 0, 0]);
7550
- }
7551
- this.min = min;
7552
- this.dist = dist;
7553
- }
7554
- this.isCurveValue = true;
7555
- };
7556
- CurveValue.prototype.getValue = function (time) {
7557
- var _a = this, keys = _a.keys, min = _a.min, dist = _a.dist;
7558
- var keysNumerArray = keys;
7559
- if (time <= keysNumerArray[0][CURVE_PRO_TIME]) {
7560
- return keysNumerArray[0][CURVE_PRO_VALUE] * dist + min;
7561
- }
7562
- var end = keysNumerArray.length - 1;
7563
- for (var i = 0; i < end; i++) {
7564
- var key = keysNumerArray[i];
7565
- var k2 = keysNumerArray[i + 1];
7566
- if (time > key[CURVE_PRO_TIME] && time <= k2[CURVE_PRO_TIME]) {
7567
- return curveValueEvaluate(time, key, k2) * dist + min;
7568
- }
7569
- }
7570
- return keysNumerArray[end][CURVE_PRO_VALUE] * dist + min;
7571
- };
7572
- CurveValue.prototype.getIntegrateByTime = function (t0, t1) {
7573
- var d = this.integrate(t1, true) - this.integrate(t0, true);
7574
- return this.min * 0.5 * (t1 - t0) * (t1 - t0) + d * this.dist;
7575
- };
7576
- CurveValue.prototype.getIntegrateValue = function (t0, t1, ts) {
7577
- ts = ts || 1;
7578
- var d = (this.integrate(t1 / ts, false) - this.integrate(t0 / ts, false)) * ts;
7579
- var dt = (t1 - t0) / ts;
7580
- return this.min * dt + d * this.dist;
7581
- };
7582
- CurveValue.prototype.integrate = function (time, byTime) {
7583
- var keys = this.keys;
7584
- if (time <= keys[0][CURVE_PRO_TIME]) {
7585
- return 0;
7586
- }
7587
- var ret = 0;
7588
- var end = keys.length - 1;
7589
- var func = byTime ? curveValueIntegrateByTime : curveValueIntegrate;
7590
- for (var i = 0; i < end; i++) {
7591
- var key = keys[i];
7592
- var k2 = keys[i + 1];
7593
- var t1 = key[CURVE_PRO_TIME];
7594
- var t2 = k2[CURVE_PRO_TIME];
7595
- if (time > t1 && time <= t2) {
7596
- return ret + func(time, key, k2);
7597
- }
7598
- else {
7599
- ret += func(t2, key, k2);
7600
- }
7601
- }
7602
- return ret;
7603
- };
7604
- CurveValue.prototype.toData = function () {
7605
- var keys = this.keys;
7606
- var data = new Float32Array(keys.length * 4);
7607
- for (var i = 0, cursor = 0; i < keys.length; i++, cursor += 4) {
7608
- data.set(keys[i], cursor);
7609
- }
7610
- return data;
7611
- };
7612
- CurveValue.prototype.toUniform = function (meta) {
7613
- var index = meta.index;
7614
- var keys = this.keys;
7615
- meta.curves.push(this);
7616
- meta.index += keys.length;
7617
- meta.max = Math.max(meta.max, keys.length);
7618
- meta.curveCount += keys.length;
7619
- return new Float32Array([2, index + 1 / keys.length, this.min, this.dist]);
7620
- };
7621
- CurveValue.prototype.map = function (func) {
7622
- this.keys.forEach(function (k) {
7623
- k[CURVE_PRO_VALUE] = func(k[CURVE_PRO_VALUE]);
7624
- });
7625
- return this;
7626
- };
7627
- CurveValue.prototype.scaleXCoord = function (scale) {
7628
- this.keys.forEach(function (k) { return k[CURVE_PRO_TIME] = scale * k[CURVE_PRO_TIME]; });
7629
- return this;
7630
- };
7631
- return CurveValue;
7632
- }(ValueGetter));
7633
7940
  var LineSegments = /** @class */ (function (_super) {
7634
7941
  __extends(LineSegments, _super);
7635
7942
  function LineSegments() {
@@ -7731,77 +8038,247 @@ var LineSegments = /** @class */ (function (_super) {
7731
8038
  };
7732
8039
  return LineSegments;
7733
8040
  }(ValueGetter));
7734
- var PathSegments = /** @class */ (function (_super) {
7735
- __extends(PathSegments, _super);
7736
- function PathSegments() {
8041
+ // export class PathSegments extends ValueGetter<number[]> {
8042
+ // keys: number[][];
8043
+ // values: number[][];
8044
+ //
8045
+ // override onCreate (props: number[][][]) {
8046
+ // this.keys = props[0];
8047
+ // this.values = props[1];
8048
+ // }
8049
+ //
8050
+ // override getValue (time: number) {
8051
+ // const keys = this.keys;
8052
+ // const values = this.values;
8053
+ //
8054
+ // for (let i = 0; i < keys.length - 1; i++) {
8055
+ // const k0 = keys[i];
8056
+ // const k1 = keys[i + 1];
8057
+ //
8058
+ // if (k0[0] <= time && k1[0] >= time) {
8059
+ // const dis = k1[1] - k0[1];
8060
+ // let dt;
8061
+ //
8062
+ // if (dis === 0) {
8063
+ // dt = (time - k0[0]) / (k1[0] - k0[0]);
8064
+ // } else {
8065
+ // const val = curveValueEvaluate(time, k0, k1);
8066
+ //
8067
+ // dt = (val - k0[1]) / dis;
8068
+ // }
8069
+ //
8070
+ // return this.calculateVec(i, dt);
8071
+ // }
8072
+ // }
8073
+ // if (time <= keys[0][0]) {
8074
+ // return values[0].slice();
8075
+ // }
8076
+ //
8077
+ // return values[values.length - 1].slice();
8078
+ // }
8079
+ //
8080
+ // calculateVec (i: number, dt: number) {
8081
+ // const vec0 = this.values[i];
8082
+ // const vec1 = this.values[i + 1];
8083
+ // const ret = [0, 0, 0];
8084
+ //
8085
+ // for (let j = 0; j < vec0.length; j++) {
8086
+ // ret[j] = vec0[j] * (1 - dt) + vec1[j] * dt;
8087
+ // }
8088
+ //
8089
+ // return ret;
8090
+ // }
8091
+ // }
8092
+ var BezierCurve = /** @class */ (function (_super) {
8093
+ __extends(BezierCurve, _super);
8094
+ function BezierCurve() {
7737
8095
  return _super !== null && _super.apply(this, arguments) || this;
7738
8096
  }
7739
- PathSegments.prototype.onCreate = function (props) {
7740
- this.keys = props[0];
7741
- this.values = props[1];
8097
+ BezierCurve.prototype.onCreate = function (props) {
8098
+ var keyframes = props;
8099
+ this.curveMap = {};
8100
+ this.keys = [];
8101
+ for (var i = 0; i < keyframes.length - 1; i++) {
8102
+ var leftKeyframe = keyframes[i];
8103
+ var rightKeyframe = keyframes[i + 1];
8104
+ var _a = buildEasingCurve(leftKeyframe, rightKeyframe), points = _a.points, curve = _a.curve, timeInterval = _a.timeInterval, valueInterval = _a.valueInterval;
8105
+ var s = points[0];
8106
+ var e = points[points.length - 1];
8107
+ this.keys.push(__spreadArray$2(__spreadArray$2([], __read$3(s.toArray()), false), __read$3(points[1].toArray()), false));
8108
+ this.keys.push(__spreadArray$2(__spreadArray$2([], __read$3(e.toArray()), false), __read$3(points[2].toArray()), false));
8109
+ this.curveMap["".concat(s.x, "&").concat(e.x)] = {
8110
+ points: points,
8111
+ timeInterval: timeInterval,
8112
+ valueInterval: valueInterval,
8113
+ curve: curve,
8114
+ };
8115
+ }
7742
8116
  };
7743
- PathSegments.prototype.getValue = function (time) {
7744
- var keys = this.keys;
7745
- var values = this.values;
7746
- for (var i = 0; i < keys.length - 1; i++) {
7747
- var k0 = keys[i];
7748
- var k1 = keys[i + 1];
7749
- if (k0[0] <= time && k1[0] >= time) {
7750
- var dis = k1[1] - k0[1];
7751
- var dt = void 0;
7752
- if (dis === 0) {
7753
- dt = (time - k0[0]) / (k1[0] - k0[0]);
7754
- }
7755
- else {
7756
- var val = curveValueEvaluate(time, k0, k1);
7757
- dt = (val - k0[1]) / dis;
7758
- }
7759
- return this.calculateVec(i, dt);
8117
+ BezierCurve.prototype.getValue = function (time) {
8118
+ var result = 0;
8119
+ var keyTimeData = Object.keys(this.curveMap);
8120
+ var keyTimeStart = Number(keyTimeData[0].split('&')[0]);
8121
+ var keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split('&')[1]);
8122
+ if (time <= keyTimeStart) {
8123
+ return this.getCurveValue(keyTimeData[0], keyTimeStart);
8124
+ }
8125
+ if (time >= keyTimeEnd) {
8126
+ return this.getCurveValue(keyTimeData[keyTimeData.length - 1], keyTimeEnd);
8127
+ }
8128
+ for (var i = 0; i < keyTimeData.length; i++) {
8129
+ var _a = __read$3(keyTimeData[i].split('&'), 2), xMin = _a[0], xMax = _a[1];
8130
+ if (time >= Number(xMin) && time < Number(xMax)) {
8131
+ result = this.getCurveValue(keyTimeData[i], time);
8132
+ break;
7760
8133
  }
7761
8134
  }
7762
- if (time <= keys[0][0]) {
7763
- return values[0].slice();
8135
+ return result;
8136
+ };
8137
+ BezierCurve.prototype.getIntegrateValue = function (t0, t1, ts) {
8138
+ if (ts === void 0) { ts = 1; }
8139
+ var time = (t1 - t0);
8140
+ var result = 0;
8141
+ var keyTimeData = Object.keys(this.curveMap);
8142
+ var keyTimeStart = Number(keyTimeData[0].split('&')[0]);
8143
+ if (time <= keyTimeStart) {
8144
+ return 0;
8145
+ }
8146
+ for (var i = 0; i < keyTimeData.length; i++) {
8147
+ var _a = __read$3(keyTimeData[i].split('&'), 2), xMin = _a[0], xMax = _a[1];
8148
+ if (time >= Number(xMax)) {
8149
+ result += ts * this.getCurveIntegrateValue(keyTimeData[i], Number(xMax));
8150
+ }
8151
+ if (time >= Number(xMin) && time < Number(xMax)) {
8152
+ result += ts * this.getCurveIntegrateValue(keyTimeData[i], time);
8153
+ break;
8154
+ }
7764
8155
  }
7765
- return values[values.length - 1].slice();
8156
+ return result;
7766
8157
  };
7767
- PathSegments.prototype.calculateVec = function (i, dt) {
7768
- var vec0 = this.values[i];
7769
- var vec1 = this.values[i + 1];
7770
- var ret = [0, 0, 0];
7771
- for (var j = 0; j < vec0.length; j++) {
7772
- ret[j] = vec0[j] * (1 - dt) + vec1[j] * dt;
8158
+ // 速度变化曲线面板移除后下线
8159
+ BezierCurve.prototype.getCurveIntegrateValue = function (curveKey, time) {
8160
+ var curveInfo = this.curveMap[curveKey];
8161
+ var _a = __read$3(curveInfo.points, 1), p0 = _a[0];
8162
+ var timeInterval = curveInfo.timeInterval;
8163
+ var valueInterval = curveInfo.valueInterval;
8164
+ var segments = 100;
8165
+ var total = 0;
8166
+ var h = (time - p0.x) / segments;
8167
+ for (var i = 0; i <= segments; i++) {
8168
+ var t = i * h;
8169
+ var normalizeTime = t / timeInterval;
8170
+ var y = p0.y + valueInterval * curveInfo.curve.getValue(normalizeTime);
8171
+ if (i === 0 || i === segments) {
8172
+ total += y;
8173
+ }
8174
+ else if (i % 2 === 1) {
8175
+ total += 4 * y;
8176
+ }
8177
+ else {
8178
+ total += 2 * y;
8179
+ }
7773
8180
  }
7774
- return ret;
8181
+ total *= h / 3;
8182
+ return total;
8183
+ };
8184
+ BezierCurve.prototype.getCurveValue = function (curveKey, time) {
8185
+ var curveInfo = this.curveMap[curveKey];
8186
+ var _a = __read$3(curveInfo.points, 1), p0 = _a[0];
8187
+ var timeInterval = curveInfo.timeInterval;
8188
+ var valueInterval = curveInfo.valueInterval;
8189
+ var normalizeTime = (time - p0.x) / timeInterval;
8190
+ var value = curveInfo.curve.getValue(normalizeTime);
8191
+ return p0.y + valueInterval * value;
8192
+ };
8193
+ BezierCurve.prototype.toUniform = function (meta) {
8194
+ var index = meta.index;
8195
+ var count = this.keys.length;
8196
+ meta.curves.push(this);
8197
+ meta.index = index + count;
8198
+ // 兼容 WebGL1
8199
+ meta.max = Math.max(meta.max, count);
8200
+ meta.curveCount += count;
8201
+ return new Float32Array([5, index + 1 / count, index, count]);
8202
+ };
8203
+ BezierCurve.prototype.toData = function () {
8204
+ var keys = this.keys;
8205
+ var data = new Float32Array(keys.length * 4);
8206
+ for (var i = 0, cursor = 0; i < keys.length; i++, cursor += 4) {
8207
+ data.set(keys[i], cursor);
8208
+ }
8209
+ return data;
7775
8210
  };
7776
- return PathSegments;
8211
+ return BezierCurve;
7777
8212
  }(ValueGetter));
7778
- var BezierSegments = /** @class */ (function (_super) {
7779
- __extends(BezierSegments, _super);
7780
- function BezierSegments() {
8213
+ var BezierCurvePath = /** @class */ (function (_super) {
8214
+ __extends(BezierCurvePath, _super);
8215
+ function BezierCurvePath() {
7781
8216
  return _super !== null && _super.apply(this, arguments) || this;
7782
8217
  }
7783
- BezierSegments.prototype.onCreate = function (props) {
7784
- _super.prototype.onCreate.call(this, props);
7785
- this.cps = props[2];
7786
- };
7787
- BezierSegments.prototype.calculateVec = function (i, t) {
7788
- var vec0 = this.values[i];
7789
- var vec1 = this.values[i + 1];
7790
- var outCp = this.cps[i + i];
7791
- var inCp = this.cps[i + i + 1];
7792
- var ret = [0, 0, 0];
7793
- var ddt = 1 - t;
7794
- var a = ddt * ddt * ddt;
7795
- var b = 3 * t * ddt * ddt;
7796
- var c = 3 * t * t * ddt;
7797
- var d = t * t * t;
7798
- for (var j = 0; j < vec0.length; j++) {
7799
- ret[j] = a * vec0[j] + b * outCp[j] + c * inCp[j] + d * vec1[j];
8218
+ BezierCurvePath.prototype.onCreate = function (props) {
8219
+ var _a = __read$3(props, 3), keyframes = _a[0], points = _a[1], controlPoints = _a[2];
8220
+ this.curveSegments = {};
8221
+ if (!controlPoints.length) {
8222
+ return;
8223
+ }
8224
+ for (var i = 0; i < keyframes.length - 1; i++) {
8225
+ var leftKeyframe = keyframes[i];
8226
+ var rightKeyframe = keyframes[i + 1];
8227
+ 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]);
8228
+ 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]);
8229
+ var _b = buildEasingCurve(leftKeyframe, rightKeyframe), ps = _b.points, easingCurve = _b.curve, timeInterval = _b.timeInterval, valueInterval = _b.valueInterval;
8230
+ var s = ps[0];
8231
+ var e = ps[ps.length - 1];
8232
+ var pathCurve = new BezierPath(ps1, ps2, cp1, cp2);
8233
+ this.curveSegments["".concat(s.x, "&").concat(e.x)] = {
8234
+ points: ps,
8235
+ timeInterval: timeInterval,
8236
+ valueInterval: valueInterval,
8237
+ easingCurve: easingCurve,
8238
+ pathCurve: pathCurve,
8239
+ };
7800
8240
  }
7801
- return ret;
7802
8241
  };
7803
- return BezierSegments;
7804
- }(PathSegments));
8242
+ BezierCurvePath.prototype.getValue = function (time) {
8243
+ var t = numberToFix(time, 5);
8244
+ var perc = 0, point = new Vector3();
8245
+ var keyTimeData = Object.keys(this.curveSegments);
8246
+ if (!keyTimeData.length) {
8247
+ return point;
8248
+ }
8249
+ var keyTimeStart = Number(keyTimeData[0].split('&')[0]);
8250
+ var keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split('&')[1]);
8251
+ if (t <= keyTimeStart) {
8252
+ var pathCurve = this.curveSegments[keyTimeData[0]].pathCurve;
8253
+ point = pathCurve.getPointInPercent(0);
8254
+ return point;
8255
+ }
8256
+ if (t >= keyTimeEnd) {
8257
+ var pathCurve = this.curveSegments[keyTimeData[keyTimeData.length - 1]].pathCurve;
8258
+ point = pathCurve.getPointInPercent(1);
8259
+ return point;
8260
+ }
8261
+ for (var i = 0; i < keyTimeData.length; i++) {
8262
+ var _a = __read$3(keyTimeData[i].split('&'), 2), xMin = _a[0], xMax = _a[1];
8263
+ if (t >= Number(xMin) && t < Number(xMax)) {
8264
+ var bezierPath = this.curveSegments[keyTimeData[i]].pathCurve;
8265
+ perc = this.getPercValue(keyTimeData[i], t);
8266
+ point = bezierPath.getPointInPercent(perc);
8267
+ }
8268
+ }
8269
+ return point;
8270
+ };
8271
+ BezierCurvePath.prototype.getPercValue = function (curveKey, time) {
8272
+ var curveInfo = this.curveSegments[curveKey];
8273
+ var _a = __read$3(curveInfo.points, 1), p0 = _a[0];
8274
+ var timeInterval = curveInfo.timeInterval;
8275
+ var normalizeTime = numberToFix((time - p0.x) / timeInterval, 4);
8276
+ var value = curveInfo.easingCurve.getValue(normalizeTime);
8277
+ // TODO 测试用 编辑器限制值域后移除clamp
8278
+ return clamp$1(value, 0, 1);
8279
+ };
8280
+ return BezierCurvePath;
8281
+ }(ValueGetter));
7805
8282
  var map$2 = (_a$8 = {},
7806
8283
  _a$8[ValueType$1.RANDOM] = function (props) {
7807
8284
  if (props[0] instanceof Array) {
@@ -7821,9 +8298,6 @@ var map$2 = (_a$8 = {},
7821
8298
  _a$8[ValueType$1.CONSTANT_VEC4] = function (props) {
7822
8299
  return new StaticValue(props);
7823
8300
  },
7824
- _a$8[ValueType$1.CURVE] = function (props) {
7825
- return new CurveValue(props);
7826
- },
7827
8301
  _a$8[ValueType$1.RGBA_COLOR] = function (props) {
7828
8302
  return new StaticValue(props);
7829
8303
  },
@@ -7839,11 +8313,20 @@ var map$2 = (_a$8 = {},
7839
8313
  _a$8[ValueType$1.GRADIENT_COLOR] = function (props) {
7840
8314
  return new GradientValue(props);
7841
8315
  },
7842
- _a$8[ValueType$1.LINEAR_PATH] = function (pros) {
7843
- return new PathSegments(pros);
8316
+ // [spec.ValueType.LINEAR_PATH] (pros: number[][][]) {
8317
+ // return new PathSegments(pros);
8318
+ // },
8319
+ _a$8[ValueType$1.BEZIER_CURVE] = function (props) {
8320
+ if (props.length === 1) {
8321
+ return new StaticValue(props[0][1][1]);
8322
+ }
8323
+ return new BezierCurve(props);
7844
8324
  },
7845
- _a$8[ValueType$1.BEZIER_PATH] = function (pros) {
7846
- return new BezierSegments(pros);
8325
+ _a$8[ValueType$1.BEZIER_CURVE_PATH] = function (props) {
8326
+ if (props[0].length === 1) {
8327
+ return new StaticValue(new Vector3(props[0][0][1][1], props[1][0][1][1], props[2][0][1][1]));
8328
+ }
8329
+ return new BezierCurvePath(props);
7847
8330
  },
7848
8331
  _a$8);
7849
8332
  function createValueGetter(args) {
@@ -7871,53 +8354,6 @@ function lineSegIntegrateByTime(t, t0, t1, y0, y1) {
7871
8354
  var t03 = t02 * t0;
7872
8355
  return (2 * t3 * (y0 - y1) + 3 * t2 * (t0 * y1 - t1 * y0) - t03 * (2 * y0 + y1) + 3 * t02 * t1 * y0) / (6 * (t0 - t1));
7873
8356
  }
7874
- function curveValueEvaluate(time, keyframe0, keyframe1) {
7875
- var dt = keyframe1[CURVE_PRO_TIME] - keyframe0[CURVE_PRO_TIME];
7876
- var m0 = keyframe0[CURVE_PRO_OUT_TANGENT] * dt;
7877
- var m1 = keyframe1[CURVE_PRO_IN_TANGENT] * dt;
7878
- var t = (time - keyframe0[CURVE_PRO_TIME]) / dt;
7879
- var t2 = t * t;
7880
- var t3 = t2 * t;
7881
- var a = 2 * t3 - 3 * t2 + 1;
7882
- var b = t3 - 2 * t2 + t;
7883
- var c = t3 - t2;
7884
- var d = -2 * t3 + 3 * t2;
7885
- //(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
7886
- return a * keyframe0[CURVE_PRO_VALUE] + b * m0 + c * m1 + d * keyframe1[CURVE_PRO_VALUE];
7887
- }
7888
- function curveValueIntegrate(time, keyframe0, keyframe1) {
7889
- var k = keyframe1[CURVE_PRO_TIME] - keyframe0[CURVE_PRO_TIME];
7890
- var m0 = keyframe0[CURVE_PRO_OUT_TANGENT] * k;
7891
- var m1 = keyframe1[CURVE_PRO_IN_TANGENT] * k;
7892
- var t0 = keyframe0[CURVE_PRO_TIME];
7893
- var v0 = keyframe0[CURVE_PRO_VALUE];
7894
- var v1 = keyframe1[CURVE_PRO_VALUE];
7895
- var dt = t0 - time;
7896
- var dt2 = dt * dt;
7897
- var dt3 = dt2 * dt;
7898
- return (m0 + m1 + 2 * v0 - 2 * v1) * dt3 * dt / (4 * k * k * k) +
7899
- (2 * m0 + m1 + 3 * v0 - 3 * v1) * dt3 / (3 * k * k) +
7900
- m0 * dt2 / 2 / k - v0 * dt;
7901
- }
7902
- function curveValueIntegrateByTime(t1, keyframe0, keyframe1) {
7903
- var k = keyframe1[CURVE_PRO_TIME] - keyframe0[CURVE_PRO_TIME];
7904
- var m0 = keyframe0[CURVE_PRO_OUT_TANGENT] * k;
7905
- var m1 = keyframe1[CURVE_PRO_IN_TANGENT] * k;
7906
- var t0 = keyframe0[CURVE_PRO_TIME];
7907
- var v0 = keyframe0[CURVE_PRO_VALUE];
7908
- var v1 = keyframe1[CURVE_PRO_VALUE];
7909
- var dt = t0 - t1;
7910
- var dt2 = dt * dt;
7911
- var dt3 = dt2 * dt;
7912
- var k2 = k * k;
7913
- var k3 = k2 * k;
7914
- //(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)
7915
- var ret = -30 * k3 * v0 * (t0 + t1) * dt +
7916
- 10 * k2 * m0 * (t0 + 2 * t1) * dt2 +
7917
- 5 * k * (t0 + 3 * t1) * (2 * m0 + m1 + 3 * v0 - 3 * v1) * dt3 +
7918
- 3 * (t0 + 4 * t1) * (m0 + m1 + 2 * v0 - 2 * v1) * dt3 * dt;
7919
- return ret / 60 / k3;
7920
- }
7921
8357
  function getKeyFrameMetaByRawValue(meta, value) {
7922
8358
  if (value) {
7923
8359
  var type = value[0];
@@ -7952,6 +8388,13 @@ function getKeyFrameMetaByRawValue(meta, value) {
7952
8388
  meta.index += uniformCount;
7953
8389
  meta.max = Math.max(meta.max, uniformCount);
7954
8390
  }
8391
+ else if (type === ValueType$1.BEZIER_CURVE) {
8392
+ var keyLen = keys.length - 1;
8393
+ meta.index += 2 * keyLen;
8394
+ meta.curves.push(keys);
8395
+ meta.max = Math.max(meta.max, 2 * keyLen);
8396
+ meta.curveCount += 2 * keyLen;
8397
+ }
7955
8398
  }
7956
8399
  }
7957
8400
  function createKeyFrameMeta() {
@@ -11682,21 +12125,19 @@ var compatible_vert = "#version 300 es\n#ifdef WEBGL2\n#define texture2D texture
11682
12125
 
11683
12126
  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);}";
11684
12127
 
11685
- 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.;}";
12128
+ 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.;}";
11686
12129
 
11687
12130
  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);}}";
11688
12131
 
11689
- var item_define = "uniform mat4 uMainData[MAX_ITEM_COUNT];uniform vec4 uTexParams[MAX_ITEM_COUNT];uniform vec4 uTexOffset[MAX_ITEM_COUNT];";
11690
-
11691
12132
  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}";
11692
12133
 
11693
- 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";
12134
+ 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";
11694
12135
 
11695
- 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}}";
12136
+ 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}}";
11696
12137
 
11697
- 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}";
12138
+ 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}";
11698
12139
 
11699
- 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.;}";
12140
+ 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.;}";
11700
12141
 
11701
12142
  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";
11702
12143
 
@@ -15132,819 +15573,146 @@ var FilterSpriteVFXItem = /** @class */ (function (_super) {
15132
15573
  return FilterSpriteVFXItem;
15133
15574
  }(SpriteVFXItem));
15134
15575
 
15135
- var ParticleMesh = /** @class */ (function () {
15136
- function ParticleMesh(props, rendererOptions) {
15137
- var _a, _b, _c, _d;
15138
- this.particleCount = 0;
15139
- var engine = rendererOptions.composition.getEngine();
15140
- var env = ((_a = engine.renderer) !== null && _a !== void 0 ? _a : {}).env;
15141
- 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;
15142
- var detail = engine.gpuCapability.detail;
15143
- var halfFloatTexture = detail.halfFloatTexture, maxVertexUniforms = detail.maxVertexUniforms;
15144
- var marcos = [
15145
- ['RENDER_MODE', +renderMode],
15146
- ['PRE_MULTIPLY_ALPHA', false],
15147
- ['ENV_EDITOR', env === PLAYER_OPTIONS_ENV_EDITOR],
15148
- ];
15149
- var level = engine.gpuCapability.level;
15150
- var vertexKeyFrameMeta = createKeyFrameMeta();
15151
- var fragmentKeyFrameMeta = createKeyFrameMeta();
15152
- var enableVertexTexture = maxVertexUniforms > 0;
15153
- var uniformValues = {};
15154
- var vertex_lookup_texture = 0;
15155
- var shaderCacheId = 0;
15156
- var particleDefine;
15157
- var useOrbitalVel;
15158
- this.useSprite = useSprite;
15159
- if (enableVertexTexture) {
15160
- marcos.push(['ENABLE_VERTEX_TEXTURE', true]);
15161
- }
15162
- if (speedOverLifetime) {
15163
- marcos.push(['SPEED_OVER_LIFETIME', true]);
15164
- shaderCacheId |= 1 << 1;
15165
- uniformValues.uSpeedLifetimeValue = speedOverLifetime.toUniform(vertexKeyFrameMeta);
15166
- }
15167
- if (sprite === null || sprite === void 0 ? void 0 : sprite.animate) {
15168
- marcos.push(['USE_SPRITE', true]);
15169
- shaderCacheId |= 1 << 2;
15170
- uniformValues.uFSprite = uniformValues.uSprite = new Float32Array([sprite.col, sprite.row, sprite.total, sprite.blend ? 1 : 0]);
15171
- this.useSprite = true;
15576
+ var LinkNode = /** @class */ (function () {
15577
+ function LinkNode(content) {
15578
+ this.content = content;
15579
+ }
15580
+ return LinkNode;
15581
+ }());
15582
+ var Link = /** @class */ (function () {
15583
+ function Link(sort) {
15584
+ this.sort = sort;
15585
+ this.length = 0;
15586
+ }
15587
+ Link.prototype.findNodeByContent = function (filter) {
15588
+ var node = this.first;
15589
+ if (node) {
15590
+ do {
15591
+ if (filter(node.content)) {
15592
+ return node;
15593
+ }
15594
+ // @ts-expect-error
15595
+ // eslint-disable-next-line no-cond-assign
15596
+ } while (node = node.next);
15172
15597
  }
15173
- if (filter && filter.name !== FILTER_NAME_NONE) {
15174
- marcos.push(['USE_FILTER', true]);
15175
- shaderCacheId |= 1 << 3;
15176
- var filterDefine = createFilter(filter, rendererOptions.composition);
15177
- if (!filterDefine.particle) {
15178
- throw new Error("particle filter ".concat(filter.name, " not implement"));
15598
+ };
15599
+ Link.prototype.insertNode = function (a, next) {
15600
+ var b = a.next;
15601
+ a.next = next;
15602
+ next.pre = a;
15603
+ next.next = b;
15604
+ if (b) {
15605
+ b.pre = next;
15606
+ }
15607
+ // a -> next -> b
15608
+ };
15609
+ Link.prototype.shiftNode = function (content) {
15610
+ var node = new LinkNode(content);
15611
+ this.length++;
15612
+ if (this.length === 1) {
15613
+ return this.first = this.last = node;
15614
+ }
15615
+ var current = this.first;
15616
+ while (current) {
15617
+ if (this.sort(current.content, node.content) <= 0) {
15618
+ if (current.next) {
15619
+ current = current.next;
15620
+ }
15621
+ else {
15622
+ this.insertNode(current, node);
15623
+ return this.last = node;
15624
+ }
15179
15625
  }
15180
- particleDefine = filterDefine.particle;
15181
- Object.keys((_b = particleDefine.uniforms) !== null && _b !== void 0 ? _b : {}).forEach(function (uName) {
15182
- var _a;
15183
- var getter = (_a = particleDefine.uniforms) === null || _a === void 0 ? void 0 : _a[uName];
15184
- if (uniformValues[uName]) {
15185
- throw new Error('conflict uniform name:' + uName);
15626
+ else {
15627
+ if (current.pre) {
15628
+ this.insertNode(current.pre, node);
15186
15629
  }
15187
- uniformValues[uName] = getter === null || getter === void 0 ? void 0 : getter.toUniform(vertexKeyFrameMeta);
15188
- });
15189
- Object.keys((_c = particleDefine.uniformValues) !== null && _c !== void 0 ? _c : {}).forEach(function (uName) {
15190
- var _a;
15191
- var val = (_a = particleDefine.uniformValues) === null || _a === void 0 ? void 0 : _a[uName];
15192
- if (uniformValues[uName]) {
15193
- throw new Error('conflict uniform name:' + uName);
15630
+ else {
15631
+ this.first = node;
15632
+ node.next = current;
15633
+ current.pre = node;
15194
15634
  }
15195
- uniformValues[uName] = val;
15196
- });
15197
- }
15198
- if (colorOverLifetime === null || colorOverLifetime === void 0 ? void 0 : colorOverLifetime.color) {
15199
- marcos.push(['COLOR_OVER_LIFETIME', true]);
15200
- shaderCacheId |= 1 << 4;
15201
- uniformValues.uColorOverLifetime = colorOverLifetime.color instanceof Texture ? colorOverLifetime.color : Texture.createWithData(engine, imageDataFromGradient(colorOverLifetime.color));
15202
- }
15203
- if (colorOverLifetime === null || colorOverLifetime === void 0 ? void 0 : colorOverLifetime.opacity) {
15204
- uniformValues.uOpacityOverLifetimeValue = colorOverLifetime.opacity.toUniform(vertexKeyFrameMeta);
15635
+ return node;
15636
+ }
15205
15637
  }
15206
- else {
15207
- uniformValues.uOpacityOverLifetimeValue = createValueGetter(1).toUniform(vertexKeyFrameMeta);
15638
+ };
15639
+ Link.prototype.pushNode = function (content) {
15640
+ var node = new LinkNode(content);
15641
+ this.length++;
15642
+ if (this.length === 1) {
15643
+ return this.last = this.first = node;
15208
15644
  }
15209
- ['x', 'y', 'z'].forEach(function (pro, i) {
15210
- var defL = 0;
15211
- var defO = 0;
15212
- if (linearVelOverLifetime === null || linearVelOverLifetime === void 0 ? void 0 : linearVelOverLifetime[pro]) {
15213
- uniformValues["uLinear".concat(pro.toUpperCase(), "ByLifetimeValue")] = linearVelOverLifetime[pro].toUniform(vertexKeyFrameMeta);
15214
- defL = 1;
15215
- shaderCacheId |= 1 << (7 + i);
15216
- linearVelOverLifetime.enabled = true;
15645
+ var current = this.last;
15646
+ while (current) {
15647
+ if (this.sort(node.content, current.content) <= 0) {
15648
+ if (this.first === current) {
15649
+ current.pre = node;
15650
+ node.next = current;
15651
+ return this.first = node;
15652
+ }
15653
+ else {
15654
+ // @ts-expect-error
15655
+ current = current.pre;
15656
+ }
15217
15657
  }
15218
- marcos.push(["LINEAR_VEL_".concat(pro.toUpperCase()), defL]);
15219
- if (orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime[pro]) {
15220
- uniformValues["uOrb".concat(pro.toUpperCase(), "ByLifetimeValue")] = orbitalVelOverLifetime[pro].toUniform(vertexKeyFrameMeta);
15221
- defO = 1;
15222
- shaderCacheId |= 1 << (10 + i);
15223
- useOrbitalVel = true;
15224
- orbitalVelOverLifetime.enabled = true;
15658
+ else {
15659
+ this.insertNode(current, node);
15660
+ if (current === this.last) {
15661
+ this.last = node;
15662
+ }
15663
+ return node;
15225
15664
  }
15226
- marcos.push(["ORB_VEL_".concat(pro.toUpperCase()), defO]);
15227
- });
15228
- if (linearVelOverLifetime === null || linearVelOverLifetime === void 0 ? void 0 : linearVelOverLifetime.asMovement) {
15229
- marcos.push(['AS_LINEAR_MOVEMENT', true]);
15230
- shaderCacheId |= 1 << 5;
15231
15665
  }
15232
- if (useOrbitalVel) {
15233
- if (orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime.asRotation) {
15234
- marcos.push(['AS_ORBITAL_MOVEMENT', true]);
15235
- shaderCacheId |= 1 << 6;
15666
+ };
15667
+ Link.prototype.removeNode = function (node) {
15668
+ var current = this.first;
15669
+ this.length--;
15670
+ if (current === node) {
15671
+ // @ts-expect-error
15672
+ var a = this.first = current.next;
15673
+ if (a) {
15674
+ a.pre = null;
15236
15675
  }
15237
- uniformValues.uOrbCenter = new Float32Array((orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime.center) || [0, 0, 0]);
15238
- }
15239
- uniformValues.uSizeByLifetimeValue = sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.x.toUniform(vertexKeyFrameMeta);
15240
- if (sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.separateAxes) {
15241
- marcos.push(['SIZE_Y_BY_LIFE', 1]);
15242
- shaderCacheId |= 1 << 14;
15243
- uniformValues.uSizeYByLifetimeValue = (_d = sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.y) === null || _d === void 0 ? void 0 : _d.toUniform(vertexKeyFrameMeta);
15244
- }
15245
- if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.z) {
15246
- uniformValues.uRZByLifeTimeValue = rotationOverLifetime.z.toUniform(vertexKeyFrameMeta);
15247
- shaderCacheId |= 1 << 15;
15248
- marcos.push(['ROT_Z_LIFETIME', 1]);
15249
- }
15250
- if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.x) {
15251
- uniformValues.uRXByLifeTimeValue = rotationOverLifetime.x.toUniform(vertexKeyFrameMeta);
15252
- shaderCacheId |= 1 << 16;
15253
- marcos.push(['ROT_X_LIFETIME', 1]);
15254
- }
15255
- if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.y) {
15256
- uniformValues.uRYByLifeTimeValue = rotationOverLifetime.y.toUniform(vertexKeyFrameMeta);
15257
- shaderCacheId |= 1 << 17;
15258
- marcos.push(['ROT_Y_LIFETIME', 1]);
15259
- }
15260
- if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.asRotation) {
15261
- marcos.push(['ROT_LIFETIME_AS_MOVEMENT', 1]);
15262
- shaderCacheId |= 1 << 18;
15263
- }
15264
- uniformValues.uGravityModifierValue = gravityModifier.toUniform(vertexKeyFrameMeta);
15265
- if (forceTarget) {
15266
- marcos.push(['FINAL_TARGET', true]);
15267
- shaderCacheId |= 1 << 19;
15268
- uniformValues.uFinalTarget = new Float32Array(forceTarget.target || [0, 0, 0]);
15269
- uniformValues.uForceCurve = forceTarget.curve.toUniform(vertexKeyFrameMeta);
15270
- }
15271
- if (halfFloatTexture && fragmentKeyFrameMeta.max) {
15272
- shaderCacheId |= 1 << 20;
15273
- uniformValues.uFCurveValueTexture = generateHalfFloatTexture(engine, CurveValue.getAllData(fragmentKeyFrameMeta, true), fragmentKeyFrameMeta.index, 1);
15274
- }
15275
- else {
15276
- uniformValues.uFCurveValues = CurveValue.getAllData(fragmentKeyFrameMeta);
15277
15676
  }
15278
- var vertexCurveTexture = vertexKeyFrameMeta.max + vertexKeyFrameMeta.curves.length - 32 > maxVertexUniforms;
15279
- // if (getConfig(RENDER_PREFER_LOOKUP_TEXTURE)) {
15280
- // vertexCurveTexture = true;
15281
- // }
15282
- if (level === 2) {
15283
- vertexKeyFrameMeta.max = -1;
15284
- vertexKeyFrameMeta.index = meshSlots ? meshSlots[0] : getSlot(vertexKeyFrameMeta.index);
15285
- if (fragmentKeyFrameMeta.index > 0) {
15286
- fragmentKeyFrameMeta.max = -1;
15287
- fragmentKeyFrameMeta.index = meshSlots ? meshSlots[1] : getSlot(fragmentKeyFrameMeta.index);
15677
+ else if ((current = this.last) === node) {
15678
+ // @ts-expect-error
15679
+ var a = this.last = current.pre;
15680
+ if (a) {
15681
+ a.next = null;
15288
15682
  }
15289
15683
  }
15290
- if (vertexCurveTexture && halfFloatTexture && enableVertexTexture) {
15291
- var tex = generateHalfFloatTexture(engine, CurveValue.getAllData(vertexKeyFrameMeta, true), vertexKeyFrameMeta.index, 1);
15292
- uniformValues.uVCurveValueTexture = tex;
15293
- vertex_lookup_texture = 1;
15684
+ else if (node) {
15685
+ var pre = node.pre;
15686
+ var next = node.next;
15687
+ // @ts-expect-error
15688
+ pre.next = next;
15689
+ if (next) {
15690
+ next.pre = pre;
15691
+ }
15294
15692
  }
15295
- else {
15296
- uniformValues.uVCurveValues = CurveValue.getAllData(vertexKeyFrameMeta);
15693
+ node.pre = null;
15694
+ node.next = null;
15695
+ };
15696
+ Link.prototype.forEach = function (func, thisObj) {
15697
+ var node = this.first;
15698
+ var i = 0;
15699
+ if (node) {
15700
+ do {
15701
+ func.call(thisObj || this, node.content, i++);
15702
+ // @ts-expect-error
15703
+ // eslint-disable-next-line no-cond-assign
15704
+ } while (node = node.next);
15297
15705
  }
15298
- var shaderCache = ['-p:', renderMode, shaderCacheId, vertexKeyFrameMeta.index, vertexKeyFrameMeta.max, fragmentKeyFrameMeta.index, fragmentKeyFrameMeta.max].join('+');
15299
- 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]);
15300
- var fragment = filter ? particleFrag.replace(/#pragma\s+FILTER_FRAG/, particleDefine.fragment) : particleFrag;
15301
- var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
15302
- var vertex = filter ? originalVertex.replace(/#pragma\s+FILTER_VERT/, particleDefine.vertex || 'void filterMain(float t){}\n') : originalVertex;
15303
- var shader = {
15304
- fragment: createShaderWithMarcos(marcos, fragment, ShaderType.fragment, level),
15305
- vertex: createShaderWithMarcos(marcos, vertex, ShaderType.vertex, level),
15306
- glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
15307
- shared: true,
15308
- cacheId: shaderCache,
15309
- marcos: marcos,
15310
- name: "particle#".concat(name),
15311
- };
15312
- if (filter) {
15313
- shader.cacheId += filter.name;
15314
- }
15315
- var mtlOptions = {
15316
- shader: shader,
15317
- uniformSemantics: {
15318
- effects_MatrixV: 'VIEW',
15319
- effects_MatrixVP: 'VIEWPROJECTION',
15320
- uEditorTransform: 'EDITOR_TRANSFORM',
15321
- effects_ObjectToWorld: 'MODEL',
15322
- },
15323
- };
15324
- var preMulAlpha = getPreMultiAlpha(blending);
15325
- uniformValues.uTexOffset = new Float32Array(diffuse ? [1 / diffuse.getWidth(), 1 / diffuse.getHeight()] : [0, 0]);
15326
- uniformValues.uMaskTex = diffuse;
15327
- uniformValues.uColorParams = new Float32Array([diffuse ? 1 : 0, +preMulAlpha, 0, +(!!occlusion && !transparentOcclusion)]);
15328
- uniformValues.uParams = [0, duration, 0, 0];
15329
- 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];
15330
- // mtlOptions.uniformValues = uniformValues;
15331
- var material = Material.create(engine, mtlOptions);
15332
- material.blending = true;
15333
- material.depthTest = true;
15334
- material.depthMask = !!(occlusion);
15335
- material.stencilRef = mask ? [mask, mask] : undefined;
15336
- setMaskMode(material, maskMode);
15337
- setBlendMode(material, blending);
15338
- setSideMode(material, side);
15339
- var typeMap = {
15340
- 'uSprite': 'vec4',
15341
- 'uParams': 'vec4',
15342
- 'uAcceleration': 'vec4',
15343
- 'uGravityModifierValue': 'vec4',
15344
- 'uOpacityOverLifetimeValue': 'vec4',
15345
- 'uRXByLifeTimeValue': 'vec4',
15346
- 'uRYByLifeTimeValue': 'vec4',
15347
- 'uRZByLifeTimeValue': 'vec4',
15348
- 'uLinearXByLifetimeValue': 'vec4',
15349
- 'uLinearYByLifetimeValue': 'vec4',
15350
- 'uLinearZByLifetimeValue': 'vec4',
15351
- 'uSpeedLifetimeValue': 'vec4',
15352
- 'uOrbXByLifetimeValue': 'vec4',
15353
- 'uOrbYByLifetimeValue': 'vec4',
15354
- 'uOrbZByLifetimeValue': 'vec4',
15355
- 'uSizeByLifetimeValue': 'vec4',
15356
- 'uSizeYByLifetimeValue': 'vec4',
15357
- 'uColorParams': 'vec4',
15358
- 'uFSprite': 'vec4',
15359
- 'uPreviewColor': 'vec4',
15360
- 'uVCurveValues': 'vec4Array',
15361
- 'uFCurveValues': 'vec4',
15362
- 'uFinalTarget': 'vec3',
15363
- 'uForceCurve': 'vec4',
15364
- 'uOrbCenter': 'vec3',
15365
- 'uTexOffset': 'vec2',
15366
- 'uPeriodValue': 'vec4',
15367
- 'uMovementValue': 'vec4',
15368
- 'uStrengthValue': 'vec4',
15369
- 'uWaveParams': 'vec4',
15370
- };
15371
- Object.keys(uniformValues).map(function (name) {
15372
- var value = uniformValues[name];
15373
- if (value instanceof Texture) {
15374
- material.setTexture(name, value);
15375
- return;
15376
- }
15377
- var res = [];
15378
- switch (typeMap[name]) {
15379
- case 'vec4':
15380
- material.setVector4(name, Vector4$1.fromArray(value));
15381
- break;
15382
- case 'vec3':
15383
- material.setVector3(name, Vector3.fromArray(value));
15384
- break;
15385
- case 'vec2':
15386
- material.setVector2(name, Vector2.fromArray(value));
15387
- break;
15388
- case 'vec4Array':
15389
- for (var i = 0; i < value.length; i = i + 4) {
15390
- var v = new Vector4$1(value[i], value[i + 1], value[i + 2], value[i + 3]);
15391
- res.push(v);
15392
- }
15393
- material.setVector4Array(name, res);
15394
- res.length = 0;
15395
- break;
15396
- default:
15397
- console.warn("uniform ".concat(name, "'s type not in typeMap"));
15398
- }
15399
- });
15400
- material.setVector3('emissionColor', new Vector3(0, 0, 0));
15401
- material.setFloat('emissionIntensity', 0.0);
15402
- var geometry = Geometry.create(engine, generateGeometryProps(maxCount * 4, this.useSprite, "particle#".concat(name)));
15403
- var mesh = Mesh.create(engine, {
15404
- name: "MParticle_".concat(name),
15405
- priority: listIndex,
15406
- material: material,
15407
- geometry: geometry,
15408
- });
15409
- this.anchor = anchor;
15410
- this.mesh = mesh;
15411
- this.geometry = mesh.firstGeometry();
15412
- this.forceTarget = forceTarget;
15413
- this.sizeOverLifetime = sizeOverLifetime;
15414
- this.speedOverLifetime = speedOverLifetime;
15415
- this.linearVelOverLifetime = linearVelOverLifetime;
15416
- this.orbitalVelOverLifetime = orbitalVelOverLifetime;
15417
- this.orbitalVelOverLifetime = orbitalVelOverLifetime;
15418
- this.gravityModifier = gravityModifier;
15419
- this.maxCount = maxCount;
15420
- this.duration = duration;
15421
- this.textureOffsets = textureFlip ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
15422
- }
15423
- Object.defineProperty(ParticleMesh.prototype, "time", {
15424
- get: function () {
15425
- var value = this.mesh.material.getVector4('uParams');
15426
- return value.x;
15427
- },
15428
- set: function (v) {
15429
- this.mesh.material.setVector4('uParams', new Vector4$1(+v, this.duration, 0, 0));
15430
- },
15431
- enumerable: false,
15432
- configurable: true
15433
- });
15434
- ParticleMesh.prototype.getPointColor = function (index) {
15435
- var data = this.geometry.getAttributeData('aRot');
15436
- var i = index * 32 + 4;
15437
- return [data[i], data[i + 1], data[i + 2], data[i + 3]];
15438
- };
15439
- /**
15440
- * 待废弃
15441
- * @deprecated - 使用 `particle-system.getPointPosition` 替代
15442
- */
15443
- ParticleMesh.prototype.getPointPosition = function (index) {
15444
- var geo = this.geometry;
15445
- var posIndex = index * 48;
15446
- var posData = geo.getAttributeData('aPos');
15447
- var offsetData = geo.getAttributeData('aOffset');
15448
- var time = this.time - offsetData[index * 16 + 2];
15449
- var pointDur = offsetData[index * 16 + 3];
15450
- var mtl = this.mesh.material;
15451
- var acc = mtl.getVector4('uAcceleration').toVector3();
15452
- var pos = Vector3.fromArray(posData, posIndex);
15453
- var vel = Vector3.fromArray(posData, posIndex + 3);
15454
- var ret = calculateTranslation(new Vector3(), this, acc, time, pointDur, pos, vel);
15455
- if (this.forceTarget) {
15456
- var target = mtl.getVector3('uFinalTarget');
15457
- var life = this.forceTarget.curve.getValue(time / pointDur);
15458
- var dl = 1 - life;
15459
- ret.x = ret.x * dl + target.x * life;
15460
- ret.y = ret.y * dl + target.y * life;
15461
- ret.z = ret.z * dl + target.z * life;
15462
- }
15463
- return ret;
15464
- };
15465
- ParticleMesh.prototype.clearPoints = function () {
15466
- this.resetGeometryData(this.geometry);
15467
- this.particleCount = 0;
15468
- this.geometry.setDrawCount(0);
15469
- this.maxParticleBufferCount = 0;
15470
- };
15471
- ParticleMesh.prototype.resetGeometryData = function (geometry) {
15472
- var names = geometry.getAttributeNames();
15473
- var index = geometry.getIndexData();
15474
- for (var i = 0; i < names.length; i++) {
15475
- var name_1 = names[i];
15476
- var data = geometry.getAttributeData(name_1);
15477
- if (data) {
15478
- // @ts-expect-error
15479
- geometry.setAttributeData(name_1, new data.constructor(0));
15480
- }
15481
- }
15482
- // @ts-expect-error
15483
- geometry.setIndexData(new index.constructor(0));
15484
- };
15485
- ParticleMesh.prototype.minusTime = function (time) {
15486
- var data = this.geometry.getAttributeData('aOffset');
15487
- for (var i = 0; i < data.length; i += 4) {
15488
- data[i + 2] -= time;
15489
- }
15490
- this.geometry.setAttributeData('aOffset', data);
15491
- this.time -= time;
15492
- };
15493
- ParticleMesh.prototype.removePoint = function (index) {
15494
- if (index < this.particleCount) {
15495
- this.geometry.setAttributeSubData('aOffset', index * 16, new Float32Array(16));
15496
- }
15497
- };
15498
- ParticleMesh.prototype.setPoint = function (point, index) {
15499
- var maxCount = this.maxCount;
15500
- if (index < maxCount) {
15501
- var particleCount = index + 1;
15502
- var vertexCount_1 = particleCount * 4;
15503
- var geometry_1 = this.geometry;
15504
- var increaseBuffer_1 = particleCount > this.maxParticleBufferCount;
15505
- var inc_1 = 1;
15506
- if (this.particleCount > 300) {
15507
- inc_1 = (this.particleCount + 100) / this.particleCount;
15508
- }
15509
- else if (this.particleCount > 100) {
15510
- inc_1 = 1.4;
15511
- }
15512
- else if (this.particleCount > 0) {
15513
- inc_1 = 2;
15514
- }
15515
- var pointData_1 = {
15516
- aPos: new Float32Array(48),
15517
- aRot: new Float32Array(32),
15518
- aOffset: new Float32Array(16),
15519
- };
15520
- var useSprite = this.useSprite;
15521
- if (useSprite) {
15522
- pointData_1.aSprite = new Float32Array(12);
15523
- }
15524
- var tempPos = new Vector3();
15525
- var tempQuat = new Quaternion();
15526
- var scale = new Vector3(1, 1, 1);
15527
- point.transform.assignWorldTRS(tempPos, tempQuat, scale);
15528
- var tempEuler = Transform.getRotation(tempQuat, new Euler());
15529
- var position = tempPos.toArray();
15530
- var rotation = tempEuler.toArray();
15531
- var offsets = this.textureOffsets;
15532
- var off = [0, 0, point.delay, point.lifetime];
15533
- var wholeUV = [0, 0, 1, 1];
15534
- var vel = point.vel;
15535
- var color = point.color;
15536
- var sizeOffsets = [-.5, .5, -.5, -.5, .5, .5, .5, -.5];
15537
- var seed = Math.random();
15538
- var sprite = void 0;
15539
- if (useSprite) {
15540
- sprite = point.sprite;
15541
- }
15542
- for (var j = 0; j < 4; j++) {
15543
- var offset = j * 2;
15544
- var j3 = j * 3;
15545
- var j4 = j * 4;
15546
- var j12 = j * 12;
15547
- var j8 = j * 8;
15548
- pointData_1.aPos.set(position, j12);
15549
- vel.fill(pointData_1.aPos, j12 + 3);
15550
- pointData_1.aRot.set(rotation, j8);
15551
- pointData_1.aRot[j8 + 3] = seed;
15552
- pointData_1.aRot.set(color, j8 + 4);
15553
- if (useSprite) {
15554
- // @ts-expect-error
15555
- pointData_1.aSprite.set(sprite, j3);
15556
- }
15557
- var uv = point.uv || wholeUV;
15558
- if (uv) {
15559
- var uvy = useSprite ? (1 - offsets[offset + 1]) : offsets[offset + 1];
15560
- off[0] = uv[0] + offsets[offset] * uv[2];
15561
- off[1] = uv[1] + uvy * uv[3];
15562
- }
15563
- pointData_1.aOffset.set(off, j4);
15564
- var ji = (j + j);
15565
- var sx = (sizeOffsets[ji] - this.anchor.x) * scale.x;
15566
- var sy = (sizeOffsets[ji + 1] - this.anchor.y) * scale.y;
15567
- for (var k = 0; k < 3; k++) {
15568
- pointData_1.aPos[j12 + 6 + k] = point.dirX.getElement(k) * sx;
15569
- pointData_1.aPos[j12 + 9 + k] = point.dirY.getElement(k) * sy;
15570
- }
15571
- }
15572
- var indexData = new Uint16Array([0, 1, 2, 2, 1, 3].map(function (x) { return x + index * 4; }));
15573
- if (increaseBuffer_1) {
15574
- var baseIndexData = geometry_1.getIndexData();
15575
- var idx = enlargeBuffer(baseIndexData, particleCount * 6, inc_1, maxCount * 6);
15576
- idx.set(indexData, index * 6);
15577
- geometry_1.setIndexData(idx);
15578
- this.maxParticleBufferCount = idx.length / 6;
15579
- }
15580
- else {
15581
- geometry_1.setIndexSubData(index * 6, indexData);
15582
- }
15583
- Object.keys(pointData_1).forEach(function (name) {
15584
- var data = pointData_1[name];
15585
- var attrSize = geometry_1.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
15586
- if (increaseBuffer_1) {
15587
- var baseData = geometry_1.getAttributeData(name);
15588
- var geoData = enlargeBuffer(baseData, vertexCount_1 * attrSize, inc_1, maxCount * 4 * attrSize);
15589
- geoData.set(data, data.length * index);
15590
- geometry_1.setAttributeData(name, geoData);
15591
- }
15592
- else {
15593
- geometry_1.setAttributeSubData(name, data.length * index, data);
15594
- }
15595
- });
15596
- this.particleCount = Math.max(particleCount, this.particleCount);
15597
- geometry_1.setDrawCount(this.particleCount * 6);
15598
- }
15599
- };
15600
- return ParticleMesh;
15601
- }());
15602
- var gl2UniformSlots = [10, 32, 64, 160];
15603
- function getSlot(count) {
15604
- for (var w = 0; w < gl2UniformSlots.length; w++) {
15605
- var slot = gl2UniformSlots[w];
15606
- if (slot > count) {
15607
- return slot;
15608
- }
15609
- }
15610
- return count || gl2UniformSlots[0];
15611
- }
15612
- function generateGeometryProps(maxVertex, useSprite, name) {
15613
- var bpe = Float32Array.BYTES_PER_ELEMENT;
15614
- var j12 = bpe * 12;
15615
- var attributes = {
15616
- aPos: { size: 3, offset: 0, stride: j12, data: new Float32Array(0) },
15617
- aVel: { size: 3, offset: 3 * bpe, stride: j12, dataSource: 'aPos' },
15618
- aDirX: { size: 3, offset: 6 * bpe, stride: j12, dataSource: 'aPos' },
15619
- aDirY: { size: 3, offset: 9 * bpe, stride: j12, dataSource: 'aPos' },
15620
- //
15621
- aRot: { size: 3, offset: 0, stride: 8 * bpe, data: new Float32Array(0) },
15622
- aSeed: { size: 1, offset: 3 * bpe, stride: 8 * bpe, dataSource: 'aRot' },
15623
- aColor: { size: 4, offset: 4 * bpe, stride: 8 * bpe, dataSource: 'aRot' },
15624
- //
15625
- aOffset: { size: 4, stride: 4 * bpe, data: new Float32Array(0) },
15626
- };
15627
- if (useSprite) {
15628
- attributes['aSprite'] = { size: 3, data: new Float32Array(0) };
15629
- }
15630
- return { attributes: attributes, indices: { data: new Uint16Array(0) }, name: name, maxVertex: maxVertex };
15631
- }
15632
- function getParticleMeshShader(item, env, gpuCapability) {
15633
- var _a, _b, _c, _d, _e;
15634
- if (env === void 0) { env = ''; }
15635
- var props = item.content;
15636
- var renderMode = +(((_a = props.renderer) === null || _a === void 0 ? void 0 : _a.renderMode) || 0);
15637
- var marcos = [
15638
- ['RENDER_MODE', renderMode],
15639
- ['PRE_MULTIPLY_ALPHA', false],
15640
- ['ENV_EDITOR', env === PLAYER_OPTIONS_ENV_EDITOR],
15641
- ];
15642
- var level = gpuCapability.level, detail = gpuCapability.detail;
15643
- var vertexKeyFrameMeta = createKeyFrameMeta();
15644
- var fragmentKeyFrameMeta = createKeyFrameMeta();
15645
- var enableVertexTexture = detail.maxVertexUniforms > 0;
15646
- var speedOverLifetime = ((_b = props.positionOverLifetime) !== null && _b !== void 0 ? _b : {}).speedOverLifetime;
15647
- var vertex_lookup_texture = 0;
15648
- var shaderCacheId = 0;
15649
- if (enableVertexTexture) {
15650
- marcos.push(['ENABLE_VERTEX_TEXTURE', true]);
15651
- }
15652
- if (speedOverLifetime) {
15653
- marcos.push(['SPEED_OVER_LIFETIME', true]);
15654
- shaderCacheId |= 1 << 1;
15655
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, speedOverLifetime);
15656
- }
15657
- var sprite = props.textureSheetAnimation;
15658
- if (sprite && sprite.animate) {
15659
- marcos.push(['USE_SPRITE', true]);
15660
- shaderCacheId |= 1 << 2;
15661
- }
15662
- var filter = undefined;
15663
- if (props.filter && props.filter.name !== FILTER_NAME_NONE) {
15664
- marcos.push(['USE_FILTER', true]);
15665
- shaderCacheId |= 1 << 3;
15666
- var f = createFilterShaders(props.filter).find(function (f) { return f.isParticle; });
15667
- if (!f) {
15668
- throw Error("particle filter ".concat(props.filter.name, " not implement"));
15669
- }
15670
- filter = f;
15671
- (_c = f.uniforms) === null || _c === void 0 ? void 0 : _c.forEach(function (val) { return getKeyFrameMetaByRawValue(vertexKeyFrameMeta, val); });
15672
- // filter = processFilter(props.filter, fragmentKeyFrameMeta, vertexKeyFrameMeta, options);
15673
- }
15674
- var colorOverLifetime = props.colorOverLifetime;
15675
- if (colorOverLifetime && colorOverLifetime.color) {
15676
- marcos.push(['COLOR_OVER_LIFETIME', true]);
15677
- shaderCacheId |= 1 << 4;
15678
- }
15679
- var opacity = colorOverLifetime && colorOverLifetime.opacity;
15680
- if (opacity) {
15681
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, opacity);
15682
- }
15683
- var positionOverLifetime = props.positionOverLifetime;
15684
- var useOrbitalVel;
15685
- ['x', 'y', 'z'].forEach(function (pro, i) {
15686
- var defL = 0;
15687
- var linearPro = 'linear' + pro.toUpperCase();
15688
- var orbitalPro = 'orbital' + pro.toUpperCase();
15689
- if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime[linearPro]) {
15690
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime[linearPro]);
15691
- defL = 1;
15692
- shaderCacheId |= 1 << (7 + i);
15693
- }
15694
- marcos.push(["LINEAR_VEL_".concat(pro.toUpperCase()), defL]);
15695
- var defO = 0;
15696
- if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime[orbitalPro]) {
15697
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime[orbitalPro]);
15698
- defO = 1;
15699
- shaderCacheId |= 1 << (10 + i);
15700
- useOrbitalVel = true;
15701
- }
15702
- marcos.push(["ORB_VEL_".concat(pro.toUpperCase()), defO]);
15703
- });
15704
- if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.asMovement) {
15705
- marcos.push(['AS_LINEAR_MOVEMENT', true]);
15706
- shaderCacheId |= 1 << 5;
15707
- }
15708
- if (useOrbitalVel) {
15709
- if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.asRotation) {
15710
- marcos.push(['AS_ORBITAL_MOVEMENT', true]);
15711
- shaderCacheId |= 1 << 6;
15712
- }
15713
- }
15714
- var sizeOverLifetime = props.sizeOverLifetime;
15715
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.x);
15716
- if (sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.separateAxes) {
15717
- marcos.push(['SIZE_Y_BY_LIFE', 1]);
15718
- shaderCacheId |= 1 << 14;
15719
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.y);
15720
- }
15721
- var rot = props.rotationOverLifetime;
15722
- if (rot === null || rot === void 0 ? void 0 : rot.z) {
15723
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot === null || rot === void 0 ? void 0 : rot.z);
15724
- shaderCacheId |= 1 << 15;
15725
- marcos.push(['ROT_Z_LIFETIME', 1]);
15726
- }
15727
- if (rot === null || rot === void 0 ? void 0 : rot.separateAxes) {
15728
- if (rot.x) {
15729
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.x);
15730
- shaderCacheId |= 1 << 16;
15731
- marcos.push(['ROT_X_LIFETIME', 1]);
15732
- }
15733
- if (rot.y) {
15734
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.y);
15735
- shaderCacheId |= 1 << 17;
15736
- marcos.push(['ROT_Y_LIFETIME', 1]);
15737
- }
15738
- }
15739
- if (rot === null || rot === void 0 ? void 0 : rot.asRotation) {
15740
- marcos.push(['ROT_LIFETIME_AS_MOVEMENT', 1]);
15741
- shaderCacheId |= 1 << 18;
15742
- }
15743
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravityOverLifetime);
15744
- var forceOpt = positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.forceTarget;
15745
- if (forceOpt) {
15746
- marcos.push(['FINAL_TARGET', true]);
15747
- shaderCacheId |= 1 << 19;
15748
- getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime.forceCurve);
15749
- }
15750
- var HALF_FLOAT = detail.halfFloatTexture;
15751
- if (HALF_FLOAT && fragmentKeyFrameMeta.max) {
15752
- shaderCacheId |= 1 << 20;
15753
- }
15754
- var maxVertexUniforms = detail.maxVertexUniforms;
15755
- var vertexCurveTexture = vertexKeyFrameMeta.max + vertexKeyFrameMeta.curves.length - 32 > maxVertexUniforms;
15756
- if (getConfig(RENDER_PREFER_LOOKUP_TEXTURE)) {
15757
- vertexCurveTexture = true;
15758
- }
15759
- if (level === 2) {
15760
- vertexKeyFrameMeta.max = -1;
15761
- // vertexKeyFrameMeta.index = getSlot(vertexKeyFrameMeta.index);
15762
- if (fragmentKeyFrameMeta.index > 0) {
15763
- fragmentKeyFrameMeta.max = -1;
15764
- // fragmentKeyFrameMeta.index = getSlot(fragmentKeyFrameMeta.index);
15765
- }
15766
- }
15767
- if (vertexCurveTexture && HALF_FLOAT && enableVertexTexture) {
15768
- vertex_lookup_texture = 1;
15769
- }
15770
- var shaderCache = ['-p:', renderMode, shaderCacheId, vertexKeyFrameMeta.index, vertexKeyFrameMeta.max, fragmentKeyFrameMeta.index, fragmentKeyFrameMeta.max].join('+');
15771
- var shader = {
15772
- fragment: particleFrag,
15773
- vertex: "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert),
15774
- shared: true,
15775
- cacheId: shaderCache,
15776
- marcos: marcos,
15777
- name: "particle#".concat(item.name),
15778
- };
15779
- if (filter) {
15780
- shader.fragment = shader.fragment.replace(/#pragma\s+FILTER_FRAG/, (_d = filter.fragment) !== null && _d !== void 0 ? _d : '');
15781
- shader.vertex = shader.vertex.replace(/#pragma\s+FILTER_VERT/, filter.vertex || 'void filterMain(float t){}\n');
15782
- shader.cacheId += '+' + ((_e = props.filter) === null || _e === void 0 ? void 0 : _e.name);
15783
- }
15784
- 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]);
15785
- return { shader: shader, vertex: vertexKeyFrameMeta.index, fragment: fragmentKeyFrameMeta.index };
15786
- }
15787
- function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
15788
- var _a;
15789
- var shaderIds = (_a = shader.cacheId) === null || _a === void 0 ? void 0 : _a.split('+');
15790
- shaderIds[3] = maxVertex;
15791
- shaderIds[5] = maxFrag;
15792
- shader.cacheId = shaderIds.join('+');
15793
- if (!shader.marcos) {
15794
- return;
15795
- }
15796
- for (var i = 0; i < shader.marcos.length; i++) {
15797
- var marco = shader.marcos[i];
15798
- if (marco[0] === 'VERT_CURVE_VALUE_COUNT') {
15799
- marco[1] = maxVertex;
15800
- }
15801
- else if (marco[0] === 'FRAG_CURVE_VALUE_COUNT') {
15802
- marco[1] = maxFrag;
15803
- break;
15804
- }
15805
- }
15806
- }
15807
-
15808
- var LinkNode = /** @class */ (function () {
15809
- function LinkNode(content) {
15810
- this.content = content;
15811
- }
15812
- return LinkNode;
15813
- }());
15814
- var Link = /** @class */ (function () {
15815
- function Link(sort) {
15816
- this.sort = sort;
15817
- this.length = 0;
15818
- }
15819
- Link.prototype.findNodeByContent = function (filter) {
15820
- var node = this.first;
15821
- if (node) {
15822
- do {
15823
- if (filter(node.content)) {
15824
- return node;
15825
- }
15826
- // @ts-expect-error
15827
- // eslint-disable-next-line no-cond-assign
15828
- } while (node = node.next);
15829
- }
15830
- };
15831
- Link.prototype.insertNode = function (a, next) {
15832
- var b = a.next;
15833
- a.next = next;
15834
- next.pre = a;
15835
- next.next = b;
15836
- if (b) {
15837
- b.pre = next;
15838
- }
15839
- // a -> next -> b
15840
- };
15841
- Link.prototype.shiftNode = function (content) {
15842
- var node = new LinkNode(content);
15843
- this.length++;
15844
- if (this.length === 1) {
15845
- return this.first = this.last = node;
15846
- }
15847
- var current = this.first;
15848
- while (current) {
15849
- if (this.sort(current.content, node.content) <= 0) {
15850
- if (current.next) {
15851
- current = current.next;
15852
- }
15853
- else {
15854
- this.insertNode(current, node);
15855
- return this.last = node;
15856
- }
15857
- }
15858
- else {
15859
- if (current.pre) {
15860
- this.insertNode(current.pre, node);
15861
- }
15862
- else {
15863
- this.first = node;
15864
- node.next = current;
15865
- current.pre = node;
15866
- }
15867
- return node;
15868
- }
15869
- }
15870
- };
15871
- Link.prototype.pushNode = function (content) {
15872
- var node = new LinkNode(content);
15873
- this.length++;
15874
- if (this.length === 1) {
15875
- return this.last = this.first = node;
15876
- }
15877
- var current = this.last;
15878
- while (current) {
15879
- if (this.sort(node.content, current.content) <= 0) {
15880
- if (this.first === current) {
15881
- current.pre = node;
15882
- node.next = current;
15883
- return this.first = node;
15884
- }
15885
- else {
15886
- // @ts-expect-error
15887
- current = current.pre;
15888
- }
15889
- }
15890
- else {
15891
- this.insertNode(current, node);
15892
- if (current === this.last) {
15893
- this.last = node;
15894
- }
15895
- return node;
15896
- }
15897
- }
15898
- };
15899
- Link.prototype.removeNode = function (node) {
15900
- var current = this.first;
15901
- this.length--;
15902
- if (current === node) {
15903
- // @ts-expect-error
15904
- var a = this.first = current.next;
15905
- if (a) {
15906
- a.pre = null;
15907
- }
15908
- }
15909
- else if ((current = this.last) === node) {
15910
- // @ts-expect-error
15911
- var a = this.last = current.pre;
15912
- if (a) {
15913
- a.next = null;
15914
- }
15915
- }
15916
- else if (node) {
15917
- var pre = node.pre;
15918
- var next = node.next;
15919
- // @ts-expect-error
15920
- pre.next = next;
15921
- if (next) {
15922
- next.pre = pre;
15923
- }
15924
- }
15925
- node.pre = null;
15926
- node.next = null;
15927
- };
15928
- Link.prototype.forEach = function (func, thisObj) {
15929
- var node = this.first;
15930
- var i = 0;
15931
- if (node) {
15932
- do {
15933
- func.call(thisObj || this, node.content, i++);
15934
- // @ts-expect-error
15935
- // eslint-disable-next-line no-cond-assign
15936
- } while (node = node.next);
15937
- }
15938
- };
15939
- Link.prototype.forEachReverse = function (func, thisObj) {
15940
- var node = this.last;
15941
- var i = this.length - 1;
15942
- if (node) {
15943
- do {
15944
- func.call(thisObj || this, node.content, i--);
15945
- // @ts-expect-error
15946
- // eslint-disable-next-line no-cond-assign
15947
- } while (node = node.pre);
15706
+ };
15707
+ Link.prototype.forEachReverse = function (func, thisObj) {
15708
+ var node = this.last;
15709
+ var i = this.length - 1;
15710
+ if (node) {
15711
+ do {
15712
+ func.call(thisObj || this, node.content, i--);
15713
+ // @ts-expect-error
15714
+ // eslint-disable-next-line no-cond-assign
15715
+ } while (node = node.pre);
15948
15716
  }
15949
15717
  };
15950
15718
  return Link;
@@ -17035,11 +16803,11 @@ var TrailMesh = /** @class */ (function () {
17035
16803
  var uWidthOverTrail = widthOverTrail.toUniform(keyFrameMeta);
17036
16804
  marcos.push(['VERT_CURVE_VALUE_COUNT', keyFrameMeta.index], ['VERT_MAX_KEY_FRAME_COUNT', keyFrameMeta.max]);
17037
16805
  if (enableVertexTexture && lookUpTexture) {
17038
- var tex = generateHalfFloatTexture(engine, CurveValue.getAllData(keyFrameMeta, true), keyFrameMeta.index, 1);
16806
+ var tex = generateHalfFloatTexture(engine, ValueGetter.getAllData(keyFrameMeta, true), keyFrameMeta.index, 1);
17039
16807
  uniformValues.uVCurveValueTexture = tex;
17040
16808
  }
17041
16809
  else {
17042
- uniformValues.uVCurveValues = CurveValue.getAllData(keyFrameMeta);
16810
+ uniformValues.uVCurveValues = ValueGetter.getAllData(keyFrameMeta);
17043
16811
  }
17044
16812
  var vertex = createShaderWithMarcos(marcos, trailVert, ShaderType.vertex, level);
17045
16813
  var fragment = createShaderWithMarcos(marcos, particleFrag, ShaderType.fragment, level);
@@ -17118,8 +16886,10 @@ var TrailMesh = /** @class */ (function () {
17118
16886
  }
17119
16887
  else if (name === 'uVCurveValues') {
17120
16888
  var array = [];
17121
- array.push(new Vector4$1(value[0], value[1], value[2], value[3]));
17122
- array.push(new Vector4$1(value[4], value[5], value[6], value[7]));
16889
+ for (var i = 0; i < value.length; i = i + 4) {
16890
+ var v = new Vector4$1(value[i], value[i + 1], value[i + 2], value[i + 3]);
16891
+ array.push(v);
16892
+ }
17123
16893
  material.setVector4Array(name, array);
17124
16894
  }
17125
16895
  else {
@@ -17867,456 +17637,1129 @@ var ParticleSystem = /** @class */ (function () {
17867
17637
  this.onIterate(this);
17868
17638
  }
17869
17639
  else {
17870
- this.ended = true;
17871
- this.onEnd(this);
17872
- var endBehavior = options.endBehavior;
17873
- if (endBehavior === END_BEHAVIOR_FREEZE$1) {
17874
- this.frozen = true;
17875
- }
17640
+ this.ended = true;
17641
+ this.onEnd(this);
17642
+ var endBehavior = options.endBehavior;
17643
+ if (endBehavior === END_BEHAVIOR_FREEZE$1) {
17644
+ this.frozen = true;
17645
+ }
17646
+ }
17647
+ }
17648
+ else if (!options.looping) {
17649
+ if (this.reusable) ;
17650
+ else if (END_BEHAVIOR_DESTROY$1 === options.endBehavior) {
17651
+ var node = link_1.last;
17652
+ if (node && (node.content[0] - loopStartTime_1) < timePassed_1) {
17653
+ this.onUpdate = function () { return _this.onDestroy(); };
17654
+ }
17655
+ }
17656
+ }
17657
+ updateTrail();
17658
+ }
17659
+ };
17660
+ ParticleSystem.prototype.onDestroy = function () {
17661
+ };
17662
+ ParticleSystem.prototype.getParticleBoxes = function () {
17663
+ var link = this.particleLink;
17664
+ var mesh = this.particleMesh;
17665
+ var res = [];
17666
+ var maxCount = this.particleCount;
17667
+ var counter = 0;
17668
+ if (!(link && mesh)) {
17669
+ return res;
17670
+ }
17671
+ var node = link.last;
17672
+ var finish = false;
17673
+ while (!finish) {
17674
+ var currentTime = node.content[0];
17675
+ var point = node.content[3];
17676
+ if (currentTime > this.timePassed) {
17677
+ var pos = this.getPointPosition(point);
17678
+ res.push({
17679
+ center: pos,
17680
+ size: point.transform.scale,
17681
+ });
17682
+ if (node.pre) {
17683
+ node = node.pre;
17684
+ }
17685
+ else {
17686
+ finish = true;
17687
+ }
17688
+ }
17689
+ counter++;
17690
+ if (counter > maxCount) {
17691
+ finish = true;
17692
+ }
17693
+ }
17694
+ return res;
17695
+ };
17696
+ ParticleSystem.prototype.raycast = function (options) {
17697
+ var link = this.particleLink;
17698
+ var mesh = this.particleMesh;
17699
+ if (!(link && mesh)) {
17700
+ return;
17701
+ }
17702
+ var node = link.last;
17703
+ var hitPositions = [];
17704
+ var temp = new Vector3();
17705
+ var finish = false;
17706
+ if (node && node.content) {
17707
+ do {
17708
+ var _a = __read$3(node.content, 4), currentTime = _a[0], pointIndex = _a[1]; _a[2]; var point = _a[3];
17709
+ if (currentTime > this.timePassed) {
17710
+ var pos = this.getPointPosition(point);
17711
+ var ray = options.ray;
17712
+ var pass = false;
17713
+ if (ray) {
17714
+ pass = !!ray.intersectSphere({
17715
+ center: pos,
17716
+ radius: options.radius,
17717
+ }, temp);
17718
+ }
17719
+ if (pass) {
17720
+ if (options.removeParticle) {
17721
+ mesh.removePoint(pointIndex);
17722
+ this.clearPointTrail(pointIndex);
17723
+ node.content[0] = 0;
17724
+ }
17725
+ hitPositions.push(pos);
17726
+ if (!options.multiple) {
17727
+ finish = true;
17728
+ }
17729
+ }
17730
+ }
17731
+ else {
17732
+ break;
17733
+ }
17734
+ // @ts-expect-error
17735
+ } while ((node = node.pre) && !finish);
17736
+ }
17737
+ return hitPositions;
17738
+ };
17739
+ ParticleSystem.prototype.clearPointTrail = function (pointIndex) {
17740
+ var _a;
17741
+ if (this.trails && this.trails.dieWithParticles) {
17742
+ (_a = this.trailMesh) === null || _a === void 0 ? void 0 : _a.clearTrail(pointIndex);
17743
+ }
17744
+ };
17745
+ ParticleSystem.prototype.updatePointTrail = function (pointIndex, emitterLifetime, point, startTime) {
17746
+ if (!this.trailMesh) {
17747
+ return;
17748
+ }
17749
+ var trails = this.trails;
17750
+ var particleMesh = this.particleMesh;
17751
+ var position = this.getPointPosition(point);
17752
+ var color = trails.inheritParticleColor ? particleMesh.getPointColor(pointIndex) : [1, 1, 1, 1];
17753
+ var size = point.transform.getWorldScale().toArray();
17754
+ var width = 1;
17755
+ var lifetime = trails.lifetime.getValue(emitterLifetime);
17756
+ if (trails.sizeAffectsWidth) {
17757
+ width *= size[0];
17758
+ }
17759
+ if (trails.sizeAffectsLifetime) {
17760
+ lifetime *= size[0];
17761
+ }
17762
+ if (trails.parentAffectsPosition && this.transform.parentTransform) {
17763
+ position.add(this.transform.parentTransform.position);
17764
+ var pos = this.trailMesh.getPointStartPos(pointIndex);
17765
+ if (pos) {
17766
+ position.subtract(pos);
17767
+ }
17768
+ }
17769
+ this.trailMesh.addPoint(pointIndex, position, {
17770
+ color: color,
17771
+ lifetime: lifetime,
17772
+ size: width,
17773
+ time: startTime,
17774
+ });
17775
+ };
17776
+ ParticleSystem.prototype.getPointPosition = function (point) {
17777
+ var transform = point.transform, vel = point.vel, lifetime = point.lifetime, delay = point.delay, _a = point.gravity, gravity = _a === void 0 ? [] : _a;
17778
+ var forceTarget = this.options.forceTarget;
17779
+ var time = this.lastUpdate - delay;
17780
+ var tempPos = new Vector3();
17781
+ var acc = Vector3.fromArray(gravity);
17782
+ transform.assignWorldTRS(tempPos);
17783
+ var ret = calculateTranslation(new Vector3(), this.options, acc, time, lifetime, tempPos, vel);
17784
+ if (forceTarget) {
17785
+ var target = forceTarget.target || [0, 0, 0];
17786
+ var life = forceTarget.curve.getValue(time / lifetime);
17787
+ var dl = 1 - life;
17788
+ ret.x = ret.x * dl + target[0] * life;
17789
+ ret.y = ret.y * dl + target[1] * life;
17790
+ ret.z = ret.z * dl + target[2] * life;
17791
+ }
17792
+ return ret;
17793
+ };
17794
+ ParticleSystem.prototype.onEnd = function (particle) {
17795
+ };
17796
+ ParticleSystem.prototype.onIterate = function (particle) {
17797
+ };
17798
+ ParticleSystem.prototype.initPoint = function (data) {
17799
+ var options = this.options;
17800
+ var lifetime = this.lifetime;
17801
+ var shape = this.shape;
17802
+ var speed = options.startSpeed.getValue(lifetime);
17803
+ var matrix4 = options.particleFollowParent ? this.transform.getMatrix() : this.transform.getWorldMatrix();
17804
+ // 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
17805
+ var position = matrix4.transformPoint(data.position, new Vector3());
17806
+ var transform = new Transform({
17807
+ position: position,
17808
+ valid: true,
17809
+ });
17810
+ var direction = data.direction;
17811
+ direction = matrix4.transformNormal(direction, tempDir).normalize();
17812
+ if (options.startTurbulence && options.turbulence) {
17813
+ for (var i = 0; i < 3; i++) {
17814
+ tempVec3.setElement(i, options.turbulence[i].getValue(lifetime));
17815
+ }
17816
+ tempEuler.setFromVector3(tempVec3.negate());
17817
+ var mat4 = tempMat4.setFromEuler(tempEuler);
17818
+ mat4.transformNormal(direction).normalize();
17819
+ }
17820
+ var dirX = tmpDirX;
17821
+ var dirY = tmpDirY;
17822
+ if (shape.alignSpeedDirection) {
17823
+ dirY.copyFrom(direction);
17824
+ if (!this.upDirectionWorld) {
17825
+ if (shape.upDirection) {
17826
+ this.upDirectionWorld = shape.upDirection.clone();
17827
+ }
17828
+ else {
17829
+ this.upDirectionWorld = Vector3.Z.clone();
17876
17830
  }
17831
+ matrix4.transformNormal(this.upDirectionWorld);
17877
17832
  }
17878
- else if (!options.looping) {
17879
- if (this.reusable) ;
17880
- else if (END_BEHAVIOR_DESTROY$1 === options.endBehavior) {
17881
- var node = link_1.last;
17882
- if (node && (node.content[0] - loopStartTime_1) < timePassed_1) {
17883
- this.onUpdate = function () { return _this.onDestroy(); };
17884
- }
17885
- }
17833
+ dirX.crossVectors(dirY, this.upDirectionWorld).normalize();
17834
+ // FIXME: 原先因为有精度问题,这里dirX不是0向量
17835
+ if (dirX.isZero()) {
17836
+ dirX.set(1, 0, 0);
17886
17837
  }
17887
- updateTrail();
17888
17838
  }
17839
+ else {
17840
+ dirX.set(1, 0, 0);
17841
+ dirY.set(0, 1, 0);
17842
+ }
17843
+ var sprite;
17844
+ var tsa = this.textureSheetAnimation;
17845
+ if (tsa && tsa.animate) {
17846
+ sprite = tempSprite;
17847
+ sprite[0] = tsa.animationDelay.getValue(lifetime);
17848
+ sprite[1] = tsa.animationDuration.getValue(lifetime);
17849
+ sprite[2] = tsa.cycles.getValue(lifetime);
17850
+ }
17851
+ var rot = tempRot;
17852
+ if (options.start3DRotation) {
17853
+ // @ts-expect-error
17854
+ rot.set(options.startRotationX.getValue(lifetime), options.startRotationY.getValue(lifetime), options.startRotationZ.getValue(lifetime));
17855
+ }
17856
+ else if (options.startRotation) {
17857
+ rot.set(0, 0, options.startRotation.getValue(lifetime));
17858
+ }
17859
+ else {
17860
+ rot.set(0, 0, 0);
17861
+ }
17862
+ transform.setRotation(rot.x, rot.y, rot.z);
17863
+ var color = options.startColor.getValue(lifetime);
17864
+ if (color.length === 3) {
17865
+ color[3] = 1;
17866
+ }
17867
+ var size = tempSize;
17868
+ if (options.start3DSize) {
17869
+ size.x = options.startSizeX.getValue(lifetime);
17870
+ size.y = options.startSizeY.getValue(lifetime);
17871
+ }
17872
+ else {
17873
+ var n = options.startSize.getValue(lifetime);
17874
+ var aspect = options.sizeAspect.getValue(lifetime);
17875
+ size.x = n;
17876
+ // 兼容aspect为0的情况
17877
+ size.y = aspect === 0 ? 0 : n / aspect;
17878
+ // size[1] = n / aspect;
17879
+ }
17880
+ var vel = direction.clone();
17881
+ vel.multiply(speed);
17882
+ // 粒子的大小受发射器父节点的影响
17883
+ if (!options.particleFollowParent) {
17884
+ var tempScale = new Vector3();
17885
+ this.transform.assignWorldTRS(undefined, undefined, tempScale);
17886
+ size.x *= tempScale.x;
17887
+ size.y *= tempScale.y;
17888
+ }
17889
+ transform.setScale(size.x, size.y, 1);
17890
+ return {
17891
+ size: size,
17892
+ vel: vel,
17893
+ color: color,
17894
+ delay: options.startDelay.getValue(lifetime),
17895
+ lifetime: options.startLifetime.getValue(lifetime),
17896
+ uv: randomArrItem(this.uvs, true),
17897
+ gravity: options.gravity,
17898
+ sprite: sprite,
17899
+ dirY: dirY,
17900
+ dirX: dirX,
17901
+ transform: transform,
17902
+ };
17889
17903
  };
17890
- ParticleSystem.prototype.onDestroy = function () {
17904
+ ParticleSystem.prototype.addBurst = function (burst, offsets) {
17905
+ var willAdd = false;
17906
+ if (!this.emission.bursts.includes(burst)) {
17907
+ this.emission.bursts.push(burst);
17908
+ willAdd = true;
17909
+ }
17910
+ if (willAdd && offsets instanceof Array) {
17911
+ var index = this.emission.bursts.indexOf(burst);
17912
+ this.emission.burstOffsets[index] = offsets;
17913
+ return index;
17914
+ }
17915
+ return -1;
17891
17916
  };
17892
- ParticleSystem.prototype.getParticleBoxes = function () {
17893
- var link = this.particleLink;
17894
- var mesh = this.particleMesh;
17895
- var res = [];
17896
- var maxCount = this.particleCount;
17897
- var counter = 0;
17898
- if (!(link && mesh)) {
17899
- return res;
17917
+ ParticleSystem.prototype.removeBurst = function (index) {
17918
+ if (index < this.emission.bursts.length) {
17919
+ this.emission.burstOffsets[index] = null;
17920
+ this.emission.bursts.splice(index, 1);
17900
17921
  }
17901
- var node = link.last;
17902
- var finish = false;
17903
- while (!finish) {
17904
- var currentTime = node.content[0];
17905
- var point = node.content[3];
17906
- if (currentTime > this.timePassed) {
17907
- var pos = this.getPointPosition(point);
17908
- res.push({
17909
- center: pos,
17910
- size: point.transform.scale,
17911
- });
17912
- if (node.pre) {
17913
- node = node.pre;
17914
- }
17915
- else {
17916
- finish = true;
17917
- }
17922
+ };
17923
+ ParticleSystem.prototype.createPoint = function (lifetime) {
17924
+ var generator = {
17925
+ total: this.emission.rateOverTime.getValue(lifetime),
17926
+ index: this.generatedCount,
17927
+ burstIndex: 0,
17928
+ burstCount: 0,
17929
+ };
17930
+ this.generatedCount++;
17931
+ return this.initPoint(this.shape.generate(generator));
17932
+ };
17933
+ return ParticleSystem;
17934
+ }());
17935
+ // array performance better for small memory than Float32Array
17936
+ var tempDir = new Vector3();
17937
+ var tempSize = new Vector2();
17938
+ var tempRot = new Euler();
17939
+ var tmpDirX = new Vector3();
17940
+ var tmpDirY = new Vector3();
17941
+ var tempVec3 = new Vector3();
17942
+ var tempEuler = new Euler();
17943
+ var tempSprite = [0, 0, 0];
17944
+ var tempMat4 = new Matrix4$1();
17945
+ function getBurstOffsets(burstOffsets) {
17946
+ var ret = {};
17947
+ if (Array.isArray(burstOffsets)) {
17948
+ burstOffsets.forEach(function (arr) {
17949
+ var isArr = arr instanceof Array;
17950
+ var index = isArr ? arr[0] : arr.index;
17951
+ var offsets = ret[index];
17952
+ if (!offsets) {
17953
+ offsets = ret[index] = [];
17918
17954
  }
17919
- counter++;
17920
- if (counter > maxCount) {
17921
- finish = true;
17955
+ if (isArr) {
17956
+ offsets.push(arr.slice(1, 4));
17922
17957
  }
17923
- }
17924
- return res;
17958
+ else {
17959
+ offsets.push([+arr.x, +arr.y, +arr.z]);
17960
+ }
17961
+ });
17962
+ }
17963
+ return ret;
17964
+ }
17965
+ function randomArrItem(arr, keepArr) {
17966
+ var index = Math.floor(Math.random() * arr.length);
17967
+ var item = arr[index];
17968
+ if (!keepArr) {
17969
+ arr.splice(index, 1);
17970
+ }
17971
+ return item;
17972
+ }
17973
+
17974
+ var ParticleVFXItem = /** @class */ (function (_super) {
17975
+ __extends(ParticleVFXItem, _super);
17976
+ function ParticleVFXItem() {
17977
+ var _this = _super !== null && _super.apply(this, arguments) || this;
17978
+ _this.destroyed = false;
17979
+ return _this;
17980
+ }
17981
+ Object.defineProperty(ParticleVFXItem.prototype, "type", {
17982
+ get: function () {
17983
+ return ItemType$1.particle;
17984
+ },
17985
+ enumerable: false,
17986
+ configurable: true
17987
+ });
17988
+ ParticleVFXItem.prototype.onConstructed = function (props) {
17989
+ this.particle = props.content;
17925
17990
  };
17926
- ParticleSystem.prototype.raycast = function (options) {
17927
- var link = this.particleLink;
17928
- var mesh = this.particleMesh;
17929
- if (!(link && mesh)) {
17930
- return;
17991
+ ParticleVFXItem.prototype.onLifetimeBegin = function (composition, particleSystem) {
17992
+ var _this = this;
17993
+ if (particleSystem) {
17994
+ particleSystem.name = this.name;
17995
+ particleSystem.start();
17996
+ particleSystem.onDestroy = function () {
17997
+ _this.destroyed = true;
17998
+ };
17931
17999
  }
17932
- var node = link.last;
17933
- var hitPositions = [];
17934
- var temp = new Vector3();
17935
- var finish = false;
17936
- if (node && node.content) {
17937
- do {
17938
- var _a = __read$3(node.content, 4), currentTime = _a[0], pointIndex = _a[1]; _a[2]; var point = _a[3];
17939
- if (currentTime > this.timePassed) {
17940
- var pos = this.getPointPosition(point);
17941
- var ray = options.ray;
17942
- var pass = false;
17943
- if (ray) {
17944
- pass = !!ray.intersectSphere({
17945
- center: pos,
17946
- radius: options.radius,
17947
- }, temp);
17948
- }
17949
- if (pass) {
17950
- if (options.removeParticle) {
17951
- mesh.removePoint(pointIndex);
17952
- this.clearPointTrail(pointIndex);
17953
- node.content[0] = 0;
17954
- }
17955
- hitPositions.push(pos);
17956
- if (!options.multiple) {
17957
- finish = true;
17958
- }
18000
+ return particleSystem;
18001
+ };
18002
+ ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
18003
+ var _a;
18004
+ if (this.content) {
18005
+ var hide = !this.visible;
18006
+ var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
18007
+ if (!hide && parentItem) {
18008
+ var parentData = parentItem.getRenderData();
18009
+ if (parentData) {
18010
+ if (!parentData.visible) {
18011
+ hide = false;
17959
18012
  }
17960
18013
  }
17961
- else {
17962
- break;
17963
- }
17964
- // @ts-expect-error
17965
- } while ((node = node.pre) && !finish);
18014
+ }
18015
+ if (hide) {
18016
+ this.content.setVisible(false);
18017
+ }
18018
+ else {
18019
+ this.content.setVisible(true);
18020
+ this.content.onUpdate(dt);
18021
+ }
17966
18022
  }
17967
- return hitPositions;
17968
18023
  };
17969
- ParticleSystem.prototype.clearPointTrail = function (pointIndex) {
17970
- var _a;
17971
- if (this.trails && this.trails.dieWithParticles) {
17972
- (_a = this.trailMesh) === null || _a === void 0 ? void 0 : _a.clearTrail(pointIndex);
18024
+ ParticleVFXItem.prototype.onItemRemoved = function (composition, content) {
18025
+ if (content) {
18026
+ composition.destroyTextures(content.getTextures());
18027
+ content.meshes.forEach(function (mesh) { return mesh.dispose({ material: { textures: DestroyOptions.keep } }); });
17973
18028
  }
17974
18029
  };
17975
- ParticleSystem.prototype.updatePointTrail = function (pointIndex, emitterLifetime, point, startTime) {
17976
- if (!this.trailMesh) {
17977
- return;
18030
+ /**
18031
+ * @internal
18032
+ */
18033
+ ParticleVFXItem.prototype.setColor = function (r, g, b, a) {
18034
+ this.content.setColor(r, g, b, a);
18035
+ };
18036
+ ParticleVFXItem.prototype.setOpacity = function (opacity) {
18037
+ this.content.setOpacity(opacity);
18038
+ };
18039
+ ParticleVFXItem.prototype.stopParticleEmission = function () {
18040
+ if (this.content) {
18041
+ this.content.emissionStopped = true;
17978
18042
  }
17979
- var trails = this.trails;
17980
- var particleMesh = this.particleMesh;
17981
- var position = this.getPointPosition(point);
17982
- var color = trails.inheritParticleColor ? particleMesh.getPointColor(pointIndex) : [1, 1, 1, 1];
17983
- var size = point.transform.getWorldScale().toArray();
17984
- var width = 1;
17985
- var lifetime = trails.lifetime.getValue(emitterLifetime);
17986
- if (trails.sizeAffectsWidth) {
17987
- width *= size[0];
18043
+ };
18044
+ ParticleVFXItem.prototype.resumeParticleEmission = function () {
18045
+ if (this.content) {
18046
+ this.content.emissionStopped = false;
17988
18047
  }
17989
- if (trails.sizeAffectsLifetime) {
17990
- lifetime *= size[0];
18048
+ };
18049
+ ParticleVFXItem.prototype.doCreateContent = function (composition) {
18050
+ assertExist(this.particle);
18051
+ return new ParticleSystem(this.particle, composition.getRendererOptions(), this);
18052
+ };
18053
+ ParticleVFXItem.prototype.isEnded = function (now) {
18054
+ return _super.prototype.isEnded.call(this, now) && this.destroyed;
18055
+ };
18056
+ ParticleVFXItem.prototype.getBoundingBox = function () {
18057
+ var pt = this.content;
18058
+ if (!pt) {
18059
+ return;
17991
18060
  }
17992
- if (trails.parentAffectsPosition && this.transform.parentTransform) {
17993
- position.add(this.transform.parentTransform.position);
17994
- var pos = this.trailMesh.getPointStartPos(pointIndex);
17995
- if (pos) {
17996
- position.subtract(pos);
17997
- }
18061
+ else {
18062
+ var area = pt.getParticleBoxes();
18063
+ return {
18064
+ type: HitTestType.sphere,
18065
+ area: area,
18066
+ };
17998
18067
  }
17999
- this.trailMesh.addPoint(pointIndex, position, {
18000
- color: color,
18001
- lifetime: lifetime,
18002
- size: width,
18003
- time: startTime,
18004
- });
18005
18068
  };
18006
- ParticleSystem.prototype.getPointPosition = function (point) {
18007
- var transform = point.transform, vel = point.vel, lifetime = point.lifetime, delay = point.delay, _a = point.gravity, gravity = _a === void 0 ? [] : _a;
18008
- var forceTarget = this.options.forceTarget;
18009
- var time = this.lastUpdate - delay;
18010
- var tempPos = new Vector3();
18011
- var acc = Vector3.fromArray(gravity);
18012
- transform.assignWorldTRS(tempPos);
18013
- var ret = calculateTranslation(new Vector3(), this.options, acc, time, lifetime, tempPos, vel);
18014
- if (forceTarget) {
18015
- var target = forceTarget.target || [0, 0, 0];
18016
- var life = forceTarget.curve.getValue(time / lifetime);
18017
- var dl = 1 - life;
18018
- ret.x = ret.x * dl + target[0] * life;
18019
- ret.y = ret.y * dl + target[1] * life;
18020
- ret.z = ret.z * dl + target[2] * life;
18069
+ ParticleVFXItem.prototype.getHitTestParams = function (force) {
18070
+ var _this = this;
18071
+ var _a;
18072
+ var interactParams = (_a = this.content) === null || _a === void 0 ? void 0 : _a.interaction;
18073
+ if (force || interactParams) {
18074
+ return {
18075
+ type: HitTestType.custom,
18076
+ collect: function (ray) {
18077
+ var _a;
18078
+ return (_a = _this.content) === null || _a === void 0 ? void 0 : _a.raycast({
18079
+ radius: (interactParams === null || interactParams === void 0 ? void 0 : interactParams.radius) || 0.4,
18080
+ multiple: !!(interactParams === null || interactParams === void 0 ? void 0 : interactParams.multiple),
18081
+ removeParticle: (interactParams === null || interactParams === void 0 ? void 0 : interactParams.behavior) === ParticleInteractionBehavior$1.removeParticle,
18082
+ ray: ray,
18083
+ });
18084
+ },
18085
+ };
18021
18086
  }
18022
- return ret;
18023
18087
  };
18024
- ParticleSystem.prototype.onEnd = function (particle) {
18025
- };
18026
- ParticleSystem.prototype.onIterate = function (particle) {
18027
- };
18028
- ParticleSystem.prototype.initPoint = function (data) {
18029
- var options = this.options;
18030
- var lifetime = this.lifetime;
18031
- var shape = this.shape;
18032
- var speed = options.startSpeed.getValue(lifetime);
18033
- var matrix4 = options.particleFollowParent ? this.transform.getMatrix() : this.transform.getWorldMatrix();
18034
- // 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
18035
- var position = matrix4.transformPoint(data.position, new Vector3());
18036
- var transform = new Transform({
18037
- position: position,
18038
- valid: true,
18039
- });
18040
- var direction = data.direction;
18041
- direction = matrix4.transformNormal(direction, tempDir).normalize();
18042
- if (options.startTurbulence && options.turbulence) {
18043
- for (var i = 0; i < 3; i++) {
18044
- tempVec3.setElement(i, options.turbulence[i].getValue(lifetime));
18045
- }
18046
- tempEuler.setFromVector3(tempVec3.negate());
18047
- var mat4 = tempMat4.setFromEuler(tempEuler);
18048
- mat4.transformNormal(direction).normalize();
18088
+ return ParticleVFXItem;
18089
+ }(VFXItem));
18090
+ var particleUniformTypeMap = {
18091
+ 'uSprite': 'vec4',
18092
+ 'uParams': 'vec4',
18093
+ 'uAcceleration': 'vec4',
18094
+ 'uGravityModifierValue': 'vec4',
18095
+ 'uOpacityOverLifetimeValue': 'vec4',
18096
+ 'uRXByLifeTimeValue': 'vec4',
18097
+ 'uRYByLifeTimeValue': 'vec4',
18098
+ 'uRZByLifeTimeValue': 'vec4',
18099
+ 'uLinearXByLifetimeValue': 'vec4',
18100
+ 'uLinearYByLifetimeValue': 'vec4',
18101
+ 'uLinearZByLifetimeValue': 'vec4',
18102
+ 'uSpeedLifetimeValue': 'vec4',
18103
+ 'uOrbXByLifetimeValue': 'vec4',
18104
+ 'uOrbYByLifetimeValue': 'vec4',
18105
+ 'uOrbZByLifetimeValue': 'vec4',
18106
+ 'uSizeByLifetimeValue': 'vec4',
18107
+ 'uSizeYByLifetimeValue': 'vec4',
18108
+ 'uColorParams': 'vec4',
18109
+ 'uFSprite': 'vec4',
18110
+ 'uPreviewColor': 'vec4',
18111
+ 'uVCurveValues': 'vec4Array',
18112
+ 'uFCurveValues': 'vec4',
18113
+ 'uFinalTarget': 'vec3',
18114
+ 'uForceCurve': 'vec4',
18115
+ 'uOrbCenter': 'vec3',
18116
+ 'uTexOffset': 'vec2',
18117
+ 'uPeriodValue': 'vec4',
18118
+ 'uMovementValue': 'vec4',
18119
+ 'uStrengthValue': 'vec4',
18120
+ 'uWaveParams': 'vec4',
18121
+ };
18122
+
18123
+ var ParticleMesh = /** @class */ (function () {
18124
+ function ParticleMesh(props, rendererOptions) {
18125
+ var _a, _b, _c, _d;
18126
+ this.particleCount = 0;
18127
+ var engine = rendererOptions.composition.getEngine();
18128
+ var env = ((_a = engine.renderer) !== null && _a !== void 0 ? _a : {}).env;
18129
+ 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;
18130
+ var detail = engine.gpuCapability.detail;
18131
+ var halfFloatTexture = detail.halfFloatTexture, maxVertexUniforms = detail.maxVertexUniforms;
18132
+ var marcos = [
18133
+ ['RENDER_MODE', +renderMode],
18134
+ ['PRE_MULTIPLY_ALPHA', false],
18135
+ ['ENV_EDITOR', env === PLAYER_OPTIONS_ENV_EDITOR],
18136
+ ];
18137
+ var level = engine.gpuCapability.level;
18138
+ var vertexKeyFrameMeta = createKeyFrameMeta();
18139
+ var fragmentKeyFrameMeta = createKeyFrameMeta();
18140
+ var enableVertexTexture = maxVertexUniforms > 0;
18141
+ var uniformValues = {};
18142
+ var vertex_lookup_texture = 0;
18143
+ var shaderCacheId = 0;
18144
+ var particleDefine;
18145
+ var useOrbitalVel;
18146
+ this.useSprite = useSprite;
18147
+ if (enableVertexTexture) {
18148
+ marcos.push(['ENABLE_VERTEX_TEXTURE', true]);
18049
18149
  }
18050
- var dirX = tmpDirX;
18051
- var dirY = tmpDirY;
18052
- if (shape.alignSpeedDirection) {
18053
- dirY.copyFrom(direction);
18054
- if (!this.upDirectionWorld) {
18055
- if (shape.upDirection) {
18056
- this.upDirectionWorld = shape.upDirection.clone();
18150
+ if (speedOverLifetime) {
18151
+ marcos.push(['SPEED_OVER_LIFETIME', true]);
18152
+ shaderCacheId |= 1 << 1;
18153
+ uniformValues.uSpeedLifetimeValue = speedOverLifetime.toUniform(vertexKeyFrameMeta);
18154
+ }
18155
+ if (sprite === null || sprite === void 0 ? void 0 : sprite.animate) {
18156
+ marcos.push(['USE_SPRITE', true]);
18157
+ shaderCacheId |= 1 << 2;
18158
+ uniformValues.uFSprite = uniformValues.uSprite = new Float32Array([sprite.col, sprite.row, sprite.total, sprite.blend ? 1 : 0]);
18159
+ this.useSprite = true;
18160
+ }
18161
+ if (filter && filter.name !== FILTER_NAME_NONE) {
18162
+ marcos.push(['USE_FILTER', true]);
18163
+ shaderCacheId |= 1 << 3;
18164
+ var filterDefine = createFilter(filter, rendererOptions.composition);
18165
+ if (!filterDefine.particle) {
18166
+ throw new Error("particle filter ".concat(filter.name, " not implement"));
18167
+ }
18168
+ particleDefine = filterDefine.particle;
18169
+ Object.keys((_b = particleDefine.uniforms) !== null && _b !== void 0 ? _b : {}).forEach(function (uName) {
18170
+ var _a;
18171
+ var getter = (_a = particleDefine.uniforms) === null || _a === void 0 ? void 0 : _a[uName];
18172
+ if (uniformValues[uName]) {
18173
+ throw new Error('conflict uniform name:' + uName);
18057
18174
  }
18058
- else {
18059
- this.upDirectionWorld = Vector3.Z.clone();
18175
+ uniformValues[uName] = getter === null || getter === void 0 ? void 0 : getter.toUniform(vertexKeyFrameMeta);
18176
+ });
18177
+ Object.keys((_c = particleDefine.uniformValues) !== null && _c !== void 0 ? _c : {}).forEach(function (uName) {
18178
+ var _a;
18179
+ var val = (_a = particleDefine.uniformValues) === null || _a === void 0 ? void 0 : _a[uName];
18180
+ if (uniformValues[uName]) {
18181
+ throw new Error('conflict uniform name:' + uName);
18060
18182
  }
18061
- matrix4.transformNormal(this.upDirectionWorld);
18183
+ uniformValues[uName] = val;
18184
+ });
18185
+ }
18186
+ if (colorOverLifetime === null || colorOverLifetime === void 0 ? void 0 : colorOverLifetime.color) {
18187
+ marcos.push(['COLOR_OVER_LIFETIME', true]);
18188
+ shaderCacheId |= 1 << 4;
18189
+ uniformValues.uColorOverLifetime = colorOverLifetime.color instanceof Texture ? colorOverLifetime.color : Texture.createWithData(engine, imageDataFromGradient(colorOverLifetime.color));
18190
+ }
18191
+ if (colorOverLifetime === null || colorOverLifetime === void 0 ? void 0 : colorOverLifetime.opacity) {
18192
+ uniformValues.uOpacityOverLifetimeValue = colorOverLifetime.opacity.toUniform(vertexKeyFrameMeta);
18193
+ }
18194
+ else {
18195
+ uniformValues.uOpacityOverLifetimeValue = createValueGetter(1).toUniform(vertexKeyFrameMeta);
18196
+ }
18197
+ ['x', 'y', 'z'].forEach(function (pro, i) {
18198
+ var defL = 0;
18199
+ var defO = 0;
18200
+ if (linearVelOverLifetime === null || linearVelOverLifetime === void 0 ? void 0 : linearVelOverLifetime[pro]) {
18201
+ uniformValues["uLinear".concat(pro.toUpperCase(), "ByLifetimeValue")] = linearVelOverLifetime[pro].toUniform(vertexKeyFrameMeta);
18202
+ defL = 1;
18203
+ shaderCacheId |= 1 << (7 + i);
18204
+ linearVelOverLifetime.enabled = true;
18062
18205
  }
18063
- dirX.crossVectors(dirY, this.upDirectionWorld).normalize();
18064
- // FIXME: 原先因为有精度问题,这里dirX不是0向量
18065
- if (dirX.isZero()) {
18066
- dirX.set(1, 0, 0);
18206
+ marcos.push(["LINEAR_VEL_".concat(pro.toUpperCase()), defL]);
18207
+ if (orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime[pro]) {
18208
+ uniformValues["uOrb".concat(pro.toUpperCase(), "ByLifetimeValue")] = orbitalVelOverLifetime[pro].toUniform(vertexKeyFrameMeta);
18209
+ defO = 1;
18210
+ shaderCacheId |= 1 << (10 + i);
18211
+ useOrbitalVel = true;
18212
+ orbitalVelOverLifetime.enabled = true;
18213
+ }
18214
+ marcos.push(["ORB_VEL_".concat(pro.toUpperCase()), defO]);
18215
+ });
18216
+ if (linearVelOverLifetime === null || linearVelOverLifetime === void 0 ? void 0 : linearVelOverLifetime.asMovement) {
18217
+ marcos.push(['AS_LINEAR_MOVEMENT', true]);
18218
+ shaderCacheId |= 1 << 5;
18219
+ }
18220
+ if (useOrbitalVel) {
18221
+ if (orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime.asRotation) {
18222
+ marcos.push(['AS_ORBITAL_MOVEMENT', true]);
18223
+ shaderCacheId |= 1 << 6;
18067
18224
  }
18225
+ uniformValues.uOrbCenter = new Float32Array((orbitalVelOverLifetime === null || orbitalVelOverLifetime === void 0 ? void 0 : orbitalVelOverLifetime.center) || [0, 0, 0]);
18068
18226
  }
18069
- else {
18070
- dirX.set(1, 0, 0);
18071
- dirY.set(0, 1, 0);
18227
+ uniformValues.uSizeByLifetimeValue = sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.x.toUniform(vertexKeyFrameMeta);
18228
+ if (sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.separateAxes) {
18229
+ marcos.push(['SIZE_Y_BY_LIFE', 1]);
18230
+ shaderCacheId |= 1 << 14;
18231
+ uniformValues.uSizeYByLifetimeValue = (_d = sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.y) === null || _d === void 0 ? void 0 : _d.toUniform(vertexKeyFrameMeta);
18072
18232
  }
18073
- var sprite;
18074
- var tsa = this.textureSheetAnimation;
18075
- if (tsa && tsa.animate) {
18076
- sprite = tempSprite;
18077
- sprite[0] = tsa.animationDelay.getValue(lifetime);
18078
- sprite[1] = tsa.animationDuration.getValue(lifetime);
18079
- sprite[2] = tsa.cycles.getValue(lifetime);
18233
+ if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.z) {
18234
+ uniformValues.uRZByLifeTimeValue = rotationOverLifetime.z.toUniform(vertexKeyFrameMeta);
18235
+ shaderCacheId |= 1 << 15;
18236
+ marcos.push(['ROT_Z_LIFETIME', 1]);
18080
18237
  }
18081
- var rot = tempRot;
18082
- if (options.start3DRotation) {
18083
- // @ts-expect-error
18084
- rot.set(options.startRotationX.getValue(lifetime), options.startRotationY.getValue(lifetime), options.startRotationZ.getValue(lifetime));
18238
+ if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.x) {
18239
+ uniformValues.uRXByLifeTimeValue = rotationOverLifetime.x.toUniform(vertexKeyFrameMeta);
18240
+ shaderCacheId |= 1 << 16;
18241
+ marcos.push(['ROT_X_LIFETIME', 1]);
18085
18242
  }
18086
- else if (options.startRotation) {
18087
- rot.set(0, 0, options.startRotation.getValue(lifetime));
18243
+ if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.y) {
18244
+ uniformValues.uRYByLifeTimeValue = rotationOverLifetime.y.toUniform(vertexKeyFrameMeta);
18245
+ shaderCacheId |= 1 << 17;
18246
+ marcos.push(['ROT_Y_LIFETIME', 1]);
18088
18247
  }
18089
- else {
18090
- rot.set(0, 0, 0);
18248
+ if (rotationOverLifetime === null || rotationOverLifetime === void 0 ? void 0 : rotationOverLifetime.asRotation) {
18249
+ marcos.push(['ROT_LIFETIME_AS_MOVEMENT', 1]);
18250
+ shaderCacheId |= 1 << 18;
18091
18251
  }
18092
- transform.setRotation(rot.x, rot.y, rot.z);
18093
- var color = options.startColor.getValue(lifetime);
18094
- if (color.length === 3) {
18095
- color[3] = 1;
18252
+ uniformValues.uGravityModifierValue = gravityModifier.toUniform(vertexKeyFrameMeta);
18253
+ if (forceTarget) {
18254
+ marcos.push(['FINAL_TARGET', true]);
18255
+ shaderCacheId |= 1 << 19;
18256
+ uniformValues.uFinalTarget = new Float32Array(forceTarget.target || [0, 0, 0]);
18257
+ uniformValues.uForceCurve = forceTarget.curve.toUniform(vertexKeyFrameMeta);
18096
18258
  }
18097
- var size = tempSize;
18098
- if (options.start3DSize) {
18099
- size.x = options.startSizeX.getValue(lifetime);
18100
- size.y = options.startSizeY.getValue(lifetime);
18259
+ if (halfFloatTexture && fragmentKeyFrameMeta.max) {
18260
+ shaderCacheId |= 1 << 20;
18261
+ uniformValues.uFCurveValueTexture = generateHalfFloatTexture(engine, ValueGetter.getAllData(fragmentKeyFrameMeta, true), fragmentKeyFrameMeta.index, 1);
18101
18262
  }
18102
18263
  else {
18103
- var n = options.startSize.getValue(lifetime);
18104
- var aspect = options.sizeAspect.getValue(lifetime);
18105
- size.x = n;
18106
- // 兼容aspect为0的情况
18107
- size.y = aspect === 0 ? 0 : n / aspect;
18108
- // size[1] = n / aspect;
18264
+ uniformValues.uFCurveValues = ValueGetter.getAllData(fragmentKeyFrameMeta);
18109
18265
  }
18110
- var vel = direction.clone();
18111
- vel.multiply(speed);
18112
- // 粒子的大小受发射器父节点的影响
18113
- if (!options.particleFollowParent) {
18114
- var tempScale = new Vector3();
18115
- this.transform.assignWorldTRS(undefined, undefined, tempScale);
18116
- size.x *= tempScale.x;
18117
- size.y *= tempScale.y;
18266
+ var vertexCurveTexture = vertexKeyFrameMeta.max + vertexKeyFrameMeta.curves.length - 32 > maxVertexUniforms;
18267
+ // if (getConfig(RENDER_PREFER_LOOKUP_TEXTURE)) {
18268
+ // vertexCurveTexture = true;
18269
+ // }
18270
+ if (level === 2) {
18271
+ vertexKeyFrameMeta.max = -1;
18272
+ vertexKeyFrameMeta.index = meshSlots ? meshSlots[0] : getSlot(vertexKeyFrameMeta.index);
18273
+ if (fragmentKeyFrameMeta.index > 0) {
18274
+ fragmentKeyFrameMeta.max = -1;
18275
+ fragmentKeyFrameMeta.index = meshSlots ? meshSlots[1] : getSlot(fragmentKeyFrameMeta.index);
18276
+ }
18118
18277
  }
18119
- transform.setScale(size.x, size.y, 1);
18120
- return {
18121
- size: size,
18122
- vel: vel,
18123
- color: color,
18124
- delay: options.startDelay.getValue(lifetime),
18125
- lifetime: options.startLifetime.getValue(lifetime),
18126
- uv: randomArrItem(this.uvs, true),
18127
- gravity: options.gravity,
18128
- sprite: sprite,
18129
- dirY: dirY,
18130
- dirX: dirX,
18131
- transform: transform,
18132
- };
18133
- };
18134
- ParticleSystem.prototype.addBurst = function (burst, offsets) {
18135
- var willAdd = false;
18136
- if (!this.emission.bursts.includes(burst)) {
18137
- this.emission.bursts.push(burst);
18138
- willAdd = true;
18278
+ if (vertexCurveTexture && halfFloatTexture && enableVertexTexture) {
18279
+ var tex = generateHalfFloatTexture(engine, ValueGetter.getAllData(vertexKeyFrameMeta, true), vertexKeyFrameMeta.index, 1);
18280
+ uniformValues.uVCurveValueTexture = tex;
18281
+ vertex_lookup_texture = 1;
18139
18282
  }
18140
- if (willAdd && offsets instanceof Array) {
18141
- var index = this.emission.bursts.indexOf(burst);
18142
- this.emission.burstOffsets[index] = offsets;
18143
- return index;
18283
+ else {
18284
+ uniformValues.uVCurveValues = ValueGetter.getAllData(vertexKeyFrameMeta);
18144
18285
  }
18145
- return -1;
18146
- };
18147
- ParticleSystem.prototype.removeBurst = function (index) {
18148
- if (index < this.emission.bursts.length) {
18149
- this.emission.burstOffsets[index] = null;
18150
- this.emission.bursts.splice(index, 1);
18286
+ var shaderCache = ['-p:', renderMode, shaderCacheId, vertexKeyFrameMeta.index, vertexKeyFrameMeta.max, fragmentKeyFrameMeta.index, fragmentKeyFrameMeta.max].join('+');
18287
+ 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]);
18288
+ var fragment = filter ? particleFrag.replace(/#pragma\s+FILTER_FRAG/, particleDefine.fragment) : particleFrag;
18289
+ var originalVertex = "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert);
18290
+ var vertex = filter ? originalVertex.replace(/#pragma\s+FILTER_VERT/, particleDefine.vertex || 'void filterMain(float t){}\n') : originalVertex;
18291
+ var shader = {
18292
+ fragment: createShaderWithMarcos(marcos, fragment, ShaderType.fragment, level),
18293
+ vertex: createShaderWithMarcos(marcos, vertex, ShaderType.vertex, level),
18294
+ glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
18295
+ shared: true,
18296
+ cacheId: shaderCache,
18297
+ marcos: marcos,
18298
+ name: "particle#".concat(name),
18299
+ };
18300
+ if (filter) {
18301
+ shader.cacheId += filter.name;
18151
18302
  }
18152
- };
18153
- ParticleSystem.prototype.createPoint = function (lifetime) {
18154
- var generator = {
18155
- total: this.emission.rateOverTime.getValue(lifetime),
18156
- index: this.generatedCount,
18157
- burstIndex: 0,
18158
- burstCount: 0,
18303
+ var mtlOptions = {
18304
+ shader: shader,
18305
+ uniformSemantics: {
18306
+ effects_MatrixV: 'VIEW',
18307
+ effects_MatrixVP: 'VIEWPROJECTION',
18308
+ uEditorTransform: 'EDITOR_TRANSFORM',
18309
+ effects_ObjectToWorld: 'MODEL',
18310
+ },
18159
18311
  };
18160
- this.generatedCount++;
18161
- return this.initPoint(this.shape.generate(generator));
18162
- };
18163
- return ParticleSystem;
18164
- }());
18165
- // array performance better for small memory than Float32Array
18166
- var tempDir = new Vector3();
18167
- var tempSize = new Vector2();
18168
- var tempRot = new Euler();
18169
- var tmpDirX = new Vector3();
18170
- var tmpDirY = new Vector3();
18171
- var tempVec3 = new Vector3();
18172
- var tempEuler = new Euler();
18173
- var tempSprite = [0, 0, 0];
18174
- var tempMat4 = new Matrix4$1();
18175
- function getBurstOffsets(burstOffsets) {
18176
- var ret = {};
18177
- if (Array.isArray(burstOffsets)) {
18178
- burstOffsets.forEach(function (arr) {
18179
- var isArr = arr instanceof Array;
18180
- var index = isArr ? arr[0] : arr.index;
18181
- var offsets = ret[index];
18182
- if (!offsets) {
18183
- offsets = ret[index] = [];
18184
- }
18185
- if (isArr) {
18186
- offsets.push(arr.slice(1, 4));
18312
+ var preMulAlpha = getPreMultiAlpha(blending);
18313
+ uniformValues.uTexOffset = new Float32Array(diffuse ? [1 / diffuse.getWidth(), 1 / diffuse.getHeight()] : [0, 0]);
18314
+ uniformValues.uMaskTex = diffuse;
18315
+ uniformValues.uColorParams = new Float32Array([diffuse ? 1 : 0, +preMulAlpha, 0, +(!!occlusion && !transparentOcclusion)]);
18316
+ uniformValues.uParams = [0, duration, 0, 0];
18317
+ 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];
18318
+ // mtlOptions.uniformValues = uniformValues;
18319
+ var material = Material.create(engine, mtlOptions);
18320
+ material.blending = true;
18321
+ material.depthTest = true;
18322
+ material.depthMask = !!(occlusion);
18323
+ material.stencilRef = mask ? [mask, mask] : undefined;
18324
+ setMaskMode(material, maskMode);
18325
+ setBlendMode(material, blending);
18326
+ setSideMode(material, side);
18327
+ Object.keys(uniformValues).map(function (name) {
18328
+ var value = uniformValues[name];
18329
+ if (value instanceof Texture) {
18330
+ material.setTexture(name, value);
18331
+ return;
18187
18332
  }
18188
- else {
18189
- offsets.push([+arr.x, +arr.y, +arr.z]);
18333
+ var res = [];
18334
+ switch (particleUniformTypeMap[name]) {
18335
+ case 'vec4':
18336
+ material.setVector4(name, Vector4$1.fromArray(value));
18337
+ break;
18338
+ case 'vec3':
18339
+ material.setVector3(name, Vector3.fromArray(value));
18340
+ break;
18341
+ case 'vec2':
18342
+ material.setVector2(name, Vector2.fromArray(value));
18343
+ break;
18344
+ case 'vec4Array':
18345
+ for (var i = 0; i < value.length; i = i + 4) {
18346
+ var v = new Vector4$1(value[i], value[i + 1], value[i + 2], value[i + 3]);
18347
+ res.push(v);
18348
+ }
18349
+ material.setVector4Array(name, res);
18350
+ res.length = 0;
18351
+ break;
18352
+ default:
18353
+ console.warn("uniform ".concat(name, "'s type not in typeMap"));
18190
18354
  }
18191
18355
  });
18356
+ material.setVector3('emissionColor', new Vector3(0, 0, 0));
18357
+ material.setFloat('emissionIntensity', 0.0);
18358
+ var geometry = Geometry.create(engine, generateGeometryProps(maxCount * 4, this.useSprite, "particle#".concat(name)));
18359
+ var mesh = Mesh.create(engine, {
18360
+ name: "MParticle_".concat(name),
18361
+ priority: listIndex,
18362
+ material: material,
18363
+ geometry: geometry,
18364
+ });
18365
+ this.anchor = anchor;
18366
+ this.mesh = mesh;
18367
+ this.geometry = mesh.firstGeometry();
18368
+ this.forceTarget = forceTarget;
18369
+ this.sizeOverLifetime = sizeOverLifetime;
18370
+ this.speedOverLifetime = speedOverLifetime;
18371
+ this.linearVelOverLifetime = linearVelOverLifetime;
18372
+ this.orbitalVelOverLifetime = orbitalVelOverLifetime;
18373
+ this.orbitalVelOverLifetime = orbitalVelOverLifetime;
18374
+ this.gravityModifier = gravityModifier;
18375
+ this.maxCount = maxCount;
18376
+ this.duration = duration;
18377
+ this.textureOffsets = textureFlip ? [0, 0, 1, 0, 0, 1, 1, 1] : [0, 1, 0, 0, 1, 1, 1, 0];
18192
18378
  }
18193
- return ret;
18194
- }
18195
- function randomArrItem(arr, keepArr) {
18196
- var index = Math.floor(Math.random() * arr.length);
18197
- var item = arr[index];
18198
- if (!keepArr) {
18199
- arr.splice(index, 1);
18200
- }
18201
- return item;
18202
- }
18203
-
18204
- var ParticleVFXItem = /** @class */ (function (_super) {
18205
- __extends(ParticleVFXItem, _super);
18206
- function ParticleVFXItem() {
18207
- var _this = _super !== null && _super.apply(this, arguments) || this;
18208
- _this.destroyed = false;
18209
- return _this;
18210
- }
18211
- Object.defineProperty(ParticleVFXItem.prototype, "type", {
18379
+ Object.defineProperty(ParticleMesh.prototype, "time", {
18212
18380
  get: function () {
18213
- return ItemType$1.particle;
18381
+ var value = this.mesh.material.getVector4('uParams');
18382
+ return value.x;
18383
+ },
18384
+ set: function (v) {
18385
+ this.mesh.material.setVector4('uParams', new Vector4$1(+v, this.duration, 0, 0));
18214
18386
  },
18215
18387
  enumerable: false,
18216
18388
  configurable: true
18217
18389
  });
18218
- ParticleVFXItem.prototype.onConstructed = function (props) {
18219
- this.particle = props.content;
18390
+ ParticleMesh.prototype.getPointColor = function (index) {
18391
+ var data = this.geometry.getAttributeData('aRot');
18392
+ var i = index * 32 + 4;
18393
+ return [data[i], data[i + 1], data[i + 2], data[i + 3]];
18220
18394
  };
18221
- ParticleVFXItem.prototype.onLifetimeBegin = function (composition, particleSystem) {
18222
- var _this = this;
18223
- if (particleSystem) {
18224
- particleSystem.name = this.name;
18225
- particleSystem.start();
18226
- particleSystem.onDestroy = function () {
18227
- _this.destroyed = true;
18228
- };
18395
+ /**
18396
+ * 待废弃
18397
+ * @deprecated - 使用 `particle-system.getPointPosition` 替代
18398
+ */
18399
+ ParticleMesh.prototype.getPointPosition = function (index) {
18400
+ var geo = this.geometry;
18401
+ var posIndex = index * 48;
18402
+ var posData = geo.getAttributeData('aPos');
18403
+ var offsetData = geo.getAttributeData('aOffset');
18404
+ var time = this.time - offsetData[index * 16 + 2];
18405
+ var pointDur = offsetData[index * 16 + 3];
18406
+ var mtl = this.mesh.material;
18407
+ var acc = mtl.getVector4('uAcceleration').toVector3();
18408
+ var pos = Vector3.fromArray(posData, posIndex);
18409
+ var vel = Vector3.fromArray(posData, posIndex + 3);
18410
+ var ret = calculateTranslation(new Vector3(), this, acc, time, pointDur, pos, vel);
18411
+ if (this.forceTarget) {
18412
+ var target = mtl.getVector3('uFinalTarget');
18413
+ var life = this.forceTarget.curve.getValue(time / pointDur);
18414
+ var dl = 1 - life;
18415
+ ret.x = ret.x * dl + target.x * life;
18416
+ ret.y = ret.y * dl + target.y * life;
18417
+ ret.z = ret.z * dl + target.z * life;
18229
18418
  }
18230
- return particleSystem;
18419
+ return ret;
18231
18420
  };
18232
- ParticleVFXItem.prototype.onItemUpdate = function (dt, lifetime) {
18233
- var _a;
18234
- if (this.content) {
18235
- var hide = !this.visible;
18236
- var parentItem = this.parentId && ((_a = this.composition) === null || _a === void 0 ? void 0 : _a.getItemByID(this.parentId));
18237
- if (!hide && parentItem) {
18238
- var parentData = parentItem.getRenderData();
18239
- if (parentData) {
18240
- if (!parentData.visible) {
18241
- hide = false;
18242
- }
18421
+ ParticleMesh.prototype.clearPoints = function () {
18422
+ this.resetGeometryData(this.geometry);
18423
+ this.particleCount = 0;
18424
+ this.geometry.setDrawCount(0);
18425
+ this.maxParticleBufferCount = 0;
18426
+ };
18427
+ ParticleMesh.prototype.resetGeometryData = function (geometry) {
18428
+ var names = geometry.getAttributeNames();
18429
+ var index = geometry.getIndexData();
18430
+ for (var i = 0; i < names.length; i++) {
18431
+ var name_1 = names[i];
18432
+ var data = geometry.getAttributeData(name_1);
18433
+ if (data) {
18434
+ // @ts-expect-error
18435
+ geometry.setAttributeData(name_1, new data.constructor(0));
18436
+ }
18437
+ }
18438
+ // @ts-expect-error
18439
+ geometry.setIndexData(new index.constructor(0));
18440
+ };
18441
+ ParticleMesh.prototype.minusTime = function (time) {
18442
+ var data = this.geometry.getAttributeData('aOffset');
18443
+ for (var i = 0; i < data.length; i += 4) {
18444
+ data[i + 2] -= time;
18445
+ }
18446
+ this.geometry.setAttributeData('aOffset', data);
18447
+ this.time -= time;
18448
+ };
18449
+ ParticleMesh.prototype.removePoint = function (index) {
18450
+ if (index < this.particleCount) {
18451
+ this.geometry.setAttributeSubData('aOffset', index * 16, new Float32Array(16));
18452
+ }
18453
+ };
18454
+ ParticleMesh.prototype.setPoint = function (point, index) {
18455
+ var maxCount = this.maxCount;
18456
+ if (index < maxCount) {
18457
+ var particleCount = index + 1;
18458
+ var vertexCount_1 = particleCount * 4;
18459
+ var geometry_1 = this.geometry;
18460
+ var increaseBuffer_1 = particleCount > this.maxParticleBufferCount;
18461
+ var inc_1 = 1;
18462
+ if (this.particleCount > 300) {
18463
+ inc_1 = (this.particleCount + 100) / this.particleCount;
18464
+ }
18465
+ else if (this.particleCount > 100) {
18466
+ inc_1 = 1.4;
18467
+ }
18468
+ else if (this.particleCount > 0) {
18469
+ inc_1 = 2;
18470
+ }
18471
+ var pointData_1 = {
18472
+ aPos: new Float32Array(48),
18473
+ aRot: new Float32Array(32),
18474
+ aOffset: new Float32Array(16),
18475
+ };
18476
+ var useSprite = this.useSprite;
18477
+ if (useSprite) {
18478
+ pointData_1.aSprite = new Float32Array(12);
18479
+ }
18480
+ var tempPos = new Vector3();
18481
+ var tempQuat = new Quaternion();
18482
+ var scale = new Vector3(1, 1, 1);
18483
+ point.transform.assignWorldTRS(tempPos, tempQuat, scale);
18484
+ var tempEuler = Transform.getRotation(tempQuat, new Euler());
18485
+ var position = tempPos.toArray();
18486
+ var rotation = tempEuler.toArray();
18487
+ var offsets = this.textureOffsets;
18488
+ var off = [0, 0, point.delay, point.lifetime];
18489
+ var wholeUV = [0, 0, 1, 1];
18490
+ var vel = point.vel;
18491
+ var color = point.color;
18492
+ var sizeOffsets = [-.5, .5, -.5, -.5, .5, .5, .5, -.5];
18493
+ var seed = Math.random();
18494
+ var sprite = void 0;
18495
+ if (useSprite) {
18496
+ sprite = point.sprite;
18497
+ }
18498
+ for (var j = 0; j < 4; j++) {
18499
+ var offset = j * 2;
18500
+ var j3 = j * 3;
18501
+ var j4 = j * 4;
18502
+ var j12 = j * 12;
18503
+ var j8 = j * 8;
18504
+ pointData_1.aPos.set(position, j12);
18505
+ vel.fill(pointData_1.aPos, j12 + 3);
18506
+ pointData_1.aRot.set(rotation, j8);
18507
+ pointData_1.aRot[j8 + 3] = seed;
18508
+ pointData_1.aRot.set(color, j8 + 4);
18509
+ if (useSprite) {
18510
+ // @ts-expect-error
18511
+ pointData_1.aSprite.set(sprite, j3);
18512
+ }
18513
+ var uv = point.uv || wholeUV;
18514
+ if (uv) {
18515
+ var uvy = useSprite ? (1 - offsets[offset + 1]) : offsets[offset + 1];
18516
+ off[0] = uv[0] + offsets[offset] * uv[2];
18517
+ off[1] = uv[1] + uvy * uv[3];
18518
+ }
18519
+ pointData_1.aOffset.set(off, j4);
18520
+ var ji = (j + j);
18521
+ var sx = (sizeOffsets[ji] - this.anchor.x) * scale.x;
18522
+ var sy = (sizeOffsets[ji + 1] - this.anchor.y) * scale.y;
18523
+ for (var k = 0; k < 3; k++) {
18524
+ pointData_1.aPos[j12 + 6 + k] = point.dirX.getElement(k) * sx;
18525
+ pointData_1.aPos[j12 + 9 + k] = point.dirY.getElement(k) * sy;
18243
18526
  }
18244
18527
  }
18245
- if (hide) {
18246
- this.content.setVisible(false);
18528
+ var indexData = new Uint16Array([0, 1, 2, 2, 1, 3].map(function (x) { return x + index * 4; }));
18529
+ if (increaseBuffer_1) {
18530
+ var baseIndexData = geometry_1.getIndexData();
18531
+ var idx = enlargeBuffer(baseIndexData, particleCount * 6, inc_1, maxCount * 6);
18532
+ idx.set(indexData, index * 6);
18533
+ geometry_1.setIndexData(idx);
18534
+ this.maxParticleBufferCount = idx.length / 6;
18247
18535
  }
18248
18536
  else {
18249
- this.content.setVisible(true);
18250
- this.content.onUpdate(dt);
18537
+ geometry_1.setIndexSubData(index * 6, indexData);
18251
18538
  }
18539
+ Object.keys(pointData_1).forEach(function (name) {
18540
+ var data = pointData_1[name];
18541
+ var attrSize = geometry_1.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
18542
+ if (increaseBuffer_1) {
18543
+ var baseData = geometry_1.getAttributeData(name);
18544
+ var geoData = enlargeBuffer(baseData, vertexCount_1 * attrSize, inc_1, maxCount * 4 * attrSize);
18545
+ geoData.set(data, data.length * index);
18546
+ geometry_1.setAttributeData(name, geoData);
18547
+ }
18548
+ else {
18549
+ geometry_1.setAttributeSubData(name, data.length * index, data);
18550
+ }
18551
+ });
18552
+ this.particleCount = Math.max(particleCount, this.particleCount);
18553
+ geometry_1.setDrawCount(this.particleCount * 6);
18554
+ }
18555
+ };
18556
+ return ParticleMesh;
18557
+ }());
18558
+ var gl2UniformSlots = [10, 32, 64, 160];
18559
+ function getSlot(count) {
18560
+ for (var w = 0; w < gl2UniformSlots.length; w++) {
18561
+ var slot = gl2UniformSlots[w];
18562
+ if (slot > count) {
18563
+ return slot;
18564
+ }
18565
+ }
18566
+ return count || gl2UniformSlots[0];
18567
+ }
18568
+ function generateGeometryProps(maxVertex, useSprite, name) {
18569
+ var bpe = Float32Array.BYTES_PER_ELEMENT;
18570
+ var j12 = bpe * 12;
18571
+ var attributes = {
18572
+ aPos: { size: 3, offset: 0, stride: j12, data: new Float32Array(0) },
18573
+ aVel: { size: 3, offset: 3 * bpe, stride: j12, dataSource: 'aPos' },
18574
+ aDirX: { size: 3, offset: 6 * bpe, stride: j12, dataSource: 'aPos' },
18575
+ aDirY: { size: 3, offset: 9 * bpe, stride: j12, dataSource: 'aPos' },
18576
+ //
18577
+ aRot: { size: 3, offset: 0, stride: 8 * bpe, data: new Float32Array(0) },
18578
+ aSeed: { size: 1, offset: 3 * bpe, stride: 8 * bpe, dataSource: 'aRot' },
18579
+ aColor: { size: 4, offset: 4 * bpe, stride: 8 * bpe, dataSource: 'aRot' },
18580
+ //
18581
+ aOffset: { size: 4, stride: 4 * bpe, data: new Float32Array(0) },
18582
+ };
18583
+ if (useSprite) {
18584
+ attributes['aSprite'] = { size: 3, data: new Float32Array(0) };
18585
+ }
18586
+ return { attributes: attributes, indices: { data: new Uint16Array(0) }, name: name, maxVertex: maxVertex };
18587
+ }
18588
+ function getParticleMeshShader(item, env, gpuCapability) {
18589
+ var _a, _b, _c, _d, _e;
18590
+ if (env === void 0) { env = ''; }
18591
+ var props = item.content;
18592
+ var renderMode = +(((_a = props.renderer) === null || _a === void 0 ? void 0 : _a.renderMode) || 0);
18593
+ var marcos = [
18594
+ ['RENDER_MODE', renderMode],
18595
+ ['PRE_MULTIPLY_ALPHA', false],
18596
+ ['ENV_EDITOR', env === PLAYER_OPTIONS_ENV_EDITOR],
18597
+ ];
18598
+ var level = gpuCapability.level, detail = gpuCapability.detail;
18599
+ var vertexKeyFrameMeta = createKeyFrameMeta();
18600
+ var fragmentKeyFrameMeta = createKeyFrameMeta();
18601
+ var enableVertexTexture = detail.maxVertexUniforms > 0;
18602
+ var speedOverLifetime = ((_b = props.positionOverLifetime) !== null && _b !== void 0 ? _b : {}).speedOverLifetime;
18603
+ var vertex_lookup_texture = 0;
18604
+ var shaderCacheId = 0;
18605
+ if (enableVertexTexture) {
18606
+ marcos.push(['ENABLE_VERTEX_TEXTURE', true]);
18607
+ }
18608
+ if (speedOverLifetime) {
18609
+ marcos.push(['SPEED_OVER_LIFETIME', true]);
18610
+ shaderCacheId |= 1 << 1;
18611
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, speedOverLifetime);
18612
+ }
18613
+ var sprite = props.textureSheetAnimation;
18614
+ if (sprite && sprite.animate) {
18615
+ marcos.push(['USE_SPRITE', true]);
18616
+ shaderCacheId |= 1 << 2;
18617
+ }
18618
+ var filter = undefined;
18619
+ if (props.filter && props.filter.name !== FILTER_NAME_NONE) {
18620
+ marcos.push(['USE_FILTER', true]);
18621
+ shaderCacheId |= 1 << 3;
18622
+ var f = createFilterShaders(props.filter).find(function (f) { return f.isParticle; });
18623
+ if (!f) {
18624
+ throw Error("particle filter ".concat(props.filter.name, " not implement"));
18252
18625
  }
18253
- };
18254
- ParticleVFXItem.prototype.onItemRemoved = function (composition, content) {
18255
- if (content) {
18256
- composition.destroyTextures(content.getTextures());
18257
- content.meshes.forEach(function (mesh) { return mesh.dispose({ material: { textures: DestroyOptions.keep } }); });
18626
+ filter = f;
18627
+ (_c = f.uniforms) === null || _c === void 0 ? void 0 : _c.forEach(function (val) { return getKeyFrameMetaByRawValue(vertexKeyFrameMeta, val); });
18628
+ // filter = processFilter(props.filter, fragmentKeyFrameMeta, vertexKeyFrameMeta, options);
18629
+ }
18630
+ var colorOverLifetime = props.colorOverLifetime;
18631
+ if (colorOverLifetime && colorOverLifetime.color) {
18632
+ marcos.push(['COLOR_OVER_LIFETIME', true]);
18633
+ shaderCacheId |= 1 << 4;
18634
+ }
18635
+ var opacity = colorOverLifetime && colorOverLifetime.opacity;
18636
+ if (opacity) {
18637
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, opacity);
18638
+ }
18639
+ var positionOverLifetime = props.positionOverLifetime;
18640
+ var useOrbitalVel;
18641
+ ['x', 'y', 'z'].forEach(function (pro, i) {
18642
+ var defL = 0;
18643
+ var linearPro = 'linear' + pro.toUpperCase();
18644
+ var orbitalPro = 'orbital' + pro.toUpperCase();
18645
+ if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime[linearPro]) {
18646
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime[linearPro]);
18647
+ defL = 1;
18648
+ shaderCacheId |= 1 << (7 + i);
18258
18649
  }
18259
- };
18260
- /**
18261
- * @internal
18262
- */
18263
- ParticleVFXItem.prototype.setColor = function (r, g, b, a) {
18264
- this.content.setColor(r, g, b, a);
18265
- };
18266
- ParticleVFXItem.prototype.setOpacity = function (opacity) {
18267
- this.content.setOpacity(opacity);
18268
- };
18269
- ParticleVFXItem.prototype.stopParticleEmission = function () {
18270
- if (this.content) {
18271
- this.content.emissionStopped = true;
18650
+ marcos.push(["LINEAR_VEL_".concat(pro.toUpperCase()), defL]);
18651
+ var defO = 0;
18652
+ if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime[orbitalPro]) {
18653
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime[orbitalPro]);
18654
+ defO = 1;
18655
+ shaderCacheId |= 1 << (10 + i);
18656
+ useOrbitalVel = true;
18272
18657
  }
18273
- };
18274
- ParticleVFXItem.prototype.resumeParticleEmission = function () {
18275
- if (this.content) {
18276
- this.content.emissionStopped = false;
18658
+ marcos.push(["ORB_VEL_".concat(pro.toUpperCase()), defO]);
18659
+ });
18660
+ if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.asMovement) {
18661
+ marcos.push(['AS_LINEAR_MOVEMENT', true]);
18662
+ shaderCacheId |= 1 << 5;
18663
+ }
18664
+ if (useOrbitalVel) {
18665
+ if (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.asRotation) {
18666
+ marcos.push(['AS_ORBITAL_MOVEMENT', true]);
18667
+ shaderCacheId |= 1 << 6;
18277
18668
  }
18278
- };
18279
- ParticleVFXItem.prototype.doCreateContent = function (composition) {
18280
- assertExist(this.particle);
18281
- return new ParticleSystem(this.particle, composition.getRendererOptions(), this);
18282
- };
18283
- ParticleVFXItem.prototype.isEnded = function (now) {
18284
- return _super.prototype.isEnded.call(this, now) && this.destroyed;
18285
- };
18286
- ParticleVFXItem.prototype.getBoundingBox = function () {
18287
- var pt = this.content;
18288
- if (!pt) {
18289
- return;
18669
+ }
18670
+ var sizeOverLifetime = props.sizeOverLifetime;
18671
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.x);
18672
+ if (sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.separateAxes) {
18673
+ marcos.push(['SIZE_Y_BY_LIFE', 1]);
18674
+ shaderCacheId |= 1 << 14;
18675
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime === null || sizeOverLifetime === void 0 ? void 0 : sizeOverLifetime.y);
18676
+ }
18677
+ var rot = props.rotationOverLifetime;
18678
+ if (rot === null || rot === void 0 ? void 0 : rot.z) {
18679
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot === null || rot === void 0 ? void 0 : rot.z);
18680
+ shaderCacheId |= 1 << 15;
18681
+ marcos.push(['ROT_Z_LIFETIME', 1]);
18682
+ }
18683
+ if (rot === null || rot === void 0 ? void 0 : rot.separateAxes) {
18684
+ if (rot.x) {
18685
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.x);
18686
+ shaderCacheId |= 1 << 16;
18687
+ marcos.push(['ROT_X_LIFETIME', 1]);
18290
18688
  }
18291
- else {
18292
- var area = pt.getParticleBoxes();
18293
- return {
18294
- type: HitTestType.sphere,
18295
- area: area,
18296
- };
18689
+ if (rot.y) {
18690
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.y);
18691
+ shaderCacheId |= 1 << 17;
18692
+ marcos.push(['ROT_Y_LIFETIME', 1]);
18297
18693
  }
18298
- };
18299
- ParticleVFXItem.prototype.getHitTestParams = function (force) {
18300
- var _this = this;
18301
- var _a;
18302
- var interactParams = (_a = this.content) === null || _a === void 0 ? void 0 : _a.interaction;
18303
- if (force || interactParams) {
18304
- return {
18305
- type: HitTestType.custom,
18306
- collect: function (ray) {
18307
- var _a;
18308
- return (_a = _this.content) === null || _a === void 0 ? void 0 : _a.raycast({
18309
- radius: (interactParams === null || interactParams === void 0 ? void 0 : interactParams.radius) || 0.4,
18310
- multiple: !!(interactParams === null || interactParams === void 0 ? void 0 : interactParams.multiple),
18311
- removeParticle: (interactParams === null || interactParams === void 0 ? void 0 : interactParams.behavior) === ParticleInteractionBehavior$1.removeParticle,
18312
- ray: ray,
18313
- });
18314
- },
18315
- };
18694
+ }
18695
+ if (rot === null || rot === void 0 ? void 0 : rot.asRotation) {
18696
+ marcos.push(['ROT_LIFETIME_AS_MOVEMENT', 1]);
18697
+ shaderCacheId |= 1 << 18;
18698
+ }
18699
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravityOverLifetime);
18700
+ var forceOpt = positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.forceTarget;
18701
+ if (forceOpt) {
18702
+ marcos.push(['FINAL_TARGET', true]);
18703
+ shaderCacheId |= 1 << 19;
18704
+ getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime.forceCurve);
18705
+ }
18706
+ var HALF_FLOAT = detail.halfFloatTexture;
18707
+ if (HALF_FLOAT && fragmentKeyFrameMeta.max) {
18708
+ shaderCacheId |= 1 << 20;
18709
+ }
18710
+ var maxVertexUniforms = detail.maxVertexUniforms;
18711
+ var vertexCurveTexture = vertexKeyFrameMeta.max + vertexKeyFrameMeta.curves.length - 32 > maxVertexUniforms;
18712
+ if (getConfig(RENDER_PREFER_LOOKUP_TEXTURE)) {
18713
+ vertexCurveTexture = true;
18714
+ }
18715
+ if (level === 2) {
18716
+ vertexKeyFrameMeta.max = -1;
18717
+ // vertexKeyFrameMeta.index = getSlot(vertexKeyFrameMeta.index);
18718
+ if (fragmentKeyFrameMeta.index > 0) {
18719
+ fragmentKeyFrameMeta.max = -1;
18720
+ // fragmentKeyFrameMeta.index = getSlot(fragmentKeyFrameMeta.index);
18316
18721
  }
18722
+ }
18723
+ if (vertexCurveTexture && HALF_FLOAT && enableVertexTexture) {
18724
+ vertex_lookup_texture = 1;
18725
+ }
18726
+ var shaderCache = ['-p:', renderMode, shaderCacheId, vertexKeyFrameMeta.index, vertexKeyFrameMeta.max, fragmentKeyFrameMeta.index, fragmentKeyFrameMeta.max].join('+');
18727
+ var shader = {
18728
+ fragment: particleFrag,
18729
+ vertex: "#define LOOKUP_TEXTURE_CURVE ".concat(vertex_lookup_texture, "\n").concat(particleVert),
18730
+ shared: true,
18731
+ cacheId: shaderCache,
18732
+ marcos: marcos,
18733
+ name: "particle#".concat(item.name),
18317
18734
  };
18318
- return ParticleVFXItem;
18319
- }(VFXItem));
18735
+ if (filter) {
18736
+ shader.fragment = shader.fragment.replace(/#pragma\s+FILTER_FRAG/, (_d = filter.fragment) !== null && _d !== void 0 ? _d : '');
18737
+ shader.vertex = shader.vertex.replace(/#pragma\s+FILTER_VERT/, filter.vertex || 'void filterMain(float t){}\n');
18738
+ shader.cacheId += '+' + ((_e = props.filter) === null || _e === void 0 ? void 0 : _e.name);
18739
+ }
18740
+ 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]);
18741
+ return { shader: shader, vertex: vertexKeyFrameMeta.index, fragment: fragmentKeyFrameMeta.index };
18742
+ }
18743
+ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
18744
+ var _a;
18745
+ var shaderIds = (_a = shader.cacheId) === null || _a === void 0 ? void 0 : _a.split('+');
18746
+ shaderIds[3] = maxVertex;
18747
+ shaderIds[5] = maxFrag;
18748
+ shader.cacheId = shaderIds.join('+');
18749
+ if (!shader.marcos) {
18750
+ return;
18751
+ }
18752
+ for (var i = 0; i < shader.marcos.length; i++) {
18753
+ var marco = shader.marcos[i];
18754
+ if (marco[0] === 'VERT_CURVE_VALUE_COUNT') {
18755
+ marco[1] = maxVertex;
18756
+ }
18757
+ else if (marco[0] === 'FRAG_CURVE_VALUE_COUNT') {
18758
+ marco[1] = maxFrag;
18759
+ break;
18760
+ }
18761
+ }
18762
+ }
18320
18763
 
18321
18764
  var ParticleLoader = /** @class */ (function (_super) {
18322
18765
  __extends(ParticleLoader, _super);
@@ -21567,7 +22010,7 @@ var filters = {
21567
22010
  * Name: @galacean/effects-specification
21568
22011
  * Description: Galacean Effects JSON Specification
21569
22012
  * Author: Ant Group CO., Ltd.
21570
- * Version: v1.1.0
22013
+ * Version: v1.2.0-beta.0
21571
22014
  */
21572
22015
 
21573
22016
  /*********************************************/
@@ -22328,15 +22771,27 @@ function ensureFixedNumber(a) {
22328
22771
  return [ValueType.CONSTANT, a];
22329
22772
  }
22330
22773
  if (a) {
22331
- if (a[0] === 'lines') {
22774
+ var valueType = a[0];
22775
+ var valueData = a[1];
22776
+ if (Array.isArray(valueType)) {
22777
+ // 没有数据类型的数据
22778
+ return;
22779
+ }
22780
+ if (valueType === 'static' || valueType === ValueType.CONSTANT) {
22781
+ return [ValueType.CONSTANT, a[1]];
22782
+ }
22783
+ if (valueType === 'lines') {
22332
22784
  return [ValueType.LINE, a[1]];
22333
22785
  }
22334
- if (a[0] === 'curve') {
22335
- return [ValueType.CURVE, a[1]];
22786
+ if (valueType === ValueType.LINE) {
22787
+ // @ts-expect-error
22788
+ var keyframes = valueData.map(function (data) { return [BezierKeyframeType.LINE, data]; });
22789
+ return [ValueType.BEZIER_CURVE, keyframes];
22336
22790
  }
22337
- if (a[0] === 'static') {
22338
- return [ValueType.CONSTANT, a[1]];
22791
+ if (valueType === 'curve' || valueType === ValueType.CURVE) {
22792
+ return [ValueType.BEZIER_CURVE, getBezierCurveFromHermiteInGE(valueData)];
22339
22793
  }
22794
+ return a;
22340
22795
  }
22341
22796
  }
22342
22797
  function ensureFixedNumberWithRandom(a, p) {
@@ -22362,6 +22817,7 @@ function ensureColorExpression(a, normalized) {
22362
22817
  else if (a[0] === 'color') {
22363
22818
  return [ValueType.RGBA_COLOR, colorToArr(a[1], normalized)];
22364
22819
  }
22820
+ return a;
22365
22821
  }
22366
22822
  }
22367
22823
  function ensureNumberExpression(a) {
@@ -22429,6 +22885,9 @@ function parsePercent(c) {
22429
22885
  }
22430
22886
  function getGradientColor(color, normalized) {
22431
22887
  if (Array.isArray(color)) {
22888
+ if (color[0] === ValueType.GRADIENT_COLOR) {
22889
+ return color;
22890
+ }
22432
22891
  // @ts-expect-error
22433
22892
  return (color[0] === 'gradient' || color[0] === 'color') && ensureGradient(color[1], normalized);
22434
22893
  }
@@ -22441,12 +22900,36 @@ function ensureFixedVec3(a) {
22441
22900
  if (a.length === 3) {
22442
22901
  return [ValueType.CONSTANT_VEC3, a];
22443
22902
  }
22444
- if (a[0] === 'path') {
22445
- return [ValueType.LINEAR_PATH, a[1]];
22446
- }
22447
- if (a[0] === 'bezier') {
22448
- return [ValueType.BEZIER_PATH, a[1]];
22903
+ var valueType = a[0];
22904
+ if (valueType === 'path' ||
22905
+ valueType === 'bezier' ||
22906
+ valueType === ValueType.BEZIER_PATH ||
22907
+ valueType === ValueType.LINEAR_PATH) {
22908
+ var valueData = a[1];
22909
+ var easing = valueData[0];
22910
+ var points = valueData[1];
22911
+ var controlPoints = valueData[2];
22912
+ var bezierEasing = getBezierCurveFromHermiteInGE(easing);
22913
+ // linear path没有controlPoints
22914
+ if (!controlPoints) {
22915
+ controlPoints = [];
22916
+ for (var keyframeIndex = 0; keyframeIndex < points.length; keyframeIndex++) {
22917
+ var point = points[keyframeIndex].slice();
22918
+ if (keyframeIndex === 0) {
22919
+ controlPoints.push(point);
22920
+ }
22921
+ else if (keyframeIndex < points.length - 1) {
22922
+ controlPoints.push(point);
22923
+ controlPoints.push(point);
22924
+ }
22925
+ else {
22926
+ controlPoints.push(point);
22927
+ }
22928
+ }
22929
+ }
22930
+ return [ValueType.BEZIER_CURVE_PATH, [bezierEasing, points, controlPoints]];
22449
22931
  }
22932
+ return a;
22450
22933
  }
22451
22934
  }
22452
22935
  function objectValueToNumber(o) {
@@ -22536,6 +23019,50 @@ function rotationZYXFromQuat(out, quat) {
22536
23019
  }
22537
23020
  return out;
22538
23021
  }
23022
+ function getBezierCurveFromHermite(m0, m1, p0, p3) {
23023
+ var xStart = p0[0];
23024
+ var yStart = p0[1];
23025
+ var xEnd = p3[0];
23026
+ var yEnd = p3[1];
23027
+ var dt = xEnd - xStart;
23028
+ m0 = m0 * dt;
23029
+ m1 = m1 * dt;
23030
+ var bezierControlPoints = [[xStart + (xEnd - xStart) / 3, yStart + m0 / 3], [xEnd - (xEnd - xStart) / 3, yEnd - m1 / 3]];
23031
+ return bezierControlPoints;
23032
+ }
23033
+ function getBezierCurveFromHermiteInGE(geHermiteCurves) {
23034
+ var ymax = -1000000;
23035
+ var ymin = 1000000;
23036
+ for (var i = 0; i < geHermiteCurves.length; i++) {
23037
+ ymax = Math.max(ymax, geHermiteCurves[i][1]);
23038
+ ymin = Math.min(ymin, geHermiteCurves[i][1]);
23039
+ }
23040
+ var geBezierCurves = [[geHermiteCurves[0][0], geHermiteCurves[0][1]]];
23041
+ for (var i = 0; i < geHermiteCurves.length - 1; i++) {
23042
+ var m0 = geHermiteCurves[i][3] * (ymax - ymin);
23043
+ var m1 = geHermiteCurves[i + 1][2] * (ymax - ymin);
23044
+ var p0 = [geHermiteCurves[i][0], geHermiteCurves[i][1]];
23045
+ var p3 = [geHermiteCurves[i + 1][0], geHermiteCurves[i + 1][1]];
23046
+ if (p0[0] != p3[0]) {
23047
+ var bezierControlPoints = getBezierCurveFromHermite(m0, m1, p0, p3);
23048
+ var p1 = bezierControlPoints[0];
23049
+ var p2 = bezierControlPoints[1];
23050
+ geBezierCurves[geBezierCurves.length - 1].push(p1[0]);
23051
+ geBezierCurves[geBezierCurves.length - 1].push(p1[1]);
23052
+ geBezierCurves.push([p2[0], p2[1], p3[0], p3[1]]);
23053
+ }
23054
+ else {
23055
+ geBezierCurves[geBezierCurves.length - 1].push(p3[0]);
23056
+ geBezierCurves[geBezierCurves.length - 1].push(p3[1]);
23057
+ }
23058
+ }
23059
+ // 添加关键帧类型
23060
+ return geBezierCurves.map(function (curve, index) {
23061
+ return index === 0 ? [BezierKeyframeType.EASE_OUT, curve]
23062
+ : index === geBezierCurves.length - 1 ? [BezierKeyframeType.EASE_IN, curve]
23063
+ : [BezierKeyframeType.EASE, curve];
23064
+ });
23065
+ }
22539
23066
 
22540
23067
  function getStandardParticleContent(particle) {
22541
23068
  var _a;
@@ -22947,12 +23474,63 @@ function version22Migration(json) {
22947
23474
  });
22948
23475
  return json;
22949
23476
  }
23477
+ /**
23478
+ * 2.5 以下版本 赫尔米特数据转换成贝塞尔数据
23479
+ */
23480
+ function version24Migration(json) {
23481
+ // 曲线转换成贝塞尔
23482
+ json.compositions.map(function (comp) {
23483
+ var e_1, _a;
23484
+ try {
23485
+ for (var _b = __values(comp.items), _c = _b.next(); !_c.done; _c = _b.next()) {
23486
+ var item = _c.value;
23487
+ convertParam(item.content);
23488
+ }
23489
+ }
23490
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
23491
+ finally {
23492
+ try {
23493
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
23494
+ }
23495
+ finally { if (e_1) throw e_1.error; }
23496
+ }
23497
+ });
23498
+ return json;
23499
+ }
23500
+ function convertParam(content) {
23501
+ var e_2, _a;
23502
+ try {
23503
+ for (var _b = __values(Object.keys(content)), _c = _b.next(); !_c.done; _c = _b.next()) {
23504
+ var key = _c.value;
23505
+ var value = content[key];
23506
+ var isArray = Array.isArray(value);
23507
+ if (isArray && value.length === 2 && Array.isArray(value[1])) {
23508
+ if (key === 'path') {
23509
+ content[key] = ensureFixedVec3(value);
23510
+ }
23511
+ else {
23512
+ content[key] = ensureFixedNumber(value);
23513
+ }
23514
+ }
23515
+ else if (!isArray && typeof value === 'object') {
23516
+ convertParam(value);
23517
+ }
23518
+ }
23519
+ }
23520
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
23521
+ finally {
23522
+ try {
23523
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
23524
+ }
23525
+ finally { if (e_2) throw e_2.error; }
23526
+ }
23527
+ }
22950
23528
 
22951
23529
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
22952
23530
  var standardVersion = /^(\d+)\.(\d+)$/;
22953
23531
  var reverseParticle = false;
22954
23532
  function getStandardJSON(json) {
22955
- var _a, _b;
23533
+ var _a;
22956
23534
  if (!json || typeof json !== 'object') {
22957
23535
  throw Error('expect a json object');
22958
23536
  }
@@ -22962,9 +23540,14 @@ function getStandardJSON(json) {
22962
23540
  reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
22963
23541
  return version21Migration(getStandardJSONFromV0(json));
22964
23542
  }
22965
- var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
23543
+ var vs = standardVersion.exec(json.version) || [];
23544
+ var mainVersion = Number(vs[1]);
23545
+ var minorVersion = Number(vs[2]);
22966
23546
  if (mainVersion) {
22967
- if (Number(mainVersion) < 2) {
23547
+ if (mainVersion < 2 || (mainVersion === 2 && minorVersion < 4)) {
23548
+ version24Migration(json);
23549
+ }
23550
+ if (mainVersion < 2) {
22968
23551
  return version21Migration(json);
22969
23552
  }
22970
23553
  return json;
@@ -30460,8 +31043,8 @@ Renderer.create = function (canvas, framework, renderOptions) {
30460
31043
  Engine.create = function (gl) {
30461
31044
  return new GLEngine(gl);
30462
31045
  };
30463
- var version = "1.3.1";
31046
+ var version = "1.4.0-beta.0";
30464
31047
  logger.info('player version: ' + version);
30465
31048
 
30466
- export { AbstractPlugin, AssetManager, BYTES_TYPE_MAP, BezierSegments, COMPRESSED_TEXTURE, 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, GLEngine, GLGeometry, GLRenderer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK$1 as 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, Player, 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, TextItem, TextLoader, TextMesh, TextVFXItem, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, 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, disableAllPlayer, distortionFrag, distortionVert, earcut, enlargeBuffer, ensureVec3, filters, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateHalfFloatTexture, getActivePlayers, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getParticleMeshShader, getPixelRatio, getPlayerByCanvas, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isCanvasUsedByPlayer, isFunction, isIOS, isObject, isScene, isSceneWithOptions, 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, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError$1 as throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };
31049
+ export { AbstractPlugin, AssetManager, BYTES_TYPE_MAP, BezierCurve, BezierCurvePath, COMPRESSED_TEXTURE, 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, GLEngine, GLGeometry, GLRenderer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK$1 as 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, Player, 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, TextItem, TextLoader, TextMesh, TextVFXItem, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, 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, disableAllPlayer, distortionFrag, distortionVert, earcut, enlargeBuffer, ensureVec3, filters, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateHalfFloatTexture, getActivePlayers, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getParticleMeshShader, getPixelRatio, getPlayerByCanvas, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isCanvasUsedByPlayer, isFunction, isIOS, isObject, isScene, isSceneWithOptions, 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, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError$1 as throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };
30467
31050
  //# sourceMappingURL=weapp.mjs.map