Added path to gulpfile.

This commit is contained in:
2019-08-06 15:34:57 +02:00
parent a42427f987
commit 141d27d4f1
6 changed files with 96 additions and 166 deletions
+17 -29
View File
@@ -62,7 +62,7 @@ export class TileLoader {
_textureAvailable(url, col, row, texture) {
let tile = this.loaded.get(url)
if (tile != null) {
console.warn("Tile already loaded")
console.warn('Tile already loaded')
tile.unregister()
}
try {
@@ -70,9 +70,8 @@ export class TileLoader {
this.loaded.set(url, tile)
this.tiles.tileAvailable(tile, col, row, url)
} catch (error) {
console.warn("Tile loading error", error)
console.warn('Tile loading error', error)
}
}
}
@@ -82,7 +81,6 @@ export class TileLoader {
* Calls the Tiles.tileAvailable method if the texture is available.
**/
export class PIXITileLoader extends TileLoader {
constructor(tiles, compression) {
super(tiles)
this.destroyed = false
@@ -124,15 +122,13 @@ export class PIXITileLoader extends TileLoader {
/** Load one and only one of the scheduled tiles **/
loadOneTile() {
if (this.destroyed)
return
if (this.destroyed) return
this._loadOneTile()
}
/** Load all scheduled tiles **/
loadAll() {
if (this.destroyed)
return
if (this.destroyed) return
this._loadAllTiles()
}
@@ -143,7 +139,7 @@ export class PIXITileLoader extends TileLoader {
try {
this.loader.reset()
} catch (error) {
console.warn("Error while resetting loader", error)
console.warn('Error while resetting loader', error)
}
}
@@ -162,15 +158,14 @@ export class PIXITileLoader extends TileLoader {
let texture = resource.texture
let url = resource.url
Tile.lateTexture(url, texture)
console.warn("Received resource after destroy", texture)
console.warn('Received resource after destroy', texture)
return
}
try {
let [col, row] = this.map.get(resource.url)
this._textureAvailable(resource.url, col, row, resource.texture)
}
catch (err) {
console.warn("Texture unavailable: " + err.message)
} catch (err) {
console.warn('Texture unavailable: ' + err.message)
}
}
@@ -216,9 +211,8 @@ export class PIXITileLoader extends TileLoader {
if (!this.loaded.has(url)) {
let resource = this.loader.resources[url]
if (resource) {
console.log("Resource already added", url)
}
else {
console.log('Resource already added', url)
} else {
urls.push(url)
i += 1
}
@@ -237,7 +231,6 @@ export class PIXITileLoader extends TileLoader {
* Calls the Tiles.tileAvailable method if the texture is available.
**/
export class RequestTileLoader extends TileLoader {
constructor(tiles, compression) {
super(tiles)
this.compression = compression
@@ -255,10 +248,7 @@ export class RequestTileLoader extends TileLoader {
xhr.responseType = 'arraybuffer'
xhr.onload = e => {
let CompressedImage = PIXI.compressedTextures.CompressedImage
let compressed = CompressedImage.loadFromArrayBuffer(
xhr.response,
url
)
let compressed = CompressedImage.loadFromArrayBuffer(xhr.response, url)
let base = new PIXI.BaseTexture(compressed)
let texture = new PIXI.Texture(base)
this._textureAvailable(url, col, row, texture)
@@ -319,20 +309,18 @@ export class RequestTileLoader extends TileLoader {
}
}
/**
* Uses Workers but can be replaced with other loaders implementing
* the public methods without underscore.
* Calls the Tiles.tileAvailable method if the texture is available.
**/
export class WorkerTileLoader extends TileLoader {
constructor(tiles, workerPath) {
super(tiles)
let worker = this.worker = new Worker(workerPath)
let worker = (this.worker = new Worker(workerPath))
worker.onmessage = (event) => {
worker.onmessage = event => {
if (event.data.success) {
let { url, col, row, buffer } = event.data
//console.log("WorkerTileLoader.loaded", url, buffer)
@@ -350,7 +338,7 @@ export class WorkerTileLoader extends TileLoader {
let url = this.loadQueue.pop()
let [col, row] = this.map.get(url)
let tile = [col, row, url]
this.worker.postMessage({ command: "load", tiles: [tile] })
this.worker.postMessage({ command: 'load', tiles: [tile] })
}
}
@@ -361,16 +349,16 @@ export class WorkerTileLoader extends TileLoader {
let [col, row] = this.map.get(url)
tiles.push([col, row, url])
}
this.worker.postMessage({ command: "load", tiles })
this.worker.postMessage({ command: 'load', tiles })
}
cancel() {
super.cancel()
this.worker.postMessage({ command: "abort" })
this.worker.postMessage({ command: 'abort' })
}
destroy() {
this.worker.postMessage({ command: "abort" })
this.worker.postMessage({ command: 'abort' })
this.worker.terminate()
this.worker = null
super.destroy()