Added active flag to avoid transform of inactive deepzoom images.
This commit is contained in:
parent
5a336e8d40
commit
4c08359394
11
dist/iwmlib.js
vendored
11
dist/iwmlib.js
vendored
@ -2995,11 +2995,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_throwDeltaTime() {
|
||||||
|
let t = performance.now();
|
||||||
|
let dt = t - this.lastframe;
|
||||||
|
this.lastframe = t;
|
||||||
|
return dt
|
||||||
|
}
|
||||||
|
|
||||||
animateThrow(time) {
|
animateThrow(time) {
|
||||||
if (this.velocity != null) {
|
if (this.velocity != null) {
|
||||||
let t = performance.now();
|
let dt = this._throwDeltaTime();
|
||||||
let dt = t - this.lastframe;
|
|
||||||
this.lastframe = t;
|
|
||||||
// console.log("animateThrow", dt)
|
// console.log("animateThrow", dt)
|
||||||
let next = this.nextVelocity(this.velocity);
|
let next = this.nextVelocity(this.velocity);
|
||||||
let prevLength = Points.length(this.velocity);
|
let prevLength = Points.length(this.velocity);
|
||||||
|
35
dist/iwmlib.pixi.js
vendored
35
dist/iwmlib.pixi.js
vendored
@ -6159,11 +6159,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_throwDeltaTime() {
|
||||||
|
let t = performance.now();
|
||||||
|
let dt = t - this.lastframe;
|
||||||
|
this.lastframe = t;
|
||||||
|
return dt
|
||||||
|
}
|
||||||
|
|
||||||
animateThrow(time) {
|
animateThrow(time) {
|
||||||
if (this.velocity != null) {
|
if (this.velocity != null) {
|
||||||
let t = performance.now();
|
let dt = this._throwDeltaTime();
|
||||||
let dt = t - this.lastframe;
|
|
||||||
this.lastframe = t;
|
|
||||||
// console.log("animateThrow", dt)
|
// console.log("animateThrow", dt)
|
||||||
let next = this.nextVelocity(this.velocity);
|
let next = this.nextVelocity(this.velocity);
|
||||||
let prevLength = Points.length(this.velocity);
|
let prevLength = Points.length(this.velocity);
|
||||||
@ -7796,6 +7801,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ES Lint */
|
||||||
|
/* globals PIXI, console*/
|
||||||
|
|
||||||
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 */
|
||||||
@ -7936,18 +7944,18 @@
|
|||||||
* @param {*} options Part of the PIXI API, but ignored in the implementation
|
* @param {*} options Part of the PIXI API, but ignored in the implementation
|
||||||
* @memberof Tile
|
* @memberof Tile
|
||||||
*/
|
*/
|
||||||
destroy(options, debug = true) {
|
destroy(options, debug = false) {
|
||||||
let count = this.unregister();
|
let count = this.unregister();
|
||||||
|
|
||||||
if (keepTextures > 0) {
|
if (keepTextures > 0) {
|
||||||
keptTextures.push({ url: this.url, texture: this.texture});
|
keptTextures.push({ url: this.url, texture: this.texture });
|
||||||
|
|
||||||
let opts = { children: true, texture: false, baseTexture: false };
|
let opts = { children: true, texture: false, baseTexture: false };
|
||||||
if (debug) console.log("Tile.destroy", registeredTiles.size, opts);
|
if (debug) console.log("Tile.destroy", registeredTiles.size, opts);
|
||||||
super.destroy(opts);
|
super.destroy(opts);
|
||||||
|
|
||||||
while(keptTextures.length > keepTextures) {
|
while (keptTextures.length > keepTextures) {
|
||||||
let {url, texture} = keptTextures.shift();
|
let { url, texture } = keptTextures.shift();
|
||||||
if (Tile.isObsolete(url)) {
|
if (Tile.isObsolete(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);
|
||||||
@ -8995,6 +9003,7 @@
|
|||||||
: 1;
|
: 1;
|
||||||
this.alpha = alpha;
|
this.alpha = alpha;
|
||||||
this.fastLoads = 0;
|
this.fastLoads = 0;
|
||||||
|
this.active = true;
|
||||||
this.autoLoadTiles = autoLoadTiles;
|
this.autoLoadTiles = autoLoadTiles;
|
||||||
this.minimumLevel = minimumLevel;
|
this.minimumLevel = minimumLevel;
|
||||||
this.quadTrees = new Map(); // url as keys, TileQuadNodes as values
|
this.quadTrees = new Map(); // url as keys, TileQuadNodes as values
|
||||||
@ -9266,7 +9275,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
worldBounds() {
|
worldBounds() {
|
||||||
let viewBounds = this.app.scene.getBounds();
|
let viewBounds = this.app.scene.bounds; // UO: Never use getBounds()
|
||||||
// Using getBounds extends visible scope after loading tiles and leads
|
// Using getBounds extends visible scope after loading tiles and leads
|
||||||
// to excessive loading
|
// to excessive loading
|
||||||
if (this.world != null) {
|
if (this.world != null) {
|
||||||
@ -9648,6 +9657,9 @@
|
|||||||
* @param {boolean} debug - log debug infos
|
* @param {boolean} debug - log debug infos
|
||||||
*/
|
*/
|
||||||
transformed(event) {
|
transformed(event) {
|
||||||
|
if (!this.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let key = this.currentLevel.toString();
|
let key = this.currentLevel.toString();
|
||||||
let currentTiles = this.tileLayers[key];
|
let currentTiles = this.tileLayers[key];
|
||||||
if (typeof currentTiles == 'undefined') {
|
if (typeof currentTiles == 'undefined') {
|
||||||
@ -9695,6 +9707,7 @@
|
|||||||
* @memberof DeepZoomImage
|
* @memberof DeepZoomImage
|
||||||
*/
|
*/
|
||||||
activate() {
|
activate() {
|
||||||
|
this.active = true;
|
||||||
this.destroyTilesAboveLevel(this.currentLevel);
|
this.destroyTilesAboveLevel(this.currentLevel);
|
||||||
this.ensureTiles(this.currentLevel, null);
|
this.ensureTiles(this.currentLevel, null);
|
||||||
//console.log("Activate Textures!", this.currentLevel)
|
//console.log("Activate Textures!", this.currentLevel)
|
||||||
@ -9706,16 +9719,14 @@
|
|||||||
* @memberof DeepZoomImage
|
* @memberof DeepZoomImage
|
||||||
*/
|
*/
|
||||||
deactivate() {
|
deactivate() {
|
||||||
|
this.active = false;
|
||||||
this.destroyAllTiles();
|
this.destroyAllTiles();
|
||||||
Object.keys(this.tileLayers).forEach(key => {
|
|
||||||
this.destroyTiles(key);
|
|
||||||
});
|
|
||||||
this.tileContainer.destroy({ children: true });
|
this.tileContainer.destroy({ children: true });
|
||||||
printTileCacheInfos();
|
printTileCacheInfos();
|
||||||
}
|
}
|
||||||
|
|
||||||
throwFinished() {
|
throwFinished() {
|
||||||
console.log("throwFinished");
|
//console.log("throwFinished")
|
||||||
let key = this.currentLevel.toString();
|
let key = this.currentLevel.toString();
|
||||||
let currentTiles = this.tileLayers[key];
|
let currentTiles = this.tileLayers[key];
|
||||||
if (typeof currentTiles == 'undefined') {
|
if (typeof currentTiles == 'undefined') {
|
||||||
|
@ -364,6 +364,7 @@ export class DeepZoomImage extends PIXI.Container {
|
|||||||
: 1
|
: 1
|
||||||
this.alpha = alpha
|
this.alpha = alpha
|
||||||
this.fastLoads = 0
|
this.fastLoads = 0
|
||||||
|
this.active = true
|
||||||
this.autoLoadTiles = autoLoadTiles
|
this.autoLoadTiles = autoLoadTiles
|
||||||
this.minimumLevel = minimumLevel
|
this.minimumLevel = minimumLevel
|
||||||
this.quadTrees = new Map() // url as keys, TileQuadNodes as values
|
this.quadTrees = new Map() // url as keys, TileQuadNodes as values
|
||||||
@ -1017,6 +1018,9 @@ export class DeepZoomImage extends PIXI.Container {
|
|||||||
* @param {boolean} debug - log debug infos
|
* @param {boolean} debug - log debug infos
|
||||||
*/
|
*/
|
||||||
transformed(event) {
|
transformed(event) {
|
||||||
|
if (!this.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let key = this.currentLevel.toString()
|
let key = this.currentLevel.toString()
|
||||||
let currentTiles = this.tileLayers[key]
|
let currentTiles = this.tileLayers[key]
|
||||||
if (typeof currentTiles == 'undefined') {
|
if (typeof currentTiles == 'undefined') {
|
||||||
@ -1064,6 +1068,7 @@ export class DeepZoomImage extends PIXI.Container {
|
|||||||
* @memberof DeepZoomImage
|
* @memberof DeepZoomImage
|
||||||
*/
|
*/
|
||||||
activate() {
|
activate() {
|
||||||
|
this.active = true
|
||||||
this.destroyTilesAboveLevel(this.currentLevel)
|
this.destroyTilesAboveLevel(this.currentLevel)
|
||||||
this.ensureTiles(this.currentLevel, null)
|
this.ensureTiles(this.currentLevel, null)
|
||||||
//console.log("Activate Textures!", this.currentLevel)
|
//console.log("Activate Textures!", this.currentLevel)
|
||||||
@ -1075,6 +1080,7 @@ export class DeepZoomImage extends PIXI.Container {
|
|||||||
* @memberof DeepZoomImage
|
* @memberof DeepZoomImage
|
||||||
*/
|
*/
|
||||||
deactivate() {
|
deactivate() {
|
||||||
|
this.active = false
|
||||||
this.destroyAllTiles()
|
this.destroyAllTiles()
|
||||||
this.tileContainer.destroy({ children: true })
|
this.tileContainer.destroy({ children: true })
|
||||||
printTileCacheInfos()
|
printTileCacheInfos()
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* ES Lint */
|
||||||
|
/* globals PIXI, console*/
|
||||||
|
|
||||||
const registeredTiles = new Map()
|
const registeredTiles = new Map()
|
||||||
const pendingTiles = new Map()
|
const pendingTiles = new Map()
|
||||||
|
@ -173,11 +173,16 @@ class Throwable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_throwDeltaTime() {
|
||||||
|
let t = performance.now()
|
||||||
|
let dt = t - this.lastframe
|
||||||
|
this.lastframe = t
|
||||||
|
return dt
|
||||||
|
}
|
||||||
|
|
||||||
animateThrow(time) {
|
animateThrow(time) {
|
||||||
if (this.velocity != null) {
|
if (this.velocity != null) {
|
||||||
let t = performance.now()
|
let dt = this._throwDeltaTime()
|
||||||
let dt = t - this.lastframe
|
|
||||||
this.lastframe = t
|
|
||||||
// console.log("animateThrow", dt)
|
// console.log("animateThrow", dt)
|
||||||
let next = this.nextVelocity(this.velocity)
|
let next = this.nextVelocity(this.velocity)
|
||||||
let prevLength = Points.length(this.velocity)
|
let prevLength = Points.length(this.velocity)
|
||||||
|
Loading…
Reference in New Issue
Block a user