@galacean/effects-core 2.1.0-alpha.1 → 2.1.0-alpha.2
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 +77 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -59
- package/dist/index.mjs.map +1 -1
- package/dist/math/value-getter.d.ts +2 -0
- package/dist/plugins/particle/particle-mesh.d.ts +10 -3
- package/dist/texture/texture.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.1.0-alpha.
|
|
6
|
+
* Version: v2.1.0-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -8352,7 +8352,7 @@ var seed$8 = 1;
|
|
|
8352
8352
|
* 通过 URL 创建 Texture 对象。
|
|
8353
8353
|
* @param url - 要创建的 Texture URL
|
|
8354
8354
|
* @since 2.0.0
|
|
8355
|
-
*/ Texture.fromImage = function fromImage(url, engine) {
|
|
8355
|
+
*/ Texture.fromImage = function fromImage(url, engine, options) {
|
|
8356
8356
|
return _async_to_generator(function() {
|
|
8357
8357
|
var image, texture;
|
|
8358
8358
|
return __generator(this, function(_state) {
|
|
@@ -8364,12 +8364,13 @@ var seed$8 = 1;
|
|
|
8364
8364
|
];
|
|
8365
8365
|
case 1:
|
|
8366
8366
|
image = _state.sent();
|
|
8367
|
-
texture = Texture.create(engine, {
|
|
8367
|
+
texture = Texture.create(engine, _extends({
|
|
8368
8368
|
sourceType: exports.TextureSourceType.image,
|
|
8369
8369
|
image: image,
|
|
8370
|
+
target: glContext.TEXTURE_2D,
|
|
8370
8371
|
id: generateGUID(),
|
|
8371
8372
|
flipY: true
|
|
8372
|
-
});
|
|
8373
|
+
}, options));
|
|
8373
8374
|
texture.initialize();
|
|
8374
8375
|
return [
|
|
8375
8376
|
2,
|
|
@@ -10301,15 +10302,19 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10301
10302
|
points: points,
|
|
10302
10303
|
timeInterval: timeInterval,
|
|
10303
10304
|
valueInterval: valueInterval,
|
|
10304
|
-
curve: curve
|
|
10305
|
+
curve: curve,
|
|
10306
|
+
timeStart: Number(s.x),
|
|
10307
|
+
timeEnd: Number(e.x)
|
|
10305
10308
|
};
|
|
10306
10309
|
}
|
|
10307
10310
|
};
|
|
10308
10311
|
_proto.getValue = function getValue(time) {
|
|
10309
10312
|
var result = 0;
|
|
10310
10313
|
var keyTimeData = Object.keys(this.curveMap);
|
|
10311
|
-
var keyTimeStart =
|
|
10312
|
-
var keyTimeEnd =
|
|
10314
|
+
var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
|
|
10315
|
+
var keyTimeEnd = this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
|
|
10316
|
+
// const keyTimeStart = Number(keyTimeData[0].split('&')[0]);
|
|
10317
|
+
// const keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split('&')[1]);
|
|
10313
10318
|
if (time <= keyTimeStart) {
|
|
10314
10319
|
return this.getCurveValue(keyTimeData[0], keyTimeStart);
|
|
10315
10320
|
}
|
|
@@ -10317,7 +10322,9 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10317
10322
|
return this.getCurveValue(keyTimeData[keyTimeData.length - 1], keyTimeEnd);
|
|
10318
10323
|
}
|
|
10319
10324
|
for(var i = 0; i < keyTimeData.length; i++){
|
|
10320
|
-
var
|
|
10325
|
+
var xMin = this.curveMap[keyTimeData[i]].timeStart;
|
|
10326
|
+
var xMax = this.curveMap[keyTimeData[i]].timeEnd;
|
|
10327
|
+
// const [xMin, xMax] = keyTimeData[i].split('&');
|
|
10321
10328
|
if (time >= Number(xMin) && time < Number(xMax)) {
|
|
10322
10329
|
result = this.getCurveValue(keyTimeData[i], time);
|
|
10323
10330
|
break;
|
|
@@ -10330,12 +10337,13 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10330
10337
|
var time = (t1 - t0) / ts;
|
|
10331
10338
|
var result = 0;
|
|
10332
10339
|
var keyTimeData = Object.keys(this.curveMap);
|
|
10333
|
-
var keyTimeStart =
|
|
10340
|
+
var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
|
|
10334
10341
|
if (time <= keyTimeStart) {
|
|
10335
10342
|
return 0;
|
|
10336
10343
|
}
|
|
10337
10344
|
for(var i = 0; i < keyTimeData.length; i++){
|
|
10338
|
-
var
|
|
10345
|
+
var xMin = this.curveMap[keyTimeData[i]].timeStart;
|
|
10346
|
+
var xMax = this.curveMap[keyTimeData[i]].timeEnd;
|
|
10339
10347
|
if (time >= Number(xMax)) {
|
|
10340
10348
|
result += ts * this.getCurveIntegrateValue(keyTimeData[i], Number(xMax));
|
|
10341
10349
|
}
|
|
@@ -17669,6 +17677,12 @@ var particleUniformTypeMap = {
|
|
|
17669
17677
|
var ParticleMesh = /*#__PURE__*/ function() {
|
|
17670
17678
|
function ParticleMesh(engine, props) {
|
|
17671
17679
|
this.particleCount = 0;
|
|
17680
|
+
this.cachedVelocity = new Vector3();
|
|
17681
|
+
this.cachedRotationVector3 = new Vector3();
|
|
17682
|
+
this.cachedRotationMatrix = new Matrix3();
|
|
17683
|
+
this.cachedLinearMove = new Vector3();
|
|
17684
|
+
this.tempMatrix3 = new Matrix3();
|
|
17685
|
+
this.tempVector3 = new Vector3();
|
|
17672
17686
|
this.VERT_MAX_KEY_FRAME_COUNT = 0;
|
|
17673
17687
|
var _engine_renderer;
|
|
17674
17688
|
var env = ((_engine_renderer = engine.renderer) != null ? _engine_renderer : {}).env;
|
|
@@ -18072,39 +18086,40 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18072
18086
|
// if (!uParams) {
|
|
18073
18087
|
// return;
|
|
18074
18088
|
// }
|
|
18075
|
-
var localTime =
|
|
18076
|
-
this.time
|
|
18077
|
-
])[0];
|
|
18089
|
+
var localTime = this.time;
|
|
18078
18090
|
var particleCount = Math.ceil(aPosArray.length / 12);
|
|
18079
18091
|
// calculate particle translation
|
|
18080
18092
|
var aTranslationArray = this.geometry.getAttributeData("aTranslation");
|
|
18081
18093
|
if (aTranslationArray.length < particleCount * 3) {
|
|
18082
|
-
aTranslationArray =
|
|
18094
|
+
aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
|
|
18083
18095
|
}
|
|
18084
|
-
var velocity =
|
|
18096
|
+
var velocity = this.cachedVelocity;
|
|
18085
18097
|
for(var i = 0; i < particleCount; i++){
|
|
18086
18098
|
var velOffset = i * 12 + 3;
|
|
18087
18099
|
velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
|
|
18088
|
-
|
|
18100
|
+
this.calculateTranslation(velocity, aOffsetArray[i * 4 + 2], localTime, aOffsetArray[i * 4 + 3]);
|
|
18089
18101
|
var aTranslationOffset = i * 3;
|
|
18090
|
-
|
|
18091
|
-
|
|
18092
|
-
|
|
18102
|
+
if (aOffsetArray[i * 4 + 2] < localTime) {
|
|
18103
|
+
var translation = velocity.multiply(dt / 1000);
|
|
18104
|
+
aTranslationArray[aTranslationOffset] += translation.x;
|
|
18105
|
+
aTranslationArray[aTranslationOffset + 1] += translation.y;
|
|
18106
|
+
aTranslationArray[aTranslationOffset + 2] += translation.z;
|
|
18107
|
+
}
|
|
18093
18108
|
}
|
|
18094
18109
|
this.geometry.setAttributeData("aTranslation", aTranslationArray);
|
|
18095
18110
|
// calculate particle rotation
|
|
18096
18111
|
var aRotationArray = this.geometry.getAttributeData("aRotation0");
|
|
18097
18112
|
if (aRotationArray.length < particleCount * 9) {
|
|
18098
|
-
aRotationArray =
|
|
18113
|
+
aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
|
|
18099
18114
|
}
|
|
18100
18115
|
for(var i1 = 0; i1 < particleCount; i1++){
|
|
18101
18116
|
var time = localTime - aOffsetArray[i1 * 4 + 2];
|
|
18102
18117
|
var duration = aOffsetArray[i1 * 4 + 3];
|
|
18103
18118
|
var life = clamp$1(time / duration, 0.0, 1.0);
|
|
18104
18119
|
var aRotOffset = i1 * 8;
|
|
18105
|
-
var aRot =
|
|
18120
|
+
var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
|
|
18106
18121
|
var aSeed = aSeedArray[i1 * 8 + 3];
|
|
18107
|
-
var aRotation = this.transformFromRotation(aRot, life, duration, aSeed);
|
|
18122
|
+
var aRotation = this.transformFromRotation(aRot, life, duration, aSeed, this.cachedRotationMatrix);
|
|
18108
18123
|
var aRotationOffset = i1 * 9;
|
|
18109
18124
|
var matrixArray = aRotation.toArray();
|
|
18110
18125
|
aRotationArray.set(matrixArray, aRotationOffset);
|
|
@@ -18113,14 +18128,16 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18113
18128
|
// calculate linear movement
|
|
18114
18129
|
var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
|
|
18115
18130
|
if (aLinearMoveArray.length < particleCount * 3) {
|
|
18116
|
-
aLinearMoveArray =
|
|
18131
|
+
aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
|
|
18117
18132
|
}
|
|
18133
|
+
var linearMove = this.cachedLinearMove;
|
|
18118
18134
|
for(var i2 = 0; i2 < particleCount; i2++){
|
|
18119
18135
|
var time1 = localTime - aOffsetArray[i2 * 4 + 2];
|
|
18120
18136
|
var duration1 = aOffsetArray[i2 * 4 + 3];
|
|
18121
18137
|
// const life = math.clamp(time / duration, 0.0, 1.0);
|
|
18122
18138
|
var aSeed1 = aSeedArray[i2 * 8 + 3];
|
|
18123
|
-
|
|
18139
|
+
linearMove.setZero();
|
|
18140
|
+
this.calLinearMov(time1, duration1, aSeed1, linearMove);
|
|
18124
18141
|
var aLinearMoveOffset = i2 * 3;
|
|
18125
18142
|
aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
|
|
18126
18143
|
aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
|
|
@@ -18140,29 +18157,23 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18140
18157
|
var uAcceleration = this.mesh.material.getVector4("uAcceleration");
|
|
18141
18158
|
var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
|
|
18142
18159
|
if (!uAcceleration || !uGravityModifierValue) {
|
|
18143
|
-
return
|
|
18160
|
+
return velocity;
|
|
18144
18161
|
}
|
|
18145
18162
|
var dt = t1 - t0; // 相对delay的时间
|
|
18146
|
-
var d = this.gravityModifier.
|
|
18147
|
-
var acc =
|
|
18148
|
-
uAcceleration.x * d,
|
|
18149
|
-
uAcceleration.y * d,
|
|
18150
|
-
uAcceleration.z * d
|
|
18151
|
-
];
|
|
18152
|
-
// ret.addScaledVector(velData, speedIntegrate);
|
|
18153
|
-
// ret.addScaledVector(acc, d);
|
|
18163
|
+
var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
|
|
18164
|
+
var acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
|
|
18154
18165
|
// speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
|
|
18155
18166
|
if (this.speedOverLifetime) {
|
|
18156
18167
|
// dt / dur 归一化
|
|
18157
|
-
var speed = this.speedOverLifetime.
|
|
18158
|
-
return velocity.
|
|
18168
|
+
var speed = this.speedOverLifetime.getValue(dt / duration);
|
|
18169
|
+
return velocity.multiply(speed).add(acc);
|
|
18159
18170
|
}
|
|
18160
|
-
return velocity.
|
|
18171
|
+
return velocity.add(acc);
|
|
18161
18172
|
};
|
|
18162
|
-
_proto.transformFromRotation = function transformFromRotation(rot, life, dur, aSeed) {
|
|
18163
|
-
var rotation = rot
|
|
18173
|
+
_proto.transformFromRotation = function transformFromRotation(rot, life, dur, aSeed, result) {
|
|
18174
|
+
var rotation = rot;
|
|
18164
18175
|
if (!this.rotationOverLifetime) {
|
|
18165
|
-
return
|
|
18176
|
+
return result.setZero();
|
|
18166
18177
|
}
|
|
18167
18178
|
if (this.rotationOverLifetime.asRotation) {
|
|
18168
18179
|
// Adjust rotation based on the specified lifetime components
|
|
@@ -18213,32 +18224,33 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18213
18224
|
}
|
|
18214
18225
|
// If the rotation vector is zero, return the identity matrix
|
|
18215
18226
|
if (rotation.dot(rotation) === 0.0) {
|
|
18216
|
-
return
|
|
18227
|
+
return result.identity();
|
|
18217
18228
|
}
|
|
18218
18229
|
// Return the rotation matrix derived from the rotation vector
|
|
18219
|
-
return this.mat3FromRotation(rotation);
|
|
18230
|
+
return this.mat3FromRotation(rotation, result);
|
|
18220
18231
|
};
|
|
18221
|
-
_proto.mat3FromRotation = function mat3FromRotation(rotation) {
|
|
18232
|
+
_proto.mat3FromRotation = function mat3FromRotation(rotation, result) {
|
|
18222
18233
|
var d2r = Math.PI / 180;
|
|
18223
|
-
var
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
var
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
var
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18234
|
+
var rotationXD2r = rotation.x * d2r;
|
|
18235
|
+
var rotationYD2r = rotation.y * d2r;
|
|
18236
|
+
var rotationZD2r = rotation.z * d2r;
|
|
18237
|
+
var sinRX = Math.sin(rotationXD2r);
|
|
18238
|
+
var sinRY = Math.sin(rotationYD2r);
|
|
18239
|
+
var sinRZ = Math.sin(rotationZD2r);
|
|
18240
|
+
var cosRX = Math.cos(rotationXD2r);
|
|
18241
|
+
var cosRY = Math.cos(rotationYD2r);
|
|
18242
|
+
var cosRZ = Math.cos(rotationZD2r);
|
|
18243
|
+
// rotZ * rotY * rotX
|
|
18244
|
+
result.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
|
|
18245
|
+
result.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
|
|
18246
|
+
result.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
|
|
18235
18247
|
return result;
|
|
18236
18248
|
};
|
|
18237
|
-
_proto.calLinearMov = function calLinearMov(time, duration, aSeed) {
|
|
18238
|
-
var mov =
|
|
18249
|
+
_proto.calLinearMov = function calLinearMov(time, duration, aSeed, result) {
|
|
18250
|
+
var mov = result;
|
|
18239
18251
|
var lifetime = time / duration;
|
|
18240
18252
|
if (!this.linearVelOverLifetime || !this.linearVelOverLifetime.enabled) {
|
|
18241
|
-
return
|
|
18253
|
+
return mov;
|
|
18242
18254
|
}
|
|
18243
18255
|
if (this.linearVelOverLifetime.asMovement) {
|
|
18244
18256
|
if (this.linearVelOverLifetime.x) {
|
|
@@ -18311,7 +18323,8 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18311
18323
|
var pointData = {
|
|
18312
18324
|
aPos: new Float32Array(48),
|
|
18313
18325
|
aRot: new Float32Array(32),
|
|
18314
|
-
aOffset: new Float32Array(16)
|
|
18326
|
+
aOffset: new Float32Array(16),
|
|
18327
|
+
aTranslation: new Float32Array(12)
|
|
18315
18328
|
};
|
|
18316
18329
|
var useSprite = this.useSprite;
|
|
18317
18330
|
if (useSprite) {
|
|
@@ -18420,6 +18433,11 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18420
18433
|
geometry.setDrawCount(this.particleCount * 6);
|
|
18421
18434
|
}
|
|
18422
18435
|
};
|
|
18436
|
+
_proto.expandArray = function expandArray(array, newSize) {
|
|
18437
|
+
var newArr = new Float32Array(newSize);
|
|
18438
|
+
newArr.set(array);
|
|
18439
|
+
return newArr;
|
|
18440
|
+
};
|
|
18423
18441
|
return ParticleMesh;
|
|
18424
18442
|
}();
|
|
18425
18443
|
var gl2UniformSlots = [
|
|
@@ -28070,7 +28088,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
28070
28088
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
28071
28089
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
28072
28090
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
28073
|
-
var version = "2.1.0-alpha.
|
|
28091
|
+
var version = "2.1.0-alpha.2";
|
|
28074
28092
|
logger.info("Core version: " + version + ".");
|
|
28075
28093
|
|
|
28076
28094
|
exports.AbstractPlugin = AbstractPlugin;
|