Skip to content

Commit

Permalink
Merge pull request #213 from davidmtech/master
Browse files Browse the repository at this point in the history
Support for super mesh and new metatiles
  • Loading branch information
davidmtech authored Apr 14, 2021
2 parents 6fe2e99 + 9fe0228 commit bd0915d
Show file tree
Hide file tree
Showing 36 changed files with 2,093 additions and 829 deletions.
Empty file modified README.md
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions demos/switching-surfaces/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function onSwitchView() {
surfaces: {
'melown-viewfinder-world': [
'bmng08-world',
'bing-world'
'sentinel2-cloudless-eox'
]
},
freeLayers: {}
Expand All @@ -58,7 +58,7 @@ function onSwitchView() {
surfaces: {
'melown-viewfinder-world': [
'bmng08-world',
'bing-world'
'sentinel2-cloudless-eox'
],
'melown-benatky-nad-jizerou': []
},
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vts-browser-js",
"version": "2.23.6",
"version": "2.23.11",
"description": "JavaScript WebGL 3D maps rendering engine",
"main": "src/browser/index.js",
"scripts": {
Expand Down Expand Up @@ -59,6 +59,7 @@
"dependencies": {
"earcut": "^2.2.2",
"geographiclib": "^1.50.0",
"melowntech-proj4": "^2.4.5"
"melowntech-proj4": "^2.4.5",
"npm": "^6.14.9"
}
}
18 changes: 18 additions & 0 deletions src/browser/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ Browser.prototype.onMapLoaded = function(event) {
}
}

var map = this.getMap();

if (this.config.tiles3d && map) {
this.tiles3d = map.createGeodata();
this.tiles3d.load3DTiles(this.config.tiles3d, {}, this.on3DTilesLoaded.bind(this));
}

if (this.autopilot) {
this.autopilot.setAutorotate(this.config.autoRotate);
this.autopilot.setAutopan(this.config.autoPan[0], this.config.autoPan[1]);
Expand Down Expand Up @@ -268,6 +275,16 @@ Browser.prototype.onGeoJsonLoaded = function(data) {
};


Browser.prototype.on3DTilesLoaded = function() {
var map = this.getMap();
var freeLayer = this.tiles3d.makeFreeLayer({});
map.addFreeLayer('tiles3d', freeLayer);
var view = map.getView();
view.freeLayers.tiles3d = { options: { fastParse: true }};
map.setView(view);
}


Browser.prototype.onTick = function() {
if (this.killed) {
return;
Expand Down Expand Up @@ -416,6 +433,7 @@ Browser.prototype.setConfigParam = function(key, value, ignoreCore) {
case 'walkMode': this.config.walkMode = utils.validateBool(value, false); break;
case 'fixedHeight': this.config.fixedHeight = utils.validateNumber(value, -Number.MAXINTEGER, Number.MAXINTEGER, 0); break;
case 'geodata': this.config.geodata = value; break;
case 'tiles3d': this.config.tiles3d = value; break;
case 'geojson': this.config.geojson = value; break;
case 'geojsonStyle': this.config.geojsonStyle = JSON.parse(value); break;
case 'rotate':
Expand Down
4 changes: 3 additions & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ var Core = function(element, config, coreInterface) {
mapParseMeshInWorker : true,
mapPackGeodataEvents : true,
mapCheckTextureSize : false,
mapTraverseToMeshNode : true,
mapNormalizeOctantTexelSize : true,

mapFeatureStickMode : [1,1],

Expand Down Expand Up @@ -586,7 +588,7 @@ string getCoreVersion()
*/

function getCoreVersion(full) {
return (full ? 'Core: ' : '') + '2.23.6';
return (full ? 'Core: ' : '') + '2.23.11';
}


Expand Down
5 changes: 5 additions & 0 deletions src/core/inspector/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ InspectorInput.prototype.onKeyUp = function(event, press) {
case 112:
debug.drawPositions = !debug.drawPositions; break; //key P pressed

case 85:
case 117:
debug.drawOctants = !debug.drawOctants; break; //key U pressed

case 84:
case 116:
debug.drawTextureSize = !debug.drawTextureSize; break; //key T pressed
Expand Down Expand Up @@ -462,6 +466,7 @@ InspectorInput.prototype.setParameter = function(key, value) {
if (has('V')) debug.drawSpaceBBox = true;
if (has('M')) debug.drawMeshBBox = true;
if (has('I')) debug.drawIndices = true;
if (has('U')) debug.drawOctants = true;
if (has('B')) debug.drawBoundLayers = true;
if (has('S')) debug.drawSurfaces = true;
if (has('Z')) debug.drawSurfaces2 = true;
Expand Down
11 changes: 9 additions & 2 deletions src/core/inspector/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ InspectorStats.prototype.updateStatsPanel = function(stats) {
' - meshes: ' + Math.round(stats.gpuMeshes/(1024*1024)) + 'MB<br/>' +
' - geodata: ' + Math.round(stats.gpuGeodata/(1024*1024)) + 'MB<br/>' +
'CPU Cache: ' + Math.round(stats.resourcesUsed/(1024*1024)) + 'MB<br/>' +
'Metaile Cache: ' + Math.round(stats.metaUsed/(1024*1024)) + 'MB<br/>' +
'Metatile Cache: ' + Math.round(stats.metaUsed/(1024*1024)) + 'MB<br/>' +
// "FOV: " + Math.round(this.core.getOption("fov")) + " deg<br/>" +
// "viewHeight: " + Math.round(this.core.getOption("viewHeight")) + " m<br/>" +
// "distance: " + Math.round(this.core.renderer.cameraDistance) + " m<br/>" +
Expand Down Expand Up @@ -153,7 +153,14 @@ InspectorStats.prototype.updateStatsPanel = function(stats) {

text3 += 'Metatiles: ' + (stats.processedMetatiles) +'<br/>'+
'Metanodes: ' + (stats.processedNodes) + ' / ' + (stats.usedNodes) + '<br/>'+
'GeodataTiles: ' + (stats.drawnGeodataTiles) + '<br/><br/>';
'GeodataTiles: ' + (stats.drawnGeodataTiles) + '<br/>';

if (stats.octoNodes) {
text3 += 'OctoNodes: ' + (stats.octoNodes) +'<br/>'+
'OctoNodesMem: ' + Math.round(stats.octoNodesMemSize/(1024*1024)) + 'MB<br/>';
}

text3 += '<br/>';

if (renderer) {
text3 += 'Nodes: ' + (renderer.drawnNodes) +'<br/><br/>';
Expand Down
3 changes: 2 additions & 1 deletion src/core/map/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var MapDraw = function(map) {
drawSurfaces : false,
drawCredits : false,
drawOrder : false,
drawOctants : false,
drawLabelBoxes : false,
drawAllLabels : false,
drawHiddenLabels : false,
Expand Down Expand Up @@ -798,7 +799,7 @@ MapDraw.prototype.drawMonoliticGeodata = function(surface) {
surface.monoGeodataCounter = surface.geodataCounter;
}

if (surface.monoGeodata.isReady()) {
if (surface.monoGeodata.isReady(null, null, null, surface.options.fastParse)) {

if (!surface.monoGeodataView) {
surface.monoGeodataView = new MapGeodataView(this.map, surface.monoGeodata, {tile:null, surface:surface});
Expand Down
31 changes: 28 additions & 3 deletions src/core/map/geodata-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import MapGeodataGeometry_ from './geodata-geometry';
import MapGeodataImportGeoJSON_ from './geodata-import/geojson';
import MapGeodataImportVTSGeodata_ from './geodata-import/vts-geodata';
import MapGeodataImport3DTiles_ from './geodata-import/3dtiles';
//import MapGeodataImport3DTiles_ from './geodata-import/3dtiles';
//import GeographicLib_ from 'geographiclib';
import {vec3 as vec3_, mat4 as mat4_,} from '../utils/matrix';

Expand All @@ -12,7 +12,7 @@ import {vec3 as vec3_, mat4 as mat4_,} from '../utils/matrix';
var MapGeodataGeometry = MapGeodataGeometry_;
var MapGeodataImportGeoJSON = MapGeodataImportGeoJSON_;
var MapGeodataImportVTSGeodata = MapGeodataImportVTSGeodata_;
var MapGeodataImport3DTiles = MapGeodataImport3DTiles_;
//var MapGeodataImport3DTiles = MapGeodataImport3DTiles_;

//var GeographicLib = GeographicLib_;
var vec3 = vec3_;
Expand Down Expand Up @@ -138,6 +138,17 @@ MapGeodataBuilder.prototype.addMesh = function(node, path) {
};


MapGeodataBuilder.prototype.addLoadNode = function(node, path) {
if (node) {
if (!node.loadNodes) {
node.loadNodes = [];
}

node.loadNodes.push(path);
}
};


MapGeodataBuilder.prototype.addPoint = function(point, heightMode, properties, id, srs, directCopy) {
if (!this.currentGroup) {
this.addGroup('some-group');
Expand Down Expand Up @@ -1426,7 +1437,7 @@ MapGeodataBuilder.prototype.addPolygonRAW = function(vertices, surface, borders,
featureVertices[j++] = [vertices[i], vertices[i+1], vertices[i+2]];
}
} else {
featureVertices[j++] = this.physSrs.convertCoordsFrom(coords, srs);
featureVertices[j++] = this.physSrs.convertCoordsFrom([vertices[i], vertices[i+1], vertices[i+2]], srs);
}
}
}
Expand Down Expand Up @@ -1464,11 +1475,21 @@ MapGeodataBuilder.prototype.import3DTiles = function(json, options) {
return importer.processJSON(json);
};


MapGeodataBuilder.prototype.load3DTiles = function(path, options, onLoaded) {
var importer = new MapGeodataImport3DTiles(this, options);
importer.loadJSON(path, options, onLoaded);
};


MapGeodataBuilder.prototype.load3DTiles2 = function(path, options, onLoaded) {
this.binPath = path;
if (onMapLoaded) {
onMapLoaded();
}
};


MapGeodataBuilder.prototype.processHeights = function(heightsSource, precision, onProcessed) {
if (this.heightsToProcess <= 0) {
if (onProcessed) {
Expand Down Expand Up @@ -1916,6 +1937,10 @@ MapGeodataBuilder.prototype.makeGeodata = function(resolution) {
"version" : 1,
"groups" : [],
}

if (this.binPath) {
geodata["binPath"] = this.binPath;
}

for (var i = 0, li = this.groups.length; i < li; i++) {
geodata["groups"].push(this.compileGroup(this.groups[i], resolution));
Expand Down
9 changes: 7 additions & 2 deletions src/core/map/geodata-import/3dtiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ var MapGeodataImport3DTiles = function(builder, options) {
this.srs = this.navSrs;
this.rootPath = '';
this.filesToLoad = 0;
options = options || {};
//this.options = options || {};
};


MapGeodataImport3DTiles.prototype.processNode = function(builderNode, node, onlyChildren) {
var boundingVolume = node['boundingVolume'], volume;

Expand Down Expand Up @@ -86,7 +87,11 @@ MapGeodataImport3DTiles.prototype.processNode = function(builderNode, node, only
path = utilsUrl.getProcessUrl(path, this.rootPath);

if (path.indexOf('.json') != -1) {
this.loadJSON(path, { internal: true, node: builderNode } );
if (this.baseOptions.gradualJSONLoader) {
this.builder.addLoadNode(builderNode, path);
} else {
this.loadJSON(path, { internal: true, node: builderNode } );
}
}

else if (path.indexOf('.mesh') != -1) {
Expand Down
Loading

0 comments on commit bd0915d

Please sign in to comment.