forked from CesiumGS/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxOutlineGeometrySpec.js
91 lines (77 loc) · 2.98 KB
/
BoxOutlineGeometrySpec.js
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
defineSuite([
'Core/BoxOutlineGeometry',
'Core/AxisAlignedBoundingBox',
'Core/Cartesian3',
'Specs/createPackableSpecs'
], function(
BoxOutlineGeometry,
AxisAlignedBoundingBox,
Cartesian3,
createPackableSpecs) {
'use strict';
it('constructor throws without maximum corner', function() {
expect(function() {
return new BoxOutlineGeometry({
maximum : new Cartesian3()
});
}).toThrowDeveloperError();
});
it('constructor throws without minimum corner', function() {
expect(function() {
return new BoxOutlineGeometry({
minimum : new Cartesian3()
});
}).toThrowDeveloperError();
});
it('constructor creates positions', function() {
var m = BoxOutlineGeometry.createGeometry(new BoxOutlineGeometry({
minimum : new Cartesian3(-1, -2, -3),
maximum : new Cartesian3(1, 2, 3)
}));
expect(m.attributes.position.values.length).toEqual(8 * 3);
expect(m.indices.length).toEqual(12 * 2);
});
it('fromDimensions throws without dimensions', function() {
expect(function() {
return BoxOutlineGeometry.fromDimensions();
}).toThrowDeveloperError();
});
it('fromDimensions throws with negative dimensions', function() {
expect(function() {
return BoxOutlineGeometry.fromDimensions({
dimensions : new Cartesian3(1, 2, -1)
});
}).toThrowDeveloperError();
});
it('fromDimensions', function() {
var m = BoxOutlineGeometry.createGeometry(BoxOutlineGeometry.fromDimensions({
dimensions : new Cartesian3(1, 2, 3)
}));
expect(m.attributes.position.values.length).toEqual(8 * 3);
expect(m.indices.length).toEqual(12 * 2);
});
it('fromAxisAlignedBoundingBox throws with no boundingBox', function() {
expect(function() {
return BoxOutlineGeometry.fromAxisAlignedBoundingBox(undefined);
}).toThrowDeveloperError();
});
it('fromAxisAlignedBoundingBox', function() {
var min = new Cartesian3(-1, -2, -3);
var max = new Cartesian3(1, 2, 3);
var m = BoxOutlineGeometry.fromAxisAlignedBoundingBox(new AxisAlignedBoundingBox(min, max));
expect(m._min).toEqual(min);
expect(m._max).toEqual(max);
});
it('undefined is returned if min and max are equal', function() {
var box = new BoxOutlineGeometry({
maximum : new Cartesian3(250000.0, 250000.0, 250000.0),
minimum : new Cartesian3(250000.0, 250000.0, 250000.0)
});
var geometry = BoxOutlineGeometry.createGeometry(box);
expect(geometry).toBeUndefined();
});
createPackableSpecs(BoxOutlineGeometry, new BoxOutlineGeometry({
minimum : new Cartesian3(1.0, 2.0, 3.0),
maximum : new Cartesian3(4.0, 5.0, 6.0)
}), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);
});