Fixed minor problems.
This commit is contained in:
parent
304818dc13
commit
0c46c4e656
@ -2,7 +2,7 @@
|
|||||||
const registeredTiles = new Map()
|
const registeredTiles = new Map()
|
||||||
const pendingTiles = new Map()
|
const pendingTiles = new Map()
|
||||||
/** Implements a baseTexture cache. The last textures are kept for reuse */
|
/** Implements a baseTexture cache. The last textures are kept for reuse */
|
||||||
const keepTextures = 0
|
let keepTextures = 0
|
||||||
const keptTextures = []
|
const keptTextures = []
|
||||||
|
|
||||||
/** The current Tile implementation simply uses PIXI.Sprites.
|
/** The current Tile implementation simply uses PIXI.Sprites.
|
||||||
@ -56,6 +56,13 @@ export default class Tile extends PIXI.Sprite {
|
|||||||
return pendingTiles.has(url) && pendingTiles.get(url) > 0
|
return pendingTiles.has(url) && pendingTiles.get(url) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static isObsolete(url) {
|
||||||
|
if (registeredTiles.has(url) && registeredTiles.get(url) > 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given url from pending urls.
|
* Removes the given url from pending urls.
|
||||||
*
|
*
|
||||||
@ -121,6 +128,7 @@ export default class Tile extends PIXI.Sprite {
|
|||||||
tiles.delete(this)
|
tiles.delete(this)
|
||||||
if (tiles.size == 0) {
|
if (tiles.size == 0) {
|
||||||
registeredTiles.delete(this.url)
|
registeredTiles.delete(this.url)
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
return tiles.size
|
return tiles.size
|
||||||
}
|
}
|
||||||
@ -142,9 +150,8 @@ export default class Tile extends PIXI.Sprite {
|
|||||||
super.destroy(opts)
|
super.destroy(opts)
|
||||||
|
|
||||||
while(keptTextures.length > keepTextures) {
|
while(keptTextures.length > keepTextures) {
|
||||||
let {url, texture} = keptTextures.shift()
|
let {url, texture} = keptTextures.shift()
|
||||||
let tiles = registeredTiles.get(url)
|
if (Tile.isObsolete(url)) {
|
||||||
if (tiles.size > 0 && !Tile.isPending(url)) {
|
|
||||||
texture.destroy(true) // Destroy base as well
|
texture.destroy(true) // Destroy base as well
|
||||||
if (debug) console.log("Destroying texture and baseTexture", url)
|
if (debug) console.log("Destroying texture and baseTexture", url)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user