@galacean/engine 1.1.0-beta.5 → 1.1.0-beta.6

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/browser.js CHANGED
@@ -5511,13 +5511,13 @@
5511
5511
  break;
5512
5512
  case Array:
5513
5513
  var targetPropertyA = target[k];
5514
- var length1 = sourceProperty.length;
5514
+ var length = sourceProperty.length;
5515
5515
  if (targetPropertyA == null) {
5516
- target[k] = targetPropertyA = new Array(length1);
5516
+ target[k] = targetPropertyA = new Array(length);
5517
5517
  } else {
5518
- targetPropertyA.length = length1;
5518
+ targetPropertyA.length = length;
5519
5519
  }
5520
- for(var i = 0; i < length1; i++){
5520
+ for(var i = 0; i < length; i++){
5521
5521
  CloneManager.cloneProperty(sourceProperty, targetPropertyA, i, cloneMode);
5522
5522
  }
5523
5523
  default:
@@ -6238,7 +6238,7 @@
6238
6238
  /**
6239
6239
  * Two-dimensional texture array.
6240
6240
  */ var Texture2DArray = /*#__PURE__*/ function(Texture1) {
6241
- var Texture2DArray = function Texture2DArray(engine, width, height, length1, format, mipmap) {
6241
+ var Texture2DArray = function Texture2DArray(engine, width, height, length, format, mipmap) {
6242
6242
  if (format === void 0) format = exports.TextureFormat.R8G8B8A8;
6243
6243
  if (mipmap === void 0) mipmap = true;
6244
6244
  var _this;
@@ -6246,7 +6246,7 @@
6246
6246
  _this._mipmap = mipmap;
6247
6247
  _this._width = width;
6248
6248
  _this._height = height;
6249
- _this._length = length1;
6249
+ _this._length = length;
6250
6250
  _this._format = format;
6251
6251
  _this._mipmapCount = _this._getMipmapCount();
6252
6252
  _this._platformTexture = engine._hardwareRenderer.createPlatformTexture2DArray(_assert_this_initialized(_this));
@@ -6267,11 +6267,11 @@
6267
6267
  * @param width - Data width. if it's empty, width is the width corresponding to mipLevel minus x , width corresponding to mipLevel is Math.max(1, this.width >> mipLevel)
6268
6268
  * @param height - Data height. if it's empty, height is the height corresponding to mipLevel minus y , height corresponding to mipLevel is Math.max(1, this.height >> mipLevel)
6269
6269
  * @param length - Data length. if it's empty, length is the length of Texture2DArray.length
6270
- */ _proto.setPixelBuffer = function setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length1) {
6270
+ */ _proto.setPixelBuffer = function setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length) {
6271
6271
  if (mipLevel === void 0) mipLevel = 0;
6272
6272
  if (x === void 0) x = 0;
6273
6273
  if (y === void 0) y = 0;
6274
- this._platformTexture.setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length1);
6274
+ this._platformTexture.setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length);
6275
6275
  this._isContentLost = false;
6276
6276
  };
6277
6277
  /**
@@ -7890,11 +7890,11 @@
7890
7890
  var pathArr = this._stringToPath(path);
7891
7891
  var object = target;
7892
7892
  var index = 0;
7893
- var length1 = pathArr.length;
7894
- while(object != null && index < length1){
7893
+ var length = pathArr.length;
7894
+ while(object != null && index < length){
7895
7895
  object = object[pathArr[index++]];
7896
7896
  }
7897
- return index && index == length1 ? object : undefined;
7897
+ return index && index == length ? object : undefined;
7898
7898
  };
7899
7899
  /**
7900
7900
  * Fast remove an element from array.
@@ -9071,7 +9071,7 @@
9071
9071
  */ _proto.findByPath = function findByPath(path) {
9072
9072
  var splits = path.split("/");
9073
9073
  var entity = this;
9074
- for(var i = 0, length1 = splits.length; i < length1; ++i){
9074
+ for(var i = 0, length = splits.length; i < length; ++i){
9075
9075
  var split = splits[i];
9076
9076
  if (split) {
9077
9077
  entity = Entity._findChildByName(entity, split);
@@ -9303,7 +9303,7 @@
9303
9303
  };
9304
9304
  _proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
9305
9305
  var activeChangedComponents = this._activeChangedComponents;
9306
- for(var i = 0, length1 = activeChangedComponents.length; i < length1; ++i){
9306
+ for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
9307
9307
  activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
9308
9308
  }
9309
9309
  this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
@@ -13299,14 +13299,14 @@
13299
13299
  vertexElements[index] = element;
13300
13300
  this._bufferStructChanged = true;
13301
13301
  };
13302
- _proto.setVertexElementsLength = function setVertexElementsLength(length1) {
13302
+ _proto.setVertexElementsLength = function setVertexElementsLength(length) {
13303
13303
  var vertexElementMap = this._vertexElementMap;
13304
13304
  var vertexElements = this._vertexElements;
13305
- for(var i = length1, n = vertexElements.length; i < n; i++){
13305
+ for(var i = length, n = vertexElements.length; i < n; i++){
13306
13306
  var element = vertexElements[i];
13307
13307
  delete vertexElementMap[element.attribute];
13308
13308
  }
13309
- vertexElements.length = length1;
13309
+ vertexElements.length = length;
13310
13310
  };
13311
13311
  _proto.setVertexBufferBinding = function setVertexBufferBinding(index, binding) {
13312
13312
  var referCount = this._getReferCount();
@@ -13460,8 +13460,8 @@
13460
13460
  /**
13461
13461
  * @internal
13462
13462
  *
13463
- */ _proto._setVertexElementsLength = function _setVertexElementsLength(length1) {
13464
- this._primitive.setVertexElementsLength(length1);
13463
+ */ _proto._setVertexElementsLength = function _setVertexElementsLength(length) {
13464
+ this._primitive.setVertexElementsLength(length);
13465
13465
  };
13466
13466
  /**
13467
13467
  * @internal
@@ -15177,9 +15177,9 @@
15177
15177
  }
15178
15178
  var bsUpdate = !bsManager._useTextureMode() && bsManager._vertexElementsNeedUpdate();
15179
15179
  if (previousBSOffset !== bsManager._vertexElementOffset || bsUpdate && bsManager._blendShapeCount > 0) {
15180
- var length1 = bsManager._addVertexElements(this);
15181
- if (length1 < previousCount) {
15182
- this._setVertexElementsLength(length1);
15180
+ var length = bsManager._addVertexElements(this);
15181
+ if (length < previousCount) {
15182
+ this._setVertexElementsLength(length);
15183
15183
  }
15184
15184
  }
15185
15185
  };
@@ -20333,9 +20333,9 @@
20333
20333
  pointer._firePointerDrag();
20334
20334
  var rayCastEntity = this._pointerRayCast(scenes, position.x / canvas.width, position.y / canvas.height);
20335
20335
  pointer._firePointerExitAndEnter(rayCastEntity);
20336
- var length1 = events.length;
20337
- if (length1 > 0) {
20338
- for(var i1 = 0; i1 < length1; i1++){
20336
+ var length = events.length;
20337
+ if (length > 0) {
20338
+ for(var i1 = 0; i1 < length; i1++){
20339
20339
  switch(events[i1].type){
20340
20340
  case "pointerdown":
20341
20341
  pointer.phase = exports.PointerPhase.Down;
@@ -20430,15 +20430,15 @@
20430
20430
  };
20431
20431
  _proto._updatePointerInfo = function _updatePointerInfo(frameCount, pointer, left, top, widthPixelRatio, heightPixelRatio) {
20432
20432
  var events = pointer._events, position = pointer.position;
20433
- var length1 = events.length;
20434
- if (length1 > 0) {
20433
+ var length = events.length;
20434
+ if (length > 0) {
20435
20435
  var _this = this, _upList = _this._upList, _upMap = _this._upMap, _downList = _this._downList, _downMap = _this._downMap;
20436
- var latestEvent = events[length1 - 1];
20436
+ var latestEvent = events[length - 1];
20437
20437
  var currX = (latestEvent.clientX - left) * widthPixelRatio;
20438
20438
  var currY = (latestEvent.clientY - top) * heightPixelRatio;
20439
20439
  pointer.deltaPosition.set(currX - position.x, currY - position.y);
20440
20440
  position.set(currX, currY);
20441
- for(var i = 0; i < length1; i++){
20441
+ for(var i = 0; i < length; i++){
20442
20442
  var event = events[i];
20443
20443
  var button = event.button;
20444
20444
  pointer.button = _pointerDec2BinMap[button] || exports.PointerButton.None;
@@ -20480,8 +20480,8 @@
20480
20480
  continue;
20481
20481
  }
20482
20482
  var cameras = scene._activeCameras;
20483
- for(var j = 0; j < cameras.length; j++){
20484
- var camera = cameras[i];
20483
+ for(var j = cameras.length - 1; j >= 0; j--){
20484
+ var camera = cameras[j];
20485
20485
  if (!camera.enabled || camera.renderTarget) {
20486
20486
  continue;
20487
20487
  }
@@ -21304,9 +21304,9 @@
21304
21304
  var shaderProgramPools = this._shaderProgramPools;
21305
21305
  var pool = shaderProgramPools[index];
21306
21306
  if (!pool) {
21307
- var length1 = index + 1;
21308
- if (length1 > shaderProgramPools.length) {
21309
- shaderProgramPools.length = length1;
21307
+ var length = index + 1;
21308
+ if (length > shaderProgramPools.length) {
21309
+ shaderProgramPools.length = length;
21310
21310
  }
21311
21311
  shaderProgramPools[index] = pool = new ShaderProgramPool();
21312
21312
  }
@@ -21760,11 +21760,11 @@
21760
21760
  /**
21761
21761
  * @internal
21762
21762
  */ _proto.destroy = function destroy() {
21763
+ this.texture = null;
21763
21764
  this._mesh._addReferCount(-1);
21764
21765
  this._mesh = null;
21765
21766
  this._material._addReferCount(-1);
21766
21767
  this._material = null;
21767
- this.texture = null;
21768
21768
  this.solidColor = null;
21769
21769
  this.sky.destroy();
21770
21770
  };
@@ -22008,7 +22008,7 @@
22008
22008
  var _this = this, pendingDestroyScripts = _this._disposeDestroyScripts, disposeDestroyScripts = _this._pendingDestroyScripts;
22009
22009
  this._disposeDestroyScripts = disposeDestroyScripts;
22010
22010
  this._pendingDestroyScripts = pendingDestroyScripts;
22011
- length = disposeDestroyScripts.length;
22011
+ var length = disposeDestroyScripts.length;
22012
22012
  if (length > 0) {
22013
22013
  for(var i = length - 1; i >= 0; i--){
22014
22014
  disposeDestroyScripts[i].onDestroy();
@@ -28191,11 +28191,11 @@
28191
28191
  /**
28192
28192
  * @internal
28193
28193
  */ var CharRenderDataPool = /*#__PURE__*/ function() {
28194
- var CharRenderDataPool = function CharRenderDataPool(type, length1) {
28194
+ var CharRenderDataPool = function CharRenderDataPool(type, length) {
28195
28195
  this._elements = [];
28196
28196
  this._type = type;
28197
28197
  var elements = this._elements;
28198
- for(var i = 0; i < length1; ++i){
28198
+ for(var i = 0; i < length; ++i){
28199
28199
  elements[i] = new type();
28200
28200
  }
28201
28201
  };
@@ -29246,8 +29246,8 @@
29246
29246
  /**
29247
29247
  * @internal
29248
29248
  */ _proto._evaluate = function _evaluate(time, evaluateData) {
29249
- var length1 = this.keys.length;
29250
- if (!length1) {
29249
+ var length = this.keys.length;
29250
+ if (!length) {
29251
29251
  console.warn("This curve don't have any keyframes: ", this);
29252
29252
  return;
29253
29253
  }
@@ -29255,11 +29255,11 @@
29255
29255
  // Compute curIndex and nextIndex.
29256
29256
  var curIndex = evaluateData.curKeyframeIndex;
29257
29257
  // Reset loop,if delete keyfranme may cause `curIndex >= length`
29258
- if (curIndex !== -1 && (curIndex >= length1 || time < keys[curIndex].time)) {
29258
+ if (curIndex !== -1 && (curIndex >= length || time < keys[curIndex].time)) {
29259
29259
  curIndex = -1;
29260
29260
  }
29261
29261
  var nextIndex = curIndex + 1;
29262
- while(nextIndex < length1){
29262
+ while(nextIndex < length){
29263
29263
  if (time < keys[nextIndex].time) {
29264
29264
  break;
29265
29265
  }
@@ -29271,7 +29271,7 @@
29271
29271
  var value;
29272
29272
  if (curIndex === -1) {
29273
29273
  value = this._type._setValue(keys[0].value, evaluateData.value);
29274
- } else if (nextIndex === length1) {
29274
+ } else if (nextIndex === length) {
29275
29275
  value = this._type._setValue(keys[curIndex].value, evaluateData.value);
29276
29276
  } else {
29277
29277
  // Time between first frame and end frame.
@@ -31632,62 +31632,199 @@
31632
31632
  (function() {
31633
31633
  SkyProceduralMaterial._sunSimpleMacro = ShaderMacro.getByName("MATERIAL_SUN_SIMPLE");
31634
31634
  })();
31635
+ var SubPrimitive = function SubPrimitive() {};
31635
31636
  /**
31636
- * Particle Material.
31637
- */ var ParticleMaterial = /*#__PURE__*/ function(BaseMaterial1) {
31638
- var ParticleMaterial = function ParticleMaterial(engine) {
31637
+ * The rendering mode for particle renderer.
31638
+ */ exports.ParticleRenderMode = void 0;
31639
+ (function(ParticleRenderMode) {
31640
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards facing the active camera. */ "Billboard"] = 0] = "Billboard";
31641
+ ParticleRenderMode[ParticleRenderMode[/** Stretch particles in the direction of motion. */ "StretchBillboard"] = 1] = "StretchBillboard";
31642
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing up along the y-Axis. */ "HorizontalBillboard"] = 2] = "HorizontalBillboard";
31643
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing the player, but not pitching along the x-Axis. */ "VerticalBillboard"] = 3] = "VerticalBillboard";
31644
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as meshes. */ "Mesh"] = 4] = "Mesh";
31645
+ ParticleRenderMode[ParticleRenderMode[/** Do not render particles. */ "None"] = 5] = "None";
31646
+ })(exports.ParticleRenderMode || (exports.ParticleRenderMode = {}));
31647
+ exports.ParticleStopMode = void 0;
31648
+ (function(ParticleStopMode) {
31649
+ ParticleStopMode[ParticleStopMode[/** Stop emitting new particles and clear existing particles immediately. */ "StopEmittingAndClear"] = 0] = "StopEmittingAndClear";
31650
+ ParticleStopMode[ParticleStopMode[/** Stop emitting new particles, but keep existing particles until they expire. */ "StopEmitting"] = 1] = "StopEmitting";
31651
+ })(exports.ParticleStopMode || (exports.ParticleStopMode = {}));
31652
+ /**
31653
+ * Particle Renderer Component.
31654
+ */ var ParticleRenderer = /*#__PURE__*/ function(Renderer1) {
31655
+ _inherits$2(ParticleRenderer, Renderer1);
31656
+ function ParticleRenderer(entity) {
31639
31657
  var _this;
31640
- _this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
31641
- var shaderData = _this.shaderData;
31642
- shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
31643
- shaderData.setColor(BaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
31644
- _this.isTransparent = true;
31658
+ _this = Renderer1.call(this, entity) || this;
31659
+ /** Particle generator. */ _this.generator = new ParticleGenerator(_assert_this_initialized(_this));
31660
+ /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0;
31661
+ /** How much are the particles stretched in their direction of motion, defined as the length of the particle compared to its width. */ _this.lengthScale = 2;
31662
+ /** The pivot of particle. */ _this.pivot = new Vector3();
31663
+ _this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
31664
+ _this.shaderData.enableMacro(ParticleRenderer._billboardModeMacro);
31665
+ _this._supportInstancedArrays = _this.engine._hardwareRenderer.canIUse(exports.GLCapabilityType.instancedArrays);
31645
31666
  return _this;
31667
+ }
31668
+ var _proto = ParticleRenderer.prototype;
31669
+ /**
31670
+ * @internal
31671
+ */ _proto._onEnable = function _onEnable() {
31672
+ if (this.generator.main.playOnEnabled) {
31673
+ this.generator.play(false);
31674
+ }
31646
31675
  };
31647
- _inherits$2(ParticleMaterial, BaseMaterial1);
31648
- var _proto = ParticleMaterial.prototype;
31649
31676
  /**
31650
- * @inheritdoc
31651
- */ _proto.clone = function clone() {
31652
- var dest = new ParticleMaterial(this._engine);
31653
- this.cloneTo(dest);
31654
- return dest;
31677
+ * @internal
31678
+ */ _proto._onDisable = function _onDisable() {
31679
+ this.generator.stop(false, exports.ParticleStopMode.StopEmittingAndClear);
31655
31680
  };
31656
- _create_class$3(ParticleMaterial, [
31681
+ /**
31682
+ * @internal
31683
+ */ _proto._prepareRender = function _prepareRender(context) {
31684
+ if (!this._supportInstancedArrays) {
31685
+ return;
31686
+ }
31687
+ var generator = this.generator;
31688
+ generator._update(this.engine.time.deltaTime);
31689
+ // No particles to render
31690
+ if (generator._firstActiveElement === generator._firstFreeElement) {
31691
+ return;
31692
+ }
31693
+ Renderer1.prototype._prepareRender.call(this, context);
31694
+ };
31695
+ /**
31696
+ * @internal
31697
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
31698
+ worldBounds.min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
31699
+ worldBounds.max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
31700
+ };
31701
+ /**
31702
+ * @internal
31703
+ */ _proto._updateShaderData = function _updateShaderData(context) {
31704
+ var shaderData = this.shaderData;
31705
+ shaderData.setFloat(ParticleRenderer._lengthScale, this.lengthScale);
31706
+ shaderData.setFloat(ParticleRenderer._speedScale, this.velocityScale);
31707
+ shaderData.setFloat(ParticleRenderer._currentTime, this.generator._playTime);
31708
+ shaderData.setVector3(ParticleRenderer._pivotOffsetProperty, this.pivot);
31709
+ this.generator._updateShaderData(shaderData);
31710
+ };
31711
+ _proto._render = function _render(context) {
31712
+ var generator = this.generator;
31713
+ var primitive = generator._primitive;
31714
+ if (generator._firstActiveElement < generator._firstFreeElement) {
31715
+ primitive.instanceCount = generator._firstFreeElement - generator._firstActiveElement;
31716
+ } else {
31717
+ var instanceCount = generator._currentParticleCount - generator._firstActiveElement;
31718
+ if (generator._firstFreeElement > 0) {
31719
+ instanceCount += generator._firstFreeElement;
31720
+ }
31721
+ primitive.instanceCount = instanceCount;
31722
+ }
31723
+ var material = this.getMaterial();
31724
+ var renderData = this._engine._renderDataPool.getFromPool();
31725
+ renderData.setX(this, material, generator._primitive, generator._subPrimitive);
31726
+ context.camera._renderPipeline.pushRenderData(context, renderData);
31727
+ };
31728
+ _proto._onDestroy = function _onDestroy() {
31729
+ this.generator._destroy();
31730
+ };
31731
+ _create_class$3(ParticleRenderer, [
31657
31732
  {
31658
- key: "baseColor",
31733
+ key: "renderMode",
31659
31734
  get: /**
31660
- * Base color.
31735
+ * Specifies how particles are rendered.
31661
31736
  */ function get() {
31662
- return this.shaderData.getColor(BaseMaterial._baseColorProp);
31737
+ return this._renderMode;
31663
31738
  },
31664
31739
  set: function set(value) {
31665
- var baseColor = this.shaderData.getColor(BaseMaterial._baseColorProp);
31666
- if (value !== baseColor) {
31667
- baseColor.copyFrom(value);
31740
+ if (this._renderMode !== value) {
31741
+ var lastRenderMode = this._renderMode;
31742
+ this._renderMode = value;
31743
+ var renderModeMacro = null;
31744
+ var shaderData = this.shaderData;
31745
+ switch(value){
31746
+ case exports.ParticleRenderMode.Billboard:
31747
+ renderModeMacro = ParticleRenderer._billboardModeMacro;
31748
+ break;
31749
+ case exports.ParticleRenderMode.StretchBillboard:
31750
+ renderModeMacro = ParticleRenderer._stretchedBillboardModeMacro;
31751
+ break;
31752
+ case exports.ParticleRenderMode.HorizontalBillboard:
31753
+ throw "Not implemented";
31754
+ case exports.ParticleRenderMode.VerticalBillboard:
31755
+ throw "Not implemented";
31756
+ case exports.ParticleRenderMode.Mesh:
31757
+ throw "Not implemented";
31758
+ }
31759
+ if (this._currentRenderModeMacro !== renderModeMacro) {
31760
+ this._currentRenderModeMacro && shaderData.disableMacro(this._currentRenderModeMacro);
31761
+ renderModeMacro && shaderData.enableMacro(renderModeMacro);
31762
+ this._currentRenderModeMacro = renderModeMacro;
31763
+ }
31764
+ // @ts-ignore
31765
+ if (lastRenderMode !== exports.ParticleRenderMode.Mesh !== (value === exports.ParticleRenderMode.Mesh)) {
31766
+ this.generator._reorganizeGeometryBuffers();
31767
+ }
31668
31768
  }
31669
31769
  }
31670
31770
  },
31671
31771
  {
31672
- key: "baseTexture",
31772
+ key: "mesh",
31673
31773
  get: /**
31674
- * Base texture.
31774
+ * The mesh of particle.
31775
+ * @remarks Valid when `renderMode` is `Mesh`.
31675
31776
  */ function get() {
31676
- return this.shaderData.getTexture(BaseMaterial._baseTextureProp);
31777
+ return this._mesh;
31677
31778
  },
31678
31779
  set: function set(value) {
31679
- this.shaderData.setTexture(BaseMaterial._baseTextureProp, value);
31680
- if (value) {
31681
- this.shaderData.enableMacro(BaseMaterial._baseTextureMacro);
31682
- } else {
31683
- this.shaderData.disableMacro(BaseMaterial._baseTextureMacro);
31780
+ var lastMesh = this._mesh;
31781
+ if (lastMesh !== value) {
31782
+ var _lastMesh, _value;
31783
+ this._mesh = value;
31784
+ (_lastMesh = lastMesh) == null ? void 0 : _lastMesh._addReferCount(-1);
31785
+ (_value = value) == null ? void 0 : _value._addReferCount(1);
31786
+ if (this.renderMode === exports.ParticleRenderMode.Mesh) {
31787
+ this.generator._reorganizeGeometryBuffers();
31788
+ }
31684
31789
  }
31685
31790
  }
31686
31791
  }
31687
31792
  ]);
31688
- return ParticleMaterial;
31689
- }(BaseMaterial);
31690
- var SubPrimitive = function SubPrimitive() {};
31793
+ return ParticleRenderer;
31794
+ }(exports.Renderer);
31795
+ (function() {
31796
+ ParticleRenderer._billboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_SPHERE_BILLBOARD");
31797
+ })();
31798
+ (function() {
31799
+ ParticleRenderer._stretchedBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_STRETCHED_BILLBOARD");
31800
+ })();
31801
+ (function() {
31802
+ ParticleRenderer._horizontalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD");
31803
+ })();
31804
+ (function() {
31805
+ ParticleRenderer._verticalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_VERTICAL_BILLBOARD");
31806
+ })();
31807
+ (function() {
31808
+ ParticleRenderer._renderModeMeshMacro = ShaderMacro.getByName("RENDERER_MODE_MESH");
31809
+ })();
31810
+ (function() {
31811
+ ParticleRenderer._pivotOffsetProperty = ShaderProperty.getByName("renderer_PivotOffset");
31812
+ })();
31813
+ (function() {
31814
+ ParticleRenderer._lengthScale = ShaderProperty.getByName("renderer_StretchedBillboardLengthScale");
31815
+ })();
31816
+ (function() {
31817
+ ParticleRenderer._speedScale = ShaderProperty.getByName("renderer_StretchedBillboardSpeedScale");
31818
+ })();
31819
+ (function() {
31820
+ ParticleRenderer._currentTime = ShaderProperty.getByName("renderer_CurrentTime");
31821
+ })();
31822
+ __decorate$1([
31823
+ deepClone
31824
+ ], ParticleRenderer.prototype, "generator", void 0);
31825
+ __decorate$1([
31826
+ shallowClone
31827
+ ], ParticleRenderer.prototype, "pivot", void 0);
31691
31828
  /**
31692
31829
  * Particle curve mode.
31693
31830
  */ exports.ParticleCurveMode = void 0;
@@ -31706,17 +31843,6 @@
31706
31843
  ParticleGradientMode[ParticleGradientMode[/* Single color gradient curve mode. */ "Gradient"] = 2] = "Gradient";
31707
31844
  ParticleGradientMode[ParticleGradientMode[/* Random value between two color gradients. */ "TwoGradients"] = 3] = "TwoGradients";
31708
31845
  })(exports.ParticleGradientMode || (exports.ParticleGradientMode = {}));
31709
- /**
31710
- * The rendering mode for particle renderer.
31711
- */ exports.ParticleRenderMode = void 0;
31712
- (function(ParticleRenderMode) {
31713
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards facing the active camera. */ "Billboard"] = 0] = "Billboard";
31714
- ParticleRenderMode[ParticleRenderMode[/** Stretch particles in the direction of motion. */ "StretchBillboard"] = 1] = "StretchBillboard";
31715
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing up along the y-Axis. */ "HorizontalBillboard"] = 2] = "HorizontalBillboard";
31716
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing the player, but not pitching along the x-Axis. */ "VerticalBillboard"] = 3] = "VerticalBillboard";
31717
- ParticleRenderMode[ParticleRenderMode[/** Render particles as meshes. */ "Mesh"] = 4] = "Mesh";
31718
- ParticleRenderMode[ParticleRenderMode[/** Do not render particles. */ "None"] = 5] = "None";
31719
- })(exports.ParticleRenderMode || (exports.ParticleRenderMode = {}));
31720
31846
  /**
31721
31847
  * The space to simulate particles in.
31722
31848
  */ exports.ParticleSimulationSpace = void 0;
@@ -31724,11 +31850,6 @@
31724
31850
  ParticleSimulationSpace[ParticleSimulationSpace[/** Simulate particles in local space. */ "Local"] = 0] = "Local";
31725
31851
  ParticleSimulationSpace[ParticleSimulationSpace[/** Simulate particles in world space. */ "World"] = 1] = "World";
31726
31852
  })(exports.ParticleSimulationSpace || (exports.ParticleSimulationSpace = {}));
31727
- exports.ParticleStopMode = void 0;
31728
- (function(ParticleStopMode) {
31729
- ParticleStopMode[ParticleStopMode[/** Stop emitting new particles and clear existing particles immediately. */ "StopEmittingAndClear"] = 0] = "StopEmittingAndClear";
31730
- ParticleStopMode[ParticleStopMode[/** Stop emitting new particles, but keep existing particles until they expire. */ "StopEmitting"] = 1] = "StopEmitting";
31731
- })(exports.ParticleStopMode || (exports.ParticleStopMode = {}));
31732
31853
  /**
31733
31854
  * @internal
31734
31855
  */ var ParticleRandomSubSeeds;
@@ -33664,181 +33785,60 @@
33664
33785
  ignoreClone
33665
33786
  ], ParticleGenerator.prototype, "_instanceVertices", void 0);
33666
33787
  /**
33667
- * Particle Renderer Component.
33668
- */ var ParticleRenderer = /*#__PURE__*/ function(Renderer1) {
33669
- _inherits$2(ParticleRenderer, Renderer1);
33670
- function ParticleRenderer(entity) {
33788
+ * Particle Material.
33789
+ */ var ParticleMaterial = /*#__PURE__*/ function(BaseMaterial1) {
33790
+ var ParticleMaterial = function ParticleMaterial(engine) {
33671
33791
  var _this;
33672
- _this = Renderer1.call(this, entity) || this;
33673
- /** Particle generator. */ _this.generator = new ParticleGenerator(_assert_this_initialized(_this));
33674
- /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0;
33675
- /** How much are the particles stretched in their direction of motion, defined as the length of the particle compared to its width. */ _this.lengthScale = 2;
33676
- /** The pivot of particle. */ _this.pivot = new Vector3();
33677
- _this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
33678
- _this.shaderData.enableMacro(ParticleRenderer._billboardModeMacro);
33679
- _this._supportInstancedArrays = _this.engine._hardwareRenderer.canIUse(exports.GLCapabilityType.instancedArrays);
33792
+ _this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
33793
+ var shaderData = _this.shaderData;
33794
+ shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
33795
+ shaderData.setColor(BaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
33796
+ _this.isTransparent = true;
33680
33797
  return _this;
33681
- }
33682
- var _proto = ParticleRenderer.prototype;
33683
- /**
33684
- * @internal
33685
- */ _proto._onEnable = function _onEnable() {
33686
- if (this.generator.main.playOnEnabled) {
33687
- this.generator.play(false);
33688
- }
33689
- };
33690
- /**
33691
- * @internal
33692
- */ _proto._onDisable = function _onDisable() {
33693
- this.generator.stop(false, exports.ParticleStopMode.StopEmittingAndClear);
33694
- };
33695
- /**
33696
- * @internal
33697
- */ _proto._prepareRender = function _prepareRender(context) {
33698
- if (!this._supportInstancedArrays) {
33699
- return;
33700
- }
33701
- var generator = this.generator;
33702
- generator._update(this.engine.time.deltaTime);
33703
- // No particles to render
33704
- if (generator._firstActiveElement === generator._firstFreeElement) {
33705
- return;
33706
- }
33707
- Renderer1.prototype._prepareRender.call(this, context);
33708
- };
33709
- /**
33710
- * @internal
33711
- */ _proto._updateBounds = function _updateBounds(worldBounds) {
33712
- worldBounds.min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
33713
- worldBounds.max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
33714
33798
  };
33799
+ _inherits$2(ParticleMaterial, BaseMaterial1);
33800
+ var _proto = ParticleMaterial.prototype;
33715
33801
  /**
33716
- * @internal
33717
- */ _proto._updateShaderData = function _updateShaderData(context) {
33718
- var shaderData = this.shaderData;
33719
- shaderData.setFloat(ParticleRenderer._lengthScale, this.lengthScale);
33720
- shaderData.setFloat(ParticleRenderer._speedScale, this.velocityScale);
33721
- shaderData.setFloat(ParticleRenderer._currentTime, this.generator._playTime);
33722
- shaderData.setVector3(ParticleRenderer._pivotOffsetProperty, this.pivot);
33723
- this.generator._updateShaderData(shaderData);
33724
- };
33725
- _proto._render = function _render(context) {
33726
- var generator = this.generator;
33727
- var primitive = generator._primitive;
33728
- if (generator._firstActiveElement < generator._firstFreeElement) {
33729
- primitive.instanceCount = generator._firstFreeElement - generator._firstActiveElement;
33730
- } else {
33731
- var instanceCount = generator._currentParticleCount - generator._firstActiveElement;
33732
- if (generator._firstFreeElement > 0) {
33733
- instanceCount += generator._firstFreeElement;
33734
- }
33735
- primitive.instanceCount = instanceCount;
33736
- }
33737
- var material = this.getMaterial();
33738
- var renderData = this._engine._renderDataPool.getFromPool();
33739
- renderData.setX(this, material, generator._primitive, generator._subPrimitive);
33740
- context.camera._renderPipeline.pushRenderData(context, renderData);
33741
- };
33742
- _proto._onDestroy = function _onDestroy() {
33743
- this.generator._destroy();
33802
+ * @inheritdoc
33803
+ */ _proto.clone = function clone() {
33804
+ var dest = new ParticleMaterial(this._engine);
33805
+ this.cloneTo(dest);
33806
+ return dest;
33744
33807
  };
33745
- _create_class$3(ParticleRenderer, [
33808
+ _create_class$3(ParticleMaterial, [
33746
33809
  {
33747
- key: "renderMode",
33810
+ key: "baseColor",
33748
33811
  get: /**
33749
- * Specifies how particles are rendered.
33812
+ * Base color.
33750
33813
  */ function get() {
33751
- return this._renderMode;
33814
+ return this.shaderData.getColor(BaseMaterial._baseColorProp);
33752
33815
  },
33753
33816
  set: function set(value) {
33754
- if (this._renderMode !== value) {
33755
- var lastRenderMode = this._renderMode;
33756
- this._renderMode = value;
33757
- var renderModeMacro = null;
33758
- var shaderData = this.shaderData;
33759
- switch(value){
33760
- case exports.ParticleRenderMode.Billboard:
33761
- renderModeMacro = ParticleRenderer._billboardModeMacro;
33762
- break;
33763
- case exports.ParticleRenderMode.StretchBillboard:
33764
- renderModeMacro = ParticleRenderer._stretchedBillboardModeMacro;
33765
- break;
33766
- case exports.ParticleRenderMode.HorizontalBillboard:
33767
- throw "Not implemented";
33768
- case exports.ParticleRenderMode.VerticalBillboard:
33769
- throw "Not implemented";
33770
- case exports.ParticleRenderMode.Mesh:
33771
- throw "Not implemented";
33772
- }
33773
- if (this._currentRenderModeMacro !== renderModeMacro) {
33774
- this._currentRenderModeMacro && shaderData.disableMacro(this._currentRenderModeMacro);
33775
- renderModeMacro && shaderData.enableMacro(renderModeMacro);
33776
- this._currentRenderModeMacro = renderModeMacro;
33777
- }
33778
- // @ts-ignore
33779
- if (lastRenderMode !== exports.ParticleRenderMode.Mesh !== (value === exports.ParticleRenderMode.Mesh)) {
33780
- this.generator._reorganizeGeometryBuffers();
33781
- }
33817
+ var baseColor = this.shaderData.getColor(BaseMaterial._baseColorProp);
33818
+ if (value !== baseColor) {
33819
+ baseColor.copyFrom(value);
33782
33820
  }
33783
33821
  }
33784
33822
  },
33785
33823
  {
33786
- key: "mesh",
33824
+ key: "baseTexture",
33787
33825
  get: /**
33788
- * The mesh of particle.
33789
- * @remarks Valid when `renderMode` is `Mesh`.
33826
+ * Base texture.
33790
33827
  */ function get() {
33791
- return this._mesh;
33828
+ return this.shaderData.getTexture(BaseMaterial._baseTextureProp);
33792
33829
  },
33793
33830
  set: function set(value) {
33794
- var lastMesh = this._mesh;
33795
- if (lastMesh !== value) {
33796
- var _lastMesh, _value;
33797
- this._mesh = value;
33798
- (_lastMesh = lastMesh) == null ? void 0 : _lastMesh._addReferCount(-1);
33799
- (_value = value) == null ? void 0 : _value._addReferCount(1);
33800
- if (this.renderMode === exports.ParticleRenderMode.Mesh) {
33801
- this.generator._reorganizeGeometryBuffers();
33802
- }
33831
+ this.shaderData.setTexture(BaseMaterial._baseTextureProp, value);
33832
+ if (value) {
33833
+ this.shaderData.enableMacro(BaseMaterial._baseTextureMacro);
33834
+ } else {
33835
+ this.shaderData.disableMacro(BaseMaterial._baseTextureMacro);
33803
33836
  }
33804
33837
  }
33805
33838
  }
33806
33839
  ]);
33807
- return ParticleRenderer;
33808
- }(exports.Renderer);
33809
- (function() {
33810
- ParticleRenderer._billboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_SPHERE_BILLBOARD");
33811
- })();
33812
- (function() {
33813
- ParticleRenderer._stretchedBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_STRETCHED_BILLBOARD");
33814
- })();
33815
- (function() {
33816
- ParticleRenderer._horizontalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD");
33817
- })();
33818
- (function() {
33819
- ParticleRenderer._verticalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_VERTICAL_BILLBOARD");
33820
- })();
33821
- (function() {
33822
- ParticleRenderer._renderModeMeshMacro = ShaderMacro.getByName("RENDERER_MODE_MESH");
33823
- })();
33824
- (function() {
33825
- ParticleRenderer._pivotOffsetProperty = ShaderProperty.getByName("renderer_PivotOffset");
33826
- })();
33827
- (function() {
33828
- ParticleRenderer._lengthScale = ShaderProperty.getByName("renderer_StretchedBillboardLengthScale");
33829
- })();
33830
- (function() {
33831
- ParticleRenderer._speedScale = ShaderProperty.getByName("renderer_StretchedBillboardSpeedScale");
33832
- })();
33833
- (function() {
33834
- ParticleRenderer._currentTime = ShaderProperty.getByName("renderer_CurrentTime");
33835
- })();
33836
- __decorate$1([
33837
- deepClone
33838
- ], ParticleRenderer.prototype, "generator", void 0);
33839
- __decorate$1([
33840
- shallowClone
33841
- ], ParticleRenderer.prototype, "pivot", void 0);
33840
+ return ParticleMaterial;
33841
+ }(BaseMaterial);
33842
33842
  /**
33843
33843
  * A burst is a particle emission event, where a number of particles are all emitted at the same time
33844
33844
  */ var Burst = function Burst(time, count) {
@@ -34580,6 +34580,7 @@
34580
34580
  ParticleCompositeCurve: ParticleCompositeCurve,
34581
34581
  ParticleCurve: ParticleCurve,
34582
34582
  get ParticleCurveMode () { return exports.ParticleCurveMode; },
34583
+ ParticleGenerator: ParticleGenerator,
34583
34584
  get ParticleGradientMode () { return exports.ParticleGradientMode; },
34584
34585
  ParticleMaterial: ParticleMaterial,
34585
34586
  get ParticleRenderMode () { return exports.ParticleRenderMode; },
@@ -42996,7 +42997,7 @@
42996
42997
  ], GALACEAN_animation_event);
42997
42998
 
42998
42999
  //@ts-ignore
42999
- var version = "1.1.0-beta.5";
43000
+ var version = "1.1.0-beta.6";
43000
43001
  console.log("Galacean engine version: " + version);
43001
43002
  for(var key in CoreObjects){
43002
43003
  Loader.registerClass(key, CoreObjects[key]);
@@ -43082,6 +43083,7 @@
43082
43083
  exports.PBRSpecularMaterial = PBRSpecularMaterial;
43083
43084
  exports.ParticleCompositeCurve = ParticleCompositeCurve;
43084
43085
  exports.ParticleCurve = ParticleCurve;
43086
+ exports.ParticleGenerator = ParticleGenerator;
43085
43087
  exports.ParticleMaterial = ParticleMaterial;
43086
43088
  exports.ParticleRenderer = ParticleRenderer;
43087
43089
  exports.PhysicsMaterial = PhysicsMaterial;