@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/main.js CHANGED
@@ -35139,30 +35139,48 @@ __decorate([
35139
35139
  }
35140
35140
  this._emitBySubBurst(middleTime, playTime, duration);
35141
35141
  } else {
35142
- this._emitBySubBurst(lastPlayTime, playTime, duration);
35142
+ if (lastPlayTime < duration) {
35143
+ this._emitBySubBurst(lastPlayTime, Math.min(playTime, duration), duration);
35144
+ }
35143
35145
  }
35144
35146
  };
35145
35147
  _proto._emitBySubBurst = function _emitBySubBurst(lastPlayTime, playTime, duration) {
35146
- var generator = this._generator;
35147
- var rand = this._burstRand;
35148
- var bursts = this.bursts;
35149
- // Calculate the relative time of the burst
35148
+ var _this = this, generator = _this._generator, rand = _this._burstRand, bursts = _this.bursts;
35150
35149
  var baseTime = Math.floor(lastPlayTime / duration) * duration;
35151
35150
  var startTime = lastPlayTime % duration;
35152
35151
  var endTime = startTime + (playTime - lastPlayTime);
35152
+ var pendingIndex = -1;
35153
35153
  var index = this._currentBurstIndex;
35154
35154
  for(var n = bursts.length; index < n; index++){
35155
35155
  var burst = bursts[index];
35156
35156
  var burstTime = burst.time;
35157
- if (burstTime > endTime) {
35158
- break;
35159
- }
35160
- if (burstTime >= startTime) {
35161
- var count = burst.count.evaluate(undefined, rand.random());
35162
- generator._emit(baseTime + burstTime, count);
35157
+ if (burstTime >= endTime) break;
35158
+ var cycles = burst.cycles, repeatInterval = burst.repeatInterval;
35159
+ if (cycles === 1) {
35160
+ if (burstTime >= startTime) {
35161
+ generator._emit(baseTime + burstTime, burst.count.evaluate(undefined, rand.random()));
35162
+ }
35163
+ } else {
35164
+ var maxCycles = cycles === Infinity ? Math.ceil((duration - burstTime) / repeatInterval) : cycles;
35165
+ // Absorb float drift: (startTime - burstTime) / repeatInterval may land at cycle + 1e-15
35166
+ // when it should be exactly cycle, and ceil would then skip ahead to cycle + 1.
35167
+ var tolerance = engineMath.MathUtil.zeroTolerance;
35168
+ var lastCycle = Math.ceil((endTime - burstTime) / repeatInterval - tolerance) - 1;
35169
+ var first = Math.max(0, Math.ceil((startTime - burstTime) / repeatInterval - tolerance));
35170
+ var last = Math.min(maxCycles - 1, lastCycle);
35171
+ for(var c = first; c <= last; c++){
35172
+ var effectiveTime = burstTime + c * repeatInterval;
35173
+ if (effectiveTime >= duration) break;
35174
+ generator._emit(baseTime + effectiveTime, burst.count.evaluate(undefined, rand.random()));
35175
+ }
35176
+ // `_currentBurstIndex` caches next frame's scan start, so only the earliest unfinished
35177
+ // burst can be the entry point — skipping past it would drop its remaining cycles
35178
+ if (pendingIndex < 0 && lastCycle < maxCycles - 1) {
35179
+ pendingIndex = index;
35180
+ }
35163
35181
  }
35164
35182
  }
35165
- this._currentBurstIndex = index;
35183
+ this._currentBurstIndex = pendingIndex >= 0 ? pendingIndex : index;
35166
35184
  };
35167
35185
  _create_class(EmissionModule, [
35168
35186
  {
@@ -35813,9 +35831,9 @@ __decorate([
35813
35831
  /**
35814
35832
  * Control how Particle Generator apply transform scale.
35815
35833
  */ var ParticleScaleMode = /*#__PURE__*/ function(ParticleScaleMode) {
35816
- /** Scale the Particle Generator using the entire transform hierarchy. */ ParticleScaleMode[ParticleScaleMode["Hierarchy"] = 0] = "Hierarchy";
35817
- /** Scale the Particle Generator using only its own transform scale. (Ignores parent scale). */ ParticleScaleMode[ParticleScaleMode["Local"] = 1] = "Local";
35818
- /** 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";
35834
+ /** Scale the Particle Generator using the world scale, including all parent transforms. */ ParticleScaleMode[ParticleScaleMode["World"] = 0] = "World";
35835
+ /** Scale the Particle Generator using only its own transform scale, ignoring parent scale. */ ParticleScaleMode[ParticleScaleMode["Local"] = 1] = "Local";
35836
+ /** Scale only the emitter shape positions; particle size and movement are unaffected. */ ParticleScaleMode[ParticleScaleMode["Shape"] = 2] = "Shape";
35819
35837
  return ParticleScaleMode;
35820
35838
  }({});
35821
35839
 
@@ -35867,8 +35885,8 @@ var MainModule = /*#__PURE__*/ function() {
35867
35885
  */ _proto._getPositionScale = function _getPositionScale() {
35868
35886
  var transform = this._generator._renderer.entity.transform;
35869
35887
  switch(this.scalingMode){
35870
- case ParticleScaleMode.Hierarchy:
35871
35888
  case ParticleScaleMode.World:
35889
+ case ParticleScaleMode.Shape:
35872
35890
  return transform.lossyWorldScale;
35873
35891
  case ParticleScaleMode.Local:
35874
35892
  return transform.scale;
@@ -35892,7 +35910,7 @@ var MainModule = /*#__PURE__*/ function() {
35892
35910
  throw new Error("ParticleRenderer: SimulationSpace value is invalid.");
35893
35911
  }
35894
35912
  switch(this.scalingMode){
35895
- case ParticleScaleMode.Hierarchy:
35913
+ case ParticleScaleMode.World:
35896
35914
  var scale = transform.lossyWorldScale;
35897
35915
  shaderData.setVector3(MainModule._positionScale, scale);
35898
35916
  shaderData.setVector3(MainModule._sizeScale, scale);
@@ -35902,7 +35920,7 @@ var MainModule = /*#__PURE__*/ function() {
35902
35920
  shaderData.setVector3(MainModule._positionScale, scale);
35903
35921
  shaderData.setVector3(MainModule._sizeScale, scale);
35904
35922
  break;
35905
- case ParticleScaleMode.World:
35923
+ case ParticleScaleMode.Shape:
35906
35924
  shaderData.setVector3(MainModule._positionScale, transform.lossyWorldScale);
35907
35925
  shaderData.setVector3(MainModule._sizeScale, MainModule._vector3One);
35908
35926
  break;
@@ -38309,10 +38327,39 @@ __decorate([
38309
38327
 
38310
38328
  /**
38311
38329
  * A burst is a particle emission event, where a number of particles are all emitted at the same time
38312
- */ var Burst = function Burst(time, count) {
38313
- this.time = time;
38314
- this.count = count;
38315
- };
38330
+ */ var Burst = /*#__PURE__*/ function() {
38331
+ function Burst(time, count, cycles, repeatInterval) {
38332
+ this.time = time;
38333
+ this.count = count;
38334
+ this._cycles = Math.max(cycles != null ? cycles : 1, 1);
38335
+ this._repeatInterval = Math.max(repeatInterval != null ? repeatInterval : 0.01, 0.01);
38336
+ }
38337
+ _create_class(Burst, [
38338
+ {
38339
+ key: "cycles",
38340
+ get: /**
38341
+ * Number of times to repeat the burst.
38342
+ */ function get() {
38343
+ return this._cycles;
38344
+ },
38345
+ set: function set(value) {
38346
+ this._cycles = Math.max(value, 1);
38347
+ }
38348
+ },
38349
+ {
38350
+ key: "repeatInterval",
38351
+ get: /**
38352
+ * Time interval between each repeated burst.
38353
+ */ function get() {
38354
+ return this._repeatInterval;
38355
+ },
38356
+ set: function set(value) {
38357
+ this._repeatInterval = Math.max(value, 0.01);
38358
+ }
38359
+ }
38360
+ ]);
38361
+ return Burst;
38362
+ }();
38316
38363
  __decorate([
38317
38364
  deepClone
38318
38365
  ], Burst.prototype, "count", void 0);