yzt
2023-05-26 de4278af2fd46705a40bac58ec01122db6b7f3d7
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
import { ColorGeometryInstanceAttribute } from "../../Source/Cesium.js";
import { GeometryInstance } from "../../Source/Cesium.js";
import { Rectangle } from "../../Source/Cesium.js";
import { RectangleGeometry } from "../../Source/Cesium.js";
import { Appearance } from "../../Source/Cesium.js";
import { EllipsoidSurfaceAppearance } from "../../Source/Cesium.js";
import { Material } from "../../Source/Cesium.js";
import { Primitive } from "../../Source/Cesium.js";
import createScene from "../createScene.js";
 
describe(
  "Scene/EllipsoidSurfaceAppearance",
  function () {
    var scene;
    var rectangle;
    var primitive;
 
    beforeAll(function () {
      scene = createScene();
      scene.primitives.destroyPrimitives = false;
      scene.frameState.scene3DOnly = false;
 
      rectangle = Rectangle.fromDegrees(-10.0, -10.0, 10.0, 10.0);
    });
 
    beforeEach(function () {
      scene.camera.setView({ destination: rectangle });
    });
 
    afterAll(function () {
      scene.destroyForSpecs();
    });
 
    afterEach(function () {
      scene.primitives.removeAll();
      primitive = primitive && !primitive.isDestroyed() && primitive.destroy();
    });
 
    it("constructor", function () {
      var a = new EllipsoidSurfaceAppearance();
 
      expect(a.material).toBeDefined();
      expect(a.material.type).toEqual(Material.ColorType);
      expect(a.vertexShaderSource).toBeDefined();
      expect(a.fragmentShaderSource).toBeDefined();
      expect(a.renderState).toEqual(
        Appearance.getDefaultRenderState(true, true)
      );
      expect(a.vertexFormat).toEqual(EllipsoidSurfaceAppearance.VERTEX_FORMAT);
      expect(a.flat).toEqual(false);
      expect(a.faceForward).toEqual(false);
      expect(a.translucent).toEqual(true);
      expect(a.aboveGround).toEqual(false);
      expect(a.closed).toEqual(false);
    });
 
    it("renders", function () {
      primitive = new Primitive({
        geometryInstances: new GeometryInstance({
          geometry: new RectangleGeometry({
            rectangle: rectangle,
            vertexFormat: EllipsoidSurfaceAppearance.VERTEX_FORMAT,
          }),
          attributes: {
            color: new ColorGeometryInstanceAttribute(1.0, 1.0, 0.0, 1.0),
          },
        }),
        asynchronous: false,
      });
      primitive.appearance = new EllipsoidSurfaceAppearance();
 
      expect(scene).toRender([0, 0, 0, 255]);
 
      scene.primitives.add(primitive);
      expect(scene).notToRender([0, 0, 0, 255]);
    });
  },
  "WebGL"
);