@@ -64,17 +64,8 @@ defineSuite([
64
64
var primitive ;
65
65
var globePrimitive ;
66
66
var tilesetPrimitive ;
67
-
68
- beforeAll ( function ( ) {
69
- scene = createScene ( ) ;
70
- scene . postProcessStages . fxaa . enabled = false ;
71
-
72
- ellipsoid = Ellipsoid . WGS84 ;
73
- } ) ;
74
-
75
- afterAll ( function ( ) {
76
- scene . destroyForSpecs ( ) ;
77
- } ) ;
67
+ var reusableGlobePrimitive ;
68
+ var reusableTilesetPrimitive ;
78
69
79
70
function viewCenter ( ) {
80
71
scene . camera . setView ( { destination : rectangle } ) ;
@@ -88,7 +79,7 @@ defineSuite([
88
79
scene . camera . setView ( { destination : tilesetRectangle } ) ;
89
80
}
90
81
91
- function MockPrimitive ( rectangle , pass ) {
82
+ function createPrimitive ( rectangle , pass ) {
92
83
var renderState ;
93
84
if ( pass === Pass . CESIUM_3D_TILE ) {
94
85
renderState = RenderState . fromCache ( {
@@ -101,7 +92,7 @@ defineSuite([
101
92
}
102
93
var depthColorAttribute = ColorGeometryInstanceAttribute . fromColor ( new Color ( 0.0 , 0.0 , 1.0 , 1.0 ) ) ;
103
94
depthColor = depthColorAttribute . value ;
104
- this . _primitive = new Primitive ( {
95
+ return new Primitive ( {
105
96
geometryInstances : new GeometryInstance ( {
106
97
geometry : new RectangleGeometry ( {
107
98
ellipsoid : Ellipsoid . WGS84 ,
@@ -119,7 +110,10 @@ defineSuite([
119
110
} ) ,
120
111
asynchronous : false
121
112
} ) ;
113
+ }
122
114
115
+ function MockPrimitive ( primitive , pass ) {
116
+ this . _primitive = primitive ;
123
117
this . _pass = pass ;
124
118
}
125
119
@@ -139,21 +133,36 @@ defineSuite([
139
133
} ;
140
134
141
135
MockPrimitive . prototype . destroy = function ( ) {
142
- this . _primitive . destroy ( ) ;
143
136
return destroyObject ( this ) ;
144
137
} ;
145
138
146
- beforeEach ( function ( ) {
147
- scene . morphTo3D ( 0 ) ;
148
- scene . render ( ) ; // clear any afterRender commands
139
+ beforeAll ( function ( ) {
140
+ scene = createScene ( ) ;
141
+ scene . postProcessStages . fxaa . enabled = false ;
142
+
143
+ ellipsoid = Ellipsoid . WGS84 ;
149
144
150
145
rectangle = Rectangle . fromDegrees ( - 75.0 , 25.0 , - 70.0 , 30.0 ) ;
151
146
globeRectangle = Rectangle . fromDegrees ( - 75.0 , 27.5 , - 70.0 , 30.0 ) ;
152
147
tilesetRectangle = Rectangle . fromDegrees ( - 75.0 , 25.0 , - 70.0 , 27.5 ) ;
153
148
149
+ reusableGlobePrimitive = createPrimitive ( globeRectangle , Pass . GLOBE ) ;
150
+ reusableTilesetPrimitive = createPrimitive ( tilesetRectangle , Pass . CESIUM_3D_TILE ) ;
151
+ } ) ;
152
+
153
+ afterAll ( function ( ) {
154
+ reusableGlobePrimitive . destroy ( ) ;
155
+ reusableTilesetPrimitive . destroy ( ) ;
156
+ scene . destroyForSpecs ( ) ;
157
+ } ) ;
158
+
159
+ beforeEach ( function ( ) {
160
+ scene . morphTo3D ( 0 ) ;
161
+ scene . render ( ) ; // clear any afterRender commands
162
+
154
163
// wrap rectangle primitive so it gets executed during the globe pass or 3D Tiles pass to lay down depth
155
- globePrimitive = new MockPrimitive ( globeRectangle , Pass . GLOBE ) ;
156
- tilesetPrimitive = new MockPrimitive ( tilesetRectangle , Pass . CESIUM_3D_TILE ) ;
164
+ globePrimitive = new MockPrimitive ( reusableGlobePrimitive , Pass . GLOBE ) ;
165
+ tilesetPrimitive = new MockPrimitive ( reusableTilesetPrimitive , Pass . CESIUM_3D_TILE ) ;
157
166
158
167
var center = Rectangle . center ( rectangle ) ;
159
168
var origin = ellipsoid . cartographicToCartesian ( center ) ;
@@ -1046,7 +1055,7 @@ defineSuite([
1046
1055
primitive . appearance = new MaterialAppearance ( ) ;
1047
1056
1048
1057
expect ( function ( ) {
1049
- expectRender ( boxColor ) ;
1058
+ expect ( scene ) . toRender ( boxColor ) ;
1050
1059
} ) . toThrowDeveloperError ( ) ;
1051
1060
} ) ;
1052
1061
0 commit comments