15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Cartesian3 } from "../../Source/Cesium.js";
import { Math as CesiumMath } from "../../Source/Cesium.js";
import { ConeEmitter } from "../../Source/Cesium.js";
import { Particle } from "../../Source/Cesium.js";
 
describe("Scene/ConeEmitter", function () {
  it("default constructor", function () {
    var emitter = new ConeEmitter();
    expect(emitter.angle).toEqual(CesiumMath.toRadians(30.0));
  });
 
  it("constructor", function () {
    var emitter = new ConeEmitter(CesiumMath.PI_OVER_SIX);
    expect(emitter.angle).toEqual(CesiumMath.PI_OVER_SIX);
  });
 
  it("angle setter", function () {
    var emitter = new ConeEmitter();
    emitter.angle = CesiumMath.PI_OVER_SIX;
    expect(emitter.angle).toEqual(CesiumMath.PI_OVER_SIX);
  });
 
  it("angle setter throws with invalid value", function () {
    var emitter = new ConeEmitter();
    expect(function () {
      emitter.angle = undefined;
    }).toThrowDeveloperError();
  });
 
  it("emits", function () {
    var emitter = new ConeEmitter(CesiumMath.PI_OVER_SIX);
    var particle = new Particle();
 
    for (var i = 0; i < 1000; ++i) {
      emitter.emit(particle);
      expect(particle.position).toEqual(Cartesian3.ZERO);
      expect(Cartesian3.magnitude(particle.velocity)).toEqualEpsilon(
        1.0,
        CesiumMath.EPSILON14
      );
 
      // acos(dot(unit v, unit z)) <= angle
      expect(Math.acos(particle.velocity.z)).toBeLessThanOrEqualTo(
        emitter.angle
      );
    }
  });
});