@@ -109,7 +109,7 @@ BlitterBatch.prototype = {
109109
110110 // Populate the index buffer only once
111111 for ( var indexA = 0 , indexB = 0 ; indexA < max ; indexA += CONST . PARTICLE_INDEX_COUNT , indexB += CONST . PARTICLE_VERTEX_COUNT )
112- {
112+ {
113113 indexBuffer [ indexA + 0 ] = indexB + 0 ;
114114 indexBuffer [ indexA + 1 ] = indexB + 1 ;
115115 indexBuffer [ indexA + 2 ] = indexB + 2 ;
@@ -131,54 +131,42 @@ BlitterBatch.prototype = {
131131 return ( this . vertexDataBuffer . getByteLength ( ) >= this . vertexDataBuffer . getByteCapacity ( ) ) ;
132132 } ,
133133
134- add : function ( x , y , width , height , umin , vmin , umax , vmax )
134+ add : function ( x , y , frame )
135135 {
136- this . manager . setBatch ( this ) ;
136+ this . manager . setBatch ( this , frame . texture . source [ 0 ] . glTexture ) ;
137137
138138 // The user must check if the buffers are full before flushing
139139 // this is to give freedom of when should the renderer flush. var vertexDataBuffer = this.vertexDataBuffer;
140140 var vertexDataBuffer = this . vertexDataBuffer ;
141141 var vertexBuffer = vertexDataBuffer . floatView ;
142142 var vertexOffset = vertexDataBuffer . allocate ( CONST . PARTICLE_VERTEX_COMPONENT_COUNT * CONST . PARTICLE_VERTEX_COUNT ) ;
143+ var uvs = frame . uvs ;
144+ var width = frame . width ;
145+ var height = frame . height ;
143146
144147 vertexBuffer [ vertexOffset ++ ] = x ;
145148 vertexBuffer [ vertexOffset ++ ] = y ;
146- vertexBuffer [ vertexOffset ++ ] = umin ;
147- vertexBuffer [ vertexOffset ++ ] = vmin ;
149+ vertexBuffer [ vertexOffset ++ ] = uvs . x0 ;
150+ vertexBuffer [ vertexOffset ++ ] = uvs . y0 ;
148151
149152 vertexBuffer [ vertexOffset ++ ] = x ;
150153 vertexBuffer [ vertexOffset ++ ] = y + height ;
151- vertexBuffer [ vertexOffset ++ ] = umin ;
152- vertexBuffer [ vertexOffset ++ ] = vmax ;
154+ vertexBuffer [ vertexOffset ++ ] = uvs . x1 ;
155+ vertexBuffer [ vertexOffset ++ ] = uvs . y1 ;
153156
154157 vertexBuffer [ vertexOffset ++ ] = x + width ;
155158 vertexBuffer [ vertexOffset ++ ] = y + height ;
156- vertexBuffer [ vertexOffset ++ ] = umax ;
157- vertexBuffer [ vertexOffset ++ ] = vmax ;
159+ vertexBuffer [ vertexOffset ++ ] = uvs . x2 ;
160+ vertexBuffer [ vertexOffset ++ ] = uvs . y2 ;
158161
159162 vertexBuffer [ vertexOffset ++ ] = x + width ;
160163 vertexBuffer [ vertexOffset ++ ] = y ;
161- vertexBuffer [ vertexOffset ++ ] = umax ;
162- vertexBuffer [ vertexOffset ++ ] = vmin ;
164+ vertexBuffer [ vertexOffset ++ ] = uvs . x3 ;
165+ vertexBuffer [ vertexOffset ++ ] = uvs . y3 ;
163166
164167 this . elementCount += CONST . PARTICLE_INDEX_COUNT ;
165168 } ,
166169
167- setTexture2D : function ( texture2D , force )
168- {
169- var gl = this . glContext ;
170-
171- if ( this . currentTexture2D !== texture2D || force )
172- {
173- this . flush ( ) ;
174-
175- gl . activeTexture ( gl . TEXTURE0 ) ;
176- gl . bindTexture ( gl . TEXTURE_2D , texture2D ) ;
177-
178- this . currentTexture2D = texture2D ;
179- }
180- } ,
181-
182170 bind : function ( )
183171 {
184172 var gl = this . glContext ;
0 commit comments