@galacean/effects-core 2.1.0-alpha.2 → 2.1.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.1.0-alpha.2
6
+ * Version: v2.1.0-alpha.3
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -13601,25 +13601,25 @@ function _assert_this_initialized(self) {
13601
13601
  }
13602
13602
  var _proto = PlayableGraph.prototype;
13603
13603
  _proto.evaluate = function evaluate(dt) {
13604
- // 初始化节点状态
13605
- for(var _iterator = _create_for_of_iterator_helper_loose(this.playables), _step; !(_step = _iterator()).done;){
13606
- var playable = _step.value;
13607
- this.updatePlayableTime(playable, dt);
13608
- }
13609
13604
  // 初始化输出节点状态
13610
- for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13611
- var playableOutput = _step1.value;
13605
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.playableOutputs), _step; !(_step = _iterator()).done;){
13606
+ var playableOutput = _step.value;
13612
13607
  playableOutput.context.deltaTime = dt;
13613
13608
  }
13614
13609
  // 执行生命周期函数
13615
- for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13616
- var playableOutput1 = _step2.value;
13610
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13611
+ var playableOutput1 = _step1.value;
13617
13612
  this.prepareFrameWithRoot(playableOutput1);
13618
13613
  }
13619
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step3; !(_step3 = _iterator3()).done;){
13620
- var playableOutput2 = _step3.value;
13614
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13615
+ var playableOutput2 = _step2.value;
13621
13616
  this.processFrameWithRoot(playableOutput2);
13622
13617
  }
13618
+ // 更新节点时间
13619
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
13620
+ var playable = _step3.value;
13621
+ this.updatePlayableTime(playable, dt);
13622
+ }
13623
13623
  };
13624
13624
  _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
13625
13625
  destination.connectInput(destinationInputPort, source, sourceOutputPort);
@@ -13642,11 +13642,7 @@ function _assert_this_initialized(self) {
13642
13642
  if (playable.getPlayState() !== 0) {
13643
13643
  return;
13644
13644
  }
13645
- if (playable.overrideTimeNextEvaluation) {
13646
- playable.overrideTimeNextEvaluation = false;
13647
- } else {
13648
- playable.setTime(playable.getTime() + deltaTime);
13649
- }
13645
+ playable.setTime(playable.getTime() + deltaTime);
13650
13646
  };
13651
13647
  return PlayableGraph;
13652
13648
  }();
