diff --git a/dist/iwmlib.pixi.js b/dist/iwmlib.pixi.js index 1fe4da9..706334d 100644 --- a/dist/iwmlib.pixi.js +++ b/dist/iwmlib.pixi.js @@ -8323,9 +8323,11 @@ **/ class WorkerTileLoader extends TileLoader { - constructor(tiles) { + constructor(tiles, workerPath) { super(tiles); - let worker = this.worker = new Worker("../../lib/pixi/deepzoom/tileloader.js"); + + let worker = this.worker = new Worker(workerPath); + worker.onmessage = (event) => { if (event.data.success) { let { url, col, row, buffer } = event.data; @@ -8417,10 +8419,11 @@ this.tileScale = scale; this.fadeInTime = fadeInTime; this.keep = false; - if (this.view.preferWorker && view.info.compression.length > 0) - this.loader = new WorkerTileLoader(this); - else + if (this.view.useWorker && view.info.compression && view.info.compression.length > 0) { + this.loader = new WorkerTileLoader(this, this.view.useWorker); + } else { this.loader = new PIXITileLoader(this, view.info.compression); + } this.interactive = false; this._highlight = null; @@ -9043,7 +9046,7 @@ world = null, // Defines the world bounds the images lives in highResolution = true, autoLoadTiles = true, - preferWorker = false, + useWorker = '', minimumLevel = 0, alpha = 1, app = window.app @@ -9054,7 +9057,7 @@ this.debug = debug; this.shadow = shadow; this.world = world; - this.preferWorker = preferWorker; + this.useWorker = useWorker; this.resolution = highResolution ? Math.round(window.devicePixelRatio) : 1; diff --git a/lib/pixi/deepzoom/image.js b/lib/pixi/deepzoom/image.js index 01aab0e..a15b576 100755 --- a/lib/pixi/deepzoom/image.js +++ b/lib/pixi/deepzoom/image.js @@ -344,7 +344,7 @@ export class DeepZoomImage extends PIXI.Container { world = null, // Defines the world bounds the images lives in highResolution = true, autoLoadTiles = true, - preferWorker = false, + useWorker = '', minimumLevel = 0, alpha = 1, app = window.app @@ -355,7 +355,7 @@ export class DeepZoomImage extends PIXI.Container { this.debug = debug this.shadow = shadow this.world = world - this.preferWorker = preferWorker + this.useWorker = useWorker this.resolution = highResolution ? Math.round(window.devicePixelRatio) : 1 diff --git a/lib/pixi/deepzoom/loader.js b/lib/pixi/deepzoom/loader.js index 06dcaf2..81a5878 100644 --- a/lib/pixi/deepzoom/loader.js +++ b/lib/pixi/deepzoom/loader.js @@ -327,9 +327,11 @@ export class RequestTileLoader extends TileLoader { **/ export class WorkerTileLoader extends TileLoader { - constructor(tiles) { + constructor(tiles, workerPath) { super(tiles) - let worker = this.worker = new Worker("../../lib/pixi/deepzoom/tileloader.js") + + let worker = this.worker = new Worker(workerPath) + worker.onmessage = (event) => { if (event.data.success) { let { url, col, row, buffer } = event.data diff --git a/lib/pixi/deepzoom/tileloader.js b/lib/pixi/deepzoom/tileloader.js index 3a382e3..88215b1 100644 --- a/lib/pixi/deepzoom/tileloader.js +++ b/lib/pixi/deepzoom/tileloader.js @@ -9,7 +9,7 @@ function load() { let tile = loadQueue.shift() let [col, row, url] = tile let xhr = new XMLHttpRequest() - xhr.responseType = "arraybuffer" + xhr.responseType = 'arraybuffer' xhr.onload = (event) => { pendingRequests.delete(url) let buffer = xhr.response @@ -27,7 +27,7 @@ function load() { if (loadQueue.length>0) setTimeout(load, 1000/120) else { - if (debug) console.log("Ready") + if (debug) console.log('Ready') } } diff --git a/lib/pixi/deepzoom/tiles.js b/lib/pixi/deepzoom/tiles.js index 834e362..c0bab2f 100644 --- a/lib/pixi/deepzoom/tiles.js +++ b/lib/pixi/deepzoom/tiles.js @@ -48,10 +48,11 @@ export class Tiles extends PIXI.Container { this.tileScale = scale this.fadeInTime = fadeInTime this.keep = false - if (this.view.preferWorker && view.info.compression.length > 0) - this.loader = new WorkerTileLoader(this) - else + if (this.view.useWorker && view.info.compression && view.info.compression.length > 0) { + this.loader = new WorkerTileLoader(this, this.view.useWorker) + } else { this.loader = new PIXITileLoader(this, view.info.compression) + } this.interactive = false this._highlight = null diff --git a/lib/pixi/deepzoom/worker/module.html b/lib/pixi/deepzoom/worker/module.html new file mode 100644 index 0000000..d38f81c --- /dev/null +++ b/lib/pixi/deepzoom/worker/module.html @@ -0,0 +1,39 @@ + + + + + + + DeepZoomImage Worker Doctests + + + + + + + + + + + + + +

DeepZoomImage with tiles loaded by a worker...

+

...from inside a module.

+
+
+ + + + diff --git a/lib/pixi/deepzoom/worker/module.js b/lib/pixi/deepzoom/worker/module.js new file mode 100644 index 0000000..1d0e998 --- /dev/null +++ b/lib/pixi/deepzoom/worker/module.js @@ -0,0 +1,54 @@ +import PIXIApp from '../../app.js' +import {DeepZoomInfo, DeepZoomImage} from '../image.js' +import {ScatterContainer, DisplayObjectScatter} from '../../scatter.js' + +// deepZoom +//-------------------- +const deepZoomInfo = new DeepZoomInfo({ + compression: ["dds"], + clip: { + minLevel: 12, + maxLevel: 20, + startCol: 275215, + startRow: 181050, + bounds: { + min: [48.458353, 8.96484374976547], + max: [48.5747899110263, 9.14062499976523] + } + }, + tileSize: 512, + format: "png", + overlap: 0, + type: "map", + height: 131072, + width: 131072, + path: "../../../../Tuesch/var/luftbild/2018", + urlTileTemplate: "{path}/{level}/{row}/{column}.{format}" +}) + +// app +//-------------------- +const app = new PIXIApp({ + width: 800, + height: 500 +}).setup().run() + +div1.appendChild(app.view) + +// create the ScatterContainer +//-------------------- +const scatterContainer = new ScatterContainer(app.renderer, {showBounds: true, app: app}) +app.scene.addChild(scatterContainer) + +// Create the DeepZoomImage +//-------------------- +const deepZoomImage = new DeepZoomImage(deepZoomInfo, {app, world: scatterContainer, useWorker: '../tileloader.js'}) +deepZoomImage.scatter = new DisplayObjectScatter(deepZoomImage, app.renderer, { + minScale: 0, + maxScale: 50, + onTransform: event => { + deepZoomImage.transformed(event) + } +}) + +scatterContainer.addChild(deepZoomImage) \ No newline at end of file diff --git a/lib/pixi/deepzoom/worker/script.html b/lib/pixi/deepzoom/worker/script.html new file mode 100644 index 0000000..d2b0fe6 --- /dev/null +++ b/lib/pixi/deepzoom/worker/script.html @@ -0,0 +1,91 @@ + + + + + + + DeepZoomImage Worker Doctests + + + + + + + + + + + + + + +

DeepZoomImage with tiles loaded by a worker...

+

...using the dist variants.

+
+
+ + + +