particleSystem.functions.js 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { Vector3 } from "../Maths/math.vector.js";
  2. import { PointParticleEmitter } from "./EmitterTypes/pointParticleEmitter.js";
  3. import { HemisphericParticleEmitter } from "./EmitterTypes/hemisphericParticleEmitter.js";
  4. import { SphereDirectedParticleEmitter, SphereParticleEmitter } from "./EmitterTypes/sphereParticleEmitter.js";
  5. import { CylinderDirectedParticleEmitter, CylinderParticleEmitter } from "./EmitterTypes/cylinderParticleEmitter.js";
  6. import { ConeParticleEmitter } from "./EmitterTypes/coneParticleEmitter.js";
  7. /**
  8. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  9. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  10. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11. * @returns the emitter
  12. */
  13. export function CreatePointEmitter(direction1, direction2) {
  14. const particleEmitter = new PointParticleEmitter();
  15. particleEmitter.direction1 = direction1;
  16. particleEmitter.direction2 = direction2;
  17. return particleEmitter;
  18. }
  19. /**
  20. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21. * @param radius The radius of the hemisphere to emit from
  22. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  23. * @returns the emitter
  24. */
  25. export function CreateHemisphericEmitter(radius = 1, radiusRange = 1) {
  26. return new HemisphericParticleEmitter(radius, radiusRange);
  27. }
  28. /**
  29. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30. * @param radius The radius of the sphere to emit from
  31. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32. * @returns the emitter
  33. */
  34. export function CreateSphereEmitter(radius = 1, radiusRange = 1) {
  35. return new SphereParticleEmitter(radius, radiusRange);
  36. }
  37. /**
  38. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  39. * @param radius The radius of the sphere to emit from
  40. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  41. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  42. * @returns the emitter
  43. */
  44. export function CreateDirectedSphereEmitter(radius = 1, direction1 = new Vector3(0, 1.0, 0), direction2 = new Vector3(0, 1.0, 0)) {
  45. return new SphereDirectedParticleEmitter(radius, direction1, direction2);
  46. }
  47. /**
  48. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  49. * @param radius The radius of the emission cylinder
  50. * @param height The height of the emission cylinder
  51. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  52. * @param directionRandomizer How much to randomize the particle direction [0-1]
  53. * @returns the emitter
  54. */
  55. export function CreateCylinderEmitter(radius = 1, height = 1, radiusRange = 1, directionRandomizer = 0) {
  56. return new CylinderParticleEmitter(radius, height, radiusRange, directionRandomizer);
  57. }
  58. /**
  59. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  60. * @param radius The radius of the cylinder to emit from
  61. * @param height The height of the emission cylinder
  62. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  63. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  64. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  65. * @returns the emitter
  66. */
  67. export function CreateDirectedCylinderEmitter(radius = 1, height = 1, radiusRange = 1, direction1 = new Vector3(0, 1.0, 0), direction2 = new Vector3(0, 1.0, 0)) {
  68. return new CylinderDirectedParticleEmitter(radius, height, radiusRange, direction1, direction2);
  69. }
  70. /**
  71. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72. * @param radius The radius of the cone to emit from
  73. * @param angle The base angle of the cone
  74. * @returns the emitter
  75. */
  76. export function CreateConeEmitter(radius = 1, angle = Math.PI / 4) {
  77. return new ConeParticleEmitter(radius, angle);
  78. }
  79. //# sourceMappingURL=particleSystem.functions.js.map