Skip to content

Commit

Permalink
Merge pull request #40 from DavidLevinsky/master
Browse files Browse the repository at this point in the history
Fixed streets names orientation
  • Loading branch information
davidmtech authored May 5, 2017
2 parents 6fb3cd5 + eef90df commit ccb049a
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 17 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.0",
"version": "2.2.1",
"description": "JavaScript WebGL 3D maps rendering engine",
"main": "src/browser/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {getCoreVersion as getCoreVersion_, checkSupport as checkSupport_} from '
import {vec2 as vec2_, vec3 as vec3_, vec4 as vec4_, mat3 as mat3_, mat4 as mat4_} from '../core/utils/matrix';
import {utils as utils_} from '../core/utils/utils';
import {math as math_} from '../core/utils/math';
import {platform as platform_} from '../core/utils/platform';
import BrowserInterface_ from './interface';

//get rid of compiler mess
Expand All @@ -13,6 +14,7 @@ var utils = utils_;
var math = math_;
var BrowserInterface = BrowserInterface_;
var proj4 = Proj4;
var platform = platform_;

function browser (element, config) {
var browserInterface = new BrowserInterface(element, config);
Expand All @@ -24,4 +26,4 @@ function getBrowserVersion() {
return '' + getCoreVersion();
}

export {vec2,vec3,vec4,mat3,mat4,math,utils,getCoreVersion,checkSupport,browser,getBrowserVersion,proj4};
export {vec2,vec3,vec4,mat3,mat4,math,utils,getCoreVersion,checkSupport,browser,getBrowserVersion,proj4,platform};
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.0';
return (full ? 'Core: ' : '') + '2.2.1';
}


Expand Down
4 changes: 3 additions & 1 deletion src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {CoreInterface as CoreInterface_} from './interface';
import {vec2 as vec2_, vec3 as vec3_, vec4 as vec4_, mat3 as mat3_, mat4 as mat4_} from './utils/matrix';
import {utils as utils_} from './utils/utils';
import {math as math_} from './utils/math';
import {platform as platform_} from './utils/platform';

//get rid of compiler mess
var getCoreVersion = getCoreVersion_, checkSupport = checkSupport_;
Expand All @@ -12,6 +13,7 @@ var vec2 = vec2_, vec3 = vec3_, vec4 = vec4_, mat3 = mat3_, mat4 = mat4_;
var utils = utils_;
var math = math_;
var proj4 = Proj4;
var platform = platform_;


function core(element, config) {
Expand All @@ -25,5 +27,5 @@ function core(element, config) {
}


export {vec2,vec3,vec4,mat3,mat4,math,utils,getCoreVersion,checkSupport,core,proj4};
export {vec2,vec3,vec4,mat3,mat4,math,utils,getCoreVersion,checkSupport,core,proj4,platform};

2 changes: 1 addition & 1 deletion src/core/inspector/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ InspectorInput.prototype.onKeyUp = function(event, press) {

case 88:
case 120:
debug.config.mapFog = !debug.config.mapFog; hit = true; break; //key X pressed
debug.drawFog = !debug.drawFog; hit = true; break; //key X pressed

case 82:
case 114:
Expand Down
6 changes: 3 additions & 3 deletions src/core/map/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) {
for (i = 0, li = tiles.length; i < li; i++) {
if (!tiles[i][1]) { //skip grids
tile = tiles[i][0];
if ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod)) {
if (tile && ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod))) {
drawTiles.drawSurfaceTile(tile, tile.metanode, cameraPos, tile.pixelSize, tile.priority, false, false);
}
}
Expand All @@ -247,7 +247,7 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) {
for (i = 0, li = tiles.length; i < li; i++) {
if (!tiles[i][1]) { //skip grids
tile = tiles[i][0];
if ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod)) {
if (tile && ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod))) {
drawTiles.drawSurfaceTile(tile, tile.metanode, cameraPos, tile.pixelSize, tile.priority, false, false);
}
}
Expand All @@ -260,7 +260,7 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) {
debug.drawBBoxes = true;
for (i = 0, li = tiles.length; i < li; i++) {
tile = tiles[i];
if ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod)) {
if (tile && ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod))) {
drawTiles.drawTileInfo(tile, tile.metanode, cameraPos, tile.surfaceMesh, tile.pixelSize);
}
}
Expand Down
17 changes: 10 additions & 7 deletions src/core/map/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,11 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp
if (clampTilt) { //used for street labels
orientation[1] = math.clamp(orientation[1], -89.0, 90.0);
}


var roty = math.clamp(orientation[1], -89.5, 89.5);

