forked from CesiumGS/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSkyAtmosphereSpec.js
160 lines (123 loc) · 4.54 KB
/
SkyAtmosphereSpec.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
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
/*global defineSuite*/
defineSuite([
'Scene/SkyAtmosphere',
'Core/Cartesian3',
'Core/Ellipsoid',
'Core/Math',
'Renderer/ClearCommand',
'Scene/SceneMode',
'Specs/createScene'
], function(
SkyAtmosphere,
Cartesian3,
Ellipsoid,
CesiumMath,
ClearCommand,
SceneMode,
createScene) {
'use strict';
var scene;
beforeAll(function() {
scene = createScene();
});
afterAll(function() {
scene.destroyForSpecs();
});
beforeEach(function() {
scene.mode = SceneMode.SCENE3D;
});
it('draws sky with camera in atmosphere', function() {
var s = new SkyAtmosphere();
expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
expect(command).toBeDefined();
command.execute(scene.context); // Not reliable enough across browsers to test pixels
s.destroy();
});
it('draws sky with camera in space', function() {
var s = new SkyAtmosphere();
expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
expect(command).toBeDefined();
command.execute(scene.context); // Not reliable enough across browsers to test pixels
s.destroy();
});
it('draws sky with setDynamicAtmosphereColor set to true', function() {
var s = new SkyAtmosphere();
s.setDynamicAtmosphereColor(true);
expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
expect(command).toBeDefined();
expect(s._cameraAndRadiiAndDynamicAtmosphereColor.w).toBe(1);
command.execute(scene.context); // Not reliable enough across browsers to test pixels
s.destroy();
});
it('draws sky with setDynamicAtmosphereColor set to false', function() {
var s = new SkyAtmosphere();
s.setDynamicAtmosphereColor(false);
expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
expect(command).toBeDefined();
expect(s._cameraAndRadiiAndDynamicAtmosphereColor.w).toBe(0);
command.execute(scene.context); // Not reliable enough across browsers to test pixels
s.destroy();
});
it('draws sky with color correction active', function() {
var oldSkyAtmosphere = scene.skyAtmosphere;
var s = new SkyAtmosphere();
scene.skyAtmosphere = s;
scene._environmentState.isReadyForAtmosphere = true;
scene.camera.setView({
destination : Cartesian3.fromDegrees(-75.5847, 40.0397, 1000.0),
orientation: {
heading : -CesiumMath.PI_OVER_TWO,
pitch : 0.2,
roll : 0.0
}
});
var color = scene.renderForSpecs();
expect(color).not.toEqual([0, 0, 0, 255]);
// Expect color correction to change the color output.
s.hueShift = 0.5;
var hueColor = scene.renderForSpecs();
expect(hueColor).not.toEqual([0, 0, 0, 255]);
expect(hueColor).not.toEqual(color);
scene.skyAtmosphere = oldSkyAtmosphere;
});
it('does not render when show is false', function() {
var s = new SkyAtmosphere();
s.show = false;
expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
expect(command).not.toBeDefined();
});
it('does not render in 2D', function() {
var s = new SkyAtmosphere();
expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
scene.mode = SceneMode.SCENE2D;
scene.render();
var command = s.update(scene.frameState);
expect(command).not.toBeDefined();
});
it('does not render without a color pass', function() {
var s = new SkyAtmosphere();
scene.frameState.passes.render = false;
var command = s.update(scene.frameState);
expect(command).not.toBeDefined();
});
it('gets ellipsoid', function() {
var s = new SkyAtmosphere(Ellipsoid.UNIT_SPHERE);
expect(s.ellipsoid).toEqual(Ellipsoid.UNIT_SPHERE);
});
it('isDestroyed', function() {
var s = new SkyAtmosphere();
expect(s.isDestroyed()).toEqual(false);
s.destroy();
expect(s.isDestroyed()).toEqual(true);
});
}, 'WebGL');