@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/main.js +63 -16
- package/dist/main.js.map +1 -1
- package/dist/module.js +63 -16
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/particle/modules/Burst.d.ts +21 -1
package/dist/main.js
CHANGED
|
@@ -35139,30 +35139,48 @@ __decorate([
|
|
|
35139
35139
|
}
|
|
35140
35140
|
this._emitBySubBurst(middleTime, playTime, duration);
|
|
35141
35141
|
} else {
|
|
35142
|
-
|
|
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 =
|
|
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
|
|
35158
|
-
|
|
35159
|
-
|
|
35160
|
-
|
|
35161
|
-
|
|
35162
|
-
|
|
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
|
{
|
|
@@ -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
|
|
38313
|
-
|
|
38314
|
-
|
|
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);
|