@@ -24,28 +24,30 @@ PIXI.Tilemap = function (texture, displayWidth, displayHeight, mapWidth, mapHeig
2424 PIXI . DisplayObjectContainer . call ( this ) ;
2525
2626 /**
27- * The clipping limit of the display area.
27+ * The texture of the Tilemap
2828 *
29- * @property displayWidth
30- * @type integer
29+ * @property texture
30+ * @type Texture
3131 */
32- this . displayWidth = displayWidth ;
32+ this . texture = texture ;
3333
3434 /**
3535 * The clipping limit of the display area.
3636 *
37- * @property displayHeight
37+ * @property _displayWidth
3838 * @type integer
39+ * @private
3940 */
40- this . displayHeight = displayHeight ;
41+ this . _displayWidth = displayWidth ;
4142
4243 /**
43- * The texture of the Tilemap
44+ * The clipping limit of the display area.
4445 *
45- * @property texture
46- * @type Texture
46+ * @property _displayHeight
47+ * @type integer
48+ * @private
4749 */
48- this . texture = texture ;
50+ this . _displayHeight = displayHeight ;
4951
5052 /**
5153 * The width of a single tile in pixels.
@@ -289,26 +291,26 @@ PIXI.Tilemap.prototype._renderBatch = function (renderSession) {
289291 }
290292
291293 // calculate the destination location of the tile in screen units (-1..1)
292- buffer [ c ] = buffer [ c + 4 ] = lft ;
293- buffer [ c + 1 ] = buffer [ c + 9 ] = bot ;
294- buffer [ c + 8 ] = buffer [ c + 12 ] = oldR = x + wide ;
295- buffer [ c + 5 ] = buffer [ c + 13 ] = oldT = y - high ;
294+ buffer [ c ] = buffer [ c + 4 ] = lft ;
295+ buffer [ c + 1 ] = buffer [ c + 9 ] = bot ;
296+ buffer [ c + 8 ] = buffer [ c + 12 ] = oldR = x + wide ;
297+ buffer [ c + 5 ] = buffer [ c + 13 ] = oldT = y - high ;
296298
297299 // calculate the uv coordinates of the tile source image
298300 if ( t . fd === 1 )
299301 {
300302 // flipped diagonally, swap x,y axes
301- buffer [ c + 14 ] = buffer [ c + 6 ] = uvl ;
302- buffer [ c + 15 ] = buffer [ c + 11 ] = uvt ;
303- buffer [ c + 10 ] = buffer [ c + 2 ] = uvl + t . sw * iTextureWide ;
304- buffer [ c + 7 ] = buffer [ c + 3 ] = uvt + t . sh * iTextureHigh ;
303+ buffer [ c + 14 ] = buffer [ c + 6 ] = uvl ;
304+ buffer [ c + 15 ] = buffer [ c + 11 ] = uvt ;
305+ buffer [ c + 10 ] = buffer [ c + 2 ] = uvl + t . sw * iTextureWide ;
306+ buffer [ c + 7 ] = buffer [ c + 3 ] = uvt + t . sh * iTextureHigh ;
305307 }
306308 else
307309 {
308- buffer [ c + 2 ] = buffer [ c + 6 ] = uvl ;
309- buffer [ c + 3 ] = buffer [ c + 11 ] = uvt ;
310- buffer [ c + 10 ] = buffer [ c + 14 ] = uvl + t . sw * iTextureWide ;
311- buffer [ c + 7 ] = buffer [ c + 15 ] = uvt + t . sh * iTextureHigh ;
310+ buffer [ c + 2 ] = buffer [ c + 6 ] = uvl ;
311+ buffer [ c + 3 ] = buffer [ c + 11 ] = uvt ;
312+ buffer [ c + 10 ] = buffer [ c + 14 ] = uvl + t . sw * iTextureWide ;
313+ buffer [ c + 7 ] = buffer [ c + 15 ] = uvt + t . sh * iTextureHigh ;
312314 }
313315
314316 // advance the buffer index
@@ -333,9 +335,9 @@ PIXI.Tilemap.prototype._renderBatch = function (renderSession) {
333335} ;
334336
335337/**
336- * render the entire tilemap using a fast webgl batched tile render
338+ * Render the entire tilemap using a fast WebGL batched tile render.
337339*
338- * @param {[type] } renderSession [description]
340+ * @param {Object } renderSession - The PIXI RenderSession.
339341*/
340342PIXI . Tilemap . prototype . _renderWholeTilemap = function ( renderSession ) {
341343
@@ -351,9 +353,9 @@ PIXI.Tilemap.prototype._renderWholeTilemap = function (renderSession) {
351353 gl . uniform2f ( shader . uOffset , renderSession . offset . x / this . game . width * 2 , - renderSession . offset . y / this . game . height * 2 ) ;
352354
353355 // set the clipping limits
354- gl . uniform2f ( shader . uClipOffset , this . offset . x / this . game . width * 2 , this . offset . y / this . game . height * 2 ) ;
355- gl . uniform2f ( shader . uClipLoc , this . offset . x , this . offset . y ) ;
356- gl . uniform2f ( shader . uClipLimit , this . displayWidth , this . game . height - this . displayHeight ) ;
356+ gl . uniform2f ( shader . uClipOffset , this . _offset . x / this . game . width * 2 , this . _offset . y / this . game . height * 2 ) ;
357+ gl . uniform2f ( shader . uClipLoc , this . _offset . x , this . _offset . y ) ;
358+ gl . uniform2f ( shader . uClipLimit , this . _offset . x + this . _displayWidth , this . game . height - ( this . _offset . y + this . _displayHeight ) ) ;
357359
358360 // set the offset in screen units to the center of the screen
359361 // and flip the GL y coordinate to be zero at the top
@@ -399,67 +401,3 @@ PIXI.Tilemap.prototype.onTextureUpdate = function () {
399401 this . updateFrame = true ;
400402
401403} ;
402-
403- /**
404- * Returns the bounds of the map as a rectangle. The bounds calculation takes the worldTransform into account.
405- *
406- * @method getBounds
407- * @param matrix {Matrix} the transformation matrix of the sprite
408- * @return {Rectangle } the framing rectangle
409- */
410- PIXI . Tilemap . prototype . getBounds = function ( matrix ) {
411-
412- var worldTransform = matrix || this . worldTransform ;
413-
414- var a = worldTransform . a ;
415- var b = worldTransform . b ;
416- var c = worldTransform . c ;
417- var d = worldTransform . d ;
418- var tx = worldTransform . tx ;
419- var ty = worldTransform . ty ;
420-
421- var maxX = - Infinity ;
422- var maxY = - Infinity ;
423-
424- var minX = Infinity ;
425- var minY = Infinity ;
426-
427- var vertices = [
428- 0 , 0 ,
429- this . mapWide * this . tileWide , 0 ,
430- this . mapWide * this . tileWide , this . mapHigh * this . tileHigh ,
431- 0 , this . mapHigh * this . tileHigh
432- ] ;
433-
434- for ( var i = 0 , n = vertices . length ; i < n ; i += 2 )
435- {
436- var rawX = vertices [ i ] , rawY = vertices [ i + 1 ] ;
437- var x = ( a * rawX ) + ( c * rawY ) + tx ;
438- var y = ( d * rawY ) + ( b * rawX ) + ty ;
439-
440- minX = x < minX ? x : minX ;
441- minY = y < minY ? y : minY ;
442-
443- maxX = x > maxX ? x : maxX ;
444- maxY = y > maxY ? y : maxY ;
445- }
446-
447- if ( minX === - Infinity || maxY === Infinity )
448- {
449- return PIXI . EmptyRectangle ;
450- }
451-
452- var bounds = this . _bounds ;
453-
454- bounds . x = minX ;
455- bounds . width = maxX - minX ;
456-
457- bounds . y = minY ;
458- bounds . height = maxY - minY ;
459-
460- // store a reference so that if this function gets called again in the render cycle we do not have to recalculate
461- this . _currentBounds = bounds ;
462-
463- return bounds ;
464-
465- } ;
0 commit comments