@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.
@@ -23,6 +23,7 @@ export declare class EffectComponent extends RendererComponent {
23
23
  private hitTestGeometry;
24
24
  constructor(engine: Engine);
25
25
  onStart(): void;
26
+ onUpdate(dt: number): void;
26
27
  render(renderer: Renderer): void;
27
28
  /**
28
29
  * 设置当前 Mesh 的材质
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.2
6
+ * Version: v2.1.0-alpha.3
7
7
  */
8
8
 
9
9
  'use strict';
@@ -13605,25 +13605,25 @@ function _assert_this_initialized(self) {
13605
13605
  }
13606
13606
  var _proto = PlayableGraph.prototype;
13607
13607
  _proto.evaluate = function evaluate(dt) {
13608
- // 初始化节点状态
13609
- for(var _iterator = _create_for_of_iterator_helper_loose(this.playables), _step; !(_step = _iterator()).done;){
13610
- var playable = _step.value;
13611
- this.updatePlayableTime(playable, dt);
13612
- }
13613
13608
  // 初始化输出节点状态
13614
- for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13615
- var playableOutput = _step1.value;
13609
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.playableOutputs), _step; !(_step = _iterator()).done;){
13610
+ var playableOutput = _step.value;
13616
13611
  playableOutput.context.deltaTime = dt;
13617
13612
  }
13618
13613
  // 执行生命周期函数
13619
- for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13620
- var playableOutput1 = _step2.value;
13614
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13615
+ var playableOutput1 = _step1.value;
13621
13616
  this.prepareFrameWithRoot(playableOutput1);
13622
13617
  }
13623
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step3; !(_step3 = _iterator3()).done;){
13624
- var playableOutput2 = _step3.value;
13618
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13619
+ var playableOutput2 = _step2.value;
13625
13620
  this.processFrameWithRoot(playableOutput2);
13626
13621
  }
13622
+ // 更新节点时间
13623
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
13624
+ var playable = _step3.value;
13625
+ this.updatePlayableTime(playable, dt);
13626
+ }
13627
13627
  };
13628
13628
  _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
13629
13629
  destination.connectInput(destinationInputPort, source, sourceOutputPort);
@@ -13646,11 +13646,7 @@ function _assert_this_initialized(self) {
13646
13646
  if (playable.getPlayState() !== 0) {
13647
13647
  return;
13648
13648
  }
13649
- if (playable.overrideTimeNextEvaluation) {
13650
- playable.overrideTimeNextEvaluation = false;
13651
- } else {
13652
- playable.setTime(playable.getTime() + deltaTime);
13653
- }
13649
+ playable.setTime(playable.getTime() + deltaTime);
13654
13650
  };
13655
13651
  return PlayableGraph;
13656
13652
  }();
