@@ -202,6 +202,130 @@ var TextureTintPipeline = new Class({
202202 }
203203 } ,
204204
205+ batchTexture : function (
206+ texture ,
207+ dstX , dstY ,
208+ scaleX , scaleY ,
209+ rotation ,
210+ flipX , flipY ,
211+ scrollFactorX , scrollFactorY ,
212+ displayOriginX , displayOriginY ,
213+ frameX , frameY , frameWidth , frameHeight ,
214+ tintTL , tintTR , tintBL , tintBR ,
215+ camera )
216+ {
217+ this . renderer . setPipeline ( this ) ;
218+
219+ if ( this . vertexCount + 6 > this . vertexCapacity )
220+ {
221+ this . flush ( ) ;
222+ }
223+
224+ flipY = flipY ^ ( texture . isRenderTexture ? 1 : 0 ) ;
225+ rotation = - rotation ;
226+
227+ var getTint = Utils . getTintAppendFloatAlpha ;
228+ var vertexViewF32 = this . vertexViewF32 ;
229+ var vertexViewU32 = this . vertexViewU32 ;
230+ var renderer = this . renderer ;
231+ var cameraMatrix = camera . matrix . matrix ;
232+ var cameraWidth = camera . width + 50 ;
233+ var cameraHeight = camera . height + 50 ;
234+ var cameraX = - 50 ;
235+ var cameraY = - 50 ;
236+ var width = frameWidth * ( flipX ? - 1.0 : 1.0 ) ;
237+ var height = frameHeight * ( flipY ? - 1.0 : 1.0 ) ;
238+ var x = - displayOriginX + frameX + ( ( frameWidth ) * ( flipX ? 1.0 : 0.0 ) ) ;
239+ var y = - displayOriginY + frameY + ( ( frameHeight ) * ( flipY ? 1.0 : 0.0 ) ) ;
240+ var xw = x + width ;
241+ var yh = y + height ;
242+ var translateX = dstX - camera . scrollX * scrollFactorX ;
243+ var translateY = dstY - camera . scrollY * scrollFactorY ;
244+ var sr = Math . sin ( rotation ) ;
245+ var cr = Math . cos ( rotation ) ;
246+ var sra = cr * scaleX ;
247+ var srb = - sr * scaleX ;
248+ var src = sr * scaleY ;
249+ var srd = cr * scaleY ;
250+ var sre = translateX ;
251+ var srf = translateY ;
252+ var cma = cameraMatrix [ 0 ] ;
253+ var cmb = cameraMatrix [ 1 ] ;
254+ var cmc = cameraMatrix [ 2 ] ;
255+ var cmd = cameraMatrix [ 3 ] ;
256+ var cme = cameraMatrix [ 4 ] ;
257+ var cmf = cameraMatrix [ 5 ] ;
258+ var mva = sra * cma + srb * cmc ;
259+ var mvb = sra * cmb + srb * cmd ;
260+ var mvc = src * cma + srd * cmc ;
261+ var mvd = src * cmb + srd * cmd ;
262+ var mve = sre * cma + srf * cmc + cme ;
263+ var mvf = sre * cmb + srf * cmd + cmf ;
264+ var tx0 = x * mva + y * mvc + mve ;
265+ var ty0 = x * mvb + y * mvd + mvf ;
266+ var tx1 = x * mva + yh * mvc + mve ;
267+ var ty1 = x * mvb + yh * mvd + mvf ;
268+ var tx2 = xw * mva + yh * mvc + mve ;
269+ var ty2 = xw * mvb + yh * mvd + mvf ;
270+ var tx3 = xw * mva + y * mvc + mve ;
271+ var ty3 = xw * mvb + y * mvd + mvf ;
272+ var vertexOffset = 0 ;
273+
274+ if ( ( tx0 < cameraX || tx0 > cameraWidth || ty0 < cameraY || ty0 > cameraHeight ) &&
275+ ( tx1 < cameraX || tx1 > cameraWidth || ty1 < cameraY || ty1 > cameraHeight ) &&
276+ ( tx2 < cameraX || tx2 > cameraWidth || ty2 < cameraY || ty2 > cameraHeight ) &&
277+ ( tx3 < cameraX || tx3 > cameraWidth || ty3 < cameraY || ty3 > cameraHeight ) )
278+ {
279+ return ;
280+ }
281+
282+ var u0 = frameX / texture . width ;
283+ var v0 = frameY / texture . height ;
284+ var u1 = frameX / texture . width ;
285+ var v1 = ( frameY + frameHeight ) / texture . height ;
286+ var u2 = ( frameX + frameWidth ) / texture . width ;
287+ var v2 = ( frameY + frameHeight ) / texture . height ;
288+ var u3 = ( frameX + frameWidth ) / texture . width ;
289+ var v3 = frameY / texture . height ;
290+
291+ renderer . setTexture2D ( texture , 0 ) ;
292+
293+ vertexOffset = this . vertexCount * this . vertexComponentCount ;
294+
295+ vertexViewF32 [ vertexOffset + 0 ] = tx0 ;
296+ vertexViewF32 [ vertexOffset + 1 ] = ty0 ;
297+ vertexViewF32 [ vertexOffset + 2 ] = u0 ;
298+ vertexViewF32 [ vertexOffset + 3 ] = v0 ;
299+ vertexViewU32 [ vertexOffset + 4 ] = tintTL ;
300+ vertexViewF32 [ vertexOffset + 5 ] = tx1 ;
301+ vertexViewF32 [ vertexOffset + 6 ] = ty1 ;
302+ vertexViewF32 [ vertexOffset + 7 ] = u1 ;
303+ vertexViewF32 [ vertexOffset + 8 ] = v1 ;
304+ vertexViewU32 [ vertexOffset + 9 ] = tintTR ;
305+ vertexViewF32 [ vertexOffset + 10 ] = tx2 ;
306+ vertexViewF32 [ vertexOffset + 11 ] = ty2 ;
307+ vertexViewF32 [ vertexOffset + 12 ] = u2 ;
308+ vertexViewF32 [ vertexOffset + 13 ] = v2 ;
309+ vertexViewU32 [ vertexOffset + 14 ] = tintBL ;
310+ vertexViewF32 [ vertexOffset + 15 ] = tx0 ;
311+ vertexViewF32 [ vertexOffset + 16 ] = ty0 ;
312+ vertexViewF32 [ vertexOffset + 17 ] = u0 ;
313+ vertexViewF32 [ vertexOffset + 18 ] = v0 ;
314+ vertexViewU32 [ vertexOffset + 19 ] = tintTL ;
315+ vertexViewF32 [ vertexOffset + 20 ] = tx2 ;
316+ vertexViewF32 [ vertexOffset + 21 ] = ty2 ;
317+ vertexViewF32 [ vertexOffset + 22 ] = u2 ;
318+ vertexViewF32 [ vertexOffset + 23 ] = v2 ;
319+ vertexViewU32 [ vertexOffset + 24 ] = tintBL ;
320+ vertexViewF32 [ vertexOffset + 25 ] = tx3 ;
321+ vertexViewF32 [ vertexOffset + 26 ] = ty3 ;
322+ vertexViewF32 [ vertexOffset + 27 ] = u3 ;
323+ vertexViewF32 [ vertexOffset + 28 ] = v3 ;
324+ vertexViewU32 [ vertexOffset + 29 ] = tintBR ;
325+
326+ this . vertexCount += 6 ;
327+ } ,
328+
205329 batchSprite : function ( sprite , camera )
206330 {
207331 this . renderer . setPipeline ( this ) ;
0 commit comments