@galacean/engine-core 2.0.0-alpha.29 → 2.0.0-alpha.30

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/module.js CHANGED
@@ -35135,30 +35135,48 @@ __decorate([
35135
35135
  }
35136
35136
  this._emitBySubBurst(middleTime, playTime, duration);
35137
35137
  } else {
35138
- this._emitBySubBurst(lastPlayTime, playTime, duration);
35138
+ if (lastPlayTime < duration) {
35139
+ this._emitBySubBurst(lastPlayTime, Math.min(playTime, duration), duration);
35140
+ }
35139
35141
  }
35140
35142
  };
35141
35143
  _proto._emitBySubBurst = function _emitBySubBurst(lastPlayTime, playTime, duration) {
35142
- var generator = this._generator;
35143
- var rand = this._burstRand;
35144
- var bursts = this.bursts;
35145
- // Calculate the relative time of the burst
35144
+ var _this = this, generator = _this._generator, rand = _this._burstRand, bursts = _this.bursts;
35146
35145
  var baseTime = Math.floor(lastPlayTime / duration) * duration;
35147
35146
  var startTime = lastPlayTime % duration;
35148
35147
  var endTime = startTime + (playTime - lastPlayTime);
35148
+ var pendingIndex = -1;
35149
35149
  var index = this._currentBurstIndex;
35150
35150
  for(var n = bursts.length; index < n; index++){
35151
35151
  var burst = bursts[index];
35152
35152
  var burstTime = burst.time;
35153
- if (burstTime > endTime) {
35154
- break;
35155
- }
35156
- if (burstTime >= startTime) {
35157
- var count = burst.count.evaluate(undefined, rand.random());
35158
- generator._emit(baseTime + burstTime, count);
35153
+ if (burstTime >= endTime) break;
35154
+ var cycles = burst.cycles, repeatInterval = burst.repeatInterval;
35155
+ if (cycles === 1) {
35156
+ if (burstTime >= startTime) {
35157
+ generator._emit(baseTime + burstTime, burst.count.evaluate(undefined, rand.random()));
35158
+ }
35159
+ } else {
35160
+ var maxCycles = cycles === Infinity ? Math.ceil((duration - burstTime) / repeatInterval) : cycles;
35161
+ // Absorb float drift: (startTime - burstTime) / repeatInterval may land at cycle + 1e-15
35162
+ // when it should be exactly cycle, and ceil would then skip ahead to cycle + 1.
35163
+ var tolerance = MathUtil.zeroTolerance;
35164
+ var lastCycle = Math.ceil((endTime - burstTime) / repeatInterval - tolerance) - 1;
35165
+ var first = Math.max(0, Math.ceil((startTime - burstTime) / repeatInterval - tolerance));
35166
+ var last = Math.min(maxCycles - 1, lastCycle);
35167
+ for(var c = first; c <= last; c++){
35168
+ var effectiveTime = burstTime + c * repeatInterval;
35169
+ if (effectiveTime >= duration) break;
35170
+ generator._emit(baseTime + effectiveTime, burst.count.evaluate(undefined, rand.random()));
35171
+ }
35172
+ // `_currentBurstIndex` caches next frame's scan start, so only the earliest unfinished
35173
+ // burst can be the entry point — skipping past it would drop its remaining cycles
35174
+ if (pendingIndex < 0 && lastCycle < maxCycles - 1) {
35175
+ pendingIndex = index;
35176
+ }
35159
35177
  }
35160
35178
  }
35161
- this._currentBurstIndex = index;
35179
+ this._currentBurstIndex = pendingIndex >= 0 ? pendingIndex : index;
35162
35180
  };
35163
35181
  _create_class(EmissionModule, [
35164
35182
  {
@@ -38305,10 +38323,39 @@ __decorate([
38305
38323
 
38306
38324
  /**
38307
38325
  * A burst is a particle emission event, where a number of particles are all emitted at the same time
38308
- */ var Burst = function Burst(time, count) {
38309
- this.time = time;
38310
- this.count = count;
38311
- };
38326
+ */ var Burst = /*#__PURE__*/ function() {
38327
+ function Burst(time, count, cycles, repeatInterval) {
38328
+ this.time = time;
38329
+ this.count = count;
38330
+ this._cycles = Math.max(cycles != null ? cycles : 1, 1);
38331
+ this._repeatInterval = Math.max(repeatInterval != null ? repeatInterval : 0.01, 0.01);
38332
+ }
38333
+ _create_class(Burst, [
38334
+ {
38335
+ key: "cycles",
38336
+ get: /**
38337
+ * Number of times to repeat the burst.
38338
+ */ function get() {
38339
+ return this._cycles;
38340
+ },
38341
+ set: function set(value) {
38342
+ this._cycles = Math.max(value, 1);
38343
+ }
38344
+ },
38345
+ {
38346
+ key: "repeatInterval",
38347
+ get: /**
38348
+ * Time interval between each repeated burst.
38349
+ */ function get() {
38350
+ return this._repeatInterval;
38351
+ },
38352
+ set: function set(value) {
38353
+ this._repeatInterval = Math.max(value, 0.01);
38354
+ }
38355
+ }
38356
+ ]);
38357
+ return Burst;
38358
+ }();
38312
38359
  __decorate([
38313
38360
  deepClone
38314
38361
  ], Burst.prototype, "count", void 0);