@@ -19,7 +19,9 @@ defineSuite([
19
19
'Renderer/Framebuffer' ,
20
20
'Renderer/Pass' ,
21
21
'Renderer/PixelDatatype' ,
22
+ 'Renderer/RenderState' ,
22
23
'Renderer/ShaderProgram' ,
24
+ 'Renderer/ShaderSource' ,
23
25
'Renderer/Texture' ,
24
26
'Scene/Camera' ,
25
27
'Scene/EllipsoidSurfaceAppearance' ,
@@ -55,7 +57,9 @@ defineSuite([
55
57
Framebuffer ,
56
58
Pass ,
57
59
PixelDatatype ,
60
+ RenderState ,
58
61
ShaderProgram ,
62
+ ShaderSource ,
59
63
Texture ,
60
64
Camera ,
61
65
EllipsoidSurfaceAppearance ,
@@ -74,9 +78,21 @@ defineSuite([
74
78
'use strict' ;
75
79
76
80
var scene ;
81
+ var simpleShaderProgram ;
82
+ var simpleRenderState ;
77
83
78
84
beforeAll ( function ( ) {
79
85
scene = createScene ( ) ;
86
+ simpleShaderProgram = ShaderProgram . fromCache ( {
87
+ context : scene . context ,
88
+ vertexShaderSource : new ShaderSource ( {
89
+ sources : [ 'void main() { gl_Position = vec4(1.0); }' ]
90
+ } ) ,
91
+ fragmentShaderSource : new ShaderSource ( {
92
+ sources : [ 'void main() { gl_FragColor = vec4(1.0); }' ]
93
+ } )
94
+ } ) ;
95
+ simpleRenderState = new RenderState ( ) ;
80
96
} ) ;
81
97
82
98
afterEach ( function ( ) {
@@ -199,6 +215,8 @@ defineSuite([
199
215
200
216
it ( 'debugCommandFilter filters commands' , function ( ) {
201
217
var c = new DrawCommand ( {
218
+ shaderProgram : simpleShaderProgram ,
219
+ renderState : simpleRenderState ,
202
220
pass : Pass . OPAQUE
203
221
} ) ;
204
222
c . execute = function ( ) { } ;
@@ -216,6 +234,8 @@ defineSuite([
216
234
217
235
it ( 'debugCommandFilter does not filter commands' , function ( ) {
218
236
var c = new DrawCommand ( {
237
+ shaderProgram : simpleShaderProgram ,
238
+ renderState : simpleRenderState ,
219
239
pass : Pass . OPAQUE
220
240
} ) ;
221
241
c . execute = function ( ) { } ;
@@ -233,6 +253,8 @@ defineSuite([
233
253
var center = Cartesian3 . add ( scene . camera . position , scene . camera . direction , new Cartesian3 ( ) ) ;
234
254
235
255
var c = new DrawCommand ( {
256
+ shaderProgram : simpleShaderProgram ,
257
+ renderState : simpleRenderState ,
236
258
pass : Pass . OPAQUE ,
237
259
debugShowBoundingVolume : true ,
238
260
boundingVolume : new BoundingSphere ( center , radius )
@@ -249,13 +271,9 @@ defineSuite([
249
271
250
272
it ( 'debugShowCommands tints commands' , function ( ) {
251
273
var c = new DrawCommand ( {
252
- pass : Pass . OPAQUE ,
253
-
254
- shaderProgram : ShaderProgram . fromCache ( {
255
- context : scene . context ,
256
- vertexShaderSource : 'void main() { gl_Position = vec4(1.0); }' ,
257
- fragmentShaderSource : 'void main() { gl_FragColor = vec4(1.0); }'
258
- } )
274
+ shaderProgram : simpleShaderProgram ,
275
+ renderState : simpleRenderState ,
276
+ pass : Pass . OPAQUE
259
277
} ) ;
260
278
c . execute = function ( ) { } ;
261
279
@@ -753,6 +771,66 @@ defineSuite([
753
771
} ) ;
754
772
} ) ;
755
773
774
+ it ( 'pickPosition picks translucent geometry when pickTranslucentDepth is true' , function ( ) {
775
+ if ( ! scene . pickPositionSupported ) {
776
+ return ;
777
+ }
778
+
779
+ var rectangle = Rectangle . fromDegrees ( - 100.0 , 30.0 , - 90.0 , 40.0 ) ;
780
+ scene . camera . setView ( {
781
+ destination : rectangle
782
+ } ) ;
783
+
784
+ var canvas = scene . canvas ;
785
+ var windowPosition = new Cartesian2 ( canvas . clientWidth / 2 , canvas . clientHeight / 2 ) ;
786
+
787
+ var rectanglePrimitive = createRectangle ( rectangle ) ;
788
+ rectanglePrimitive . appearance . material . uniforms . color = new Color ( 1.0 , 0.0 , 0.0 , 0.5 ) ;
789
+
790
+ var primitives = scene . primitives ;
791
+ primitives . add ( rectanglePrimitive ) ;
792
+
793
+ scene . useDepthPicking = true ;
794
+ scene . pickTranslucentDepth = false ;
795
+ expect ( scene ) . toRenderAndCall ( function ( ) {
796
+ var position = scene . pickPosition ( windowPosition ) ;
797
+ expect ( position ) . not . toBeDefined ( ) ;
798
+ } ) ;
799
+
800
+ scene . pickTranslucentDepth = true ;
801
+ expect ( scene ) . toRenderAndCall ( function ( ) {
802
+ var position = scene . pickPosition ( windowPosition ) ;
803
+ expect ( position ) . toBeDefined ( ) ;
804
+ } ) ;
805
+
806
+ var rectanglePrimitive2 = createRectangle ( rectangle ) ;
807
+ rectanglePrimitive2 . appearance . material . uniforms . color = new Color ( 0.0 , 1.0 , 0.0 , 0.5 ) ;
808
+ primitives . add ( rectanglePrimitive2 ) ;
809
+
810
+ expect ( scene ) . toRenderAndCall ( function ( ) {
811
+ var position = scene . pickPosition ( windowPosition ) ;
812
+ expect ( position ) . toBeDefined ( ) ;
813
+
814
+ var commandList = scene . frameState . commandList ;
815
+ expect ( commandList . length ) . toEqual ( 2 ) ;
816
+
817
+ var command1 = commandList [ 0 ] ;
818
+ var command2 = commandList [ 1 ] ;
819
+
820
+ expect ( command1 . derivedCommands ) . toBeDefined ( ) ;
821
+ expect ( command2 . derivedCommands ) . toBeDefined ( ) ;
822
+
823
+ expect ( command1 . derivedCommands . depth ) . toBeDefined ( ) ;
824
+ expect ( command2 . derivedCommands . depth ) . toBeDefined ( ) ;
825
+
826
+ expect ( command1 . derivedCommands . depth . depthOnlyCommand ) . toBeDefined ( ) ;
827
+ expect ( command2 . derivedCommands . depth . depthOnlyCommand ) . toBeDefined ( ) ;
828
+
829
+ expect ( command1 . derivedCommands . depth . depthOnlyCommand . shaderProgram ) . toEqual ( command2 . derivedCommands . depth . depthOnlyCommand . shaderProgram ) ;
830
+ expect ( command1 . derivedCommands . depth . depthOnlyCommand . renderState ) . toEqual ( command2 . derivedCommands . depth . depthOnlyCommand . renderState ) ;
831
+ } ) ;
832
+ } ) ;
833
+
756
834
it ( 'pickPosition throws without windowPosition' , function ( ) {
757
835
expect ( function ( ) {
758
836
scene . pickPosition ( ) ;
0 commit comments