@@ -2,11 +2,17 @@ defineSuite([
2
2
'DataSources/StaticGeometryColorBatch' ,
3
3
'Core/Cartesian3' ,
4
4
'Core/Color' ,
5
+ 'Core/DistanceDisplayCondition' ,
5
6
'Core/JulianDate' ,
7
+ 'Core/Math' ,
8
+ 'Core/TimeInterval' ,
9
+ 'Core/TimeIntervalCollection' ,
6
10
'DataSources/CallbackProperty' ,
11
+ 'DataSources/ColorMaterialProperty' ,
7
12
'DataSources/EllipseGeometryUpdater' ,
8
13
'DataSources/Entity' ,
9
14
'DataSources/PolylineGeometryUpdater' ,
15
+ 'DataSources/TimeIntervalCollectionProperty' ,
10
16
'Scene/PerInstanceColorAppearance' ,
11
17
'Scene/PolylineColorAppearance' ,
12
18
'Scene/ShadowMode' ,
@@ -16,11 +22,17 @@ defineSuite([
16
22
StaticGeometryColorBatch ,
17
23
Cartesian3 ,
18
24
Color ,
25
+ DistanceDisplayCondition ,
19
26
JulianDate ,
27
+ CesiumMath ,
28
+ TimeInterval ,
29
+ TimeIntervalCollection ,
20
30
CallbackProperty ,
31
+ ColorMaterialProperty ,
21
32
EllipseGeometryUpdater ,
22
33
Entity ,
23
34
PolylineGeometryUpdater ,
35
+ TimeIntervalCollectionProperty ,
24
36
PerInstanceColorAppearance ,
25
37
PolylineColorAppearance ,
26
38
ShadowMode ,
@@ -87,6 +99,97 @@ defineSuite([
87
99
} ) ;
88
100
} ) ;
89
101
102
+ it ( 'updates with sampled color out of range' , function ( ) {
103
+ var validTime = JulianDate . fromIso8601 ( '2018-02-14T04:10:00+1100' ) ;
104
+ var color = new TimeIntervalCollectionProperty ( ) ;
105
+ color . intervals . addInterval ( TimeInterval . fromIso8601 ( {
106
+ iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100' ,
107
+ data : Color . RED
108
+ } ) ) ;
109
+ var entity = new Entity ( {
110
+ availability : new TimeIntervalCollection ( [ TimeInterval . fromIso8601 ( { iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100' } ) ] ) ,
111
+ position : new Cartesian3 ( 1234 , 5678 , 9101112 ) ,
112
+ ellipse : {
113
+ semiMajorAxis : 2 ,
114
+ semiMinorAxis : 1 ,
115
+ extrudedHeight : 20 ,
116
+ material : new ColorMaterialProperty ( color )
117
+ }
118
+ } ) ;
119
+
120
+ var batch = new StaticGeometryColorBatch ( scene . primitives , PerInstanceColorAppearance , undefined , false , ShadowMode . DISABLED ) ;
121
+
122
+ var updater = new EllipseGeometryUpdater ( entity , scene ) ;
123
+ batch . add ( validTime , updater ) ;
124
+
125
+ return pollToPromise ( function ( ) {
126
+ scene . initializeFrame ( ) ;
127
+ var isUpdated = batch . update ( validTime ) ;
128
+ scene . render ( validTime ) ;
129
+ return isUpdated ;
130
+ } ) . then ( function ( ) {
131
+ expect ( scene . primitives . length ) . toEqual ( 1 ) ;
132
+ var primitive = scene . primitives . get ( 0 ) ;
133
+ var attributes = primitive . getGeometryInstanceAttributes ( entity ) ;
134
+ expect ( attributes . color ) . toEqual ( [ 255 , 0 , 0 , 255 ] ) ;
135
+
136
+ batch . update ( time ) ;
137
+ scene . render ( time ) ;
138
+
139
+ primitive = scene . primitives . get ( 0 ) ;
140
+ attributes = primitive . getGeometryInstanceAttributes ( entity ) ;
141
+ expect ( attributes . color ) . toEqual ( [ 255 , 255 , 255 , 255 ] ) ;
142
+
143
+ batch . removeAllPrimitives ( ) ;
144
+ } ) ;
145
+ } ) ;
146
+
147
+ it ( 'updates with sampled distance display condition out of range' , function ( ) {
148
+ var validTime = JulianDate . fromIso8601 ( '2018-02-14T04:10:00+1100' ) ;
149
+ var ddc = new TimeIntervalCollectionProperty ( ) ;
150
+ ddc . intervals . addInterval ( TimeInterval . fromIso8601 ( {
151
+ iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100' ,
152
+ data : new DistanceDisplayCondition ( 1.0 , 2.0 )
153
+ } ) ) ;
154
+ var entity = new Entity ( {
155
+ availability : new TimeIntervalCollection ( [ TimeInterval . fromIso8601 ( { iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100' } ) ] ) ,
156
+ position : new Cartesian3 ( 1234 , 5678 , 9101112 ) ,
157
+ ellipse : {
158
+ semiMajorAxis : 2 ,
159
+ semiMinorAxis : 1 ,
160
+ extrudedHeight : 20 ,
161
+ material : Color . RED ,
162
+ distanceDisplayCondition : ddc
163
+ }
164
+ } ) ;
165
+
166
+ var batch = new StaticGeometryColorBatch ( scene . primitives , PerInstanceColorAppearance , undefined , false , ShadowMode . DISABLED ) ;
167
+
168
+ var updater = new EllipseGeometryUpdater ( entity , scene ) ;
169
+ batch . add ( validTime , updater ) ;
170
+
171
+ return pollToPromise ( function ( ) {
172
+ scene . initializeFrame ( ) ;
173
+ var isUpdated = batch . update ( validTime ) ;
174
+ scene . render ( validTime ) ;
175
+ return isUpdated ;
176
+ } ) . then ( function ( ) {
177
+ expect ( scene . primitives . length ) . toEqual ( 1 ) ;
178
+ var primitive = scene . primitives . get ( 0 ) ;
179
+ var attributes = primitive . getGeometryInstanceAttributes ( entity ) ;
180
+ expect ( attributes . distanceDisplayCondition ) . toEqualEpsilon ( [ 1.0 , 2.0 ] , CesiumMath . EPSILON6 ) ;
181
+
182
+ batch . update ( time ) ;
183
+ scene . render ( time ) ;
184
+
185
+ primitive = scene . primitives . get ( 0 ) ;
186
+ attributes = primitive . getGeometryInstanceAttributes ( entity ) ;
187
+ expect ( attributes . distanceDisplayCondition ) . toEqual ( [ 0.0 , Infinity ] ) ;
188
+
189
+ batch . removeAllPrimitives ( ) ;
190
+ } ) ;
191
+ } ) ;
192
+
90
193
it ( 'updates color attribute after rebuilding polyline primitive' , function ( ) {
91
194
var batch = new StaticGeometryColorBatch ( scene . primitives , PolylineColorAppearance , undefined , false , ShadowMode . DISABLED ) ;
92
195
@@ -128,4 +231,47 @@ defineSuite([
128
231
} ) ;
129
232
} ) ;
130
233
} ) ;
234
+
235
+ it ( 'updates with sampled depth fail color out of range' , function ( ) {
236
+ var validTime = JulianDate . fromIso8601 ( '2018-02-14T04:10:00+1100' ) ;
237
+ var color = new TimeIntervalCollectionProperty ( ) ;
238
+ color . intervals . addInterval ( TimeInterval . fromIso8601 ( {
239
+ iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100' ,
240
+ data : Color . RED
241
+ } ) ) ;
242
+ var entity = new Entity ( {
243
+ availability : new TimeIntervalCollection ( [ TimeInterval . fromIso8601 ( { iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100' } ) ] ) ,
244
+ polyline : {
245
+ positions : [ Cartesian3 . fromDegrees ( 0.0 , 0.0 ) , Cartesian3 . fromDegrees ( 0.0 , 1.0 ) ] ,
246
+ material : Color . BLUE ,
247
+ depthFailMaterial : new ColorMaterialProperty ( color )
248
+ }
249
+ } ) ;
250
+
251
+ var batch = new StaticGeometryColorBatch ( scene . primitives , PolylineColorAppearance , PolylineColorAppearance , false , ShadowMode . DISABLED ) ;
252
+
253
+ var updater = new PolylineGeometryUpdater ( entity , scene ) ;
254
+ batch . add ( validTime , updater ) ;
255
+
256
+ return pollToPromise ( function ( ) {
257
+ scene . initializeFrame ( ) ;
258
+ var isUpdated = batch . update ( validTime ) ;
259
+ scene . render ( validTime ) ;
260
+ return isUpdated ;
261
+ } ) . then ( function ( ) {
262
+ expect ( scene . primitives . length ) . toEqual ( 1 ) ;
263
+ var primitive = scene . primitives . get ( 0 ) ;
264
+ var attributes = primitive . getGeometryInstanceAttributes ( entity ) ;
265
+ expect ( attributes . depthFailColor ) . toEqual ( [ 255 , 0 , 0 , 255 ] ) ;
266
+
267
+ batch . update ( time ) ;
268
+ scene . render ( time ) ;
269
+
270
+ primitive = scene . primitives . get ( 0 ) ;
271
+ attributes = primitive . getGeometryInstanceAttributes ( entity ) ;
272
+ expect ( attributes . depthFailColor ) . toEqual ( [ 255 , 255 , 255 , 255 ] ) ;
273
+
274
+ batch . removeAllPrimitives ( ) ;
275
+ } ) ;
276
+ } ) ;
131
277
} ) ;
0 commit comments