@@ -4,7 +4,6 @@ var pathArray = [];
44var cos = Math . cos ;
55var sin = Math . sin ;
66
7-
87var Point = function ( x , y )
98{
109 this . x = x ;
@@ -14,7 +13,8 @@ var Point = function (x, y)
1413var Path = function ( x , y )
1514{
1615 this . points = [ ] ;
17- this . points . push ( new Point ( x , y ) ) ;
16+ this . pointsLength = 1 ;
17+ this . points [ 0 ] = new Point ( x , y ) ;
1818} ;
1919
2020var lerp = function ( norm , min , max )
@@ -71,6 +71,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
7171 var path ;
7272 var pathLength ;
7373 var point ;
74+ var maxVertices = shapeBatch . maxVertices ;
7475
7576 renderer . setBatch ( shapeBatch , null ) ;
7677
@@ -127,11 +128,15 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
127128 }
128129 break ;
129130 case Commands . FILL_PATH :
130- for ( var pathArrayIndex = 0 , pathArrayLength = pathArray . length ; pathArrayIndex < pathArrayLength ; ++ pathArrayIndex )
131+ for ( var pathArrayIndex = 0 , pathArrayLength = pathArray . length ;
132+ pathArrayIndex < pathArrayLength ;
133+ ++ pathArrayIndex )
131134 {
132135 path = pathArray [ pathArrayIndex ] . points ;
133136 pathLength = path . length ;
134- for ( var pathIndex = 0 ; pathIndex < pathLength ; ++ pathIndex )
137+ for ( var pathIndex = 0 ;
138+ pathIndex < pathLength ;
139+ ++ pathIndex )
135140 {
136141 point = path [ pathIndex ] ;
137142 polygon . push ( point . x , point . y ) ;
@@ -142,6 +147,11 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
142147 v0 = polygonIndex [ index + 0 ] * 2 ;
143148 v1 = polygonIndex [ index + 1 ] * 2 ;
144149 v2 = polygonIndex [ index + 2 ] * 2 ;
150+ if ( vertexCount + 3 > maxVertices )
151+ {
152+ shapeBatch . flush ( ) ;
153+ vertexCount = 0 ;
154+ }
145155 vertexOffset = vertexDataBuffer . allocate ( 9 * 3 ) ;
146156 vertexCount += 3 ;
147157
@@ -188,14 +198,18 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
188198 vertexBufferF32 [ vertexOffset ++ ] = srcScaleX ;
189199 vertexBufferF32 [ vertexOffset ++ ] = srcScaleY ;
190200 vertexBufferF32 [ vertexOffset ++ ] = srcRotation ;
191-
192201 }
193202 polygon . length = 0 ;
194203 }
195204 break ;
196205 case Commands . STROKE_PATH :
197206 break ;
198207 case Commands . FILL_RECT :
208+ if ( vertexCount + 6 > maxVertices )
209+ {
210+ shapeBatch . flush ( ) ;
211+ vertexCount = 0 ;
212+ }
199213 vertexOffset = vertexDataBuffer . allocate ( 9 * 6 ) ;
200214 vertexCount += 6 ;
201215
@@ -262,13 +276,6 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
262276 vertexBufferF32 [ vertexOffset ++ ] = srcScaleX ;
263277 vertexBufferF32 [ vertexOffset ++ ] = srcScaleY ;
264278 vertexBufferF32 [ vertexOffset ++ ] = srcRotation ;
265-
266- cmdIndex += 4 ;
267- break ;
268- case Commands . STROKE_CIRCLE :
269- cmdIndex += 3 ;
270- break ;
271- case Commands . STROKE_RECT :
272279 cmdIndex += 4 ;
273280 break ;
274281 case Commands . LINE_TO :
0 commit comments