yzt
2023-05-05 634ab285812bcc3eb802cacb9ec54f489bc2728f
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, Color, DirectionalLight } from "../../Source/Cesium.js";
 
describe("Scene/DirectionalLight", function () {
  it("constructs with default options", function () {
    var light = new DirectionalLight({
      direction: Cartesian3.UNIT_X,
    });
 
    expect(light.direction).toEqual(Cartesian3.UNIT_X);
    expect(light.direction).not.toBe(Cartesian3.UNIT_X);
    expect(light.color).toEqual(Color.WHITE);
    expect(light.intensity).toBe(1.0);
  });
 
  it("constructs with all options", function () {
    var light = new DirectionalLight({
      direction: Cartesian3.UNIT_X,
      color: Color.RED,
      intensity: 2.0,
    });
    expect(light.direction).toEqual(Cartesian3.UNIT_X);
    expect(light.color).toEqual(Color.RED);
    expect(light.color).not.toBe(Color.RED);
    expect(light.intensity).toBe(2.0);
  });
 
  it("throws if options is undefined", function () {
    expect(function () {
      return new DirectionalLight();
    }).toThrowDeveloperError();
  });
 
  it("throws if options.direction is undefined", function () {
    expect(function () {
      return new DirectionalLight({
        color: Color.RED,
      });
    }).toThrowDeveloperError();
  });
 
  it("throws if options.direction is zero-length", function () {
    expect(function () {
      return new DirectionalLight({
        direction: Cartesian3.ZERO,
      });
    }).toThrowDeveloperError();
  });
});