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
import { arrayFill } from "../../Source/Cesium.js";
import { CylinderOutlineGeometry } from "../../Source/Cesium.js";
import { GeometryOffsetAttribute } from "../../Source/Cesium.js";
import createPackableSpecs from "../createPackableSpecs.js";
describe("Core/CylinderOutlineGeometry", function () {
it("constructor throws with no length", function () {
expect(function () {
return new CylinderOutlineGeometry({});
}).toThrowDeveloperError();
});
it("constructor throws with no topRadius", function () {
expect(function () {
return new CylinderOutlineGeometry({
length: 1,
});
}).toThrowDeveloperError();
});
it("constructor throws with no bottomRadius", function () {
expect(function () {
return new CylinderOutlineGeometry({
length: 1,
topRadius: 1,
});
}).toThrowDeveloperError();
});
it("constructor throws if slices is less than 3", function () {
expect(function () {
return new CylinderOutlineGeometry({
length: 1,
topRadius: 1,
bottomRadius: 1,
slices: 2,
});
}).toThrowDeveloperError();
});
it("computes positions", function () {
var m = CylinderOutlineGeometry.createGeometry(
new CylinderOutlineGeometry({
length: 1,
topRadius: 1,
bottomRadius: 1,
slices: 3,
})
);
expect(m.attributes.position.values.length).toEqual(6 * 3); // 3 top + 3 bottom
expect(m.indices.length).toEqual(9 * 2); // 3 top + 3 bottom + 3 sides
});
it("computes offset attribute", function () {
var m = CylinderOutlineGeometry.createGeometry(
new CylinderOutlineGeometry({
length: 1,
topRadius: 1,
bottomRadius: 1,
slices: 3,
offsetAttribute: GeometryOffsetAttribute.ALL,
})
);
var numVertices = 6;
expect(m.attributes.position.values.length).toEqual(numVertices * 3);
var offset = m.attributes.applyOffset.values;
expect(offset.length).toEqual(numVertices);
var expected = new Array(offset.length);
expected = arrayFill(expected, 1);
expect(offset).toEqual(expected);
});
it("computes positions with no lines along the length", function () {
var m = CylinderOutlineGeometry.createGeometry(
new CylinderOutlineGeometry({
length: 1,
topRadius: 1,
bottomRadius: 1,
slices: 3,
numberOfVerticalLines: 0,
})
);
var numVertices = 6; //3 top 3 bottom
var numLines = 6; //3 top 3 bottom
expect(m.attributes.position.values.length).toEqual(numVertices * 3);
expect(m.indices.length).toEqual(numLines * 2);
});
it(
"undefined is returned if the length is less than or equal to zero or if " +
"both radii are equal to zero or is either radii and less than zero",
function () {
var cylinderOutline0 = new CylinderOutlineGeometry({
length: 0,
topRadius: 80000,
bottomRadius: 200000,
});
var cylinderOutline1 = new CylinderOutlineGeometry({
length: 200000,
topRadius: 0,
bottomRadius: 0,
});
var cylinderOutline2 = new CylinderOutlineGeometry({
length: 200000,
topRadius: -10,
bottomRadius: 4,
});
var cylinderOutline3 = new CylinderOutlineGeometry({
length: -200000,
topRadius: 100,
bottomRadius: 100,
});
var cylinderOutline4 = new CylinderOutlineGeometry({
length: 200000,
topRadius: 32,
bottomRadius: -100,
});
var geometry0 = CylinderOutlineGeometry.createGeometry(cylinderOutline0);
var geometry1 = CylinderOutlineGeometry.createGeometry(cylinderOutline1);
var geometry2 = CylinderOutlineGeometry.createGeometry(cylinderOutline2);
var geometry3 = CylinderOutlineGeometry.createGeometry(cylinderOutline3);
var geometry4 = CylinderOutlineGeometry.createGeometry(cylinderOutline4);
expect(geometry0).toBeUndefined();
expect(geometry1).toBeUndefined();
expect(geometry2).toBeUndefined();
expect(geometry3).toBeUndefined();
expect(geometry4).toBeUndefined();
}
);
var cylinder = new CylinderOutlineGeometry({
length: 1,
topRadius: 1,
bottomRadius: 0,
slices: 3,
numberOfVerticalLines: 0,
});
var packedInstance = [1.0, 1.0, 0.0, 3.0, 0.0, -1.0];
createPackableSpecs(CylinderOutlineGeometry, cylinder, packedInstance);
});