@galacean/engine-core 1.1.0-beta.5 → 1.1.0-beta.7

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
@@ -15742,8 +15742,8 @@ Joint = __decorate([
15742
15742
  continue;
15743
15743
  }
15744
15744
  var cameras = scene._activeCameras;
15745
- for(var j = 0; j < cameras.length; j++){
15746
- var camera = cameras[i];
15745
+ for(var j = cameras.length - 1; j >= 0; j--){
15746
+ var camera = cameras[j];
15747
15747
  if (!camera.enabled || camera.renderTarget) {
15748
15748
  continue;
15749
15749
  }
@@ -17058,24 +17058,23 @@ ShaderPool.init();
17058
17058
  /**
17059
17059
  * @internal
17060
17060
  */ _proto.destroy = function destroy() {
17061
+ this.texture = null;
17061
17062
  this._mesh._addReferCount(-1);
17062
17063
  this._mesh = null;
17063
17064
  this._material._addReferCount(-1);
17064
17065
  this._material = null;
17065
- this.texture = null;
17066
17066
  this.solidColor = null;
17067
17067
  this.sky.destroy();
17068
17068
  };
17069
17069
  /**
17070
17070
  * @internal
17071
17071
  */ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
17072
+ var _this = this, texture = _this._texture, mesh = _this._mesh;
17072
17073
  if (!this._texture) {
17073
17074
  return;
17074
17075
  }
17075
- var canvas = this._engine.canvas;
17076
- var width = canvas.width, height = canvas.height;
17077
- var _this = this, _backgroundTextureMesh = _this._mesh;
17078
- var positions = _backgroundTextureMesh.getPositions();
17076
+ var _this__engine_canvas = this._engine.canvas, width = _this__engine_canvas.width, height = _this__engine_canvas.height;
17077
+ var positions = mesh.getPositions();
17079
17078
  switch(this._textureFillMode){
17080
17079
  case BackgroundTextureFillMode.Fill:
17081
17080
  positions[0].set(-1, -1, 1);
@@ -17084,22 +17083,22 @@ ShaderPool.init();
17084
17083
  positions[3].set(1, 1, 1);
17085
17084
  break;
17086
17085
  case BackgroundTextureFillMode.AspectFitWidth:
17087
- var fitWidthScale = this._texture.height * width / this.texture.width / height;
17086
+ var fitWidthScale = texture.height * width / texture.width / height;
17088
17087
  positions[0].set(-1, -fitWidthScale, 1);
17089
17088
  positions[1].set(1, -fitWidthScale, 1);
17090
17089
  positions[2].set(-1, fitWidthScale, 1);
17091
17090
  positions[3].set(1, fitWidthScale, 1);
17092
17091
  break;
17093
17092
  case BackgroundTextureFillMode.AspectFitHeight:
17094
- var fitHeightScale = this._texture.width * height / this.texture.height / width;
17093
+ var fitHeightScale = texture.width * height / texture.height / width;
17095
17094
  positions[0].set(-fitHeightScale, -1, 1);
17096
17095
  positions[1].set(fitHeightScale, -1, 1);
17097
17096
  positions[2].set(-fitHeightScale, 1, 1);
17098
17097
  positions[3].set(fitHeightScale, 1, 1);
17099
17098
  break;
17100
17099
  }
17101
- _backgroundTextureMesh.setPositions(positions);
17102
- _backgroundTextureMesh.uploadData(false);
17100
+ mesh.setPositions(positions);
17101
+ mesh.uploadData(false);
17103
17102
  };
17104
17103
  _proto._initMesh = function _initMesh(engine) {
17105
17104
  this._mesh = this._createPlane(engine);
@@ -17150,13 +17149,13 @@ ShaderPool.init();
17150
17149
  (_this__texture = this._texture) == null ? void 0 : _this__texture._addReferCount(-1);
17151
17150
  this._texture = value;
17152
17151
  this._material.shaderData.setTexture("material_BaseTexture", value);
17152
+ this._resizeBackgroundTexture();
17153
17153
  }
17154
17154
  }
17155
17155
  },