@@ -13658,7 +13654,6 @@ function _assert_this_initialized(self) {
13658
13654
  if (inputCount === void 0) inputCount = 0;
13659
13655
  this.onPlayablePlayFlag = true;
13660
13656
  this.onPlayablePauseFlag = false;
13661
- this.overrideTimeNextEvaluation = false;
13662
13657
  this.destroyed = false;
13663
13658
  this.inputs = [];
13664
13659
  this.inputOuputPorts = [];
@@ -13747,7 +13742,6 @@ function _assert_this_initialized(self) {
13747
13742
  };
13748
13743
  _proto.setTime = function setTime(time) {
13749
13744
  this.time = time;
13750
- this.overrideTimeNextEvaluation = true;
13751
13745
  };
13752
13746
  _proto.getTime = function getTime() {
13753
13747
  return this.time;
@@ -16550,8 +16544,9 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16550
16544
  };
16551
16545
  _proto.onUpdate = function onUpdate(dt) {
16552
16546
  var time = this.particleMesh.time;
16553
- this.particleMesh.mesh.material.setVector4("uParams", new Vector4(time, this.item.duration, 0, 0));
16554
- this.particleMesh.onUpdate(dt);
16547
+ var _this_particleMesh_mesh_material_getVector4;
16548
+ var uParams = (_this_particleMesh_mesh_material_getVector4 = this.particleMesh.mesh.material.getVector4("uParams")) != null ? _this_particleMesh_mesh_material_getVector4 : new Vector4();
16549
+ this.particleMesh.mesh.material.setVector4("uParams", uParams.set(time, this.item.duration, 0, 0));
16555
16550
  };
16556
16551
  _proto.render = function render(renderer) {
16557
16552
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
@@ -16566,7 +16561,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16566
16561
  };
16567
16562
  _proto.updateTime = function updateTime(now, delta) {
16568
16563
  this.particleMesh.time = now;
16569
- // this.particleMesh.onUpdate(delta);
16564
+ this.particleMesh.onUpdate(delta);
16570
16565
  if (this.trailMesh) {
16571
16566
  this.trailMesh.time = now;
16572
16567
  this.trailMesh.onUpdate(delta);
@@ -16860,7 +16855,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
16860
16855
  break;
16861
16856
  }
16862
16857
  var burst = bursts[j];
16863
- var opts = burst.getGeneratorOptions(timePassed, lifetime);
16858
+ var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
16864
16859
  if (opts) {
16865
16860
  var originVec = [
16866
16861
  0,
@@ -16869,6 +16864,9 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
16869
16864
  ];
16870
16865
  var offsets = emission.burstOffsets[j];
16871
16866
  var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
16867
+ if (burst.once) {
16868
+ this.removeBurst(j);
16869
+ }
16872
16870
  for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
16873
16871
  var _p_transform;
16874
16872
  if (shouldSkipGenerate()) {
@@ -17673,12 +17671,10 @@ var particleUniformTypeMap = {
17673
17671
  var ParticleMesh = /*#__PURE__*/ function() {
17674
17672
  function ParticleMesh(engine, props) {
17675
17673
  this.particleCount = 0;
17676
- this.cachedVelocity = new Vector3();
17677
17674
  this.cachedRotationVector3 = new Vector3();
17678
17675
  this.cachedRotationMatrix = new Matrix3();
17679
17676
  this.cachedLinearMove = new Vector3();
17680
17677
  this.tempMatrix3 = new Matrix3();
17681
- this.tempVector3 = new Vector3();
17682
17678
  this.VERT_MAX_KEY_FRAME_COUNT = 0;
17683
17679
  var _engine_renderer;
17684
17680
  var env = ((_engine_renderer = engine.renderer) != null ? _engine_renderer : {}).env;
@@ -18074,72 +18070,10 @@ var ParticleMesh = /*#__PURE__*/ function() {
18074
18070
  };
18075
18071
  _proto.onUpdate = function onUpdate(dt) {
18076
18072
  var aPosArray = this.geometry.getAttributeData("aPos"); // vector3
18077
- var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
18078
- var aOffsetArray = this.geometry.getAttributeData("aOffset");
18079
- var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
18080
- var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18081
- // const uParams = this.mesh.material.getVector4('uParams');
18082
- // if (!uParams) {
18083
- // return;
18084
- // }
18085
- var localTime = this.time;
18086
18073
  var particleCount = Math.ceil(aPosArray.length / 12);
18087
- // calculate particle translation
18088
- var aTranslationArray = this.geometry.getAttributeData("aTranslation");
18089
- if (aTranslationArray.length < particleCount * 3) {
18090
- aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
18091
- }
18092
- var velocity = this.cachedVelocity;
18093
- for(var i = 0; i < particleCount; i++){
18094
- var velOffset = i * 12 + 3;
18095
- velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
18096
- this.calculateTranslation(velocity, aOffsetArray[i * 4 + 2], localTime, aOffsetArray[i * 4 + 3]);
18097
- var aTranslationOffset = i * 3;
18098
- if (aOffsetArray[i * 4 + 2] < localTime) {
18099
- var translation = velocity.multiply(dt / 1000);
18100
- aTranslationArray[aTranslationOffset] += translation.x;
18101
- aTranslationArray[aTranslationOffset + 1] += translation.y;
18102
- aTranslationArray[aTranslationOffset + 2] += translation.z;
18103
- }
18104
- }
18105
- this.geometry.setAttributeData("aTranslation", aTranslationArray);
18106
- // calculate particle rotation
18107
- var aRotationArray = this.geometry.getAttributeData("aRotation0");
18108
- if (aRotationArray.length < particleCount * 9) {
18109
- aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
18110
- }
18111
- for(var i1 = 0; i1 < particleCount; i1++){
18112
- var time = localTime - aOffsetArray[i1 * 4 + 2];
18113
- var duration = aOffsetArray[i1 * 4 + 3];
18114
- var life = clamp$1(time / duration, 0.0, 1.0);
18115
- var aRotOffset = i1 * 8;
18116
- var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
18117
- var aSeed = aSeedArray[i1 * 8 + 3];
18118
- var aRotation = this.transformFromRotation(aRot, life, duration, aSeed, this.cachedRotationMatrix);
18119
- var aRotationOffset = i1 * 9;
18120
- var matrixArray = aRotation.toArray();
18121
- aRotationArray.set(matrixArray, aRotationOffset);
18122
- }
18123
- this.geometry.setAttributeData("aRotation0", aRotationArray);
18124
- // calculate linear movement
18125
- var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
18126
- if (aLinearMoveArray.length < particleCount * 3) {
18127
- aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
18128
- }
18129
- var linearMove = this.cachedLinearMove;
18130
- for(var i2 = 0; i2 < particleCount; i2++){
18131
- var time1 = localTime - aOffsetArray[i2 * 4 + 2];
18132
- var duration1 = aOffsetArray[i2 * 4 + 3];
18133
- // const life = math.clamp(time / duration, 0.0, 1.0);
18134
- var aSeed1 = aSeedArray[i2 * 8 + 3];
18135
- linearMove.setZero();
18136
- this.calLinearMov(time1, duration1, aSeed1, linearMove);
18137
- var aLinearMoveOffset = i2 * 3;
18138
- aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
18139
- aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
18140
- aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
18141
- }
18142
- this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
18074
+ this.applyTranslation(particleCount, dt);
18075
+ this.applyRotation(particleCount, dt);
18076
+ this.applyLinearMove(particleCount, dt);
18143
18077
  };
18144
18078
  _proto.minusTime = function minusTime(time) {
18145
18079
  var aOffset = this.geometry.getAttributeData("aOffset");
@@ -18149,153 +18083,6 @@ var ParticleMesh = /*#__PURE__*/ function() {
18149
18083
  this.geometry.setAttributeData("aOffset", aOffset);
18150
18084
  this.time -= time;
18151
18085
  };
18152
- _proto.calculateTranslation = function calculateTranslation(velocity, t0, t1, duration) {
18153
- var uAcceleration = this.mesh.material.getVector4("uAcceleration");
18154
- var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
18155
- if (!uAcceleration || !uGravityModifierValue) {
18156
- return velocity;
18157
- }
18158
- var dt = t1 - t0; // 相对delay的时间
18159
- var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
18160
- var acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
18161
- // speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
18162
- if (this.speedOverLifetime) {
18163
- // dt / dur 归一化
18164
- var speed = this.speedOverLifetime.getValue(dt / duration);
18165
- return velocity.multiply(speed).add(acc);
18166
- }
18167
- return velocity.add(acc);
18168
- };
18169
- _proto.transformFromRotation = function transformFromRotation(rot, life, dur, aSeed, result) {
18170
- var rotation = rot;
18171
- if (!this.rotationOverLifetime) {
18172
- return result.setZero();
18173
- }
18174
- if (this.rotationOverLifetime.asRotation) {
18175
- // Adjust rotation based on the specified lifetime components
18176
- if (this.rotationOverLifetime.x) {
18177
- if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18178
- rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
18179
- } else {
18180
- rotation.x += this.rotationOverLifetime.x.getValue(life);
18181
- }
18182
- }
18183
- if (this.rotationOverLifetime.y) {
18184
- if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18185
- rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
18186
- } else {
18187
- rotation.y += this.rotationOverLifetime.y.getValue(life);
18188
- }
18189
- }
18190
- if (this.rotationOverLifetime.z) {
18191
- if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18192
- rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
18193
- } else {
18194
- rotation.z += this.rotationOverLifetime.z.getValue(life);
18195
- }
18196
- }
18197
- } else {
18198
- // Adjust rotation based on the specified lifetime components
18199
- if (this.rotationOverLifetime.x) {
18200
- if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18201
- rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * dur;
18202
- } else {
18203
- rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, dur) * dur;
18204
- }
18205
- }
18206
- if (this.rotationOverLifetime.y) {
18207
- if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18208
- rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * dur;
18209
- } else {
18210
- rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, dur) * dur;
18211
- }
18212
- }
18213
- if (this.rotationOverLifetime.z) {
18214
- if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18215
- rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * dur;
18216
- } else {
18217
- rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, dur) * dur;
18218
- }
18219
- }
18220
- }
18221
- // If the rotation vector is zero, return the identity matrix
18222
- if (rotation.dot(rotation) === 0.0) {
18223
- return result.identity();
18224
- }
18225
- // Return the rotation matrix derived from the rotation vector
18226
- return this.mat3FromRotation(rotation, result);
18227
- };
18228
- _proto.mat3FromRotation = function mat3FromRotation(rotation, result) {
18229
- var d2r = Math.PI / 180;
18230
- var rotationXD2r = rotation.x * d2r;
18231
- var rotationYD2r = rotation.y * d2r;
18232
- var rotationZD2r = rotation.z * d2r;
18233
- var sinRX = Math.sin(rotationXD2r);
18234
- var sinRY = Math.sin(rotationYD2r);
18235
- var sinRZ = Math.sin(rotationZD2r);
18236
- var cosRX = Math.cos(rotationXD2r);
18237
- var cosRY = Math.cos(rotationYD2r);
18238
- var cosRZ = Math.cos(rotationZD2r);
18239
- // rotZ * rotY * rotX
18240
- result.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
18241
- result.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
18242
- result.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
18243
- return result;
18244
- };
18245
- _proto.calLinearMov = function calLinearMov(time, duration, aSeed, result) {
18246
- var mov = result;
18247
- var lifetime = time / duration;
18248
- if (!this.linearVelOverLifetime || !this.linearVelOverLifetime.enabled) {
18249
- return mov;
18250
- }
18251
- if (this.linearVelOverLifetime.asMovement) {
18252
- if (this.linearVelOverLifetime.x) {
18253
- if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18254
- mov.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
18255
- } else {
18256
- mov.x = this.linearVelOverLifetime.x.getValue(lifetime);
18257
- }
18258
- }
18259
- if (this.linearVelOverLifetime.y) {
18260
- if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18261
- mov.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
18262
- } else {
18263
- mov.y = this.linearVelOverLifetime.y.getValue(lifetime);
18264
- }
18265
- }
18266
- if (this.linearVelOverLifetime.z) {
18267
- if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18268
- mov.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
18269
- } else {
18270
- mov.z = this.linearVelOverLifetime.z.getValue(lifetime);
18271
- }
18272
- }
18273
- } else {
18274
- // Adjust rotation based on the specified lifetime components
18275
- if (this.linearVelOverLifetime.x) {
18276
- if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18277
- mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
18278
- } else {
18279
- mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
18280
- }
18281
- }
18282
- if (this.linearVelOverLifetime.y) {
18283
- if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18284
- mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
18285
- } else {
18286
- mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
18287
- }
18288
- }
18289
- if (this.linearVelOverLifetime.z) {
18290
- if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18291
- mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
18292
- } else {
18293
- mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
18294
- }
18295
- }
18296
- }
18297
- return mov;
18298
- };
18299
18086
  _proto.removePoint = function removePoint(index) {
18300
18087
  if (index < this.particleCount) {
18301
18088
  this.geometry.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
@@ -18429,6 +18216,221 @@ var ParticleMesh = /*#__PURE__*/ function() {
18429
18216
  geometry.setDrawCount(this.particleCount * 6);
18430
18217
  }
18431
18218
  };
18219
+ _proto.applyTranslation = function applyTranslation(particleCount, deltaTime) {
18220
+ var localTime = this.time;
18221
+ var aTranslationArray = this.geometry.getAttributeData("aTranslation");
18222
+ var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
18223
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18224
+ if (aTranslationArray.length < particleCount * 3) {
18225
+ aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
18226
+ }
18227
+ // const velocity = this.cachedVelocity;
18228
+ var velocityX = 0;
18229
+ var velocityY = 0;
18230
+ var velocityZ = 0;
18231
+ var uAcceleration = this.mesh.material.getVector4("uAcceleration");
18232
+ var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
18233
+ for(var i = 0; i < particleCount; i++){
18234
+ var velOffset = i * 12 + 3;
18235
+ velocityX = aVelArray[velOffset];
18236
+ velocityY = aVelArray[velOffset + 1];
18237
+ velocityZ = aVelArray[velOffset + 2];
18238
+ // velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
18239
+ var dt = localTime - aOffsetArray[i * 4 + 2]; // 相对delay的时间
18240
+ var duration = aOffsetArray[i * 4 + 3];
18241
+ if (uAcceleration && uGravityModifierValue) {
18242
+ var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
18243
+ // const acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
18244
+ var accX = uAcceleration.x * d;
18245
+ var accY = uAcceleration.y * d;
18246
+ var accZ = uAcceleration.z * d;
18247
+ // speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
18248
+ if (this.speedOverLifetime) {
18249
+ // dt / dur 归一化
18250
+ var speed = this.speedOverLifetime.getValue(dt / duration);
18251
+ velocityX = velocityX * speed + accX;
18252
+ velocityY = velocityY * speed + accY;
18253
+ velocityZ = velocityZ * speed + accZ;
18254
+ // velocity.multiply(speed).add(acc);
18255
+ } else {
18256
+ velocityX = velocityX + accX;
18257
+ velocityY = velocityY + accY;
18258
+ velocityZ = velocityZ + accZ;
18259
+ // velocity.add(acc);
18260
+ }
18261
+ }
18262
+ var aTranslationOffset = i * 3;
18263
+ if (aOffsetArray[i * 4 + 2] < localTime) {
18264
+ // const translation = velocity.multiply(deltaTime / 1000);
18265
+ aTranslationArray[aTranslationOffset] += velocityX * (deltaTime / 1000);
18266
+ aTranslationArray[aTranslationOffset + 1] += velocityY * (deltaTime / 1000);
18267
+ aTranslationArray[aTranslationOffset + 2] += velocityZ * (deltaTime / 1000);
18268
+ }
18269
+ }
18270
+ this.geometry.setAttributeData("aTranslation", aTranslationArray);
18271
+ };
18272
+ _proto.applyRotation = function applyRotation(particleCount, deltaTime) {
18273
+ var aRotationArray = this.geometry.getAttributeData("aRotation0");
18274
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18275
+ var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
18276
+ var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18277
+ var localTime = this.time;
18278
+ var aRotationMatrix = this.cachedRotationMatrix;
18279
+ if (aRotationArray.length < particleCount * 9) {
18280
+ aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
18281
+ }
18282
+ for(var i = 0; i < particleCount; i++){
18283
+ var time = localTime - aOffsetArray[i * 4 + 2];
18284
+ var duration = aOffsetArray[i * 4 + 3];
18285
+ var life = clamp$1(time / duration, 0.0, 1.0);
18286
+ var aRotOffset = i * 8;
18287
+ var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
18288
+ var aSeed = aSeedArray[i * 8 + 3];
18289
+ var rotation = aRot;
18290
+ if (!this.rotationOverLifetime) {
18291
+ aRotationMatrix.setZero();
18292
+ } else if (this.rotationOverLifetime.asRotation) {
18293
+ // Adjust rotation based on the specified lifetime components
18294
+ if (this.rotationOverLifetime.x) {
18295
+ if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18296
+ rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
18297
+ } else {
18298
+ rotation.x += this.rotationOverLifetime.x.getValue(life);
18299
+ }
18300
+ }
18301
+ if (this.rotationOverLifetime.y) {
18302
+ if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18303
+ rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
18304
+ } else {
18305
+ rotation.y += this.rotationOverLifetime.y.getValue(life);
18306
+ }
18307
+ }
18308
+ if (this.rotationOverLifetime.z) {
18309
+ if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18310
+ rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
18311
+ } else {
18312
+ rotation.z += this.rotationOverLifetime.z.getValue(life);
18313
+ }
18314
+ }
18315
+ } else {
18316
+ // Adjust rotation based on the specified lifetime components
18317
+ if (this.rotationOverLifetime.x) {
18318
+ if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18319
+ rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * duration;
18320
+ } else {
18321
+ rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, duration) * duration;
18322
+ }
18323
+ }
18324
+ if (this.rotationOverLifetime.y) {
18325
+ if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18326
+ rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * duration;
18327
+ } else {
18328
+ rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, duration) * duration;
18329
+ }
18330
+ }
18331
+ if (this.rotationOverLifetime.z) {
18332
+ if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18333
+ rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * duration;
18334
+ } else {
18335
+ rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, duration) * duration;
18336
+ }
18337
+ }
18338
+ }
18339
+ // If the rotation vector is zero, return the identity matrix
18340
+ if (rotation.dot(rotation) === 0.0) {
18341
+ aRotationMatrix.identity();
18342
+ }
18343
+ var d2r = Math.PI / 180;
18344
+ var rotationXD2r = rotation.x * d2r;
18345
+ var rotationYD2r = rotation.y * d2r;
18346
+ var rotationZD2r = rotation.z * d2r;
18347
+ var sinRX = Math.sin(rotationXD2r);
18348
+ var sinRY = Math.sin(rotationYD2r);
18349
+ var sinRZ = Math.sin(rotationZD2r);
18350
+ var cosRX = Math.cos(rotationXD2r);
18351
+ var cosRY = Math.cos(rotationYD2r);
18352
+ var cosRZ = Math.cos(rotationZD2r);
18353
+ // rotZ * rotY * rotX
18354
+ aRotationMatrix.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
18355
+ aRotationMatrix.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
18356
+ aRotationMatrix.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
18357
+ var aRotationOffset = i * 9;
18358
+ var matrixArray = aRotationMatrix.elements;
18359
+ aRotationArray.set(matrixArray, aRotationOffset);
18360
+ }
18361
+ this.geometry.setAttributeData("aRotation0", aRotationArray);
18362
+ };
18363
+ _proto.applyLinearMove = function applyLinearMove(particleCount, deltaTime) {
18364
+ var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
18365
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18366
+ var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18367
+ var localTime = this.time;
18368
+ if (aLinearMoveArray.length < particleCount * 3) {
18369
+ aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
18370
+ }
18371
+ var linearMove = this.cachedLinearMove;
18372
+ if (this.linearVelOverLifetime && this.linearVelOverLifetime.enabled) {
18373
+ for(var i = 0; i < particleCount; i++){
18374
+ var time = localTime - aOffsetArray[i * 4 + 2];
18375
+ var duration = aOffsetArray[i * 4 + 3];
18376
+ // const life = math.clamp(time / duration, 0.0, 1.0);
18377
+ var lifetime = time / duration;
18378
+ var aSeed = aSeedArray[i * 8 + 3];
18379
+ linearMove.setZero();
18380
+ if (this.linearVelOverLifetime.asMovement) {
18381
+ if (this.linearVelOverLifetime.x) {
18382
+ if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18383
+ linearMove.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
18384
+ } else {
18385
+ linearMove.x = this.linearVelOverLifetime.x.getValue(lifetime);
18386
+ }
18387
+ }
18388
+ if (this.linearVelOverLifetime.y) {
18389
+ if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18390
+ linearMove.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
18391
+ } else {
18392
+ linearMove.y = this.linearVelOverLifetime.y.getValue(lifetime);
18393
+ }
18394
+ }
18395
+ if (this.linearVelOverLifetime.z) {
18396
+ if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18397
+ linearMove.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
18398
+ } else {
18399
+ linearMove.z = this.linearVelOverLifetime.z.getValue(lifetime);
18400
+ }
18401
+ }
18402
+ } else {
18403
+ // Adjust rotation based on the specified lifetime components
18404
+ if (this.linearVelOverLifetime.x) {
18405
+ if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18406
+ linearMove.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
18407
+ } else {
18408
+ linearMove.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
18409
+ }
18410
+ }
18411
+ if (this.linearVelOverLifetime.y) {
18412
+ if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18413
+ linearMove.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
18414
+ } else {
18415
+ linearMove.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
18416
+ }
18417
+ }
18418
+ if (this.linearVelOverLifetime.z) {
18419
+ if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18420
+ linearMove.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
18421
+ } else {
18422
+ linearMove.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
18423
+ }
18424
+ }
18425
+ }
18426
+ var aLinearMoveOffset = i * 3;
18427
+ aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
18428
+ aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
18429
+ aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
18430
+ }
18431
+ }
18432
+ this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
18433
+ };
18432
18434
  _proto.expandArray = function expandArray(array, newSize) {
18433
18435
  var newArr = new Float32Array(newSize);
18434
18436
  newArr.set(array);
@@ -19065,7 +19067,13 @@ TransformPlayableAsset = __decorate([
19065
19067
  return Playable.apply(this, arguments);
19066
19068
  }
19067
19069
  var _proto = ActivationPlayable.prototype;
19068
- _proto.processFrame = function processFrame(context) {};
19070
+ _proto.processFrame = function processFrame(context) {
19071
+ var vfxItem = context.output.getUserData();
19072
+ if (!_instanceof1(vfxItem, VFXItem)) {
19073
+ return;
19074
+ }
19075
+ vfxItem.time = this.time;
19076
+ };
19069
19077
  return ActivationPlayable;
19070
19078
  }(Playable);
19071
19079
  var ActivationPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
@@ -19218,7 +19226,7 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
19218
19226
  _proto.toLocalTime = function toLocalTime(time) {
19219
19227
  var localTime = time - this.start;
19220
19228
  var duration = this.duration;
19221
- if (localTime - duration > 0.001) {
19229
+ if (localTime - duration > 0) {
19222
19230
  if (this.endBehavior === EndBehavior.restart) {
19223
19231
  localTime = localTime % duration;
19224
19232
  } else if (this.endBehavior === EndBehavior.freeze) {
@@ -19347,7 +19355,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
19347
19355
  var ended = false;
19348
19356
  var started = false;
19349
19357
  var boundObject = this.track.binding;
19350
- if (localTime > clip.start + clip.duration + 0.001 && clip.endBehavior === EndBehavior.destroy) {
19358
+ if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
19351
19359
  if (_instanceof1(boundObject, VFXItem) && VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
19352
19360
  weight = 1.0;
19353
19361
  } else {
@@ -20577,6 +20585,12 @@ var EffectComponent = /*#__PURE__*/ function(RendererComponent) {
20577
20585
  _proto.onStart = function onStart() {
20578
20586
  this.item.getHitTestParams = this.getHitTestParams;
20579
20587
  };
20588
+ _proto.onUpdate = function onUpdate(dt) {
20589
+ var time = this.item.time;
20590
+ var _this_material_getVector4;
20591
+ var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
20592
+ this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
20593
+ };
20580
20594
  _proto.render = function render(renderer) {
20581
20595
  if (renderer.renderingData.currentFrame.globalUniforms) {
20582
20596
  renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
@@ -20830,6 +20844,9 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20830
20844
  * 元素的变换包含位置、旋转、缩放。
20831
20845
  */ _this.transform = new Transform();
20832
20846
  /**
20847
+ * 元素动画的当前时间
20848
+ */ _this.time = 0;
20849
+ /**
20833
20850
  * 元素动画的持续时间
20834
20851
  */ _this.duration = 0;
20835
20852
  /**
@@ -28084,7 +28101,7 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
28084
28101
  registerPlugin("particle", ParticleLoader, VFXItem, true);
28085
28102
  registerPlugin("cal", CalculateLoader, VFXItem, true);
28086
28103
  registerPlugin("interact", InteractLoader, VFXItem, true);
28087
- var version = "2.1.0-alpha.2";
28104
+ var version = "2.1.0-alpha.3";
28088
28105
  logger.info("Core version: " + version + ".");
28089
28106
 
28090
28107
  export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSceneJSON, isSceneURL, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };