Skip to content

Commit

Permalink
added cachelevels option in layouttiles:
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
ponchio committed Aug 28, 2023
1 parent b337e28 commit f85eeaf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/LayoutTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
});
}

Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -34,7 +34,7 @@ let lime = new Viewer('.openlime', { background: 'black', canvas: { preserveDraw

//testAnnotationEditor();

testNeural();
//testNeural();

function testNeural() {

Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit f85eeaf

Please sign in to comment.