@galacean/effects-threejs 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.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin 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';
@@ -13627,25 +13627,25 @@ function _assert_this_initialized(self) {
13627
13627
  }
13628
13628
  var _proto = PlayableGraph.prototype;
13629
13629
  _proto.evaluate = function evaluate(dt) {
13630
- // 初始化节点状态
13631
- for(var _iterator = _create_for_of_iterator_helper_loose(this.playables), _step; !(_step = _iterator()).done;){
13632
- var playable = _step.value;
13633
- this.updatePlayableTime(playable, dt);
13634
- }
13635
13630
  // 初始化输出节点状态
13636
- for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13637
- var playableOutput = _step1.value;
13631
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.playableOutputs), _step; !(_step = _iterator()).done;){
13632
+ var playableOutput = _step.value;
13638
13633
  playableOutput.context.deltaTime = dt;
13639
13634
  }
13640
13635
  // 执行生命周期函数
13641
- for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13642
- var playableOutput1 = _step2.value;
13636
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step1; !(_step1 = _iterator1()).done;){
13637
+ var playableOutput1 = _step1.value;
13643
13638
  this.prepareFrameWithRoot(playableOutput1);
13644
13639
  }
13645
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step3; !(_step3 = _iterator3()).done;){
13646
- var playableOutput2 = _step3.value;
13640
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(this.playableOutputs), _step2; !(_step2 = _iterator2()).done;){
13641
+ var playableOutput2 = _step2.value;
13647
13642
  this.processFrameWithRoot(playableOutput2);
13648
13643
  }
13644
+ // 更新节点时间
13645
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
13646
+ var playable = _step3.value;
13647
+ this.updatePlayableTime(playable, dt);
13648
+ }
13649
13649
  };
13650
13650
  _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
13651
13651
  destination.connectInput(destinationInputPort, source, sourceOutputPort);
@@ -13668,11 +13668,7 @@ function _assert_this_initialized(self) {
13668
13668
  if (playable.getPlayState() !== 0) {
13669
13669
  return;
13670
13670
  }
13671
- if (playable.overrideTimeNextEvaluation) {
13672
- playable.overrideTimeNextEvaluation = false;
13673
- } else {
13674
- playable.setTime(playable.getTime() + deltaTime);
13675
- }
13671
+ playable.setTime(playable.getTime() + deltaTime);
13676
13672
  };
13677
13673
  return PlayableGraph;
13678
13674
  }();
