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