@@ -109,48 +109,50 @@ var _WebGL_enableSampleAlphaToCoverage = F2(function (gl, setting) {
109109} ) ;
110110
111111// eslint-disable-next-line no-unused-vars
112- var _WebGL_disableBlend = function ( gl ) {
113- gl . disable ( gl . BLEND ) ;
112+ var _WebGL_disableBlend = function ( cache ) {
113+ cache . gl . disable ( cache . gl . BLEND ) ;
114114} ;
115115
116116// eslint-disable-next-line no-unused-vars
117- var _WebGL_disableDepthTest = function ( gl ) {
118- gl . disable ( gl . DEPTH_TEST ) ;
117+ var _WebGL_disableDepthTest = function ( cache ) {
118+ cache . gl . disable ( cache . gl . DEPTH_TEST ) ;
119+ cache . gl . depthMask ( true ) ;
119120} ;
120121
121122// eslint-disable-next-line no-unused-vars
122- var _WebGL_disableStencilTest = function ( gl ) {
123- gl . disable ( gl . STENCIL_TEST ) ;
123+ var _WebGL_disableStencilTest = function ( cache ) {
124+ cache . gl . disable ( cache . gl . STENCIL_TEST ) ;
125+ cache . gl . stencilMask ( cache . STENCIL_WRITEMASK ) ;
124126} ;
125127
126128// eslint-disable-next-line no-unused-vars
127- var _WebGL_disableScissor = function ( gl ) {
128- gl . disable ( gl . SCISSOR_TEST ) ;
129+ var _WebGL_disableScissor = function ( cache ) {
130+ cache . gl . disable ( cache . gl . SCISSOR_TEST ) ;
129131} ;
130132
131133// eslint-disable-next-line no-unused-vars
132- var _WebGL_disableColorMask = function ( gl ) {
133- gl . colorMask ( true , true , true , true ) ;
134+ var _WebGL_disableColorMask = function ( cache ) {
135+ cache . gl . colorMask ( true , true , true , true ) ;
134136} ;
135137
136138// eslint-disable-next-line no-unused-vars
137- var _WebGL_disableCullFace = function ( gl ) {
138- gl . disable ( gl . CULL_FACE ) ;
139+ var _WebGL_disableCullFace = function ( cache ) {
140+ cache . gl . disable ( cache . gl . CULL_FACE ) ;
139141} ;
140142
141143// eslint-disable-next-line no-unused-vars
142- var _WebGL_disablePolygonOffset = function ( gl ) {
143- gl . disable ( gl . POLYGON_OFFSET_FILL ) ;
144+ var _WebGL_disablePolygonOffset = function ( cache ) {
145+ cache . gl . disable ( cache . gl . POLYGON_OFFSET_FILL ) ;
144146} ;
145147
146148// eslint-disable-next-line no-unused-vars
147- var _WebGL_disableSampleCoverage = function ( gl ) {
148- gl . disable ( gl . SAMPLE_COVERAGE ) ;
149+ var _WebGL_disableSampleCoverage = function ( cache ) {
150+ cache . gl . disable ( cache . gl . SAMPLE_COVERAGE ) ;
149151} ;
150152
151153// eslint-disable-next-line no-unused-vars
152- var _WebGL_disableSampleAlphaToCoverage = function ( gl ) {
153- gl . disable ( gl . SAMPLE_ALPHA_TO_COVERAGE ) ;
154+ var _WebGL_disableSampleAlphaToCoverage = function ( cache ) {
155+ cache . gl . disable ( cache . gl . SAMPLE_ALPHA_TO_COVERAGE ) ;
154156} ;
155157
156158function _WebGL_doCompile ( gl , src , type ) {
@@ -446,15 +448,11 @@ var _WebGL_drawGL = F2(function (model, domNode) {
446448 }
447449 }
448450 }
449- _WebGL_listEach ( function ( setting ) {
450- return A2 ( __WI_enableSetting , gl , setting ) ;
451- } , entity . __settings ) ;
451+ _WebGL_listEach ( __WI_enableSetting ( gl ) , entity . __settings ) ;
452452
453453 gl . drawElements ( entity . __mesh . a . __$mode , buffer . numIndices , gl . UNSIGNED_SHORT , 0 ) ;
454454
455- _WebGL_listEach ( function ( setting ) {
456- return A2 ( __WI_disableSetting , gl , setting ) ;
457- } , entity . __settings ) ;
455+ _WebGL_listEach ( __WI_disableSetting ( model . __cache ) , entity . __settings ) ;
458456
459457 }
460458
@@ -631,6 +629,9 @@ function _WebGL_render(model) {
631629 model . __cache . programs = { } ;
632630 model . __cache . buffers = new WeakMap ( ) ;
633631 model . __cache . textures = new WeakMap ( ) ;
632+ // Memorize the initial stencil write mask, because
633+ // browsers may have different number of stencil bits
634+ model . __cache . STENCIL_WRITEMASK = gl . getParameter ( gl . STENCIL_WRITEMASK ) ;
634635
635636 // Render for the first time.
636637 // This has to be done in animation frame,
0 commit comments