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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { BoundingSphere } from "../../Source/Cesium.js";
import { Color } from "../../Source/Cesium.js";
import { defined } from "../../Source/Cesium.js";
import { Ellipsoid } from "../../Source/Cesium.js";
import { Matrix3 } from "../../Source/Cesium.js";
import { Simon1994PlanetaryPositions } from "../../Source/Cesium.js";
import { Transforms } from "../../Source/Cesium.js";
import { Moon } from "../../Source/Cesium.js";
import createScene from "../createScene.js";
 
describe(
  "Scene/Moon",
  function () {
    var scene;
    var backgroundColor = [255, 0, 0, 255];
 
    beforeAll(function () {
      scene = createScene();
      Color.unpack(backgroundColor, 0, scene.backgroundColor);
    });
 
    afterAll(function () {
      scene.destroyForSpecs();
    });
 
    function lookAtMoon(camera, date) {
      var icrfToFixed = new Matrix3();
      if (!defined(Transforms.computeIcrfToFixedMatrix(date, icrfToFixed))) {
        Transforms.computeTemeToPseudoFixedMatrix(date, icrfToFixed);
      }
 
      var moonPosition = Simon1994PlanetaryPositions.computeMoonPositionInEarthInertialFrame(
        date
      );
      Matrix3.multiplyByVector(icrfToFixed, moonPosition, moonPosition);
 
      camera.viewBoundingSphere(
        new BoundingSphere(moonPosition, Ellipsoid.MOON.maximumRadius)
      );
    }
 
    it("default constructs the moon", function () {
      var moon = new Moon();
      expect(moon.show).toEqual(true);
      expect(moon.textureUrl).toContain("Assets/Textures/moonSmall.jpg");
      expect(moon.ellipsoid).toBe(Ellipsoid.MOON);
      expect(moon.onlySunLighting).toEqual(true);
    });
 
    it("draws in 3D", function () {
      expect(scene).toRender(backgroundColor);
      scene.moon = new Moon();
 
      lookAtMoon(scene.camera, scene.frameState.time);
 
      expect(scene).notToRender(backgroundColor);
      scene.moon = scene.moon.destroy();
    });
 
    it("does not render when show is false", function () {
      expect(scene).toRender(backgroundColor);
      scene.moon = new Moon();
 
      lookAtMoon(scene.camera, scene.frameState.time);
 
      expect(scene).notToRender(backgroundColor);
      scene.moon.show = false;
 
      expect(scene).toRender(backgroundColor);
      scene.moon = scene.moon.destroy();
    });
 
    it("isDestroyed", function () {
      var moon = new Moon();
      expect(moon.isDestroyed()).toEqual(false);
      moon.destroy();
      expect(moon.isDestroyed()).toEqual(true);
    });
  },
  "WebGL"
);