@galacean/engine-core 2.0.0-alpha.28 → 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
  {
@@ -35809,9 +35827,9 @@ __decorate([
35809
35827
  /**
35810
35828
  * Control how Particle Generator apply transform scale.
35811
35829
  */ var ParticleScaleMode = /*#__PURE__*/ function(ParticleScaleMode) {
35812
- /** Scale the Particle Generator using the entire transform hierarchy. */ ParticleScaleMode[ParticleScaleMode["Hierarchy"] = 0] = "Hierarchy";
35813
- /** Scale the Particle Generator using only its own transform scale. (Ignores parent scale). */ ParticleScaleMode[ParticleScaleMode["Local"] = 1] = "Local";
35814
- /** Only apply transform scale to the shape component, which controls where particles are spawned, but does not affect their size or movement. */ ParticleScaleMode[ParticleScaleMode["World"] = 2] = "World";
35830
+ /** Scale the Particle Generator using the world scale, including all parent transforms. */ ParticleScaleMode[ParticleScaleMode["World"] = 0] = "World";
35831
+ /** Scale the Particle Generator using only its own transform scale, ignoring parent scale. */ ParticleScaleMode[ParticleScaleMode["Local"] = 1] = "Local";
35832
+ /** Scale only the emitter shape positions; particle size and movement are unaffected. */ ParticleScaleMode[ParticleScaleMode["Shape"] = 2] = "Shape";
35815
35833
  return ParticleScaleMode;
35816
35834
  }({});
35817
35835
 
@@ -35863,8 +35881,8 @@ var MainModule = /*#__PURE__*/ function() {
35863
35881
  */ _proto._getPositionScale = function _getPositionScale() {
35864
35882
  var transform = this._generator._renderer.entity.transform;
35865
35883
  switch(this.scalingMode){
35866
- case ParticleScaleMode.Hierarchy:
35867
35884
  case ParticleScaleMode.World:
35885
+ case ParticleScaleMode.Shape:
35868
35886
  return transform.lossyWorldScale;
35869
35887
  case ParticleScaleMode.Local:
35870
35888
  return transform.scale;
@@ -35888,7 +35906,7 @@ var MainModule = /*#__PURE__*/ function() {
35888
35906
  throw new Error("ParticleRenderer: SimulationSpace value is invalid.");
35889
35907
  }
35890
35908
  switch(this.scalingMode){
35891
- case ParticleScaleMode.Hierarchy:
35909
+ case ParticleScaleMode.World:
35892
35910
  var scale = transform.lossyWorldScale;
35893
35911
  shaderData.setVector3(MainModule._positionScale, scale);
35894
35912
  shaderData.setVector3(MainModule._sizeScale, scale);
@@ -35898,7 +35916,7 @@ var MainModule = /*#__PURE__*/ function() {
35898
35916
  shaderData.setVector3(MainModule._positionScale, scale);
35899
35917
  shaderData.setVector3(MainModule._sizeScale, scale);
35900
35918
  break;
35901
- case ParticleScaleMode.World:
35919
+ case ParticleScaleMode.Shape:
35902
35920
  shaderData.setVector3(MainModule._positionScale, transform.lossyWorldScale);
35903
35921
  shaderData.setVector3(MainModule._sizeScale, MainModule._vector3One);
35904
35922
  break;
@@ -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);