智慧水务管理系统 - 精河县供水工程综合管理平台

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import Cartesian3 from "../Core/Cartesian3.js";
  2. import Check from "../Core/Check.js";
  3. import CesiumMath from "../Core/Math.js";
  4. /**
  5. * A ParticleEmitter that emits particles from a circle.
  6. * Particles will be positioned within a circle and have initial velocities going along the z vector.
  7. *
  8. * @alias CircleEmitter
  9. * @constructor
  10. *
  11. * @param {number} [radius=1.0] The radius of the circle in meters.
  12. */
  13. function CircleEmitter(radius) {
  14. radius = radius ?? 1.0;
  15. //>>includeStart('debug', pragmas.debug);
  16. Check.typeOf.number.greaterThan("radius", radius, 0.0);
  17. //>>includeEnd('debug');
  18. this._radius = radius ?? 1.0;
  19. }
  20. Object.defineProperties(CircleEmitter.prototype, {
  21. /**
  22. * The radius of the circle in meters.
  23. * @memberof CircleEmitter.prototype
  24. * @type {number}
  25. * @default 1.0
  26. */
  27. radius: {
  28. get: function () {
  29. return this._radius;
  30. },
  31. set: function (value) {
  32. //>>includeStart('debug', pragmas.debug);
  33. Check.typeOf.number.greaterThan("value", value, 0.0);
  34. //>>includeEnd('debug');
  35. this._radius = value;
  36. },
  37. },
  38. });
  39. /**
  40. * Initializes the given {@link Particle} by setting it's position and velocity.
  41. *
  42. * @private
  43. * @param {Particle} particle The particle to initialize.
  44. */
  45. CircleEmitter.prototype.emit = function (particle) {
  46. const theta = CesiumMath.randomBetween(0.0, CesiumMath.TWO_PI);
  47. const rad = CesiumMath.randomBetween(0.0, this._radius);
  48. const x = rad * Math.cos(theta);
  49. const y = rad * Math.sin(theta);
  50. const z = 0.0;
  51. particle.position = Cartesian3.fromElements(x, y, z, particle.position);
  52. particle.velocity = Cartesian3.clone(Cartesian3.UNIT_Z, particle.velocity);
  53. };
  54. export default CircleEmitter;