17156
17156
  {
17157
17157
  key: "textureFillMode",
17158
17158
  get: /**
17159
- * @internal
17160
17159
  * Background texture fill mode.
17161
17160
  * @remarks When `mode` is `BackgroundMode.Texture`, the property will take effects.
17162
17161
  * @defaultValue `BackgroundTextureFillMode.FitHeight`
@@ -17307,7 +17306,7 @@ ShaderPool.init();
17307
17306
  var _this = this, pendingDestroyScripts = _this._disposeDestroyScripts, disposeDestroyScripts = _this._pendingDestroyScripts;
17308
17307
  this._disposeDestroyScripts = disposeDestroyScripts;
17309
17308
  this._pendingDestroyScripts = pendingDestroyScripts;
17310
- length = disposeDestroyScripts.length;
17309
+ var length = disposeDestroyScripts.length;
17311
17310
  if (length > 0) {
17312
17311
  for(var i = length - 1; i >= 0; i--){
17313
17312
  disposeDestroyScripts[i].onDestroy();
@@ -27027,64 +27026,203 @@ var SunMode;
27027
27026
  SkyProceduralMaterial._sunSimpleMacro = ShaderMacro.getByName("MATERIAL_SUN_SIMPLE");
27028
27027
  })();
27029
27028
 
27029
+ var SubPrimitive = function SubPrimitive() {
27030
+ };
27031
+
27030
27032
  /**
27031
- * Particle Material.
27032
- */ var ParticleMaterial = /*#__PURE__*/ function(BaseMaterial1) {
27033
- _inherits(ParticleMaterial, BaseMaterial1);
27034
- function ParticleMaterial(engine) {
27033
+ * The rendering mode for particle renderer.
27034
+ */ var ParticleRenderMode;
27035
+ (function(ParticleRenderMode) {
27036
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards facing the active camera. */ "Billboard"] = 0] = "Billboard";
27037
+ ParticleRenderMode[ParticleRenderMode[/** Stretch particles in the direction of motion. */ "StretchBillboard"] = 1] = "StretchBillboard";
27038
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing up along the y-Axis. */ "HorizontalBillboard"] = 2] = "HorizontalBillboard";
27039
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing the player, but not pitching along the x-Axis. */ "VerticalBillboard"] = 3] = "VerticalBillboard";
27040
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as meshes. */ "Mesh"] = 4] = "Mesh";
27041
+ ParticleRenderMode[ParticleRenderMode[/** Do not render particles. */ "None"] = 5] = "None";
27042
+ })(ParticleRenderMode || (ParticleRenderMode = {}));
27043
+
27044
+ var ParticleStopMode;
27045
+ (function(ParticleStopMode) {
27046
+ ParticleStopMode[ParticleStopMode[/** Stop emitting new particles and clear existing particles immediately. */ "StopEmittingAndClear"] = 0] = "StopEmittingAndClear";
27047
+ ParticleStopMode[ParticleStopMode[/** Stop emitting new particles, but keep existing particles until they expire. */ "StopEmitting"] = 1] = "StopEmitting";
27048
+ })(ParticleStopMode || (ParticleStopMode = {}));
27049
+
27050
+ /**
27051
+ * Particle Renderer Component.
27052
+ */ var ParticleRenderer = /*#__PURE__*/ function(Renderer1) {
27053
+ _inherits(ParticleRenderer, Renderer1);
27054
+ function ParticleRenderer(entity) {
27035
27055
  var _this;
27036
- _this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
27037
- var shaderData = _this.shaderData;
27038
- shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
27039
- shaderData.setColor(BaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
27040
- _this.isTransparent = true;
27056
+ _this = Renderer1.call(this, entity) || this;
27057
+ /** Particle generator. */ _this.generator = new ParticleGenerator(_assert_this_initialized(_this));
27058
+ /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0;
27059
+ /** 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;
27060
+ /** The pivot of particle. */ _this.pivot = new Vector3();
27061
+ _this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
27062
+ _this.shaderData.enableMacro(ParticleRenderer._billboardModeMacro);
27063
+ _this._supportInstancedArrays = _this.engine._hardwareRenderer.canIUse(GLCapabilityType.instancedArrays);
27041
27064
  return _this;
27042
27065
  }
27043
- var _proto = ParticleMaterial.prototype;
27066
+ var _proto = ParticleRenderer.prototype;
27044
27067
  /**
27045
- * @inheritdoc
27046
- */ _proto.clone = function clone() {
27047
- var dest = new ParticleMaterial(this._engine);
27048
- this.cloneTo(dest);
27049
- return dest;
27068
+ * @internal
27069
+ */ _proto._onEnable = function _onEnable() {
27070
+ if (this.generator.main.playOnEnabled) {
27071
+ this.generator.play(false);
27072
+ }
27050
27073
  };
27051
- _create_class(ParticleMaterial, [
27074
+ /**
27075
+ * @internal
27076
+ */ _proto._onDisable = function _onDisable() {
27077
+ this.generator.stop(false, ParticleStopMode.StopEmittingAndClear);
27078
+ };
27079
+ /**
27080
+ * @internal
27081
+ */ _proto._prepareRender = function _prepareRender(context) {
27082
+ if (!this._supportInstancedArrays) {
27083
+ return;
27084
+ }
27085
+ var generator = this.generator;
27086
+ generator._update(this.engine.time.deltaTime);
27087
+ // No particles to render
27088
+ if (generator._firstActiveElement === generator._firstFreeElement) {
27089
+ return;
27090
+ }
27091
+ Renderer1.prototype._prepareRender.call(this, context);
27092
+ };
27093
+ /**
27094
+ * @internal
27095
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
27096
+ worldBounds.min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
27097
+ worldBounds.max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
27098
+ };
27099
+ /**
27100
+ * @internal
27101
+ */ _proto._updateShaderData = function _updateShaderData(context) {
27102
+ var shaderData = this.shaderData;
27103
+ shaderData.setFloat(ParticleRenderer._lengthScale, this.lengthScale);
27104
+ shaderData.setFloat(ParticleRenderer._speedScale, this.velocityScale);
27105
+ shaderData.setFloat(ParticleRenderer._currentTime, this.generator._playTime);
27106
+ shaderData.setVector3(ParticleRenderer._pivotOffsetProperty, this.pivot);
27107
+ this.generator._updateShaderData(shaderData);
27108
+ };
27109
+ _proto._render = function _render(context) {
27110
+ var generator = this.generator;
27111
+ var primitive = generator._primitive;
27112
+ if (generator._firstActiveElement < generator._firstFreeElement) {
27113
+ primitive.instanceCount = generator._firstFreeElement - generator._firstActiveElement;
27114
+ } else {
27115
+ var instanceCount = generator._currentParticleCount - generator._firstActiveElement;
27116
+ if (generator._firstFreeElement > 0) {
27117
+ instanceCount += generator._firstFreeElement;
27118
+ }
27119
+ primitive.instanceCount = instanceCount;
27120
+ }
27121
+ var material = this.getMaterial();
27122
+ var renderData = this._engine._renderDataPool.getFromPool();
27123
+ renderData.setX(this, material, generator._primitive, generator._subPrimitive);
27124
+ context.camera._renderPipeline.pushRenderData(context, renderData);
27125
+ };
27126
+ _proto._onDestroy = function _onDestroy() {
27127
+ this.generator._destroy();
27128
+ };
27129
+ _create_class(ParticleRenderer, [
27052
27130
  {
27053
- key: "baseColor",
27131
+ key: "renderMode",
27054
27132
  get: /**
27055
- * Base color.
27133
+ * Specifies how particles are rendered.
27056
27134
  */ function get() {
27057
- return this.shaderData.getColor(BaseMaterial._baseColorProp);
27135
+ return this._renderMode;
27058
27136
  },
27059
27137
  set: function set(value) {
27060
- var baseColor = this.shaderData.getColor(BaseMaterial._baseColorProp);
27061
- if (value !== baseColor) {
27062
- baseColor.copyFrom(value);
27138
+ if (this._renderMode !== value) {
27139
+ var lastRenderMode = this._renderMode;
27140
+ this._renderMode = value;
27141
+ var renderModeMacro = null;
27142
+ var shaderData = this.shaderData;
27143
+ switch(value){
27144
+ case ParticleRenderMode.Billboard:
27145
+ renderModeMacro = ParticleRenderer._billboardModeMacro;
27146
+ break;
27147
+ case ParticleRenderMode.StretchBillboard:
27148
+ renderModeMacro = ParticleRenderer._stretchedBillboardModeMacro;
27149
+ break;
27150
+ case ParticleRenderMode.HorizontalBillboard:
27151
+ throw "Not implemented";
27152
+ case ParticleRenderMode.VerticalBillboard:
27153
+ throw "Not implemented";
27154
+ case ParticleRenderMode.Mesh:
27155
+ throw "Not implemented";
27156
+ }
27157
+ if (this._currentRenderModeMacro !== renderModeMacro) {
27158
+ this._currentRenderModeMacro && shaderData.disableMacro(this._currentRenderModeMacro);
27159
+ renderModeMacro && shaderData.enableMacro(renderModeMacro);
27160
+ this._currentRenderModeMacro = renderModeMacro;
27161
+ }
27162
+ // @ts-ignore
27163
+ if (lastRenderMode !== ParticleRenderMode.Mesh !== (value === ParticleRenderMode.Mesh)) {
27164
+ this.generator._reorganizeGeometryBuffers();
27165
+ }
27063
27166
  }
27064
27167
  }
27065
27168
  },
27066
27169
  {
27067
- key: "baseTexture",
27170
+ key: "mesh",
27068
27171
  get: /**
27069
- * Base texture.
27172
+ * The mesh of particle.
27173
+ * @remarks Valid when `renderMode` is `Mesh`.
27070
27174
  */ function get() {
27071
- return this.shaderData.getTexture(BaseMaterial._baseTextureProp);
27175
+ return this._mesh;
27072
27176
  },
27073
27177
  set: function set(value) {
27074
- this.shaderData.setTexture(BaseMaterial._baseTextureProp, value);
27075
- if (value) {
27076
- this.shaderData.enableMacro(BaseMaterial._baseTextureMacro);
27077
- } else {
27078
- this.shaderData.disableMacro(BaseMaterial._baseTextureMacro);
27178
+ var lastMesh = this._mesh;
27179
+ if (lastMesh !== value) {
27180
+ var _lastMesh, _value;
27181
+ this._mesh = value;
27182
+ (_lastMesh = lastMesh) == null ? void 0 : _lastMesh._addReferCount(-1);
27183
+ (_value = value) == null ? void 0 : _value._addReferCount(1);
27184
+ if (this.renderMode === ParticleRenderMode.Mesh) {
27185
+ this.generator._reorganizeGeometryBuffers();
27186
+ }
27079
27187
  }
27080
27188
  }
27081
27189
  }
27082
27190
  ]);
27083
- return ParticleMaterial;
27084
- }(BaseMaterial);
27085
-
27086
- var SubPrimitive = function SubPrimitive() {
27087
- };
27191
+ return ParticleRenderer;
27192
+ }(Renderer);
27193
+ (function() {
27194
+ ParticleRenderer._billboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_SPHERE_BILLBOARD");
27195
+ })();
27196
+ (function() {
27197
+ ParticleRenderer._stretchedBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_STRETCHED_BILLBOARD");
27198
+ })();
27199
+ (function() {
27200
+ ParticleRenderer._horizontalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD");
27201
+ })();
27202
+ (function() {
27203
+ ParticleRenderer._verticalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_VERTICAL_BILLBOARD");
27204
+ })();
27205
+ (function() {
27206
+ ParticleRenderer._renderModeMeshMacro = ShaderMacro.getByName("RENDERER_MODE_MESH");
27207
+ })();
27208
+ (function() {
27209
+ ParticleRenderer._pivotOffsetProperty = ShaderProperty.getByName("renderer_PivotOffset");
27210
+ })();
27211
+ (function() {
27212
+ ParticleRenderer._lengthScale = ShaderProperty.getByName("renderer_StretchedBillboardLengthScale");
27213
+ })();
27214
+ (function() {
27215
+ ParticleRenderer._speedScale = ShaderProperty.getByName("renderer_StretchedBillboardSpeedScale");
27216
+ })();
27217
+ (function() {
27218
+ ParticleRenderer._currentTime = ShaderProperty.getByName("renderer_CurrentTime");
27219
+ })();
27220
+ __decorate([
27221
+ deepClone
27222
+ ], ParticleRenderer.prototype, "generator", void 0);
27223
+ __decorate([
27224
+ shallowClone
27225
+ ], ParticleRenderer.prototype, "pivot", void 0);
27088
27226
 
27089
27227
  /**
27090
27228
  * Particle curve mode.
@@ -27106,18 +27244,6 @@ var SubPrimitive = function SubPrimitive() {
27106
27244
  ParticleGradientMode[ParticleGradientMode[/* Random value between two color gradients. */ "TwoGradients"] = 3] = "TwoGradients";
27107
27245
  })(ParticleGradientMode || (ParticleGradientMode = {}));
27108
27246
 
27109
- /**
27110
- * The rendering mode for particle renderer.
27111
- */ var ParticleRenderMode;
27112
- (function(ParticleRenderMode) {
27113
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards facing the active camera. */ "Billboard"] = 0] = "Billboard";
27114
- ParticleRenderMode[ParticleRenderMode[/** Stretch particles in the direction of motion. */ "StretchBillboard"] = 1] = "StretchBillboard";
27115
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing up along the y-Axis. */ "HorizontalBillboard"] = 2] = "HorizontalBillboard";
27116
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing the player, but not pitching along the x-Axis. */ "VerticalBillboard"] = 3] = "VerticalBillboard";
27117
- ParticleRenderMode[ParticleRenderMode[/** Render particles as meshes. */ "Mesh"] = 4] = "Mesh";
27118
- ParticleRenderMode[ParticleRenderMode[/** Do not render particles. */ "None"] = 5] = "None";
27119
- })(ParticleRenderMode || (ParticleRenderMode = {}));
27120
-
27121
27247
  /**
27122
27248
  * The space to simulate particles in.
27123
27249
  */ var ParticleSimulationSpace;
