Skip to content

Commit

Permalink
Merge pull request #105 from DavidLevinsky/master
Browse files Browse the repository at this point in the history
Global screen count filtering
  • Loading branch information
davidmtech authored Jul 12, 2018
2 parents 3cc76a6 + 3e71bcf commit 20e501c
Show file tree
Hide file tree
Showing 31 changed files with 1,043 additions and 191 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.15.8",
"version": "2.15.10",
"description": "JavaScript WebGL 3D maps rendering engine",
"main": "src/browser/index.js",
"scripts": {
Expand Down
10 changes: 7 additions & 3 deletions src/browser/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,29 @@ BrowserInterface.prototype.destroyMap = function() {


BrowserInterface.prototype.on = function(eventName, call) {
if (this.killed) return;
this.core.on(eventName, call);
return this;
};


BrowserInterface.prototype.setParams = function(params) {
this.setConfigParams(params);
if (this.killed) return;
this.setConfigParams(params,true);
return this;
};


BrowserInterface.prototype.setParam = function(key, value) {
this.setConfigParam(key, value);
if (this.killed) return;
this.browser.setConfigParam(key, value, true);
return this;
};


BrowserInterface.prototype.getParam = function(key) {
return this.getConfigParam(key);
if (this.killed) return;
return this.browser.getConfigParam(key);
};


Expand Down
16 changes: 15 additions & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,18 @@ var Core = function(element, config, coreInterface) {
mapXhrImageLoad : true,
mapStoreLoadStats : false,
mapRefreshCycles : 3,
mapFeatureGridCells : 31,
mapFeaturesPerSquareInch : 0.25, //0.6614,
mapFeaturesSortByTop : false,
mapDegradeHorizon : false,
mapDegradeHorizonParams : [1, 1500, 97500, 3500], //[1, 3000, 15000, 7000],
mapDefaultFont : '//cdn.melown.com/libs/vtsjs/fonts/noto-basic/1.0.0/noto.fnt',
//mapDefaultFont : '../fonts/basic.fnt',
mapFog : true,
mapNoTextures: false,
mapMetricUnits : !(lang == 'en' || lang.indexOf('en-') == 0),
mapForceFrameTime: 0,
mapForcePipeline: 0,
rendererAnisotropic : 0,
rendererAntialiasing : true,
rendererAllowScreenshots : false,
Expand Down Expand Up @@ -188,6 +193,13 @@ Core.prototype.loadMap = function(path) {
//this.tokenLoaded = true;

var onAutorizationLoaded = (function(data) {
if (!data || (data && data['status'])) {
if (this.tokenCanBeSkiped) {
onLoadMapconfig(path);
}
return;
}

this.tokenLoaded = true;
this.xhrParams['token'] = data['token'];
this.xhrParams['tokenHeader'] = data['header'];
Expand Down Expand Up @@ -427,6 +439,8 @@ Core.prototype.setConfigParam = function(key, value) {
this.config.map = utils.validateString(value, null);
} else if (key == 'mapVirtualSurfaces') {
this.config.mapVirtualSurfaces = utils.validateBool(value, true);
} else if (key == 'mapForcePipeline') {
this.config.mapForcePipeline = utils.validateNumber(value, -1, Number.MAXINTEGER, 0);
} else if (key == 'inspector') {
this.config.inspector = utils.validateBool(value, true);
} else if (key == 'authorization') {
Expand Down Expand Up @@ -494,7 +508,7 @@ string getCoreVersion()
*/

function getCoreVersion(full) {
return (full ? 'Core: ' : '') + '2.15.8';
return (full ? 'Core: ' : '') + '2.15.10';
}


Expand Down
15 changes: 15 additions & 0 deletions src/core/inspector/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@ InspectorInput.prototype.onKeyUp = function(event, press) {
}
}

if (this.diagnosticMode && debug.drawWireframe && !press) {
if (keyCode >= 96 && keyCode <= 105) {
if (this.altDown) {
debug.drawTestData = keyCode - 96;
if (this.ctrlDown) {
debug.drawTestData += 10;
}
} else {
debug.drawTestMode = keyCode - 96;
}

hit = true;
}
}

if (this.diagnosticMode && inspector.drawRadar && !this.shiftDown && !press) {
blockHit = true;

Expand Down
34 changes: 34 additions & 0 deletions src/core/map/body.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

var MapBody = function(map, json) {
//this.map = map;
//this.id = json["id"] || null;
this.parse(json);
};


MapBody.prototype.parse = function(json) {
this.class = json['class'] || '';
this.comment = json['comment'] || '';
this.parent = json['parent'] || '';
this.atmosphere = json['atmosphere'] || null;

if (this.atmosphere) {
if (!this.atmosphere['colorHorizon']) this.atmosphere['colorHorizon'] = [0,0,0,0];
if (!this.atmosphere['colorZenith']) this.atmosphere['colorZenith'] = [0,0,0,0];
if (!this.atmosphere['thickness']) this.atmosphere['thickness'] = 100000;
if (!this.atmosphere['visibility']) this.atmosphere['visibility'] = 100000;
}
};


MapBody.prototype.getInfo = function() {
return {
'class' : this.class,
'comment' : this.comment,
'parent' : this.parent,
'atmosphere' : JSON.parse(JSON.stringify(this.atmosphere)),
};
};


export default MapBody;
8 changes: 8 additions & 0 deletions src/core/map/bound-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var MapBoundLayer = function(map, json, id) {
this.baseUrlSchema = this.map.url.baseUrlSchema;
this.baseUrlOrigin = this.map.url.baseUrlOrigin;
this.ready = false;
this.dataType = VTS_TEXTURETYPE_COLOR;

//hack
if (id == 'esri-world-imagery') {
Expand Down Expand Up @@ -73,6 +74,13 @@ MapBoundLayer.prototype.parseJson = function(json) {
this.credits = json['credits'] || [];
this.creditsUrl = null;

switch(json['dataType']) {
default:
case 'color': this.dataType = VTS_TEXTURETYPE_COLOR; break;
case 'height': this.dataType = VTS_TEXTURETYPE_HEIGHT; break;
case 'classification': this.dataType = VTS_TEXTURETYPE_CLASS; break;
}

this.specificity = Math.pow(2,this.lodRange[0]) / ((this.tileRange[1][0] - this.tileRange[1][0]+1)*(this.tileRange[1][1] - this.tileRange[1][1]+1));

this.availability = json['availability'] ? {} : null;
Expand Down
20 changes: 19 additions & 1 deletion src/core/map/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import MapCredit_ from './credit';
import MapRefFrame_ from './refframe';
import MapView_ from './view';
import MapSrs_ from './srs';
import MapBody_ from './body';
import MapSurface_ from './surface';
import MapVirtualSurface_ from './virtual-surface';
import MapStylesheet_ from './stylesheet';
Expand All @@ -14,6 +15,7 @@ var MapBoundLayer = MapBoundLayer_;
var MapRefFrame = MapRefFrame_;
var MapView = MapView_;
var MapSrs = MapSrs_;
var MapBody = MapBody_;
var MapSurface = MapSurface_;
var MapVirtualSurface = MapVirtualSurface_;
var MapStylesheet = MapStylesheet_;
Expand All @@ -27,7 +29,7 @@ var MapConfig = function(map, config) {


MapConfig.prototype.parseConfig = function() {
if (!(this.parseSrses() && this.parseReferenceFrame() &&
if (!(this.parseSrses() && this.parseBodies() && this.parseReferenceFrame() &&
this.parseCredits() && this.parseStylesheets() &&
this.parseSurfaces() && this.parseGlues() &&
this.parseVirtualSurfaces() && this.parseBoundLayers() &&
Expand Down Expand Up @@ -69,6 +71,22 @@ MapConfig.prototype.parseSrses = function() {
};


MapConfig.prototype.parseBodies = function() {
var bodies = this.mapConfig['bodies'];
this.map.bodies = {};

if (bodies == null) {
return true;//false;
}

for (var key in bodies) {
this.map.addBody(key, new MapBody(this.map, bodies[key]));
}

return true;
};


MapConfig.prototype.parseReferenceFrame = function() {
var rf = this.mapConfig['referenceFrame'];

Expand Down
68 changes: 55 additions & 13 deletions src/core/map/draw-tiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize,
if (submesh.internalUVs) { //draw surface
if (tile.surfaceTextures[i] == null) {
path = tile.resourceSurface.getTextureUrl(tile.id, i);
tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true);
tile.surfaceTextures[i] = tile.resources.getTexture(path, VTS_TEXTURETYPE_COLOR, null, null, tile, true);
}

tile.drawCommands[0].push({
Expand Down Expand Up @@ -301,8 +301,8 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize,
mesh : tile.surfaceMesh,
submesh : i,
texture : texture,
material : VTS_MATERIAL_EXTERNAL_NOFOG,
alpha : bounds.alpha[layers[j]][1]
alpha : bounds.alpha[layers[j]][1],
material : VTS_MATERIAL_EXTERNAL_NOFOG
});
}
}
Expand Down Expand Up @@ -386,7 +386,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize,
if (submesh.internalUVs) { //draw surface
if (tile.surfaceTextures[i] == null) {
path = tile.resourceSurface.getTextureUrl(tile.id, i);
tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true);
tile.surfaceTextures[i] = tile.resources.getTexture(path, VTS_TEXTURETYPE_COLOR, null, null, tile, true);
}

//draw mesh
Expand Down Expand Up @@ -414,7 +414,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize,

if (tile.surfaceTextures[i] == null) {
path = tile.resourceSurface.getTextureUrl(tile.id, i);
tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true);
tile.surfaceTextures[i] = tile.resources.getTexture(path, VTS_TEXTURETYPE_COLOR, null, null, tile, true);
} //else {
tile.drawCommands[0].push({
type : VTS_DRAWCOMMAND_SUBMESH,
Expand All @@ -431,7 +431,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize,

if (tile.surfaceTextures[i] == null) {
path = tile.resourceSurface.getTextureUrl(tile.id, i);
tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true);
tile.surfaceTextures[i] = tile.resources.getTexture(path, VTS_TEXTURETYPE_COLOR, null, null, tile, true);
} //else {
tile.drawCommands[0].push({
type : VTS_DRAWCOMMAND_SUBMESH,
Expand Down Expand Up @@ -616,11 +616,53 @@ MapDrawTiles.prototype.drawGeodataTile = function(tile, node, cameraPos, pixelSi


MapDrawTiles.prototype.updateTileHmap = function(tile, node) {
if (node && node.hasNavtile() && tile.surface) {
var path = tile.surface.getNavUrl(tile.id);
this.hmap = tile.resources.getTexture(path, null, null, null, tile, true);
if (node && node.hasNavtile() && tile.surface) {

if (!tile.surface || !tile.resourceSurface) { //surface.virtual) {
return false; //is it best way how to do it?
}

if (!tile.resourceSurface.getHMapUrl) { //virtual surface is as resource surface. Is it bug??!!
return false; //is it best way how to do it?
}

var path = tile.resourceSurface.getHMapUrl(tile.id, true);
tile.hmap = tile.resources.getTexture(path);

//var path = tile.surface.getNavUrl(tile.id);
//tile.hmap = tile.resources.getTexture(path, null, null, null, tile, true);
} else {
this.hmap = this.renderer.blackTexture;

//get parent with nav tile
var parent = tile.parent;
var extraBound = null;

while(parent && parent.id[0] > 0) {
if (parent.metanode && parent.metanode.hasNavtile()) {
extraBound = {
sourceTile : parent,
sourceTexture : null,
hmap : true,
tile : tile
};

break;
}

parent = parent.parent;
}

//does parent with navtile exist
if (extraBound) {
var path = tile.resourceSurface.getHMapUrl(tile.id, true);
tile.hmap = tile.resources.getTexture(path, null, extraBound, {tile: tile, hmap: true}, tile, false);

if (tile.hmap.neverReady) {
tile.hmap = null;
}
} else {
tile.hmap = null;
}
}
};

Expand Down Expand Up @@ -721,7 +763,7 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface

if (!texture) { //TODO: make sure that we load only textures which we need
path = layer.getUrl(tile.id);
texture = tile.resources.getTexture(path, null, extraBound, {tile: tile, layer: layer}, tile, false);
texture = tile.resources.getTexture(path, layer.dataType, extraBound, {tile: tile, layer: layer}, tile, false);

if (texture.checkType == VTS_TEXTURECHECK_MEATATILE) {
texture.checkMask = true;
Expand Down Expand Up @@ -818,7 +860,7 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface
tile.boundLayers[layer.id] = layer;
if (!tile.boundTextures[layer.id]) {
path = layer.getUrl(tile.id);
tile.boundTextures[layer.id] = tile.resources.getTexture(path, null, extraBound, {tile: tile, layer: layer}, tile, false);
tile.boundTextures[layer.id] = tile.resources.getTexture(path, layer.dataType, extraBound, {tile: tile, layer: layer}, tile, false);
}
}
}
Expand All @@ -842,7 +884,7 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface
tile.boundLayers[layer.id] = layer;
if (!tile.boundTextures[layer.id]) {
path = layer.getUrl(tile.id);
tile.boundTextures[layer.id] = tile.resources.getTexture(path, null, extraBound, {tile: tile, layer: layer}, tile, false);
tile.boundTextures[layer.id] = tile.resources.getTexture(path, layer.dataType, extraBound, {tile: tile, layer: layer}, tile, false);
}
}
}
Expand Down
Loading

0 comments on commit 20e501c

Please sign in to comment.