@@ -13684,7 +13680,6 @@ function _assert_this_initialized(self) {
13684
13680
  if (inputCount === void 0) inputCount = 0;
13685
13681
  this.onPlayablePlayFlag = true;
13686
13682
  this.onPlayablePauseFlag = false;
13687
- this.overrideTimeNextEvaluation = false;
13688
13683
  this.destroyed = false;
13689
13684
  this.inputs = [];
13690
13685
  this.inputOuputPorts = [];
@@ -13773,7 +13768,6 @@ function _assert_this_initialized(self) {
13773
13768
  };
13774
13769
  _proto.setTime = function setTime(time) {
13775
13770
  this.time = time;
13776
- this.overrideTimeNextEvaluation = true;
13777
13771
  };
13778
13772
  _proto.getTime = function getTime() {
13779
13773
  return this.time;
@@ -16576,8 +16570,9 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16576
16570
  };
16577
16571
  _proto.onUpdate = function onUpdate(dt) {
16578
16572
  var time = this.particleMesh.time;
16579
- this.particleMesh.mesh.material.setVector4("uParams", new Vector4(time, this.item.duration, 0, 0));
16580
- this.particleMesh.onUpdate(dt);
16573
+ var _this_particleMesh_mesh_material_getVector4;
16574
+ var uParams = (_this_particleMesh_mesh_material_getVector4 = this.particleMesh.mesh.material.getVector4("uParams")) != null ? _this_particleMesh_mesh_material_getVector4 : new Vector4();
16575
+ this.particleMesh.mesh.material.setVector4("uParams", uParams.set(time, this.item.duration, 0, 0));
16581
16576
  };
16582
16577
  _proto.render = function render(renderer) {
16583
16578
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
@@ -16592,7 +16587,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
16592
16587
  };
16593
16588
  _proto.updateTime = function updateTime(now, delta) {
16594
16589
  this.particleMesh.time = now;
16595
- // this.particleMesh.onUpdate(delta);
16590
+ this.particleMesh.onUpdate(delta);
16596
16591
  if (this.trailMesh) {
16597
16592
  this.trailMesh.time = now;
16598
16593
  this.trailMesh.onUpdate(delta);
@@ -16886,7 +16881,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16886
16881
  break;
16887
16882
  }
16888
16883
  var burst = bursts[j];
16889
- var opts = burst.getGeneratorOptions(timePassed, lifetime);
16884
+ var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
16890
16885
  if (opts) {
16891
16886
  var originVec = [
16892
16887
  0,
@@ -16895,6 +16890,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16895
16890
  ];
16896
16891
  var offsets = emission.burstOffsets[j];
16897
16892
  var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
16893
+ if (burst.once) {
16894
+ this.removeBurst(j);
16895
+ }
16898
16896
  for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
16899
16897
  var _p_transform;
16900
16898
  if (shouldSkipGenerate()) {
@@ -17699,12 +17697,10 @@ var particleUniformTypeMap = {
17699
17697
  var ParticleMesh = /*#__PURE__*/ function() {
17700
17698
  function ParticleMesh(engine, props) {
17701
17699
  this.particleCount = 0;
17702
- this.cachedVelocity = new Vector3();
17703
17700
  this.cachedRotationVector3 = new Vector3();
17704
17701
  this.cachedRotationMatrix = new Matrix3();
17705
17702
  this.cachedLinearMove = new Vector3();
17706
17703
  this.tempMatrix3 = new Matrix3();
17707
- this.tempVector3 = new Vector3();
17708
17704
  this.VERT_MAX_KEY_FRAME_COUNT = 0;
17709
17705
  var _engine_renderer;
17710
17706
  var env = ((_engine_renderer = engine.renderer) != null ? _engine_renderer : {}).env;
@@ -18100,72 +18096,10 @@ var ParticleMesh = /*#__PURE__*/ function() {
18100
18096
  };
18101
18097
  _proto.onUpdate = function onUpdate(dt) {
18102
18098
  var aPosArray = this.geometry.getAttributeData("aPos"); // vector3
18103
- var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
18104
- var aOffsetArray = this.geometry.getAttributeData("aOffset");
18105
- var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
18106
- var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18107
- // const uParams = this.mesh.material.getVector4('uParams');
18108
- // if (!uParams) {
18109
- // return;
18110
- // }
18111
- var localTime = this.time;
18112
18099
  var particleCount = Math.ceil(aPosArray.length / 12);
18113
- // calculate particle translation
18114
- var aTranslationArray = this.geometry.getAttributeData("aTranslation");
18115
- if (aTranslationArray.length < particleCount * 3) {
18116
- aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
18117
- }
18118
- var velocity = this.cachedVelocity;
18119
- for(var i = 0; i < particleCount; i++){
18120
- var velOffset = i * 12 + 3;
18121
- velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
18122
- this.calculateTranslation(velocity, aOffsetArray[i * 4 + 2], localTime, aOffsetArray[i * 4 + 3]);
18123
- var aTranslationOffset = i * 3;
18124
- if (aOffsetArray[i * 4 + 2] < localTime) {
18125
- var translation = velocity.multiply(dt / 1000);
18126
- aTranslationArray[aTranslationOffset] += translation.x;
18127
- aTranslationArray[aTranslationOffset + 1] += translation.y;
18128
- aTranslationArray[aTranslationOffset + 2] += translation.z;
18129
- }
18130
- }
18131
- this.geometry.setAttributeData("aTranslation", aTranslationArray);
18132
- // calculate particle rotation
18133
- var aRotationArray = this.geometry.getAttributeData("aRotation0");
18134
- if (aRotationArray.length < particleCount * 9) {
18135
- aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
18136
- }
18137
- for(var i1 = 0; i1 < particleCount; i1++){
18138
- var time = localTime - aOffsetArray[i1 * 4 + 2];
18139
- var duration = aOffsetArray[i1 * 4 + 3];
18140
- var life = clamp$1(time / duration, 0.0, 1.0);
18141
- var aRotOffset = i1 * 8;
18142
- var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
18143
- var aSeed = aSeedArray[i1 * 8 + 3];
18144
- var aRotation = this.transformFromRotation(aRot, life, duration, aSeed, this.cachedRotationMatrix);
18145
- var aRotationOffset = i1 * 9;
18146
- var matrixArray = aRotation.toArray();
18147
- aRotationArray.set(matrixArray, aRotationOffset);
18148
- }
18149
- this.geometry.setAttributeData("aRotation0", aRotationArray);
18150
- // calculate linear movement
18151
- var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
18152
- if (aLinearMoveArray.length < particleCount * 3) {
18153
- aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
18154
- }
18155
- var linearMove = this.cachedLinearMove;
18156
- for(var i2 = 0; i2 < particleCount; i2++){
18157
- var time1 = localTime - aOffsetArray[i2 * 4 + 2];
18158
- var duration1 = aOffsetArray[i2 * 4 + 3];
18159
- // const life = math.clamp(time / duration, 0.0, 1.0);
18160
- var aSeed1 = aSeedArray[i2 * 8 + 3];
18161
- linearMove.setZero();
18162
- this.calLinearMov(time1, duration1, aSeed1, linearMove);
18163
- var aLinearMoveOffset = i2 * 3;
18164
- aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
18165
- aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
18166
- aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
18167
- }
18168
- this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
18100
+ this.applyTranslation(particleCount, dt);
18101
+ this.applyRotation(particleCount, dt);
18102
+ this.applyLinearMove(particleCount, dt);
18169
18103
  };
18170
18104
  _proto.minusTime = function minusTime(time) {
18171
18105
  var aOffset = this.geometry.getAttributeData("aOffset");
@@ -18175,153 +18109,6 @@ var ParticleMesh = /*#__PURE__*/ function() {
18175
18109
  this.geometry.setAttributeData("aOffset", aOffset);
18176
18110
  this.time -= time;
18177
18111
  };
18178
- _proto.calculateTranslation = function calculateTranslation(velocity, t0, t1, duration) {
18179
- var uAcceleration = this.mesh.material.getVector4("uAcceleration");
18180
- var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
18181
- if (!uAcceleration || !uGravityModifierValue) {
18182
- return velocity;
18183
- }
18184
- var dt = t1 - t0; // 相对delay的时间
18185
- var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
18186
- var acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
18187
- // speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
18188
- if (this.speedOverLifetime) {
18189
- // dt / dur 归一化
18190
- var speed = this.speedOverLifetime.getValue(dt / duration);
18191
- return velocity.multiply(speed).add(acc);
18192
- }
18193
- return velocity.add(acc);
18194
- };
18195
- _proto.transformFromRotation = function transformFromRotation(rot, life, dur, aSeed, result) {
18196
- var rotation = rot;
18197
- if (!this.rotationOverLifetime) {
18198
- return result.setZero();
18199
- }
18200
- if (this.rotationOverLifetime.asRotation) {
18201
- // Adjust rotation based on the specified lifetime components
18202
- if (this.rotationOverLifetime.x) {
18203
- if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18204
- rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
18205
- } else {
18206
- rotation.x += this.rotationOverLifetime.x.getValue(life);
18207
- }
18208
- }
18209
- if (this.rotationOverLifetime.y) {
18210
- if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18211
- rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
18212
- } else {
18213
- rotation.y += this.rotationOverLifetime.y.getValue(life);
18214
- }
18215
- }
18216
- if (this.rotationOverLifetime.z) {
18217
- if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18218
- rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
18219
- } else {
18220
- rotation.z += this.rotationOverLifetime.z.getValue(life);
18221
- }
18222
- }
18223
- } else {
18224
- // Adjust rotation based on the specified lifetime components
18225
- if (this.rotationOverLifetime.x) {
18226
- if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18227
- rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * dur;
18228
- } else {
18229
- rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, dur) * dur;
18230
- }
18231
- }
18232
- if (this.rotationOverLifetime.y) {
18233
- if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18234
- rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * dur;
18235
- } else {
18236
- rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, dur) * dur;
18237
- }
18238
- }
18239
- if (this.rotationOverLifetime.z) {
18240
- if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18241
- rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * dur;
18242
- } else {
18243
- rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, dur) * dur;
18244
- }
18245
- }
18246
- }
18247
- // If the rotation vector is zero, return the identity matrix
18248
- if (rotation.dot(rotation) === 0.0) {
18249
- return result.identity();
18250
- }
18251
- // Return the rotation matrix derived from the rotation vector
18252
- return this.mat3FromRotation(rotation, result);
18253
- };
18254
- _proto.mat3FromRotation = function mat3FromRotation(rotation, result) {
18255
- var d2r = Math.PI / 180;
18256
- var rotationXD2r = rotation.x * d2r;
18257
- var rotationYD2r = rotation.y * d2r;
18258
- var rotationZD2r = rotation.z * d2r;
18259
- var sinRX = Math.sin(rotationXD2r);
18260
- var sinRY = Math.sin(rotationYD2r);
18261
- var sinRZ = Math.sin(rotationZD2r);
18262
- var cosRX = Math.cos(rotationXD2r);
18263
- var cosRY = Math.cos(rotationYD2r);
18264
- var cosRZ = Math.cos(rotationZD2r);
18265
- // rotZ * rotY * rotX
18266
- result.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
18267
- result.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
18268
- result.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
18269
- return result;
18270
- };
18271
- _proto.calLinearMov = function calLinearMov(time, duration, aSeed, result) {
18272
- var mov = result;
18273
- var lifetime = time / duration;
18274
- if (!this.linearVelOverLifetime || !this.linearVelOverLifetime.enabled) {
18275
- return mov;
18276
- }
18277
- if (this.linearVelOverLifetime.asMovement) {
18278
- if (this.linearVelOverLifetime.x) {
18279
- if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18280
- mov.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
18281
- } else {
18282
- mov.x = this.linearVelOverLifetime.x.getValue(lifetime);
18283
- }
18284
- }
18285
- if (this.linearVelOverLifetime.y) {
18286
- if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18287
- mov.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
18288
- } else {
18289
- mov.y = this.linearVelOverLifetime.y.getValue(lifetime);
18290
- }
18291
- }
18292
- if (this.linearVelOverLifetime.z) {
18293
- if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18294
- mov.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
18295
- } else {
18296
- mov.z = this.linearVelOverLifetime.z.getValue(lifetime);
18297
- }
18298
- }
18299
- } else {
18300
- // Adjust rotation based on the specified lifetime components
18301
- if (this.linearVelOverLifetime.x) {
18302
- if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18303
- mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
18304
- } else {
18305
- mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
18306
- }
18307
- }
18308
- if (this.linearVelOverLifetime.y) {
18309
- if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18310
- mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
18311
- } else {
18312
- mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
18313
- }
18314
- }
18315
- if (this.linearVelOverLifetime.z) {
18316
- if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18317
- mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
18318
- } else {
18319
- mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
18320
- }
18321
- }
18322
- }
18323
- return mov;
18324
- };
18325
18112
  _proto.removePoint = function removePoint(index) {
18326
18113
  if (index < this.particleCount) {
18327
18114
  this.geometry.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
@@ -18455,6 +18242,221 @@ var ParticleMesh = /*#__PURE__*/ function() {
18455
18242
  geometry.setDrawCount(this.particleCount * 6);
18456
18243
  }
18457
18244
  };
18245
+ _proto.applyTranslation = function applyTranslation(particleCount, deltaTime) {
18246
+ var localTime = this.time;
18247
+ var aTranslationArray = this.geometry.getAttributeData("aTranslation");
18248
+ var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
18249
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18250
+ if (aTranslationArray.length < particleCount * 3) {
18251
+ aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
18252
+ }
18253
+ // const velocity = this.cachedVelocity;
18254
+ var velocityX = 0;
18255
+ var velocityY = 0;
18256
+ var velocityZ = 0;
18257
+ var uAcceleration = this.mesh.material.getVector4("uAcceleration");
18258
+ var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
18259
+ for(var i = 0; i < particleCount; i++){
18260
+ var velOffset = i * 12 + 3;
18261
+ velocityX = aVelArray[velOffset];
18262
+ velocityY = aVelArray[velOffset + 1];
18263
+ velocityZ = aVelArray[velOffset + 2];
18264
+ // velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
18265
+ var dt = localTime - aOffsetArray[i * 4 + 2]; // 相对delay的时间
18266
+ var duration = aOffsetArray[i * 4 + 3];
18267
+ if (uAcceleration && uGravityModifierValue) {
18268
+ var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
18269
+ // const acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
18270
+ var accX = uAcceleration.x * d;
18271
+ var accY = uAcceleration.y * d;
18272
+ var accZ = uAcceleration.z * d;
18273
+ // speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
18274
+ if (this.speedOverLifetime) {
18275
+ // dt / dur 归一化
18276
+ var speed = this.speedOverLifetime.getValue(dt / duration);
18277
+ velocityX = velocityX * speed + accX;
18278
+ velocityY = velocityY * speed + accY;
18279
+ velocityZ = velocityZ * speed + accZ;
18280
+ // velocity.multiply(speed).add(acc);
18281
+ } else {
18282
+ velocityX = velocityX + accX;
18283
+ velocityY = velocityY + accY;
18284
+ velocityZ = velocityZ + accZ;
18285
+ // velocity.add(acc);
18286
+ }
18287
+ }
18288
+ var aTranslationOffset = i * 3;
18289
+ if (aOffsetArray[i * 4 + 2] < localTime) {
18290
+ // const translation = velocity.multiply(deltaTime / 1000);
18291
+ aTranslationArray[aTranslationOffset] += velocityX * (deltaTime / 1000);
18292
+ aTranslationArray[aTranslationOffset + 1] += velocityY * (deltaTime / 1000);
18293
+ aTranslationArray[aTranslationOffset + 2] += velocityZ * (deltaTime / 1000);
18294
+ }
18295
+ }
18296
+ this.geometry.setAttributeData("aTranslation", aTranslationArray);
18297
+ };
18298
+ _proto.applyRotation = function applyRotation(particleCount, deltaTime) {
18299
+ var aRotationArray = this.geometry.getAttributeData("aRotation0");
18300
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18301
+ var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
18302
+ var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18303
+ var localTime = this.time;
18304
+ var aRotationMatrix = this.cachedRotationMatrix;
18305
+ if (aRotationArray.length < particleCount * 9) {
18306
+ aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
18307
+ }
18308
+ for(var i = 0; i < particleCount; i++){
18309
+ var time = localTime - aOffsetArray[i * 4 + 2];
18310
+ var duration = aOffsetArray[i * 4 + 3];
18311
+ var life = clamp$1(time / duration, 0.0, 1.0);
18312
+ var aRotOffset = i * 8;
18313
+ var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
18314
+ var aSeed = aSeedArray[i * 8 + 3];
18315
+ var rotation = aRot;
18316
+ if (!this.rotationOverLifetime) {
18317
+ aRotationMatrix.setZero();
18318
+ } else if (this.rotationOverLifetime.asRotation) {
18319
+ // Adjust rotation based on the specified lifetime components
18320
+ if (this.rotationOverLifetime.x) {
18321
+ if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18322
+ rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
18323
+ } else {
18324
+ rotation.x += this.rotationOverLifetime.x.getValue(life);
18325
+ }
18326
+ }
18327
+ if (this.rotationOverLifetime.y) {
18328
+ if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18329
+ rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
18330
+ } else {
18331
+ rotation.y += this.rotationOverLifetime.y.getValue(life);
18332
+ }
18333
+ }
18334
+ if (this.rotationOverLifetime.z) {
18335
+ if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18336
+ rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
18337
+ } else {
18338
+ rotation.z += this.rotationOverLifetime.z.getValue(life);
18339
+ }
18340
+ }
18341
+ } else {
18342
+ // Adjust rotation based on the specified lifetime components
18343
+ if (this.rotationOverLifetime.x) {
18344
+ if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
18345
+ rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * duration;
18346
+ } else {
18347
+ rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, duration) * duration;
18348
+ }
18349
+ }
18350
+ if (this.rotationOverLifetime.y) {
18351
+ if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
18352
+ rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * duration;
18353
+ } else {
18354
+ rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, duration) * duration;
18355
+ }
18356
+ }
18357
+ if (this.rotationOverLifetime.z) {
18358
+ if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
18359
+ rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * duration;
18360
+ } else {
18361
+ rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, duration) * duration;
18362
+ }
18363
+ }
18364
+ }
18365
+ // If the rotation vector is zero, return the identity matrix
18366
+ if (rotation.dot(rotation) === 0.0) {
18367
+ aRotationMatrix.identity();
18368
+ }
18369
+ var d2r = Math.PI / 180;
18370
+ var rotationXD2r = rotation.x * d2r;
18371
+ var rotationYD2r = rotation.y * d2r;
18372
+ var rotationZD2r = rotation.z * d2r;
18373
+ var sinRX = Math.sin(rotationXD2r);
18374
+ var sinRY = Math.sin(rotationYD2r);
18375
+ var sinRZ = Math.sin(rotationZD2r);
18376
+ var cosRX = Math.cos(rotationXD2r);
18377
+ var cosRY = Math.cos(rotationYD2r);
18378
+ var cosRZ = Math.cos(rotationZD2r);
18379
+ // rotZ * rotY * rotX
18380
+ aRotationMatrix.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
18381
+ aRotationMatrix.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
18382
+ aRotationMatrix.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
18383
+ var aRotationOffset = i * 9;
18384
+ var matrixArray = aRotationMatrix.elements;
18385
+ aRotationArray.set(matrixArray, aRotationOffset);
18386
+ }
18387
+ this.geometry.setAttributeData("aRotation0", aRotationArray);
18388
+ };
18389
+ _proto.applyLinearMove = function applyLinearMove(particleCount, deltaTime) {
18390
+ var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
18391
+ var aOffsetArray = this.geometry.getAttributeData("aOffset");
18392
+ var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
18393
+ var localTime = this.time;
18394
+ if (aLinearMoveArray.length < particleCount * 3) {
18395
+ aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
18396
+ }
18397
+ var linearMove = this.cachedLinearMove;
18398
+ if (this.linearVelOverLifetime && this.linearVelOverLifetime.enabled) {
18399
+ for(var i = 0; i < particleCount; i++){
18400
+ var time = localTime - aOffsetArray[i * 4 + 2];
18401
+ var duration = aOffsetArray[i * 4 + 3];
18402
+ // const life = math.clamp(time / duration, 0.0, 1.0);
18403
+ var lifetime = time / duration;
18404
+ var aSeed = aSeedArray[i * 8 + 3];
18405
+ linearMove.setZero();
18406
+ if (this.linearVelOverLifetime.asMovement) {
18407
+ if (this.linearVelOverLifetime.x) {
18408
+ if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18409
+ linearMove.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
18410
+ } else {
18411
+ linearMove.x = this.linearVelOverLifetime.x.getValue(lifetime);
18412
+ }
18413
+ }
18414
+ if (this.linearVelOverLifetime.y) {
18415
+ if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18416
+ linearMove.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
18417
+ } else {
18418
+ linearMove.y = this.linearVelOverLifetime.y.getValue(lifetime);
18419
+ }
18420
+ }
18421
+ if (this.linearVelOverLifetime.z) {
18422
+ if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18423
+ linearMove.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
18424
+ } else {
18425
+ linearMove.z = this.linearVelOverLifetime.z.getValue(lifetime);
18426
+ }
18427
+ }
18428
+ } else {
18429
+ // Adjust rotation based on the specified lifetime components
18430
+ if (this.linearVelOverLifetime.x) {
18431
+ if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
18432
+ linearMove.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
18433
+ } else {
18434
+ linearMove.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
18435
+ }
18436
+ }
18437
+ if (this.linearVelOverLifetime.y) {
18438
+ if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
18439
+ linearMove.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
18440
+ } else {
18441
+ linearMove.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
18442
+ }
18443
+ }
18444
+ if (this.linearVelOverLifetime.z) {
18445
+ if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
18446
+ linearMove.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
18447
+ } else {
18448
+ linearMove.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
18449
+ }
18450
+ }
18451
+ }
18452
+ var aLinearMoveOffset = i * 3;
18453
+ aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
18454
+ aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
18455
+ aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
18456
+ }
18457
+ }
18458
+ this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
18459
+ };
18458
18460
  _proto.expandArray = function expandArray(array, newSize) {
18459
18461
  var newArr = new Float32Array(newSize);
18460
18462
  newArr.set(array);
@@ -19091,7 +19093,13 @@ exports.TransformPlayableAsset = __decorate([
19091
19093
  return Playable.apply(this, arguments);
19092
19094
  }
19093
19095
  var _proto = ActivationPlayable.prototype;
19094
- _proto.processFrame = function processFrame(context) {};
19096
+ _proto.processFrame = function processFrame(context) {
19097
+ var vfxItem = context.output.getUserData();
19098
+ if (!_instanceof1(vfxItem, exports.VFXItem)) {
19099
+ return;
19100
+ }
19101
+ vfxItem.time = this.time;
19102
+ };
19095
19103
  return ActivationPlayable;
19096
19104
  }(Playable);
19097
19105
  exports.ActivationPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
@@ -19244,7 +19252,7 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
19244
19252
  _proto.toLocalTime = function toLocalTime(time) {
19245
19253
  var localTime = time - this.start;
19246
19254
  var duration = this.duration;
19247
- if (localTime - duration > 0.001) {
19255
+ if (localTime - duration > 0) {
19248
19256
  if (this.endBehavior === EndBehavior.restart) {
19249
19257
  localTime = localTime % duration;
19250
19258
  } else if (this.endBehavior === EndBehavior.freeze) {
@@ -19373,7 +19381,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
19373
19381
  var ended = false;
19374
19382
  var started = false;
19375
19383
  var boundObject = this.track.binding;
19376
- if (localTime > clip.start + clip.duration + 0.001 && clip.endBehavior === EndBehavior.destroy) {
19384
+ if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
19377
19385
  if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
19378
19386
  weight = 1.0;
19379
19387
  } else {
@@ -20603,6 +20611,12 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
20603
20611
  _proto.onStart = function onStart() {
20604
20612
  this.item.getHitTestParams = this.getHitTestParams;
20605
20613
  };
20614
+ _proto.onUpdate = function onUpdate(dt) {
20615
+ var time = this.item.time;
20616
+ var _this_material_getVector4;
20617
+ var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
20618
+ this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
20619
+ };
20606
20620
  _proto.render = function render(renderer) {
20607
20621
  if (renderer.renderingData.currentFrame.globalUniforms) {
20608
20622
  renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
@@ -20856,6 +20870,9 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
20856
20870
  * 元素的变换包含位置、旋转、缩放。
20857
20871
  */ _this.transform = new Transform();
20858
20872
  /**
20873
+ * 元素动画的当前时间
20874
+ */ _this.time = 0;
20875
+ /**
20859
20876
  * 元素动画的持续时间
20860
20877
  */ _this.duration = 0;
20861
20878
  /**
@@ -28110,7 +28127,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
28110
28127
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
28111
28128
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
28112
28129
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
28113
- var version$1 = "2.1.0-alpha.2";
28130
+ var version$1 = "2.1.0-alpha.3";
28114
28131
  logger.info("Core version: " + version$1 + ".");
28115
28132
 
28116
28133
  var _obj;
@@ -29791,7 +29808,7 @@ setMaxSpriteMeshItemCount(8);
29791
29808
  */ Mesh.create = function(engine, props) {
29792
29809
  return new ThreeMesh(engine, props);
29793
29810
  };
29794
- var version = "2.1.0-alpha.2";
29811
+ var version = "2.1.0-alpha.3";
29795
29812
  logger.info("THREEJS plugin version: " + version + ".");
29796
29813
 
29797
29814
  exports.AbstractPlugin = AbstractPlugin;