@@ -27126,12 +27252,6 @@ var SubPrimitive = function SubPrimitive() {
27126
27252
  ParticleSimulationSpace[ParticleSimulationSpace[/** Simulate particles in world space. */ "World"] = 1] = "World";
27127
27253
  })(ParticleSimulationSpace || (ParticleSimulationSpace = {}));
27128
27254
 
27129
- var ParticleStopMode;
27130
- (function(ParticleStopMode) {
27131
- ParticleStopMode[ParticleStopMode[/** Stop emitting new particles and clear existing particles immediately. */ "StopEmittingAndClear"] = 0] = "StopEmittingAndClear";
27132
- ParticleStopMode[ParticleStopMode[/** Stop emitting new particles, but keep existing particles until they expire. */ "StopEmitting"] = 1] = "StopEmitting";
27133
- })(ParticleStopMode || (ParticleStopMode = {}));
27134
-
27135
27255
  /**
27136
27256
  * @internal
27137
27257
  */ var ParticleRandomSubSeeds;
@@ -29082,181 +29202,60 @@ __decorate([
29082
29202
  ], ParticleGenerator.prototype, "_instanceVertices", void 0);
29083
29203
 
29084
29204
  /**
29085
- * Particle Renderer Component.
29086
- */ var ParticleRenderer = /*#__PURE__*/ function(Renderer1) {
29087
- _inherits(ParticleRenderer, Renderer1);
29088
- function ParticleRenderer(entity) {
29205
+ * Particle Material.
29206
+ */ var ParticleMaterial = /*#__PURE__*/ function(BaseMaterial1) {
29207
+ _inherits(ParticleMaterial, BaseMaterial1);
29208
+ function ParticleMaterial(engine) {
29089
29209
  var _this;
29090
- _this = Renderer1.call(this, entity) || this;
29091
- /** Particle generator. */ _this.generator = new ParticleGenerator(_assert_this_initialized(_this));
29092
- /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0;
29093
- /** 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;
29094
- /** The pivot of particle. */ _this.pivot = new Vector3();
29095
- _this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
29096
- _this.shaderData.enableMacro(ParticleRenderer._billboardModeMacro);
29097
- _this._supportInstancedArrays = _this.engine._hardwareRenderer.canIUse(GLCapabilityType.instancedArrays);
29210
+ _this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
29211
+ var shaderData = _this.shaderData;
29212
+ shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
29213
+ shaderData.setColor(BaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
29214
+ _this.isTransparent = true;
29098
29215
  return _this;
29099
29216
  }
29100
- var _proto = ParticleRenderer.prototype;
29101
- /**
29102
- * @internal
29103
- */ _proto._onEnable = function _onEnable() {
29104
- if (this.generator.main.playOnEnabled) {
29105
- this.generator.play(false);
29106
- }
29107
- };
29108
- /**
29109
- * @internal
29110
- */ _proto._onDisable = function _onDisable() {
29111
- this.generator.stop(false, ParticleStopMode.StopEmittingAndClear);
29112
- };
29113
- /**
29114
- * @internal
29115
- */ _proto._prepareRender = function _prepareRender(context) {
29116
- if (!this._supportInstancedArrays) {
29117
- return;
29118
- }
29119
- var generator = this.generator;
29120
- generator._update(this.engine.time.deltaTime);
29121
- // No particles to render
29122
- if (generator._firstActiveElement === generator._firstFreeElement) {
29123
- return;
29124
- }
29125
- Renderer1.prototype._prepareRender.call(this, context);
29126
- };
29127
- /**
29128
- * @internal
29129
- */ _proto._updateBounds = function _updateBounds(worldBounds) {
29130
- worldBounds.min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
29131
- worldBounds.max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
29132
- };
29217
+ var _proto = ParticleMaterial.prototype;
29133
29218
  /**
29134
- * @internal
29135
- */ _proto._updateShaderData = function _updateShaderData(context) {
29136
- var shaderData = this.shaderData;
29137
- shaderData.setFloat(ParticleRenderer._lengthScale, this.lengthScale);
29138
- shaderData.setFloat(ParticleRenderer._speedScale, this.velocityScale);
29139
- shaderData.setFloat(ParticleRenderer._currentTime, this.generator._playTime);
29140
- shaderData.setVector3(ParticleRenderer._pivotOffsetProperty, this.pivot);
29141
- this.generator._updateShaderData(shaderData);
29142
- };
29143
- _proto._render = function _render(context) {
29144
- var generator = this.generator;
29145
- var primitive = generator._primitive;
29146
- if (generator._firstActiveElement < generator._firstFreeElement) {
29147
- primitive.instanceCount = generator._firstFreeElement - generator._firstActiveElement;
29148
- } else {
29149
- var instanceCount = generator._currentParticleCount - generator._firstActiveElement;
29150
- if (generator._firstFreeElement > 0) {
29151
- instanceCount += generator._firstFreeElement;
29152
- }
29153
- primitive.instanceCount = instanceCount;
29154
- }
29155
- var material = this.getMaterial();
29156
- var renderData = this._engine._renderDataPool.getFromPool();
29157
- renderData.setX(this, material, generator._primitive, generator._subPrimitive);
29158
- context.camera._renderPipeline.pushRenderData(context, renderData);
29159
- };
29160
- _proto._onDestroy = function _onDestroy() {
29161
- this.generator._destroy();
29219
+ * @inheritdoc
29220
+ */ _proto.clone = function clone() {
29221
+ var dest = new ParticleMaterial(this._engine);
29222
+ this.cloneTo(dest);
29223
+ return dest;
29162
29224
  };
29163
- _create_class(ParticleRenderer, [
29225
+ _create_class(ParticleMaterial, [
29164
29226
  {
29165
- key: "renderMode",
29227
+ key: "baseColor",
29166
29228
  get: /**
29167
- * Specifies how particles are rendered.
29229
+ * Base color.
29168
29230
  */ function get() {
29169
- return this._renderMode;
29231
+ return this.shaderData.getColor(BaseMaterial._baseColorProp);
29170
29232
  },
29171
29233
  set: function set(value) {
29172
- if (this._renderMode !== value) {
29173
- var lastRenderMode = this._renderMode;
29174
- this._renderMode = value;
29175
- var renderModeMacro = null;
29176
- var shaderData = this.shaderData;
29177
- switch(value){
29178
- case ParticleRenderMode.Billboard:
29179
- renderModeMacro = ParticleRenderer._billboardModeMacro;
29180
- break;
29181
- case ParticleRenderMode.StretchBillboard:
29182
- renderModeMacro = ParticleRenderer._stretchedBillboardModeMacro;
29183
- break;
29184
- case ParticleRenderMode.HorizontalBillboard:
29185
- throw "Not implemented";
29186
- case ParticleRenderMode.VerticalBillboard:
29187
- throw "Not implemented";
29188
- case ParticleRenderMode.Mesh:
29189
- throw "Not implemented";
29190
- }
29191
- if (this._currentRenderModeMacro !== renderModeMacro) {
29192
- this._currentRenderModeMacro && shaderData.disableMacro(this._currentRenderModeMacro);
29193
- renderModeMacro && shaderData.enableMacro(renderModeMacro);
29194
- this._currentRenderModeMacro = renderModeMacro;
29195
- }
29196
- // @ts-ignore
29197
- if (lastRenderMode !== ParticleRenderMode.Mesh !== (value === ParticleRenderMode.Mesh)) {
29198
- this.generator._reorganizeGeometryBuffers();
29199
- }
29234
+ var baseColor = this.shaderData.getColor(BaseMaterial._baseColorProp);
29235
+ if (value !== baseColor) {
29236
+ baseColor.copyFrom(value);
29200
29237
  }
29201
29238
  }
29202
29239
  },
29203
29240
  {
29204
- key: "mesh",
29241
+ key: "baseTexture",
29205
29242
  get: /**
29206
- * The mesh of particle.
29207
- * @remarks Valid when `renderMode` is `Mesh`.
29243
+ * Base texture.
29208
29244
  */ function get() {
29209
- return this._mesh;
29245
+ return this.shaderData.getTexture(BaseMaterial._baseTextureProp);
29210
29246
  },
29211
29247
  set: function set(value) {
29212
- var lastMesh = this._mesh;
29213
- if (lastMesh !== value) {
29214
- var _lastMesh, _value;
29215
- this._mesh = value;
29216
- (_lastMesh = lastMesh) == null ? void 0 : _lastMesh._addReferCount(-1);
29217
- (_value = value) == null ? void 0 : _value._addReferCount(1);
29218
- if (this.renderMode === ParticleRenderMode.Mesh) {
29219
- this.generator._reorganizeGeometryBuffers();
29220
- }
29248
+ this.shaderData.setTexture(BaseMaterial._baseTextureProp, value);
29249
+ if (value) {
29250
+ this.shaderData.enableMacro(BaseMaterial._baseTextureMacro);
29251
+ } else {
29252
+ this.shaderData.disableMacro(BaseMaterial._baseTextureMacro);
29221
29253
  }
29222
29254
  }
29223
29255
  }
29224
29256
  ]);
29225
- return ParticleRenderer;
29226
- }(Renderer);
29227
- (function() {
29228
- ParticleRenderer._billboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_SPHERE_BILLBOARD");
29229
- })();
29230
- (function() {
29231
- ParticleRenderer._stretchedBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_STRETCHED_BILLBOARD");
29232
- })();
29233
- (function() {
29234
- ParticleRenderer._horizontalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD");
29235
- })();
29236
- (function() {
29237
- ParticleRenderer._verticalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_VERTICAL_BILLBOARD");
29238
- })();
29239
- (function() {
29240
- ParticleRenderer._renderModeMeshMacro = ShaderMacro.getByName("RENDERER_MODE_MESH");
29241
- })();
29242
- (function() {
29243
- ParticleRenderer._pivotOffsetProperty = ShaderProperty.getByName("renderer_PivotOffset");
29244
- })();
29245
- (function() {
29246
- ParticleRenderer._lengthScale = ShaderProperty.getByName("renderer_StretchedBillboardLengthScale");
29247
- })();
29248
- (function() {
29249
- ParticleRenderer._speedScale = ShaderProperty.getByName("renderer_StretchedBillboardSpeedScale");
29250
- })();
29251
- (function() {
29252
- ParticleRenderer._currentTime = ShaderProperty.getByName("renderer_CurrentTime");
29253
- })();
29254
- __decorate([
29255
- deepClone
29256
- ], ParticleRenderer.prototype, "generator", void 0);
29257
- __decorate([
29258
- shallowClone
29259
- ], ParticleRenderer.prototype, "pivot", void 0);
29257
+ return ParticleMaterial;
29258
+ }(BaseMaterial);
29260
29259
 
29261
29260
  /**
29262
29261
  * A burst is a particle emission event, where a number of particles are all emitted at the same time
@@ -29896,5 +29895,5 @@ var cacheDir = new Vector3();
29896
29895
  return CubeProbe;
29897
29896
  }(Probe);
29898
29897
 
29899
- export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, Basic2DBatcher, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CapsuleColliderShape, CharacterController, CircleShape, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorSpace, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DynamicCollider, DynamicColliderConstraints, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleCompositeCurve, ParticleCurve, ParticleCurveMode, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RenderBufferDepthFormat, RenderFace, RenderPass, RenderQueue, RenderQueueType, RenderState, RenderStateElementKey as RenderStateDataKey, RenderTarget, RenderTargetBlendState, Renderer, ResourceManager, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubMesh, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureUsage, TextureWrapMode, Time, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
29898
+ export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, Basic2DBatcher, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CapsuleColliderShape, CharacterController, CircleShape, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorOverLifetimeModule, ColorSpace, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, MainModule, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RenderBufferDepthFormat, RenderFace, RenderPass, RenderQueue, RenderQueueType, RenderState, RenderStateElementKey as RenderStateDataKey, RenderTarget, RenderTargetBlendState, Renderer, ResourceManager, RotationOverLifetimeModule, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubMesh, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureWrapMode, Time, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
29900
29899
  //# sourceMappingURL=module.js.map