From ceff08503edb3a783b76994e38b43735015f95f5 Mon Sep 17 00:00:00 2001 From: David Levinsky Date: Fri, 5 May 2017 17:07:07 +0200 Subject: [PATCH 1/2] fixed bound layers --- src/core/map/draw-tiles.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/map/draw-tiles.js b/src/core/map/draw-tiles.js index c679693b..ced2d1ed 100755 --- a/src/core/map/draw-tiles.js +++ b/src/core/map/draw-tiles.js @@ -628,9 +628,9 @@ MapDrawTiles.prototype.getTileTextureTransform = function(sourceTile, targetTile MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface, bound, fullUpdate) { var path, extraBound, layer, texture; - //if (tile.id[0] == 18 && tile.id[1] == 70930 && tile.id[2] == 44286) { - // tile = tile; - //} + if (tile.id[0] == 18 && tile.id[1] == 70930 && tile.id[2] == 44286) { + tile = tile; + } //search map view if (surface.boundLayerSequence.length > 0) { @@ -671,7 +671,8 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface bound.transparent = true; } - var fullAndOpaque = !((surface.boundLayerSequence[j][1] < 1.0) || texture.extraBound || texture.getMaskTexture() || layer.isTransparent); + //var fullAndOpaque = !((surface.boundLayerSequence[j][1] < 1.0) || texture.extraBound || texture.getMaskTexture() || layer.isTransparent); + var fullAndOpaque = !((surface.boundLayerSequence[j][1] < 1.0) || extraBound || texture.getMaskTexture() || layer.isTransparent); if (fullAndOpaque) { fullAndOpaqueCounter++; } @@ -762,6 +763,12 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface } } } + + if (tile.id[0] == 18 && tile.id[1] == 70930 && tile.id[2] == 44286) { + console.log(JSON.stringify(bound.sequence)) + //tile = tile; + } + }; From 43a58ea9c3c07446f4e81aae18ecdd17e3fea2ea Mon Sep 17 00:00:00 2001 From: David Levinsky Date: Tue, 9 May 2017 17:01:19 +0200 Subject: [PATCH 2/2] no autorotation when loading screen is displayed, fixed bboxes with infinite size, fixed surface switching --- package.json | 2 +- src/browser/autopilot/autopilot.js | 6 ++++ src/browser/browser.js | 4 +-- src/core/core.js | 2 +- src/core/inspector/layers.js | 45 +++++++++++++++++------------- src/core/map/draw-tiles.js | 6 ++-- src/core/map/metanode.js | 14 +++++----- src/core/map/surface-tile.js | 14 +++++----- src/core/map/surface-tree.js | 6 ++-- src/core/renderer/bbox.js | 30 +++++++++++++++----- src/core/renderer/camera.js | 6 ++-- 11 files changed, 82 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index fc9c193e..a0d0572e 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vts-browser-js", - "version": "2.2.1", + "version": "2.2.2", "description": "JavaScript WebGL 3D maps rendering engine", "main": "src/browser/index.js", "scripts": { diff --git a/src/browser/autopilot/autopilot.js b/src/browser/autopilot/autopilot.js index 30f4744d..73826f9b 100755 --- a/src/browser/autopilot/autopilot.js +++ b/src/browser/autopilot/autopilot.js @@ -118,6 +118,12 @@ Autopilot.prototype.tick = function() { var timeFactor = (time - this.lastTime) / 1000; this.lastTime = time; + if (this.browser.ui && this.browser.ui.loading && + this.browser.ui.loading.control.getVisible()) { + return; + } + + if (this.autoRotate != 0) { pos = map.getPosition(); var o = pos.getOrientation(); diff --git a/src/browser/browser.js b/src/browser/browser.js index 74599b3c..7d0a153c 100755 --- a/src/browser/browser.js +++ b/src/browser/browser.js @@ -353,7 +353,7 @@ Browser.prototype.setConfigParam = function(key, value, ignoreCore) { case 'sensitivity': this.config.sensitivity = utils.validateNumberArray(value, 3, [0,0,0], [10, 10, 10], [1, 0.12, 0.05]); break; case 'inertia': this.config.inertia = utils.validateNumberArray(value, 3, [0,0,0], [0.99, 0.99, 0.99], [0.85, 0.9, 0.7]); break; case 'rotate': - this.config.autoRotate = utils.validateNumber(value, Number.NEGATIVEINFINITY, Number.POSITIVEINFINITY, 0); + this.config.autoRotate = utils.validateNumber(value, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, 0); if (map && this.autopilot) { this.autopilot.setAutorotate(this.config.autoRotate); } @@ -361,7 +361,7 @@ Browser.prototype.setConfigParam = function(key, value, ignoreCore) { case 'pan': if (Array.isArray(value) && value.length == 2){ this.config.autoPan = [ - utils.validateNumber(value[0], Number.NEGATIVEINFINITY, Number.POSITIVEINFINITY, 0), + utils.validateNumber(value[0], Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, 0), utils.validateNumber(value[1], -360, 360, 0) ]; } diff --git a/src/core/core.js b/src/core/core.js index 9228323e..790eec0b 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -468,7 +468,7 @@ string getCoreVersion() */ function getCoreVersion(full) { - return (full ? 'Core: ' : '') + '2.2.1'; + return (full ? 'Core: ' : '') + '2.2.2'; } diff --git a/src/core/inspector/layers.js b/src/core/inspector/layers.js index 95959590..62b655af 100755 --- a/src/core/inspector/layers.js +++ b/src/core/inspector/layers.js @@ -435,31 +435,36 @@ InspectorLayers.prototype.buildSurfaces = function() { InspectorLayers.prototype.buildBoundLayers = function(id) { var view = this.views[this.currentView]; - var layers = view.surfaces[id].layers; var html = ''; - for (var i = 0, li = layers.length; i < li; i++) { - var layer = layers[i]; + if (view.surfaces[id]) { + var layers = view.surfaces[id].layers; - html += '
' - + '
' + layer.id + '
' - + '' - + '' - + '' - + '
'; + for (var i = 0, li = layers.length; i < li; i++) { + var layer = layers[i]; + + html += '
' + + '
' + layer.id + '
' + + '' + + '' + + '' + + '
'; + } } this.boundLayersItems.innerHTML = html; - for (i = 0, li = layers.length; i < li; i++) { - var htmlId = 'vts-boundlayer-checkbox-' + layers[i].id; - document.getElementById(htmlId).onchange = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'enable'); - htmlId = 'vts-boundlayer-spinner-' + layers[i].id; - document.getElementById(htmlId).onchange = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'alpha'); - htmlId = 'vts-boundlayer-ubutton-' + layers[i].id; - document.getElementById(htmlId).onclick = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'up'); - htmlId = 'vts-boundlayer-dbutton-' + layers[i].id; - document.getElementById(htmlId).onclick = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'down'); + if (view.surfaces[id]) { + for (i = 0, li = layers.length; i < li; i++) { + var htmlId = 'vts-boundlayer-checkbox-' + layers[i].id; + document.getElementById(htmlId).onchange = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'enable'); + htmlId = 'vts-boundlayer-spinner-' + layers[i].id; + document.getElementById(htmlId).onchange = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'alpha'); + htmlId = 'vts-boundlayer-ubutton-' + layers[i].id; + document.getElementById(htmlId).onclick = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'up'); + htmlId = 'vts-boundlayer-dbutton-' + layers[i].id; + document.getElementById(htmlId).onclick = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'down'); + } } }; @@ -664,7 +669,9 @@ InspectorLayers.prototype.selectSurface = function(id) { //select new one element = document.getElementById('vts-surface-item-' + id); - element.style.backgroundColor = '#ddd'; + if (element) { + element.style.backgroundColor = '#ddd'; + } this.currentSurface = id; this.buildBoundLayers(this.currentSurface); }; diff --git a/src/core/map/draw-tiles.js b/src/core/map/draw-tiles.js index ced2d1ed..82ef01e2 100755 --- a/src/core/map/draw-tiles.js +++ b/src/core/map/draw-tiles.js @@ -628,9 +628,9 @@ MapDrawTiles.prototype.getTileTextureTransform = function(sourceTile, targetTile MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface, bound, fullUpdate) { var path, extraBound, layer, texture; - if (tile.id[0] == 18 && tile.id[1] == 70930 && tile.id[2] == 44286) { - tile = tile; - } + //if (tile.id[0] == 18 && tile.id[1] == 70930 && tile.id[2] == 44286) { + //tile = tile; + //} //search map view if (surface.boundLayerSequence.length > 0) { diff --git a/src/core/map/metanode.js b/src/core/map/metanode.js index 598085af..10b5219d 100755 --- a/src/core/map/metanode.js +++ b/src/core/map/metanode.js @@ -164,12 +164,12 @@ struct Metanode { //console.log("empty-node: id: " + JSON.stringify(this.id)); //console.log("empty-node: surafce: " + this.metatile.surface.id); - minExtents[0] = Number.POSITIVEINFINITY; - minExtents[1] = Number.POSITIVEINFINITY; - minExtents[2] = Number.POSITIVEINFINITY; - maxExtents[0] = Number.NEGATIVEINFINITY; - maxExtents[1] = Number.NEGATIVEINFINITY; - maxExtents[2] = Number.NEGATIVEINFINITY; + minExtents[0] = Number.POSITIVE_INFINITY; + minExtents[1] = Number.POSITIVE_INFINITY; + minExtents[2] = Number.POSITIVE_INFINITY; + maxExtents[0] = Number.NEGATIVE_INFINITY; + maxExtents[1] = Number.NEGATIVE_INFINITY; + maxExtents[2] = Number.NEGATIVE_INFINITY; } this.bbox = new BBox(minExtents[0], minExtents[1], minExtents[2], maxExtents[0], maxExtents[1], maxExtents[2]); @@ -187,7 +187,7 @@ struct Metanode { this.displaySize = streamData.getUint16(stream.index, true); stream.index += 2; this.displaySize = 1024; if ((this.flags & (1 << 2)) == 0) { - this.pixelSize = Number.POSITIVEINFINITY; + this.pixelSize = Number.POSITIVE_INFINITY; } if ((this.flags & (1 << 3)) == 0) { diff --git a/src/core/map/surface-tile.js b/src/core/map/surface-tile.js index d16df570..b4aeb619 100755 --- a/src/core/map/surface-tile.js +++ b/src/core/map/surface-tile.js @@ -669,10 +669,10 @@ MapSurfaceTile.prototype.getPixelSize = function(bbox, screenPixelSize, cameraPo cameraPos[2] > min[2] && cameraPos[2] < max[2]) { if (returnDistance) { - return [Number.POSITIVEINFINITY, 0.1]; + return [Number.POSITIVE_INFINITY, 0.1]; } - return Number.POSITIVEINFINITY; + return Number.POSITIVE_INFINITY; } } @@ -775,7 +775,7 @@ MapSurfaceTile.prototype.getPixelSize3Old = function(node, screenPixelSize, fact var d = (camera.geocentDistance*factor) - node.diskDistance; if (d < 0) { d = -d; - //return [Number.POSITIVEINFINITY, 0.1]; + //return [Number.POSITIVE_INFINITY, 0.1]; } var a = vec3.dot(camera.geocentNormal, node.diskNormal); @@ -830,7 +830,7 @@ MapSurfaceTile.prototype.getPixelSize3 = function(node, screenPixelSize) { if (d2 < 0) { //is camera is belown bottom bbox level? d = -d2; } else { //is camera inside bbox - return [Number.POSITIVEINFINITY, 0.1]; + return [Number.POSITIVE_INFINITY, 0.1]; } } } @@ -874,7 +874,7 @@ MapSurfaceTile.prototype.updateTexelSize = function() { var preciseDistance = (map.isGeocent && (map.config.mapPreciseDistanceTest || node.metatile.useVersion >= 4)); if (node.hasGeometry()) { - var screenPixelSize = Number.POSITIVEINFINITY; + var screenPixelSize = Number.POSITIVE_INFINITY; if (node.usedTexelSize()) { screenPixelSize = draw.ndcToScreenPixel * node.pixelSize; @@ -931,7 +931,7 @@ MapSurfaceTile.prototype.updateTexelSize = function() { } //pixelSize = this.getPixelSize(node.bbox, 1, cameraPos, cameraPos, true); - pixelSize[0] = Number.POSITIVEINFINITY; + pixelSize[0] = Number.POSITIVE_INFINITY; } this.texelSize = pixelSize[0]; @@ -976,7 +976,7 @@ MapSurfaceTile.prototype.updateTexelSize = function() { MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { - if ((this.texelSize == Number.POSITIVEINFINITY || this.texelSize > 4.4) && this.metanode && this.metanode.hasChildren()) { + if ((this.texelSize == Number.POSITIVE_INFINITY || this.texelSize > 4.4) && this.metanode && this.metanode.hasChildren()) { return; } diff --git a/src/core/map/surface-tree.js b/src/core/map/surface-tree.js index 6b6da1db..43910f94 100755 --- a/src/core/map/surface-tree.js +++ b/src/core/map/surface-tree.js @@ -301,7 +301,7 @@ MapSurfaceTree.prototype.drawSurface = function() { usedNodes++; - if (tile.texelSize != Number.POSITIVEINFINITY){ + if (tile.texelSize != Number.POSITIVE_INFINITY){ if (tile.texelSize > best) { best = tile.texelSize; } @@ -533,7 +533,7 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function() { storeNodesBuffer.push(tile); } - if (tile.texelSize != Number.POSITIVEINFINITY){ + if (tile.texelSize != Number.POSITIVE_INFINITY){ if (tile.texelSize > best) { best = tile.texelSize; } @@ -763,7 +763,7 @@ MapSurfaceTree.prototype.drawSurfaceFit = function() { usedNodes++; - if (tile.texelSize != Number.POSITIVEINFINITY){ + if (tile.texelSize != Number.POSITIVE_INFINITY){ if (tile.texelSize > best) { best = tile.texelSize; } diff --git a/src/core/renderer/bbox.js b/src/core/renderer/bbox.js index d0266ccc..ef6b675d 100755 --- a/src/core/renderer/bbox.js +++ b/src/core/renderer/bbox.js @@ -3,13 +3,13 @@ var BBox = function(xmin, ymin, zmin, xmax, ymax, zmax) { this.min = []; this.max = []; - this.min[0] = (xmin != null) ? xmin : Number.POSITIVEINFINITY; - this.min[1] = (ymin != null) ? ymin : Number.POSITIVEINFINITY; - this.min[2] = (zmin != null) ? zmin : Number.POSITIVEINFINITY; + this.min[0] = (xmin != null) ? xmin : Number.POSITIVE_INFINITY; + this.min[1] = (ymin != null) ? ymin : Number.POSITIVE_INFINITY; + this.min[2] = (zmin != null) ? zmin : Number.POSITIVE_INFINITY; - this.max[0] = (xmax != null) ? xmax : Number.NEGATIVEINFINITY; - this.max[1] = (ymax != null) ? ymax : Number.NEGATIVEINFINITY; - this.max[2] = (zmax != null) ? zmax : Number.NEGATIVEINFINITY; + this.max[0] = (xmax != null) ? xmax : Number.NEGATIVE_INFINITY; + this.max[1] = (ymax != null) ? ymax : Number.NEGATIVE_INFINITY; + this.max[2] = (zmax != null) ? zmax : Number.NEGATIVE_INFINITY; /* this.maxSize = Math.max(this.max[0] - this.min[0], @@ -43,7 +43,23 @@ BBox.prototype.center = function(vec) { vec[1] = (this.min[1] + this.max[1])*0.5; return vec; } else { - return [(this.min[0] + this.max[0])*0.5, (this.min[1] + this.max[1])*0.5, (this.min[2] + this.max[2])*0.5]; + if (!this.middle) { + this.middle = [(this.min[0] + this.max[0])*0.5, (this.min[1] + this.max[1])*0.5, (this.min[2] + this.max[2])*0.5]; + + if (Number.isNaN(this.middle[0])) { + this.middle[0] = 0; + } + + if (Number.isNaN(this.middle[1])) { + this.middle[1] = 0; + } + + if (Number.isNaN(this.middle[2])) { + this.middle[2] = 0; + } + } + + return this.middle; } }; diff --git a/src/core/renderer/camera.js b/src/core/renderer/camera.js index dba1f872..fab9dbc4 100755 --- a/src/core/renderer/camera.js +++ b/src/core/renderer/camera.js @@ -158,12 +158,12 @@ Camera.prototype.scaleFactor = function(worldPos, returnDist) { // resolution independent of camera rotation) if (returnDist) { - if (dist < this.near) return [Number.POSITIVEINFINITY, dist]; + if (dist < this.near) return [Number.POSITIVE_INFINITY, dist]; return [this.projection[0] / dist, dist]; //return [(this.projection[5]*0.5) / dist, dist]; //projection by sy } - if (dist < this.near) return Number.POSITIVEINFINITY; + if (dist < this.near) return Number.POSITIVE_INFINITY; return this.projection[0] / dist; //return (this.projection[5]*0.5) / dist; //projection by sy }; @@ -172,7 +172,7 @@ Camera.prototype.scaleFactor = function(worldPos, returnDist) { Camera.prototype.scaleFactor2 = function(dist) { if (this.dirty) this.update(); - if (dist < this.near) return Number.POSITIVEINFINITY; + if (dist < this.near) return Number.POSITIVE_INFINITY; return this.projection[0] / dist; //return (this.projection[5]*0.5) / dist; //projection by sy };