Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b9ed733dd | |||
| 5c95128dfc | |||
| beca78d7a7 | |||
| 54a1e74e27 | |||
| 909ef9d242 | |||
| 6ec0e9631a | |||
| 6f7a18d6b8 | |||
| 322fdf8deb | |||
| 012fe4bc4a | |||
| 502bdf47a3 | |||
| 437320b4ad | |||
| 3b6402a682 | |||
| fa25d13469 | |||
| 4c08359394 | |||
| b5400c8223 | |||
| 5a336e8d40 | |||
| 2d1a6b1b7f | |||
| 636e2e439c | |||
| b208592e3a |
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
*
|
||||
* make screenshots and log errors to
|
||||
*
|
||||
* make screenshots and log errors to
|
||||
* console
|
||||
* (c) 2019 - Leibniz-Insitut für Wissensmedien
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
const puppeteer = require('puppeteer');
|
||||
@@ -24,13 +24,13 @@ function logPageEvent(event){
|
||||
}
|
||||
|
||||
async function makeScreenshot(href){
|
||||
|
||||
|
||||
const browser = await puppeteer.launch({args: [
|
||||
'–allow-file-access-from-files',
|
||||
],});
|
||||
|
||||
const page = await browser.newPage();
|
||||
|
||||
|
||||
await page.setViewport({width: 1024,height : 624})
|
||||
|
||||
// register events
|
||||
@@ -53,9 +53,9 @@ async function makeScreenshot(href){
|
||||
}
|
||||
// image_url = image_url.replace("file:///","")
|
||||
// fpath = fpath.replace("file:///","")
|
||||
|
||||
|
||||
page.removeAllListeners()
|
||||
|
||||
|
||||
fs.ensureDir(fpath)
|
||||
|
||||
await page.screenshot({path: image_url});
|
||||
@@ -63,10 +63,10 @@ async function makeScreenshot(href){
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* collect all navigational links in all documents
|
||||
*
|
||||
* */
|
||||
*
|
||||
* */
|
||||
|
||||
async function collectLinks(href,reflist)
|
||||
{
|
||||
@@ -76,12 +76,12 @@ async function collectLinks(href,reflist)
|
||||
|
||||
await page.goto(href)
|
||||
let hrefs = await page.$$('a.wrapper')
|
||||
|
||||
|
||||
for (var i=0; i < hrefs.length; i++) {
|
||||
let hrefValue = await hrefs[i].getProperty('href')
|
||||
let linkText = await hrefValue.jsonValue();
|
||||
if (!linkText.startsWith("file:"))
|
||||
{
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(linkText.endsWith("#")) continue;
|
||||
@@ -113,4 +113,4 @@ async function collectLinks(href,reflist)
|
||||
await makeScreenshot(reflist[i])
|
||||
console.log(i,reflist[i])
|
||||
}
|
||||
})()
|
||||
})()
|
||||
|
||||
@@ -92733,86 +92733,86 @@ module.exports = function (_Plugin) {
|
||||
|
||||
},{}]},{},[13]);
|
||||
|
||||
/*jslint plusplus: true, vars: true, indent: 2 */
|
||||
/* convertPointFromPageToNode.js from
|
||||
<script src="https://gist.github.com/Yaffle/1145197.js"></script>
|
||||
|
||||
convertPointFromPageToNode(element, event.pageX, event.pageY) -> {x, y}
|
||||
returns coordinate in element's local coordinate system (works properly
|
||||
with css transforms without perspective projection)
|
||||
convertPointFromNodeToPage(element, offsetX, offsetY) -> {x, y}
|
||||
returns coordinate in window's coordinate system (works properly with
|
||||
css transforms without perspective projection)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict'
|
||||
|
||||
var I = (typeof(WebKitCSSMatrix) == 'undefined') ? new DOMMatrix() : new WebKitCSSMatrix()
|
||||
|
||||
function Point(x, y, z) {
|
||||
this.x = x
|
||||
this.y = y
|
||||
this.z = z
|
||||
}
|
||||
|
||||
Point.prototype.transformBy = function (matrix) {
|
||||
var tmp = matrix.multiply(I.translate(this.x, this.y, this.z))
|
||||
return new Point(tmp.m41, tmp.m42, tmp.m43)
|
||||
}
|
||||
|
||||
function createMatrix(transform) {
|
||||
try {
|
||||
return (typeof(WebKitCSSMatrix) == 'undefined') ? new DOMMatrix(transform) : new WebKitCSSMatrix(transform)
|
||||
} catch(e) {
|
||||
console.warn(transform)
|
||||
console.warn(e.toString())
|
||||
return I
|
||||
}
|
||||
}
|
||||
|
||||
function getTransformationMatrix(element) {
|
||||
var transformationMatrix = I
|
||||
var x = element
|
||||
|
||||
while (x != undefined && x !== x.ownerDocument.documentElement) {
|
||||
var computedStyle = window.getComputedStyle(x, undefined)
|
||||
var transform = computedStyle.transform || 'none'
|
||||
var c = transform === 'none' ? I : createMatrix(transform)
|
||||
transformationMatrix = c.multiply(transformationMatrix)
|
||||
x = x.parentNode
|
||||
}
|
||||
|
||||
var w = element.offsetWidth
|
||||
var h = element.offsetHeight
|
||||
var i = 4
|
||||
var left = +Infinity
|
||||
var top = +Infinity
|
||||
while (--i >= 0) {
|
||||
var p = new Point(i === 0 || i === 1 ? 0 : w, i === 0 || i === 3 ? 0 : h,
|
||||
0).transformBy(transformationMatrix)
|
||||
if (p.x < left) {
|
||||
left = p.x
|
||||
}
|
||||
if (p.y < top) {
|
||||
top = p.y
|
||||
}
|
||||
}
|
||||
var rect = element.getBoundingClientRect()
|
||||
transformationMatrix = I.translate(window.pageXOffset + rect.left - left,
|
||||
window.pageYOffset + rect.top - top, 0)
|
||||
.multiply(transformationMatrix)
|
||||
return transformationMatrix
|
||||
}
|
||||
|
||||
window.convertPointFromPageToNode = function (element, pageX, pageY) {
|
||||
return new Point(pageX, pageY, 0).transformBy(
|
||||
getTransformationMatrix(element).inverse())
|
||||
}
|
||||
|
||||
window.convertPointFromNodeToPage = function (element, offsetX, offsetY) {
|
||||
return new Point(offsetX, offsetY, 0).transformBy(
|
||||
getTransformationMatrix(element))
|
||||
}
|
||||
|
||||
}())
|
||||
/*jslint plusplus: true, vars: true, indent: 2 */
|
||||
/* convertPointFromPageToNode.js from
|
||||
<script src="https://gist.github.com/Yaffle/1145197.js"></script>
|
||||
|
||||
convertPointFromPageToNode(element, event.pageX, event.pageY) -> {x, y}
|
||||
returns coordinate in element's local coordinate system (works properly
|
||||
with css transforms without perspective projection)
|
||||
convertPointFromNodeToPage(element, offsetX, offsetY) -> {x, y}
|
||||
returns coordinate in window's coordinate system (works properly with
|
||||
css transforms without perspective projection)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict'
|
||||
|
||||
var I = (typeof(WebKitCSSMatrix) == 'undefined') ? new DOMMatrix() : new WebKitCSSMatrix()
|
||||
|
||||
function Point(x, y, z) {
|
||||
this.x = x
|
||||
this.y = y
|
||||
this.z = z
|
||||
}
|
||||
|
||||
Point.prototype.transformBy = function (matrix) {
|
||||
var tmp = matrix.multiply(I.translate(this.x, this.y, this.z))
|
||||
return new Point(tmp.m41, tmp.m42, tmp.m43)
|
||||
}
|
||||
|
||||
function createMatrix(transform) {
|
||||
try {
|
||||
return (typeof(WebKitCSSMatrix) == 'undefined') ? new DOMMatrix(transform) : new WebKitCSSMatrix(transform)
|
||||
} catch(e) {
|
||||
console.warn(transform)
|
||||
console.warn(e.toString())
|
||||
return I
|
||||
}
|
||||
}
|
||||
|
||||
function getTransformationMatrix(element) {
|
||||
var transformationMatrix = I
|
||||
var x = element
|
||||
|
||||
while (x != undefined && x !== x.ownerDocument.documentElement) {
|
||||
var computedStyle = window.getComputedStyle(x, undefined)
|
||||
var transform = computedStyle.transform || 'none'
|
||||
var c = transform === 'none' ? I : createMatrix(transform)
|
||||
transformationMatrix = c.multiply(transformationMatrix)
|
||||
x = x.parentNode
|
||||
}
|
||||
|
||||
var w = element.offsetWidth
|
||||
var h = element.offsetHeight
|
||||
var i = 4
|
||||
var left = +Infinity
|
||||
var top = +Infinity
|
||||
while (--i >= 0) {
|
||||
var p = new Point(i === 0 || i === 1 ? 0 : w, i === 0 || i === 3 ? 0 : h,
|
||||
0).transformBy(transformationMatrix)
|
||||
if (p.x < left) {
|
||||
left = p.x
|
||||
}
|
||||
if (p.y < top) {
|
||||
top = p.y
|
||||
}
|
||||
}
|
||||
var rect = element.getBoundingClientRect()
|
||||
transformationMatrix = I.translate(window.pageXOffset + rect.left - left,
|
||||
window.pageYOffset + rect.top - top, 0)
|
||||
.multiply(transformationMatrix)
|
||||
return transformationMatrix
|
||||
}
|
||||
|
||||
window.convertPointFromPageToNode = function (element, pageX, pageY) {
|
||||
return new Point(pageX, pageY, 0).transformBy(
|
||||
getTransformationMatrix(element).inverse())
|
||||
}
|
||||
|
||||
window.convertPointFromNodeToPage = function (element, offsetX, offsetY) {
|
||||
return new Point(offsetX, offsetY, 0).transformBy(
|
||||
getTransformationMatrix(element))
|
||||
}
|
||||
|
||||
}())
|
||||
|
||||
@@ -2336,8 +2336,6 @@
|
||||
onMouseWheel(event) {
|
||||
if (this.capture(event) && this.target.onMouseWheel) {
|
||||
this.target.onMouseWheel(event);
|
||||
} else {
|
||||
//console.warn('Target has no onMouseWheel callback')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2531,8 +2529,6 @@
|
||||
}
|
||||
if (this.target.onMouseWheel) {
|
||||
this.target.onMouseWheel(event);
|
||||
} else {
|
||||
//console.warn('Target has no onMouseWheel callback', this.target)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2999,11 +2995,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
_throwDeltaTime() {
|
||||
let t = performance.now();
|
||||
let dt = t - this.lastframe;
|
||||
this.lastframe = t;
|
||||
return dt
|
||||
}
|
||||
|
||||
animateThrow(time) {
|
||||
if (this.velocity != null) {
|
||||
let t = performance.now();
|
||||
let dt = t - this.lastframe;
|
||||
this.lastframe = t;
|
||||
let dt = this._throwDeltaTime();
|
||||
// console.log("animateThrow", dt)
|
||||
let next = this.nextVelocity(this.velocity);
|
||||
let prevLength = Points.length(this.velocity);
|
||||
@@ -4206,10 +4207,7 @@
|
||||
let event = new ResizeEvent(this, { width: w, height: h });
|
||||
this.onResize(event);
|
||||
}
|
||||
if (this.resizeButton != null) {
|
||||
// this.resizeButton.style.width = 50/this.scale+"px"
|
||||
// this.resizeButton.style.height = 50/this.scale+"px"
|
||||
}
|
||||
if (this.resizeButton != null) ;
|
||||
}
|
||||
|
||||
startResize(e) {
|
||||
@@ -4260,7 +4258,7 @@
|
||||
let resizeW = r * Math.cos(Angle.degree2radian(phiCorrected));
|
||||
let resizeH = -r * Math.sin(Angle.degree2radian(phiCorrected));
|
||||
|
||||
if (this.element.offsetWidth + resizeW / this.scale > this.width * 0.3 && this.element.offsetHeight + resizeH / this.scale > this.height * 0.3) TweenLite.to(this.element, 0, { width: this.element.offsetWidth + resizeW / this.scale, height: this.element.offsetHeight + resizeH / this.scale });
|
||||
if ((this.element.offsetWidth + resizeW) / this.scale > this.width * 0.5 / this.scale && (this.element.offsetHeight + resizeH) / this.scale > this.height * 0.3 / this.scale) TweenLite.to(this.element, 0, { width: this.element.offsetWidth + resizeW / this.scale, height: this.element.offsetHeight + resizeH / this.scale });
|
||||
|
||||
this.oldX = e.clientX;
|
||||
this.oldY = e.clientY;
|
||||
|
||||
@@ -5500,8 +5500,6 @@
|
||||
onMouseWheel(event) {
|
||||
if (this.capture(event) && this.target.onMouseWheel) {
|
||||
this.target.onMouseWheel(event);
|
||||
} else {
|
||||
//console.warn('Target has no onMouseWheel callback')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5695,8 +5693,6 @@
|
||||
}
|
||||
if (this.target.onMouseWheel) {
|
||||
this.target.onMouseWheel(event);
|
||||
} else {
|
||||
//console.warn('Target has no onMouseWheel callback', this.target)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6163,11 +6159,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
_throwDeltaTime() {
|
||||
let t = performance.now();
|
||||
let dt = t - this.lastframe;
|
||||
this.lastframe = t;
|
||||
return dt
|
||||
}
|
||||
|
||||
animateThrow(time) {
|
||||
if (this.velocity != null) {
|
||||
let t = performance.now();
|
||||
let dt = t - this.lastframe;
|
||||
this.lastframe = t;
|
||||
let dt = this._throwDeltaTime();
|
||||
// console.log("animateThrow", dt)
|
||||
let next = this.nextVelocity(this.velocity);
|
||||
let prevLength = Points.length(this.velocity);
|
||||
@@ -7208,10 +7209,7 @@
|
||||
let event = new ResizeEvent(this, { width: w, height: h });
|
||||
this.onResize(event);
|
||||
}
|
||||
if (this.resizeButton != null) {
|
||||
// this.resizeButton.style.width = 50/this.scale+"px"
|
||||
// this.resizeButton.style.height = 50/this.scale+"px"
|
||||
}
|
||||
if (this.resizeButton != null) ;
|
||||
}
|
||||
|
||||
startResize(e) {
|
||||
@@ -7262,7 +7260,7 @@
|
||||
let resizeW = r * Math.cos(Angle.degree2radian(phiCorrected));
|
||||
let resizeH = -r * Math.sin(Angle.degree2radian(phiCorrected));
|
||||
|
||||
if (this.element.offsetWidth + resizeW / this.scale > this.width * 0.3 && this.element.offsetHeight + resizeH / this.scale > this.height * 0.3) TweenLite.to(this.element, 0, { width: this.element.offsetWidth + resizeW / this.scale, height: this.element.offsetHeight + resizeH / this.scale });
|
||||
if ((this.element.offsetWidth + resizeW) / this.scale > this.width * 0.5 / this.scale && (this.element.offsetHeight + resizeH) / this.scale > this.height * 0.3 / this.scale) TweenLite.to(this.element, 0, { width: this.element.offsetWidth + resizeW / this.scale, height: this.element.offsetHeight + resizeH / this.scale });
|
||||
|
||||
this.oldX = e.clientX;
|
||||
this.oldY = e.clientY;
|
||||
@@ -7803,11 +7801,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* ES Lint */
|
||||
/* globals PIXI, console*/
|
||||
|
||||
const registeredTiles = new Map();
|
||||
const pendingTiles = new Map();
|
||||
// const pendingTiles = new Map()
|
||||
/** Implements a baseTexture cache. The last textures are kept for reuse */
|
||||
const keepBaseTextures = 0;
|
||||
const keptBaseTextures = [];
|
||||
let keepTextures = 0;
|
||||
const keptTextures = [];
|
||||
|
||||
/** The current Tile implementation simply uses PIXI.Sprites.
|
||||
*
|
||||
@@ -7828,8 +7829,8 @@
|
||||
* @param {*} value
|
||||
* @memberof Tile
|
||||
*/
|
||||
static enableKeepBaseTextures(value = 1000) {
|
||||
keepBaseTextures = value;
|
||||
static enableKeepTextures(value = 1000) {
|
||||
keepTextures = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7839,25 +7840,14 @@
|
||||
* @param {*} url
|
||||
* @memberof Tile
|
||||
*/
|
||||
static schedule(url) {
|
||||
let count = 0;
|
||||
/* static schedule(url) {
|
||||
let count = 0
|
||||
if (pendingTiles.has(url)) {
|
||||
count = pendingTiles.get(url);
|
||||
count = pendingTiles.get(url)
|
||||
}
|
||||
pendingTiles.set(url, count + 1);
|
||||
pendingTiles.set(url, count + 1)
|
||||
// console.log("Tile.scheduled", url, pendingTiles.size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true iff the url is pending
|
||||
*
|
||||
* @static
|
||||
* @returns
|
||||
* @memberof Tile
|
||||
*/
|
||||
static isPending() {
|
||||
return pendingTiles.has(url) && pendingTiles.get(url) > 0
|
||||
}
|
||||
} */
|
||||
|
||||
/**
|
||||
* Removes the given url from pending urls.
|
||||
@@ -7866,17 +7856,37 @@
|
||||
* @param {*} url
|
||||
* @memberof Tile
|
||||
*/
|
||||
static unschedule(url) {
|
||||
/* static unschedule(url) {
|
||||
if (pendingTiles.has(url)) {
|
||||
let count = pendingTiles.get(url);
|
||||
let count = pendingTiles.get(url)
|
||||
if (count > 1) {
|
||||
pendingTiles.set(url, count - 1);
|
||||
pendingTiles.set(url, count - 1)
|
||||
}
|
||||
else {
|
||||
pendingTiles.clear(url);
|
||||
pendingTiles.clear(url)
|
||||
}
|
||||
}
|
||||
// console.log("Tile.unscheduled", url, pendingTiles.size)
|
||||
} */
|
||||
|
||||
|
||||
/**
|
||||
* Returns true iff the url is pending
|
||||
*
|
||||
* @static
|
||||
* @param {*} url
|
||||
* @returns
|
||||
* @memberof Tile
|
||||
*/
|
||||
/*static isPending(url) {
|
||||
return pendingTiles.has(url) && pendingTiles.get(url) > 0
|
||||
} */
|
||||
|
||||
static isObsolete(url) {
|
||||
if (registeredTiles.has(url) && registeredTiles.get(url) > 0) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7901,7 +7911,7 @@
|
||||
* @memberof Tile
|
||||
*/
|
||||
register(url, debug = false) {
|
||||
Tile.unschedule(url);
|
||||
//Tile.unschedule(url)
|
||||
if (registeredTiles.has(url)) {
|
||||
let tiles = registeredTiles.get(url);
|
||||
tiles.add(this);
|
||||
@@ -7924,6 +7934,7 @@
|
||||
tiles.delete(this);
|
||||
if (tiles.size == 0) {
|
||||
registeredTiles.delete(this.url);
|
||||
return 0
|
||||
}
|
||||
return tiles.size
|
||||
}
|
||||
@@ -7934,28 +7945,27 @@
|
||||
* @param {*} options Part of the PIXI API, but ignored in the implementation
|
||||
* @memberof Tile
|
||||
*/
|
||||
destroy(options, debug = true) {
|
||||
destroy(options, debug = false) {
|
||||
let count = this.unregister();
|
||||
|
||||
if (keepBaseTextures > 0) {
|
||||
keptBaseTextures.push({ url: this.url, texture: this.texture.baseTexture});
|
||||
if (keepTextures > 0) {
|
||||
keptTextures.push({ url: this.url, texture: this.texture });
|
||||
|
||||
let opts = { children: true, texture: false, baseTexture: false };
|
||||
if (debug) console.log("Tile.destroy", registeredTiles.size, opts);
|
||||
super.destroy(opts);
|
||||
|
||||
while(keptBaseTextures.length > keepBaseTextures) {
|
||||
let {url, texture} = keptBaseTextures.shift();
|
||||
let tiles = registeredTiles.get(url);
|
||||
if (tiles.size > 0 && !Tile.isPending(url)) {
|
||||
texture.destroy();
|
||||
if (debug) console.log("Destroying baseTexture", url);
|
||||
while (keptTextures.length > keepTextures) {
|
||||
let { url, texture } = keptTextures.shift();
|
||||
if (Tile.isObsolete(url)) {
|
||||
texture.destroy(true); // Destroy base as well
|
||||
if (debug) console.log("Destroying texture and baseTexture", url);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No longer registered and not pending
|
||||
if (count <= 0 && !Tile.isPending(url)) {
|
||||
if (count <= 0) { // && !Tile.isPending(this.url)
|
||||
let opts = { children: true, texture: true, baseTexture: true };
|
||||
super.destroy(opts);
|
||||
if (debug) console.log("Tile.destroy", registeredTiles.size, opts);
|
||||
@@ -7971,7 +7981,6 @@
|
||||
this.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7992,6 +8001,16 @@
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Texture received too late. We do not need it.
|
||||
* @param {*} url
|
||||
* @param {*} texture
|
||||
*/
|
||||
static lateTexture(url, texture) {
|
||||
let destroyBase = !registeredTiles.has(url);
|
||||
texture.destroy(destroyBase);
|
||||
}
|
||||
|
||||
static printInfos() {
|
||||
let references = new Map();
|
||||
let multiples = 0;
|
||||
@@ -8035,7 +8054,7 @@
|
||||
if (this.loaded.has(url)) return false
|
||||
if (this.loading.has(url)) return false
|
||||
|
||||
Tile.schedule(url);
|
||||
//Tile.schedule(url)
|
||||
this.map.set(url, [col, row]);
|
||||
this.loading.add(url);
|
||||
this.loadQueue.push(url);
|
||||
@@ -8045,7 +8064,7 @@
|
||||
unschedule(url) {
|
||||
if (this.loaded.has(url)) this.loaded.delete(url);
|
||||
if (this.loading.has(url)) this.loading.delete(url);
|
||||
Tile.unschedule(url);
|
||||
//Tile.unschedule(url)
|
||||
this.loadQueue = this.loadQueue.filter(item => item != url);
|
||||
}
|
||||
|
||||
@@ -8105,7 +8124,7 @@
|
||||
if (this.loaded.has(url)) return false
|
||||
if (this.loading.has(url)) return false
|
||||
|
||||
Tile.schedule(url);
|
||||
//Tile.schedule(url)
|
||||
let reusableTexture = Tile.textureAvailable(url);
|
||||
if (reusableTexture) {
|
||||
if (this.debug) console.log('Texture reusable', reusableTexture);
|
||||
@@ -8166,8 +8185,8 @@
|
||||
_onLoaded(loader, resource) {
|
||||
if (this.destroyed) {
|
||||
let texture = resource.texture;
|
||||
let destroyBase = !deepZoomTileCache.has(resource.url);
|
||||
texture.destroy(destroyBase);
|
||||
let url = resource.url;
|
||||
Tile.lateTexture(url, texture);
|
||||
console.warn("Received resource after destroy", texture);
|
||||
return
|
||||
}
|
||||
@@ -8628,9 +8647,6 @@
|
||||
return n % 2 == 0
|
||||
}
|
||||
|
||||
function printTileCacheInfos() {
|
||||
Tile.printInfos();
|
||||
}
|
||||
/**
|
||||
* A utility class that holds information typically provided by DZI files, i.e.
|
||||
* height and width of the overall image, overlap, and image type.
|
||||
@@ -8985,6 +9001,7 @@
|
||||
: 1;
|
||||
this.alpha = alpha;
|
||||
this.fastLoads = 0;
|
||||
this.active = true;
|
||||
this.autoLoadTiles = autoLoadTiles;
|
||||
this.minimumLevel = minimumLevel;
|
||||
this.quadTrees = new Map(); // url as keys, TileQuadNodes as values
|
||||
@@ -9256,9 +9273,9 @@
|
||||
}
|
||||
|
||||
worldBounds() {
|
||||
let viewBounds = this.app.scene.getBounds();
|
||||
let viewBounds = this.app.scene.bounds || this.app.scene.getBounds();
|
||||
// Using getBounds extends visible scope after loading tiles and leads
|
||||
// to excessive loading
|
||||
// to excessive loading. So we prefer bounds over getBounds()
|
||||
if (this.world != null) {
|
||||
let bounds = this.world.bounds;
|
||||
let x = Math.max(-bounds.width, bounds.x);
|
||||
@@ -9638,6 +9655,9 @@
|
||||
* @param {boolean} debug - log debug infos
|
||||
*/
|
||||
transformed(event) {
|
||||
if (!this.active) {
|
||||
return
|
||||
}
|
||||
let key = this.currentLevel.toString();
|
||||
let currentTiles = this.tileLayers[key];
|
||||
if (typeof currentTiles == 'undefined') {
|
||||
@@ -9660,7 +9680,7 @@
|
||||
this.ensureTiles(this.currentLevel, event.about);
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let level = this.levelForScale(event.scale);
|
||||
let newLevel = Math.max(level, this.minimumLevel);
|
||||
if (newLevel != this.currentLevel) {
|
||||
@@ -9685,6 +9705,7 @@
|
||||
* @memberof DeepZoomImage
|
||||
*/
|
||||
activate() {
|
||||
this.active = true;
|
||||
this.destroyTilesAboveLevel(this.currentLevel);
|
||||
this.ensureTiles(this.currentLevel, null);
|
||||
//console.log("Activate Textures!", this.currentLevel)
|
||||
@@ -9696,35 +9717,19 @@
|
||||
* @memberof DeepZoomImage
|
||||
*/
|
||||
deactivate() {
|
||||
this.active = false;
|
||||
this.destroyAllTiles();
|
||||
Object.keys(this.tileLayers).forEach(key => {
|
||||
this.destroyTiles(key);
|
||||
});
|
||||
this.tileContainer.destroy({ children: true });
|
||||
printTileCacheInfos();
|
||||
}
|
||||
|
||||
throwFinished() {
|
||||
console.log("throwFinished");
|
||||
//console.log("throwFinished")
|
||||
let key = this.currentLevel.toString();
|
||||
let currentTiles = this.tileLayers[key];
|
||||
if (typeof currentTiles == 'undefined') {
|
||||
return
|
||||
}
|
||||
|
||||
this.ensureTiles(this.currentLevel);
|
||||
// let all = new Set()
|
||||
// for (let tile of currentTiles.children) {
|
||||
// all.add(tile.url)
|
||||
// }
|
||||
// let { centerCol, centerRow, needed } = this.neededTiles(currentTiles, this.currentLevel)
|
||||
// for (let [url, col, row] of needed) {
|
||||
// all.delete(url)
|
||||
// }
|
||||
// for (let url of all) {
|
||||
// currentTiles.destroyTileByUrl(url)
|
||||
// }
|
||||
// currentTiles.loader.loader.reset()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ a single delegate pattern.
|
||||
<p>The main differences are that <code>PointerEvent</code> are fired for each
|
||||
touch point, whereas the <code>TouchEvent</code> collects multiple
|
||||
<code>TouchPoints</code> into a single event. The basic PointMap and Interaction
|
||||
classes unify this behavior by collection all contact points regardless
|
||||
classes unify this behavior by collecting all contact points regardless
|
||||
of their original mouse, touch, or pointer events.</p>
|
||||
<h2>
|
||||
Point Maps
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
let ipc = null
|
||||
let logMessages = new Set()
|
||||
|
||||
try {
|
||||
ipc = require('electron').ipcRenderer
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
console.log("Cannot use electron logging.")
|
||||
}
|
||||
|
||||
/** Basic class for app specific logging requirements.
|
||||
* Can be used to implement persistent logging in electron apps.
|
||||
* Uses a logMessage cache to prevent error overflows. This is
|
||||
* needed since errors may occur very frequently
|
||||
* (e.g. display update loops at 60fps, programmatic loops, ...).
|
||||
*/
|
||||
export default class Logging {
|
||||
|
||||
@@ -20,4 +26,36 @@ export default class Logging {
|
||||
console.log(message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Static warn function.
|
||||
* Emits each warning only once per session.
|
||||
* @param {*} message
|
||||
*/
|
||||
static warn(message) {
|
||||
if (!logMessages.has(message)) {
|
||||
logMessages.add(message)
|
||||
if (ipc) {
|
||||
ipc.send('warn', message)
|
||||
} else {
|
||||
console.warn(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Static error function.
|
||||
* Emits each error message only once per session.
|
||||
* @param {*} message
|
||||
*/
|
||||
static error(message) {
|
||||
if (!logMessages.has(message)) {
|
||||
logMessages.add(message)
|
||||
if (ipc) {
|
||||
ipc.send('error', message)
|
||||
} else {
|
||||
console.error(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ function isEven(n) {
|
||||
return n % 2 == 0
|
||||
}
|
||||
|
||||
function printTileCacheInfos() {
|
||||
Tile.printInfos()
|
||||
}
|
||||
/**
|
||||
* A utility class that holds information typically provided by DZI files, i.e.
|
||||
* height and width of the overall image, overlap, and image type.
|
||||
@@ -364,6 +361,7 @@ export class DeepZoomImage extends PIXI.Container {
|
||||
: 1
|
||||
this.alpha = alpha
|
||||
this.fastLoads = 0
|
||||
this.active = true
|
||||
this.autoLoadTiles = autoLoadTiles
|
||||
this.minimumLevel = minimumLevel
|
||||
this.quadTrees = new Map() // url as keys, TileQuadNodes as values
|
||||
@@ -635,9 +633,9 @@ export class DeepZoomImage extends PIXI.Container {
|
||||
}
|
||||
|
||||
worldBounds() {
|
||||
let viewBounds = this.app.scene.bounds // UO: Never use getBounds()
|
||||
let viewBounds = this.app.scene.bounds || this.app.scene.getBounds()
|
||||
// Using getBounds extends visible scope after loading tiles and leads
|
||||
// to excessive loading
|
||||
// to excessive loading. So we prefer bounds over getBounds()
|
||||
if (this.world != null) {
|
||||
let bounds = this.world.bounds
|
||||
let x = Math.max(-bounds.width, bounds.x)
|
||||
@@ -1017,6 +1015,9 @@ export class DeepZoomImage extends PIXI.Container {
|
||||
* @param {boolean} debug - log debug infos
|
||||
*/
|
||||
transformed(event) {
|
||||
if (!this.active) {
|
||||
return
|
||||
}
|
||||
let key = this.currentLevel.toString()
|
||||
let currentTiles = this.tileLayers[key]
|
||||
if (typeof currentTiles == 'undefined') {
|
||||
@@ -1064,6 +1065,7 @@ export class DeepZoomImage extends PIXI.Container {
|
||||
* @memberof DeepZoomImage
|
||||
*/
|
||||
activate() {
|
||||
this.active = true
|
||||
this.destroyTilesAboveLevel(this.currentLevel)
|
||||
this.ensureTiles(this.currentLevel, null)
|
||||
//console.log("Activate Textures!", this.currentLevel)
|
||||
@@ -1075,9 +1077,9 @@ export class DeepZoomImage extends PIXI.Container {
|
||||
* @memberof DeepZoomImage
|
||||
*/
|
||||
deactivate() {
|
||||
this.active = false
|
||||
this.destroyAllTiles()
|
||||
this.tileContainer.destroy({ children: true })
|
||||
printTileCacheInfos()
|
||||
}
|
||||
|
||||
throwFinished() {
|
||||
@@ -1087,19 +1089,6 @@ export class DeepZoomImage extends PIXI.Container {
|
||||
if (typeof currentTiles == 'undefined') {
|
||||
return
|
||||
}
|
||||
|
||||
this.ensureTiles(this.currentLevel)
|
||||
// let all = new Set()
|
||||
// for (let tile of currentTiles.children) {
|
||||
// all.add(tile.url)
|
||||
// }
|
||||
// let { centerCol, centerRow, needed } = this.neededTiles(currentTiles, this.currentLevel)
|
||||
// for (let [url, col, row] of needed) {
|
||||
// all.delete(url)
|
||||
// }
|
||||
// for (let url of all) {
|
||||
// currentTiles.destroyTileByUrl(url)
|
||||
// }
|
||||
// currentTiles.loader.loader.reset()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export class TileLoader {
|
||||
if (this.loaded.has(url)) return false
|
||||
if (this.loading.has(url)) return false
|
||||
|
||||
Tile.schedule(url)
|
||||
//Tile.schedule(url)
|
||||
this.map.set(url, [col, row])
|
||||
this.loading.add(url)
|
||||
this.loadQueue.push(url)
|
||||
@@ -39,7 +39,7 @@ export class TileLoader {
|
||||
unschedule(url) {
|
||||
if (this.loaded.has(url)) this.loaded.delete(url)
|
||||
if (this.loading.has(url)) this.loading.delete(url)
|
||||
Tile.unschedule(url)
|
||||
//Tile.unschedule(url)
|
||||
this.loadQueue = this.loadQueue.filter(item => item != url)
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ export class PIXITileLoader extends TileLoader {
|
||||
if (this.loaded.has(url)) return false
|
||||
if (this.loading.has(url)) return false
|
||||
|
||||
Tile.schedule(url)
|
||||
//Tile.schedule(url)
|
||||
let reusableTexture = Tile.textureAvailable(url)
|
||||
if (reusableTexture) {
|
||||
if (this.debug) console.log('Texture reusable', reusableTexture)
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
/* ES Lint */
|
||||
/* globals PIXI, console*/
|
||||
|
||||
const registeredTiles = new Map()
|
||||
const pendingTiles = new Map()
|
||||
/** Implements a baseTexture cache. The last textures are kept for reuse */
|
||||
let keepTextures = 0
|
||||
const keptTextures = []
|
||||
const lateTextures = new Map()
|
||||
let lastSweepTime = 0
|
||||
let sweepInterval = 2000.0
|
||||
|
||||
/** The current Tile implementation simply uses PIXI.Sprites.
|
||||
*
|
||||
@@ -28,22 +32,6 @@ export default class Tile extends PIXI.Sprite {
|
||||
keepTextures = value
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the given url as pending. Pending tiles should not be destroyed
|
||||
*
|
||||
* @static
|
||||
* @param {*} url
|
||||
* @memberof Tile
|
||||
*/
|
||||
static schedule(url) {
|
||||
let count = 0
|
||||
if (pendingTiles.has(url)) {
|
||||
count = pendingTiles.get(url)
|
||||
}
|
||||
pendingTiles.set(url, count + 1)
|
||||
// console.log("Tile.scheduled", url, pendingTiles.size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true iff the url is pending
|
||||
*
|
||||
@@ -52,9 +40,9 @@ export default class Tile extends PIXI.Sprite {
|
||||
* @returns
|
||||
* @memberof Tile
|
||||
*/
|
||||
static isPending(url) {
|
||||
/*static isPending(url) {
|
||||
return pendingTiles.has(url) && pendingTiles.get(url) > 0
|
||||
}
|
||||
} */
|
||||
|
||||
static isObsolete(url) {
|
||||
if (registeredTiles.has(url) && registeredTiles.get(url) > 0) {
|
||||
@@ -63,26 +51,6 @@ export default class Tile extends PIXI.Sprite {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given url from pending urls.
|
||||
*
|
||||
* @static
|
||||
* @param {*} url
|
||||
* @memberof Tile
|
||||
*/
|
||||
static unschedule(url) {
|
||||
if (pendingTiles.has(url)) {
|
||||
let count = pendingTiles.get(url)
|
||||
if (count > 1) {
|
||||
pendingTiles.set(url, count - 1)
|
||||
}
|
||||
else {
|
||||
pendingTiles.clear(url)
|
||||
}
|
||||
}
|
||||
// console.log("Tile.unscheduled", url, pendingTiles.size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a tile from image using the PIXI.Texture.fromImage method.
|
||||
*
|
||||
@@ -105,7 +73,7 @@ export default class Tile extends PIXI.Sprite {
|
||||
* @memberof Tile
|
||||
*/
|
||||
register(url, debug = false) {
|
||||
Tile.unschedule(url)
|
||||
//Tile.unschedule(url)
|
||||
if (registeredTiles.has(url)) {
|
||||
let tiles = registeredTiles.get(url)
|
||||
tiles.add(this)
|
||||
@@ -159,7 +127,7 @@ export default class Tile extends PIXI.Sprite {
|
||||
}
|
||||
else {
|
||||
// No longer registered and not pending
|
||||
if (count <= 0 && !Tile.isPending(this.url)) {
|
||||
if (count <= 0) { // && !Tile.isPending(this.url)
|
||||
let opts = { children: true, texture: true, baseTexture: true }
|
||||
super.destroy(opts)
|
||||
if (debug) console.log("Tile.destroy", registeredTiles.size, opts)
|
||||
@@ -195,14 +163,60 @@ export default class Tile extends PIXI.Sprite {
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialized renderWebGL to avoid freezing system
|
||||
*
|
||||
* @param {*} renderer
|
||||
* @memberof Tile
|
||||
*/
|
||||
renderWebGL(renderer) {
|
||||
try {
|
||||
super.renderWebGL(renderer)
|
||||
}
|
||||
catch (e) {
|
||||
// We want persistent logging here
|
||||
Logging.error("Error in Tile.renderWebGL: " + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes lately arrived texture if they have not been touched in the meanwhile.
|
||||
*
|
||||
* @static
|
||||
* @memberof Tile
|
||||
*/
|
||||
static sweepLateTextures() {
|
||||
let now = performance.now()
|
||||
if (now > lastSweepTime + sweepInterval) {
|
||||
lastSweepTime = now
|
||||
let count = 0
|
||||
for (let [url, texture] of lateTextures.entries()) {
|
||||
if (texture) {
|
||||
let base = texture.baseTexture
|
||||
if (base != null && base.touched == 0) {
|
||||
texture.destroy(true)
|
||||
//console.info("Sweeping ", url)
|
||||
count += 1
|
||||
lateTextures.delete(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > 0)
|
||||
console.log("Sweeping textures", count)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Texture received too late. We do not need it.
|
||||
* @param {*} url
|
||||
* @param {*} texture
|
||||
*/
|
||||
static lateTexture(url, texture) {
|
||||
let destroyBase = !registeredTiles.has(url)
|
||||
texture.destroy(destroyBase)
|
||||
lateTextures.set(url, texture)
|
||||
//console.warn("Tile.lateTexture")
|
||||
// We cannot destroy the texture since we got errors in t.renderWebGL.
|
||||
// Perhaps we can destroy unsed textures later on
|
||||
Tile.sweepLateTextures()
|
||||
}
|
||||
|
||||
static printInfos() {
|
||||
|
||||
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@@ -173,11 +173,16 @@ class Throwable {
|
||||
}
|
||||
}
|
||||
|
||||
_throwDeltaTime() {
|
||||
let t = performance.now()
|
||||
let dt = t - this.lastframe
|
||||
this.lastframe = t
|
||||
return dt
|
||||
}
|
||||
|
||||
animateThrow(time) {
|
||||
if (this.velocity != null) {
|
||||
let t = performance.now()
|
||||
let dt = t - this.lastframe
|
||||
this.lastframe = t
|
||||
let dt = this._throwDeltaTime()
|
||||
// console.log("animateThrow", dt)
|
||||
let next = this.nextVelocity(this.velocity)
|
||||
let prevLength = Points.length(this.velocity)
|
||||
@@ -1434,7 +1439,7 @@ export class DOMScatter extends AbstractScatter {
|
||||
let resizeW = r * Math.cos(Angle.degree2radian(phiCorrected))
|
||||
let resizeH = -r * Math.sin(Angle.degree2radian(phiCorrected))
|
||||
|
||||
if (this.element.offsetWidth + resizeW / this.scale > this.width * 0.3 && this.element.offsetHeight + resizeH / this.scale > this.height * 0.3) TweenLite.to(this.element, 0, { width: this.element.offsetWidth + resizeW / this.scale, height: this.element.offsetHeight + resizeH / this.scale });
|
||||
if ((this.element.offsetWidth + resizeW) / this.scale > this.width * 0.5 / this.scale && (this.element.offsetHeight + resizeH) / this.scale > this.height * 0.3 / this.scale) TweenLite.to(this.element, 0, { width: this.element.offsetWidth + resizeW / this.scale, height: this.element.offsetHeight + resizeH / this.scale });
|
||||
|
||||
this.oldX = e.clientX
|
||||
this.oldY = e.clientY
|
||||
|
||||
|
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 184 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 44 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "iwmlib",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.14",
|
||||
"description": "An Open Source library for multi-touch, WebGL powered applications.",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
|
||||