@@ -13662,7 +13658,6 @@ function _assert_this_initialized(self) {
13662
13658
  if (inputCount === void 0) inputCount = 0;
13663
13659
  this.onPlayablePlayFlag = true;
13664
13660
  this.onPlayablePauseFlag = false;
13665
- this.overrideTimeNextEvaluation = false;
13666
13661
  this.destroyed = false;
13667
13662
  this.inputs = [];
13668
13663
  this.inputOuputPorts = [];
@@ -13751,7 +13746,6 @@ function _assert_this_initialized(self) {
13751
13746
  };
13752
13747
  _proto.setTime = function setTime(time) {
13753
13748
  this.time = time;
13754
- this.overrideTimeNextEvaluation = true;
13755
13749
  };
13756
13750
  _proto.getTime = function getTime() {
13757
13751
  return this.time;
@@ -16554,8 +16548,9 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16554
16548
  };
16555
16549
  _proto.onUpdate = function onUpdate(dt) {
16556
16550
  var time = this.particleMesh.time;
16557
- this.particleMesh.mesh.material.setVector4("uParams", new Vector4(time, this.item.duration, 0, 0));
16558
- this.particleMesh.onUpdate(dt);
16551
+ var _this_particleMesh_mesh_material_getVector4;
16552
+ var uParams = (_this_particleMesh_mesh_material_getVector4 = this.particleMesh.mesh.material.getVector4("uParams")) != null ? _this_particleMesh_mesh_material_getVector4 : new Vector4();
16553
+ this.particleMesh.mesh.material.setVector4("uParams", uParams.set(time, this.item.duration, 0, 0));
16559
16554
  };
16560
16555
  _proto.render = function render(renderer) {
16561
16556
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
@@ -16570,7 +16565,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16570
16565
  };
16571
16566
  _proto.updateTime = function updateTime(now, delta) {
16572
16567
  this.particleMesh.time = now;
16573
- // this.particleMesh.onUpdate(delta);
16568
+ this.particleMesh.onUpdate(delta);
16574
16569
  if (this.trailMesh) {
16575
16570
  this.trailMesh.time = now;
16576
16571
  this.trailMesh.onUpdate(delta);
@@ -16864,7 +16859,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16864
16859
  break;
16865
16860
  }
16866
16861
  var burst = bursts[j];
16867
- var opts = burst.getGeneratorOptions(timePassed, lifetime);
16862
+ var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
16868
16863
  if (opts) {
16869
16864
  var originVec = [
16870
16865
  0,
@@ -16873,6 +16868,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16873
16868
  ];
16874
16869
  var offsets = emission.burstOffsets[j];
16875
16870
  var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
16871
+ if (burst.once) {
16872
+ this.removeBurst(j);
16873
+ }
16876
16874
  for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
16877
16875
  var _p_transform;
16878
16876
  if (shouldSkipGenerate()) {
@@ -17677,12 +17675,10 @@ var particleUniformTypeMap = {
17677
17675
  var ParticleMesh = /*#__PURE__*/ function() {
17678
17676
  function ParticleMesh(engine, props) {
17679
17677
  this.particleCount = 0;
17680
- this.cachedVelocity = new Vector3();
17681
17678
  this.cachedRotationVector3 = new Vector3();
17682
17679
  this.cachedRotationMatrix = new Matrix3();
17683
17680
  this.cachedLinearMove = new Vector3();
17684
17681
  this.tempMatrix3 = new Matrix3();
17685
- this.tempVector3 = new Vector3();
17686
17682
  this.VERT_MAX_KEY_FRAME_COUNT = 0;
17687
17683
  var _engine_renderer;
17688
17684
  var env = ((_engine_renderer = engine.renderer) != null ? _engine_renderer : {}).env;
@@ -18078,72 +18074,10 @@ var ParticleMesh = /*#__PURE__*/ function() {
18078
18074
  };
18079
18075
  _proto.onUpdate = function onUpdate(dt) {
18080
18076
  var aPosArray = this.geometry.getAttributeData("aPos"); // vector3
18081
- var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
18082
- var aOffsetArray = this.geometry.getAttributeData("aOffset");
18083
- var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
18084
- var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18085
- // const uParams = this.mesh.material.getVector4('uParams');
18086
- // if (!uParams) {
18087
- // return;
18088
- // }
18089
- var localTime = this.time;
18090
18077
  var particleCount = Math.ceil(aPosArray.length / 12);
18091
- // calculate particle translation
18092
- var aTranslationArray = this.geometry.getAttributeData("aTranslation");
18093
- if (aTranslationArray.length < particleCount * 3) {
18094
- aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
18095
- }
18096
- var velocity = this.cachedVelocity;
18097
- for(var i = 0; i < particleCount; i++){
18098
- var velOffset = i * 12 + 3;
18099
- velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
18100
- this.calculateTranslation(velocity, aOffsetArray[i * 4 + 2], localTime, aOffsetArray[i * 4 + 3]);
18101
- var aTranslationOffset = i * 3;
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
- }
18108
- }
18109
- this.geometry.setAttributeData("aTranslation", aTranslationArray);
18110
- // calculate particle rotation
18111
- var aRotationArray = this.geometry.getAttributeData("aRotation0");
18112
- if (aRotationArray.length < particleCount * 9) {
18113
- aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
18114
- }
18115
- for(var i1 = 0; i1 < particleCount; i1++){
18116
- var time = localTime - aOffsetArray[i1 * 4 + 2];
18117
- var duration = aOffsetArray[i1 * 4 + 3];
18118
- var life = clamp$1(time / duration, 0.0, 1.0);
18119
- var aRotOffset = i1 * 8;
18120
- var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
18121
- var aSeed = aSeedArray[i1 * 8 + 3];
18122
- var aRotation = this.transformFromRotation(aRot, life, duration, aSeed, this.cachedRotationMatrix);
18123
- var aRotationOffset = i1 * 9;
18124
- var matrixArray = aRotation.toArray();
18125
- aRotationArray.set(matrixArray, aRotationOffset);
18126
- }
18127
- this.geometry.setAttributeData("aRotation0", aRotationArray);
18128
- // calculate linear movement
18129
- var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
18130
- if (aLinearMoveArray.length < particleCount * 3) {
18131
- aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
18132
- }
18133
- var linearMove = this.cachedLinearMove;
18134
- for(var i2 = 0; i2 < particleCount; i2++){
18135
- var time1 = localTime - aOffsetArray[i2 * 4 + 2];
18136
- var duration1 = aOffsetArray[i2 * 4 + 3];
18137
- // const life = math.clamp(time / duration, 0.0, 1.0);
18138
- var aSeed1 = aSeedArray[i2 * 8 + 3];
18139
- linearMove.setZero();
18140
- this.calLinearMov(time1, duration1, aSeed1, linearMove);
18141
- var aLinearMoveOffset = i2 * 3;
18142
- aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
18143
- aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
18144
- aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
18145
- }
18146
- this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
18078
+ this.applyTranslation(particleCount, dt);
18079
+ this.applyRotation(particleCount, dt);
18080
+ this.applyLinearMove(particleCount, dt);
18147
18081
  };
18148
18082
  _proto.minusTime = function minusTime(time) {
18149
18083
  var aOffset = this.geometry.getAttributeData("aOffset");
@@ -18153,153 +18087,6 @@ var ParticleMesh = /*#__PURE__*/ function() {
18153
18087
  this.geometry.setAttributeData("aOffset", aOffset);
18154
18088
  this.time -= time;
18155
18089
  };
18156
- _proto.calculateTranslation = function calculateTranslation(velocity, t0, t1, duration) {
18157
- var uAcceleration = this.mesh.material.getVector4("uAcceleration");
18158
- var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
18159
- if (!uAcceleration || !uGravityModifierValue) {
18160
- return velocity;
18161
- }
18162
- var dt = t1 - t0; // 相对delay的时间
18163
- var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
18164
- var acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
18165
- // speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
18166
- if (this.speedOverLifetime) {
18167
- // dt / dur 归一化
18168
- var speed = this.speedOverLifetime.getValue(dt / duration);
18169
- return velocity.multiply(speed).add(acc);
18170
- }
18171
- return velocity.add(acc);
18172
- };
18173
- _proto.transformFromRotation = function transformFromRotation(rot, life, dur, aSeed, result) {
18174
- var rotation = rot;
18175
- if (!this.rotationOverLifetime) {
18176
- return result.setZero();
18177
- }
18178
- if (this.rotationOverLifetime.asRotation) {
18179
- // Adjust rotation based on the specified lifetime components
18180
- if (this.rotationOverLifetime.x) {
18181
- if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18182
- rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
18183
- } else {
18184
- rotation.x += this.rotationOverLifetime.x.getValue(life);
18185
- }
18186
- }
18187
- if (this.rotationOverLifetime.y) {
18188
- if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18189
- rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
18190
- } else {
18191
- rotation.y += this.rotationOverLifetime.y.getValue(life);
18192
- }
18193
- }
18194
- if (this.rotationOverLifetime.z) {
18195
- if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18196
- rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
18197
- } else {
18198
- rotation.z += this.rotationOverLifetime.z.getValue(life);
18199
- }
18200
- }
18201
- } else {
18202
- // Adjust rotation based on the specified lifetime components
18203
- if (this.rotationOverLifetime.x) {
18204
- if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18205
- rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * dur;
18206
- } else {
18207
- rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, dur) * dur;
18208
- }
18209
- }
18210
- if (this.rotationOverLifetime.y) {
18211
- if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18212
- rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * dur;
18213
- } else {
18214
- rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, dur) * dur;
18215
- }
18216
- }
18217
- if (this.rotationOverLifetime.z) {
18218
- if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18219
- rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * dur;
18220
- } else {
18221
- rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, dur) * dur;
18222
- }
18223
- }
18224
- }
18225
- // If the rotation vector is zero, return the identity matrix
18226
- if (rotation.dot(rotation) === 0.0) {
18227
- return result.identity();
18228
- }
18229
- // Return the rotation matrix derived from the rotation vector
18230
- return this.mat3FromRotation(rotation, result);
18231
- };
18232
- _proto.mat3FromRotation = function mat3FromRotation(rotation, result) {
18233
- var d2r = Math.PI / 180;
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
18247
- return result;
18248
- };
18249
- _proto.calLinearMov = function calLinearMov(time, duration, aSeed, result) {
18250
- var mov = result;
18251
- var lifetime = time / duration;
18252
- if (!this.linearVelOverLifetime || !this.linearVelOverLifetime.enabled) {
18253
- return mov;
18254
- }
18255
- if (this.linearVelOverLifetime.asMovement) {
18256
- if (this.linearVelOverLifetime.x) {
18257
- if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18258
- mov.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
18259
- } else {
18260
- mov.x = this.linearVelOverLifetime.x.getValue(lifetime);
18261
- }
18262
- }
18263
- if (this.linearVelOverLifetime.y) {
18264
- if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18265
- mov.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
18266
- } else {
18267
- mov.y = this.linearVelOverLifetime.y.getValue(lifetime);
18268
- }
18269
- }
18270
- if (this.linearVelOverLifetime.z) {
18271
- if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18272
- mov.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
18273
- } else {
18274
- mov.z = this.linearVelOverLifetime.z.getValue(lifetime);
18275
- }
18276
- }
18277
- } else {
18278
- // Adjust rotation based on the specified lifetime components
18279
- if (this.linearVelOverLifetime.x) {
18280
- if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18281
- mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
18282
- } else {
18283
- mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
18284
- }
18285
- }
18286
- if (this.linearVelOverLifetime.y) {
18287
- if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18288
- mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
18289
- } else {
18290
- mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
18291
- }
18292
- }
18293
- if (this.linearVelOverLifetime.z) {
18294
- if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18295
- mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
18296
- } else {
18297
- mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
18298
- }
18299
- }
18300
- }
18301
- return mov;
18302
- };
18303
18090
  _proto.removePoint = function removePoint(index) {
18304
18091
  if (index < this.particleCount) {
18305
18092
  this.geometry.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
@@ -18433,6 +18220,221 @@ var ParticleMesh = /*#__PURE__*/ function() {
18433
18220
  geometry.setDrawCount(this.particleCount * 6);
18434
18221
  }
18435
18222
  };
18223
+ _proto.applyTranslation = function applyTranslation(particleCount, deltaTime) {
18224
+ var localTime = this.time;
18225
+ var aTranslationArray = this.geometry.getAttributeData("aTranslation");
18226
+ var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
18227
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18228
+ if (aTranslationArray.length < particleCount * 3) {
18229
+ aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
18230
+ }
18231
+ // const velocity = this.cachedVelocity;
18232
+ var velocityX = 0;
18233
+ var velocityY = 0;
18234
+ var velocityZ = 0;
18235
+ var uAcceleration = this.mesh.material.getVector4("uAcceleration");
18236
+ var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
18237
+ for(var i = 0; i < particleCount; i++){
18238
+ var velOffset = i * 12 + 3;
18239
+ velocityX = aVelArray[velOffset];
18240
+ velocityY = aVelArray[velOffset + 1];
18241
+ velocityZ = aVelArray[velOffset + 2];
18242
+ // velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
18243
+ var dt = localTime - aOffsetArray[i * 4 + 2]; // 相对delay的时间
18244
+ var duration = aOffsetArray[i * 4 + 3];
18245
+ if (uAcceleration && uGravityModifierValue) {
18246
+ var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
18247
+ // const acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
18248
+ var accX = uAcceleration.x * d;
18249
+ var accY = uAcceleration.y * d;
18250
+ var accZ = uAcceleration.z * d;
18251
+ // speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
18252
+ if (this.speedOverLifetime) {
18253
+ // dt / dur 归一化
18254
+ var speed = this.speedOverLifetime.getValue(dt / duration);
18255
+ velocityX = velocityX * speed + accX;
18256
+ velocityY = velocityY * speed + accY;
18257
+ velocityZ = velocityZ * speed + accZ;
18258
+ // velocity.multiply(speed).add(acc);
18259
+ } else {
18260
+ velocityX = velocityX + accX;
18261
+ velocityY = velocityY + accY;
18262
+ velocityZ = velocityZ + accZ;
18263
+ // velocity.add(acc);
18264
+ }
18265
+ }
18266
+ var aTranslationOffset = i * 3;
18267
+ if (aOffsetArray[i * 4 + 2] < localTime) {
18268
+ // const translation = velocity.multiply(deltaTime / 1000);
18269
+ aTranslationArray[aTranslationOffset] += velocityX * (deltaTime / 1000);
18270
+ aTranslationArray[aTranslationOffset + 1] += velocityY * (deltaTime / 1000);
18271
+ aTranslationArray[aTranslationOffset + 2] += velocityZ * (deltaTime / 1000);
18272
+ }
18273
+ }
18274
+ this.geometry.setAttributeData("aTranslation", aTranslationArray);
18275
+ };
18276
+ _proto.applyRotation = function applyRotation(particleCount, deltaTime) {
18277
+ var aRotationArray = this.geometry.getAttributeData("aRotation0");
18278
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18279
+ var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
18280
+ var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18281
+ var localTime = this.time;
18282
+ var aRotationMatrix = this.cachedRotationMatrix;
18283
+ if (aRotationArray.length < particleCount * 9) {
18284
+ aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
18285
+ }
18286
+ for(var i = 0; i < particleCount; i++){
18287
+ var time = localTime - aOffsetArray[i * 4 + 2];
18288
+ var duration = aOffsetArray[i * 4 + 3];
18289
+ var life = clamp$1(time / duration, 0.0, 1.0);
18290
+ var aRotOffset = i * 8;
18291
+ var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
18292
+ var aSeed = aSeedArray[i * 8 + 3];
18293
+ var rotation = aRot;
18294
+ if (!this.rotationOverLifetime) {
18295
+ aRotationMatrix.setZero();
18296
+ } else if (this.rotationOverLifetime.asRotation) {
18297
+ // Adjust rotation based on the specified lifetime components
18298
+ if (this.rotationOverLifetime.x) {
18299
+ if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18300
+ rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
18301
+ } else {
18302
+ rotation.x += this.rotationOverLifetime.x.getValue(life);
18303
+ }
18304
+ }
18305
+ if (this.rotationOverLifetime.y) {
18306
+ if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18307
+ rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
18308
+ } else {
18309
+ rotation.y += this.rotationOverLifetime.y.getValue(life);
18310
+ }
18311
+ }
18312
+ if (this.rotationOverLifetime.z) {
18313
+ if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18314
+ rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
18315
+ } else {
18316
+ rotation.z += this.rotationOverLifetime.z.getValue(life);
18317
+ }
18318
+ }
18319
+ } else {
18320
+ // Adjust rotation based on the specified lifetime components
18321
+ if (this.rotationOverLifetime.x) {
18322
+ if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18323
+ rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * duration;
18324
+ } else {
18325
+ rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, duration) * duration;
18326
+ }
18327
+ }
18328
+ if (this.rotationOverLifetime.y) {
18329
+ if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18330
+ rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * duration;
18331
+ } else {
18332
+ rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, duration) * duration;
18333
+ }
18334
+ }
18335
+ if (this.rotationOverLifetime.z) {
18336
+ if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18337
+ rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * duration;
18338
+ } else {
18339
+ rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, duration) * duration;
18340
+ }
18341
+ }
18342
+ }
18343
+ // If the rotation vector is zero, return the identity matrix
18344
+ if (rotation.dot(rotation) === 0.0) {
18345
+ aRotationMatrix.identity();
18346
+ }
18347
+ var d2r = Math.PI / 180;
18348
+ var rotationXD2r = rotation.x * d2r;
18349
+ var rotationYD2r = rotation.y * d2r;
18350
+ var rotationZD2r = rotation.z * d2r;
18351
+ var sinRX = Math.sin(rotationXD2r);
18352
+ var sinRY = Math.sin(rotationYD2r);
18353
+ var sinRZ = Math.sin(rotationZD2r);
18354
+ var cosRX = Math.cos(rotationXD2r);
18355
+ var cosRY = Math.cos(rotationYD2r);
18356
+ var cosRZ = Math.cos(rotationZD2r);
18357
+ // rotZ * rotY * rotX
18358
+ aRotationMatrix.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
18359
+ aRotationMatrix.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
18360
+ aRotationMatrix.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
18361
+ var aRotationOffset = i * 9;
18362
+ var matrixArray = aRotationMatrix.elements;
18363
+ aRotationArray.set(matrixArray, aRotationOffset);
18364
+ }
18365
+ this.geometry.setAttributeData("aRotation0", aRotationArray);
18366
+ };
18367
+ _proto.applyLinearMove = function applyLinearMove(particleCount, deltaTime) {
18368
+ var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
18369
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18370
+ var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18371
+ var localTime = this.time;
18372
+ if (aLinearMoveArray.length < particleCount * 3) {
18373
+ aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
18374
+ }
18375
+ var linearMove = this.cachedLinearMove;
18376
+ if (this.linearVelOverLifetime && this.linearVelOverLifetime.enabled) {
18377
+ for(var i = 0; i < particleCount; i++){
18378
+ var time = localTime - aOffsetArray[i * 4 + 2];
18379
+ var duration = aOffsetArray[i * 4 + 3];
18380
+ // const life = math.clamp(time / duration, 0.0, 1.0);
18381
+ var lifetime = time / duration;
18382
+ var aSeed = aSeedArray[i * 8 + 3];
18383
+ linearMove.setZero();
18384
+ if (this.linearVelOverLifetime.asMovement) {
18385
+ if (this.linearVelOverLifetime.x) {
18386
+ if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18387
+ linearMove.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
18388
+ } else {
18389
+ linearMove.x = this.linearVelOverLifetime.x.getValue(lifetime);
18390
+ }
18391
+ }
18392
+ if (this.linearVelOverLifetime.y) {
18393
+ if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18394
+ linearMove.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
18395
+ } else {
18396
+ linearMove.y = this.linearVelOverLifetime.y.getValue(lifetime);
18397
+ }
18398
+ }
18399
+ if (this.linearVelOverLifetime.z) {
18400
+ if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18401
+ linearMove.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
18402
+ } else {
18403
+ linearMove.z = this.linearVelOverLifetime.z.getValue(lifetime);
18404
+ }
18405
+ }
18406
+ } else {
18407
+ // Adjust rotation based on the specified lifetime components
18408
+ if (this.linearVelOverLifetime.x) {
18409
+ if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18410
+ linearMove.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
18411
+ } else {
18412
+ linearMove.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
18413
+ }
18414
+ }
18415
+ if (this.linearVelOverLifetime.y) {
18416
+ if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18417
+ linearMove.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
18418
+ } else {
18419
+ linearMove.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
18420
+ }
18421
+ }
18422
+ if (this.linearVelOverLifetime.z) {
18423
+ if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18424
+ linearMove.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
18425
+ } else {
18426
+ linearMove.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
18427
+ }
18428
+ }
18429
+ }
18430
+ var aLinearMoveOffset = i * 3;
18431
+ aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
18432
+ aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
18433
+ aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
18434
+ }
18435
+ }
18436
+ this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
18437
+ };
18436
18438
  _proto.expandArray = function expandArray(array, newSize) {
18437
18439
  var newArr = new Float32Array(newSize);
18438
18440
  newArr.set(array);
@@ -19069,7 +19071,13 @@ exports.TransformPlayableAsset = __decorate([
19069
19071
  return Playable.apply(this, arguments);
19070
19072
  }
19071
19073
  var _proto = ActivationPlayable.prototype;
19072
- _proto.processFrame = function processFrame(context) {};
19074
+ _proto.processFrame = function processFrame(context) {
19075
+ var vfxItem = context.output.getUserData();
19076
+ if (!_instanceof1(vfxItem, exports.VFXItem)) {
19077
+ return;
19078
+ }
19079
+ vfxItem.time = this.time;
19080
+ };
19073
19081
  return ActivationPlayable;
19074
19082
  }(Playable);
19075
19083
  exports.ActivationPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
@@ -19222,7 +19230,7 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
19222
19230
  _proto.toLocalTime = function toLocalTime(time) {
19223
19231
  var localTime = time - this.start;
19224
19232
  var duration = this.duration;
19225
- if (localTime - duration > 0.001) {
19233
+ if (localTime - duration > 0) {
19226
19234
  if (this.endBehavior === EndBehavior.restart) {
19227
19235
  localTime = localTime % duration;
19228
19236
  } else if (this.endBehavior === EndBehavior.freeze) {
@@ -19351,7 +19359,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
19351
19359
  var ended = false;
19352
19360
  var started = false;
19353
19361
  var boundObject = this.track.binding;
19354
- if (localTime > clip.start + clip.duration + 0.001 && clip.endBehavior === EndBehavior.destroy) {
19362
+ if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
19355
19363
  if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
19356
19364
  weight = 1.0;
19357
19365
  } else {
@@ -20581,6 +20589,12 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
20581
20589
  _proto.onStart = function onStart() {
20582
20590
  this.item.getHitTestParams = this.getHitTestParams;
20583
20591
  };
20592
+ _proto.onUpdate = function onUpdate(dt) {
20593
+ var time = this.item.time;
20594
+ var _this_material_getVector4;
20595
+ var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
20596
+ this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
20597
+ };
20584
20598
  _proto.render = function render(renderer) {
20585
20599
  if (renderer.renderingData.currentFrame.globalUniforms) {
20586
20600
  renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
@@ -20834,6 +20848,9 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
20834
20848
  * 元素的变换包含位置、旋转、缩放。
20835
20849
  */ _this.transform = new Transform();
20836
20850
  /**
20851
+ * 元素动画的当前时间
20852
+ */ _this.time = 0;
20853
+ /**
20837
20854
  * 元素动画的持续时间
20838
20855
  */ _this.duration = 0;
20839
20856
  /**
@@ -28088,7 +28105,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
28088
28105
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
28089
28106
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
28090
28107
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
28091
- var version = "2.1.0-alpha.2";
28108
+ var version = "2.1.0-alpha.3";
28092
28109
  logger.info("Core version: " + version + ".");
28093
28110
 
28094
28111
  exports.AbstractPlugin = AbstractPlugin;