diff --git a/package.json b/package.json index 2b52cfa..26c1c65 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vts-browser-js", - "version": "2.23.10", + "version": "2.23.11", "description": "JavaScript WebGL 3D maps rendering engine", "main": "src/browser/index.js", "scripts": { diff --git a/src/core/core.js b/src/core/core.js index 3abb6c1..64c1fdc 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -588,7 +588,7 @@ string getCoreVersion() */ function getCoreVersion(full) { - return (full ? 'Core: ' : '') + '2.23.10'; + return (full ? 'Core: ' : '') + '2.23.11'; } diff --git a/src/core/map/metanode.js b/src/core/map/metanode.js index 9cbae99..bc306b2 100755 --- a/src/core/map/metanode.js +++ b/src/core/map/metanode.js @@ -596,6 +596,14 @@ MapMetanode.prototype.generateCullingHelpers = function(virtual) { maxDelta = Math.min(d1, d2, d3, d4); } + if (version >= 5 && this.usedDisplaySize()) { + this.bboxMaxSize = Math.max( + vec3.distance2(bbox, 0, bbox, 3), + vec3.distance2(bbox, 3, bbox, 6), + vec3.distance2(bbox, 0, bbox, 12) + ); + } + //get cos angle based at 90deg this.diskAngle = Math.cos(Math.max(0,(Math.PI * 0.5) - Math.acos(maxDelta))); this.diskAngle2 = maxDelta; diff --git a/src/core/map/surface-tile.js b/src/core/map/surface-tile.js index 371a06c..b428a9b 100755 --- a/src/core/map/surface-tile.js +++ b/src/core/map/surface-tile.js @@ -918,7 +918,7 @@ MapSurfaceTile.prototype.updateTexelSize = function() { if (node.usedTexelSize()) { screenPixelSize = draw.ndcToScreenPixel * node.pixelSize; } else if (node.usedDisplaySize()) { - screenPixelSize = draw.ndcToScreenPixel * (node.bbox.maxSize / node.displaySize); + screenPixelSize = draw.ndcToScreenPixel * ((node.bbox ? node.bbox.maxSize : node.bboxMaxSize) / node.displaySize); } if (camera.camera.ortho) { @@ -929,10 +929,9 @@ MapSurfaceTile.prototype.updateTexelSize = function() { if (node.usedDisplaySize()) { if (!preciseDistance) { - screenPixelSize = draw.ndcToScreenPixel * (node.bbox.maxSize / 256); + screenPixelSize = draw.ndcToScreenPixel * ((node.bbox ? node.bbox.maxSize : node.bboxMaxSize) / 256); factor = (node.displaySize / 256) * camera.distance; - //var factor = (256 / 256) * this.map.cameraDistance; v = camera.vector; //move camera away hack p = [cameraPos[0] - v[0] * factor, cameraPos[1] - v[1] * factor, cameraPos[2] - v[2] * factor]; @@ -940,11 +939,9 @@ MapSurfaceTile.prototype.updateTexelSize = function() { pixelSize = this.getPixelSize(node.bbox, screenPixelSize, p, p, true); } else { if (draw.isGeocent) { - //screenPixelSize = draw.ndcToScreenPixel * ((node.diskAngle2A * draw.planetRadius * 2 * 0.70710678118) / 256) * (256 / node.displaySize); screenPixelSize = draw.ndcToScreenPixel * ((node.diskAngle2A * draw.planetRadius * 1.41421356236) / node.displaySize); } else { - //screenPixelSize = draw.ndcToScreenPixel * (node.bbox.maxSize / 256) * (256 / node.displaySize); - screenPixelSize = draw.ndcToScreenPixel * (node.bbox.maxSize / node.displaySize); + screenPixelSize = draw.ndcToScreenPixel * ((node.bbox ? node.bbox.maxSize : node.bboxMaxSize) / node.displaySize); } pixelSize = this.getPixelSize3(node, screenPixelSize); diff --git a/src/core/utils/matrix.js b/src/core/utils/matrix.js index 48c5c11..5d73f64 100755 --- a/src/core/utils/matrix.js +++ b/src/core/utils/matrix.js @@ -265,6 +265,14 @@ vec3.distance = function (a, b) { return Math.sqrt(dx*dx + dy*dy + dz*dz); }; +vec3.distance2 = function (a, i, b, j) { + var dx = b[j] - a[i]; + var dy = b[j+1] - a[i+1]; + var dz = b[j+2] - a[i+2]; + return Math.sqrt(dx*dx + dy*dy + dz*dz); +}; + + vec3.squareDistance = function (a, b) { var dx = b[0] - a[0]; var dy = b[1] - a[1];