@galacean/engine-core 2.0.0-alpha.34 → 2.0.0-alpha.35

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
@@ -16897,6 +16897,16 @@ BasicResources._maskReadOutsideRenderStates = null;
16897
16897
  BasicResources._maskWriteIncrementRenderStates = null;
16898
16898
  BasicResources._maskWriteDecrementRenderStates = null;
16899
16899
 
16900
+ /**
16901
+ * Engine event type.
16902
+ */ var EngineEventType = /*#__PURE__*/ function(EngineEventType) {
16903
+ /** Dispatched when the engine starts running. */ EngineEventType["Run"] = "run";
16904
+ /** Dispatched when the engine shuts down. */ EngineEventType["Shutdown"] = "shutdown";
16905
+ /** Dispatched when the graphic device is lost. */ EngineEventType["DeviceLost"] = "devicelost";
16906
+ /** Dispatched when the graphic device is restored. */ EngineEventType["DeviceRestored"] = "devicerestored";
16907
+ return EngineEventType;
16908
+ }({});
16909
+
16900
16910
  function _is_native_reflect_construct() {
16901
16911
  // Since Reflect.construct can't be properly polyfilled, some
16902
16912
  // implementations (e.g. core-js@2) don't set the correct internal slots.
@@ -27307,7 +27317,7 @@ var OverlayCamera = function OverlayCamera() {
27307
27317
  * Execution engine loop.
27308
27318
  */ _proto.run = function run() {
27309
27319
  this.resume();
27310
- this.dispatch("run", this);
27320
+ this.dispatch(EngineEventType.Run, this);
27311
27321
  };
27312
27322
  /**
27313
27323
  * Force lose graphic device.
@@ -27392,7 +27402,7 @@ var OverlayCamera = function OverlayCamera() {
27392
27402
  this._batcherManager.destroy();
27393
27403
  this._renderTargetPool.gc();
27394
27404
  (_this_xrManager = this.xrManager) == null ? void 0 : _this_xrManager._destroy();
27395
- this.dispatch("shutdown", this);
27405
+ this.dispatch(EngineEventType.Shutdown, this);
27396
27406
  // Cancel animation
27397
27407
  this.pause();
27398
27408
  Shader._clear(this);
@@ -27529,7 +27539,7 @@ var OverlayCamera = function OverlayCamera() {
27529
27539
  this.resourceManager._lostGraphicResources();
27530
27540
  this._renderingStatistics._reset();
27531
27541
  console.log("Device lost.");
27532
- this.dispatch("devicelost", this);
27542
+ this.dispatch(EngineEventType.DeviceLost, this);
27533
27543
  };
27534
27544
  _proto._onDeviceRestored = function _onDeviceRestored() {
27535
27545
  var _this = this;
@@ -27546,7 +27556,7 @@ var OverlayCamera = function OverlayCamera() {
27546
27556
  // Restore resources content
27547
27557
  resourceManager._restoreResourcesContent().then(function() {
27548
27558
  console.log("Graphic resource content restored.\n\n" + "Device restored.");
27549
- _this.dispatch("devicerestored", _this);
27559
+ _this.dispatch(EngineEventType.DeviceRestored, _this);
27550
27560
  }).catch(function(error) {
27551
27561
  console.error(error);
27552
27562
  });
@@ -33978,6 +33988,13 @@ var ParticleStopMode = /*#__PURE__*/ function(ParticleStopMode) {
33978
33988
  };
33979
33989
  /**
33980
33990
  * @internal
33991
+ */ _proto._cloneTo = function _cloneTo(target) {
33992
+ Renderer.prototype._cloneTo.call(this, target);
33993
+ target.mesh = this._mesh;
33994
+ target.renderMode = this._renderMode;
33995
+ };
33996
+ /**
33997
+ * @internal
33981
33998
  */ _proto._isContainDirtyFlag = function _isContainDirtyFlag(type) {
33982
33999
  return (this._dirtyUpdateFlag & type) != 0;
33983
34000
  };
@@ -34039,9 +34056,7 @@ var ParticleStopMode = /*#__PURE__*/ function(ParticleStopMode) {
34039
34056
  var wasMeshMode = lastRenderMode === ParticleRenderMode.Mesh;
34040
34057
  var isMeshMode = value === ParticleRenderMode.Mesh;
34041
34058
  if (wasMeshMode !== isMeshMode) {
34042
- if (!isMeshMode || this.mesh) {
34043
- this.generator._reorganizeGeometryBuffers();
34044
- }
34059
+ this.generator._reorganizeGeometryBuffers();
34045
34060
  }
34046
34061
  }
34047
34062
  }
@@ -34095,6 +34110,15 @@ __decorate([
34095
34110
  __decorate([
34096
34111
  ignoreClone
34097
34112
  ], ParticleRenderer.prototype, "_transformedBounds", void 0);
34113
+ __decorate([
34114
+ ignoreClone
34115
+ ], ParticleRenderer.prototype, "_mesh", void 0);
34116
+ __decorate([
34117
+ ignoreClone
34118
+ ], ParticleRenderer.prototype, "_renderMode", void 0);
34119
+ __decorate([
34120
+ ignoreClone
34121
+ ], ParticleRenderer.prototype, "_currentRenderModeMacro", void 0);
34098
34122
  __decorate([
34099
34123
  ignoreClone
34100
34124
  ], ParticleRenderer.prototype, "_onGeneratorParamsChanged", null);
@@ -34485,6 +34509,7 @@ ParticleTransformFeedbackSimulator._deltaTimeProperty = ShaderProperty.getByName
34485
34509
  ParticleRandomSubSeeds[ParticleRandomSubSeeds["ForceOverLifetime"] = 3875246972] = "ForceOverLifetime";
34486
34510
  ParticleRandomSubSeeds[ParticleRandomSubSeeds["LimitVelocityOverLifetime"] = 3047300990] = "LimitVelocityOverLifetime";
34487
34511
  ParticleRandomSubSeeds[ParticleRandomSubSeeds["Noise"] = 4105357473] = "Noise";
34512
+ ParticleRandomSubSeeds[ParticleRandomSubSeeds["EmissionRate"] = 2625893077] = "EmissionRate";
34488
34513
  return ParticleRandomSubSeeds;
34489
34514
  }({});
34490
34515
 
@@ -35409,10 +35434,6 @@ __decorate([
35409
35434
  Logger.error("CustomDataModule." + method + ': "' + name + '" must contain only letters, digits, or underscores; call ignored.');
35410
35435
  return false;
35411
35436
  }
35412
- if (CustomDataModule._reservedPrefixPattern.test(name)) {
35413
- Logger.error("CustomDataModule." + method + ': "' + name + '" starts with a reserved engine particle module prefix ' + "(VOL/FOL/SOL/COL/ROL/TSA/LVL) and would collide with built-in uniforms; call ignored.");
35414
- return false;
35415
- }
35416
35437
  if (this._curves.has(name) || this._gradients.has(name)) {
35417
35438
  Logger.error("CustomDataModule." + method + ': "' + name + '" is already in use; call ignored.');
35418
35439
  return false;
@@ -35440,7 +35461,6 @@ __decorate([
35440
35461
  return CustomDataModule;
35441
35462
  }(ParticleGeneratorModule);
35442
35463
  CustomDataModule._streamNamePattern = /^[A-Za-z0-9_]+$/;
35443
- CustomDataModule._reservedPrefixPattern = /^(?:VOL|FOL|SOL|COL|ROL|TSA|LVL)/;
35444
35464
  CustomDataModule._zeroCurveArray = new Float32Array(8);
35445
35465
  CustomDataModule._zeroGradientColorArray = new Float32Array(16);
35446
35466
  CustomDataModule._zeroGradientAlphaArray = new Float32Array(8);
@@ -35465,7 +35485,7 @@ __decorate([
35465
35485
  _inherits(EmissionModule, ParticleGeneratorModule);
35466
35486
  function EmissionModule() {
35467
35487
  var _this;
35468
- _this = ParticleGeneratorModule.apply(this, arguments) || this, /** The rate of particle emission. */ _this.rateOverTime = new ParticleCompositeCurve(10), /** The rate at which the emitter spawns new particles over distance. */ _this.rateOverDistance = new ParticleCompositeCurve(0), /** @internal */ _this._shapeRand = new engineMath.Rand(0, ParticleRandomSubSeeds.Shape), /** @internal */ _this._frameRateTime = 0, _this._distanceAccumulator = 0, _this._lastEmitPosition = new engineMath.Vector3(), _this._hasLastEmitPosition = false, _this._bursts = [], _this._currentBurstIndex = 0, _this._burstRand = new engineMath.Rand(0, ParticleRandomSubSeeds.Burst);
35488
+ _this = ParticleGeneratorModule.apply(this, arguments) || this, /** The rate of particle emission. */ _this.rateOverTime = new ParticleCompositeCurve(10), /** The rate at which the emitter spawns new particles over distance. */ _this.rateOverDistance = new ParticleCompositeCurve(0), /** @internal */ _this._shapeRand = new engineMath.Rand(0, ParticleRandomSubSeeds.Shape), /** @internal */ _this._rateRand = new engineMath.Rand(0, ParticleRandomSubSeeds.EmissionRate), /** @internal */ _this._frameRateTime = 0, _this._distanceAccumulator = 0, _this._lastEmitPosition = new engineMath.Vector3(), _this._hasLastEmitPosition = false, _this._bursts = [], _this._currentBurstIndex = 0, _this._burstRand = new engineMath.Rand(0, ParticleRandomSubSeeds.Burst);
35469
35489
  return _this;
35470
35490
  }
35471
35491
  var _proto = EmissionModule.prototype;
@@ -35507,9 +35527,16 @@ __decorate([
35507
35527
  };
35508
35528
  /**
35509
35529
  * @internal
35530
+ */ _proto._updateShaderData = function _updateShaderData(shaderData) {
35531
+ var shapeMacro = this._enabled && this._shape ? EmissionModule._emissionShapeMacro : null;
35532
+ this._shapeMacro = this._enableMacro(shaderData, this._shapeMacro, shapeMacro);
35533
+ };
35534
+ /**
35535
+ * @internal
35510
35536
  */ _proto._resetRandomSeed = function _resetRandomSeed(seed) {
35511
35537
  this._burstRand.reset(seed, ParticleRandomSubSeeds.Burst);
35512
35538
  this._shapeRand.reset(seed, ParticleRandomSubSeeds.Shape);
35539
+ this._rateRand.reset(seed, ParticleRandomSubSeeds.EmissionRate);
35513
35540
  };
35514
35541
  /** @internal */ _proto._resyncCursors = function _resyncCursors(playTime) {
35515
35542
  this._frameRateTime = playTime;
@@ -35524,24 +35551,24 @@ __decorate([
35524
35551
  (_this__shape = this._shape) == null ? void 0 : _this__shape._unRegisterOnValueChanged(this._generator._renderer._onGeneratorParamsChanged);
35525
35552
  };
35526
35553
  _proto._emitByRateOverTime = function _emitByRateOverTime(playTime) {
35527
- var ratePerSeconds = this.rateOverTime.evaluate(undefined, undefined);
35528
- if (ratePerSeconds <= 0) {
35529
- this._frameRateTime = playTime;
35530
- return;
35531
- }
35532
- var generator = this._generator;
35533
- var emitInterval = 1.0 / ratePerSeconds;
35554
+ var _this = this, rateOverTime = _this.rateOverTime, generator = _this._generator;
35534
35555
  var cumulativeTime = playTime - this._frameRateTime;
35535
- while(cumulativeTime >= emitInterval){
35556
+ var ratePerSeconds = this._evaluateRate(rateOverTime, this._frameRateTime);
35557
+ while(ratePerSeconds > 0){
35558
+ var emitInterval = 1.0 / ratePerSeconds;
35559
+ if (cumulativeTime < emitInterval) return;
35536
35560
  cumulativeTime -= emitInterval;
35537
35561
  this._frameRateTime += emitInterval;
35538
35562
  generator._emit(this._frameRateTime, 1);
35563
+ ratePerSeconds = this._evaluateRate(rateOverTime, this._frameRateTime);
35539
35564
  }
35565
+ this._frameRateTime = playTime;
35540
35566
  };
35541
35567
  _proto._emitByRateOverDistance = function _emitByRateOverDistance(lastPlayTime, playTime) {
35542
- var ratePerUnit = this.rateOverDistance.evaluate(undefined, undefined);
35543
- var generator = this._generator;
35544
- if (ratePerUnit <= 0) {
35568
+ var _this = this, rateOverDistance = _this.rateOverDistance, generator = _this._generator;
35569
+ // Distance rate is sampled once per frame at the current cycle position
35570
+ var ratePerUnit = this._evaluateRate(rateOverDistance, playTime);
35571
+ if (!(ratePerUnit > 0)) {
35545
35572
  this._hasLastEmitPosition = false;
35546
35573
  this._distanceAccumulator = 0;
35547
35574
  return;
@@ -35588,6 +35615,23 @@ __decorate([
35588
35615
  }
35589
35616
  lastPos.copyFrom(currentPos);
35590
35617
  };
35618
+ _proto._evaluateRate = function _evaluateRate(rate, cursorTime) {
35619
+ switch(rate.mode){
35620
+ case ParticleCurveMode.Constant:
35621
+ return rate.constant;
35622
+ case ParticleCurveMode.Curve:
35623
+ {
35624
+ var duration = this._generator.main.duration;
35625
+ return rate.evaluate(cursorTime % duration / duration, undefined);
35626
+ }
35627
+ default:
35628
+ {
35629
+ // TwoConstants / TwoCurves: lerp between the two values with a per-sample random factor
35630
+ var duration1 = this._generator.main.duration;
35631
+ return rate.evaluate(cursorTime % duration1 / duration1, this._rateRand.random());
35632
+ }
35633
+ }
35634
+ };
35591
35635
  _proto._emitByBurst = function _emitByBurst(lastPlayTime, playTime) {
35592
35636
  var main = this._generator.main;
35593
35637
  var duration = main.duration;
@@ -35662,11 +35706,6 @@ __decorate([
35662
35706
  this._resyncCursors(this._generator._playTime);
35663
35707
  }
35664
35708
  this._enabled = value;
35665
- if (value && this._shape) {
35666
- this._generator._renderer.shaderData.enableMacro(EmissionModule._emissionShapeMacro);
35667
- } else {
35668
- this._generator._renderer.shaderData.disableMacro(EmissionModule._emissionShapeMacro);
35669
- }
35670
35709
  }
35671
35710
  }
35672
35711
  },
@@ -35683,12 +35722,7 @@ __decorate([
35683
35722
  this._shape = value;
35684
35723
  var renderer = this._generator._renderer;
35685
35724
  lastShape == null ? void 0 : lastShape._unRegisterOnValueChanged(renderer._onGeneratorParamsChanged);
35686
- if (value) {
35687
- value._registerOnValueChanged(renderer._onGeneratorParamsChanged);
35688
- this.enabled && renderer.shaderData.enableMacro(EmissionModule._emissionShapeMacro);
35689
- } else {
35690
- renderer.shaderData.disableMacro(EmissionModule._emissionShapeMacro);
35691
- }
35725
+ value == null ? void 0 : value._registerOnValueChanged(renderer._onGeneratorParamsChanged);
35692
35726
  renderer._onGeneratorParamsChanged();
35693
35727
  }
35694
35728
  }
@@ -35718,6 +35752,12 @@ __decorate([
35718
35752
  __decorate([
35719
35753
  ignoreClone
35720
35754
  ], EmissionModule.prototype, "_shapeRand", void 0);
35755
+ __decorate([
35756
+ ignoreClone
35757
+ ], EmissionModule.prototype, "_shapeMacro", void 0);
35758
+ __decorate([
35759
+ ignoreClone
35760
+ ], EmissionModule.prototype, "_rateRand", void 0);
35721
35761
  __decorate([
35722
35762
  ignoreClone
35723
35763
  ], EmissionModule.prototype, "_distanceAccumulator", void 0);
@@ -37840,6 +37880,9 @@ __decorate([
37840
37880
  vertexBufferBindings.length = 0;
37841
37881
  if (renderer.renderMode === ParticleRenderMode.Mesh) {
37842
37882
  var mesh = renderer.mesh;
37883
+ if (!mesh) {
37884
+ return;
37885
+ }
37843
37886
  var positionElement = mesh.getVertexElement(VertexAttribute.Position);
37844
37887
  var colorElement = mesh.getVertexElement(VertexAttribute.Color);
37845
37888
  var uvElement = mesh.getVertexElement(VertexAttribute.UV);
@@ -37973,6 +38016,7 @@ __decorate([
37973
38016
  * @internal
37974
38017
  */ _proto._updateShaderData = function _updateShaderData(shaderData) {
37975
38018
  this.main._updateShaderData(shaderData);
38019
+ this.emission._updateShaderData(shaderData);
37976
38020
  this.velocityOverLifetime._updateShaderData(shaderData);
37977
38021
  this.forceOverLifetime._updateShaderData(shaderData);
37978
38022
  this.limitVelocityOverLifetime._updateShaderData(shaderData);
@@ -38652,6 +38696,9 @@ __decorate([
38652
38696
  __decorate([
38653
38697
  deepClone
38654
38698
  ], ParticleGenerator.prototype, "customData", void 0);
38699
+ __decorate([
38700
+ ignoreClone
38701
+ ], ParticleGenerator.prototype, "_currentParticleCount", void 0);
38655
38702
  __decorate([
38656
38703
  ignoreClone
38657
38704
  ], ParticleGenerator.prototype, "_playTime", void 0);
@@ -40969,6 +41016,7 @@ exports.DynamicCollider = DynamicCollider;
40969
41016
  exports.DynamicColliderConstraints = DynamicColliderConstraints;
40970
41017
  exports.EmissionModule = EmissionModule;
40971
41018
  exports.Engine = Engine;
41019
+ exports.EngineEventType = EngineEventType;
40972
41020
  exports.EngineObject = EngineObject;
40973
41021
  exports.Entity = Entity;
40974
41022
  exports.EntityModifyFlags = EntityModifyFlags;