particleSystem.d.ts 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import { ThinParticleSystem } from "./thinParticleSystem";
  2. import { SubEmitter } from "./subEmitter";
  3. import { Vector3 } from "../Maths/math.vector";
  4. import type { IParticleSystem } from "./IParticleSystem";
  5. import type { Scene } from "../scene";
  6. import { AbstractEngine } from "../Engines/abstractEngine";
  7. import type { Particle } from "./particle";
  8. import { BoxParticleEmitter } from "./EmitterTypes/boxParticleEmitter";
  9. import { PointParticleEmitter } from "./EmitterTypes/pointParticleEmitter";
  10. import { HemisphericParticleEmitter } from "./EmitterTypes/hemisphericParticleEmitter";
  11. import { SphereDirectedParticleEmitter, SphereParticleEmitter } from "./EmitterTypes/sphereParticleEmitter";
  12. import { CylinderDirectedParticleEmitter, CylinderParticleEmitter } from "./EmitterTypes/cylinderParticleEmitter";
  13. import { ConeParticleEmitter } from "./EmitterTypes/coneParticleEmitter";
  14. /**
  15. * This represents a particle system in Babylon.
  16. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18. * @example https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/particle_system_intro
  19. */
  20. export declare class ParticleSystem extends ThinParticleSystem {
  21. /**
  22. * Billboard mode will only apply to Y axis
  23. */
  24. static readonly BILLBOARDMODE_Y = 2;
  25. /**
  26. * Billboard mode will apply to all axes
  27. */
  28. static readonly BILLBOARDMODE_ALL = 7;
  29. /**
  30. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31. */
  32. static readonly BILLBOARDMODE_STRETCHED = 8;
  33. /**
  34. * Special billboard mode where the particle will be billboard to the camera but only around the axis of the direction of particle emission
  35. */
  36. static readonly BILLBOARDMODE_STRETCHED_LOCAL = 9;
  37. private _rootParticleSystem;
  38. /**
  39. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  40. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  41. */
  42. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  43. private _subEmitters;
  44. /**
  45. * @internal
  46. * If the particle systems emitter should be disposed when the particle system is disposed
  47. */
  48. _disposeEmitterOnDispose: boolean;
  49. /**
  50. * The current active Sub-systems, this property is used by the root particle system only.
  51. */
  52. activeSubSystems: Array<ParticleSystem>;
  53. /**
  54. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  55. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  56. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  57. * @returns the emitter
  58. */
  59. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  60. /**
  61. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  62. * @param radius The radius of the hemisphere to emit from
  63. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  64. * @returns the emitter
  65. */
  66. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  67. /**
  68. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  69. * @param radius The radius of the sphere to emit from
  70. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71. * @returns the emitter
  72. */
  73. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74. /**
  75. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76. * @param radius The radius of the sphere to emit from
  77. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  78. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  79. * @returns the emitter
  80. */
  81. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82. /**
  83. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84. * @param radius The radius of the emission cylinder
  85. * @param height The height of the emission cylinder
  86. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87. * @param directionRandomizer How much to randomize the particle direction [0-1]
  88. * @returns the emitter
  89. */
  90. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91. /**
  92. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93. * @param radius The radius of the cylinder to emit from
  94. * @param height The height of the emission cylinder
  95. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  96. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  97. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  98. * @returns the emitter
  99. */
  100. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  101. /**
  102. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  103. * @param radius The radius of the cone to emit from
  104. * @param angle The base angle of the cone
  105. * @returns the emitter
  106. */
  107. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  108. /**
  109. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  110. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  111. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  112. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  113. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  114. * @returns the emitter
  115. */
  116. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  117. private _prepareSubEmitterInternalArray;
  118. private _stopSubEmitters;
  119. private _removeFromRoot;
  120. _emitFromParticle: (particle: Particle) => void;
  121. _preStart(): void;
  122. _postStop(stopSubEmitters: boolean): void;
  123. _prepareParticle(particle: Particle): void;
  124. /** @internal */
  125. _onDispose(disposeAttachedSubEmitters?: boolean, disposeEndSubEmitters?: boolean): void;
  126. /**
  127. * @internal
  128. */
  129. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | AbstractEngine, rootUrl: string): void;
  130. /**
  131. * Parses a JSON object to create a particle system.
  132. * @param parsedParticleSystem The JSON object to parse
  133. * @param sceneOrEngine The scene or the engine to create the particle system in
  134. * @param rootUrl The root url to use to load external dependencies like texture
  135. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136. * @param capacity defines the system capacity (if null or undefined the sotred capacity will be used)
  137. * @returns the Parsed particle system
  138. */
  139. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | AbstractEngine, rootUrl: string, doNotStart?: boolean, capacity?: number): ParticleSystem;
  140. /**
  141. * Serializes the particle system to a JSON object
  142. * @param serializeTexture defines if the texture must be serialized as well
  143. * @returns the JSON object
  144. */
  145. serialize(serializeTexture?: boolean): any;
  146. /**
  147. * @internal
  148. */
  149. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  150. /**
  151. * Clones the particle system.
  152. * @param name The name of the cloned object
  153. * @param newEmitter The new emitter to use
  154. * @param cloneTexture Also clone the textures if true
  155. * @returns the cloned particle system
  156. */
  157. clone(name: string, newEmitter: any, cloneTexture?: boolean): ParticleSystem;
  158. }