yzt
2023-05-26 2f70f6727314edd84d8ec2bfe3ce832803f1ea77
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
import { arrayFill } from "../../Source/Cesium.js";
import { Cartesian2 } from "../../Source/Cesium.js";
import { Cartesian3 } from "../../Source/Cesium.js";
import { Ellipsoid } from "../../Source/Cesium.js";
import { GeographicProjection } from "../../Source/Cesium.js";
import { GeometryOffsetAttribute } from "../../Source/Cesium.js";
import { Math as CesiumMath } from "../../Source/Cesium.js";
import { Matrix2 } from "../../Source/Cesium.js";
import { Rectangle } from "../../Source/Cesium.js";
import { RectangleGeometry } from "../../Source/Cesium.js";
import { VertexFormat } from "../../Source/Cesium.js";
import createPackableSpecs from "../createPackableSpecs.js";
 
describe("Core/RectangleGeometry", function () {
  it("computes positions", function () {
    var rectangle = new Rectangle(-2.0, -1.0, 0.0, 1.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
        granularity: 1.0,
      })
    );
    var positions = m.attributes.position.values;
    var length = positions.length;
 
    expect(positions.length).toEqual(9 * 3);
    expect(m.indices.length).toEqual(8 * 3);
 
    var expectedNWCorner = Ellipsoid.WGS84.cartographicToCartesian(
      Rectangle.northwest(rectangle)
    );
    var expectedSECorner = Ellipsoid.WGS84.cartographicToCartesian(
      Rectangle.southeast(rectangle)
    );
    expect(
      new Cartesian3(positions[0], positions[1], positions[2])
    ).toEqualEpsilon(expectedNWCorner, CesiumMath.EPSILON9);
    expect(
      new Cartesian3(
        positions[length - 3],
        positions[length - 2],
        positions[length - 1]
      )
    ).toEqualEpsilon(expectedSECorner, CesiumMath.EPSILON9);
  });
 
  it("computes positions across IDL", function () {
    var rectangle = Rectangle.fromDegrees(179.0, -1.0, -179.0, 1.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
      })
    );
    var positions = m.attributes.position.values;
    var length = positions.length;
 
    expect(positions.length).toEqual(9 * 3);
    expect(m.indices.length).toEqual(8 * 3);
 
    var expectedNWCorner = Ellipsoid.WGS84.cartographicToCartesian(
      Rectangle.northwest(rectangle)
    );
    var expectedSECorner = Ellipsoid.WGS84.cartographicToCartesian(
      Rectangle.southeast(rectangle)
    );
    expect(
      new Cartesian3(positions[0], positions[1], positions[2])
    ).toEqualEpsilon(expectedNWCorner, CesiumMath.EPSILON8);
    expect(
      new Cartesian3(
        positions[length - 3],
        positions[length - 2],
        positions[length - 1]
      )
    ).toEqualEpsilon(expectedSECorner, CesiumMath.EPSILON8);
  });
 
  it("computes positions at north pole", function () {
    var rectangle = Rectangle.fromDegrees(-180.0, 89.0, -179.0, 90.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
      })
    );
    var positions = m.attributes.position.values;
    expect(positions.length).toEqual(5 * 3);
    expect(m.indices.length).toEqual(3 * 3);
  });
 
  it("computes positions at south pole", function () {
    var rectangle = Rectangle.fromDegrees(-180.0, -90.0, -179.0, -89.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
      })
    );
    var positions = m.attributes.position.values;
    expect(positions.length).toEqual(5 * 3);
    expect(m.indices.length).toEqual(3 * 3);
  });
 
  it("computes all attributes", function () {
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.ALL,
        rectangle: new Rectangle(-2.0, -1.0, 0.0, 1.0),
        granularity: 1.0,
      })
    );
    var numVertices = 9; // 8 around edge + 1 in middle
    var numTriangles = 8; // 4 squares * 2 triangles per square
    expect(m.attributes.position.values.length).toEqual(numVertices * 3);
    expect(m.attributes.st.values.length).toEqual(numVertices * 2);
    expect(m.attributes.normal.values.length).toEqual(numVertices * 3);
    expect(m.attributes.tangent.values.length).toEqual(numVertices * 3);
    expect(m.attributes.bitangent.values.length).toEqual(numVertices * 3);
    expect(m.indices.length).toEqual(numTriangles * 3);
  });
 
  it("compute positions with rotation", function () {
    var rectangle = new Rectangle(-1, -1, 1, 1);
    var angle = CesiumMath.PI_OVER_TWO;
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITIONS_ONLY,
        rectangle: rectangle,
        rotation: angle,
        granularity: 1.0,
      })
    );
    var positions = m.attributes.position.values;
    var length = positions.length;
 
    expect(length).toEqual(9 * 3);
    expect(m.indices.length).toEqual(8 * 3);
 
    var unrotatedSECorner = Rectangle.southeast(rectangle);
    var projection = new GeographicProjection();
    var projectedSECorner = projection.project(unrotatedSECorner);
    var rotation = Matrix2.fromRotation(angle);
    var rotatedSECornerCartographic = projection.unproject(
      Matrix2.multiplyByVector(rotation, projectedSECorner, new Cartesian2())
    );
    var rotatedSECorner = Ellipsoid.WGS84.cartographicToCartesian(
      rotatedSECornerCartographic
    );
    var actual = new Cartesian3(
      positions[length - 3],
      positions[length - 2],
      positions[length - 1]
    );
    expect(actual).toEqualEpsilon(rotatedSECorner, CesiumMath.EPSILON6);
  });
 
  it("compute vertices with PI rotation", function () {
    var rectangle = new Rectangle(-1, -1, 1, 1);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        rectangle: rectangle,
        rotation: CesiumMath.PI,
        granularity: 1.0,
      })
    );
    var positions = m.attributes.position.values;
    var length = positions.length;
 
    expect(length).toEqual(9 * 3);
    expect(m.indices.length).toEqual(8 * 3);
 
    var unrotatedNWCorner = Ellipsoid.WGS84.cartographicToCartesian(
      Rectangle.northwest(rectangle)
    );
    var unrotatedSECorner = Ellipsoid.WGS84.cartographicToCartesian(
      Rectangle.southeast(rectangle)
    );
 
    var actual = new Cartesian3(positions[0], positions[1], positions[2]);
    expect(actual).toEqualEpsilon(unrotatedSECorner, CesiumMath.EPSILON8);
 
    actual = new Cartesian3(
      positions[length - 3],
      positions[length - 2],
      positions[length - 1]
    );
    expect(actual).toEqualEpsilon(unrotatedNWCorner, CesiumMath.EPSILON8);
  });
 
  it("compute texture coordinates with rotation", function () {
    var rectangle = new Rectangle(-1, -1, 1, 1);
    var angle = CesiumMath.PI_OVER_TWO;
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_AND_ST,
        rectangle: rectangle,
        stRotation: angle,
        granularity: 1.0,
      })
    );
    var positions = m.attributes.position.values;
    var st = m.attributes.st.values;
    var length = st.length;
 
    expect(positions.length).toEqual(9 * 3);
    expect(length).toEqual(9 * 2);
    expect(m.indices.length).toEqual(8 * 3);
 
    expect(st[length - 2]).toEqualEpsilon(0.0, CesiumMath.EPSILON14);
    expect(st[length - 1]).toEqualEpsilon(0.0, CesiumMath.EPSILON14);
  });
 
  it("compute texture coordinate rotation with rectangle rotation", function () {
    var rectangle = new Rectangle(-1, -1, 1, 1);
    var angle = CesiumMath.toRadians(30);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_AND_ST,
        rectangle: rectangle,
        rotation: angle,
        stRotation: angle,
        granularity: 1.0,
      })
    );
    var st = m.attributes.st.values;
 
    expect(st[0]).toEqual(0.0); //top left corner
    expect(st[1]).toEqual(1.0);
    expect(st[4]).toEqual(1.0); //top right corner
    expect(st[5]).toEqual(1.0);
    expect(st[12]).toEqual(0.0); //bottom left corner
    expect(st[13]).toEqual(0.0);
    expect(st[16]).toEqual(1.0); //bottom right corner
    expect(st[17]).toEqual(0.0);
  });
 
  it("throws without rectangle", function () {
    expect(function () {
      return new RectangleGeometry({});
    }).toThrowDeveloperError();
  });
 
  it("throws if rotated rectangle is invalid", function () {
    expect(function () {
      return RectangleGeometry.createGeometry(
        new RectangleGeometry({
          rectangle: new Rectangle(
            -CesiumMath.PI_OVER_TWO,
            1,
            CesiumMath.PI_OVER_TWO,
            CesiumMath.PI_OVER_TWO
          ),
          rotation: CesiumMath.PI_OVER_TWO,
        })
      );
    }).toThrowDeveloperError();
  });
 
  it("throws if north is less than south", function () {
    expect(function () {
      return new RectangleGeometry({
        rectangle: new Rectangle(
          -CesiumMath.PI_OVER_TWO,
          CesiumMath.PI_OVER_TWO,
          CesiumMath.PI_OVER_TWO,
          -CesiumMath.PI_OVER_TWO
        ),
      });
    }).toThrowDeveloperError();
  });
 
  it("computes positions extruded", function () {
    var rectangle = new Rectangle(-2.0, -1.0, 0.0, 1.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
        granularity: 1.0,
        extrudedHeight: 2,
      })
    );
    var positions = m.attributes.position.values;
 
    expect(positions.length).toEqual(42 * 3); // (9 fill + 8 edge + 4 corners) * 2 to duplicate for bottom
    expect(m.indices.length).toEqual(32 * 3); // 8 * 2 for fill top and bottom + 4 triangles * 4 walls
  });
 
  it("computes positions extruded at the north pole", function () {
    var rectangle = Rectangle.fromDegrees(-180.0, 89.0, -179.0, 90.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
        extrudedHeight: 2,
      })
    );
    var positions = m.attributes.position.values;
 
    expect(positions.length).toEqual(26 * 3); // (5 fill + 5 edge + 3 corners) * 2 to duplicate for bottom
    expect(m.indices.length).toEqual(16 * 3); // 3 * 2 for fill top and bottom + 2 triangles * 5 walls
  });
 
  it("computes positions extruded at the south pole", function () {
    var rectangle = Rectangle.fromDegrees(-180.0, -90.0, -179.0, -89.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
        extrudedHeight: 2,
      })
    );
    var positions = m.attributes.position.values;
 
    expect(positions.length).toEqual(26 * 3); // (5 fill + 5 edge + 3 corners) * 2 to duplicate for bottom
    expect(m.indices.length).toEqual(16 * 3); // 3 * 2 for fill top and bottom + 2 triangles * 5 walls
  });
 
  it("computes all attributes extruded", function () {
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.ALL,
        rectangle: new Rectangle(-2.0, -1.0, 0.0, 1.0),
        granularity: 1.0,
        extrudedHeight: 2,
      })
    );
    var numVertices = 42;
    var numTriangles = 32;
    expect(m.attributes.position.values.length).toEqual(numVertices * 3);
    expect(m.attributes.st.values.length).toEqual(numVertices * 2);
    expect(m.attributes.normal.values.length).toEqual(numVertices * 3);
    expect(m.attributes.tangent.values.length).toEqual(numVertices * 3);
    expect(m.attributes.bitangent.values.length).toEqual(numVertices * 3);
    expect(m.indices.length).toEqual(numTriangles * 3);
  });
 
  it("compute positions with rotation extruded", function () {
    var rectangle = new Rectangle(-1, -1, 1, 1);
    var angle = CesiumMath.PI_OVER_TWO;
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITIONS_ONLY,
        rectangle: rectangle,
        rotation: angle,
        granularity: 1.0,
        extrudedHeight: 2,
      })
    );
    var positions = m.attributes.position.values;
    var length = positions.length;
 
    expect(length).toEqual(42 * 3);
    expect(m.indices.length).toEqual(32 * 3);
 
    var unrotatedSECorner = Rectangle.southeast(rectangle);
    var projection = new GeographicProjection();
    var projectedSECorner = projection.project(unrotatedSECorner);
    var rotation = Matrix2.fromRotation(angle);
    var rotatedSECornerCartographic = projection.unproject(
      Matrix2.multiplyByVector(rotation, projectedSECorner, new Cartesian2())
    );
    var rotatedSECorner = Ellipsoid.WGS84.cartographicToCartesian(
      rotatedSECornerCartographic
    );
    var actual = new Cartesian3(positions[51], positions[52], positions[53]);
    expect(actual).toEqualEpsilon(rotatedSECorner, CesiumMath.EPSILON6);
  });
 
  it("computes non-extruded rectangle if height is small", function () {
    var rectangle = new Rectangle(-2.0, -1.0, 0.0, 1.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
        granularity: 1.0,
        extrudedHeight: CesiumMath.EPSILON14,
      })
    );
    var positions = m.attributes.position.values;
 
    var numVertices = 9;
    var numTriangles = 8;
    expect(positions.length).toEqual(numVertices * 3);
    expect(m.indices.length).toEqual(numTriangles * 3);
  });
 
  it("computes offset attribute", function () {
    var rectangle = new Rectangle(-2.0, -1.0, 0.0, 1.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
        granularity: 1.0,
        offsetAttribute: GeometryOffsetAttribute.TOP,
      })
    );
    var positions = m.attributes.position.values;
 
    var numVertices = 9;
    expect(positions.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 offset attribute extruded for top vertices", function () {
    var rectangle = new Rectangle(-2.0, -1.0, 0.0, 1.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
        granularity: 1.0,
        extrudedHeight: 2,
        offsetAttribute: GeometryOffsetAttribute.TOP,
      })
    );
    var positions = m.attributes.position.values;
 
    var numVertices = 42; // (9 fill + 8 edge + 4 corners) * 2 to duplicate for bottom
    expect(positions.length).toEqual(numVertices * 3);
 
    var offset = m.attributes.applyOffset.values;
    expect(offset.length).toEqual(numVertices);
    var expected = new Array(offset.length);
    expected = arrayFill(expected, 0);
    expected = arrayFill(expected, 1, 0, 9);
    for (var i = 18; i < offset.length; i += 2) {
      expected[i] = 1;
    }
    expect(offset).toEqual(expected);
  });
 
  it("computes offset attribute extruded for all vertices", function () {
    var rectangle = new Rectangle(-2.0, -1.0, 0.0, 1.0);
    var m = RectangleGeometry.createGeometry(
      new RectangleGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
        rectangle: rectangle,
        granularity: 1.0,
        extrudedHeight: 2,
        offsetAttribute: GeometryOffsetAttribute.ALL,
      })
    );
    var positions = m.attributes.position.values;
 
    var numVertices = 42; // (9 fill + 8 edge + 4 corners) * 2 to duplicate for bottom
    expect(positions.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);
    for (var i = 18; i < offset.length; i += 2) {
      expected[i] = 1;
    }
    expect(offset).toEqual(expected);
  });
 
  it("undefined is returned if any side are of length zero", function () {
    var rectangle0 = new RectangleGeometry({
      rectangle: Rectangle.fromDegrees(-80.0, 39.0, -80.0, 42.0),
    });
    var rectangle1 = new RectangleGeometry({
      rectangle: Rectangle.fromDegrees(-81.0, 42.0, -80.0, 42.0),
    });
    var rectangle2 = new RectangleGeometry({
      rectangle: Rectangle.fromDegrees(-80.0, 39.0, -80.0, 39.0),
    });
 
    var geometry0 = RectangleGeometry.createGeometry(rectangle0);
    var geometry1 = RectangleGeometry.createGeometry(rectangle1);
    var geometry2 = RectangleGeometry.createGeometry(rectangle2);
 
    expect(geometry0).toBeUndefined();
    expect(geometry1).toBeUndefined();
    expect(geometry2).toBeUndefined();
  });
 
  it("computing rectangle property", function () {
    var rectangle = new Rectangle.fromDegrees(-1.0, -1.0, 1.0, 1.0);
    var geometry = new RectangleGeometry({
      vertexFormat: VertexFormat.POSITION_ONLY,
      rectangle: rectangle,
      granularity: 1.0,
    });
 
    var r = geometry.rectangle;
    expect(CesiumMath.toDegrees(r.north)).toEqual(1.0);
    expect(CesiumMath.toDegrees(r.south)).toEqual(-1.0);
    expect(CesiumMath.toDegrees(r.east)).toEqual(1.0);
    expect(CesiumMath.toDegrees(r.west)).toEqual(-1.0);
  });
 
  it("computing rectangle property with rotation", function () {
    var rectangle = new Rectangle.fromDegrees(-1.0, -1.0, 1.0, 1.0);
    var geometry = new RectangleGeometry({
      vertexFormat: VertexFormat.POSITION_ONLY,
      rectangle: rectangle,
      granularity: 1.0,
      rotation: CesiumMath.toRadians(45.0),
    });
 
    var r = geometry.rectangle;
    expect(CesiumMath.toDegrees(r.north)).toEqualEpsilon(
      1.414213562373095,
      CesiumMath.EPSILON15
    );
    expect(CesiumMath.toDegrees(r.south)).toEqualEpsilon(
      -1.414213562373095,
      CesiumMath.EPSILON15
    );
    expect(CesiumMath.toDegrees(r.east)).toEqualEpsilon(
      1.414213562373095,
      CesiumMath.EPSILON15
    );
    expect(CesiumMath.toDegrees(r.west)).toEqualEpsilon(
      -1.4142135623730951,
      CesiumMath.EPSILON15
    );
  });
 
  it("computing textureCoordinateRotationPoints property", function () {
    var rectangle = new Rectangle.fromDegrees(-1.0, -1.0, 1.0, 1.0);
    var geometry = new RectangleGeometry({
      vertexFormat: VertexFormat.POSITION_ONLY,
      rectangle: rectangle,
      granularity: 1.0,
      rotation: CesiumMath.toRadians(90.0),
    });
 
    // 90 degree rotation means (0, 1) should be the new min and (1, 1) (0, 0) are extents
    var textureCoordinateRotationPoints =
      geometry.textureCoordinateRotationPoints;
    expect(textureCoordinateRotationPoints.length).toEqual(6);
    expect(textureCoordinateRotationPoints[0]).toEqualEpsilon(
      0,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[1]).toEqualEpsilon(
      0,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[2]).toEqualEpsilon(
      0,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[3]).toEqualEpsilon(
      1,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[4]).toEqualEpsilon(
      1,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[5]).toEqualEpsilon(
      0,
      CesiumMath.EPSILON7
    );
 
    geometry = new RectangleGeometry({
      vertexFormat: VertexFormat.POSITION_ONLY,
      rectangle: rectangle,
      granularity: 1.0,
      rotation: CesiumMath.toRadians(90.0),
    });
 
    textureCoordinateRotationPoints = geometry.textureCoordinateRotationPoints;
    expect(textureCoordinateRotationPoints.length).toEqual(6);
    expect(textureCoordinateRotationPoints[0]).toEqualEpsilon(
      0,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[1]).toEqualEpsilon(
      0,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[2]).toEqualEpsilon(
      0,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[3]).toEqualEpsilon(
      1,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[4]).toEqualEpsilon(
      1,
      CesiumMath.EPSILON7
    );
    expect(textureCoordinateRotationPoints[5]).toEqualEpsilon(
      0,
      CesiumMath.EPSILON7
    );
  });
 
  it("computeRectangle", function () {
    var options = {
      vertexFormat: VertexFormat.POSITION_ONLY,
      rectangle: new Rectangle.fromDegrees(-1.0, -1.0, 1.0, 1.0),
      granularity: 1.0,
      ellipsoid: Ellipsoid.UNIT_SPHERE,
      rotation: CesiumMath.PI,
    };
    var geometry = new RectangleGeometry(options);
 
    var expected = geometry.rectangle;
    var result = RectangleGeometry.computeRectangle(options);
 
    expect(result).toEqual(expected);
  });
 
  it("computeRectangle with result parameter", function () {
    var options = {
      vertexFormat: VertexFormat.POSITION_ONLY,
      rectangle: new Rectangle.fromDegrees(-1.0, -1.0, 1.0, 1.0),
    };
    var geometry = new RectangleGeometry(options);
 
    var result = new Rectangle();
    var expected = geometry.rectangle;
    var returned = RectangleGeometry.computeRectangle(options, result);
 
    expect(returned).toEqual(expected);
    expect(returned).toBe(result);
  });
 
  it("computing rectangle property with zero rotation", function () {
    expect(function () {
      return RectangleGeometry.createGeometry(
        new RectangleGeometry({
          vertexFormat: VertexFormat.POSITION_ONLY,
          rectangle: Rectangle.MAX_VALUE,
          granularity: 1.0,
          rotation: 0,
        })
      );
    }).not.toThrowDeveloperError();
  });
 
  it("can create rectangle geometry where the nw corner and the center are on opposite sides of the IDL", function () {
    var rectangle = new Rectangle(
      Math.PI - 0.005,
      CesiumMath.PI_OVER_SIX + 0.02,
      0.01 - Math.PI,
      CesiumMath.PI_OVER_SIX + 0.04
    );
 
    var geometry = new RectangleGeometry({
      rectangle: rectangle,
      rotation: 0.5,
    });
 
    expect(function () {
      RectangleGeometry.createGeometry(geometry);
    }).not.toThrowDeveloperError();
  });
 
  var rectangle = new RectangleGeometry({
    vertexFormat: VertexFormat.POSITION_ONLY,
    rectangle: new Rectangle(-2.0, -1.0, 0.0, 1.0),
    granularity: 1.0,
    ellipsoid: Ellipsoid.UNIT_SPHERE,
  });
  var packedInstance = [
    -2.0,
    -1.0,
    0.0,
    1.0,
    1.0,
    1.0,
    1.0,
    1.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    1.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    -1,
  ];
  createPackableSpecs(RectangleGeometry, rectangle, packedInstance);
});