babylon.IParticleSystem.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. module BABYLON {
  2. /**
  3. * Interface representing a particle system in Babylon.js.
  4. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  5. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  6. */
  7. export interface IParticleSystem {
  8. /**
  9. * List of animations used by the particle system.
  10. */
  11. animations: Animation[];
  12. /**
  13. * The id of the Particle system.
  14. */
  15. id: string;
  16. /**
  17. * The name of the Particle system.
  18. */
  19. name: string;
  20. /**
  21. * The emitter represents the Mesh or position we are attaching the particle system to.
  22. */
  23. emitter: Nullable<AbstractMesh | Vector3>;
  24. /**
  25. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  26. */
  27. isBillboardBased: boolean;
  28. /**
  29. * The rendering group used by the Particle system to chose when to render.
  30. */
  31. renderingGroupId: number;
  32. /**
  33. * The layer mask we are rendering the particles through.
  34. */
  35. layerMask: number;
  36. /**
  37. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  38. */
  39. updateSpeed: number;
  40. /**
  41. * The amount of time the particle system is running (depends of the overall update speed).
  42. */
  43. targetStopDuration: number;
  44. /**
  45. * The texture used to render each particle. (this can be a spritesheet)
  46. */
  47. particleTexture: Nullable<Texture>;
  48. /**
  49. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  50. */
  51. blendMode: number;
  52. /**
  53. * Minimum life time of emitting particles.
  54. */
  55. minLifeTime: number;
  56. /**
  57. * Maximum life time of emitting particles.
  58. */
  59. maxLifeTime: number;
  60. /**
  61. * Minimum Size of emitting particles.
  62. */
  63. minSize: number;
  64. /**
  65. * Maximum Size of emitting particles.
  66. */
  67. maxSize: number;
  68. /**
  69. * Minimum scale of emitting particles on X axis.
  70. */
  71. minScaleX: number;
  72. /**
  73. * Maximum scale of emitting particles on X axis.
  74. */
  75. maxScaleX: number;
  76. /**
  77. * Minimum scale of emitting particles on Y axis.
  78. */
  79. minScaleY: number;
  80. /**
  81. * Maximum scale of emitting particles on Y axis.
  82. */
  83. maxScaleY: number;
  84. /**
  85. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86. */
  87. color1: Color4;
  88. /**
  89. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90. */
  91. color2: Color4;
  92. /**
  93. * Color the particle will have at the end of its lifetime.
  94. */
  95. colorDead: Color4;
  96. /**
  97. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  98. */
  99. emitRate: number;
  100. /**
  101. * You can use gravity if you want to give an orientation to your particles.
  102. */
  103. gravity: Vector3;
  104. /**
  105. * Minimum power of emitting particles.
  106. */
  107. minEmitPower: number;
  108. /**
  109. * Maximum power of emitting particles.
  110. */
  111. maxEmitPower: number;
  112. /**
  113. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  114. */
  115. minAngularSpeed: number;
  116. /**
  117. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  118. */
  119. maxAngularSpeed: number;
  120. /**
  121. * Gets or sets the minimal initial rotation in radians.
  122. */
  123. minInitialRotation: number;
  124. /**
  125. * Gets or sets the maximal initial rotation in radians.
  126. */
  127. maxInitialRotation: number;
  128. /**
  129. * The particle emitter type defines the emitter used by the particle system.
  130. * It can be for example box, sphere, or cone...
  131. */
  132. particleEmitterType: Nullable<IParticleEmitterType>;
  133. /**
  134. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  135. */
  136. preWarmCycles: number;
  137. /**
  138. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  139. */
  140. preWarmStepOffset: number;
  141. /**
  142. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  143. */
  144. spriteCellChangeSpeed: number;
  145. /**
  146. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  147. */
  148. startSpriteCellID: number;
  149. /**
  150. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  151. */
  152. endSpriteCellID: number;
  153. /**
  154. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  155. */
  156. spriteCellWidth: number;
  157. /**
  158. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  159. */
  160. spriteCellHeight: number;
  161. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  162. translationPivot: Vector2;
  163. /**
  164. * Gets or sets a texture used to add random noise to particle positions
  165. */
  166. noiseTexture: Nullable<BaseTexture>;
  167. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  168. noiseStrength: Vector3;
  169. /**
  170. * Gets or sets the billboard mode to use when isBillboardBased = true.
  171. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  172. */
  173. billboardMode: number;
  174. /**
  175. * Gets the maximum number of particles active at the same time.
  176. * @returns The max number of active particles.
  177. */
  178. getCapacity(): number;
  179. /**
  180. * Gets Wether the system has been started.
  181. * @returns True if it has been started, otherwise false.
  182. */
  183. isStarted(): boolean;
  184. /**
  185. * Gets if the particle system has been started.
  186. * @return true if the system has been started, otherwise false.
  187. */
  188. isStarted(): boolean;
  189. /**
  190. * Animates the particle system for this frame.
  191. */
  192. animate(): void;
  193. /**
  194. * Renders the particle system in its current state.
  195. * @returns the current number of particles
  196. */
  197. render(): number;
  198. /**
  199. * Dispose the particle system and frees its associated resources.
  200. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  201. */
  202. dispose(disposeTexture?: boolean): void;
  203. /**
  204. * Clones the particle system.
  205. * @param name The name of the cloned object
  206. * @param newEmitter The new emitter to use
  207. * @returns the cloned particle system
  208. */
  209. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  210. /**
  211. * Serializes the particle system to a JSON object.
  212. * @returns the JSON object
  213. */
  214. serialize(): any;
  215. /**
  216. * Rebuild the particle system
  217. */
  218. rebuild(): void;
  219. /**
  220. * Starts the particle system and begins to emit
  221. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  222. */
  223. start(delay?: number): void;
  224. /**
  225. * Stops the particle system.
  226. */
  227. stop(): void;
  228. /**
  229. * Remove all active particles
  230. */
  231. reset(): void;
  232. /**
  233. * Is this system ready to be used/rendered
  234. * @return true if the system is ready
  235. */
  236. isReady(): boolean;
  237. /**
  238. * Adds a new color gradient
  239. * @param gradient defines the gradient to use (between 0 and 1)
  240. * @param color defines the color to affect to the specified gradient
  241. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  242. * @returns the current particle system
  243. */
  244. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  245. /**
  246. * Remove a specific color gradient
  247. * @param gradient defines the gradient to remove
  248. * @returns the current particle system
  249. */
  250. removeColorGradient(gradient: number): IParticleSystem;
  251. /**
  252. * Adds a new size gradient
  253. * @param gradient defines the gradient to use (between 0 and 1)
  254. * @param factor defines the size factor to affect to the specified gradient
  255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  256. * @returns the current particle system
  257. */
  258. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  259. /**
  260. * Remove a specific size gradient
  261. * @param gradient defines the gradient to remove
  262. * @returns the current particle system
  263. */
  264. removeSizeGradient(gradient: number): IParticleSystem;
  265. /**
  266. * Gets the current list of color gradients.
  267. * You must use addColorGradient and removeColorGradient to udpate this list
  268. * @returns the list of color gradients
  269. */
  270. getColorGradients(): Nullable<Array<ColorGradient>>;
  271. /**
  272. * Gets the current list of size gradients.
  273. * You must use addSizeGradient and removeSizeGradient to udpate this list
  274. * @returns the list of size gradients
  275. */
  276. getSizeGradients(): Nullable<Array<FactorGradient>>;
  277. /**
  278. * Gets the current list of angular speed gradients.
  279. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  280. * @returns the list of angular speed gradients
  281. */
  282. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  283. /**
  284. * Adds a new angular speed gradient
  285. * @param gradient defines the gradient to use (between 0 and 1)
  286. * @param factor defines the size factor to affect to the specified gradient
  287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  288. * @returns the current particle system
  289. */
  290. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  291. /**
  292. * Remove a specific angular speed gradient
  293. * @param gradient defines the gradient to remove
  294. * @returns the current particle system
  295. */
  296. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  297. /**
  298. * Gets the current list of velocity gradients.
  299. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  300. * @returns the list of velocity gradients
  301. */
  302. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  303. /**
  304. * Adds a new velocity gradient
  305. * @param gradient defines the gradient to use (between 0 and 1)
  306. * @param factor defines the size factor to affect to the specified gradient
  307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  308. * @returns the current particle system
  309. */
  310. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  311. /**
  312. * Remove a specific velocity gradient
  313. * @param gradient defines the gradient to remove
  314. * @returns the current particle system
  315. */
  316. removeVelocityGradient(gradient: number): IParticleSystem;
  317. }
  318. }