var tmpMatrix = mat4.create();
mat4.multiply(math.rotationMatrix(2, math.radians(-orientation[0])), math.rotationMatrix(0, math.radians(orientation[1])), tmpMatrix);
mat4.multiply(math.rotationMatrix(2, math.radians(-orientation[0])), math.rotationMatrix(0, math.radians(roty)), tmpMatrix);
var orbitPos, ned, north, east, direction, spaceMatrix, rotationMatrix;
var east2, north2, direction2, dir, up, right;

Expand All @@ -730,7 +732,7 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp
if (projected) {

tmpMatrix = mat4.create();
mat4.multiply(math.rotationMatrix(0, math.radians(-orientation[1] - 90.0)), math.rotationMatrix(2, math.radians(orientation[0])), tmpMatrix);
mat4.multiply(math.rotationMatrix(0, math.radians(-roty - 90.0)), math.rotationMatrix(2, math.radians(orientation[0])), tmpMatrix);

ned = this.getNED(coords);
north = ned.north;
Expand Down Expand Up @@ -820,7 +822,7 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp
//spaceMatrix = mat4.inverse(spaceMatrix);

var localRotMatrix = mat4.create();
mat4.multiply(math.rotationMatrix(0, math.radians(-orientation[1] - 90.0)), math.rotationMatrix(2, math.radians(orientation[0])), localRotMatrix);
mat4.multiply(math.rotationMatrix(0, math.radians(-roty - 90.0)), math.rotationMatrix(2, math.radians(orientation[0])), localRotMatrix);

east2 = [1,0,0];
direction2 = [0,1,0];
Expand Down Expand Up @@ -892,13 +894,14 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp
spaceMatrix = mat4.inverse(spaceMatrix);
mat4.multiplyVec3(spaceMatrix, orbitPos);

ret.vector2 = [-spaceMatrix[8], -spaceMatrix[9], -spaceMatrix[10]]; //vector2 is probably hack for tree.js bboxVisible
//ret.vector2 = [-spaceMatrix[8], -spaceMatrix[9], -spaceMatrix[10]]; //vector2 is probably hack for tree.js bboxVisible
ret.vector = [-rotationMatrix[2], -rotationMatrix[6], -rotationMatrix[10]];

//var ray = this.map.renderer.getScreenRay(800,400);

//get camera direction
mat4.inverse(rotationMatrix, spaceMatrix);
ret.vector = [-spaceMatrix[8], -spaceMatrix[9], -spaceMatrix[10]];
//mat4.inverse(rotationMatrix, spaceMatrix);
//ret.vector = [-spaceMatrix[8], -spaceMatrix[9], -spaceMatrix[10]];

//console.log("cam vec: " + JSON.stringify(this.cameraVector));

Expand Down
23 changes: 23 additions & 0 deletions src/core/map/metanode.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ MapMetanode.prototype.generateCullingHelpers = function(virtual) {
bbox[18] = maxX; bbox[19] = maxY; bbox[20] = maxZ;
bbox[21] = minX; bbox[22] = maxY; bbox[23] = maxZ;
} else {

normalize = vec3.normalize3;
dot = vec3.dot2;

Expand All @@ -505,6 +506,28 @@ MapMetanode.prototype.generateCullingHelpers = function(virtual) {

maxDelta = Math.min(d1, d2, d3, d4);

if (this.id[0] <= 8) { //extend bbox because of lon curvature
pos = this.diskPos;

var expand = 0.12 / (9-4) * (5-(this.id[0]-4));

bbox[0] += (bbox[0] - pos[0]) * expand;
bbox[1] += (bbox[1] - pos[1]) * expand;
bbox[2] += (bbox[2] - pos[2]) * expand;

bbox[3] += (bbox[3] - pos[0]) * expand;
bbox[4] += (bbox[4] - pos[1]) * expand;
bbox[5] += (bbox[5] - pos[2]) * expand;

bbox[6] += (bbox[6] - pos[0]) * expand;
bbox[7] += (bbox[7] - pos[1]) * expand;
bbox[8] += (bbox[8] - pos[2]) * expand;

bbox[9] += (bbox[9] - pos[0]) * expand;
bbox[10] += (bbox[10] - pos[1]) * expand;
bbox[11] += (bbox[11] - pos[2]) * expand;
}

//extend bbox height by tile curvature
height += draw.planetRadius - (draw.planetRadius * maxDelta);

Expand Down
4 changes: 2 additions & 2 deletions src/core/map/surface-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ MapSurfaceTree.prototype.drawSurface = function() {


if (replay.storeTiles || replay.storeFreeTiles) { //used only in inspectors
if (!this.map.tileBuffer[0]) {
this.map.tileBuffer[0] = [];
if (!draw.tileBuffer[0]) {
draw.tileBuffer[0] = [];
}

var tiles = draw.tileBuffer[0];
Expand Down

0 comments on commit ccb049a

Please sign in to comment.