|
@@ -845,7 +845,12 @@ function Renderer(container) { |
|
|
this.level = level; |
|
|
this.level = level; |
|
|
this.x = x; |
|
|
this.x = x; |
|
|
this.y = y; |
|
|
this.y = y; |
|
|
this.path = path.replace('%s',side).replace('%l',level).replace('%x',x).replace('%y',y); |
|
|
|
|
|
|
|
|
if (!path) { |
|
|
|
|
|
this.path = side + '_' + level + '_' + x + '_' + y; |
|
|
|
|
|
} else { |
|
|
|
|
|
this.path = path.replace('%s', side).replace('%l', level).replace('%x', x).replace('%y', y); |
|
|
|
|
|
} |
|
|
|
|
|
this.uri = encodeURI(this.path + '.' + image.extension); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -1146,10 +1151,21 @@ function Renderer(container) { |
|
|
this.image.addEventListener('error', loadFn); // ignore missing tile file to support partial image, otherwise retry loop causes high CPU load |
|
|
this.image.addEventListener('error', loadFn); // ignore missing tile file to support partial image, otherwise retry loop causes high CPU load |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
TextureImageLoader.prototype.loadTexture = function(src, texture, callback) { |
|
|
|
|
|
|
|
|
TextureImageLoader.prototype.loadTexture = function(node, src, texture, callback) { |
|
|
this.texture = texture; |
|
|
this.texture = texture; |
|
|
this.callback = callback; |
|
|
this.callback = callback; |
|
|
this.image.src = src; |
|
|
|
|
|
|
|
|
if (src instanceof Function) { |
|
|
|
|
|
src(node, this.image, this.texture).then(img => { |
|
|
|
|
|
if (!image) |
|
|
|
|
|
this.callback(this.texture, false); |
|
|
|
|
|
else if (img != this.image) { |
|
|
|
|
|
processLoadedTexture(img, this.texture); |
|
|
|
|
|
this.callback(img, true); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.image.src = src; |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
function PendingTextureRequest(node, src, texture, callback) { |
|
|
function PendingTextureRequest(node, src, texture, callback) { |
|
@@ -1162,7 +1178,7 @@ function Renderer(container) { |
|
|
function releaseTextureImageLoader(til) { |
|
|
function releaseTextureImageLoader(til) { |
|
|
if (pendingTextureRequests.length) { |
|
|
if (pendingTextureRequests.length) { |
|
|
var req = pendingTextureRequests.shift(); |
|
|
var req = pendingTextureRequests.shift(); |
|
|
til.loadTexture(req.src, req.texture, req.callback); |
|
|
|
|
|
|
|
|
til.loadTexture(req.node, req.src, req.texture, req.callback); |
|
|
} else |
|
|
} else |
|
|
textureImageCache[cacheTop++] = til; |
|
|
textureImageCache[cacheTop++] = til; |
|
|
} |
|
|
} |
|
@@ -1174,7 +1190,7 @@ function Renderer(container) { |
|
|
crossOrigin = _crossOrigin; |
|
|
crossOrigin = _crossOrigin; |
|
|
var texture = gl.createTexture(); |
|
|
var texture = gl.createTexture(); |
|
|
if (cacheTop) |
|
|
if (cacheTop) |
|
|
textureImageCache[--cacheTop].loadTexture(src, texture, callback); |
|
|
|
|
|
|
|
|
textureImageCache[--cacheTop].loadTexture(node, src, texture, callback); |
|
|
else |
|
|
else |
|
|
pendingTextureRequests.push(new PendingTextureRequest(node, src, texture, callback)); |
|
|
pendingTextureRequests.push(new PendingTextureRequest(node, src, texture, callback)); |
|
|
return texture; |
|
|
return texture; |
|
@@ -1187,7 +1203,7 @@ function Renderer(container) { |
|
|
* @param {MultiresNode} node - Input node. |
|
|
* @param {MultiresNode} node - Input node. |
|
|
*/ |
|
|
*/ |
|
|
function processNextTile(node) { |
|
|
function processNextTile(node) { |
|
|
loadTexture(node, encodeURI(node.path + '.' + image.extension), function(texture, loaded) { |
|
|
|
|
|
|
|
|
loadTexture(node, image.loader || node.uri, function (texture, loaded) { |
|
|
node.texture = texture; |
|
|
node.texture = texture; |
|
|
node.textureLoaded = loaded ? 2 : 1; |
|
|
node.textureLoaded = loaded ? 2 : 1; |
|
|
}, globalParams.crossOrigin); |
|
|
}, globalParams.crossOrigin); |
|
|