Skip to content

Commit

Permalink
no autorotation when loading screen is displayed, fixed bboxes with i…
Browse files Browse the repository at this point in the history
…nfinite size, fixed surface switching
  • Loading branch information
davidmtech committed May 9, 2017
1 parent ceff085 commit 43a58ea
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 53 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions src/browser/autopilot/autopilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/browser/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,15 @@ 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);
}
break;
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)
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ string getCoreVersion()
*/

function getCoreVersion(full) {
return (full ? 'Core: ' : '') + '2.2.1';
return (full ? 'Core: ' : '') + '2.2.2';
}


Expand Down
45 changes: 26 additions & 19 deletions src/core/inspector/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += '<div class="vts-layers-item"><input id="vts-boundlayer-checkbox-' + layer.id + '" type="checkbox" ' + (layer.enabled ? 'checked' : '') + '/>'
+ '<div class="vts-layers-name">' + layer.id + '</div>'
+ '<input id="vts-boundlayer-spinner-' + layer.id + '" type="number" title="Alpha" min="0" max="100" step="10" value="' + layer.alpha + '">'
+ '<button id="vts-boundlayer-ubutton-' + layer.id + '" type="button" title="Move Above">&uarr;</button>'
+ '<button id="vts-boundlayer-dbutton-' + layer.id + '" type="button" title="Move Bellow">&darr;</button>'
+ '</div>';
for (var i = 0, li = layers.length; i < li; i++) {
var layer = layers[i];

html += '<div class="vts-layers-item"><input id="vts-boundlayer-checkbox-' + layer.id + '" type="checkbox" ' + (layer.enabled ? 'checked' : '') + '/>'
+ '<div class="vts-layers-name">' + layer.id + '</div>'
+ '<input id="vts-boundlayer-spinner-' + layer.id + '" type="number" title="Alpha" min="0" max="100" step="10" value="' + layer.alpha + '">'
+ '<button id="vts-boundlayer-ubutton-' + layer.id + '" type="button" title="Move Above">&uarr;</button>'
+ '<button id="vts-boundlayer-dbutton-' + layer.id + '" type="button" title="Move Bellow">&darr;</button>'
+ '</div>';
}
}

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');
}
}
};

Expand Down Expand Up @@ -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);
};
Expand Down
6 changes: 3 additions & 3 deletions src/core/map/draw-tiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions src/core/map/metanode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions src/core/map/surface-tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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];
}
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/map/surface-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
30 changes: 23 additions & 7 deletions src/core/renderer/bbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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;
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/core/renderer/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -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
};
Expand Down

0 comments on commit 43a58ea

Please sign in to comment.