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