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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import { Cartesian3 } from "../../Source/Cesium.js";
import { CircleOutlineGeometry } from "../../Source/Cesium.js";
import { Ellipsoid } from "../../Source/Cesium.js";
import createPackableSpecs from "../createPackableSpecs.js";
 
describe("Core/CircleOutlineGeometry", function () {
  it("throws without a center", function () {
    expect(function () {
      return new CircleOutlineGeometry({
        radius: 1.0,
      });
    }).toThrowDeveloperError();
  });
 
  it("throws without a radius", function () {
    expect(function () {
      return new CircleOutlineGeometry({
        center: Cartesian3.fromDegrees(0, 0),
      });
    }).toThrowDeveloperError();
  });
 
  it("throws with a negative granularity", function () {
    expect(function () {
      return new CircleOutlineGeometry({
        center: Cartesian3.fromDegrees(0, 0),
        radius: 1.0,
        granularity: -1.0,
      });
    }).toThrowDeveloperError();
  });
 
  it("computes positions", function () {
    var m = CircleOutlineGeometry.createGeometry(
      new CircleOutlineGeometry({
        ellipsoid: Ellipsoid.WGS84,
        center: Cartesian3.fromDegrees(0, 0),
        granularity: 0.1,
        radius: 1.0,
      })
    );
 
    expect(m.attributes.position.values.length).toEqual(8 * 3);
    expect(m.indices.length).toEqual(8 * 2);
    expect(m.boundingSphere.radius).toEqual(1);
  });
 
  it("computes positions extruded", function () {
    var m = CircleOutlineGeometry.createGeometry(
      new CircleOutlineGeometry({
        ellipsoid: Ellipsoid.WGS84,
        center: Cartesian3.fromDegrees(0, 0),
        granularity: 0.1,
        radius: 1.0,
        extrudedHeight: 5,
      })
    );
 
    expect(m.attributes.position.values.length).toEqual(16 * 3); //8 top circle + 8 bottom circle
    expect(m.indices.length).toEqual(24 * 2); //8 top + 8 bottom + 8 vertical
  });
 
  it("computes positions extruded, no lines between top and bottom", function () {
    var m = CircleOutlineGeometry.createGeometry(
      new CircleOutlineGeometry({
        ellipsoid: Ellipsoid.WGS84,
        center: Cartesian3.fromDegrees(0, 0),
        granularity: 0.1,
        radius: 1.0,
        extrudedHeight: 10000,
        numberOfVerticalLines: 0,
      })
    );
 
    expect(m.attributes.position.values.length).toEqual(16 * 3);
    expect(m.indices.length).toEqual(16 * 2);
  });
 
  it("undefined is returned if radius is equal to or less than zero", function () {
    var circleOutline0 = new CircleOutlineGeometry({
      center: Cartesian3.fromDegrees(-75.59777, 40.03883),
      radius: 0.0,
    });
    var circleOutline1 = new CircleOutlineGeometry({
      center: Cartesian3.fromDegrees(-75.59777, 40.03883),
      radius: -10.0,
    });
 
    var geometry0 = CircleOutlineGeometry.createGeometry(circleOutline0);
    var geometry1 = CircleOutlineGeometry.createGeometry(circleOutline1);
 
    expect(geometry0).toBeUndefined();
    expect(geometry1).toBeUndefined();
  });
 
  var center = new Cartesian3(8, 9, 10);
  var ellipsoid = new Ellipsoid(11, 12, 13);
  var packableInstance = new CircleOutlineGeometry({
    ellipsoid: ellipsoid,
    center: center,
    granularity: 1,
    radius: 2,
    numberOfVerticalLines: 4,
    height: 5,
    extrudedHeight: 7,
  });
  var packedInstance = [
    center.x,
    center.y,
    center.z,
    ellipsoid.radii.x,
    ellipsoid.radii.y,
    ellipsoid.radii.z,
    2,
    2,
    0,
    7,
    1,
    5,
    4,
    -1,
  ];
  createPackableSpecs(
    CircleOutlineGeometry,
    packableInstance,
    packedInstance,
    "extruded"
  );
 
  //Because extrudedHeight is optional and has to be taken into account when packing, we have a second test without it.
  packableInstance = new CircleOutlineGeometry({
    ellipsoid: ellipsoid,
    center: center,
    granularity: 1,
    radius: 2,
    numberOfVerticalLines: 4,
    height: 5,
  });
  packedInstance = [
    center.x,
    center.y,
    center.z,
    ellipsoid.radii.x,
    ellipsoid.radii.y,
    ellipsoid.radii.z,
    2,
    2,
    0,
    5,
    1,
    5,
    4,
    -1,
  ];
  createPackableSpecs(
    CircleOutlineGeometry,
    packableInstance,
    packedInstance,
    "at height"
  );
});