@@ -496,10 +496,25 @@ var WebGLRenderer = new Class({
496496 var list = children . list ;
497497 var childCount = list . length ;
498498 var color = this . game . config . backgroundColor ;
499+ var scissorEnabled = ( camera . x !== 0 || camera . y !== 0 || camera . width !== gl . canvas . width || camera . height !== gl . canvas . height ) ;
500+ var pipeline = null ;
499501
500502 gl . clearColor ( color . redGL , color . greenGL , color . blueGL , color . alphaGL ) ;
501503 gl . clear ( gl . COLOR_BUFFER_BIT | gl . DEPTH_BUFFER_BIT | gl . STENCIL_BUFFER_BIT ) ;
502504
505+ this . currentScissorState . enabled = scissorEnabled ;
506+
507+ if ( scissorEnabled )
508+ {
509+ gl . enable ( gl . SCISSOR_TEST ) ;
510+ this . currentScissorState . x = camera . x ;
511+ this . currentScissorState . y = gl . drawingBufferHeight - camera . y - camera . height ;
512+ this . currentScissorState . width = camera . width ;
513+ this . currentScissorState . height = camera . height ;
514+
515+ gl . scissor ( this . currentScissorState . x , this . currentScissorState . y , this . currentScissorState . width , this . currentScissorState . height ) ;
516+ }
517+
503518 for ( var index = 0 ; index < childCount ; ++ index )
504519 {
505520 var child = list [ index ] ;
@@ -509,8 +524,34 @@ var WebGLRenderer = new Class({
509524 continue ;
510525 }
511526
527+ if ( child . blendMode !== this . currentBlendMode )
528+ {
529+ this . setBlendMode ( child . blendMode ) ;
530+ }
531+
532+ if ( child . mask )
533+ {
534+ child . mask . preRenderWebGL ( this , child , camera ) ;
535+ }
536+
512537 child . renderWebGL ( this , child , interpolationPercentage , camera ) ;
513538
539+ if ( child . mask )
540+ {
541+ child . mask . postRenderWebGL ( this , child ) ;
542+ }
543+
544+ pipeline = this . currentPipeline ;
545+
546+ if ( pipeline && pipeline . shouldFlush ( ) )
547+ {
548+ pipeline . flush ( ) ;
549+ }
550+ }
551+
552+ if ( scissorEnabled )
553+ {
554+ gl . disable ( gl . SCISSOR_TEST ) ;
514555 }
515556 } ,
516557
0 commit comments