From f85eeafe21bca30300b93bb6a621f18c3a0ae253 Mon Sep 17 00:00:00 2001 From: ponchio Date: Mon, 28 Aug 2023 11:47:20 +0200 Subject: [PATCH] added cachelevels option in layouttiles: When loading tiles, upper levels are loaded for faster feedback, cached zoom out, and avoiding missing tiles while rendering. Cachelevels option specify how many levels in the pyramid are loaded (default: 10). --- src/LayoutTiles.js | 3 +++ src/index.js | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/LayoutTiles.js b/src/LayoutTiles.js index 4f9767d7..0b111602 100644 --- a/src/LayoutTiles.js +++ b/src/LayoutTiles.js @@ -65,6 +65,7 @@ class LayoutTiles extends Layout { * @param {number} options.height The total height of the original, unsplit image. This parameter must only be specified for the 'google' layout type. * @param {string} options.suffix='jpg' The filename suffix of the tiles. * @param {string} options.subdomains='abc' The ('a'|'b'|'c') *s* subdomain of a Google template URL (for instance: 'https:{s}.my.example//{z}/{x}/{y}.png'). + * @param {number} options.cachelevels Number of levels above the current level which will be loaded. Lowering will reduce number of http requests, but image will have tile missing while loading. */ constructor(url, type, options) { super(url, null, options); @@ -80,6 +81,7 @@ class LayoutTiles extends Layout { qbox: [], //array of bounding box in tiles, one for mipmap bbox: [], //array of bounding box in pixels (w, h) urls: [], + cachelevels: 10, }); } @@ -282,6 +284,7 @@ class LayoutTiles extends Layout { let tile = tiles.get(index) || this.newTile(index); //{ index, x, y, missing, tex: [], level }; tile.time = now; tile.priority = neededBox.level - level; + if(tile.priority > this.cachelevels) continue; if (tile.missing === null) // || tile.missing != 0 && !this.requested[index]) tmp.push(tile); } diff --git a/src/index.js b/src/index.js index 997595c3..c28c5030 100644 --- a/src/index.js +++ b/src/index.js @@ -22,7 +22,7 @@ let lime = new Viewer('.openlime', { background: 'black', canvas: { preserveDraw //imageTest('google'); // image google deepzoom deepzoom1px zoomify iiif tarzoon itarzoom //flipTest(); //brdfTest(); -//rtiTest('rbf'); +rtiTest('rbf'); //tomeTest(); //testUIBasic(); @@ -34,7 +34,7 @@ let lime = new Viewer('.openlime', { background: 'black', canvas: { preserveDraw //testAnnotationEditor(); -testNeural(); +//testNeural(); function testNeural() { @@ -261,9 +261,11 @@ function rtiTest(dataset) { label: '4', layout: 'deepzoom', type:'rti', - url: 'assets/rti/hsh/info.json', +// url: 'assets/rti/hsh/info.json', + url: 'assets/rti/tablets_ptm/info.json', normals: false }); + layer0.layout.cachelevels = 0; lime.canvas.addLayer('coin', layer0); // let layer0 = new Layer({