From 372cac7885b361056b5e1d55f7e3da2b4ed0d528 Mon Sep 17 00:00:00 2001 From: David Levinsky Date: Mon, 1 May 2017 17:28:10 +0200 Subject: [PATCH] code passes eslint --- src/browser/autopilot/autopilot.js | 7 +- src/browser/browser.js | 8 +- src/browser/control-mode/map-observer.js | 61 +- src/browser/control-mode/pano.js | 8 +- src/browser/presenter/presenter.js | 15 +- src/browser/rois/rois.js | 2 +- src/browser/ui/control/credits.js | 21 +- src/browser/ui/control/fullscreen.js | 2 +- src/browser/ui/control/link.js | 2 +- src/browser/ui/control/loading.js | 5 +- src/browser/ui/control/map.js | 2 +- src/browser/ui/control/search.js | 35 +- src/browser/ui/element/element.js | 41 +- src/browser/ui/element/event.js | 15 +- src/core/core.js | 23 +- src/core/inspector/graphs.js | 170 ++-- src/core/inspector/input.js | 13 +- src/core/inspector/inspector.js | 55 +- src/core/inspector/layers.js | 155 ++-- src/core/inspector/replay.js | 744 +++++++++--------- src/core/interface.js | 4 +- src/core/map/bound-layer.js | 13 +- src/core/map/cache.js | 4 +- src/core/map/camera.js | 3 - src/core/map/config.js | 2 - src/core/map/convert.js | 33 +- src/core/map/draw-tiles.js | 136 ++-- src/core/map/draw.js | 101 ++- src/core/map/geodata-processor/processor.js | 5 +- .../map/geodata-processor/worker-style.js | 4 +- src/core/map/geodata-view.js | 2 +- src/core/map/geodata.js | 2 +- src/core/map/interface.js | 2 +- src/core/map/loader.js | 15 +- src/core/map/map.js | 73 +- src/core/map/measure.js | 147 ++-- src/core/map/metanode.js | 90 ++- src/core/map/metatile.js | 2 +- src/core/map/position.js | 6 +- src/core/map/render-slots.js | 2 +- src/core/map/resource-node.js | 13 +- src/core/map/resource-tree.js | 2 +- src/core/map/srs.js | 4 +- src/core/map/stylesheet.js | 2 +- src/core/map/submesh.js | 69 +- src/core/map/subtexture.js | 22 +- src/core/map/surface-sequence.js | 63 +- src/core/map/surface-tile.js | 114 ++- src/core/map/surface-tree.js | 118 ++- src/core/map/surface.js | 19 +- src/core/map/texture.js | 16 +- src/core/map/trajectory.js | 12 +- src/core/map/url.js | 30 +- src/core/map/virtual-surface.js | 4 +- src/core/renderer/camera.js | 49 +- src/core/renderer/draw.js | 71 +- src/core/renderer/geometry.js | 2 - src/core/renderer/gpu/bbox.js | 6 +- src/core/renderer/gpu/device.js | 35 +- src/core/renderer/gpu/font.js | 13 +- src/core/renderer/gpu/group.js | 12 +- src/core/renderer/gpu/mesh.js | 6 - src/core/renderer/gpu/pixel-line3.js | 16 +- src/core/renderer/gpu/texture.js | 2 - src/core/renderer/init.js | 52 +- src/core/renderer/interface.js | 19 +- src/core/renderer/renderer.js | 27 +- src/core/utils/matrix.js | 8 +- src/core/utils/utils.js | 3 +- 69 files changed, 1392 insertions(+), 1447 deletions(-) diff --git a/src/browser/autopilot/autopilot.js b/src/browser/autopilot/autopilot.js index cc3716ba..30f4744d 100755 --- a/src/browser/autopilot/autopilot.js +++ b/src/browser/autopilot/autopilot.js @@ -70,7 +70,6 @@ Autopilot.prototype.flyTo = function(position, options) { Autopilot.prototype.flyTrajectory = function(trajectory, sampleDuration) { - var options = {}; this.setTrajectory(trajectory, sampleDuration || 10, {}); }; @@ -115,12 +114,12 @@ Autopilot.prototype.tick = function() { return; } - var time = performance.now(); + var time = performance.now(), pos; var timeFactor = (time - this.lastTime) / 1000; this.lastTime = time; if (this.autoRotate != 0) { - var pos = map.getPosition(); + pos = map.getPosition(); var o = pos.getOrientation(); o[0] = (o[0] + this.autoRotate*timeFactor) % 360; pos.setOrientation(o); @@ -128,7 +127,7 @@ Autopilot.prototype.tick = function() { } if (this.autoPan != 0) { - var pos = map.getPosition(); + pos = map.getPosition(); pos = map.movePositionCoordsTo(pos, this.autoPanAzimuth, map.getPositionViewExtent(pos)*(this.autoPan*0.01)*timeFactor, 0); map.setPosition(pos); } diff --git a/src/browser/browser.js b/src/browser/browser.js index 84ed001c..74599b3c 100755 --- a/src/browser/browser.js +++ b/src/browser/browser.js @@ -1,5 +1,5 @@ -import {Core as Core_, getCoreVersion as getCoreVersion_, checkSupport as checkSupport_} from '../core/core'; +import {checkSupport as checkSupport_} from '../core/core'; import {CoreInterface as CoreInterface_} from '../core/interface'; import {utils as utils_} from '../core/utils/utils'; import UI_ from './ui/ui'; @@ -16,7 +16,7 @@ var Autopilot = Autopilot_; var ControlMode = ControlMode_; var Presenter = Presenter_; var Rois = Rois_; -var Core = Core_, getCoreVersion = getCoreVersion_, checkSupport = checkSupport_; +var checkSupport = checkSupport_; var Browser = function(element, config) { @@ -251,7 +251,7 @@ Browser.prototype.onTick = function() { }; -Browser.prototype.initConfig = function(data) { +Browser.prototype.initConfig = function() { this.config = { panAllowed : true, rotationAllowed : true, @@ -287,7 +287,7 @@ Browser.prototype.initConfig = function(data) { Browser.prototype.setConfigParams = function(params, ignoreCore) { if (typeof params === 'object' && params !== null) { for (var key in params) { - this.setConfigParam(key, params[key]); + this.setConfigParam(key, params[key], ignoreCore); /*if (!(key == "pos" || key == "position" || key == "view" || key.indexOf("map") == 0 || key.indexOf("renderer") == 0)) { diff --git a/src/browser/control-mode/map-observer.js b/src/browser/control-mode/map-observer.js index 880a11d7..bcbaf123 100755 --- a/src/browser/control-mode/map-observer.js +++ b/src/browser/control-mode/map-observer.js @@ -37,9 +37,10 @@ ControlModeMapObserver.prototype.drag = function(event) { var pos = map.getPosition(); var coords = pos.getCoords(); var delta = event.getDragDelta(); - var zoom = event.getDragZoom(); + //var zoom = event.getDragZoom(); var touches = event.getDragTouches(); var azimuthDistance = this.getAzimuthAndDistance(delta[0], delta[1]); + var sensitivity; var modifierKey = (this.browser.controlMode.altKey || this.browser.controlMode.shiftKey @@ -54,8 +55,8 @@ ControlModeMapObserver.prototype.drag = function(event) { } if (event.getTouchParameter('touchMode') == 'pan' && this.config.rotationAllowed) { - var pan = event.getTouchParameter('touchPanDelta'); - var sensitivity = this.config.sensitivity[1] * this.retinaFactor; + //var pan = event.getTouchParameter('touchPanDelta'); + sensitivity = this.config.sensitivity[1] * this.retinaFactor; this.orientationDeltas.push([delta[0] * sensitivity, -delta[1] * sensitivity, 0]); this.browser.callListener('map-position-rotated', {}); @@ -76,7 +77,7 @@ ControlModeMapObserver.prototype.drag = function(event) { this.setPosition(pos); } } else { - var sensitivity = this.config.sensitivity[0] * this.retinaFactor; + sensitivity = this.config.sensitivity[0] * this.retinaFactor; var fov = pos.getFov(); var fovCorrection = (fov > 0.01 && fov < 179) ? (1.0 / Math.tan(math.radians(fov*0.5))) : 1.0; var azimuth = math.radians(azimuthDistance[0]); @@ -92,7 +93,7 @@ ControlModeMapObserver.prototype.drag = function(event) { } else if (((touches <= 1 && event.getDragButton('right')) || event.getDragButton('middle') || modifierKey) && this.config.rotationAllowed) { //rotate - var sensitivity = this.config.sensitivity[1] * this.retinaFactor; + sensitivity = this.config.sensitivity[1] * this.retinaFactor; this.orientationDeltas.push([delta[0] * sensitivity, -delta[1] * sensitivity, 0]); this.browser.callListener('map-position-rotated', {}); @@ -164,15 +165,15 @@ ControlModeMapObserver.prototype.doubleclick = function(event) { }; -ControlModeMapObserver.prototype.keyup = function(event) { +ControlModeMapObserver.prototype.keyup = function() { }; -ControlModeMapObserver.prototype.keydown = function(event) { +ControlModeMapObserver.prototype.keydown = function() { }; -ControlModeMapObserver.prototype.keypress = function(event) { +ControlModeMapObserver.prototype.keypress = function() { }; @@ -231,31 +232,31 @@ ControlModeMapObserver.prototype.getAzimuthAndDistance = function(dx, dy) { }; -ControlModeMapObserver.prototype.tick = function(event) { +ControlModeMapObserver.prototype.tick = function() { var map = this.browser.getMap(); if (map == null) { return; } - var pos = map.getPosition(); - var update = false; + var pos = map.getPosition(), delta, deltas; + var update = false, azimuth, correction, i; var inertia = this.config.inertia; //[0.83, 0.9, 0.7]; //var inertia = [0.95, 0.8, 0.8]; //var inertia = [0, 0, 0]; //process coords deltas if (this.coordsDeltas.length > 0) { - var deltas = this.coordsDeltas; + deltas = this.coordsDeltas; var forward = [0,0]; var coords = pos.getCoords(); //get foward vector form coord deltas - for (var i = 0; i < deltas.length; i++) { - var delta = deltas[i]; + for (i = 0; i < deltas.length; i++) { + delta = deltas[i]; - var coords2 = [delta[4], delta[5]]; + //var coords2 = [delta[4], delta[5]]; - var azimuth = delta[3]; + azimuth = delta[3]; azimuth += 0;//map.getAzimuthCorrection(coords2, coords); azimuth = math.radians(azimuth); @@ -277,18 +278,18 @@ ControlModeMapObserver.prototype.tick = function(event) { } var distance = Math.sqrt(forward[0]*forward[0] + forward[1]*forward[1]); - var azimuth = math.degrees(Math.atan2(forward[0], forward[1])); + azimuth = math.degrees(Math.atan2(forward[0], forward[1])); //console.log("tick: " + azimuth + " " + distance); //apply final azimuth and distance if (this.config.navigationMode == 'free') { - var correction = pos.getOrientation()[0]; + correction = pos.getOrientation()[0]; pos = map.movePositionCoordsTo(pos, (this.isNavigationSRSProjected() ? -1 : 1) * azimuth, distance); correction = pos.getOrientation()[0] - correction; } else { // "azimuthal" - var correction = pos.getOrientation()[0]; + correction = pos.getOrientation()[0]; //pos = map.movePositionCoordsTo(pos, (this.isNavigationSRSProjected() ? -1 : 1) * azimuth, distance, true); @@ -341,8 +342,8 @@ ControlModeMapObserver.prototype.tick = function(event) { //console.log("correction2: " + correction); - for (var i = 0; i < deltas.length; i++) { - var delta = deltas[i]; + for (i = 0; i < deltas.length; i++) { + delta = deltas[i]; delta[3] += correction; } @@ -351,12 +352,12 @@ ControlModeMapObserver.prototype.tick = function(event) { //process coords deltas if (this.orientationDeltas.length > 0) { - var deltas = this.orientationDeltas; + deltas = this.orientationDeltas; var orientation = pos.getOrientation(); //apply detals to current orientation - for (var i = 0; i < deltas.length; i++) { - var delta = deltas[i]; + for (i = 0; i < deltas.length; i++) { + delta = deltas[i]; orientation[0] += delta[0]; orientation[1] += delta[1]; orientation[2] += delta[2]; @@ -379,11 +380,11 @@ ControlModeMapObserver.prototype.tick = function(event) { //process view extents deltas if (this.viewExtentDeltas.length > 0) { - var deltas = this.viewExtentDeltas; + deltas = this.viewExtentDeltas; var viewExtent = pos.getViewExtent(); //apply detals to current view extent - for (var i = 0; i < deltas.length; i++) { + for (i = 0; i < deltas.length; i++) { viewExtent *= deltas[i]; deltas[i] += (1 - deltas[i]) * (1.0 - inertia[2]); @@ -408,7 +409,7 @@ ControlModeMapObserver.prototype.tick = function(event) { }; -ControlModeMapObserver.prototype.reset = function(config) { +ControlModeMapObserver.prototype.reset = function() { this.coordsDeltas = []; this.orientationDeltas = []; this.viewExtentDeltas = []; @@ -423,7 +424,7 @@ function constrainMapPosition(browser, pos) { var minVE = browser.config.minViewExtent; var maxVE = browser.config.maxViewExtent; - var map = browser.getMap(); + var map = browser.getMap(), o; //clamp view extets var viewExtent = math.clamp(pos.getViewExtent(), minVE, maxVE); @@ -442,7 +443,7 @@ function constrainMapPosition(browser, pos) { var maxTilt = 20 + ((-90) - 20) * factor; var minTilt = -90; - var o = pos.getOrientation(); + o = pos.getOrientation(); if (o[1] > maxTilt) { o[1] = maxTilt; @@ -468,7 +469,7 @@ function constrainMapPosition(browser, pos) { var cameraHeight = camPos[2]; //this.cameraHeight() - this.cameraHeightOffset - this.cameraHeightOffset2; if (cameraHeight < hmax) { - var o = pos.getOrientation(); + o = pos.getOrientation(); var getFinalOrientation = (function(start, end, level) { var value = (start + end) * 0.5; diff --git a/src/browser/control-mode/pano.js b/src/browser/control-mode/pano.js index 23b955ae..81798870 100755 --- a/src/browser/control-mode/pano.js +++ b/src/browser/control-mode/pano.js @@ -75,19 +75,19 @@ ControlModePano.prototype.wheel = function(event) { }; -ControlModePano.prototype.keyup = function(event) { +ControlModePano.prototype.keyup = function() { }; -ControlModePano.prototype.keydown = function(event) { +ControlModePano.prototype.keydown = function() { }; -ControlModePano.prototype.keypress = function(event) { +ControlModePano.prototype.keypress = function() { }; -ControlModePano.prototype.tick = function(event) { +ControlModePano.prototype.tick = function() { if (this.velocity[0] == 0.0 && this.velocity[1] == 0.0) { return; } diff --git a/src/browser/presenter/presenter.js b/src/browser/presenter/presenter.js index 6129707b..172e47f0 100644 --- a/src/browser/presenter/presenter.js +++ b/src/browser/presenter/presenter.js @@ -183,8 +183,8 @@ Presenter.prototype.readTextInput = function(id) { path = path + loc[i] + '/'; } path = path + this.htmlDataStorage.split(split)[1]; - console.log('Final path:'); - console.log(path); + //console.log('Final path:'); + //console.log(path); this.htmlDataStorage = path; return 'url'; } else if (hash.test(this.htmlDataStorage)) { @@ -278,7 +278,7 @@ Presenter.prototype.linksDecode = function(obj) { // parseFloat here Presenter.prototype.getNumbers = function(obj) { - var obj = obj; + //var obj = obj; for (var i = 0; i < obj.length; i++){ if (typeof obj == 'string' && parseFloat(obj)) { obj = parseFloat(obj); @@ -333,9 +333,10 @@ Presenter.prototype.useToolbox = function() { } var rightPanel = this.container.getElementsByClassName('vts-presenter panelContainer')[0]; - var toolboxContainer = this.container.getElementsByClassName('vts-presenter toolboxContainer')[0]; + //var toolboxContainer = this.container.getElementsByClassName('vts-presenter toolboxContainer')[0]; var subtitles = this.container.getElementsByClassName('vts-presenter subtitlesContainer')[0]; var swipeControl = this.container.getElementsByClassName('vts-presenter swipeControl'); + var i; this.currentToolbox = type; subtitles.setAttribute('style', 'opacity: 0;'); @@ -347,7 +348,7 @@ Presenter.prototype.useToolbox = function() { }, 20); swipeControl[0].style.display = 'block'; swipeControl[1].style.display = 'block'; - for (var i = 0; i < this.sectionTags.length; i++) { // Set maxHeight back as there is no dynamic rescaling of rightPanel + for (i = 0; i < this.sectionTags.length; i++) { // Set maxHeight back as there is no dynamic rescaling of rightPanel this.sectionTags[i].style.height = this.maxHeight + 'px'; } this.nextArticle(0); @@ -360,7 +361,7 @@ Presenter.prototype.useToolbox = function() { rightPanel.style.opacity = 0; swipeControl[0].style.display = 'none'; swipeControl[1].style.display = 'none'; - for (var i = 0; i < this.sectionTags.length; i++) { // Set height to auto so we can dynamicaly adjust subtitles height + for (i = 0; i < this.sectionTags.length; i++) { // Set height to auto so we can dynamicaly adjust subtitles height this.sectionTags[i].style.height = 'auto'; } this.handleSubtitlesPosition(0, true); @@ -427,7 +428,7 @@ Presenter.prototype.getElementsTrueHeight = function(elems) { } } - for (var i = 0; i < elems.length; i++) { + for (i = 0; i < elems.length; i++) { elems[i].style.height = this.maxHeight + 'px'; } }; diff --git a/src/browser/rois/rois.js b/src/browser/rois/rois.js index 22fa2d80..092895fa 100755 --- a/src/browser/rois/rois.js +++ b/src/browser/rois/rois.js @@ -18,7 +18,7 @@ var Rois = function(roiServers) { * @param clb callback * @return Response promise object (if ES6 is supported otherwise null) */ -Rois.prototype.roisAtPosition = function(position, count, clb) { +Rois.prototype.roisAtPosition = function(/*position, count, clb*/) { // TODO request ROI server // ROI gravity must be defined before implementation }; diff --git a/src/browser/ui/control/credits.js b/src/browser/ui/control/credits.js index 41c4d0d2..3b3f79ce 100755 --- a/src/browser/ui/control/credits.js +++ b/src/browser/ui/control/credits.js @@ -17,14 +17,15 @@ var UIControlCredits = function(ui, visible) { UIControlCredits.prototype.getCreditsString = function(array, separator, full) { var map = this.browser.getMap(); var html = ''; - var copyright = '©' + (new Date().getFullYear()); + //var copyright = '©' + (new Date().getFullYear()); var li = array.length; var plain = ''; var more = false; + var creditInfo; for (var i = 0; i < li; i++) { - var creditInfo = map.getCreditInfo(array[i]); + creditInfo = map.getCreditInfo(array[i]); if (creditInfo['plain']) { plain += creditInfo['plain']; } @@ -35,8 +36,8 @@ UIControlCredits.prototype.getCreditsString = function(array, separator, full) { more = true; } - for (var i = 0; i < li; i++) { - var creditInfo = map.getCreditInfo(array[i]); + for (i = 0; i < li; i++) { + creditInfo = map.getCreditInfo(array[i]); if (creditInfo['html']) { html += creditInfo['html']; @@ -57,30 +58,28 @@ UIControlCredits.prototype.update = function() { return; } - var html = ''; - var html2 = ''; - var html3 = ''; + var html = '', html2 = '', html3 = '', res; var credits = map.getCurrentCredits(); if (credits['imagery'].length > 0) { - var res = this.getCreditsString(credits['imagery'], ', '); + res = this.getCreditsString(credits['imagery'], ', '); html += '
'; html += '
Imagery: ' + res[0] + '
'; html += res[1] ? '
and others
' : ''; html += '
'; html += '
'; - var html2 = '
'; + html2 = '
'; html2 += this.getCreditsString(credits['imagery'], '
', true)[0] + '
'; } if (credits['mapdata'].length > 0) { - var res = this.getCreditsString(credits['mapdata'], ', '); + res = this.getCreditsString(credits['mapdata'], ', '); html += '
'; html += '
Map Data: ' + res[0] + '
'; html += res[1] ? '
and others
' : ''; html += '
'; html += '
'; - var html3 = '
'; + html3 = '
'; html3 += this.getCreditsString(credits['mapdata'], '
', true)[0] + '
'; } diff --git a/src/browser/ui/control/fullscreen.js b/src/browser/ui/control/fullscreen.js index 4e17857e..56fa4caf 100755 --- a/src/browser/ui/control/fullscreen.js +++ b/src/browser/ui/control/fullscreen.js @@ -54,7 +54,7 @@ UIControlFullscreen.prototype.fullscreenEnabled = function() { }; -UIControlFullscreen.prototype.onClick = function(event) { +UIControlFullscreen.prototype.onClick = function() { var element = this.ui.element; if (!this.enabled) { diff --git a/src/browser/ui/control/link.js b/src/browser/ui/control/link.js index b8080ae4..694978e3 100755 --- a/src/browser/ui/control/link.js +++ b/src/browser/ui/control/link.js @@ -50,7 +50,7 @@ UIControlLink.prototype.onSwitch = function() { UIControlLink.prototype.update = function() { - var button = this.control.getElement('vts-link-button'); + //var button = this.control.getElement('vts-link-button'); var left = 10 + (this.ui.config.controlZoom ? 70 : 0) + (this.ui.config.controlSpace ? 35 : 0); diff --git a/src/browser/ui/control/loading.js b/src/browser/ui/control/loading.js index 499aa5b5..6f9c1951 100755 --- a/src/browser/ui/control/loading.js +++ b/src/browser/ui/control/loading.js @@ -76,9 +76,10 @@ UIControlLoading.prototype.hide = function() { UIControlLoading.prototype.update = function() { var timer = Date.now(); + var timeDelta; if (this.hiding) { - var timeDelta = (timer - this.hiding) * 0.001; + timeDelta = (timer - this.hiding) * 0.001; this.loading.setStyle('opacity', (1-Math.min(1.0, timeDelta*2)) + '' ); if (timeDelta > 0.5) { @@ -87,7 +88,7 @@ UIControlLoading.prototype.update = function() { } - var timeDelta = (timer - this.time) * 0.001; + timeDelta = (timer - this.time) * 0.001; //sine wave /* diff --git a/src/browser/ui/control/map.js b/src/browser/ui/control/map.js index c4abe44a..ae0974c3 100755 --- a/src/browser/ui/control/map.js +++ b/src/browser/ui/control/map.js @@ -5,7 +5,7 @@ var UIControlMap = function(ui, visible) { this.control = this.ui.addControl('map', '
' - + '
'); + + '
', visible); var map = this.getMapElement(); map.setDraggableState(true); diff --git a/src/browser/ui/control/search.js b/src/browser/ui/control/search.js index 2745877c..ca587a95 100755 --- a/src/browser/ui/control/search.js +++ b/src/browser/ui/control/search.js @@ -68,12 +68,12 @@ UIControlSearch.prototype.processTemplate = function(str, obj) { }; -UIControlSearch.prototype.showList = function(event) { +UIControlSearch.prototype.showList = function() { this.list.setStyle('display', 'block'); }; -UIControlSearch.prototype.hideList = function(event) { +UIControlSearch.prototype.hideList = function() { //this.data = {}; this.list.setStyle('display', 'none'); }; @@ -97,13 +97,14 @@ UIControlSearch.prototype.moveSelector = function(delta) { UIControlSearch.prototype.updateList = function(json) { if (json['data']) { + var item; var list = ''; var data = json['data']; data = data.slice(0,10); - this.data = data; - + this.data = data; + for (var i = 0, li = data.length; i < li; i++) { - var item = data[i]; + item = data[i]; if (this.itemIndex == i) { list += '
' + item['title'] + ' ' + (item['region'] ? item['region'] : '') + '
'; @@ -115,9 +116,9 @@ UIControlSearch.prototype.updateList = function(json) { this.list.setHtml(list); - for (var i = 0, li = data.length; i < li; i++) { + for (i = 0, li = data.length; i < li; i++) { var id = 'vts-search-item' + i; - var item = this.control.getElement(id); + item = this.control.getElement(id); if (item) { item.on('click', this.onSelectItem.bind(this, i)); @@ -134,7 +135,7 @@ UIControlSearch.prototype.updateList = function(json) { }; -UIControlSearch.prototype.onSelectItem = function(index, event) { +UIControlSearch.prototype.onSelectItem = function(index) { var map = this.browser.getMap(); if (map == null) { return; @@ -185,7 +186,7 @@ UIControlSearch.prototype.onSelectItem = function(index, event) { }; -UIControlSearch.prototype.onHoverItem = function(index, event) { +UIControlSearch.prototype.onHoverItem = function(index) { if (this.itemIndex == index) { return; } @@ -202,11 +203,11 @@ UIControlSearch.prototype.onListLoaded = function(counter, data) { }; -UIControlSearch.prototype.onListLoadError = function(event) { +UIControlSearch.prototype.onListLoadError = function() { }; -UIControlSearch.prototype.onFocus = function(event) { +UIControlSearch.prototype.onFocus = function() { this.lastSearch = ''; var element = this.input.getElement(); element.value = this.lastSearch; @@ -215,7 +216,7 @@ UIControlSearch.prototype.onFocus = function(event) { UIControlSearch.prototype.onKeyPress = function(event) { - console.log('press'); + //console.log('press'); this.onKeyUp(event); }; @@ -246,7 +247,7 @@ UIControlSearch.prototype.onKeyUp = function(event) { }; -UIControlSearch.prototype.onChange = function(event) { +UIControlSearch.prototype.onChange = function() { var value = this.input.getElement().value; value = value.trim(); @@ -273,13 +274,13 @@ UIControlSearch.prototype.onChange = function(event) { }; -UIControlSearch.prototype.onDrag2 = function(event) { +UIControlSearch.prototype.onDrag2 = function() { this.ignoreDrag = true; - var element = this.input.getElement(); + //var element = this.input.getElement(); }; -UIControlSearch.prototype.onDrag = function(event) { +UIControlSearch.prototype.onDrag = function() { if (this.ignoreDrag) { this.ignoreDrag = false; return; @@ -292,7 +293,7 @@ UIControlSearch.prototype.onDrag = function(event) { }; -UIControlSearch.prototype.update = function(event) { +UIControlSearch.prototype.update = function() { if (this.initialValueUsed && this.browser.mapLoaded) { this.initialValueUsed = false; this.onSelectItem(0); diff --git a/src/browser/ui/element/element.js b/src/browser/ui/element/element.js index 5f245cb8..86dd81a3 100755 --- a/src/browser/ui/element/element.js +++ b/src/browser/ui/element/element.js @@ -256,7 +256,6 @@ UIElement.prototype.onDragBegin = function(event) { //} this.resetPos = true; - this.firstDragDistance = 0; this.lastDragDistance = 0; this.zoomDrag = false; @@ -286,8 +285,7 @@ UIElement.prototype.onDragBegin = function(event) { 'clientY' : pos[1] }); } else { - var pos = event.getMouseCoords(); - this.dragLastPos = pos; + this.dragLastPos = event.getMouseCoords(); } }; @@ -340,28 +338,31 @@ UIElement.prototype.onDragMove = function(event) { var v1y = (t[5][1] - t[4][1]) + (t[4][1] - t[3][1]) + (t[3][1] - t[2][1]) + (t[2][1] - t[1][1]) + (t[1][1] - t[0][1]); //get vector for touch #2 - t2 = this.dragTouches2; + var t2 = this.dragTouches2; var v2x = (t2[5][0] - t2[4][0]) + (t2[4][0] - t2[3][0]) + (t2[3][0] - t2[2][0]) + (t2[2][0] - t2[1][0]) + (t2[1][0] - t2[0][0]); var v2y = (t2[5][1] - t2[4][1]) + (t2[4][1] - t2[3][1]) + (t2[3][1] - t2[2][1]) + (t2[2][1] - t2[1][1]) + (t2[1][1] - t2[0][1]); //get distance of each vector var d1 = Math.sqrt(v1x * v1x + v1y * v1y); var d2 = Math.sqrt(v2x * v2x + v2y * v2y); + var cosAngle, cosAngle2; mode = 'pan'; if (d1 > d2 * 5 || d2 > d1 * 5) { //dectec situation where only one finger is closing to another + + var p1, p2, p3; //make first vector from non moving point to beginnig position of moving point //make seconf vector from non moving point to ending position of moving point if (d1 > d2 * 5) { - var p1 = t2[0]; - var p2 = t[0]; - var p3 = t[5]; + p1 = t2[0]; + p2 = t[0]; + p3 = t[5]; } else { - var p1 = t[0]; - var p2 = t2[0]; - var p3 = t2[5]; + p1 = t[0]; + p2 = t2[0]; + p3 = t2[5]; } var v1 = [p2[0] - p1[0], p2[1] - p1[1]]; @@ -377,8 +378,8 @@ UIElement.prototype.onDragMove = function(event) { v2[1] /= d; //measure angle between vectors - var cosAngle = v1[0] * v2[0] + v1[1] * v2[1]; - var cosAngle2 = -v1[1] * v2[0] + v1[0] * v2[1]; //v1 is rotated by 90deg + cosAngle = v1[0] * v2[0] + v1[1] * v2[1]; + cosAngle2 = -v1[1] * v2[0] + v1[0] * v2[1]; //v1 is rotated by 90deg rotateDelta = (Math.acos(cosAngle2) * (180.0/Math.PI)) - 90; @@ -398,7 +399,7 @@ UIElement.prototype.onDragMove = function(event) { var nv2y = v2y / d2; //do vectors move in same direction - var cosAngle = nv1x * nv2x + nv1y * nv2y; + cosAngle = nv1x * nv2x + nv1y * nv2y; if (cosAngle < 0.2) { mode = 'zoom'; @@ -408,18 +409,18 @@ UIElement.prototype.onDragMove = function(event) { } //if (mode == "zoom") { - var t = this.dragTouches; - var t2 = this.dragTouches2; + t = this.dragTouches; + t2 = this.dragTouches2; //get distance between points at the beginig var dx = (t2[0][0] - t[0][0]); var dy = (t2[0][1] - t[0][1]); - var d1 = Math.sqrt(dx * dx + dy * dy); + d1 = Math.sqrt(dx * dx + dy * dy); //get distance between points at the end - var dx = (t2[5][0] - t[5][0]); - var dy = (t2[5][1] - t[5][1]); - var d2 = Math.sqrt(dx * dx + dy * dy); + dx = (t2[5][0] - t[5][0]); + dy = (t2[5][1] - t[5][1]); + d2 = Math.sqrt(dx * dx + dy * dy); //get delta betwwen distances distanceDelta = d2 - d1; @@ -489,7 +490,7 @@ UIElement.prototype.onDragEnd = function(event) { !this.dragButtons['middle'] ) { this.dragging = false; - var pos = this.dragCurrentPos;//event.getMouseCoords(); + pos = this.dragCurrentPos;//event.getMouseCoords(); this.off('mousemove', this.dragMoveCall, document); this.off('mouseup', this.dragEndCall, document); //this.off("mouseup", this.onDragEnd.bind(this), document); diff --git a/src/browser/ui/element/event.js b/src/browser/ui/element/event.js index d9946bf3..6b1a559f 100755 --- a/src/browser/ui/element/event.js +++ b/src/browser/ui/element/event.js @@ -20,7 +20,9 @@ UIEvent.prototype.getMouseButton = function() { case 2: return 'right'; case 3: return 'middle'; } - } + } + + return ''; default: @@ -50,7 +52,7 @@ UIEvent.prototype.getMouseButton = function() { UIEvent.prototype.getMouseCoords = function(absolute) { - var event = null; + var pos = [0,0]; switch (this.type) { case 'touchstart': @@ -62,8 +64,6 @@ UIEvent.prototype.getMouseCoords = function(absolute) { break; } - var pos = [0,0]; - for (var i = 0, li = touches.length; i < li; i++) { var pos2 = this.getEventCoords(this.event['touches'][i], absolute); pos[0] += pos2[0]; @@ -72,7 +72,7 @@ UIEvent.prototype.getMouseCoords = function(absolute) { pos[0] /= li; pos[1] /= li; - return pos; + break; case 'mousedown': case 'mouseup': @@ -82,12 +82,11 @@ UIEvent.prototype.getMouseCoords = function(absolute) { case 'dragend': case 'drag': - return this.getEventCoords(this.event, absolute); + pos = this.getEventCoords(this.event, absolute); break; - } - return [0,0]; + return pos; }; diff --git a/src/core/core.js b/src/core/core.js index a9f68ff3..94ec429c 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -96,7 +96,7 @@ var Core = function(element, config, coreInterface) { window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || - function(callback, element) { + function(callback) { window.setTimeout(callback, 1000/60); }); @@ -132,7 +132,7 @@ Core.prototype.loadMap = function(path) { return; } - path = utilsUrl_.getProcessUrl(path, window.location.href); + path = utilsUrl.getProcessUrl(path, window.location.href); this.tokenCookieLoaded = true; this.mapConfigData = null; @@ -210,6 +210,7 @@ Core.prototype.loadMap = function(path) { }).bind(this); var onAutorizationError = (function() { + // eslint-disable-next-line console.log('auth token not loaded'); if (this.tokenCanBeSkiped) { @@ -217,16 +218,17 @@ Core.prototype.loadMap = function(path) { } }).bind(this); - var onImageCookieLoaded = (function(data) { + var onImageCookieLoaded = (function() { document.body.removeChild(this.tokenIFrame); this.tokenIFrame = null; this.tokenCookieLoaded = true; onLoaded(); }).bind(this); - var onImageCookieError = (function() { + /*var onImageCookieError = (function() { + // eslint-disable-next-line console.log('auth cookie not loaded'); - }).bind(this); + }).bind(this);*/ //var baseUrl = path.split('?')[0].split('/').slice(0, -1).join('/')+'/'; @@ -235,8 +237,8 @@ Core.prototype.loadMap = function(path) { }).bind(this); var onLoadImageCookie = (function(url, originUrl) { - url = utilsUrl_.getProcessUrl(url, originUrl); - this.tokenCookieHost = utilsUrl_.getHost(url); + url = utilsUrl.getProcessUrl(url, originUrl); + this.tokenCookieHost = utilsUrl.getHost(url); //utils.loadImage(url, onImageCookieLoaded, onImageCookieError); var iframe = document.createElement('iframe'); this.tokenIFrame = iframe; @@ -310,11 +312,11 @@ Core.prototype.getProj4 = function() { }; -Core.prototype.getOption = function(key, value) { +Core.prototype.getOption = function(/*key, value*/) { }; -Core.prototype.setOption = function(key, value) { +Core.prototype.setOption = function(/*key, value*/) { }; @@ -343,6 +345,7 @@ Core.prototype.callListener = function(name, event, log) { } if (log) { + // eslint-disable-next-line console.log('event ' + name + ': ' + JSON.stringify(event)); } }; @@ -380,7 +383,7 @@ Core.prototype.onUpdate = function() { }; -Core.prototype.setConfigParams = function(params, onlyMapRelated) { +Core.prototype.setConfigParams = function(params) { if (typeof params === 'object' && params !== null) { for (var key in params) { this.setConfigParam(key, params[key]); diff --git a/src/core/inspector/graphs.js b/src/core/inspector/graphs.js index 521065a4..721f7a41 100755 --- a/src/core/inspector/graphs.js +++ b/src/core/inspector/graphs.js @@ -287,15 +287,17 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { var totalTexture = 0; var totalMeshes = 0; var totalGpuMeshes = 0; - var realCount = 0; + var realCount = 0, i, j, lj; + var index, value, values, str, y, factorY, max, min; var valuesFrame = stats.graphsFrameTimes; var valuesRender = stats.graphsRenderTimes; var valuesTextures = stats.graphsCreateTextureTimes; var valuesMeshes = stats.graphsCreateMeshTimes; var valuesGpuMeshes = stats.graphsCreateGpuMeshTimes; + var valuesGeodata; - for (var i = 0; i < samples; i++) { + for (i = 0; i < samples; i++) { totalFrame += valuesFrame[i]; totalRender += valuesRender[i]; totalTexture += valuesTextures[i]; @@ -321,10 +323,10 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { maxValue = (totalFrame / realCount) * 0.5; } - var factorY = height / maxValue; + factorY = height / maxValue; - for (var i = 0; i < samples; i++) { - var index = samplesIndex + i; + for (i = 0; i < samples; i++) { + index = samplesIndex + i; index %= samples; ctx.fillStyle='#000000'; @@ -335,7 +337,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { ctx.fillStyle='#0000ff'; ctx.fillRect(i*factorX, height, 1, -(valuesTextures[index])*factorY); - var y = height -(valuesTextures[index])*factorY; + y = height -(valuesTextures[index])*factorY; ctx.fillStyle='#007700'; ctx.fillRect(i*factorX, y, 1, -(valuesMeshes[index])*factorY); @@ -349,38 +351,38 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { if (this.showCursor) { ctx.fillStyle='#aa00aa'; - var index = (this.cursorIndex) % samples; + index = (this.cursorIndex) % samples; ctx.fillRect(Math.floor(index*factorX)-1, 0, 1, height); ctx.fillRect(Math.floor(index*factorX)+1, 0, 1, height); index = (this.cursorIndex + samplesIndex) % samples; - var str = '◼ Frame: ' + valuesFrame[index].toFixed(2) + - '   Render: ' + valuesRender[index].toFixed(2) + - '   Textures: ' + valuesTextures[index].toFixed(2) + - '   Meshes: ' + valuesMeshes[index].toFixed(2) + - '   GpuMeshes: ' + valuesGpuMeshes[index].toFixed(2) + '
'; + str = '◼ Frame: ' + valuesFrame[index].toFixed(2) + + '   Render: ' + valuesRender[index].toFixed(2) + + '   Textures: ' + valuesTextures[index].toFixed(2) + + '   Meshes: ' + valuesMeshes[index].toFixed(2) + + '   GpuMeshes: ' + valuesGpuMeshes[index].toFixed(2) + ''; } else { - var str = '◼ Frame: ' + Math.round(totalFrame) + - '   Render: ' + Math.round(totalRender) + - '   Textures: ' + Math.round(totalTexture) + - '   Meshes: ' + Math.round(totalMeshes) + - '   GpuMeshes: ' + Math.round(totalGpuMeshes) +''; + str = '◼ Frame: ' + Math.round(totalFrame) + + '   Render: ' + Math.round(totalRender) + + '   Textures: ' + Math.round(totalTexture) + + '   Meshes: ' + Math.round(totalMeshes) + + '   GpuMeshes: ' + Math.round(totalGpuMeshes) +''; } document.getElementById('vts-graphs-info').innerHTML = str; - var width = this.canvasCache.width; - var height = this.canvasCache.height; - var ctx = this.canvasCacheCtx; + width = this.canvasCache.width; + height = this.canvasCache.height; + ctx = this.canvasCacheCtx; - var factorX = width / samples; + factorX = width / samples; ctx.clearRect(0, 0, width, height); switch (this.graph) { case 'Cache': { - var factorY = height / ((map.gpuCache.maxCost+map.resourcesCache.maxCost+map.metatileCache.maxCost)); + factorY = height / ((map.gpuCache.maxCost+map.resourcesCache.maxCost+map.metatileCache.maxCost)); var maxMetatiles = 0; var maxResources = 0; @@ -391,12 +393,12 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { var valuesMetatiles = stats.graphsCpuMemoryMetatiles; var valuesResources = stats.graphsCpuMemoryUsed; - var valuesTextures = stats.graphsGpuMemoryTextures; - var valuesMeshes = stats.graphsGpuMemoryMeshes; - var valuesGeodata = stats.graphsGpuMemoryGeodata; var valuesGpu = stats.graphsGpuMemoryRender; + valuesGeodata = stats.graphsGpuMemoryGeodata; + valuesTextures = stats.graphsGpuMemoryTextures; + valuesMeshes = stats.graphsGpuMemoryMeshes; - for (var i = 0; i < samples; i++) { + for (i = 0; i < samples; i++) { maxMetatiles = valuesMetatiles[i] > maxMetatiles ? valuesMetatiles[i] : maxMetatiles; maxResources = valuesResources[i] > maxResources ? valuesResources[i] : maxResources; maxTextures = valuesTextures[i] > maxTextures ? valuesTextures[i] : maxTextures; @@ -405,11 +407,11 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { maxGpu = valuesGpu[i] > maxGpu ? valuesGpu[i] : maxGpu; } - for (var i = 0; i < samples; i++) { - var index = samplesIndex + i; + for (i = 0; i < samples; i++) { + index = samplesIndex + i; index %= samples; - var value = valuesMetatiles[index] + valuesMeshes[index] + valuesTextures[index] + valuesGeodata[index] + valuesResources[index]; + value = valuesMetatiles[index] + valuesMeshes[index] + valuesTextures[index] + valuesGeodata[index] + valuesResources[index]; ctx.fillStyle='#000000'; ctx.fillRect(i*factorX, height, 1, -(value)*factorY); value -= valuesResources[index]; @@ -435,24 +437,24 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { } if (this.showCursor == true) { - var index = (this.cursorIndex + samplesIndex) % samples; - var str = ' Total: ' + Math.ceil((valuesMetatiles[index] + valuesResources[index] + valuesTextures[index] + valuesMeshes[index])/(1024*1024)) + 'MB' + - '   CPU: ' + Math.ceil(valuesResources[index]/(1024*1024)) + 'MB' + - '   GPU: ' + Math.ceil((valuesTextures[index] + valuesMeshes[index])/(1024*1024)) + 'MB' + - '   Te: ' + Math.ceil(valuesTextures[index]/(1024*1024)) + 'MB' + - '   Me: ' + Math.ceil(valuesMeshes[index]/(1024*1024)) + 'MB' + - '   Ge: ' + Math.ceil(valuesGeodata[index]/(1024*1024)) + 'MB' + - '   Met: ' + Math.ceil(valuesMetatiles[index]/(1024*1024)) + 'MB' + - '   Render: ' + Math.ceil(valuesGpu[index]/(1024*1024)) + 'MB' +''; + index = (this.cursorIndex + samplesIndex) % samples; + str = ' Total: ' + Math.ceil((valuesMetatiles[index] + valuesResources[index] + valuesTextures[index] + valuesMeshes[index])/(1024*1024)) + 'MB' + + '   CPU: ' + Math.ceil(valuesResources[index]/(1024*1024)) + 'MB' + + '   GPU: ' + Math.ceil((valuesTextures[index] + valuesMeshes[index])/(1024*1024)) + 'MB' + + '   Te: ' + Math.ceil(valuesTextures[index]/(1024*1024)) + 'MB' + + '   Me: ' + Math.ceil(valuesMeshes[index]/(1024*1024)) + 'MB' + + '   Ge: ' + Math.ceil(valuesGeodata[index]/(1024*1024)) + 'MB' + + '   Met: ' + Math.ceil(valuesMetatiles[index]/(1024*1024)) + 'MB' + + '   Render: ' + Math.ceil(valuesGpu[index]/(1024*1024)) + 'MB' +''; } else { - var str = ' Total: ' + Math.round((maxMetatiles + maxResources + maxTextures + maxMeshes)/(1024*1024)) + 'MB' + - '   CPU: ' + Math.ceil(maxResources/(1024*1024)) + 'MB' + - '   GPU: ' + Math.ceil((maxTextures + maxMeshes)/(1024*1024)) + 'MB' + - '   Te ' + Math.ceil(maxTextures/(1024*1024)) + 'MB' + - '   Me: ' + Math.ceil(maxMeshes/(1024*1024)) + 'MB' + - '   Ge: ' + Math.ceil(maxGeodata/(1024*1024)) + 'MB' + - '   Met: ' + Math.ceil(maxMetatiles/(1024*1024)) + 'MB' + - '   Render: ' + Math.ceil(maxGpu/(1024*1024)) + 'MB' +''; + str = ' Total: ' + Math.round((maxMetatiles + maxResources + maxTextures + maxMeshes)/(1024*1024)) + 'MB' + + '   CPU: ' + Math.ceil(maxResources/(1024*1024)) + 'MB' + + '   GPU: ' + Math.ceil((maxTextures + maxMeshes)/(1024*1024)) + 'MB' + + '   Te ' + Math.ceil(maxTextures/(1024*1024)) + 'MB' + + '   Me: ' + Math.ceil(maxMeshes/(1024*1024)) + 'MB' + + '   Ge: ' + Math.ceil(maxGeodata/(1024*1024)) + 'MB' + + '   Met: ' + Math.ceil(maxMetatiles/(1024*1024)) + 'MB' + + '   Render: ' + Math.ceil(maxGpu/(1024*1024)) + 'MB' +''; } } @@ -462,13 +464,13 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { case 'Polygons': case 'Processing': { - var max = 0; - var min = 99999999999; + max = 0; + min = 99999999999; + realCount = 0; + values = (this.graph == 'Polygons') ? stats.graphsPolygons : stats.graphsBuild; var total = 0; - var realCount = 0; - var values = (this.graph == 'Polygons') ? stats.graphsPolygons : stats.graphsBuild; - for (var i = 0; i < samples; i++) { + for (i = 0; i < samples; i++) { max = values[i] > max ? values[i] : max; if (values[i] > 0) { @@ -478,10 +480,10 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { } } - var factorY = height / max; + factorY = height / max; - for (var i = 0; i < samples; i++) { - var index = samplesIndex + i; + for (i = 0; i < samples; i++) { + index = samplesIndex + i; index %= samples; ctx.fillStyle='#007700'; @@ -489,10 +491,10 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { } if (this.showCursor) { - var index = (this.cursorIndex + samplesIndex) % samples; - var str = ' ' + this.graph + ' Max: ' + Math.round(values[index]) +''; + index = (this.cursorIndex + samplesIndex) % samples; + str = ' ' + this.graph + ' Max: ' + Math.round(values[index]) +''; } else { - var str = ' ' + this.graph + ' Max: ' + max +''; + str = ' ' + this.graph + ' Max: ' + max +''; str += '   Min: ' + min; str += '   Avrg: ' + Math.round(total / realCount) +''; } @@ -502,33 +504,35 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { case 'LODs': { - var max = 0; - var values = stats.graphsLODs; + max = 0; + values = stats.graphsLODs; - for (var i = 0; i < samples; i++) { + for (i = 0; i < samples; i++) { max = values[i][0] > max ? values[i][0] : max; } - var factorY = height / max; + factorY = height / max; ctx.fillStyle='#000000'; ctx.fillRect(0, 0, width, height); - for (var i = 0; i < samples; i++) { - var index = samplesIndex + i; + var lods; + + for (i = 0; i < samples; i++) { + index = samplesIndex + i; index %= samples; //ctx.fillStyle="#000000"; //ctx.fillRect(i*factorX, height, 1, -(values[index][0])*factorY); - var y = height; + y = height; - var lods = values[index][1]; + lods = values[index][1]; - for (var j = 0, lj = lods.length; j < lj; j++) { + for (j = 0, lj = lods.length; j < lj; j++) { if (lods[j]) { ctx.fillStyle='hsl('+((j*23)%360)+',100%,50%)'; - var value = Math.round((lods[j])*factorY); + value = Math.round((lods[j])*factorY); ctx.fillRect(i*factorX, y, 1, -value); y -= value; } @@ -537,19 +541,19 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { } if (this.showCursor) { - var index = (this.cursorIndex + samplesIndex) % samples; + index = (this.cursorIndex + samplesIndex) % samples; - var str = 'LODs:' + values[index][0]; - var lods = values[index][1]; + str = 'LODs:' + values[index][0]; + lods = values[index][1]; - for (var j = 0, lj = lods.length; j < lj; j++) { + for (j = 0, lj = lods.length; j < lj; j++) { if (lods[j]) { str += ''+j+':'+lods[j]; } } } else { - var str = 'LODs:' + values[index][0]; + str = 'LODs:' + values[index][0]; } str += ''; @@ -576,11 +580,11 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { var maxGeodataMinusCount = 0; var maxGeodataMinusSize = 0; - var valuesTextures = stats.graphsFluxTextures; - var valuesMeshes = stats.graphsFluxMeshes; - var valuesGeodata = stats.graphsFluxGeodatas; + valuesTextures = stats.graphsFluxTextures; + valuesMeshes = stats.graphsFluxMeshes; + valuesGeodata = stats.graphsFluxGeodatas; - for (var i = 0; i < samples; i++) { + for (i = 0; i < samples; i++) { var tmp = valuesTextures[i][0][0] + valuesMeshes[i][0][0]; maxCount = tmp > maxCount ? tmp : maxCount; tmp = valuesTextures[i][1][0] + valuesMeshes[i][1][0]; @@ -607,14 +611,14 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { maxGeodataMinusSize = valuesGeodata[i][1][1] > maxGeodataMinusSize ? valuesGeodata[i][1][1] : maxGeodataMinusSize; } - var factorY = (height*0.25-2) / maxCount; + factorY = (height*0.25-2) / maxCount; var factorY2 = (height*0.25-2) / maxSize; var base = Math.floor(height*0.25); var base2 = Math.floor(height*0.75); - for (var i = 0; i < samples; i++) { - var index = samplesIndex + i; + for (i = 0; i < samples; i++) { + index = samplesIndex + i; index %= samples; var y1Up = base; @@ -662,8 +666,8 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { if (this.showCursor) { - var index = (this.cursorIndex + samplesIndex) % samples; - var str = ' Textures Count +/-: ' + valuesTextures[index][0][0] + '/' + valuesTextures[index][1][0]; + index = (this.cursorIndex + samplesIndex) % samples; + str = ' Textures Count +/-: ' + valuesTextures[index][0][0] + '/' + valuesTextures[index][1][0]; str += '   Size +/-: ' + (valuesTextures[index][0][1]/1024/1024).toFixed(2) + '/' + (valuesTextures[index][1][1]/1024/1024).toFixed(2); str += '   Meshes Count +/-: ' + valuesMeshes[index][0][0] + '/' + valuesMeshes[index][1][0]; str += '   Size +/-: ' + (valuesMeshes[index][0][1]/1024/1024).toFixed(2) + '/' + (valuesMeshes[index][1][1]/1024/1024).toFixed(2); @@ -671,7 +675,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { str += '   Size +/-: ' + (valuesGeodata[index][0][1]/1024/1024).toFixed(2) + '/' + (valuesGeodata[index][1][1]/1024/1024).toFixed(2); str += ''; } else { - var str = ' Textures Count +/-: ' + maxTexPlusCount + '/' + maxTexMinusCount; + str = ' Textures Count +/-: ' + maxTexPlusCount + '/' + maxTexMinusCount; str += '   Size +/-: ' + (maxTexPlusSize/1024/1024).toFixed(2) + '/' + (maxTexMinusSize/1024/1024).toFixed(2); str += '   Meshes Count +/-: ' + maxMeshPlusCount + '/' + maxMeshMinusCount; str += '   Size +/-: ' + (maxMeshPlusSize/1024/1024).toFixed(2) + '/' + (maxMeshMinusSize/1024/1024).toFixed(2); @@ -687,7 +691,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { if (this.showCursor) { ctx.fillStyle='#aa00aa'; - var index = (this.cursorIndex) % samples; + index = (this.cursorIndex) % samples; ctx.fillRect(Math.floor(index*factorX)-1, 0, 1, height); ctx.fillRect(Math.floor(index*factorX)+1, 0, 1, height); } diff --git a/src/core/inspector/input.js b/src/core/inspector/input.js index 873ec320..5c42ce55 100755 --- a/src/core/inspector/input.js +++ b/src/core/inspector/input.js @@ -59,8 +59,8 @@ InspectorInput.prototype.onKeyUp = function(event, press) { this.ctrlDown = event.ctrlKey; this.shiftDown = event.shiftKey; - var done = (function(){}); var hit = false; + var blockHit = true; if (event) { var keyCode; @@ -123,7 +123,7 @@ InspectorInput.prototype.onKeyUp = function(event, press) { } if (this.diagnosticMode) { - var blockHit = true; + blockHit = true; switch(keyCode) { @@ -167,9 +167,12 @@ InspectorInput.prototype.onKeyUp = function(event, press) { case 81: case 113: var pos = map.getPosition(); + // eslint-disable-next-line console.log('pos-before: ' + JSON.stringify(pos.pos)); map.convertPositionViewMode(pos, (pos.getViewMode() == 'obj') ? 'subj' : 'obj'); + // eslint-disable-next-line console.log('new mode: ' + pos.getViewMode()); + // eslint-disable-next-line console.log('pos-after: ' + JSON.stringify(pos.pos)); map.setPosition(pos); /*this.core.saveScreenshot(pos);*/ break; //key Q pressed @@ -255,6 +258,7 @@ InspectorInput.prototype.onKeyUp = function(event, press) { //console.log("zfactor " + map.zFactor2 + " zz: " + map.renderer.getZoffsetFactor([map.zFactor2, 0, 0])); map.loaderSuspended = !map.loaderSuspended; + // eslint-disable-next-line console.log('loader state ' + map.loaderSuspended); break; //key M pressed @@ -262,7 +266,6 @@ InspectorInput.prototype.onKeyUp = function(event, press) { case 74: case 106: debug.drawEarth = !debug.drawEarth; hit = true; break; //key X pressed - break; //key J pressed case 88: case 120: @@ -301,7 +304,7 @@ InspectorInput.prototype.onKeyUp = function(event, press) { } if (this.diagnosticMode && inspector.drawRadar && !this.shiftDown && !press) { - var blockHit = true; + blockHit = true; switch(keyCode) { case 43: @@ -329,7 +332,7 @@ InspectorInput.prototype.onKeyUp = function(event, press) { } if (this.diagnosticMode && debug.drawBBoxes && !this.shiftDown && !press) { - var blockHit = true; + blockHit = true; switch(keyCode) { case 76: diff --git a/src/core/inspector/inspector.js b/src/core/inspector/inspector.js index 1e5575a4..6ddd37a8 100755 --- a/src/core/inspector/inspector.js +++ b/src/core/inspector/inspector.js @@ -1,5 +1,5 @@ -import {mat3 as mat3_, mat4 as mat4_} from '../utils/matrix'; +import {mat4 as mat4_} from '../utils/matrix'; import {math as math_} from '../utils/math'; import InspectorInput_ from './input'; import InspectorStats_ from './stats'; @@ -9,7 +9,7 @@ import InspectorReplay_ from './replay'; import InspectorStylesheets_ from './stylesheets'; //get rid of compiler mess -var mat3 = mat3_, mat4 = mat4_; +var mat4 = mat4_; var math = math_; var InspectorInput = InspectorInput_; var InspectorStats = InspectorStats_; @@ -81,7 +81,7 @@ Inspector.prototype.preventDefault = function(e) { }; -Inspector.prototype.onMapUpdate = function(string) { +Inspector.prototype.onMapUpdate = function() { var map = this.core.getMapInterface(); if (!map) { return; @@ -97,18 +97,17 @@ Inspector.prototype.onMapUpdate = function(string) { map.convertCoordsFromPhysToCanvas(this.measurePoints[0]); }*/ + var renderer = this.core.getRenderer(), i, li, j, lj, lines, slines, p; + if (this.replay.drawGlobe) { - var renderer = this.core.getRenderer(); - var p = map.convertCoordsFromPhysToCameraSpace([0,0,0]); + p = map.convertCoordsFromPhysToCameraSpace([0,0,0]); renderer.draw.drawTBall(p, 12742000 * 0.5, renderer.progStardome, this.replay.globeTexture, 12742000 * 0.5, true); } if (this.replay.drawCamera) { - var renderer = this.core.getRendererInterface(); - - var lines = this.replay.cameraLines; - var slines = []; - for (var i = 0, li = lines.length; i < li; i++) { + lines = this.replay.cameraLines; + slines = []; + for (i = 0, li = lines.length; i < li; i++) { slines.push(map.convertCoordsFromPhysToCanvas(lines[i])); } @@ -120,10 +119,10 @@ Inspector.prototype.onMapUpdate = function(string) { 'blend' : false }); - var lines = this.replay.cameraLines3; - for (var i = 0, li = lines.length; i < li; i++) { - var slines = []; - for (var j = 0, lj = lines[i].length; j < lj; j++) { + lines = this.replay.cameraLines3; + for (i = 0, li = lines.length; i < li; i++) { + slines = []; + for (j = 0, lj = lines[i].length; j < lj; j++) { slines.push(map.convertCoordsFromPhysToCanvas(lines[i][j])); } @@ -136,10 +135,10 @@ Inspector.prototype.onMapUpdate = function(string) { }); } - var lines = this.replay.cameraLines2; - for (var i = 0, li = lines.length; i < li; i++) { - var slines = []; - for (var j = 0, lj = lines[i].length; j < lj; j++) { + lines = this.replay.cameraLines2; + for (i = 0, li = lines.length; i < li; i++) { + slines = []; + for (j = 0, lj = lines[i].length; j < lj; j++) { slines.push(map.convertCoordsFromPhysToCanvas(lines[i][j])); } @@ -156,7 +155,7 @@ Inspector.prototype.onMapUpdate = function(string) { var cameInfo = map.getCameraInfo(); var p1 = map.convertCoordsFromPhysToCameraSpace(this.replay.cameraLines[0]); - var map2 = this.core.getMap(); + //var map2 = this.core.getMap(); //var m2 = map2.camera.getRotationviewMatrix(); var mv = mat4.create(this.replay.cameraMatrix); @@ -210,7 +209,7 @@ Inspector.prototype.onMapUpdate = function(string) { } if (this.drawRadar && this.circleTexture) { - var renderer = this.core.getRendererInterface(); + //var renderer = this.core.getRendererInterface(); var pos = map.getPosition(); var count = 16; var step = pos.getViewExtent() / (count * 4); @@ -231,8 +230,8 @@ Inspector.prototype.onMapUpdate = function(string) { */ - for (var j = 0; j < count; j++) { - for (var i = 0; i < count; i++) { + for (j = 0; j < count; j++) { + for (i = 0; i < count; i++) { var dx = i*step - count*0.5*step; var dy = j*step - count*0.5*step; var a = Math.atan2(dy, dx); @@ -250,8 +249,8 @@ Inspector.prototype.onMapUpdate = function(string) { var lbuffer = new Array(count); - for (var j = 0; j < count; j++) { - for (var i = 0; i < count; i++) { + for (j = 0; j < count; j++) { + for (i = 0; i < count; i++) { lbuffer[i] = cbuffer[j * count + i]; } @@ -265,8 +264,8 @@ Inspector.prototype.onMapUpdate = function(string) { } - for (var i = 0; i < count; i++) { - for (var j = 0; j < count; j++) { + for (i = 0; i < count; i++) { + for (j = 0; j < count; j++) { lbuffer[j] = cbuffer[j * count + i]; } @@ -279,8 +278,8 @@ Inspector.prototype.onMapUpdate = function(string) { }); } - for (var i = 0, li = cbuffer.length; i < li; i++) { - var p = cbuffer[i]; + for (i = 0, li = cbuffer.length; i < li; i++) { + p = cbuffer[i]; renderer.drawImage({ 'rect' : [p[0]-10, p[1]-10, 20, 20], 'texture' : this.circleTexture, diff --git a/src/core/inspector/layers.js b/src/core/inspector/layers.js index d63ba606..95959590 100755 --- a/src/core/inspector/layers.js +++ b/src/core/inspector/layers.js @@ -212,16 +212,19 @@ InspectorLayers.prototype.initViews = function() { return; } - var views = map.getNamedViews(); + var views = map.getNamedViews(), freeLayer; var id = '--initial--'; + var i, li, j, lj, layers, states, index, view, surfaces, skey; + + this.views[id] = { surfaces : {}, freeLayers : {}, original : JSON.parse(JSON.stringify(map.getView())) }; - for (var i = 0, li = views.length; i < li; i++) { - var view = views[i]; + for (i = 0, li = views.length; i < li; i++) { + view = views[i]; this.views[view] = { surfaces : {}, freeLayers : {}, @@ -230,20 +233,20 @@ InspectorLayers.prototype.initViews = function() { } this.currentView = id; - var views = this.views; + views = this.views; for (var key in views) { - var view = views[key]; - var surfaces = map.getSurfaces(); + view = views[key]; + surfaces = map.getSurfaces(); - for (var i = 0, li = surfaces.length; i < li; i++) { - var id = surfaces[i]; - var surface = map.getSurface(id); - var layers = map.getBoundLayers(); - var states = []; + for (i = 0, li = surfaces.length; i < li; i++) { + id = surfaces[i]; + surface = map.getSurface(id); + layers = map.getBoundLayers(); + states = []; - for (var j = 0, lj = layers.length; j < lj; j++) { - var layer = map.getBoundLayerById(layers[j]); + for (j = 0, lj = layers.length; j < lj; j++) { + //layer = map.getBoundLayerById(layers[j]); states.push({ id : layers[j], @@ -260,14 +263,13 @@ InspectorLayers.prototype.initViews = function() { var freeLayers = map.getFreeLayers(); - for (var i = 0, li = freeLayers.length; i < li; i++) { - var id = freeLayers[i]; - - var layers = map.getBoundLayers(); - var states = []; + for (i = 0, li = freeLayers.length; i < li; i++) { + id = freeLayers[i]; + layers = map.getBoundLayers(); + states = []; - for (var j = 0, lj = layers.length; j < lj; j++) { - var layer = map.getBoundLayerById(layers[j]); + for (j = 0, lj = layers.length; j < lj; j++) { + //layer = map.getBoundLayerById(layers[j]); states.push({ id : layers[j], @@ -276,7 +278,7 @@ InspectorLayers.prototype.initViews = function() { }); } - var freeLayer = map.getFreeLayer(id); + freeLayer = map.getFreeLayer(id); var freeLayerInfo = freeLayer.getInfo(); view.freeLayers[id] = { @@ -290,23 +292,23 @@ InspectorLayers.prototype.initViews = function() { var viewSurfaces = view.original['surfaces']; - for (var skey in viewSurfaces) { - var layers = viewSurfaces[skey]; + for (skey in viewSurfaces) { + layers = viewSurfaces[skey]; if (view.surfaces[skey]) { var surface = view.surfaces[skey]; surface.enabled = true; - for (var i = 0, li = layers.length; i < li; i++) { + for (i = 0, li = layers.length; i < li; i++) { if (typeof layers[i] === 'string') { - var index = this.findIdInArray(surface.layers, layers[i]); + index = this.findIdInArray(surface.layers, layers[i]); if (index != -1 && surface.layers[index]) { surface.layers[index].enabled = true; surface.layers.splice(i, 0, surface.layers.splice(index, 1)[0]); } } else { - var id = layers[i]['id']; - var index = this.findIdInArray(surface.layers, id); + id = layers[i]['id']; + index = this.findIdInArray(surface.layers, id); if (index != -1 && surface.layers[index]) { surface.layers[index].enabled = true; surface.layers[index].alpha = layers[i]['alpha'] ? (parseFloat(layers[i]['alpha'])*100) : 100; @@ -319,30 +321,30 @@ InspectorLayers.prototype.initViews = function() { var viewfreeLayers = view.original['freeLayers']; - for (var skey in viewfreeLayers) { + for (skey in viewfreeLayers) { var freeLayerProperties = viewfreeLayers[skey]; if (view.freeLayers[skey]) { - var freeLayer = view.freeLayers[skey]; + freeLayer = view.freeLayers[skey]; freeLayer.enabled = true; freeLayer.depthShift = freeLayerProperties['depthShift'] || 0; freeLayer.depthShift *= 100; freeLayer.style = freeLayerProperties['style']; //freeLayer.originalStyle = freeLayer.style; - var layers = []; + layers = []; freeLayer.layers = layers; - for (var i = 0, li = layers.length; i < li; i++) { + for (i = 0, li = layers.length; i < li; i++) { if (typeof layers[i] === 'string') { - var index = this.findIdInArray(freeLayer.layers, layers[i]); + index = this.findIdInArray(freeLayer.layers, layers[i]); if (index != -1 && freeLayer.layers[index]) { freeLayer.layers[index].enabled = true; freeLayer.layers.splice(i, 0, freeLayer.layers.splice(index, 1)[0]); } } else { - var id = layers[i]['id']; - var index = this.findIdInArray(freeLayer.layers, id); + id = layers[i]['id']; + index = this.findIdInArray(freeLayer.layers, id); if (index != -1 && surface.layers[index]) { freeLayer.layers[index].enabled = true; freeLayer.layers[index].alpha = layers[i]['alpha'] ? (parseFloat(layers[i]['alpha'])*100) : 100; @@ -350,7 +352,6 @@ InspectorLayers.prototype.initViews = function() { } } } - } } } @@ -387,7 +388,7 @@ InspectorLayers.prototype.buildViews = function() { this.viewItems.innerHTML = html; - for (var key in views) { + for (key in views) { htmlId = 'vts-views-cbutton-' + key; document.getElementById(htmlId).onclick = this.switchView.bind(this, key, htmlId, 'clone'); htmlId = 'vts-views-xbutton-' + key; @@ -401,10 +402,10 @@ InspectorLayers.prototype.buildViews = function() { InspectorLayers.prototype.buildSurfaces = function() { var view = this.views[this.currentView]; var surfaces = view.surfaces; - var html = ''; - var firstKey = null; + var html = '', htmlId; + var firstKey = null, key; - for (var key in surfaces) { + for (key in surfaces) { html += '
' + key + '
'; @@ -416,17 +417,17 @@ InspectorLayers.prototype.buildSurfaces = function() { this.surfacesItems.innerHTML = html; this.currentSurface = firstKey; - for (var key in surfaces) { + for (key in surfaces) { if (surfaces[key].enabled) { - var htmlId = 'vts-surface-checkbox-' + key; + htmlId = 'vts-surface-checkbox-' + key; document.getElementById(htmlId).checked = true; } } - for (var key in surfaces) { - var htmlId = 'vts-surface-checkbox-' + key; + for (key in surfaces) { + htmlId = 'vts-surface-checkbox-' + key; document.getElementById(htmlId).onchange = this.switchSurface.bind(this, key, htmlId); - var htmlId = 'vts-surface-item-' + key; + htmlId = 'vts-surface-item-' + key; document.getElementById(htmlId).onclick = this.selectSurface.bind(this, key); } }; @@ -450,7 +451,7 @@ InspectorLayers.prototype.buildBoundLayers = function(id) { this.boundLayersItems.innerHTML = html; - for (var i = 0, li = layers.length; i < li; i++) { + 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; @@ -469,7 +470,7 @@ InspectorLayers.prototype.buildFreeLayers = function() { var html = ''; for (var key in layers) { - var layer = layers[key]; + //var layer = layers[key]; html += '
' + key + '
'; @@ -477,10 +478,10 @@ InspectorLayers.prototype.buildFreeLayers = function() { this.freeLayersItems.innerHTML = html; - for (var key in layers) { + for (key in layers) { var htmlId = 'vts-freelayer-checkbox-' + key; document.getElementById(htmlId).onchange = this.switchFreeLayer.bind(this, key, htmlId); - var htmlId = 'vts-freelayer-item-' + key; + htmlId = 'vts-freelayer-item-' + key; document.getElementById(htmlId).onclick = this.selectFreeLayer.bind(this, key); } }; @@ -490,7 +491,7 @@ InspectorLayers.prototype.buildFreeLayerProperties = function(id) { var map = this.core.getMap(); var view = this.views[this.currentView]; var layers = view.freeLayers[id].layers; - var html = ''; + var html = '', i, li, htmlId; if (!map || !map.getFreeLayer(id)) { return; @@ -509,7 +510,7 @@ InspectorLayers.prototype.buildFreeLayerProperties = function(id) { html += '
' + 'BoundLayers:' + '
'; - for (var i = 0, li = layers.length; i < li; i++) { + for (i = 0, li = layers.length; i < li; i++) { var layer = layers[i]; html += '
' @@ -522,11 +523,11 @@ InspectorLayers.prototype.buildFreeLayerProperties = function(id) { this.freeLayersPropertiesItems.innerHTML = html; - var htmlId = 'vts-fl-properties-depth-shift'; + htmlId = 'vts-fl-properties-depth-shift'; document.getElementById(htmlId).onchange = this.switchFreeLayerProperty.bind(this, htmlId, 'depthShift'); - for (var i = 0, li = layers.length; i < li; i++) { - var htmlId = 'vts-fl-properties-checkbox-' + layers[i].id; + for (i = 0, li = layers.length; i < li; i++) { + htmlId = 'vts-fl-properties-checkbox-' + layers[i].id; document.getElementById(htmlId).onchange = this.switchFreeLayerBoundLayer.bind(this, layers[i].id, htmlId, 'enable'); htmlId = 'vts-fl-properties-spinner-' + layers[i].id; document.getElementById(htmlId).onchange = this.switchFreeLayerBoundLayer.bind(this, layers[i].id, htmlId, 'alpha'); @@ -547,16 +548,15 @@ InspectorLayers.prototype.buildFreeLayerProperties = function(id) { var styles = map.getStylesheets(); var index = styles.indexOf(view.freeLayers[id].style || view.freeLayers[id].originalStyle); // || layerInfo["style"]); - for (var i = 0, li = styles.length; i < li; i++) { + for (i = 0, li = styles.length; i < li; i++) { html += ''; } - html += '' - + '
'; + html += '' + ''; this.freeLayersPropertiesItems.innerHTML = html; - var htmlId = 'vts-layers-fl-properties-style'; + htmlId = 'vts-layers-fl-properties-style'; document.getElementById(htmlId).onchange = this.switchFreeLayerProperty.bind(this, htmlId, 'style'); break; @@ -569,16 +569,18 @@ InspectorLayers.prototype.selectView = function(id) { return; } + var element; + //deselect previous if (this.currentView) { - var element = document.getElementById('vts-views-item-' + this.currentView); + element = document.getElementById('vts-views-item-' + this.currentView); if (element) { element.style.backgroundColor = 'initial'; } } //select new one - var element = document.getElementById('vts-views-item-' + id); + element = document.getElementById('vts-views-item-' + id); element.style.backgroundColor = '#ddd'; this.currentView = id; //this.buildBoundLayers(this.currentSurface); @@ -591,7 +593,7 @@ InspectorLayers.prototype.selectView = function(id) { InspectorLayers.prototype.switchView = function(id, htmlId, action) { - var element = document.getElementById(htmlId); + //var element = document.getElementById(htmlId); var views = this.views; for (var key in this.views) { @@ -601,6 +603,7 @@ InspectorLayers.prototype.switchView = function(id, htmlId, action) { //layers[i].enabled = element.checked; var i = 2; + // eslint-disable-next-line while(true) { if (!views[id + ' #' + i]) { views[id + ' #' + i] = JSON.parse(JSON.stringify(views[id])); @@ -616,7 +619,7 @@ InspectorLayers.prototype.switchView = function(id, htmlId, action) { var count = 0; - for (var key in views) { + for (key in views) { count++; } @@ -625,7 +628,7 @@ InspectorLayers.prototype.switchView = function(id, htmlId, action) { this.buildViews(); if (this.currentView == id) { - for (var key in views) { + for (key in views) { this.selectView(key); break; } @@ -651,15 +654,16 @@ InspectorLayers.prototype.switchSurface = function(id, htmlId) { }; -InspectorLayers.prototype.selectSurface = function(id, htmlId) { +InspectorLayers.prototype.selectSurface = function(id) { + var element; //deselect previous if (this.currentSurface) { - var element = document.getElementById('vts-surface-item-' + this.currentSurface); + element = document.getElementById('vts-surface-item-' + this.currentSurface); element.style.backgroundColor = 'initial'; } //select new one - var element = document.getElementById('vts-surface-item-' + id); + element = document.getElementById('vts-surface-item-' + id); element.style.backgroundColor = '#ddd'; this.currentSurface = id; this.buildBoundLayers(this.currentSurface); @@ -706,15 +710,16 @@ InspectorLayers.prototype.switchFreeLayer = function(id, htmlId) { }; -InspectorLayers.prototype.selectFreeLayer = function(id, htmlId) { +InspectorLayers.prototype.selectFreeLayer = function(id) { + var element; //deselect previous if (this.currentFreeLayer) { - var element = document.getElementById('vts-freelayer-item-' + this.currentFreeLayer); + element = document.getElementById('vts-freelayer-item-' + this.currentFreeLayer); element.style.backgroundColor = 'initial'; } //select new one - var element = document.getElementById('vts-freelayer-item-' + id); + element = document.getElementById('vts-freelayer-item-' + id); element.style.backgroundColor = '#ddd'; this.currentFreeLayer = id; this.buildFreeLayerProperties(this.currentFreeLayer); @@ -778,14 +783,14 @@ InspectorLayers.prototype.applyMapView = function(jsonOnly) { }; var sourceView = this.views[this.currentView]; - var surfaces = sourceView.surfaces; + var surfaces = sourceView.surfaces, i, li, layers; for (var key in surfaces) { if (surfaces[key].enabled) { var surfaceBoundLayers = []; - var layers = surfaces[key].layers; //bound layers + layers = surfaces[key].layers; //bound layers - for (var i = 0, li = layers.length; i < li; i++) { + for (i = 0, li = layers.length; i < li; i++) { if (layers[i].enabled) { if (layers[i].alpha < 100) { @@ -802,12 +807,12 @@ InspectorLayers.prototype.applyMapView = function(jsonOnly) { var freeLayers = sourceView.freeLayers; - for (var key in freeLayers) { + for (key in freeLayers) { if (freeLayers[key].enabled) { var freeLayerBoundLayers = []; - var layers = freeLayers[key].layers; //bound layers + layers = freeLayers[key].layers; //bound layers - for (var i = 0, li = layers.length; i < li; i++) { + for (i = 0, li = layers.length; i < li; i++) { if (layers[i].enabled) { if (layers[i].alpha < 100) { @@ -871,7 +876,7 @@ InspectorLayers.prototype.switchPanel = function() { }; -InspectorLayers.prototype.updatePanel = function(Layers) { +InspectorLayers.prototype.updatePanel = function() { if (!this.panelInitialized) { this.panelInitialized = false; this.initViews(); diff --git a/src/core/inspector/replay.js b/src/core/inspector/replay.js index 8049712f..48e2bded 100755 --- a/src/core/inspector/replay.js +++ b/src/core/inspector/replay.js @@ -1,11 +1,11 @@ -import GpuTexture from '../renderer/gpu/texture'; +import GpuTexture_ from '../renderer/gpu/texture'; import {math as math_} from '../utils/math'; import {vec3 as vec3_, mat4 as mat4_} from '../utils/matrix'; //get rid of compiler mess var math = math_; -var GpuTexture = GpuTexture; +var GpuTexture = GpuTexture_; var vec3 = vec3_, mat4 = mat4_; @@ -18,101 +18,101 @@ var InspectorReplay = function(inspector) { InspectorReplay.prototype.init = function() { var inspector = this.inspector; inspector.addStyle( - "#vts-replay-panel {" - + "font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;" - + "display: none;" - + "padding:15px;" - + "width: 618px;" - + "font-size: 14px;" - + "position: absolute;" - + "right: 10px;" - + "top: 10px;" - + "cursor: default;" - + "background-color: rgba(255,255,255,0.95);" - + "border-radius: 5px;" - + "border: solid 1px #ccc;" - + "text-align: left;" - + "z-index: 7;" - + "padding: 10px;" - + "}" - - + "#vts-replay-panel-left {" - + "width: 253px;" - + "height: 100%;" - + "float: left;" - + "}" - - + "#vts-replay-panel-right {" - + "width: 340px;" - + "height: 100%;" - + "float: right;" - + "}" - - + "#vts-replay-items {" - + "width: 240px;" - + "overflow-x: hidden;" - + "border: 1px solid #ddd;" - + "padding-right: 5px;" - + "}" - - + ".vts-replay-item {" - + "width: 100%;" - + "overflow: hidden;" - + "text-overflow: ellipsis;" - + "white-space: nowrap;" - + "}" - - + "#vts-replay-lod-slider {" - + "width: 240px;" - + "}" - - + "#vts-replay-lod-text {" - + "width: 60px;" - + "margin-left: 10px;" - + "margin-right: 10px;" - + "}" - - + "#vts-replay-lod-single {" - + "margin-left: 10px;" - + "}" + '#vts-replay-panel {' + + 'font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif;' + + 'display: none;' + + 'padding:15px;' + + 'width: 618px;' + + 'font-size: 14px;' + + 'position: absolute;' + + 'right: 10px;' + + 'top: 10px;' + + 'cursor: default;' + + 'background-color: rgba(255,255,255,0.95);' + + 'border-radius: 5px;' + + 'border: solid 1px #ccc;' + + 'text-align: left;' + + 'z-index: 7;' + + 'padding: 10px;' + + '}' + + + '#vts-replay-panel-left {' + + 'width: 253px;' + + 'height: 100%;' + + 'float: left;' + + '}' + + + '#vts-replay-panel-right {' + + 'width: 340px;' + + 'height: 100%;' + + 'float: right;' + + '}' + + + '#vts-replay-items {' + + 'width: 240px;' + + 'overflow-x: hidden;' + + 'border: 1px solid #ddd;' + + 'padding-right: 5px;' + + '}' + + + '.vts-replay-item {' + + 'width: 100%;' + + 'overflow: hidden;' + + 'text-overflow: ellipsis;' + + 'white-space: nowrap;' + + '}' + + + '#vts-replay-lod-slider {' + + 'width: 240px;' + + '}' + + + '#vts-replay-lod-text {' + + 'width: 60px;' + + 'margin-left: 10px;' + + 'margin-right: 10px;' + + '}' + + + '#vts-replay-lod-single {' + + 'margin-left: 10px;' + + '}' - + "#vts-replay-time-slider {" - + "width: 330px;" - + "}" - - + "#vts-replay-time-text {" - + "width: 60px;" - + "margin-left: 10px;" - + "margin-right: 10px;" - + "}" - - + "#vts-replay-time-single {" - + "margin-left: 10px;" - + "}" - - + "#vts-replay-panel-gtime canvas{" - + "border: 1px solid #555;" - + "}" - - + "#vts-replay-panel-gtime span{" - + "font-size: 10px;" - + "}" - - + "#vts-replay-info {" - + "width: 240px;" - + "height: 140px;" - + "overflow-x: hidden;" - + "border: 1px solid #ddd;" - + "padding-right: 5px;" - + "margin-top: 10px;" - + "font-size: 12px;" - + "word-wrap: break-word;" - + "}" + + '#vts-replay-time-slider {' + + 'width: 330px;' + + '}' + + + '#vts-replay-time-text {' + + 'width: 60px;' + + 'margin-left: 10px;' + + 'margin-right: 10px;' + + '}' + + + '#vts-replay-time-single {' + + 'margin-left: 10px;' + + '}' + + + '#vts-replay-panel-gtime canvas{' + + 'border: 1px solid #555;' + + '}' + + + '#vts-replay-panel-gtime span{' + + 'font-size: 10px;' + + '}' + + + '#vts-replay-info {' + + 'width: 240px;' + + 'height: 140px;' + + 'overflow-x: hidden;' + + 'border: 1px solid #ddd;' + + 'padding-right: 5px;' + + 'margin-top: 10px;' + + 'font-size: 12px;' + + 'word-wrap: break-word;' + + '}' ); - this.element = document.createElement("div"); - this.element.id = "vts-replay-panel"; + this.element = document.createElement('div'); + this.element.id = 'vts-replay-panel'; this.element.innerHTML = '
' + '
' @@ -158,51 +158,51 @@ InspectorReplay.prototype.init = function() { this.core.element.appendChild(this.element); - this.items = document.getElementById("vts-replay-items"); + this.items = document.getElementById('vts-replay-items'); - this.lodSlider = document.getElementById("vts-replay-lod-slider"); - this.lodSlider.onchange = this.onSliderChange.bind(this, "lod"); - this.lodSlider.oninput = this.onSliderChange.bind(this, "lod"); + this.lodSlider = document.getElementById('vts-replay-lod-slider'); + this.lodSlider.onchange = this.onSliderChange.bind(this, 'lod'); + this.lodSlider.oninput = this.onSliderChange.bind(this, 'lod'); - this.lodText = document.getElementById("vts-replay-lod-text"); - this.lodText.onchange = this.onTextChange.bind(this, "lod"); + this.lodText = document.getElementById('vts-replay-lod-text'); + this.lodText.onchange = this.onTextChange.bind(this, 'lod'); - document.getElementById("vts-replay-lod-up").onclick = this.onSliderChange.bind(this, "lod", "down"); - document.getElementById("vts-replay-lod-down").onclick = this.onSliderChange.bind(this, "lod", "up"); - document.getElementById("vts-replay-lod-single").onclick = this.onSliderChange.bind(this, "lod", "single"); + document.getElementById('vts-replay-lod-up').onclick = this.onSliderChange.bind(this, 'lod', 'down'); + document.getElementById('vts-replay-lod-down').onclick = this.onSliderChange.bind(this, 'lod', 'up'); + document.getElementById('vts-replay-lod-single').onclick = this.onSliderChange.bind(this, 'lod', 'single'); - this.timeSlider = document.getElementById("vts-replay-time-slider"); - this.timeSlider.onchange = this.onSliderChange.bind(this, "time"); - this.timeSlider.oninput = this.onSliderChange.bind(this, "time"); - - this.timeText = document.getElementById("vts-replay-time-text"); - this.timeText.onchange = this.onTextChange.bind(this, "time"); - - this.timeInfo = document.getElementById("vts-replay-info"); - - document.getElementById("vts-replay-time-up").onclick = this.onSliderChange.bind(this, "time", "down"); - document.getElementById("vts-replay-time-down").onclick = this.onSliderChange.bind(this, "time", "up"); - document.getElementById("vts-replay-time-single").onclick = this.onSliderChange.bind(this, "time", "single"); - - this.element.addEventListener("mouseup", inspector.doNothing.bind(this), true); - this.element.addEventListener("mousedown", inspector.doNothing.bind(this), true); - this.element.addEventListener("mousewheel", inspector.doNothing.bind(this), false); - this.element.addEventListener("dblclick", inspector.doNothing.bind(this), false); - - this.infoMeshes = document.getElementById("vts-replay-info-meshes"); - this.ctxMeshes = document.getElementById("vts-replay-canvas-meshes").getContext("2d"); - this.infoTextures = document.getElementById("vts-replay-info-textures"); - this.ctxTextures = document.getElementById("vts-replay-canvas-textures").getContext("2d"); - this.infoTextures2 = document.getElementById("vts-replay-info-textures2"); - this.ctxTextures2 = document.getElementById("vts-replay-canvas-textures2").getContext("2d"); - this.infoGeodata = document.getElementById("vts-replay-info-geodata"); - this.ctxGeodata = document.getElementById("vts-replay-canvas-geodata").getContext("2d"); - this.infoMetatiles = document.getElementById("vts-replay-info-metatiles"); - this.ctxMetatiles = document.getElementById("vts-replay-canvas-metatiles").getContext("2d"); - this.infoIntervals = document.getElementById("vts-replay-info-intervals"); - this.ctxIntervals = document.getElementById("vts-replay-canvas-intervals").getContext("2d"); - this.infoThreads = document.getElementById("vts-replay-info-threads"); - this.ctxThreads = document.getElementById("vts-replay-canvas-threads").getContext("2d"); + this.timeSlider = document.getElementById('vts-replay-time-slider'); + this.timeSlider.onchange = this.onSliderChange.bind(this, 'time'); + this.timeSlider.oninput = this.onSliderChange.bind(this, 'time'); + + this.timeText = document.getElementById('vts-replay-time-text'); + this.timeText.onchange = this.onTextChange.bind(this, 'time'); + + this.timeInfo = document.getElementById('vts-replay-info'); + + document.getElementById('vts-replay-time-up').onclick = this.onSliderChange.bind(this, 'time', 'down'); + document.getElementById('vts-replay-time-down').onclick = this.onSliderChange.bind(this, 'time', 'up'); + document.getElementById('vts-replay-time-single').onclick = this.onSliderChange.bind(this, 'time', 'single'); + + this.element.addEventListener('mouseup', inspector.doNothing.bind(this), true); + this.element.addEventListener('mousedown', inspector.doNothing.bind(this), true); + this.element.addEventListener('mousewheel', inspector.doNothing.bind(this), false); + this.element.addEventListener('dblclick', inspector.doNothing.bind(this), false); + + this.infoMeshes = document.getElementById('vts-replay-info-meshes'); + this.ctxMeshes = document.getElementById('vts-replay-canvas-meshes').getContext('2d'); + this.infoTextures = document.getElementById('vts-replay-info-textures'); + this.ctxTextures = document.getElementById('vts-replay-canvas-textures').getContext('2d'); + this.infoTextures2 = document.getElementById('vts-replay-info-textures2'); + this.ctxTextures2 = document.getElementById('vts-replay-canvas-textures2').getContext('2d'); + this.infoGeodata = document.getElementById('vts-replay-info-geodata'); + this.ctxGeodata = document.getElementById('vts-replay-canvas-geodata').getContext('2d'); + this.infoMetatiles = document.getElementById('vts-replay-info-metatiles'); + this.ctxMetatiles = document.getElementById('vts-replay-canvas-metatiles').getContext('2d'); + this.infoIntervals = document.getElementById('vts-replay-info-intervals'); + this.ctxIntervals = document.getElementById('vts-replay-canvas-intervals').getContext('2d'); + this.infoThreads = document.getElementById('vts-replay-info-threads'); + this.ctxThreads = document.getElementById('vts-replay-canvas-threads').getContext('2d'); this.cameraLines = []; this.cameraLines2 = []; @@ -215,7 +215,7 @@ InspectorReplay.prototype.init = function() { InspectorReplay.prototype.showPanel = function() { this.buildReplayCombo(); - this.element.style.display = "block"; + this.element.style.display = 'block'; this.panelVisible = true; var map = this.core.getMap(); @@ -230,7 +230,7 @@ InspectorReplay.prototype.showPanel = function() { InspectorReplay.prototype.hidePanel = function() { - this.element.style.display = "none"; + this.element.style.display = 'none'; this.panelVisible = false; }; @@ -245,35 +245,35 @@ InspectorReplay.prototype.switchPanel = function() { InspectorReplay.prototype.onSliderChange = function(type, button) { - if (type == "lod") { + if (type == 'lod') { switch (button) { - case "up": - this.lodSlider.stepUp(); - this.lodText.value = this.lodSlider.value; - break; + case 'up': + this.lodSlider.stepUp(); + this.lodText.value = this.lodSlider.value; + break; - case "down": - this.lodSlider.stepDown(); - this.lodText.value = this.lodSlider.value; - break; + case 'down': + this.lodSlider.stepDown(); + this.lodText.value = this.lodSlider.value; + break; - default: - this.lodText.value = this.lodSlider.value; + default: + this.lodText.value = this.lodSlider.value; } } else { switch (button) { - case "up": - this.timeSlider.stepUp(); - this.timeText.value = this.timeSlider.value; - break; + case 'up': + this.timeSlider.stepUp(); + this.timeText.value = this.timeSlider.value; + break; - case "down": - this.timeSlider.stepDown(); - this.timeText.value = this.timeSlider.value; - break; + case 'down': + this.timeSlider.stepDown(); + this.timeText.value = this.timeSlider.value; + break; - default: - this.timeText.value = this.timeSlider.value; + default: + this.timeText.value = this.timeSlider.value; } } @@ -284,12 +284,12 @@ InspectorReplay.prototype.onSliderChange = function(type, button) { var replay = map.draw.replay; - if (type == "lod") { + if (type == 'lod') { replay.lod = parseFloat(this.lodText.value); - replay.singleLod = document.getElementById("vts-replay-lod-single").checked; + replay.singleLod = document.getElementById('vts-replay-lod-single').checked; } else { replay.loadedIndex = parseFloat(this.timeText.value); - replay.singleLodedIndex = document.getElementById("vts-replay-time-single").checked; + replay.singleLodedIndex = document.getElementById('vts-replay-time-single').checked; this.updateFileInfo(replay.loadedIndex); this.updateLoadGraphs(); } @@ -299,7 +299,7 @@ InspectorReplay.prototype.onSliderChange = function(type, button) { InspectorReplay.prototype.onTextChange = function(type) { - if (type == "lod") { + if (type == 'lod') { this.lodSlider.value = this.lodText.value; } else { this.timeSlider.value = this.timeText.value; @@ -312,7 +312,7 @@ InspectorReplay.prototype.onTextChange = function(type) { var replay = map.draw.replay; - if (type == "lod") { + if (type == 'lod') { replay.lod = parseFloat(this.lodText.value); } else { replay.loadedIndex = parseFloat(this.timeText.value); @@ -325,11 +325,7 @@ InspectorReplay.prototype.onTextChange = function(type) { InspectorReplay.prototype.generateCameraLines = function(camera) { - var map = this.core.getMapInterface(); var renderer = this.core.getRendererInterface(); - - var pos = map.getPosition(); - var p1 = camera.position; var p2 = camera.center; @@ -396,12 +392,13 @@ InspectorReplay.prototype.generateCameraLines = function(camera) { var l = camera.cameraDistance / segments; var l2 = 0.5 * l * Math.tan(dfov); var l3 = l2 * map2.camera.getAspect(); + var v1, v2, v3, v4; for (var i = 0; i < segments; i++) { - var v1 = [-l3, -l2, -l]; - var v2 = [l3, -l2, -l]; - var v3 = [l3, l2, -l]; - var v4 = [-l3, l2, -l]; + v1 = [-l3, -l2, -l]; + v2 = [l3, -l2, -l]; + v3 = [l3, l2, -l]; + v4 = [-l3, l2, -l]; vec3.scale(v1, (i+1)); vec3.scale(v2, (i+1)); @@ -432,11 +429,11 @@ InspectorReplay.prototype.generateCameraLines = function(camera) { l2 = 0.5 * l * Math.tan(dfov); l3 = l2 * map2.camera.getAspect(); - for (var i = 0; i < segments; i++) { - var v1 = [-l3, -l2, -l]; - var v2 = [l3, -l2, -l]; - var v3 = [l3, l2, -l]; - var v4 = [-l3, l2, -l]; + for (i = 0; i < segments; i++) { + v1 = [-l3, -l2, -l]; + v2 = [l3, -l2, -l]; + v3 = [l3, l2, -l]; + v4 = [-l3, l2, -l]; vec3.scale(v1, (i+1)); vec3.scale(v2, (i+1)); @@ -459,10 +456,10 @@ InspectorReplay.prototype.generateCameraLines = function(camera) { this.cameraLines3[3].push(v4); } - var v1 = [-l3, -l2, -l]; - var v2 = [l3, -l2, -l]; - var v3 = [l3, l2, -l]; - var v4 = [-l3, l2, -l]; + v1 = [-l3, -l2, -l]; + v2 = [l3, -l2, -l]; + v3 = [l3, l2, -l]; + v4 = [-l3, l2, -l]; vec3.scale(v1, segments); vec3.scale(v2, segments); @@ -472,40 +469,40 @@ InspectorReplay.prototype.generateCameraLines = function(camera) { p1 = [0,0,0]; var vertices = [ p1[0], p1[1], p1[2], - v1[0], v1[1], v1[2], - v2[0], v2[1], v2[2], + v1[0], v1[1], v1[2], + v2[0], v2[1], v2[2], - p1[0], p1[1], p1[2], - v2[0], v2[1], v2[2], - v3[0], v3[1], v3[2], + p1[0], p1[1], p1[2], + v2[0], v2[1], v2[2], + v3[0], v3[1], v3[2], - p1[0], p1[1], p1[2], - v3[0], v3[1], v3[2], - v4[0], v4[1], v4[2], + p1[0], p1[1], p1[2], + v3[0], v3[1], v3[2], + v4[0], v4[1], v4[2], - p1[0], p1[1], p1[2], - v4[0], v4[1], v4[2], - v1[0], v1[1], v1[2] - ]; + p1[0], p1[1], p1[2], + v4[0], v4[1], v4[2], + v1[0], v1[1], v1[2] + ]; var uvs = [ 0,0, 0,0, 0,0, - 0,0, 0,0, 0,0, - 0,0, 0,0, 0,0, - 0,0, 0,0, 0,0 ]; + 0,0, 0,0, 0,0, + 0,0, 0,0, 0,0, + 0,0, 0,0, 0,0 ]; var normals = [ 0,0,1, 0,0,1, 0,0,1, - 0,0,1, 0,0,1, 0,0,1, - 0,0,1, 0,0,1, 0,0,1, - 0,0,1, 0,0,1, 0,0,1 ]; + 0,0,1, 0,0,1, 0,0,1, + 0,0,1, 0,0,1, 0,0,1, + 0,0,1, 0,0,1, 0,0,1 ]; this.frustumState = renderer.createState({ - "blend" : true, - "zwrite" : false, - "ztest" : true, - "culling" : false + 'blend' : true, + 'zwrite' : false, + 'ztest' : true, + 'culling' : false }); - this.frustumMesh = renderer.createMesh({ "vertices": vertices, "uvs": uvs, "normals": normals }); + this.frustumMesh = renderer.createMesh({ 'vertices': vertices, 'uvs': uvs, 'normals': normals }); this.cameraGenarated = true; }; @@ -519,51 +516,51 @@ InspectorReplay.prototype.itemButton = function(item, button) { var replay = map.draw.replay; switch (item) { - case "DrawnTiles": - replay.storeTiles = true; - break; - - case "DrawnTilesFreeLayers": - replay.storeFreeTiles = true; - break; - - case "TracedNodes": - replay.storeNodes = true; - break; - - case "TracedNodesFreeLayers": - replay.storeFreeNodes = true; - break; - - case "LoadSequence": - replay.storeLoaded = (button == "S"); - - if (button == "S") { - replay.loadedIndex = 0; - replay.loaded = []; - } else { - this.updateFileInfo(replay.loadedIndex); - this.updateLoadGraphs(); - } - break; + case 'DrawnTiles': + replay.storeTiles = true; + break; + + case 'DrawnTilesFreeLayers': + replay.storeFreeTiles = true; + break; + + case 'TracedNodes': + replay.storeNodes = true; + break; + + case 'TracedNodesFreeLayers': + replay.storeFreeNodes = true; + break; + + case 'LoadSequence': + replay.storeLoaded = (button == 'S'); + + if (button == 'S') { + replay.loadedIndex = 0; + replay.loaded = []; + } else { + this.updateFileInfo(replay.loadedIndex); + this.updateLoadGraphs(); + } + break; - case "Camera": + case 'Camera': - var camera = replay.camera = { - distance : map.camera.distance, - position : map.camera.position.slice(), - vector : map.camera.vector.slice(), - center : map.camera.center.slice(), - height : map.camera.height - }; + var camera = replay.camera = { + distance : map.camera.distance, + position : map.camera.position.slice(), + vector : map.camera.vector.slice(), + center : map.camera.center.slice(), + height : map.camera.height + }; - this.generateCameraLines(camera); + this.generateCameraLines(camera); //this.drawCamera = true; - break; + break; - case "Globe": + case 'Globe': - break; + break; } map.markDirty(); @@ -582,53 +579,53 @@ InspectorReplay.prototype.switchItem = function(item, htmlId) { var replay = map.draw.replay; switch (item) { - case "DrawnTiles": - replay.drawTiles = element.checked; - break; + case 'DrawnTiles': + replay.drawTiles = element.checked; + break; - case "DrawnTilesFreeLayers": - replay.drawFreeTiles = element.checked; - break; + case 'DrawnTilesFreeLayers': + replay.drawFreeTiles = element.checked; + break; - case "TracedNodes": - replay.drawNodes = element.checked; - break; + case 'TracedNodes': + replay.drawNodes = element.checked; + break; - case "TracedNodesFreeLayers": - replay.drawFreeNodes = element.checked; - break; + case 'TracedNodesFreeLayers': + replay.drawFreeNodes = element.checked; + break; - case "LoadSequence": - replay.drawLoaded = element.checked; - break; + case 'LoadSequence': + replay.drawLoaded = element.checked; + break; - case "Camera": + case 'Camera': - if (!this.cameraGenarated) { - this.itemButton("Camera"); - } + if (!this.cameraGenarated) { + this.itemButton('Camera'); + } - this.drawCamera = element.checked; - break; + this.drawCamera = element.checked; + break; - case "Globe": - var renderer = this.core.getRenderer(); + case 'Globe': + var renderer = this.core.getRenderer(); - if (!this.globeTexture) { - var texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAEACAMAAADyTj5VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo0Mzk4RkVFMzlGNjUxMUU2OTBDM0I0OEM1NjU0RURBMyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo0Mzk4RkVFNDlGNjUxMUU2OTBDM0I0OEM1NjU0RURBMyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjQzOThGRUUxOUY2NTExRTY5MEMzQjQ4QzU2NTRFREEzIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjQzOThGRUUyOUY2NTExRTY5MEMzQjQ4QzU2NTRFREEzIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+5rvbhAAAAAZQTFRFwcHBLS0tMDfv/wAAAiZJREFUeNrs2LENAEEIA0HTf9ME5DTgIZn8ta+TnLjymzuW6kMIwIcQgA8hAAqAAmBdAM4O4E/wBPgQAqAAKAAKgAKgHcDZAegJoAAoAAqAAqAAaAdwdgB6AigACoACoAAoANoBnB2AngAKgAKgACgACoB2AGcHoCeAAqAAKAAKgAKgHcDZAegJoAAoAAqAAqAAaAdwdgB6AigACoACoAAoANoBnB2AngAKgAKgACgACoB2AGcHoCeAAqAAKAAKgAKgHcDZAegJoAAoAAqAAqAAaAdwdgB6AigACoACEIAPIQAfwg7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABUABUAAUAAVAO4CzA9ATQAFQABQABUAB0A7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABUABUAAUAAVAO4CzA9ATQAFQABQABUAB0A7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABSAAH0IAPoQAfAgB0A7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABUABUAAUAAVAO4CzA9ATQAFQABQABUAB0A7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABUABUAAUAAVAO4CzA9ATQAFQABQABUAB0A7g7AD0BFAAFAAFQAFQAPxcAQYAZt2IEFFJhxsAAAAASUVORK5CYII="; - this.globeTexture = new GpuTexture(renderer.gpu, texture, this.core, null, true); - } + if (!this.globeTexture) { + var texture = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAEACAMAAADyTj5VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo0Mzk4RkVFMzlGNjUxMUU2OTBDM0I0OEM1NjU0RURBMyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo0Mzk4RkVFNDlGNjUxMUU2OTBDM0I0OEM1NjU0RURBMyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjQzOThGRUUxOUY2NTExRTY5MEMzQjQ4QzU2NTRFREEzIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjQzOThGRUUyOUY2NTExRTY5MEMzQjQ4QzU2NTRFREEzIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+5rvbhAAAAAZQTFRFwcHBLS0tMDfv/wAAAiZJREFUeNrs2LENAEEIA0HTf9ME5DTgIZn8ta+TnLjymzuW6kMIwIcQgA8hAAqAAmBdAM4O4E/wBPgQAqAAKAAKgAKgHcDZAegJoAAoAAqAAqAAaAdwdgB6AigACoACoAAoANoBnB2AngAKgAKgACgACoB2AGcHoCeAAqAAKAAKgAKgHcDZAegJoAAoAAqAAqAAaAdwdgB6AigACoACoAAoANoBnB2AngAKgAKgACgACoB2AGcHoCeAAqAAKAAKgAKgHcDZAegJoAAoAAqAAqAAaAdwdgB6AigACoACEIAPIQAfwg7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABUABUAAUAAVAO4CzA9ATQAFQABQABUAB0A7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABUABUAAUAAVAO4CzA9ATQAFQABQABUAB0A7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABSAAH0IAPoQAfAgB0A7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABUABUAAUAAVAO4CzA9ATQAFQABQABUAB0A7g7AD0BFAAFAAFQAFQALQDODsAPQEUAAVAAVAAFADtAM4OQE8ABUABUAAUAAVAO4CzA9ATQAFQABQABUAB0A7g7AD0BFAAFAAFQAFQAPxcAQYAZt2IEFFJhxsAAAAASUVORK5CYII='; + this.globeTexture = new GpuTexture(renderer.gpu, texture, this.core, null, true); + } - this.drawGlobe = element.checked; - this.drawGlobe = this.drawGlobe; - break; + this.drawGlobe = element.checked; + this.drawGlobe = this.drawGlobe; + break; } map.markDirty(); }; -InspectorReplay.prototype.updateLoadGraphs = function(index) { +InspectorReplay.prototype.updateLoadGraphs = function() { var map = this.core.getMap(); if (!map) { return; @@ -644,53 +641,52 @@ InspectorReplay.prototype.updateLoadGraphs = function(index) { var lx = 340; var ly = 30; - this.ctxMeshes.fillStyle = "#000000"; + this.ctxMeshes.fillStyle = '#000000'; this.ctxMeshes.fillRect(0, 0, lx, ly); - this.ctxTextures.fillStyle = "#000000"; + this.ctxTextures.fillStyle = '#000000'; this.ctxTextures.fillRect(0, 0, lx, ly); - this.ctxTextures2.fillStyle = "#000000"; + this.ctxTextures2.fillStyle = '#000000'; this.ctxTextures2.fillRect(0, 0, lx, ly); - this.ctxGeodata.fillStyle = "#000000"; + this.ctxGeodata.fillStyle = '#000000'; this.ctxGeodata.fillRect(0, 0, lx, ly); - this.ctxMetatiles.fillStyle = "#000000"; + this.ctxMetatiles.fillStyle = '#000000'; this.ctxMetatiles.fillRect(0, 0, lx, ly); - this.ctxIntervals.fillStyle = "#000000"; + this.ctxIntervals.fillStyle = '#000000'; this.ctxIntervals.fillRect(0, 0, lx, ly); - this.ctxThreads.fillStyle = "#000000"; + this.ctxThreads.fillStyle = '#000000'; this.ctxThreads.fillRect(0, 0, lx, ly); - var i = Math.floor(replay.loadedIndex / lx) * lx; - var shift = i; - var li = (lx-1); + var i = Math.floor(replay.loadedIndex / lx) * lx, li = (lx-1); + var shift = i, file; - for (var i = 0; i < li; i++) { - var file = loaded[i + shift]; + for (i = 0; i < li; i++) { + file = loaded[i + shift]; if (file) { switch(file.kind) { - case "mesh": ctx = this.ctxMeshes; break; - case "texture-in": ctx = this.ctxTextures; break; - case "texture-ex": ctx = this.ctxTextures2; break; - case "geodata": ctx = this.ctxGeodata; break; - case "metatile": ctx = this.ctxMetatiles; break; - default: - continue; + case 'mesh': ctx = this.ctxMeshes; break; + case 'texture-in': ctx = this.ctxTextures; break; + case 'texture-ex': ctx = this.ctxTextures2; break; + case 'geodata': ctx = this.ctxGeodata; break; + case 'metatile': ctx = this.ctxMetatiles; break; + default: + continue; } var grey = Math.round(Math.min(255, 60+20 * Math.max(1, file.duration / 300))); - ctx.fillStyle="rgb("+grey+","+grey+","+grey+")"; + ctx.fillStyle='rgb('+grey+','+grey+','+grey+')'; var h = (file.duration / 300) * 30; ctx.fillRect(i, ly, 1, -h); //interval grey = Math.round(Math.min(255, 60+20 * Math.max(1, file.interval / 300))); - this.ctxIntervals.fillStyle="rgb("+grey+","+grey+","+grey+")"; + this.ctxIntervals.fillStyle='rgb('+grey+','+grey+','+grey+')'; h = (file.interval / 300) * 30; this.ctxIntervals.fillRect(i, ly, 1, -h); //interval - this.ctxThreads.fillStyle="rgb(80,80,80)"; + this.ctxThreads.fillStyle='rgb(80,80,80)'; h = (file.threads / map.config.mapDownloadThreads) * 30; this.ctxThreads.fillRect(i, ly, 1, -h); } @@ -706,49 +702,49 @@ InspectorReplay.prototype.updateLoadGraphs = function(index) { li = loaded.length; - for (var i = 0; i < li; i++) { - var file = loaded[i]; + for (i = 0; i < li; i++) { + file = loaded[i]; if (file) { switch(file.kind) { - case "mesh": - if (file.duration < minMeshes) minMeshes = file.duration; - if (file.duration > maxMeshes) maxMeshes = file.duration; - avgMeshes += file.duration; - avgMeshesCount++; - break; + case 'mesh': + if (file.duration < minMeshes) minMeshes = file.duration; + if (file.duration > maxMeshes) maxMeshes = file.duration; + avgMeshes += file.duration; + avgMeshesCount++; + break; - case "texture-in": - if (file.duration < minTextures) minTextures = file.duration; - if (file.duration > maxTextures) maxTextures = file.duration; - avgTextures += file.duration; - avgTexturesCount++; - break; + case 'texture-in': + if (file.duration < minTextures) minTextures = file.duration; + if (file.duration > maxTextures) maxTextures = file.duration; + avgTextures += file.duration; + avgTexturesCount++; + break; - case "texture-ex": - if (file.duration < minTextures2) minTextures2 = file.duration; - if (file.duration > maxTextures2) maxTextures2 = file.duration; - avgTextures2 += file.duration; - avgTextures2Count++; - break; + case 'texture-ex': + if (file.duration < minTextures2) minTextures2 = file.duration; + if (file.duration > maxTextures2) maxTextures2 = file.duration; + avgTextures2 += file.duration; + avgTextures2Count++; + break; - case "geodata": - if (file.duration < minGeodata) minGeodata = file.duration; - if (file.duration > maxGeodata) maxGeodata = file.duration; - avgGeodata += file.duration; - avgGeodataCount++; - break; + case 'geodata': + if (file.duration < minGeodata) minGeodata = file.duration; + if (file.duration > maxGeodata) maxGeodata = file.duration; + avgGeodata += file.duration; + avgGeodataCount++; + break; - case "metatile": - if (file.duration < minMetatiles) minMetatiles = file.duration; - if (file.duration > maxMetatiles) maxMetatiles = file.duration; - avgMetatiles += file.duration; - avgMetatilesCount++; - break; - - default: - continue; + case 'metatile': + if (file.duration < minMetatiles) minMetatiles = file.duration; + if (file.duration > maxMetatiles) maxMetatiles = file.duration; + avgMetatiles += file.duration; + avgMetatilesCount++; + break; + + default: + continue; } if (file.threads < minThreads) minThreads = file.threads; @@ -765,25 +761,25 @@ InspectorReplay.prototype.updateLoadGraphs = function(index) { index -= shift; - this.ctxMeshes.fillStyle = "#ff0000"; + this.ctxMeshes.fillStyle = '#ff0000'; this.ctxMeshes.fillRect(index - 1, 0, 1, ly); this.ctxMeshes.fillRect(index + 1, 0, 1, ly); - this.ctxTextures.fillStyle = "#ff0000"; + this.ctxTextures.fillStyle = '#ff0000'; this.ctxTextures.fillRect(index - 1, 0, 1, ly); this.ctxTextures.fillRect(index + 1, 0, 1, ly); - this.ctxTextures2.fillStyle = "#ff0000"; + this.ctxTextures2.fillStyle = '#ff0000'; this.ctxTextures2.fillRect(index - 1, 0, 1, ly); this.ctxTextures2.fillRect(index + 1, 0, 1, ly); - this.ctxGeodata.fillStyle = "#ff0000"; + this.ctxGeodata.fillStyle = '#ff0000'; this.ctxGeodata.fillRect(index - 1, 0, 1, ly); this.ctxGeodata.fillRect(index + 1, 0, 1, ly); - this.ctxMetatiles.fillStyle = "#ff0000"; + this.ctxMetatiles.fillStyle = '#ff0000'; this.ctxMetatiles.fillRect(index - 1, 0, 1, ly); this.ctxMetatiles.fillRect(index + 1, 0, 1, ly); - this.ctxIntervals.fillStyle = "#ff0000"; + this.ctxIntervals.fillStyle = '#ff0000'; this.ctxIntervals.fillRect(index - 1, 0, 1, ly); this.ctxIntervals.fillRect(index + 1, 0, 1, ly); - this.ctxThreads.fillStyle = "#ff0000"; + this.ctxThreads.fillStyle = '#ff0000'; this.ctxThreads.fillRect(index - 1, 0, 1, ly); this.ctxThreads.fillRect(index + 1, 0, 1, ly); @@ -803,13 +799,13 @@ InspectorReplay.prototype.updateLoadGraphs = function(index) { avgIntervals = avgIntervalsCount ? (avgIntervals/avgIntervalsCount) : 0; avgThreads = avgThreadsCount ? (avgThreads/avgThreadsCount) : 0; - this.infoMeshes.innerHTML = "Meshes Min/Max/Avg/Count: " + minMeshes.toFixed(0) + "/" + maxMeshes.toFixed(0) + "/" + avgMeshes.toFixed(1) + "/" + avgMeshesCount; - this.infoTextures.innerHTML = "Internal Textures Min/Max/Avg/Count: " + minTextures.toFixed(0) + "/" + maxTextures.toFixed(0) + "/" + avgTextures.toFixed(1) + "/" + avgTexturesCount; - this.infoTextures2.innerHTML = "External Textures Min/Max/Avg/Count: " + minTextures2.toFixed(0) + "/" + maxTextures2.toFixed(0) + "/" + avgTextures2.toFixed(1) + "/" + avgTextures2Count; - this.infoGeodata.innerHTML = "Geodata Min/Max/Avg/Count: " + minGeodata.toFixed(0) + "/" + maxGeodata.toFixed(0) + "/" + avgGeodata.toFixed(1) + "/" + avgGeodataCount; - this.infoMetatiles.innerHTML = "Metatiles Min/Max/Avg/Count: " + minMetatiles.toFixed(0) + "/" + maxMetatiles.toFixed(0) + "/" + avgMetatiles.toFixed(1) + "/" + avgMetatilesCount; - this.infoIntervals.innerHTML = "Intervals Min/Max/Avg: " + minIntervals.toFixed(0) + "/" + maxIntervals.toFixed(0) + "/" + avgIntervals.toFixed(1); - this.infoThreads.innerHTML = "Threads Min/Max/Avg: " + minThreads + "/" + maxThreads + "/" + avgThreads.toFixed(1); + this.infoMeshes.innerHTML = 'Meshes Min/Max/Avg/Count: ' + minMeshes.toFixed(0) + '/' + maxMeshes.toFixed(0) + '/' + avgMeshes.toFixed(1) + '/' + avgMeshesCount; + this.infoTextures.innerHTML = 'Internal Textures Min/Max/Avg/Count: ' + minTextures.toFixed(0) + '/' + maxTextures.toFixed(0) + '/' + avgTextures.toFixed(1) + '/' + avgTexturesCount; + this.infoTextures2.innerHTML = 'External Textures Min/Max/Avg/Count: ' + minTextures2.toFixed(0) + '/' + maxTextures2.toFixed(0) + '/' + avgTextures2.toFixed(1) + '/' + avgTextures2Count; + this.infoGeodata.innerHTML = 'Geodata Min/Max/Avg/Count: ' + minGeodata.toFixed(0) + '/' + maxGeodata.toFixed(0) + '/' + avgGeodata.toFixed(1) + '/' + avgGeodataCount; + this.infoMetatiles.innerHTML = 'Metatiles Min/Max/Avg/Count: ' + minMetatiles.toFixed(0) + '/' + maxMetatiles.toFixed(0) + '/' + avgMetatiles.toFixed(1) + '/' + avgMetatilesCount; + this.infoIntervals.innerHTML = 'Intervals Min/Max/Avg: ' + minIntervals.toFixed(0) + '/' + maxIntervals.toFixed(0) + '/' + avgIntervals.toFixed(1); + this.infoThreads.innerHTML = 'Threads Min/Max/Avg: ' + minThreads + '/' + maxThreads + '/' + avgThreads.toFixed(1); }; @@ -823,16 +819,16 @@ InspectorReplay.prototype.updateFileInfo = function(index) { var file = replay.loaded[index]; if (file) { - this.timeInfo.innerHTML = "" - + "Resource Kind: " + file.kind + "
" - + "Time: " + file.time.toFixed(2) + "
" - + "Duration: " + file.duration.toFixed(2) + "
" - + "Interval: " + file.interval.toFixed(2) + "
" - + "Priority: " + file.priority.toFixed(2) + "
" - + "Threads: " + file.threads + "
" - + "" + file.url; + this.timeInfo.innerHTML = '' + + 'Resource Kind: ' + file.kind + '
' + + 'Time: ' + file.time.toFixed(2) + '
' + + 'Duration: ' + file.duration.toFixed(2) + '
' + + 'Interval: ' + file.interval.toFixed(2) + '
' + + 'Priority: ' + file.priority.toFixed(2) + '
' + + 'Threads: ' + file.threads + '
' + + '' + file.url; } else { - this.timeInfo.innerHTML = ""; + this.timeInfo.innerHTML = ''; } }; @@ -844,28 +840,28 @@ InspectorReplay.prototype.buildReplayCombo = function() { } var items = [ - ["Drawn Tiles",1], - ["Drawn Tiles - Free Layers",1], - ["Traced Nodes",1], - ["Traced Nodes - Free Layers",1], - ["Load Sequence",2], - ["Camera",1], - ["Globe",0] + ['Drawn Tiles',1], + ['Drawn Tiles - Free Layers',1], + ['Traced Nodes',1], + ['Traced Nodes - Free Layers',1], + ['Load Sequence',2], + ['Camera',1], + ['Globe',0] ]; var keys = [ - "DrawnTiles", - "DrawnTilesFreeLayers", - "TracedNodes", - "TracedNodesFreeLayers", - "LoadSequence", - "Camera", - "Globe" + 'DrawnTiles', + 'DrawnTilesFreeLayers', + 'TracedNodes', + 'TracedNodesFreeLayers', + 'LoadSequence', + 'Camera', + 'Globe' ]; - var html = ""; + var html = '', i, li, htmlId; - for (var i = 0, li = items.length; i < li; i++) { + for (i = 0, li = items.length; i < li; i++) { html += '
' + '' + '' + items[i][0] + '  '; @@ -884,20 +880,20 @@ InspectorReplay.prototype.buildReplayCombo = function() { this.items.innerHTML = html; //this.currentItem = keys[0]; - for (var i = 0, li = items.length; i < li; i++) { - var htmlId = "vts-replay-checkbox-" + keys[i]; + for (i = 0, li = items.length; i < li; i++) { + htmlId = 'vts-replay-checkbox-' + keys[i]; document.getElementById(htmlId).onchange = this.switchItem.bind(this, keys[i], htmlId); //var htmlId = "vts-replay-item-" + keys[i]; //document.getElementById(htmlId).onclick = this.selectReplayItem.bind(this, keys[i]); if (items[i][1] > 0) { - var htmlId = "vts-replay-sbutton-" + keys[i]; - document.getElementById(htmlId).onclick = this.itemButton.bind(this, keys[i], "S"); + htmlId = 'vts-replay-sbutton-' + keys[i]; + document.getElementById(htmlId).onclick = this.itemButton.bind(this, keys[i], 'S'); } if (items[i][1] > 1) { - var htmlId = "vts-replay-fbutton-" + keys[i]; - document.getElementById(htmlId).onclick = this.itemButton.bind(this, keys[i], "F"); + htmlId = 'vts-replay-fbutton-' + keys[i]; + document.getElementById(htmlId).onclick = this.itemButton.bind(this, keys[i], 'F'); } } }; diff --git a/src/core/interface.js b/src/core/interface.js index 6c21d134..7ea0894b 100755 --- a/src/core/interface.js +++ b/src/core/interface.js @@ -1,10 +1,10 @@ import Proj4 from 'proj4'; import {Core as Core_} from './core'; -import {CoreInterface as CoreInterface_} from './interface'; +//import {CoreInterface as CoreInterface_} from './interface'; //get rid of compiler mess -var CoreInterface = CoreInterface_; +//var CoreInterface = CoreInterface_; var Core = Core_; var proj4 = Proj4; diff --git a/src/core/map/bound-layer.js b/src/core/map/bound-layer.js index 10d7a7b3..48eef9d3 100755 --- a/src/core/map/bound-layer.js +++ b/src/core/map/bound-layer.js @@ -5,8 +5,8 @@ import {utilsUrl as utilsUrl_} from '../utils/url'; //get rid of compiler mess var utils = utils_; -var MapCredit = MapCredit_; var utilsUrl = utilsUrl_; +var MapCredit = MapCredit_; var MapBoundLayer = function(map, json, id) { @@ -38,9 +38,9 @@ var MapBoundLayer = function(map, json, id) { if (typeof json === 'string') { this.jsonUrl = this.map.url.processUrl(json); - this.baseUrl = utilsUrl_.getBase(this.jsonUrl); - this.baseUrlSchema = utilsUrl_.getSchema(this.jsonUrl); - this.baseUrlOrigin = utilsUrl_.getOrigin(this.jsonUrl); + this.baseUrl = utilsUrl.getBase(this.jsonUrl); + this.baseUrlSchema = utilsUrl.getSchema(this.jsonUrl); + this.baseUrlOrigin = utilsUrl.getOrigin(this.jsonUrl); var onLoaded = (function(data){ this.parseJson(data); @@ -110,10 +110,11 @@ MapBoundLayer.prototype.parseJson = function(json) { } } + /* for (var i = 0, li = this.credits.length; i < li; i++) { var credit = this.map.getCreditById(this.credits[i]); //this.creditsNumbers.push(credit ? credit.id : null); - } + }*/ break; } @@ -124,7 +125,7 @@ MapBoundLayer.prototype.kill = function() { }; -MapBoundLayer.prototype.setOptions = function(options) { +MapBoundLayer.prototype.setOptions = function() { }; diff --git a/src/core/map/cache.js b/src/core/map/cache.js index 38605db9..7138437a 100755 --- a/src/core/map/cache.js +++ b/src/core/map/cache.js @@ -127,13 +127,13 @@ MapCache.prototype.remove = function(item) { //if (item != this.last && item != this.first) { if (!item.prev) { - debugger; + //debugger; } else { item.prev.next = item.next; } if (!item.next) { - debugger; + //debugger; } else { item.next.prev = item.prev; } diff --git a/src/core/map/camera.js b/src/core/map/camera.js index 436b1014..de7d4823 100755 --- a/src/core/map/camera.js +++ b/src/core/map/camera.js @@ -22,10 +22,7 @@ var MapCamera = function(map) { MapCamera.prototype.update = function() { - var controlMode = 'observer'; var map = this.map; - var position = [0,0,0]; - var orientation = map.position.getOrientation(); //check position orientaion ... map.position.check(); diff --git a/src/core/map/config.js b/src/core/map/config.js index 5734a4b3..b5c8380c 100755 --- a/src/core/map/config.js +++ b/src/core/map/config.js @@ -1,7 +1,6 @@ import MapBoundLayer_ from './bound-layer'; import MapCredit_ from './credit'; -import MapPosition_ from './position'; import MapRefFrame_ from './refframe'; import MapView_ from './view'; import MapSrs_ from './srs'; @@ -10,7 +9,6 @@ import MapVirtualSurface_ from './virtual-surface'; import MapStylesheet_ from './stylesheet'; //get rid of compiler mess -var MapPosition = MapPosition_; var MapCredit = MapCredit_; var MapBoundLayer = MapBoundLayer_; var MapRefFrame = MapRefFrame_; diff --git a/src/core/map/convert.js b/src/core/map/convert.js index 340f2aee..df77731c 100755 --- a/src/core/map/convert.js +++ b/src/core/map/convert.js @@ -1,13 +1,11 @@ import {mat4 as mat4_} from '../utils/matrix'; import {math as math_} from '../utils/math'; -import MapPosition_ from './position'; import GeographicLib_ from 'geographiclib'; //get rid of compiler mess var mat4 = mat4_; var math = math_; -var MapPosition = MapPosition_; var GeographicLib = GeographicLib_; @@ -36,8 +34,6 @@ MapConvert.prototype.movePositionCoordsTo = function(position, azimuth, distance position.setCoords2([coords[0] + (forward[0]*distance), coords[1] + (forward[1]*distance)]); } else { - var navigationSrsInfo = this.map.getNavigationSrs().getSrsInfo(); - var geod = new GeographicLib.Geodesic.Geodesic(navigationSrsInfo['a'], (navigationSrsInfo['a'] / navigationSrsInfo['b']) - 1.0); @@ -75,7 +71,7 @@ MapConvert.prototype.convertPositionViewMode = function(position, mode) { this.convertPositionHeightMode(position, 'fix', true); } - var distance = position.getViewDistance(); + var distance = position.getViewDistance(), coords; var orientation = position.getOrientation(); //get height delta @@ -91,12 +87,12 @@ MapConvert.prototype.convertPositionViewMode = function(position, mode) { var forward = [-Math.sin(yaw), Math.cos(yaw)]; //get center coords - var coords = position.getCoords(); + coords = position.getCoords(); coords[0] = coords[0] + (forward[0] * distance); coords[1] = coords[1] + (forward[1] * distance); } else { this.movePositionCoordsTo(position, -orientation[0], distance); - var coords = position.getCoords(); + coords = position.getCoords(); } coords[2] -= heightDelta; @@ -107,7 +103,7 @@ MapConvert.prototype.convertPositionViewMode = function(position, mode) { } } else if (mode == 'subj') { - var coords = this.getPositionCameraCoords(position, position.getHeightMode()); + coords = this.getPositionCameraCoords(position, position.getHeightMode()); position.setCoords(coords); //TODO: take in accout planet ellipsoid @@ -149,15 +145,15 @@ MapConvert.prototype.getPositionCameraCoords = function(position, heightMode) { var rotMatrix = mat4.create(); mat4.multiply(math.rotationMatrix(2, math.radians(-orientation[0])), math.rotationMatrix(0, math.radians(orientation[1])), rotMatrix); + var coords, terrainHeight = 0, surfaceHeight, lod = -1; + if (position.getViewMode() == 'obj') { - var coords = position.getCoords(); - var terrainHeight = 0; - var lod = -1; + coords = position.getCoords(); //convert height to fix if (position.getHeightMode() == 'float') { lod = this.measure.getOptimalHeightLod(coords, position.getViewExtent(), this.config.mapNavSamplesPerViewExtent); - var surfaceHeight = this.measure.getSurfaceHeight(coords, lod); + surfaceHeight = this.measure.getSurfaceHeight(coords, lod); terrainHeight = surfaceHeight[0]; } @@ -188,7 +184,7 @@ MapConvert.prototype.getPositionCameraCoords = function(position, heightMode) { lod = this.measure.getOptimalHeightLod(coords, position.getViewExtent(), this.config.mapNavSamplesPerViewExtent); } - var surfaceHeight = this.measure.getSurfaceHeight(coords, lod); + surfaceHeight = this.measure.getSurfaceHeight(coords, lod); coords[2] -= surfaceHeight[0]; return coords; @@ -199,11 +195,11 @@ MapConvert.prototype.getPositionCameraCoords = function(position, heightMode) { if (position.getHeightMode() == heightMode) { return position.getCoords(); } else { - var lod = this.measure.getOptimalHeightLod(position.getCoords(), position.getViewExtent(), this.config.mapNavSamplesPerViewExtent); - var surfaceHeight = this.measure.getSurfaceHeight(position.getCoords(), lod); + lod = this.measure.getOptimalHeightLod(position.getCoords(), position.getViewExtent(), this.config.mapNavSamplesPerViewExtent); + surfaceHeight = this.measure.getSurfaceHeight(position.getCoords(), lod); //height += surfaceHeight[0]; - var coords = position.getCoords(); + coords = position.getCoords(); if (heightMode == 'fix') { coords[2] += surfaceHeight[0]; @@ -250,14 +246,15 @@ MapConvert.prototype.getPositionCameraSpaceCoords = function(position, lod) { MapConvert.prototype.getPositionCanvasCoords = function(position, lod, physical) { + var worldPos; if (physical) { var camPos = this.map.camera.position; var coords = position.getCoords(); - var worldPos = [coords[0] - camPos[0], + worldPos = [coords[0] - camPos[0], coords[1] - camPos[1], coords[2] - camPos[2]]; } else { - var worldPos = this.getPositionCameraSpaceCoords(position, lod); + worldPos = this.getPositionCameraSpaceCoords(position, lod); } return this.map.renderer.project2(worldPos, this.map.camera.getMvpMatrix()); diff --git a/src/core/map/draw-tiles.js b/src/core/map/draw-tiles.js index 70d7956a..b69dc40b 100755 --- a/src/core/map/draw-tiles.js +++ b/src/core/map/draw-tiles.js @@ -101,17 +101,19 @@ MapDrawTiles.prototype.drawSurfaceTile = function(tile, node, cameraPos, pixelSi MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, priority, preventRedener, preventLoad, checkGpu) { + var path; + if (!tile.surfaceMesh) { if (tile.resourceSurface.virtual) { return true; //debugger; } - var path = tile.resourceSurface.getMeshUrl(tile.id); + path = tile.resourceSurface.getMeshUrl(tile.id); tile.surfaceMesh = tile.resources.getMesh(path, tile); } - var draw = this.draw; + var draw = this.draw, texture, layer, credits; var channel = draw.drawChannel; var ret = false; @@ -166,18 +168,19 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, tile.boundsDebug = {}; //used for inspector var specificity = 0; + var i, li, j, lj, k, lk, surface; if (tile.surface.glue) { var surfaces = tile.surface.id; - for (var i = 0, li = surfaces.length; i < li; i++) { - var surface = this.map.getSurface(surfaces[i]); + for (i = 0, li = surfaces.length; i < li; i++) { + surface = this.map.getSurface(surfaces[i]); if (surface) { specificity = Math.max(specificity, surface.specificity); } } //set credits - for (var k = 0, lk = node.credits.length; k < lk; k++) { + for (k = 0, lk = node.credits.length; k < lk; k++) { tile.glueImageryCredits[node.credits[k]] = specificity; } @@ -185,12 +188,12 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, specificity = tile.surface.specificity; //set credits - for (var k = 0, lk = node.credits.length; k < lk; k++) { + for (k = 0, lk = node.credits.length; k < lk; k++) { tile.imageryCredits[node.credits[k]] = specificity; } } - for (var i = 0, li = submeshes.length; i < li; i++) { + for (i = 0, li = submeshes.length; i < li; i++) { var submesh = submeshes[i]; //debug bbox @@ -205,7 +208,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, this.updateTileBounds(tile, submeshes); } - var surface = tile.resourceSurface; + surface = tile.resourceSurface; if (tile.resourceSurface.glue /*&& submesh.surfaceReference != 0*/) { //glue have multiple surfaces per tile surface = tile.resourceSurface.getSurfaceReference(submesh.surfaceReference); } @@ -221,7 +224,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, if (bounds.transparent) { if (submesh.internalUVs) { //draw surface if (tile.surfaceTextures[i] == null) { - var path = tile.resourceSurface.getTextureUrl(tile.id, i); + path = tile.resourceSurface.getTextureUrl(tile.id, i); tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true); } @@ -240,8 +243,8 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, }); var layers = bounds.sequence; - for (var j = 0, lj = layers.length; j < lj; j++) { - var texture = tile.boundTextures[layers[j]]; + for (j = 0, lj = layers.length; j < lj; j++) { + texture = tile.boundTextures[layers[j]]; if (texture) { //debug stuff @@ -251,9 +254,9 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, tile.boundsDebug[surface.id].push(layers[j]); //set credits - var layer = tile.boundLayers[layers[j]]; - var credits = layer.credits; - for (var k = 0, lk = credits.length; k < lk; k++) { + layer = tile.boundLayers[layers[j]]; + credits = layer.credits; + for (k = 0, lk = credits.length; k < lk; k++) { tile.imageryCredits[credits[k]] = layer.specificity; } @@ -282,7 +285,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, }); } else { var layerId = bounds.sequence[bounds.sequence.length-1]; - var texture = tile.boundTextures[layerId]; + texture = tile.boundTextures[layerId]; if (texture) { //debug stuff @@ -292,9 +295,9 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, tile.boundsDebug[surface.id].push(layerId); //set credits - var layer = tile.boundLayers[layerId]; - var credits = layer.credits; - for (var k = 0, lk = credits.length; k < lk; k++) { + layer = tile.boundLayers[layerId]; + credits = layer.credits; + for (k = 0, lk = credits.length; k < lk; k++) { tile.imageryCredits[credits[k]] = layer.specificity; } @@ -311,10 +314,10 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, } else { if (submesh.textureLayer) { - var layer = this.map.getBoundLayerByNumber(submesh.textureLayer); + layer = this.map.getBoundLayerByNumber(submesh.textureLayer); if (layer) { - var texture = tile.boundTextures[layer.id]; + texture = tile.boundTextures[layer.id]; if (texture) { @@ -325,9 +328,9 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, tile.boundsDebug[surface.id].push(layer.id); //set credits - var layer = tile.boundLayers[layer.id]; - var credits = layer.credits; - for (var k = 0, lk = credits.length; k < lk; k++) { + layer = tile.boundLayers[layer.id]; + credits = layer.credits; + for (k = 0, lk = credits.length; k < lk; k++) { tile.imageryCredits[credits[k]] = layer.specificity; } @@ -346,7 +349,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, if (submesh.internalUVs) { //draw surface if (tile.surfaceTextures[i] == null) { - var path = tile.resourceSurface.getTextureUrl(tile.id, i); + path = tile.resourceSurface.getTextureUrl(tile.id, i); tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true); } @@ -374,7 +377,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, } else if (submesh.internalUVs) { if (tile.surfaceTextures[i] == null) { - var path = tile.resourceSurface.getTextureUrl(tile.id, i); + path = tile.resourceSurface.getTextureUrl(tile.id, i); tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true); } //else { tile.drawCommands[0].push({ @@ -391,7 +394,7 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, } else if (submesh.internalUVs) { if (tile.surfaceTextures[i] == null) { - var path = tile.resourceSurface.getTextureUrl(tile.id, i); + path = tile.resourceSurface.getTextureUrl(tile.id, i); tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true); } //else { tile.drawCommands[0].push({ @@ -552,10 +555,6 @@ MapDrawTiles.prototype.drawGeodataTile = function(tile, node, cameraPos, pixelSi }; -MapDrawTiles.prototype.updateTileRenderCommands = function(tile, submeshes) { - -}; - /*MapDrawTiles.prototype.updateTileBoundsDirectly = function(preventLoad, priority) { if (tile.surfaceMesh.isReady(preventLoad, priority) && !preventLoad) { @@ -627,7 +626,8 @@ MapDrawTiles.prototype.getTileTextureTransform = function(sourceTile, targetTile MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface, bound, fullUpdate) { - + var path, extraBound, layer, texture; + //search map view if (surface.boundLayerSequence.length > 0) { if (fullUpdate) { @@ -636,10 +636,10 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface var fullAndOpaqueCounter = 0; for (var j = 0, lj = surface.boundLayerSequence.length; j < lj; j++) { - var layer = surface.boundLayerSequence[j][0]; + layer = surface.boundLayerSequence[j][0]; if (layer && layer.ready && layer.hasTileOrInfluence(tile.id) && surface.boundLayerSequence[j][1] > 0) { - var extraBound = null; + extraBound = null; if (tile.id[0] > layer.lodRange[1]) { extraBound = { @@ -650,10 +650,10 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface }; } - var texture = tile.boundTextures[layer.id]; + texture = tile.boundTextures[layer.id]; if (!texture) { //TODO: make sure that we load only textures which we need - var path = layer.getUrl(tile.id); + path = layer.getUrl(tile.id); texture = tile.resources.getTexture(path, null, extraBound, {tile: tile, layer: layer}, tile, false); texture.isReady(true); //check for mask but do not load tile.boundTextures[layer.id] = texture; @@ -687,7 +687,7 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface //and remove all layer after first FullAndOpaque if (fullAndOpaqueCounter > 0) { var newSequence = []; - var firstFull = false; + //var firstFull = false; for (var i = bound.sequence.length - 1; i >= 0; i--) { var layerId = bound.sequence[i]; @@ -696,7 +696,7 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface newSequence.unshift(layerId); break; } else { - var texture = tile.boundTextures[layerId]; + texture = tile.boundTextures[layerId]; if (bound.alpha[layerId][1] < 1.0 || tile.boundLayers[layerId].isTransparent || @@ -712,9 +712,9 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface } } else if (surface.textureLayer != null) { //search surface if (fullUpdate) { - var layer = this.map.getBoundLayerById(surface.textureLayer); + layer = this.map.getBoundLayerById(surface.textureLayer); if (layer && layer.hasTileOrInfluence(tile.id)) { - var extraBound = null; + extraBound = null; if (tile.id[0] > layer.lodRange[1]) { extraBound = { @@ -728,17 +728,17 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface bound.sequence.push(layer.id); tile.boundLayers[layer.id] = layer; if (!tile.boundTextures[layer.id]) { - var path = layer.getUrl(tile.id); + path = layer.getUrl(tile.id); tile.boundTextures[layer.id] = tile.resources.getTexture(path, null, extraBound, {tile: tile, layer: layer}, tile, false); } } } } else { //search submeshes if (submesh.textureLayer != 0) { - var layer = this.map.getBoundLayerByNumber(submesh.textureLayer); + layer = this.map.getBoundLayerByNumber(submesh.textureLayer); if (layer && layer.hasTileOrInfluence(tile.id)) { - var extraBound = null; + extraBound = null; if (tile.id[0] > layer.lodRange[1]) { extraBound = { @@ -752,7 +752,7 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface //submeshes[j].textureLayerId = tile.id; tile.boundLayers[layer.id] = layer; if (!tile.boundTextures[layer.id]) { - var path = layer.getUrl(tile.id); + path = layer.getUrl(tile.id); tile.boundTextures[layer.id] = tile.resources.getTexture(path, null, extraBound, {tile: tile, layer: layer}, tile, false); } } @@ -761,8 +761,8 @@ MapDrawTiles.prototype.updateTileSurfaceBounds = function(tile, submesh, surface }; -MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixelSize) { - var debug = this.debug; +MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh) { + var debug = this.debug, pos; if (!debug.drawMeshBBox) { //if (this.drawCredits) { @@ -777,11 +777,11 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe var min = node.bbox.min; var max = node.bbox.max; - var pos = this.core.getRendererInterface().getCanvasCoords( + pos = this.core.getRendererInterface().getCanvasCoords( [(min[0] + (max[0] - min[0])*0.5) - cameraPos[0], (min[1] + (max[1] - min[1])*0.5) - cameraPos[1], (max[2]) - cameraPos[2]], - this.camera.getMvpMatrix()); + this.camera.getMvpMatrix()); pos[2] = pos[2] * 0.9992; } else { @@ -791,11 +791,11 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe var d = Math.sqrt(dx*dx + dy*dy + dz*dz); - var pos = this.core.getRendererInterface().getCanvasCoords( + pos = this.core.getRendererInterface().getCanvasCoords( [(node.bbox2[12] + node.bbox2[15] + node.bbox2[18] + node.bbox2[21])*0.25 + node.diskNormal[0] * d*0.1 - cameraPos[0], (node.bbox2[13] + node.bbox2[16] + node.bbox2[19] + node.bbox2[22])*0.25 + node.diskNormal[1] * d*0.1 - cameraPos[1], (node.bbox2[14] + node.bbox2[17] + node.bbox2[20] + node.bbox2[23])*0.25 + node.diskNormal[2] * d*0.1 - cameraPos[2]], - this.camera.getMvpMatrix()); + this.camera.getMvpMatrix()); /* var pos = this.core.getRendererInterface().getCanvasCoords( @@ -806,7 +806,7 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe */ } - var factor = debug.debugTextSize; + var factor = debug.debugTextSize, text, i, li; //draw lods if (debug.drawLods) { @@ -816,41 +816,41 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe //draw indices if (debug.drawIndices) { - var text = '' + tile.id[1] + ' ' + tile.id[2]; + text = '' + tile.id[1] + ' ' + tile.id[2]; this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]-11*factor), 4*factor, text, [0,1,1,1], pos[2]); } //draw positions if (debug.drawPositions) { - //var text = "" + min[0].toFixed(1) + " " + min[1].toFixed(1) + " " + min[2].toFixed(1); - //var text = "" + Math.floor(node.corners[0]) + " " + Math.floor(node.corners[1]) + " " + Math.floor(node.corners[2]) + " " + Math.floor(node.corners[3]); + //text = "" + min[0].toFixed(1) + " " + min[1].toFixed(1) + " " + min[2].toFixed(1); + //text = "" + Math.floor(node.corners[0]) + " " + Math.floor(node.corners[1]) + " " + Math.floor(node.corners[2]) + " " + Math.floor(node.corners[3]); var b = node.border2; if (b) { - var text = '' + Math.floor(b[0]) + ' ' + Math.floor(b[1]) + ' ' + Math.floor(b[2]) + ' ' + Math.floor(b[3]) + ' ' + Math.floor(b[4]) + ' ' + Math.floor(b[5]) + ' ' + Math.floor(b[6]) + ' ' + Math.floor(b[7]) + ' ' + Math.floor(b[8]); + text = '' + Math.floor(b[0]) + ' ' + Math.floor(b[1]) + ' ' + Math.floor(b[2]) + ' ' + Math.floor(b[3]) + ' ' + Math.floor(b[4]) + ' ' + Math.floor(b[5]) + ' ' + Math.floor(b[6]) + ' ' + Math.floor(b[7]) + ' ' + Math.floor(b[8]); this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]+3*factor), 4*factor, text, [0,1,1,1], pos[2]); } - var b = node.border; + b = node.border; if (b) { - var text = '' + Math.floor(b[0]) + ' ' + Math.floor(b[1]) + ' ' + Math.floor(b[2]) + ' ' + Math.floor(b[3]) + ' ' + Math.floor(b[4]) + ' ' + Math.floor(b[5]) + ' ' + Math.floor(b[6]) + ' ' + Math.floor(b[7]) + ' ' + Math.floor(b[8]); + text = '' + Math.floor(b[0]) + ' ' + Math.floor(b[1]) + ' ' + Math.floor(b[2]) + ' ' + Math.floor(b[3]) + ' ' + Math.floor(b[4]) + ' ' + Math.floor(b[5]) + ' ' + Math.floor(b[6]) + ' ' + Math.floor(b[7]) + ' ' + Math.floor(b[8]); this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]+10*factor), 4*factor, text, [0,1,1,1], pos[2]); } } //draw face count if (debug.drawFaceCount && mesh) { - var text = '' + mesh.faces + ' - ' + mesh.submeshes.length + ((tile.surface && tile.surface.glue) ? ' - 1' : ' - 0'); + text = '' + mesh.faces + ' - ' + mesh.submeshes.length + ((tile.surface && tile.surface.glue) ? ' - 1' : ' - 0'); this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]+10*factor), 4*factor, text, [0,1,0,1], pos[2]); } //draw order if (debug.drawOrder) { - var text = '' + this.drawTileCounter; + text = '' + this.drawTileCounter; this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]+10*factor), 4*factor, text, [0,1,0,1], pos[2]); } if (debug.drawSurfaces) { - var text = JSON.stringify(tile.surface.id); + text = JSON.stringify(tile.surface.id); if (node.alien) { text = '[A]' + text; } @@ -862,9 +862,9 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe var surface = tile.resourceSurface; if (surface.glue) { - for (var i = 0, li = surface.id.length; i < li; i++) { + for (i = 0, li = surface.id.length; i < li; i++) { if (tile.boundsDebug[surface.id[i]]) { - var text = '< ' + surface.id[i] + ' >'; + text = '< ' + surface.id[i] + ' >'; this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]+(10+i*7*2)*factor), 4*factor, text, [1,1,1,1], pos[2]); text = JSON.stringify(tile.boundsDebug[surface.id[i]]); this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]+(17+i*7*2)*factor), 4*factor, text, [1,1,1,1], pos[2]); @@ -872,7 +872,7 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe } } else if (tile.boundsDebug[surface.id]) { - var text = '< ' + surface.id + ' >'; + text = '< ' + surface.id + ' >'; this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]+10*factor), 4*factor, text, [1,1,1,1], pos[2]); text = JSON.stringify(tile.boundsDebug[surface.id]); @@ -882,7 +882,7 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe } if (debug.drawCredits) { - var text = '{ '; + text = '{ '; for (var key in tile.imageryCredits) { if (tile.imageryCredits[key]) { @@ -890,7 +890,7 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe } } - for (var key in tile.glueImageryCredits) { + for (key in tile.glueImageryCredits) { if (!tile.imageryCredits[key]) { text += key + ':' + tile.glueImageryCredits[key] + ', '; //text += key + ", "; @@ -904,7 +904,7 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe //draw distance if (debug.drawDistance) { - var text = '' + tile.distance.toFixed(2) + ' ' + tile.texelSize.toFixed(3) + ' ' + node.pixelSize.toFixed(3); + text = '' + tile.distance.toFixed(2) + ' ' + tile.texelSize.toFixed(3) + ' ' + node.pixelSize.toFixed(3); text += '--' + tile.texelSize2.toFixed(3); this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]+17*factor), 4*factor, text, [1,0,1,1], pos[2]); } @@ -912,7 +912,7 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe //draw node info if (debug.drawNodeInfo) { var children = ((node.flags & ((15)<<4))>>4); - var text = 'v' + node.metatile.version + '-' + node.flags.toString(2) + '-' + ((children & 1) ? '1' : '0') + ((children & 2) ? '1' : '0') + ((children & 4) ? '1' : '0') + ((children & 8) ? '1' : '0'); + text = 'v' + node.metatile.version + '-' + node.flags.toString(2) + '-' + ((children & 1) ? '1' : '0') + ((children & 2) ? '1' : '0') + ((children & 4) ? '1' : '0') + ((children & 8) ? '1' : '0'); text += '-' + node.minHeight + '/' + node.maxHeight+ '-' + Math.floor(node.minZ) + '/' + Math.floor(node.maxZ)+ '-' + Math.floor(node.surrogatez); this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]-18*factor), 4*factor, text, [1,0,1,1], pos[2]); } @@ -920,13 +920,13 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe //draw texture size if (debug.drawTextureSize && mesh) { var submeshes = mesh.submeshes; - for (var i = 0, li = submeshes.length; i < li; i++) { + for (i = 0, li = submeshes.length; i < li; i++) { if (submeshes[i].internalUVs) { var texture = tile.surfaceTextures[i]; if (texture && texture.gpuTexture) { - var text = '[' + i + ']: ' + texture.gpuTexture.width + ' x ' + texture.gpuTexture.height; + text = '[' + i + ']: ' + texture.gpuTexture.width + ' x ' + texture.gpuTexture.height; this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]+(17+i*7*2)*factor), 4*factor, text, [1,1,1,1], pos[2]); } } diff --git a/src/core/map/draw.js b/src/core/map/draw.js index ed9fb0a8..478895cb 100755 --- a/src/core/map/draw.js +++ b/src/core/map/draw.js @@ -213,6 +213,7 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { this.stats.renderBuild = 0; this.drawTileCounter = 0; var cameraPos = camera.position; + var i, li, j, lj, tile, tiles, tmp, layer, drawnTiles, nodeBuffer; if (map.freeLayersHaveGeodata && this.drawChannel == 0) { renderer.draw.clearJobBuffer(); @@ -230,9 +231,9 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { var single = replay.singleLod; if (replay.drawTiles && replay.drawnTiles) { - var tiles = replay.drawnTiles; - for (var i = 0, li = tiles.length; i < li; i++) { - var tile = tiles[i]; + tiles = replay.drawnTiles; + for (i = 0, li = tiles.length; i < li; i++) { + tile = tiles[i]; if ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod)) { drawTiles.drawSurfaceTile(tile, tile.metanode, cameraPos, tile.pixelSize, tile.priority, false, false); } @@ -240,9 +241,9 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { } if (replay.drawFreeTiles && replay.drawnFreeTiles) { - var tiles = replay.drawnFreeTiles; - for (var i = 0, li = tiles.length; i < li; i++) { - var tile = tiles[i]; + tiles = replay.drawnFreeTiles; + for (i = 0, li = tiles.length; i < li; i++) { + tile = tiles[i]; if ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod)) { drawTiles.drawSurfaceTile(tile, tile.metanode, cameraPos, tile.pixelSize, tile.priority, false, false); } @@ -250,11 +251,11 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { } if (replay.drawNodes && replay.tracedNodes) { - var tiles = replay.tracedNodes; - var tmp = debug.drawBBoxes; + tiles = replay.tracedNodes; + tmp = debug.drawBBoxes; debug.drawBBoxes = true; - for (var i = 0, li = tiles.length; i < li; i++) { - var tile = tiles[i]; + for (i = 0, li = tiles.length; i < li; i++) { + tile = tiles[i]; if ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod)) { drawTiles.drawTileInfo(tile, tile.metanode, cameraPos, tile.surfaceMesh, tile.pixelSize); } @@ -263,11 +264,11 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { } if (replay.drawFreeNodes && replay.tracedFreeNodes) { - var tiles = replay.tracedFreeNodes; - var tmp = debug.drawBBoxes; + tiles = replay.tracedFreeNodes; + tmp = debug.drawBBoxes; debug.drawBBoxes = true; - for (var i = 0, li = tiles.length; i < li; i++) { - var tile = tiles[i]; + for (i = 0, li = tiles.length; i < li; i++) { + tile = tiles[i]; if ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod)) { drawTiles.drawTileInfo(tile, tile.metanode, cameraPos, tile.surfaceMesh, tile.pixelSize); } @@ -281,10 +282,10 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { if (replay.drawLoaded && replay.loaded) { var loaded = replay.loaded; debug.drawBBoxes = true; - for (var i = 0, li = loaded.length; i < li; i++) { + for (i = 0, li = loaded.length; i < li; i++) { var file = loaded[i]; if (file && file.tile && file.tile.id) { - var tile = file.tile; + tile = file.tile; if (((singleIndex && i == index) || (!singleIndex && i <= index)) && ((single && tile.id[0] == lod) || (!single && tile.id[0] <= lod)) ) { if (tile.metanode) { @@ -311,7 +312,7 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { return; } - for (var i = 0, li = this.tileBuffer.length; i < li; i++) { //todo remove this + for (i = 0, li = this.tileBuffer.length; i < li; i++) { //todo remove this this.tileBuffer[i] = null; } @@ -320,13 +321,13 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { } if (replay.storeTiles) { //used only in inspectors - var drawnTiles = []; + drawnTiles = []; - for (var i = 0, li = this.tileBuffer.length; i < li; i++) { - var tiles = this.tileBuffer[i]; + for (i = 0, li = this.tileBuffer.length; i < li; i++) { + tiles = this.tileBuffer[i]; if (tiles) { - for (var j = 0, lj = tiles.length; j < lj; j++) { + for (j = 0, lj = tiles.length; j < lj; j++) { drawnTiles.push(tiles[j]); } } @@ -338,10 +339,10 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { } if (replay.storeNodes) { //used only in inspector - var nodeBuffer = []; + nodeBuffer = []; - for (var i = 0, li = replay.nodeBuffer.length; i < li; i++) { - var tile = replay.nodeBuffer[i]; + for (i = 0, li = replay.nodeBuffer.length; i < li; i++) { + tile = replay.nodeBuffer[i]; nodeBuffer.push(tile); } @@ -351,8 +352,8 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { } //draw free layers - for (var i = 0, li = map.freeLayerSequence.length; i < li; i++) { - var layer = map.freeLayerSequence[i]; + for (i = 0, li = map.freeLayerSequence.length; i < li; i++) { + layer = map.freeLayerSequence[i]; if (layer.ready && layer.tree && (!layer.geodata || (layer.stylesheet && layer.stylesheet.isReady())) && this.drawChannel == 0) { @@ -365,14 +366,14 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { } if (replay.storeFreeTiles) { //used only in inspector - var drawnTiles = []; + drawnTiles = []; - for (var i = 0, li = this.tileBuffer.length; i < li; i++) { - var tiles = this.tileBuffer[i]; + for (i = 0, li = this.tileBuffer.length; i < li; i++) { + tiles = this.tileBuffer[i]; if (tiles) { - for (var j = 0, lj = tiles.length; j < lj; j++) { - var tile = tiles[j]; + for (j = 0, lj = tiles.length; j < lj; j++) { + tile = tiles[j]; if (tile.surface && tile.surface.free) { //do no draw free layers drawnTiles.push(tile); } @@ -386,10 +387,10 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { } if (replay.storeFreeNodes) { //used only in inspector - var nodeBuffer = []; + nodeBuffer = []; - for (var i = 0, li = replay.nodeBuffer.length; i < li; i++) { - var tile = replay.nodeBuffer[i]; + for (i = 0, li = replay.nodeBuffer.length; i < li; i++) { + tile = replay.nodeBuffer[i]; if (tile.surface && tile.surface.free) { //do no draw free layers nodeBuffer.push(tile); } @@ -433,8 +434,8 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { var cameraPosToEarthCenter = [0,0,0,0]; vec3.normalize(camera.position, cameraPosToEarthCenter); - var horizAngle = Math.atan(1.0/(vec3.length(camera.position) / navigationSrsInfo['a'])); //cotan = cameraDistFromCenter / earthRadius - var horizAngle2 = (horizAngle / Math.PI * 180)*0.5; + //var horizAngle = Math.atan(1.0/(vec3.length(camera.position) / navigationSrsInfo['a'])); //cotan = cameraDistFromCenter / earthRadius + //var horizAngle2 = (horizAngle / Math.PI * 180)*0.5; var pos = map.getPosition(); var orientation = pos.getOrientation(); @@ -443,7 +444,7 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { var heightFactor = 1-Math.max(0,Math.min(1.0, camera.height / (atmoSize*(10+20*tiltFactor)))); heightFactor = heightFactor * heightFactor; - var params = [Math.max(2,heightFactor*128),0,0,0]; + var params = [Math.max(2,heightFactor*128),0,0,0], params2, params3; if (camera.height > earthRadius*2) { //prevent foggy earth from larger distance params[0] = 2-Math.min(1.0, (camera.height - earthRadius*2) / (earthRadius*2)); @@ -454,24 +455,22 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { earthRadius, renderer.progAtmo2, params, cameraPosToEarthCenter, null, true);// this.cameraHeight > atmoSize ? 1 : -1); var safetyFactor = 2.0; - var params = [safetyFactor, safetyFactor * ((earthRadius + atmoSize) / earthRadius), 0.25, safetyFactor* ((earthRadius + atmoSize) / earthRadius)]; + params = [safetyFactor, safetyFactor * ((earthRadius + atmoSize) / earthRadius), 0.25, safetyFactor* ((earthRadius + atmoSize) / earthRadius)]; var factor = (1 / (earthRadius) ) * safetyFactor; - var params2 = [camera.position[0] * factor, camera.position[1] * factor, camera.position[2] * factor, 1]; + params2 = [camera.position[0] * factor, camera.position[1] * factor, camera.position[2] * factor, 1]; var t1 = 1.4, t2 = 1.6; //previous value t1=1.1 if (camera.height > 60000) { //don render ground color in aura t1 = 1.4, t2 = 1.8; - - var params3 = [t2,1.0,t2,0]; + params3 = [t2,1.0,t2,0]; } else { - if (camera.height < 5000) { t1 = 1.05, t2 = 1.12; } - var params3 = [t1,5.2 / (t2-t1),t2,0]; + params3 = [t1,5.2 / (t2-t1),t2,0]; } gpu.setState(this.drawAuraState); @@ -616,8 +615,8 @@ MapDraw.prototype.processDrawCommands = function(cameraPos, commands, priority, } } else { - i = i; - //this should not happen + //i = i; + //this should not happen } break; @@ -645,18 +644,18 @@ MapDraw.prototype.drawMonoliticGeodata = function(surface) { return; } + var path; + if (surface.monoGeodata == null) { if (typeof surface.geodataUrl === 'object') { - var path = surface.geodataUrl; + path = surface.geodataUrl; } else { - var path = surface.getMonoGeodataUrl(surface.id); + path = surface.getMonoGeodataUrl(surface.id); } surface.monoGeodata = new MapGeodata(this.map, path, {tile:null, surface:surface}); } - var channel = this.drawChannel; - if (surface.monoGeodataCounter != surface.geodataCounter) { surface.monoGeodataView = null; surface.monoGeodataCounter = surface.geodataCounter; @@ -701,13 +700,13 @@ MapDraw.prototype.updateFogDensity = function() { // var density = Math.log(0.05) / (cameraVisibility * 10*(Math.max(5,-orientation[1])/90)); - var atmosphereHeight = 100000; + //var atmosphereHeight = 100000; //this.cameraHeight; //var density = Math.log(0.05) / (cameraVisibility * (Math.max(5,-orientation[1])/90)); var tiltFactor = (Math.max(5,-orientation[1])/90); - var heightFactor = 1-Math.max(0,Math.min(1.0,this.cameraHeight / atmosphereHeight)); + //var heightFactor = 1-Math.max(0,Math.min(1.0,this.cameraHeight / atmosphereHeight)); // var density = ((Math.log(0.05) / (cameraVisibility)) * tiltFactor * heightFactor); var density = Math.log(0.05) / ((cameraVisibility * Math.max(1,this.camera.height*0.0001))* tiltFactor); diff --git a/src/core/map/geodata-processor/processor.js b/src/core/map/geodata-processor/processor.js index f83ff046..5460cc2a 100755 --- a/src/core/map/geodata-processor/processor.js +++ b/src/core/map/geodata-processor/processor.js @@ -6,8 +6,9 @@ var MapGeodataProcessor = function(surface, listener) { this.listener = listener; this.ready = true; + // eslint-disable-next-line var worker = require('worker-loader?inline&fallback=false!./worker-main'); -// var worker = require("worker-loader?inline!./worker-main"); + //var worker = require("worker-loader?inline!./worker-main"); //debug worker this.processWorker = new worker; @@ -33,7 +34,7 @@ MapGeodataProcessor.prototype.kill = function() { }; -MapGeodataProcessor.prototype.isReady = function(listener) { +MapGeodataProcessor.prototype.isReady = function() { return this.ready || this.killed; }; diff --git a/src/core/map/geodata-processor/worker-style.js b/src/core/map/geodata-processor/worker-style.js index c7f643b2..c26c1022 100755 --- a/src/core/map/geodata-processor/worker-style.js +++ b/src/core/map/geodata-processor/worker-style.js @@ -261,7 +261,9 @@ var logError = function(errorType, layerId, key, value, index, subkey) { } if (str) { - throw str; + // eslint-disable-next-line + console.log(str); + //throw str; } }; diff --git a/src/core/map/geodata-view.js b/src/core/map/geodata-view.js index 8bbd403a..96cd9b85 100755 --- a/src/core/map/geodata-view.js +++ b/src/core/map/geodata-view.js @@ -181,7 +181,7 @@ MapGeodataView.prototype.getWorldMatrix = function(bbox, geoPos, matrix) { m[8] = 0; m[9] = 0; m[10] = bbox.side(2); m[11] = 0; m[12] = this.bbox.min[0] - geoPos[0]; m[13] = this.bbox.min[1] - geoPos[1]; m[14] = this.bbox.min[2] - geoPos[2]; m[15] = 1;*/ } else { - var m = mat4.create(); + m = mat4.create(); mat4.multiply( math.translationMatrix(bbox.min[0] - geoPos[0], bbox.min[1] - geoPos[1], bbox.min[2] - geoPos[2]), math.scaleMatrix(1, 1, 1), m); diff --git a/src/core/map/geodata.js b/src/core/map/geodata.js index 9ed6c425..2be24d04 100755 --- a/src/core/map/geodata.js +++ b/src/core/map/geodata.js @@ -53,7 +53,7 @@ MapGeodata.prototype.killGeodata = function(killedByCache) { }; -MapGeodata.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu) { +MapGeodata.prototype.isReady = function(doNotLoad, priority) { var doNotUseGpu = (this.map.stats.gpuRenderUsed >= this.map.maxGpuUsed); doNotLoad = doNotLoad || doNotUseGpu; diff --git a/src/core/map/interface.js b/src/core/map/interface.js index 79ab639e..849c1008 100755 --- a/src/core/map/interface.js +++ b/src/core/map/interface.js @@ -23,7 +23,7 @@ MapInterface.prototype.setPosition = function(position) { }; -MapInterface.prototype.getPosition = function(type) { +MapInterface.prototype.getPosition = function() { return this.map.getPosition(); }; diff --git a/src/core/map/loader.js b/src/core/map/loader.js index b75d7760..3e407ebf 100755 --- a/src/core/map/loader.js +++ b/src/core/map/loader.js @@ -18,7 +18,7 @@ var MapLoader = function(map, maxThreads) { }; -MapLoader.prototype.updateThreadCount = function(channel) { +MapLoader.prototype.updateThreadCount = function() { this.maxThreads = this.map.config.mapDownloadThreads; this.maxPending = Math.max(20, this.maxThreads * 2); this.fadeout = (this.maxPending-1) / this.maxPending; @@ -41,7 +41,7 @@ MapLoader.prototype.load = function(path, downloadFunction, priority, id, kind) var pending = this.pending[this.channel]; // put the request to the beginning of the pending list - var index = this.map.searchArrayIndexById(pending, path); + index = this.map.searchArrayIndexById(pending, path); if (index != -1) { pending[index].priority = priority; } else { @@ -97,10 +97,10 @@ MapLoader.prototype.onLoaded = function(item) { threads : this.downloading.length }); - var a = (timer - this.downloadingTime[index]); - if (Number.isNaN(a)) { - a = a; - } + //var a = (timer - this.downloadingTime[index]); + //if (Number.isNaN(a)) { + //a = a; + //} } @@ -157,9 +157,6 @@ MapLoader.prototype.updateChannel = function(channel) { } var timer = performance.now(); - var stats = this.map.stats; - - var recordStats = this.map.draw.replay.storeLoaded; while (pending.length > 0 && this.usedThreads < this.maxThreads) { var item = pending.shift(); diff --git a/src/core/map/map.js b/src/core/map/map.js index 8e332f69..5b4b2b3e 100755 --- a/src/core/map/map.js +++ b/src/core/map/map.js @@ -3,7 +3,6 @@ import {vec3 as vec3_} from '../utils/matrix'; import {utils as utils_} from '../utils/utils'; import {platform as platform_} from '../utils/platform'; import MapView_ from './view'; -import MapVirtualSurface_ from './virtual-surface'; import MapSurfaceTree_ from './surface-tree'; import MapResourceTree_ from './resource-tree'; import MapSrs_ from './srs'; @@ -25,7 +24,6 @@ var vec3 = vec3_; var utils = utils_; var platform = platform_; var MapView = MapView_; -var MapVirtualSurface = MapVirtualSurface_; var MapSurfaceTree = MapSurfaceTree_; var MapResourceTree = MapResourceTree_; var MapSrs = MapSrs_; @@ -195,11 +193,11 @@ Map.prototype.getRendererInterface = function() { }; -Map.prototype.setOption = function(key, value) { +Map.prototype.setOption = function(/*key, value*/) { }; -Map.prototype.getOption = function(key) { +Map.prototype.getOption = function(/*key*/) { }; @@ -249,7 +247,8 @@ Map.prototype.getVisibleCredits = function() { var imagery = this.visibleCredits.imagery; var glueImagery = this.visibleCredits.glueImagery; var imageryArray = []; - var imagerySpecificity = []; + var imagerySpecificity = []; + var i, li, t, sorted; for (var key in glueImagery) { if (!imagery[key]) { @@ -259,18 +258,18 @@ Map.prototype.getVisibleCredits = function() { this.visibleCredits.glueImagery = {}; - for (var key in imagery) { + for (key in imagery) { imageryArray.push(key); imagerySpecificity.push(imagery[key]); } //sort imagery do { - var sorted = true; + sorted = true; - for (var i = 0, li = imagerySpecificity.length - 1; i < li; i++) { + for (i = 0, li = imagerySpecificity.length - 1; i < li; i++) { if (imagerySpecificity[i] < imagerySpecificity[i+1]) { - var t = imagerySpecificity[i]; + t = imagerySpecificity[i]; imagerySpecificity[i] = imagerySpecificity[i+1]; imagerySpecificity[i+1] = t; t = imageryArray[i]; @@ -286,18 +285,18 @@ Map.prototype.getVisibleCredits = function() { var mapdataArray = []; var mapdataSpecificity = []; - for (var key in mapdata) { + for (key in mapdata) { mapdataArray.push(key); mapdataSpecificity.push(mapdata[key]); } //sort imagery do { - var sorted = true; + sorted = true; - for (var i = 0, li = mapdataSpecificity.length - 1; i < li; i++) { + for (i = 0, li = mapdataSpecificity.length - 1; i < li; i++) { if (mapdataSpecificity[i] < mapdataSpecificity[i+1]) { - var t = mapdataSpecificity[i]; + t = mapdataSpecificity[i]; mapdataSpecificity[i] = mapdataSpecificity[i+1]; mapdataSpecificity[i+1] = t; t = mapdataArray[i]; @@ -368,7 +367,7 @@ Map.prototype.getBoundLayerOptions = function(id) { }; -Map.prototype.removeBoundLayer = function(id, layer) { +Map.prototype.removeBoundLayer = function(id) { if (this.boundLayers[id]) { this.boundLayers[id].kill(); this.boundLayers[id] = null; @@ -559,7 +558,7 @@ Map.prototype.getStylesheets = function() { }; -Map.prototype.getStylesheetData = function(id, data) { +Map.prototype.getStylesheetData = function(id) { var stylesheet = this.getStylesheet(id); if (stylesheet) { @@ -671,7 +670,7 @@ Map.prototype.setPosition = function(pos) { }; -Map.prototype.getPhysicalSrs = function(coords, source, destination) { +Map.prototype.getPhysicalSrs = function() { return this.referenceFrame.model.physicalSrs; }; @@ -814,15 +813,15 @@ Map.prototype.getHitCoords = function(screenX, screenY, mode, lod) { var cameraPos = this.camera.position; var worldPos; - var ray = cameraSpaceCoords[4]; + var ray = cameraSpaceCoords[4], a, d; if (this.getNavigationSrs().isProjected()) { //plane fallback var planePos = [0,0,Math.min(-1000,this.referenceFrame.getGlobalHeightRange()[0])]; var planeNormal = [0,0,1]; - var d = vec3.dot(planeNormal, ray); //minification is wrong there + d = vec3.dot(planeNormal, ray); //minification is wrong there //if (d > 1e-6) { - var a = [planePos[0] - cameraPos[0], planePos[1] - cameraPos[1], planePos[2] - cameraPos[2]]; + a = [planePos[0] - cameraPos[0], planePos[1] - cameraPos[1], planePos[2] - cameraPos[2]]; t = vec3.dot(a, planeNormal) / d; //var t = (vec3.dot(cameraPos, planeNormal) + (-500)) / d; @@ -842,10 +841,10 @@ Map.prototype.getHitCoords = function(screenX, screenY, mode, lod) { var planetRadius = navigationSrsInfo['b'] + this.referenceFrame.getGlobalHeightRange()[0]; var offset = [cameraPos[0], cameraPos[1], cameraPos[2]]; - var a = vec3.dot(ray, ray); //minification is wrong there + a = vec3.dot(ray, ray); //minification is wrong there var b = 2 * vec3.dot(ray, offset); var c = vec3.dot(offset, offset) - planetRadius * planetRadius; - var d = b * b - 4 * a * c; + d = b * b - 4 * a * c; if (d > 0) { d = Math.sqrt(d); @@ -876,7 +875,7 @@ Map.prototype.getHitCoords = function(screenX, screenY, mode, lod) { var navCoords = this.convert.convertCoords(worldPos, 'physical', 'navigation'); if (mode == 'float') { - var lod = (lod != null) ? lod : this.measure.getOptimalHeightLod(navCoords, 100, this.config.mapNavSamplesPerViewExtent); + lod = (lod != null) ? lod : this.measure.getOptimalHeightLod(navCoords, 100, this.config.mapNavSamplesPerViewExtent); var surfaceHeight = this.measure.getSurfaceHeight(navCoords, lod); navCoords[2] -= surfaceHeight[0]; } @@ -902,12 +901,13 @@ Map.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { } var res = this.renderer.hitTestGeoLayers(screenX, screenY, mode); + var relatedEvents; if (res[0]) { //do we hit something? //console.log(JSON.stringify([id, JSON.stringify(this.hoverFeatureList[id])])); var id = (res[1]) + (res[2]<<8); - var elementId = (res[3]) + (res[4]<<8); + //var elementId = (res[3]) + (res[4]<<8); var feature = this.hoverFeatureList[id]; @@ -923,7 +923,7 @@ Map.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { this.hoverFeatureId = null; } - var relatedEvents = []; + relatedEvents = []; if (this.hoverFeatureId != this.lastHoverFeatureId) { if (this.lastHoverFeatureId != null) { @@ -954,7 +954,7 @@ Map.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { } } } else { - var relatedEvents = []; + relatedEvents = []; if (mode == 'hover') { this.lastHoverFeature = this.hoverFeature; @@ -977,9 +977,10 @@ Map.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { Map.prototype.applyCredits = function(tile) { + var value, value2; for (var key in tile.imageryCredits) { - var value = tile.imageryCredits[key]; - var value2 = this.visibleCredits.imagery[key]; + value = tile.imageryCredits[key]; + value2 = this.visibleCredits.imagery[key]; if (value2) { this.visibleCredits.imagery[key] = value > value2 ? value : value2; @@ -987,9 +988,9 @@ Map.prototype.applyCredits = function(tile) { this.visibleCredits.imagery[key] = value; } } - for (var key in tile.glueImageryCredits) { - var value = tile.glueImageryCredits[key]; - var value2 = this.visibleCredits.imagery[key]; + for (key in tile.glueImageryCredits) { + value = tile.glueImageryCredits[key]; + value2 = this.visibleCredits.imagery[key]; if (value2) { this.visibleCredits.glueImagery[key] = value > value2 ? value : value2; @@ -997,9 +998,9 @@ Map.prototype.applyCredits = function(tile) { this.visibleCredits.glueImagery[key] = value; } } - for (var key in tile.mapdataCredits) { - var value = tile.mapdataCredits[key]; - var value2 = this.visibleCredits.mapdata[key]; + for (key in tile.mapdataCredits) { + value = tile.mapdataCredits[key]; + value2 = this.visibleCredits.mapdata[key]; if (value2) { this.visibleCredits.mapdata[key] = value > value2 ? value : value2; @@ -1073,7 +1074,7 @@ Map.prototype.update = function() { this.dirty = true; } - var dirty = this.dirty; + var dirty = this.dirty, result; this.stats.begin(dirty); this.loader.update(); @@ -1104,7 +1105,7 @@ Map.prototype.update = function() { //this.updateGeoHitmap = this.dirty; if (this.hoverEvent != null) { - var result = this.hitTestGeoLayers(this.hoverEvent[0], this.hoverEvent[1], 'hover'); + result = this.hitTestGeoLayers(this.hoverEvent[0], this.hoverEvent[1], 'hover'); if (result[1] && result[0] != null) { this.core.callListener('geo-feature-hover', {'feature': result[0][0], 'canvas-coords':this.renderer.project2(result[0][1], this.camera.getMvpMatrix()), @@ -1138,7 +1139,7 @@ Map.prototype.update = function() { } if (this.clickEvent != null) { - var result = this.hitTestGeoLayers(this.clickEvent[0], this.clickEvent[1], 'click'); + result = this.hitTestGeoLayers(this.clickEvent[0], this.clickEvent[1], 'click'); if (result[1] && result[0] != null) { this.core.callListener('geo-feature-click', {'feature': result[0][0], 'canvas-coords':this.renderer.project2(result[0][1], this.camera.getMvpMatrix()), diff --git a/src/core/map/measure.js b/src/core/map/measure.js index ae45a23f..a49c4d13 100755 --- a/src/core/map/measure.js +++ b/src/core/map/measure.js @@ -28,8 +28,8 @@ var MapMeasure = function(map) { MapMeasure.prototype.getSurfaceHeight = function(coords, lod, storeStats, node, nodeCoords, coordsArray) { if (!node) { var result = this.getSpatialDivisionNode(coords); - var node = result[0]; - var nodeCoords = result[1]; + node = result[0]; + nodeCoords = result[1]; } if (!this.config.mapHeightLodBlend) { @@ -61,8 +61,7 @@ MapMeasure.prototype.getSurfaceHeight = function(coords, lod, storeStats, node, tree.traceHeight(root, params, false); - var heightMap = params.heightMap; - var metanode = params.metanode; + var metanode = params.metanode, i, li, height; if (params.heightMap != null) { if (storeStats) { @@ -73,22 +72,22 @@ MapMeasure.prototype.getSurfaceHeight = function(coords, lod, storeStats, node, } var res = metanode.id[0] >= Math.ceil(lod); - var arrayRes; + var arrayRes, height1, height2; if (this.config.mapHeightLodBlend && metanode.id[0] > 0 && params.parent && params.parent.heightMap && lod <= metanode.id[0]) { - var height1 = this.getHeightmapValue(nodeCoords, params.parent.metanode, params.parent); - var height2 = this.getHeightmapValue(nodeCoords, metanode, params); + height1 = this.getHeightmapValue(nodeCoords, params.parent.metanode, params.parent); + height2 = this.getHeightmapValue(nodeCoords, metanode, params); var factor = lod - Math.floor(lod); - var height = height1 + (height2 - height1) * factor; + height = height1 + (height2 - height1) * factor; if (coordsArray) { arrayRes = new Array(coordsArray.length); - for (var i = 0, li = coordsArray.length; i < li; i++) { + for (i = 0, li = coordsArray.length; i < li; i++) { var nodeCoords2 = coordsArray[i];//node.getInnerCoords(coordsArray[i]); - var height1 = this.getHeightmapValue(nodeCoords2, params.parent.metanode, params.parent); - var height2 = this.getHeightmapValue(nodeCoords2, metanode, params); + height1 = this.getHeightmapValue(nodeCoords2, params.parent.metanode, params.parent); + height2 = this.getHeightmapValue(nodeCoords2, metanode, params); arrayRes[i] = [height1 + (height2 - height1) * factor, res, true]; } @@ -96,13 +95,13 @@ MapMeasure.prototype.getSurfaceHeight = function(coords, lod, storeStats, node, //console.log("lod: " + lod + " h1: " + height1 + " h2: " + height2 + " h: " + height); } else { - var height = this.getHeightmapValue(nodeCoords, metanode, params); + height = this.getHeightmapValue(nodeCoords, metanode, params); if (coordsArray) { arrayRes = new Array(coordsArray.length); - for (var i = 0, li = coordsArray.length; i < li; i++) { - var height2 = this.getHeightmapValue(coordsArray[i], metanode, params); + for (i = 0, li = coordsArray.length; i < li; i++) { + height2 = this.getHeightmapValue(coordsArray[i], metanode, params); arrayRes[i] = [height2, res, true]; } @@ -112,7 +111,7 @@ MapMeasure.prototype.getSurfaceHeight = function(coords, lod, storeStats, node, return [height, res, true, null, null, arrayRes]; } else if (metanode != null /*&& metanode.id[0] == lod && !metanode.hasNavtile()*/){ - var res = this.getSurfaceHeightNodeOnly(coords, lod + 8, storeStats, lod, null, node, nodeCoords, coordsArray); + res = this.getSurfaceHeightNodeOnly(coords, lod + 8, storeStats, lod, null, node, nodeCoords, coordsArray); //console.log("lod2: " + lod + " h: " + height[0]); return [res[0], res[1], true, null, null, res[5]]; @@ -133,13 +132,13 @@ MapMeasure.prototype.getSurfaceHeight = function(coords, lod, storeStats, node, MapMeasure.prototype.getSurfaceHeightNodeOnly = function(coords, lod, storeStats, statsLod, deltaSample, node, nodeCoords, coordsArray) { - var arrayRes; + var arrayRes, height, stats = this.map.stats; if (!deltaSample) { if (!node) { var result = this.getSpatialDivisionNode(coords); - var node = result[0]; - var nodeCoords = result[1]; + node = result[0]; + nodeCoords = result[1]; } if (coordsArray) { @@ -151,8 +150,8 @@ MapMeasure.prototype.getSurfaceHeightNodeOnly = function(coords, lod, storeStats } } else { - var node = deltaSample[0]; - var nodeCoords = deltaSample[1]; + node = deltaSample[0]; + nodeCoords = deltaSample[1]; } if (!this.config.mapHeightLodBlend) { @@ -185,7 +184,7 @@ MapMeasure.prototype.getSurfaceHeightNodeOnly = function(coords, lod, storeStats var w0 = (res1[0] + (res2[0] - res1[0])*fx); var w1 = (res3[0] + (res4[0] - res3[0])*fx); - var height = (w0 + (w1 - w0)*fy); + height = (w0 + (w1 - w0)*fy); //console.log("h: " + height + "fx: " + fx + "fy: " + fy + "s1234: " + res1[0] + " " + res2[0] + " " + res3[0] + " " + res4[0]); /* @@ -231,7 +230,6 @@ MapMeasure.prototype.getSurfaceHeightNodeOnly = function(coords, lod, storeStats //console.log("lod2: " + lod + " nodelod: " + metanode.id[0] + " h: " + center[2]/1.55); if (storeStats) { - var stats = this.map.stats; stats.heightClass = 1; stats.heightLod = statsLod; stats.heightNode = metanode.id[0]; @@ -242,9 +240,9 @@ MapMeasure.prototype.getSurfaceHeightNodeOnly = function(coords, lod, storeStats var center2 = this.convert.convertCoords(params.parent.metanode.bbox.center(), 'physical', 'navigation'); var factor = lod - Math.floor(lod); - var height = center[2] + (center2[2] - center[2]) * factor; + height = center[2] + (center2[2] - center[2]) * factor; - var extetnts = params.extents; + //extetnts = params.extents; return [height, true, true, params.extents, metanode, arrayRes]; //console.log("lod: " + lod + " h1: " + center[2] + " h2: " + center2[2] + " h: " + height); } else { @@ -263,7 +261,6 @@ MapMeasure.prototype.getSurfaceHeightNodeOnly = function(coords, lod, storeStats //console.log("lod3: " + lod + " h: 0"); if (storeStats) { - var stats = this.map.stats; stats.heightClass = 0; stats.heightLod = statsLod; stats.heightNode = 0; @@ -350,16 +347,16 @@ MapMeasure.prototype.getSpatialDivisionNodeAndExtents = function(id) { var nodes = this.map.referenceFrame.getSpatialDivisionNodes(); var bestNode = null; - var bestLod = -1; - var bestNodeCoords = [0,0]; - var bestExtents = {ll:[0,0], ur:[1,1]}; + //var bestLod = -1; + var bestNodeCoords = [0,0], shift; + //var bestExtents = {ll:[0,0], ur:[1,1]}; for (var i = 0, li = nodes.length; i < li; i++) { var node = nodes[i]; //has division node this tile node //var shift = node.id[0] - this.lodRange[0]; - var shift = id[0] - node.id[0]; + shift = id[0] - node.id[0]; if (shift >= 0) { var x = id[1] >> shift; @@ -367,8 +364,8 @@ MapMeasure.prototype.getSpatialDivisionNodeAndExtents = function(id) { if (node.id[1] == x && node.id[2] == y) { bestNode = node; - bestLod = node.id[0]; - bestExtents = node.extents; + //bestLod = node.id[0]; + //bestExtents = node.extents; bestNodeCoords = [node.id[1] << shift, node.id[2] << shift]; } } @@ -378,7 +375,7 @@ MapMeasure.prototype.getSpatialDivisionNodeAndExtents = function(id) { return null; } - var shift = id[0] - bestNode.id[0]; + shift = id[0] - bestNode.id[0]; var factor = 1.0 / Math.pow(2, shift); var ur = bestNode.extents.ur; @@ -397,8 +394,6 @@ MapMeasure.prototype.getSpatialDivisionNodeAndExtents = function(id) { MapMeasure.prototype.getSpatialDivisionNodeFromId = function(id) { - var nodes = this.map.referenceFrame.getSpatialDivisionNodes(); - var shift = id[0] - this.maxDivisionNodeDepth; var nx = id[1] >> shift; var ny = id[2] >> shift; @@ -458,7 +453,6 @@ MapMeasure.prototype.getSpatialDivisionNodeDepths = function() { MapMeasure.prototype.getOptimalHeightLodBySampleSize = function(coords, desiredSamplesSize) { var result = this.getSpatialDivisionNode(coords); var node = result[0]; - var nodeCoords = result[1]; if (node != null) { var nodeLod = node.id[0]; @@ -478,7 +472,6 @@ MapMeasure.prototype.getOptimalHeightLodBySampleSize = function(coords, desiredS MapMeasure.prototype.getOptimalHeightLod = function(coords, viewExtent, desiredSamplesPerViewExtent) { var result = this.getSpatialDivisionNode(coords); var node = result[0]; - var nodeCoords = result[1]; if (node != null) { var nodeLod = node.id[0]; @@ -558,12 +551,13 @@ MapMeasure.prototype.getAzimuthCorrection = function(coords, coords2) { }; -MapMeasure.prototype.getNED = function(coords, returnMatrix) { +MapMeasure.prototype.getNED = function(coords) { var centerCoords = this.convert.convertCoords([coords[0], coords[1], 0], 'navigation', 'physical'); + var upCoords, rightCoords; if (this.isProjected) { - var upCoords = this.convert.convertCoords([coords[0], coords[1] + 100, 0], 'navigation', 'physical'); - var rightCoords = this.convert.convertCoords([coords[0] + 100, coords[1], 0], 'navigation', 'physical'); + upCoords = this.convert.convertCoords([coords[0], coords[1] + 100, 0], 'navigation', 'physical'); + rightCoords = this.convert.convertCoords([coords[0] + 100, coords[1], 0], 'navigation', 'physical'); } else { var cy = (coords[1] + 90) - 0.0001; var cx = (coords[0] + 180) + 0.0001; @@ -573,15 +567,15 @@ MapMeasure.prototype.getNED = function(coords, returnMatrix) { //up coords var r = geodesic.Direct(coords[1], coords[0], 0, -100); - var upCoords = this.convert.convertCoords([r.lon2, r.lat2, 0], 'navigation', 'physical'); + upCoords = this.convert.convertCoords([r.lon2, r.lat2, 0], 'navigation', 'physical'); //right coords r = geodesic.Direct(coords[1], coords[0], 90, 100); - var rightCoords = this.convert.convertCoords([r.lon2, r.lat2, 0], 'navigation', 'physical'); + rightCoords = this.convert.convertCoords([r.lon2, r.lat2, 0], 'navigation', 'physical'); } else { // substraction instead of addition is probably case of complicated view matrix calculation - var upCoords = this.convert.convertCoords([coords[0], coords[1] - 0.0001, 0], 'navigation', 'physical'); - var rightCoords = this.convert.convertCoords([coords[0] + 0.0001, coords[1], 0], 'navigation', 'physical'); + upCoords = this.convert.convertCoords([coords[0], coords[1] - 0.0001, 0], 'navigation', 'physical'); + rightCoords = this.convert.convertCoords([coords[0] + 0.0001, coords[1], 0], 'navigation', 'physical'); } } @@ -608,10 +602,11 @@ MapMeasure.prototype.getNED = function(coords, returnMatrix) { MapMeasure.prototype.getNewNED = function(coords, returnMatrix) { var centerCoords = this.convert.convertCoords([coords[0], coords[1], 0], 'navigation', 'physical'); + var upCoords, rightCoords; if (this.isProjected) { - var upCoords = this.convert.convertCoords([coords[0], coords[1] + 100, 0], 'navigation', 'physical'); - var rightCoords = this.convert.convertCoords([coords[0] + 100, coords[1], 0], 'navigation', 'physical'); + upCoords = this.convert.convertCoords([coords[0], coords[1] + 100, 0], 'navigation', 'physical'); + rightCoords = this.convert.convertCoords([coords[0] + 100, coords[1], 0], 'navigation', 'physical'); } else { //get NED for latlon coordinates //http://www.mathworks.com/help/aeroblks/directioncosinematrixeceftoned.html @@ -651,15 +646,15 @@ MapMeasure.prototype.getNewNED = function(coords, returnMatrix) { //up coords var r = geodesic.Direct(coords[1], coords[0], 0, -100); - var upCoords = this.convert.convertCoords([r.lon2, r.lat2, 0], 'navigation', 'physical'); + upCoords = this.convert.convertCoords([r.lon2, r.lat2, 0], 'navigation', 'physical'); //right coords r = geodesic.Direct(coords[1], coords[0], 90, -100); - var rightCoords = this.convert.convertCoords([r.lon2, r.lat2, 0], 'navigation', 'physical'); + rightCoords = this.convert.convertCoords([r.lon2, r.lat2, 0], 'navigation', 'physical'); } else { // substraction instead of addition is probably case of complicated view matrix calculation - var upCoords = this.convert.convertCoords([coords[0], coords[1] + 0.0001, 0], 'navigation', 'physical'); - var rightCoords = this.convert.convertCoords([coords[0] + 0.0001, coords[1], 0], 'navigation', 'physical'); + upCoords = this.convert.convertCoords([coords[0], coords[1] + 0.0001, 0], 'navigation', 'physical'); + rightCoords = this.convert.convertCoords([coords[0] + 0.0001, coords[1], 0], 'navigation', 'physical'); } } @@ -685,7 +680,7 @@ MapMeasure.prototype.getNewNED = function(coords, returnMatrix) { return [ east[0], east[1], east[2], 0, north[0], north[1], north[2], 0, - up[0], up[1], up[2], 0, + direction[0], direction[1], direction[2], 0, 0, 0, 0, 1 ]; } @@ -709,12 +704,14 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp var tmpMatrix = mat4.create(); mat4.multiply(math.rotationMatrix(2, math.radians(-orientation[0])), math.rotationMatrix(0, math.radians(orientation[1])), tmpMatrix); + var orbitPos, ned, north, east, direction, spaceMatrix, rotationMatrix; + var east2, north2, direction2, dir, up, right; if (position.getViewMode() == 'obj') { - var orbitPos = [0, -distance, 0]; + orbitPos = [0, -distance, 0]; mat4.multiplyVec3(tmpMatrix, orbitPos); } else { - var orbitPos = [0, 0, 0]; + orbitPos = [0, 0, 0]; } //this.cameraVector = [0, 0, 1]; @@ -735,25 +732,25 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp tmpMatrix = mat4.create(); mat4.multiply(math.rotationMatrix(0, math.radians(-orientation[1] - 90.0)), math.rotationMatrix(2, math.radians(orientation[0])), tmpMatrix); - var ned = this.getNED(coords); - var north = ned.north; - var east = ned.east; - var direction = ned.direction; + ned = this.getNED(coords); + north = ned.north; + east = ned.east; + direction = ned.direction; - var spaceMatrix = [ + spaceMatrix = [ east[0], east[1], east[2], 0, direction[0], direction[1], direction[2], 0, north[0], north[1], north[2], 0, 0, 0, 0, 1 ]; - var east2 = [1,0,0]; - var direction2 = [0,1,0]; - var north2 = [0,0,1]; + east2 = [1,0,0]; + direction2 = [0,1,0]; + north2 = [0,0,1]; - var dir = [1,0,0]; - var up = [0,0,-1]; - var right = [0,0,0]; + dir = [1,0,0]; + up = [0,0,-1]; + right = [0,0,0]; vec3.cross(dir, up, right); //rotate vectors according to eulers @@ -781,7 +778,7 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp */ //get rotation matrix - var rotationMatrix = [ + rotationMatrix = [ east2[0], east2[1], east2[2], 0, direction2[0], direction2[1], direction2[2], 0, north2[0], north2[1], north2[2], 0, @@ -807,13 +804,13 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp } else { //geographics - var ned = this.getNED(coords); + ned = this.getNED(coords); north = ned.north; east = ned.east; direction = ned.direction; - var spaceMatrix = [ + spaceMatrix = [ east[0], east[1], east[2], 0, direction[0], direction[1], direction[2], 0, north[0], north[1], north[2], 0, @@ -825,11 +822,11 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp var localRotMatrix = mat4.create(); mat4.multiply(math.rotationMatrix(0, math.radians(-orientation[1] - 90.0)), math.rotationMatrix(2, math.radians(orientation[0])), localRotMatrix); - var east2 = [1,0,0]; - var direction2 = [0,1,0]; - var north2 = [0,0,1]; + east2 = [1,0,0]; + direction2 = [0,1,0]; + north2 = [0,0,1]; - var coords = position.getCoords(); + coords = position.getCoords(); var latlonMatrix = mat4.create(); mat4.multiply(math.rotationMatrix(0, math.radians((coords[1] - 90.0))), math.rotationMatrix(2, math.radians((-coords[0]-90))), latlonMatrix); // mat4.multiply(math.rotationMatrix(2, math.radians((coords[0]-90))), math.rotationMatrix(0, math.radians((coords[1] - 90.0))), latlonMatrix); @@ -844,16 +841,16 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp mat4.multiplyVec3(latlonMatrix, direction2); - var spaceMatrix = [ + spaceMatrix = [ east2[0], east2[1], east2[2], 0, direction2[0], direction2[1], direction2[2], 0, north2[0], north2[1], north2[2], 0, 0, 0, 0, 1 ]; - var right = [1,0,0]; - var dir = [0,1,0]; - var up = [0,0,1]; + right = [1,0,0]; + dir = [0,1,0]; + up = [0,0,1]; //vec3.cross(dir, up, right); //rotate vectors according to eulers @@ -884,7 +881,7 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp ]; */ - var rotationMatrix = [ + rotationMatrix = [ right[0], right[1], right[2], 0, dir[0], dir[1], dir[2], 0, up[0], up[1], up[2], 0, diff --git a/src/core/map/metanode.js b/src/core/map/metanode.js index 8bb39375..8c6e77c6 100755 --- a/src/core/map/metanode.js +++ b/src/core/map/metanode.js @@ -65,7 +65,7 @@ MapMetanode.prototype.hasChildren = function() { }; -MapMetanode.prototype.parseExtentBits = function(extentBytes, extentBits, index, maxExtent) { +MapMetanode.prototype.parseExtentBits = function(extentBytes, extentBits, index) { var value = 0; for (var i = 0, li = extentBits; i < li; i++) { @@ -122,7 +122,7 @@ struct Metanode { */ var streamData = stream.data; - var lastIndex = stream.index; + //var lastIndex = stream.index; var version = this.metatile.version; this.flags = streamData.getUint8(stream.index, true); stream.index += 1; @@ -144,7 +144,7 @@ struct Metanode { var spaceExtentSize = this.map.spaceExtentSize; var spaceExtentOffset = this.map.spaceExtentOffset; - for (var i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { minExtents[i] = this.parseExtentBits(extentsBytes, extentBits, index) * spaceExtentSize[i] + spaceExtentOffset[i]; //minExtents[i] = this.parseExtentBits(extentsBytes, extentBits, index, 1.0); index += extentBits; @@ -155,7 +155,7 @@ struct Metanode { //check zero bbox var extentsBytesSum = 0; - for (var i = 0, li = extentsBytes.length; i < li; i++) { + for (i = 0, li = extentsBytes.length; i < li; i++) { extentsBytesSum += extentsBytes[i]; } @@ -215,7 +215,7 @@ struct Metanode { this.alien = false; - var nodeSize2 = stream.index - lastIndex; + //var nodeSize2 = stream.index - lastIndex; //if (!this.map.config.mapSmartNodeParsing) { this.generateCullingHelpers(); @@ -288,23 +288,25 @@ MapMetanode.prototype.generateCullingHelpers = function(virtual) { return; //result is same for each tile id } + var divisionNode; + var llx, lly, urx, ury; var pos = draw.tmpVec3; if (this.id[0] > map.measure.maxDivisionNodeDepth) { var pos2 = draw.tmpVec5; - var divisionNode = map.measure.getSpatialDivisionNodeFromId(this.id); + divisionNode = map.measure.getSpatialDivisionNodeFromId(this.id); if (!divisionNode) { return; } map.measure.getSpatialDivisionNodeAndExtents2(this.id, pos2, divisionNode); - var node = pos2[0]; - var llx = pos2[1]; - var lly = pos2[2]; - var urx = pos2[3]; - var ury = pos2[4]; + //var node = pos2[0]; + llx = pos2[1]; + lly = pos2[2]; + urx = pos2[3]; + ury = pos2[4]; this.divisionNode = divisionNode; @@ -315,16 +317,16 @@ MapMetanode.prototype.generateCullingHelpers = function(virtual) { } else { var res = map.measure.getSpatialDivisionNodeAndExtents(this.id); - var divisionNode = res[0]; + divisionNode = res[0]; if (!divisionNode) { return; } - var llx = res[1][0][0]; - var lly = res[1][0][1]; - var urx = res[1][1][0]; - var ury = res[1][1][1]; + llx = res[1][0][0]; + lly = res[1][0][1]; + urx = res[1][1][0]; + ury = res[1][1][1]; this.divisionNode = divisionNode; } @@ -376,8 +378,10 @@ MapMetanode.prototype.generateCullingHelpers = function(virtual) { pos[1] = ury; divisionNode.getPhysicalCoordsFast(pos, true, bbox, 0, 9); + var height; + if (!geocent) { - var height = this.maxZ - h; + height = this.maxZ - h; bbox[12] = bbox[0]; bbox[13] = bbox[1]; @@ -397,28 +401,30 @@ MapMetanode.prototype.generateCullingHelpers = function(virtual) { return; } - var dot = vec3.dot; + var normalize; + var dot = vec3.dot; + var d1, d2, d3, d4, maxDelta; if (map.config.mapPreciseBBoxTest || version >= 4) { //if (true) { - var height = this.maxZ - h; + height = this.maxZ - h; if (this.id[0] <= 3) { //get aabbox for low lods - var normalize = vec3.normalize2; + normalize = vec3.normalize2; normalize(bbox, 0, pos); - var d1 = dot(normal, pos); + d1 = dot(normal, pos); normalize(bbox, 3, pos); - var d2 = dot(normal, pos); + d2 = dot(normal, pos); normalize(bbox, 6, pos); - var d3 = dot(normal, pos); + d3 = dot(normal, pos); normalize(bbox, 9, pos); - var d4 = dot(normal, pos); + d4 = dot(normal, pos); - var maxDelta = Math.min(d1, d2, d3, d4); + maxDelta = Math.min(d1, d2, d3, d4); pos[0] = (urx + llx)* 0.5; pos[1] = ury; @@ -482,22 +488,22 @@ MapMetanode.prototype.generateCullingHelpers = function(virtual) { bbox[18] = maxX; bbox[19] = maxY; bbox[20] = maxZ; bbox[21] = minX; bbox[22] = maxY; bbox[23] = maxZ; } else { - var normalize = vec3.normalize3; - var dot = vec3.dot2; + normalize = vec3.normalize3; + dot = vec3.dot2; normalize(bbox, 0, bbox, 12); - var d1 = dot(normal, bbox, 12); + d1 = dot(normal, bbox, 12); normalize(bbox, 3, bbox, 15); - var d2 = dot(normal, bbox, 15); + d2 = dot(normal, bbox, 15); normalize(bbox, 6, bbox, 18); - var d3 = dot(normal, bbox, 18); + d3 = dot(normal, bbox, 18); normalize(bbox, 9, bbox, 21); - var d4 = dot(normal, bbox, 21); + d4 = dot(normal, bbox, 21); - var maxDelta = Math.min(d1, d2, d3, d4); + maxDelta = Math.min(d1, d2, d3, d4); //extend bbox height by tile curvature height += draw.planetRadius - (draw.planetRadius * maxDelta); @@ -520,21 +526,21 @@ MapMetanode.prototype.generateCullingHelpers = function(virtual) { } } else { - var normalize = vec3.normalize2; + normalize = vec3.normalize2; normalize(bbox, 0, pos); - var d1 = dot(normal, pos); + d1 = dot(normal, pos); normalize(bbox, 3, pos); - var d2 = dot(normal, pos); + d2 = dot(normal, pos); normalize(bbox, 6, pos); - var d3 = dot(normal, pos); + d3 = dot(normal, pos); normalize(bbox, 9, pos); - var d4 = dot(normal, pos); + d4 = dot(normal, pos); - var maxDelta = Math.min(d1, d2, d3, d4); + maxDelta = Math.min(d1, d2, d3, d4); } //get cos angle based at 90deg @@ -564,7 +570,7 @@ MapMetanode.prototype.getWorldMatrix = function(geoPos, matrix) { m[8] = 0; m[9] = 0; m[10] = this.bbox.side(2); m[11] = 0; m[12] = this.bbox.min[0] - geoPos[0]; m[13] = this.bbox.min[1] - geoPos[1]; m[14] = this.bbox.min[2] - geoPos[2]; m[15] = 1; } else { - var m = mat4.create(); + m = mat4.create(); mat4.multiply( math.translationMatrix(this.bbox.min[0] - geoPos[0], this.bbox.min[1] - geoPos[1], this.bbox.min[2] - geoPos[2]), math.scaleMatrix(this.bbox.side(0), this.bbox.side(1), this.bbox.side(2)), m); @@ -598,8 +604,8 @@ MapMetanode.prototype.drawBBox = function(cameraPos) { }; -MapMetanode.prototype.drawBBox2 = function(cameraPos) { - var spoints = []; +MapMetanode.prototype.drawBBox2 = function() { + //var spoints = []; //for (var i = 0, li = this.bbox2.length; i < li; i++) { //var pos = this.bbox2[i]; //pos = ["obj", pos[0], pos[1], "fix", pos[2], 0, 0, 0, 10, 90 ]; @@ -699,7 +705,7 @@ MapMetanode.prototype.drawPlane = function(cameraPos, tile) { prog.setMat4('uProj', proj); prog.setFloatArray('uPoints', buffer); - var minTile = 32; + //var minTile = 32; var embed = 8; var altitude = Math.max(10, tile.distance + 20); var gridSelect = (Math.log(altitude) / Math.log(embed)); diff --git a/src/core/map/metatile.js b/src/core/map/metatile.js index e08534e5..5c18ba70 100755 --- a/src/core/map/metatile.js +++ b/src/core/map/metatile.js @@ -129,7 +129,7 @@ MapMetatile.prototype.getNode = function(id) { if (!node) { var index = this.sizex * y + x; var stream = {data:this.data, index:this.metanodesIndex + (index * this.metanodeSize)}; - var node = (new MapMetanode(this, [this.lod, this.metatileIdx + this.offsetx + x, this.metatileIdy + this.offsety + y], stream, this.divisionNode)); + node = (new MapMetanode(this, [this.lod, this.metatileIdx + this.offsetx + x, this.metatileIdy + this.offsety + y], stream, this.divisionNode)); this.nodes[index] = node; this.applyMetanodeCredits(x, y); this.applyMetatanodeBitplanes(x, y); diff --git a/src/core/map/position.js b/src/core/map/position.js index 1fba2841..305369c4 100755 --- a/src/core/map/position.js +++ b/src/core/map/position.js @@ -1,9 +1,7 @@ import {math as math_} from '../utils/math'; -import {utils as utils_} from '../utils/utils'; //get rid of compiler mess -var utils = utils_; var math = math_; var MapPosition = function(pos) { @@ -112,7 +110,7 @@ MapPosition.prototype.getHeightMode = function() { }; -MapPosition.prototype.check = function(mode) { +MapPosition.prototype.check = function() { //check pich if (this.getViewMode() == 'obj') { this.pos[6] = math.clamp(this.pos[6], -90.0, 90.0); @@ -126,7 +124,7 @@ MapPosition.prototype.check = function(mode) { MapPosition.prototype.isSame = function(pos) { - var pos = pos.pos; + pos = pos.pos; return (this.pos[0] == pos[0] && math.isEqual(this.pos[1], pos[1], 0.0000001) && math.isEqual(this.pos[2], pos[2], 0.0000001) && diff --git a/src/core/map/render-slots.js b/src/core/map/render-slots.js index dea56943..a8523778 100755 --- a/src/core/map/render-slots.js +++ b/src/core/map/render-slots.js @@ -81,7 +81,7 @@ MapRenderSlots.prototype.getRenderSlotEnabled = function(id) { }; -MapRenderSlots.prototype.processRenderSlots = function(id, callback) { +MapRenderSlots.prototype.processRenderSlots = function() { if (this.draw.drawChannel != 1) { this.renderer.gpu.setViewport(); //just in case } diff --git a/src/core/map/resource-node.js b/src/core/map/resource-node.js index c14b2a93..7a0ae0e3 100755 --- a/src/core/map/resource-node.js +++ b/src/core/map/resource-node.js @@ -117,16 +117,17 @@ MapResourceNode.prototype.getGeodata = function(path, extraInfo) { // Textures --------------------------------- MapResourceNode.prototype.getTexture = function(path, heightMap, extraBound, extraInfo, tile, internal) { + var texture; if (extraInfo && extraInfo.layer) { var id = path + extraInfo.layer.id; - var texture = this.textures[id]; + texture = this.textures[id]; if (!texture) { texture = new MapTexture(this.map, path, heightMap, extraBound, extraInfo, tile, internal); this.textures[id] = texture; } } else { - var texture = this.textures[path]; + texture = this.textures[path]; if (!texture) { texture = new MapTexture(this.map, path, heightMap, extraBound, extraInfo, tile, internal); @@ -141,7 +142,7 @@ MapResourceNode.prototype.getTexture = function(path, heightMap, extraBound, ext // SubTextures --------------------------------- MapResourceNode.prototype.getSubtexture = function(texture, path, heightMap, extraBound, extraInfo, tile, internal) { - var texture = this.subtextures[path]; + texture = this.subtextures[path]; if (!texture) { texture = new MapSubtexture(this.map, path, heightMap, extraBound, extraInfo, tile, internal); @@ -169,7 +170,7 @@ MapResourceNode.prototype.removeMetatile = function(metatile) { MapResourceNode.prototype.getMetatile = function(surface, allowCreation, tile) { - var metatiles = this.metatiles; + var metatiles = this.metatiles, metatile; for (var key in metatiles) { if (metatiles[key].surface == surface) { return metatiles[key]; @@ -179,13 +180,13 @@ MapResourceNode.prototype.getMetatile = function(surface, allowCreation, tile) { var path = surface.getMetaUrl(this.id); if (metatiles[path]) { - var metatile = metatiles[path].clone(surface); + metatile = metatiles[path].clone(surface); this.addMetatile(path, metatile); return metatile; } if (allowCreation) { - var metatile = new MapMetatile(this, surface, tile); + metatile = new MapMetatile(this, surface, tile); this.addMetatile(path, metatile); return metatile; } else { diff --git a/src/core/map/resource-tree.js b/src/core/map/resource-tree.js index 9bd6305e..54f76094 100755 --- a/src/core/map/resource-tree.js +++ b/src/core/map/resource-tree.js @@ -51,7 +51,7 @@ MapResourceTree.prototype.findNode = function(id, createNonexisted) { MapResourceTree.prototype.findAgregatedNode = function(id, agregation, createNonexisted) { - var rootLod = 0; //TODO: fix is it same way as findNavTile + //var rootLod = 0; //TODO: fix is it same way as findNavTile var node = this.tree; var ix = ((id[1] >> agregation) << agregation); var iy = ((id[2] >> agregation) << agregation); diff --git a/src/core/map/srs.js b/src/core/map/srs.js index 2709add7..bf89e164 100755 --- a/src/core/map/srs.js +++ b/src/core/map/srs.js @@ -118,7 +118,7 @@ MapSrs.prototype.isProjected = function() { }; -MapSrs.prototype.getOriginalHeight = function(coords, direction) { +MapSrs.prototype.getOriginalHeight = function(coords) { var height = coords[2] || 0; height /= this.getVerticalAdjustmentFactor(coords); height -= this.getGeoidGridDelta(coords); @@ -134,7 +134,7 @@ MapSrs.prototype.getFinalHeight = function(coords) { }; -MapSrs.prototype.getGeoidGridDelta = function(coords, original) { +MapSrs.prototype.getGeoidGridDelta = function(coords) { if (this.geoidGridMap != null && this.isGeoidGridReady()) { //get cooords in geoidGrid space var mapCoords = this.proj4(this.srsProj4, this.geoidGrid.srsProj4, [coords[0], coords[1]]); diff --git a/src/core/map/stylesheet.js b/src/core/map/stylesheet.js index aaf2fb3e..e195c466 100755 --- a/src/core/map/stylesheet.js +++ b/src/core/map/stylesheet.js @@ -66,7 +66,7 @@ MapStylesheet.prototype.scheduleLoad = function(priority) { }; -MapStylesheet.prototype.onLoad = function(url, onLoaded, onError) { +MapStylesheet.prototype.onLoad = function() { //this.mapLoaderCallLoaded = onLoaded; //this.mapLoaderCallError = onError; diff --git a/src/core/map/submesh.js b/src/core/map/submesh.js index 8c391abf..68cddae5 100755 --- a/src/core/map/submesh.js +++ b/src/core/map/submesh.js @@ -141,6 +141,7 @@ struct VerticesBlock { this.valid = false; } + var internalUVs = null; var externalUVs = null; var vertices = new Float32Array(numVertices * 3);//[]; @@ -150,18 +151,17 @@ struct VerticesBlock { } var uvfactor = 1.0 / 65535; - var vfactor = uvfactor; - var ufactor = uvfactor; var vindex = 0; var uvindex = 0; + var i, li; - for (var i = 0; i < numVertices; i++) { + for (i = 0; i < numVertices; i++) { //vertices[vindex] = data.getUint16(index, true) * vfactor; index += 2; //vertices[vindex+1] = data.getUint16(index, true) * vfactor; index += 2; //vertices[vindex+2] = data.getUint16(index, true) * vfactor; index += 2; - vertices[vindex] = (uint8Data[index] + (uint8Data[index + 1]<<8)) * vfactor; - vertices[vindex+1] = (uint8Data[index+2] + (uint8Data[index + 3]<<8)) * vfactor; - vertices[vindex+2] = (uint8Data[index+4] + (uint8Data[index + 5]<<8)) * vfactor; + vertices[vindex] = (uint8Data[index] + (uint8Data[index + 1]<<8)) * uvfactor; + vertices[vindex+1] = (uint8Data[index+2] + (uint8Data[index + 3]<<8)) * uvfactor; + vertices[vindex+2] = (uint8Data[index+4] + (uint8Data[index + 5]<<8)) * uvfactor; vindex += 3; if (externalUVs != null) { @@ -197,10 +197,10 @@ struct TexcoorsBlock { if (this.flags & this.flagsInternalTexcoords) { var numUVs = data.getUint16(index, true); index += 2; - var internalUVs = new Float32Array(numUVs * 2);//[]; - var uvfactor = 1.0 / 65535; + internalUVs = new Float32Array(numUVs * 2);//[]; + //var uvfactor = 1.0 / 65535; - for (var i = 0, li = numUVs * 2; i < li; i+=2) { + for (i = 0, li = numUVs * 2; i < li; i+=2) { internalUVs[i] = (uint8Data[index] + (uint8Data[index + 1]<<8)) * uvfactor; internalUVs[i+1] = (65535 - (uint8Data[index+2] + (uint8Data[index + 3]<<8))) * uvfactor; index += 4; @@ -224,10 +224,10 @@ struct FacesBlock { var numFaces = data.getUint16(index, true); index += 2; - var internalUVs = null; - var externalUVs = null; + internalUVs = null; + externalUVs = null; - var vertices = new Float32Array(numFaces * 3 * 3);//[]; + vertices = new Float32Array(numFaces * 3 * 3);//[]; if (this.flags & this.flagsInternalTexcoords) { internalUVs = new Float32Array(numFaces * 3 * 2);//[]; @@ -241,8 +241,8 @@ struct FacesBlock { var eUVs = this.tmpExternalUVs; var iUVs = this.tmpInternalUVs; - for (var i = 0; i < numFaces; i++) { - var vindex = i * (3 * 3); + for (i = 0; i < numFaces; i++) { + vindex = i * (3 * 3); var v1 = (uint8Data[index] + (uint8Data[index + 1]<<8)); var v2 = (uint8Data[index+2] + (uint8Data[index + 3]<<8)); var v3 = (uint8Data[index+4] + (uint8Data[index + 5]<<8)); @@ -380,6 +380,7 @@ struct VerticesBlock { var externalUVs = null; var vertices = new Float32Array(numVertices * 3);//[]; + var vindex; var x = 0, y = 0,z = 0; var cx = center[0], cy = center[1], cz = center[2]; @@ -391,8 +392,9 @@ struct VerticesBlock { var sz = 1.0 / (this.bbox.max[2] - this.bbox.min[2]); var res = [0, index]; + var i, li; - for (var i = 0; i < numVertices; i++) { + for (i = 0; i < numVertices; i++) { this.parseDelta(uint8Data, res); x += res[0]; this.parseDelta(uint8Data, res); @@ -400,7 +402,7 @@ struct VerticesBlock { this.parseDelta(uint8Data, res); z += res[0]; - var vindex = i * 3; + vindex = i * 3; vertices[vindex] = ((x * multiplier * scale + cx) - mx) * sx; vertices[vindex+1] = ((y * multiplier * scale + cy) - my) * sy; vertices[vindex+2] = ((z * multiplier * scale + cz) - mz) * sz; @@ -416,10 +418,10 @@ struct VerticesBlock { x = 0, y = 0; res[1] = index; - for (var i = 0; i < numVertices; i++) { - var d = this.parseDelta(uint8Data, res); + for (i = 0; i < numVertices; i++) { + this.parseDelta(uint8Data, res); x += res[0]; - d = this.parseDelta(uint8Data, res); + this.parseDelta(uint8Data, res); y += res[0]; var uvindex = i * 2; @@ -458,7 +460,7 @@ struct TexcoorsBlock { var internalUVs = new Float32Array(numUVs * 2);//[]; res[1] = index; - for (var i = 0, li = numUVs * 2; i < li; i+=2) { + for (i = 0, li = numUVs * 2; i < li; i+=2) { this.parseDelta(uint8Data, res); x += res[0]; this.parseDelta(uint8Data, res); @@ -488,10 +490,10 @@ struct FacesBlock { var numFaces = data.getUint16(index, true); index += 2; - var internalUVs = null; - var externalUVs = null; + internalUVs = null; + externalUVs = null; - var vertices = new Float32Array(numFaces * 3 * 3);//[]; + vertices = new Float32Array(numFaces * 3 * 3);//[]; if (this.flags & this.flagsInternalTexcoords) { internalUVs = new Float32Array(numFaces * 3 * 2);//[]; @@ -505,21 +507,22 @@ struct FacesBlock { var eUVs = this.tmpExternalUVs; var iUVs = this.tmpInternalUVs; var high = 0; + var v1, v2, v3; res[1] = index; - for (var i = 0; i < numFaces; i++) { - var vindex = i * (3 * 3); + for (i = 0; i < numFaces; i++) { + vindex = i * (3 * 3); this.parseWord(uint8Data, res); - var v1 = high - res[0]; + v1 = high - res[0]; if (!res[0]) { high++; } this.parseWord(uint8Data, res); - var v2 = high - res[0]; + v2 = high - res[0]; if (!res[0]) { high++; } this.parseWord(uint8Data, res); - var v3 = high - res[0]; + v3 = high - res[0]; if (!res[0]) { high++; } //var dindex = i * (3 * 3); @@ -552,17 +555,17 @@ struct FacesBlock { high = 0; if (internalUVs != null) { - for (var i = 0; i < numFaces; i++) { + for (i = 0; i < numFaces; i++) { this.parseWord(uint8Data, res); - var v1 = high - res[0]; + v1 = high - res[0]; if (!res[0]) { high++; } this.parseWord(uint8Data, res); - var v2 = high - res[0]; + v2 = high - res[0]; if (!res[0]) { high++; } this.parseWord(uint8Data, res); - var v3 = high - res[0]; + v3 = high - res[0]; if (!res[0]) { high++; } vindex = i * (3 * 2); @@ -631,7 +634,7 @@ MapSubmesh.prototype.getWorldMatrix = function(geoPos, matrix) { m[8] = 0; m[9] = 0; m[10] = this.bbox.side(2); m[11] = 0; m[12] = this.bbox.min[0] - geoPos[0]; m[13] = this.bbox.min[1] - geoPos[1]; m[14] = this.bbox.min[2] - geoPos[2]; m[15] = 1; } else { - var m = mat4.create(); + m = mat4.create(); mat4.multiply( math.translationMatrix(this.bbox.min[0] - geoPos[0], this.bbox.min[1] - geoPos[1], this.bbox.min[2] - geoPos[2]), math.scaleMatrix(this.bbox.side(0), this.bbox.side(1), this.bbox.side(2)), m); diff --git a/src/core/map/subtexture.js b/src/core/map/subtexture.js index 370a1209..8d2a782f 100755 --- a/src/core/map/subtexture.js +++ b/src/core/map/subtexture.js @@ -159,6 +159,8 @@ MapSubtexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu, t } if (this.loadState == 2) { //loaded + var t; + if (!doNotLoad && this.cacheItem) { this.map.resourcesCache.updateItem(this.cacheItem); } @@ -173,7 +175,7 @@ MapSubtexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu, t if (doNotCheckGpu) { if (this.heightMap) { if (!this.imageData) { - var t = performance.now(); + t = performance.now(); this.buildHeightMap(); this.stats.renderBuild += performance.now() - t; } @@ -184,7 +186,7 @@ MapSubtexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu, t if (this.heightMap) { if (!this.imageData) { - var t = performance.now(); + t = performance.now(); this.buildHeightMap(); this.stats.renderBuild += performance.now() - t; } @@ -202,7 +204,7 @@ MapSubtexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu, t // return false; //} - var t = performance.now(); + t = performance.now(); this.buildGpuTexture(); this.stats.renderBuild += performance.now() - t; } @@ -318,9 +320,9 @@ MapSubtexture.prototype.onLoaded = function(killBlob) { var size = this.image.naturalWidth * this.image.naturalHeight * (this.heightMap ? 3 : 3); - if (!this.image.complete) { - size = size; - } + //if (!this.image.complete) { + // size = size; + //} //console.log(size); @@ -360,7 +362,7 @@ MapSubtexture.prototype.onLoadHead = function(downloadAll, url, onLoaded, onErro }; -MapSubtexture.prototype.onLoadHeadError = function(downloadAll) { +MapSubtexture.prototype.onLoadHeadError = function() { if (this.map.killed){ return; } @@ -428,9 +430,9 @@ MapSubtexture.prototype.onHeadLoaded = function(downloadAll, data, status) { case 'negative-type': if (data) { - if (!data.indexOf) { - data = data; - } + //if (!data.indexOf) { + // data = data; + //} if (data.indexOf(this.checkValue) != -1) { this.checkStatus = -1; diff --git a/src/core/map/surface-sequence.js b/src/core/map/surface-sequence.js index 2de0b0dd..2b44e94c 100755 --- a/src/core/map/surface-sequence.js +++ b/src/core/map/surface-sequence.js @@ -4,7 +4,7 @@ var MapSurfaceSequence = function(map) { }; -MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) { +MapSurfaceSequence.prototype.generateSurfaceSequence = function() { var view = this.map.currentView; var tree = this.map.tree; @@ -16,15 +16,14 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) tree.surfaceSequenceIndices = []; //probably not used tree.surfaceOnlySequence = []; - var vsurfaces = {}; + var vsurfaces = {}, surface, glue; var vsurfaceCount = 0; - var list = []; - + var list = [], listId, i, li, j , lj, key; var strId = []; //add surfaces to the list - for (var key in view.surfaces) { - var surface = this.map.getSurface(key); + for (key in view.surfaces) { + surface = this.map.getSurface(key); if (surface) { strId.push(surface.id); @@ -40,7 +39,7 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) strId.sort(); strId = strId.join(';'); - var surface = this.map.virtualSurfaces[strId]; + surface = this.map.virtualSurfaces[strId]; if (surface) { list = [ [ [(surface.index + 1)], surface, true, false] ]; //[surfaceId, surface, isSurface, isAlien] vsurfaceCount = 1; @@ -53,15 +52,15 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) var glues = []; //add proper glues to the list - for (var key in this.map.glues) { - var glue = this.map.glues[key]; + for (key in this.map.glues) { + glue = this.map.glues[key]; //add only glue which contains desired surfaces var id = glue.id; if (id.length <= vsurfaceCount) { var missed = false; - for (var j = 0, lj = id.length; j < lj; j++) { + for (j = 0, lj = id.length; j < lj; j++) { if (!vsurfaces[id[j]]) { missed = true; break; @@ -70,10 +69,10 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) if (!missed) { //var listId = ""; - var listId = []; + listId = []; //create glue id in reverse order for sorting - for (var j = 0, lj = id.length; j < lj; j++) { + for (j = 0, lj = id.length; j < lj; j++) { //listId = vsurfaces[id[j]] + (j ? "." : "") + listId; listId.unshift(vsurfaces[id[j]]); } @@ -84,9 +83,9 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) } //process glue flags - for (var i = 0, li = glues.length; i < li; i++) { + for (i = 0, li = glues.length; i < li; i++) { var item = glues[i]; - var glue = item[1]; + glue = item[1]; glue.flagProper = true; glue.flagAlien = true; @@ -97,7 +96,7 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) if (glue.flagAlien) { //remove first surface from id - var listId = item[0].slice(1); + listId = item[0].slice(1); //add same glue as alien list.push([listId, item[1], false, true]); //[surfaceId, surface, isSurface, isAlien] @@ -110,13 +109,13 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) do { var sorted = true; - for (var i = 0, li = list.length - 1; i < li; i++) { + for (i = 0, li = list.length - 1; i < li; i++) { var a1 = list[i][0]; var a2 = list[i+1][0]; var lesser = false; - for (var j = 0, lj = Math.min(a1.length, a2.length); j < lj; j++) { + for (j = 0, lj = Math.min(a1.length, a2.length); j < lj; j++) { if (a1[j] < a2[j] || (j == (lj -1) && a1[j] == a2[j] && a2.length > a1.length)) { lesser = true; break; @@ -140,7 +139,7 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) var lastIndex = vsurfaceCount - 1; //convert list to surface sequence - for (var i = 0, li = list.length; i < li; i++) { + for (i = 0, li = list.length; i < li; i++) { tree.surfaceSequence.push([list[i][1], list[i][3]]); //[surface, isAlien] //this.surfaceSequence.push(list[i][1]); list[i][1].viewSurfaceIndex = lastIndex; @@ -164,7 +163,7 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) this.map.freeLayersHaveGeodata = false; //free layers - for (var key in view.freeLayers) { + for (key in view.freeLayers) { var freeLayer = this.map.getFreeLayer(key); if (freeLayer) { freeLayer.surfaceSequence = [freeLayer]; @@ -183,28 +182,28 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) MapSurfaceSequence.prototype.generateBoundLayerSequence = function() { var view = this.map.currentView; - var surfaces = []; + var key, item, layer, alpha, i, li; //surfaces - for (var key in view.surfaces) { + for (key in view.surfaces) { var surfaceLayers = view.surfaces[key]; var surface = this.map.getSurface(key); if (surface != null) { surface.boundLayerSequence = []; - for (var i = 0, li = surfaceLayers.length; i < li; i++) { - var item = surfaceLayers[i]; + for (i = 0, li = surfaceLayers.length; i < li; i++) { + item = surfaceLayers[i]; if (typeof item === 'string') { - var layer = this.map.getBoundLayerById(item); + layer = this.map.getBoundLayerById(item); if (layer) { surface.boundLayerSequence.push([layer, 1]); } } else { - var layer = this.map.getBoundLayerById(item['id']); + layer = this.map.getBoundLayerById(item['id']); if (layer) { - var alpha = 1; + alpha = 1; if (typeof item['alpha'] !== 'undefined') { alpha = item['alpha']; } @@ -217,7 +216,7 @@ MapSurfaceSequence.prototype.generateBoundLayerSequence = function() { } //free layers - for (var key in view.freeLayers) { + for (key in view.freeLayers) { var freeLayersProperties = view.freeLayers[key]; var freeLayer = this.map.getFreeLayer(key); if (freeLayer != null && freeLayer.ready) { @@ -227,19 +226,19 @@ MapSurfaceSequence.prototype.generateBoundLayerSequence = function() { if (boundLayers && Array.isArray(boundLayers)) { - for (var i = 0, li = boundLayers.length; i < li; i++) { - var item = boundLayers[i]; + for (i = 0, li = boundLayers.length; i < li; i++) { + item = boundLayers[i]; if (typeof item === 'string') { - var layer = this.map.getBoundLayerById(item); + layer = this.map.getBoundLayerById(item); if (layer) { freeLayer.boundLayerSequence.push([layer, 1]); } } else { - var layer = this.map.getBoundLayerById(item['id']); + layer = this.map.getBoundLayerById(item['id']); if (layer) { - var alpha = 1; + alpha = 1; if (typeof item['alpha'] !== 'undefined') { alpha = item['alpha']; } diff --git a/src/core/map/surface-tile.js b/src/core/map/surface-tile.js index 515292a1..ce157cad 100755 --- a/src/core/map/surface-tile.js +++ b/src/core/map/surface-tile.js @@ -1,8 +1,8 @@ -import {vec3 as vec3_, mat4 as mat4_} from '../utils/matrix'; +import {vec3 as vec3_} from '../utils/matrix'; //get rid of compiler mess -var vec3 = vec3_, mat4 = mat4_; +var vec3 = vec3_; var MapSurfaceTile = function(map, parent, id) { @@ -507,17 +507,16 @@ MapSurfaceTile.prototype.isVirtualMetanodeReady = function(tree, priority) { MapSurfaceTile.prototype.createVirtualMetanode = function(tree, priority) { var surfaces = this.virtualSurfaces; - var first = false; - var node = null; + var node = null, i, li, surface, metatile, metanode; //get top most existing surface - for (var i = 0, li = surfaces.length; i < li; i++) { - var surface = surfaces[i][0]; + for (i = 0, li = surfaces.length; i < li; i++) { + surface = surfaces[i][0]; var alien = surfaces[i][1]; - var metatile = this.metaresources.getMetatile(surface, null, this); + metatile = this.metaresources.getMetatile(surface, null, this); if (metatile.isReady(priority) == true) { - var metanode = metatile.getNode(this.id); + metanode = metatile.getNode(this.id); if (metanode != null) { if (alien != metanode.alien) { @@ -557,12 +556,12 @@ MapSurfaceTile.prototype.createVirtualMetanode = function(tree, priority) { } //extend bbox, credits and children flags by other surfaces - for (var i = 0, li = surfaces.length; i < li; i++) { - var surface = surfaces[i][0]; - var metatile = this.metaresources.getMetatile(surface, null, this); + for (i = 0, li = surfaces.length; i < li; i++) { + surface = surfaces[i][0]; + metatile = this.metaresources.getMetatile(surface, null, this); if (metatile.isReady(priority)) { - var metanode = metatile.getNode(this.id); + metanode = metatile.getNode(this.id); if (metanode != null) { //does metanode have surface reference? @@ -619,17 +618,17 @@ MapSurfaceTile.prototype.bboxVisible = function(id, bbox, cameraPos, node) { var skipGeoTest = map.config.mapDisableCulling; if (!skipGeoTest && map.isGeocent) { if (node) { - if (true) { //version with perspektive - var p2 = node.diskPos; - var p1 = camera.position; - var camVec = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]]; - var distance = vec3.normalize4(camVec) * camera.distanceFactor; + //if (true) { //version with perspektive + var p2 = node.diskPos; + var p1 = camera.position; + var camVec = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]]; + var distance = vec3.normalize4(camVec) * camera.distanceFactor; //vec3.normalize(camVec); - var a = vec3.dot(camVec, node.diskNormal); - } else { - var a = vec3.dot(camera.vector, node.diskNormal); - } + var a = vec3.dot(camVec, node.diskNormal); + //} else { //version without perspektive + // var a = vec3.dot(camera.vector, node.diskNormal); + //} if (distance > 150000 && a > node.diskAngle) { return false; @@ -790,12 +789,12 @@ MapSurfaceTile.prototype.getPixelSize3Old = function(node, screenPixelSize, fact d = Math.sqrt(l1*l1 + d*d); } - var factor = camera.camera.scaleFactor2(d); + factor = camera.camera.scaleFactor2(d); return [factor * screenPixelSize, d]; }; -MapSurfaceTile.prototype.getPixelSize3 = function(node, screenPixelSize, factor) { +MapSurfaceTile.prototype.getPixelSize3 = function(node, screenPixelSize) { //if (this.map.drawIndices) { // return this.getPixelSize3Old(node, screenPixelSize, factor); //} @@ -803,8 +802,8 @@ MapSurfaceTile.prototype.getPixelSize3 = function(node, screenPixelSize, factor) var cameraDistance = camera.geocentDistance;// * factor; var a = vec3.dot(camera.geocentNormal, node.diskNormal); //get angle between tile normal and cameraGeocentNormal - var d = cameraDistance - (node.diskDistance + (node.maxZ - node.minZ)); //vertical distance from top bbox level - + var d = cameraDistance - (node.diskDistance + (node.maxZ - node.minZ)), d2; //vertical distance from top bbox level + if (a < node.diskAngle2) { //is camera inside tile conus? //get horizontal distance @@ -814,7 +813,7 @@ MapSurfaceTile.prototype.getPixelSize3 = function(node, screenPixelSize, factor) var l1 = Math.tan(a2) * node.diskDistance;// * factor; if (d < 0) { //is camera is belown top bbox level? - var d2 = cameraDistance - node.diskDistance; + d2 = cameraDistance - node.diskDistance; if (d2 < 0) { //is camera is belown bottom bbox level? d = -d2; d = Math.sqrt(l1*l1 + d*d); @@ -827,7 +826,7 @@ MapSurfaceTile.prototype.getPixelSize3 = function(node, screenPixelSize, factor) } else { if (d < 0) { //is camera is belown top bbox level? - var d2 = cameraDistance - node.diskDistance; + d2 = cameraDistance - node.diskDistance; if (d2 < 0) { //is camera is belown bottom bbox level? d = -d2; } else { //is camera inside bbox @@ -865,8 +864,7 @@ MapSurfaceTile.prototype.getPixelSize22 = function(bbox, screenPixelSize, camera */ MapSurfaceTile.prototype.updateTexelSize = function() { - var pixelSize; - var pixelSize2; + var pixelSize, factor, v, p; var map = this.map; var draw = map.draw; var camera = map.camera; @@ -894,11 +892,11 @@ MapSurfaceTile.prototype.updateTexelSize = function() { if (!preciseDistance) { screenPixelSize = draw.ndcToScreenPixel * (node.bbox.maxSize / 256); - var factor = (node.displaySize / 256) * camera.distance; + factor = (node.displaySize / 256) * camera.distance; //var factor = (256 / 256) * this.map.cameraDistance; - var v = camera.vector; //move camera away hack - var p = [cameraPos[0] - v[0] * factor, cameraPos[1] - v[1] * factor, cameraPos[2] - v[2] * factor]; + v = camera.vector; //move camera away hack + p = [cameraPos[0] - v[0] * factor, cameraPos[1] - v[1] * factor, cameraPos[2] - v[2] * factor]; pixelSize = this.getPixelSize(node.bbox, screenPixelSize, p, p, true); } else { @@ -910,10 +908,10 @@ MapSurfaceTile.prototype.updateTexelSize = function() { if (!preciseDistance && texelSizeFit > 1.1) { screenPixelSize = draw.ndcToScreenPixel * node.pixelSize * (texelSizeFit / 1.1); - var factor = (texelSizeFit / 1.1) * camera.distance; + factor = (texelSizeFit / 1.1) * camera.distance; - var v = camera.vector; //move camera away hack - var p = [cameraPos[0] - v[0] * factor, cameraPos[1] - v[1] * factor, cameraPos[2] - v[2] * factor]; + v = camera.vector; //move camera away hack + p = [cameraPos[0] - v[0] * factor, cameraPos[1] - v[1] * factor, cameraPos[2] - v[2] * factor]; pixelSize = this.getPixelSize(node.bbox, screenPixelSize, p, p, true); } else { @@ -988,27 +986,25 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { // return; //} - var map = this.map; + var map = this.map, node, ll, ur, res; if (divNode) { - var node = divNode[0]; - var ll = divNode[1][0]; - var ur = divNode[1][1]; + node = divNode[0]; + ll = divNode[1][0]; + ur = divNode[1][1]; } else { - var res = map.measure.getSpatialDivisionNodeAndExtents(this.id); - var node = res[0]; - var ll = res[1][0]; - var ur = res[1][1]; + res = map.measure.getSpatialDivisionNodeAndExtents(this.id); + node = res[0]; + ll = res[1][0]; + ur = res[1][1]; } var middle = [(ur[0] + ll[0])* 0.5, (ur[1] + ll[1])* 0.5]; - var normal = [0,0,0]; var hasPoles = map.referenceFrame.hasPoles; //var pseudomerc = (node.srs.id == "pseudomerc"); - var subdivision = angle; - var angle = angle || this.metanode.diskAngle2; + angle = angle || this.metanode.diskAngle2; if ((hasPoles && !node.isPole) && Math.acos(angle) > Math.PI*0.1) { angle = Math.cos(Math.acos(angle) * 0.5); @@ -1043,7 +1039,7 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { [ur[0], middle[1]] ]; - var flatGrid = true; + var flatGrid = true, h, coordsRes, factor, prog; if (fastGrid) { if (!this.metanode) { @@ -1052,12 +1048,10 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { if (flatGrid) { //var h = this.metanode.minZ; - var h = this.metanode.surrogatez; + h = this.metanode.surrogatez; //if (this.map.drawLods) { h = this.metanode.minZ; } - - - var coordsRes = [[h],[h],[h],[h],[h],[h],[h],[h]]; + coordsRes = [[h],[h],[h],[h],[h],[h],[h],[h]]; //middle[2] = h; //middle = node.getPhysicalCoords(middle, true); @@ -1141,8 +1135,8 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { } - var h = this.metanode.minZ; - var coordsRes = [[h],[h],[h],[h],[h],[h],[h],[h]]; + h = this.metanode.minZ; + coordsRes = [[h],[h],[h],[h],[h],[h],[h],[h]]; coordsRes[0] = [(border[8] + border[7] + border[5] + border[4]) * 0.25]; coordsRes[1] = [(border[2] + border[1] + border[5] + border[4]) * 0.25]; @@ -1165,10 +1159,10 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { middle = node.getPhysicalCoords(middle, true); } else { - var res = map.measure.getSurfaceHeight(null, lod, null, node, middle, coords); + res = map.measure.getSurfaceHeight(null, lod, null, node, middle, coords); middle[2] = res[0]; middle = node.getPhysicalCoords(middle, true); - var coordsRes = res[5]; + coordsRes = res[5]; if (!coordsRes) { coordsRes = [[0],[0],[0],[0],[0],[0],[0],[0]]; @@ -1177,10 +1171,8 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { var renderer = map.renderer; var buffer = map.draw.planeBuffer; - //var mvp = mat4.create(); var mv = renderer.camera.getModelviewMatrix(); var proj = renderer.camera.getProjectionMatrix(); - //mat4.multiply(proj, mv, mvp); var sx = cameraPos[0]; var sy = cameraPos[1]; @@ -1253,15 +1245,15 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { map.poleRadiusFactor = 8 * Math.pow(2.0, 552058 / map.poleRadius); } - var factor = 1; + factor = 1; if (hasPoles && node.isPole) { - var factor = map.poleRadiusFactor; - var prog = renderer.progPlane2; + factor = map.poleRadiusFactor; + prog = renderer.progPlane2; renderer.gpu.useProgram(prog, ['aPosition', 'aTexCoord']); prog.setVec4('uParams4', [-sx, -sy, map.poleRadius, 0]); } else { - var prog = renderer.progPlane; + prog = renderer.progPlane; renderer.gpu.useProgram(prog, ['aPosition', 'aTexCoord']); } diff --git a/src/core/map/surface-tree.js b/src/core/map/surface-tree.js index 786592ef..9493f3fb 100755 --- a/src/core/map/surface-tree.js +++ b/src/core/map/surface-tree.js @@ -135,7 +135,7 @@ MapSurfaceTree.prototype.draw = function() { var srs = map.getPhysicalSrs(); - var divisionNode = this.divisionNode; + //var divisionNode = this.divisionNode; var periodicity = srs.periodicity; //if (this.map.config.mapBasicTileSequence) { @@ -178,17 +178,17 @@ MapSurfaceTree.prototype.updateNodeHeightExtents = function(tile, node) { if (!node.heightReady && node.metatile.useVersion < 4) { var parent = tile.parent; - if (node.hasNavtile()) { - node = node; - } + //if (node.hasNavtile()) { + // node = node; + //} while (parent) { var parentNode = parent.metanode; if (parentNode.hasNavtile()) { - if (node.hasNavtile()) { - node = node; - } + //if (node.hasNavtile()) { + // node = node; + //} node.minHeight = parentNode.minHeight; node.maxHeight = parentNode.maxHeight; @@ -214,13 +214,13 @@ MapSurfaceTree.prototype.logTileInfo = function(tile, node, cameraPos) { var visible = tile.bboxVisible(tile.id, node.bbox, cameraPos, node); tile.updateTexelSize(); -// console.log("tile: " + JSON.stringify(tile.id) + " visible: " + visible + " texelsize: " + tile.texelSize); + // eslint-disable-next-line console.log('tile: ' + JSON.stringify(tile.id) + ' visible: ' + visible + ' texelsize: ' + tile.texelSize + ' center: ' + JSON.stringify(node.diskPos) + ' vec: ' + node.diskNormal + 'ang: ' + node.diskAngle + ' dist: ' + node.diskDistance); }; //loadmode = topdown -MapSurfaceTree.prototype.drawSurface = function(shift) { +MapSurfaceTree.prototype.drawSurface = function() { this.counter++; // this.surfaceTracer.trace(this.surfaceTree);//this.rootId); @@ -274,15 +274,14 @@ MapSurfaceTree.prototype.drawSurface = function(shift) { var pocessedNodes = 1; var pocessedMetatiles = 1; var usedNodes = 1; - var usedMetatiles = 1; - var drawCounter = draw.drawCounter; + var drawCounter = draw.drawCounter, i, j, lj; do { var best = 0; newProcessBufferIndex = 0; - for (var i = processBufferIndex - 1; i >= 0; i--) { + for (i = processBufferIndex - 1; i >= 0; i--) { tile = processBuffer[i]; node = tile.metanode; @@ -331,7 +330,7 @@ MapSurfaceTree.prototype.drawSurface = function(shift) { var more3 = 0; - for (var j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { var child = tile.children[j]; if (child) { childrenCount++; @@ -385,7 +384,7 @@ MapSurfaceTree.prototype.drawSurface = function(shift) { do { var sorted = true; - for (var j = 0, lj = childrenBuffer.length - 1; j < lj; j++) { + for (j = 0, lj = childrenBuffer.length - 1; j < lj; j++) { if (childrenBuffer[j].distance > childrenBuffer[j+1].distance) { var t = childrenBuffer[j]; childrenBuffer[j] = childrenBuffer[j+1]; @@ -398,7 +397,7 @@ MapSurfaceTree.prototype.drawSurface = function(shift) { //add childern to new process buffer - for (var j = 0, lj = childrenBuffer.length; j < lj; j++) { + for (j = 0, lj = childrenBuffer.length; j < lj; j++) { /*var n = childrenBuffer[j].metanode.divisionNode; if ((n.id[0] == 1 && n.id[1] == 1 && n.id[2] == 0)) {*/ @@ -449,12 +448,12 @@ MapSurfaceTree.prototype.drawSurface = function(shift) { } var tiles = draw.tileBuffer[0]; - for (var i = drawBufferIndex - 1; i >= 0; i--) { + for (i = drawBufferIndex - 1; i >= 0; i--) { tiles.push(drawBuffer[i]); } } - for (var i = drawBufferIndex - 1; i >= 0; i--) { + for (i = drawBufferIndex - 1; i >= 0; i--) { tile = drawBuffer[i]; //draw tile, preventRender=false, preventLoad=false drawTiles.drawSurfaceTile(tile, tile.metanode, cameraPos, tile.texelSize, 0, false, false); @@ -463,7 +462,7 @@ MapSurfaceTree.prototype.drawSurface = function(shift) { //loadmode = fitonly -MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { +MapSurfaceTree.prototype.drawSurfaceFitOnly = function() { this.counter++; // this.surfaceTracer.trace(this.surfaceTree);//this.rootId); @@ -483,7 +482,7 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { tile.updateTexelSize(); - var typeFactor = this.freeLayerSurface ? 1 : 1; + //var typeFactor = this.freeLayerSurface ? 1 : 1; var draw = map.draw; var drawTiles = draw.drawTiles; @@ -493,14 +492,12 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { var drawBufferIndex = 0; var processBufferIndex = 0; var newProcessBufferIndex = 0; - var checkGpu = true; processBuffer[0] = tile; processBufferIndex = 1; var texelSizeFit = draw.texelSizeFit; - var best2 = 0; var replay = map.draw.replay; var storeNodes = replay.storeNodes || replay.storeFreeNodes; var storeNodesBuffer = replay.nodeBuffer; @@ -510,13 +507,13 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { var usedNodes = 1; var pocessedNodes = 1; var pocessedMetatiles = 1; - var drawCounter = map.drawCounter; + var drawCounter = map.drawCounter, i, j, lj; do { var best = 0; newProcessBufferIndex = 0; - for (var i = processBufferIndex - 1; i >= 0; i--) { + for (i = processBufferIndex - 1; i >= 0; i--) { tile = processBuffer[i]; node = tile.metanode; @@ -550,10 +547,9 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { } else { //go deeper var childrenCount = 0; - var readyCount = 0; var childrenBuffer = []; - for (var j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { var child = tile.children[j]; if (child) { childrenCount++; @@ -563,7 +559,7 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { this.updateNodeHeightExtents(child, child.metanode); child.updateTexelSize(); - var priority = child.id[0] * typeFactor * child.distance; + //var priority = child.id[0] * typeFactor * child.distance; //are draw buffers ready? preventRender=true, preventLoad=false //if (this.map.drawSurfaceTile(child, child.metanode, cameraPos, child.texelSize, priority, true, false)) { @@ -597,7 +593,7 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { do { var sorted = true; - for (var j = 0, lj = childrenBuffer.length - 1; j < lj; j++) { + for (j = 0, lj = childrenBuffer.length - 1; j < lj; j++) { if (childrenBuffer[j].distance > childrenBuffer[j+1].distance) { var t = childrenBuffer[j]; childrenBuffer[j] = childrenBuffer[j+1]; @@ -609,7 +605,7 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { } while(!sorted); //add childern to new process buffer - for (var j = 0, lj = childrenBuffer.length; j < lj; j++) { + for (j = 0, lj = childrenBuffer.length; j < lj; j++) { //var n = childrenBuffer[j].metanode.divisionNode; //if ((n.id[0] == 1 && n.id[1] == 1 && n.id[2] == 0)) { @@ -631,9 +627,9 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { newProcessBuffer = tmp; processBufferIndex = newProcessBufferIndex; - if (best != 0) { - best2 = best; - } + //if (best != 0) { + // best2 = best; + //} } while(processBufferIndex > 0); @@ -647,12 +643,12 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { } var tiles = draw.tileBuffer[0]; - for (var i = drawBufferIndex - 1; i >= 0; i--) { + for (i = drawBufferIndex - 1; i >= 0; i--) { tiles.push(drawBuffer[i]); } } - for (var i = drawBufferIndex - 1; i >= 0; i--) { + for (i = drawBufferIndex - 1; i >= 0; i--) { tile = drawBuffer[i]; //draw tile, preventRender=false, preventLoad=false drawTiles.drawSurfaceTile(tile, tile.metanode, cameraPos, tile.texelSize, 0, false, false); @@ -661,7 +657,7 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { //loadmode = fit -MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { +MapSurfaceTree.prototype.drawSurfaceFit = function() { this.counter++; // this.surfaceTracer.trace(this.surfaceTree);//this.rootId); @@ -704,7 +700,6 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { var texelSizeFit = draw.texelSizeFit; - var best2 = 0; var storeNodes = replay.storeNodes || replay.storeFreeNodes; var storeNodesBuffer = replay.nodeBuffer; @@ -714,7 +709,7 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { var pocessedNodes = 1; var pocessedMetatiles = 1; var drawCounter = draw.drawCounter; - var maxHiresLodLevels = map.config.mapMaxHiresLodLevels; + var maxHiresLodLevels = map.config.mapMaxHiresLodLevels, i, j, lj, child, priority; do { var best = 0; @@ -724,7 +719,7 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { console.log("processed begin=============================================="); }*/ - for (var i = processBufferIndex - 1; i >= 0; i--) { + for (i = processBufferIndex - 1; i >= 0; i--) { var pack = processBuffer[i]; tile = pack[0]; var depth = pack[1]; @@ -783,14 +778,14 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { if (node.hasChildren() == false || tile.texelSize <= texelSizeFit) { - var priority = ((tile.id[0] + lodShift) * typeFactor) * tile.distance; + priority = ((tile.id[0] + lodShift) * typeFactor) * tile.distance; if (node.hasChildren() && !drawTiles.drawSurfaceTile(tile, tile.metanode, cameraPos, tile.texelSize, priority, true, (depth > 0), checkGpu)) { depth++; //we dont have tile ready, so we try to draw more detailed tiles - for (var j = 0; j < 4; j++) { - var child = tile.children[j]; + for (j = 0; j < 4; j++) { + child = tile.children[j]; if (child) { if (child.isMetanodeReady(this, child.id[0], true)) { //lod is used as priority @@ -798,7 +793,7 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { this.updateNodeHeightExtents(child, child.metanode); child.updateTexelSize(); - var priority = ((child.id[0] + lodShift) * typeFactor) * child.distance; + //var priority = ((child.id[0] + lodShift) * typeFactor) * child.distance; /*if (child.id[0] == 18 && child.id[1] == 20982 && @@ -832,8 +827,8 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { var readyCount = 0; var childrenBuffer = []; - for (var j = 0; j < 4; j++) { - var child = tile.children[j]; + for (j = 0; j < 4; j++) { + child = tile.children[j]; if (child) { childrenCount++; @@ -842,7 +837,7 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { this.updateNodeHeightExtents(child, child.metanode); child.updateTexelSize(); - var priority = ((child.id[0] + lodShift) * typeFactor) * child.distance; + priority = ((child.id[0] + lodShift) * typeFactor) * child.distance; //are draw buffers ready? preventRender=true, preventLoad=false if (drawTiles.drawSurfaceTile(child, child.metanode, cameraPos, child.texelSize, priority, true, true, checkGpu)) { @@ -861,7 +856,7 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { do { var sorted = true; - for (var j = 0, lj = childrenBuffer.length - 1; j < lj; j++) { + for (j = 0, lj = childrenBuffer.length - 1; j < lj; j++) { if (childrenBuffer[j].distance > childrenBuffer[j+1].distance) { var t = childrenBuffer[j]; childrenBuffer[j] = childrenBuffer[j+1]; @@ -873,7 +868,7 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { } while(!sorted); //add childern to new process buffer - for (var j = 0, lj = childrenBuffer.length; j < lj; j++) { + for (j = 0, lj = childrenBuffer.length; j < lj; j++) { newProcessBuffer[newProcessBufferIndex] = [childrenBuffer[j], depth]; newProcessBufferIndex++; } @@ -882,14 +877,14 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { //can i use coarser lod //if (child.isMetanodeReady(this, child.id[0])) { //lod is used as priority - var priority = ((tile.id[0] + lodShift) * typeFactor) * tile.distance; + priority = ((tile.id[0] + lodShift) * typeFactor) * tile.distance; if (drawTiles.drawSurfaceTile(tile, tile.metanode, cameraPos, tile.texelSize, priority, true, true, checkGpu)) { drawBuffer[drawBufferIndex] = [tile, false]; drawBufferIndex++; - for (var j = 0; j < 4; j++) { - var child = tile.children[j]; + for (j = 0; j < 4; j++) { + child = tile.children[j]; if (child) { if (child.isMetanodeReady(this, child.id[0])) { //lod is used as priority priority = ((child.id[0] + lodShift) * typeFactor) * child.distance; @@ -907,8 +902,8 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { newProcessBufferIndex++; }*/ - for (var j = 0; j < 4; j++) { - var child = tile.children[j]; + for (j = 0; j < 4; j++) { + child = tile.children[j]; if (child) { if (child.isMetanodeReady(this, child.id[0])) { //lod is used as priority this.updateNodeHeightExtents(child, child.metanode); @@ -926,8 +921,8 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { } else { //go deeper - for (var j = 0; j < 4; j++) { - var child = tile.children[j]; + for (j = 0; j < 4; j++) { + child = tile.children[j]; if (child) { /*if (child.id[0] == 18 && @@ -968,10 +963,6 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { processBuffer = newProcessBuffer; newProcessBuffer = tmp; processBufferIndex = newProcessBufferIndex; - - if (best != 0) { - best2 = best; - } } while(processBufferIndex > 0); @@ -985,12 +976,12 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { } var tiles = draw.tileBuffer[0]; - for (var i = drawBufferIndex - 1; i >= 0; i--) { + for (i = drawBufferIndex - 1; i >= 0; i--) { tiles.push(drawBuffer[i]); } } - for (var i = drawBufferIndex - 1; i >= 0; i--) { + for (i = drawBufferIndex - 1; i >= 0; i--) { var item = drawBuffer[i]; tile = drawBuffer[i]; /* @@ -1002,7 +993,7 @@ MapSurfaceTree.prototype.drawSurfaceFit = function(shift) { */ //draw tile, preventRender=false, preventLoad=false - var tile = item[0]; + tile = item[0]; if (drawGrid && item[1]) { tile.drawGrid(cameraPos); } else if (!item[1]) { @@ -1059,7 +1050,7 @@ MapSurfaceTree.prototype.traceHeightTile = function(tile, priority, nodeReadyOnl }; -MapSurfaceTree.prototype.traceHeightChild = function(tile, params, res) { +MapSurfaceTree.prototype.traceHeightChild = function(tile, params) { var coords = params.coords; var extents = params.extents; var center = [(extents.ll[0] + extents.ur[0]) *0.5, @@ -1104,7 +1095,7 @@ MapSurfaceTree.prototype.traceHeightChild = function(tile, params, res) { }; -MapSurfaceTree.prototype.traceHeightTileByMap = function(tile, params, priority) { +MapSurfaceTree.prototype.traceHeightTileByMap = function(tile, params) { if (!tile || (tile.id[0] > params.desiredLod && params.heightMap)) { return false; } @@ -1159,7 +1150,7 @@ MapSurfaceTree.prototype.traceHeightTileByMap = function(tile, params, priority) }; -MapSurfaceTree.prototype.traceHeightTileByNodeOnly = function(tile, params, priority) { +MapSurfaceTree.prototype.traceHeightTileByNodeOnly = function(tile, params) { if (!tile || tile.id[0] > params.desiredLod) { return false; } @@ -1181,7 +1172,6 @@ MapSurfaceTree.prototype.traceHeightTileByNodeOnly = function(tile, params, prio MapSurfaceTree.prototype.getNodeById = function(id) { var tile = this.surfaceTree; - var createNonexisted = true; if (tile == null) { return; diff --git a/src/core/map/surface.js b/src/core/map/surface.js index c020a3f7..a8785dba 100755 --- a/src/core/map/surface.js +++ b/src/core/map/surface.js @@ -1,4 +1,3 @@ - import MapCredit_ from './credit'; import MapStylesheet_ from './stylesheet'; import MapSurfaceTree_ from './surface-tree'; @@ -59,9 +58,9 @@ var MapSurface = function(map, json, type) { if (typeof json === 'string') { this.jsonUrl = this.map.url.processUrl(json); - this.baseUrl = utilsUrl_.getBase(this.jsonUrl); - this.baseUrlSchema = utilsUrl_.getSchema(this.jsonUrl); - this.baseUrlOrigin = utilsUrl_.getOrigin(this.jsonUrl); + this.baseUrl = utilsUrl.getBase(this.jsonUrl); + this.baseUrlSchema = utilsUrl.getSchema(this.jsonUrl); + this.baseUrlOrigin = utilsUrl.getOrigin(this.jsonUrl); var onLoaded = (function(data){ this.parseJson(data); @@ -97,6 +96,8 @@ MapSurface.prototype.parseJson = function(json) { this.credits = json['credits'] || []; this.creditsUrl = null; this.displaySize = json['displaySize'] || 256; + + var i, li; if (json['extents']) { var ll = json['extents']['ll']; @@ -126,7 +127,7 @@ MapSurface.prototype.parseJson = function(json) { } } - for (var i = 0, li = this.credits.length; i < li; i++) { + for (i = 0, li = this.credits.length; i < li; i++) { var credit = this.map.getCreditById(this.credits[i]); this.creditsNumbers.push(credit ? credit.id : null); } @@ -153,7 +154,7 @@ MapSurface.prototype.parseJson = function(json) { this.surfaceReference = []; if (this.glue) { - for (var i = 0, li = this.id.length; i < li; i++) { + for (i = 0, li = this.id.length; i < li; i++) { this.surfaceReference.push(this.map.getSurface(this.id[i])); } } @@ -174,7 +175,7 @@ MapSurface.prototype.kill = function() { }; -MapSurface.prototype.setOptions = function(options) { +MapSurface.prototype.setOptions = function() { }; @@ -371,6 +372,4 @@ export default MapSurface; - - - + \ No newline at end of file diff --git a/src/core/map/texture.js b/src/core/map/texture.js index 68fc85ae..4b916891 100755 --- a/src/core/map/texture.js +++ b/src/core/map/texture.js @@ -62,7 +62,7 @@ MapTexture.prototype.kill = function() { }; -MapTexture.prototype.killImage = function(killedByCache) { +MapTexture.prototype.killImage = function() { this.mainTexture.killImage(); if (this.maskTexture) { @@ -71,7 +71,7 @@ MapTexture.prototype.killImage = function(killedByCache) { }; -MapTexture.prototype.killGpuTexture = function(killedByCache) { +MapTexture.prototype.killGpuTexture = function() { this.mainTexture.killGpuTexture(); if (this.maskTexture) { @@ -110,12 +110,14 @@ MapTexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu) { if (this.neverReady) { return false; } + + var parent; if (this.extraBound) { if (this.extraBound.texture) { while (this.extraBound.texture.extraBound || this.extraBound.texture.checkStatus == -1) { // while (this.extraBound.texture.checkStatus == -1) { - var parent = this.extraBound.sourceTile.parent; + parent = this.extraBound.sourceTile.parent; if (parent.id[0] < this.extraBound.layer.lodRange[0]) { this.neverReady = true; this.extraBound.tile.resetDrawCommands = true; @@ -168,7 +170,7 @@ MapTexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu) { var path = this.extraInfo.metaPath; if(!this.extraInfo.metaPath) { - var path = layer.getMetatileUrl(metaresources.id); + path = layer.getMetatileUrl(metaresources.id); this.extraInfo.metaPath = path; } @@ -187,7 +189,7 @@ MapTexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu) { if (this.checkStatus == 2) { if (!(value & 64)) { //load mask - var path = layer.getMaskUrl(tile.id); + path = layer.getMaskUrl(tile.id); this.maskTexture = tile.resources.getTexture(path, null, null, null, this.tile, this.internal); this.checkStatus = 0; tile.resetDrawCommands = true; @@ -201,7 +203,7 @@ MapTexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu) { if (this.checkStatus == -1) { if (!this.extraBound) { - var parent = this.extraInfo.tile.parent; + parent = this.extraInfo.tile.parent; if (parent.id[0] < this.extraInfo.layer.lodRange[0]) { this.neverReady = true; this.extraInfo.tile.resetDrawCommands = true; @@ -216,7 +218,7 @@ MapTexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu) { while (this.extraBound.texture.extraBound || this.extraBound.texture.checkStatus == -1) { //while (this.extraBound.texture.checkStatus == -1) { - var parent = this.extraBound.sourceTile.parent; + parent = this.extraBound.sourceTile.parent; if (parent.id[0] < this.extraBound.layer.lodRange[0]) { this.neverReady = true; this.extraBound.tile.resetDrawCommands = true; diff --git a/src/core/map/trajectory.js b/src/core/map/trajectory.js index ce9de95e..71b46210 100755 --- a/src/core/map/trajectory.js +++ b/src/core/map/trajectory.js @@ -84,7 +84,7 @@ var MapTrajectory = function(map, p1, p2, options) { this.azimuth = (this.azimuth < 0) ? (360 + this.azimuth) : this.azimuth; if (!this.map.getNavigationSrs().isProjected()) { - var res = this.geodesic.Inverse(this.pp1.pos[2], this.pp1.pos[1], this.pp2.pos[2], this.pp2.pos[1]); + res = this.geodesic.Inverse(this.pp1.pos[2], this.pp1.pos[1], this.pp2.pos[2], this.pp2.pos[1]); this.geoAzimuth = res.azi1; this.geoDistance = res.s12; this.azimuth = this.geoAzimuth % 360; @@ -170,11 +170,11 @@ MapTrajectory.prototype.generate = function() { for (var time = 0; time <= this.duration; time += this.samplePeriod) { var factor = time / this.duration; - var p = this.pp1.clone(); + var p = this.pp1.clone(), x, coords; if (this.mode == 'direct') { - var x = factor; + x = factor; switch(this.fade) { case 'in': @@ -227,7 +227,7 @@ MapTrajectory.prototype.generate = function() { } else { //http://en.wikipedia.org/wiki/Smoothstep - var x = factor; + x = factor; factor = x*x*(3 - 2*x); x = factor; factor = x*x*(3 - 2*x); @@ -250,13 +250,13 @@ MapTrajectory.prototype.generate = function() { * (1 - Math.cos(2 * Math.PI * time / this.duration)) + h1 + (h2 - h1) * time / this.duration; - var coords = this.getInterpolatedCoords(distanceFactor); + coords = this.getInterpolatedCoords(distanceFactor); p.setCoords(coords); p.setHeight(height); } else { - var coords = this.getInterpolatedCoords(factor2); + coords = this.getInterpolatedCoords(factor2); p.setCoords(coords); p.setHeight(this.getSineHeight(factor)); diff --git a/src/core/map/url.js b/src/core/map/url.js index 60802351..22abac70 100755 --- a/src/core/map/url.js +++ b/src/core/map/url.js @@ -11,9 +11,9 @@ var MapUrl = function(map, path) { this.map = map; path = path.trim(); - this.baseUrl = utilsUrl_.getBase(path); - this.baseUrlSchema = utilsUrl_.getSchema(path); - this.baseUrlOrigin = utilsUrl_.getOrigin(path); + this.baseUrl = utilsUrl.getBase(path); + this.baseUrlSchema = utilsUrl.getSchema(path); + this.baseUrlOrigin = utilsUrl.getOrigin(path); this.urlCounter = 0; }; @@ -45,7 +45,7 @@ MapUrl.prototype['msDigit'] = function(iy, ix) { }; -MapUrl.prototype.hex = function(v, n) { +MapUrl.prototype.hex = function(v) { var s = v.toString(16); while (s.length < 8) { s = '0' + s; @@ -65,28 +65,28 @@ MapUrl.prototype['ppy'] = function(lod, iy) { MapUrl.prototype.processUrlFunction = function(id, counter, string) { + var string2, fc; if (typeof string == 'string') { if (string.indexOf('quad') != -1) { - var string2 = '(function(lod,x,y,loclod,locx,locy){' + string.replace('quad', 'return this.quad') + '})'; + string2 = '(function(lod,x,y,loclod,locx,locy){' + string.replace('quad', 'return this.quad') + '})'; try { - var fc = eval(string2).bind(this); + fc = eval(string2).bind(this); return fc(id.lod, id.ix, id.iy, id.loclod, id.locx, id.locy); } catch(e) { return string; } } else if (string.indexOf('msdigit') != -1) { - var string2 = '(function(x,y,loclod,locx,locy){' + string.replace('msdigit', 'return this.msDigit') + '})'; + string2 = '(function(x,y,loclod,locx,locy){' + string.replace('msdigit', 'return this.msDigit') + '})'; try { - var fc = eval(string2).bind(this); + fc = eval(string2).bind(this); return fc(id.ix, id.iy, id.loclod, id.locx, id.locy); } catch(e) { return string; } } else if (string.indexOf('alt') != -1) { - var result = /\(([^)]*)\)/.exec(string); if (result && result[1]) { @@ -100,22 +100,20 @@ MapUrl.prototype.processUrlFunction = function(id, counter, string) { return string; } else if (string.indexOf('ppx') != -1) { - - var string2 = '(function(lod,x,loclod,locx){' + string.replace('ppx', 'return this.ppx') + '})'; + string2 = '(function(lod,x,loclod,locx){' + string.replace('ppx', 'return this.ppx') + '})'; try { - var fc = eval(string2).bind(this); + fc = eval(string2).bind(this); return fc(id.lod, id.ix, id.loclod, id.locx); } catch(e) { return string; } } else if (string.indexOf('ppy') != -1) { - - var string2 = '(function(lod,y,loclod,locy){' + string.replace('ppy', 'return this.ppy') + '})'; + string2 = '(function(lod,y,loclod,locy){' + string.replace('ppy', 'return this.ppy') + '})'; try { - var fc = eval(string2).bind(this); + fc = eval(string2).bind(this); return fc(id.lod, id.iy, id.loclod, id.locy); } catch(e) { return string; @@ -150,7 +148,7 @@ MapUrl.prototype.findLocalRoot = function(id) { var bestNode = null; var bestLod = -1; - for (var i = 0, li = validNodes.length; i < li; i++) { + for (i = 0, li = validNodes.length; i < li; i++) { if (validNodes[i].id[0] > bestLod) { bestNode = validNodes[i]; } diff --git a/src/core/map/virtual-surface.js b/src/core/map/virtual-surface.js index 28ba2910..5a2ac69b 100755 --- a/src/core/map/virtual-surface.js +++ b/src/core/map/virtual-surface.js @@ -7,7 +7,7 @@ var BBox = BBox_; var utils = utils_; -var MapVirtualSurface = function(map, json, type) { +var MapVirtualSurface = function(map, json) { this.map = map; this.id = null; this.metaUrl = ''; @@ -59,7 +59,7 @@ MapVirtualSurface.prototype.onMappingFileLoaded = function(data) { }; -MapVirtualSurface.prototype.onMappingFileLoadError = function(data) { +MapVirtualSurface.prototype.onMappingFileLoadError = function() { }; diff --git a/src/core/renderer/camera.js b/src/core/renderer/camera.js index ca730a6f..05579f38 100755 --- a/src/core/renderer/camera.js +++ b/src/core/renderer/camera.js @@ -189,10 +189,12 @@ Camera.prototype.distance = function(worldPos) { Camera.prototype.pointVisible = function(point, shift) { if (this.dirty) this.update(); + var p; + if (shift) { - var p = [ point[0] - shift[0], point[1] - shift[1], point[2] - shift[2], 1 ]; + p = [ point[0] - shift[0], point[1] - shift[1], point[2] - shift[2], 1 ]; } else { - var p = [ point[0], point[1], point[2], 1 ]; + p = [ point[0], point[1], point[2], 1 ]; } // test all frustum planes quickly @@ -213,17 +215,16 @@ Camera.prototype.pointsVisible = function(points, shift) { if (this.dirty) this.update(); var planes = this.frustumPlanes; - var points2 = this.bboxPoints; - var lj = points.length; + var lj = points.length, sx, sy, sz; if (shift) { - var sx = shift[0]; - var sy = shift[1]; - var sz = shift[2]; + sx = shift[0]; + sy = shift[1]; + sz = shift[2]; } else { - var sx = 0; - var sy = 0; - var sz = 0; + sx = 0; + sy = 0; + sz = 0; } var dot = vec4.dot3; @@ -273,24 +274,24 @@ Camera.prototype.bboxVisible = function(bbox, shift) { */ var points = this.bboxPoints; - var p; + var p, minX, minY, minZ, maxX, maxY, maxZ; if (shift) { - var minX = min[0] - shift[0]; - var minY = min[1] - shift[1]; - var minZ = min[2] - shift[2]; - - var maxX = max[0] - shift[0]; - var maxY = max[1] - shift[1]; - var maxZ = max[2] - shift[2]; + minX = min[0] - shift[0]; + minY = min[1] - shift[1]; + minZ = min[2] - shift[2]; + + maxX = max[0] - shift[0]; + maxY = max[1] - shift[1]; + maxZ = max[2] - shift[2]; } else { - var minX = min[0]; - var minY = min[1]; - var minZ = min[2]; + minX = min[0]; + minY = min[1]; + minZ = min[2]; - var maxX = max[0]; - var maxY = max[1]; - var maxZ = max[2]; + maxX = max[0]; + maxY = max[1]; + maxZ = max[2]; } p = points[0]; diff --git a/src/core/renderer/draw.js b/src/core/renderer/draw.js index b8b3d7f4..35af3b26 100755 --- a/src/core/renderer/draw.js +++ b/src/core/renderer/draw.js @@ -177,7 +177,6 @@ RendererDraw.prototype.drawBall = function(position, size, shader, params, param RendererDraw.prototype.drawBall2 = function(position, size, shader, nfactor, dir, radius2) { var gpu = this.gpu; - var gl = this.gl; var renderer = this.renderer; //gl.disable(gl.CULL_FACE); @@ -223,13 +222,13 @@ RendererDraw.prototype.drawLineString = function(points, size, color, depthTest, var gpu = this.gpu; var gl = this.gl; var renderer = this.renderer; - var index = 0; + var index = 0, p, i; var totalPoints = points.length; if (totalPoints > 32) { - for (var i = 0; i < totalPoints; i += 31) { - var p = points.slice(i, i + 32); + for (i = 0; i < totalPoints; i += 31) { + p = points.slice(i, i + 32); this.drawLineString(p, size, color, depthTest, transparent, writeDepth, useState); } return; @@ -238,8 +237,8 @@ RendererDraw.prototype.drawLineString = function(points, size, color, depthTest, var plineBuffer = renderer.plineBuffer; //fill points - for (var i = 0; i < totalPoints; i++) { - var p = points[i]; + for (i = 0; i < totalPoints; i++) { + p = points[i]; plineBuffer[index] = p[0]; plineBuffer[index+1] = p[1]; plineBuffer[index+2] = p[2] || 0; @@ -644,7 +643,7 @@ RendererDraw.prototype.drawGpuJobs = function() { //draw job buffer and also clean buffer for (var i = 0, li = jobZBuffer.length; i < li; i++) { - var lj = jobZBufferSize[i]; + var j, lj = jobZBufferSize[i]; var buffer = jobZBuffer[i]; if (lj > 0 && i >= clearPass) { @@ -660,13 +659,13 @@ RendererDraw.prototype.drawGpuJobs = function() { if (onlyHitLayers) { - for (var j = 0; j < lj; j++) { + for (j = 0; j < lj; j++) { if (buffer[j].hitable) { this.drawGpuJob(gpu, gl, this, buffer[j], screenPixelSize); } } } else { - for (var j = 0; j < lj; j++) { + for (j = 0; j < lj; j++) { this.drawGpuJob(gpu, gl, this, buffer[j], screenPixelSize); //buffer[j] = null; } @@ -791,12 +790,8 @@ RendererDraw.prototype.paintGL = function() { RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixelSize) { - var gpu = this.gpu; - var gl = this.gl; - var renderer = this.renderer; - - var mv = job.mv; - var mvp = job.mvp; + var mvp = job.mvp, prog, texture; + var vertexPositionAttribute, vertexTexcoordAttribute; if (!job.ready) { return; @@ -847,13 +842,13 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel } gpu.setState(renderer.stencilLineState); - var prog = renderer.progLine; + prog = renderer.progLine; gpu.useProgram(prog, ['aPosition']); prog.setVec4('uColor', color); prog.setMat4('uMVP', mvp, renderer.getZoffsetFactor(job.zbufferOffset)); - var vertexPositionAttribute = prog.getAttribute('aPosition'); + vertexPositionAttribute = prog.getAttribute('aPosition'); //bind vetex positions gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); @@ -873,8 +868,8 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel gpu.setState(renderer.stencilLineState); } - var prog = job.program; - var texture = null; + prog = job.program; + texture = null; var textureParams = [0,0,0,0]; if (job.type != 'pixel-line') { @@ -894,7 +889,7 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel if (job.type == 'flat-tline') { textureParams[0] = 1/job.lineWidth/(texture.width/t[2]); } else { - var lod = job.lod; // || job.layer.currentLod; + //lod = job.lod; // || job.layer.currentLod; var tileSize = 256;//job.layer.core.mapConfig.tileSize(lod); var tilePixelSize = tileSize / 256;//job.layer.tilePixels; textureParams[0] = 1/texture.width/tilePixelSize; @@ -921,7 +916,7 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel prog.setSampler('uSampler', 0); } - var vertexPositionAttribute = prog.getAttribute('aPosition'); + vertexPositionAttribute = prog.getAttribute('aPosition'); var vertexNormalAttribute = prog.getAttribute('aNormal'); //bind vetex positions @@ -944,12 +939,12 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel gpu.setState(renderer.lineLabelState); } - var texture = hitmapRender ? renderer.whiteTexture : renderer.font.texture; + texture = hitmapRender ? renderer.whiteTexture : renderer.font.texture; //var yaw = math.radians(renderer.cameraOrientation[0]); //var forward = [-Math.sin(yaw), Math.cos(yaw), 0, 0]; - var prog = renderer.progText; + prog = renderer.progText; gpu.bindTexture(texture); @@ -960,8 +955,8 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel prog.setVec4('uColor', color); //prog.setVec2("uScale", screenPixelSize); - var vertexPositionAttribute = prog.getAttribute('aPosition'); - var vertexTexcoordAttribute = prog.getAttribute('aTexCoord'); + vertexPositionAttribute = prog.getAttribute('aPosition'); + vertexTexcoordAttribute = prog.getAttribute('aTexCoord'); //bind vetex positions gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); @@ -984,19 +979,21 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel gpu.setState(renderer.lineLabelState); } - var texture = hitmapRender ? renderer.whiteTexture : job.texture; + texture = hitmapRender ? renderer.whiteTexture : job.texture; if (!texture.loaded) { return; } + var p1, p2, camVec, l; + if (job.culling != 180) { - var p2 = job.center; - var p1 = renderer.cameraPosition; - var camVec = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]]; + p2 = job.center; + p1 = renderer.cameraPosition; + camVec = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]]; if (job.visibility != 0) { - var l = vec3.length(camVec); + l = vec3.length(camVec); if (l > job.visibility) { return; } @@ -1017,10 +1014,10 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel return; } } else if (job.visibility != 0) { - var p2 = job.center; - var p1 = renderer.cameraPosition; - var camVec = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]]; - var l = vec3.length(camVec); + p2 = job.center; + p1 = renderer.cameraPosition; + camVec = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]]; + l = vec3.length(camVec); if (l > job.visibility) { return; } @@ -1051,7 +1048,7 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel } } - var prog = renderer.progIcon; + prog = renderer.progIcon; gpu.bindTexture(texture); @@ -1062,8 +1059,8 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel prog.setVec4('uColor', color); //prog.setVec2("uScale", screenPixelSize); - var vertexPositionAttribute = prog.getAttribute('aPosition'); - var vertexTexcoordAttribute = prog.getAttribute('aTexCoord'); + vertexPositionAttribute = prog.getAttribute('aPosition'); + vertexTexcoordAttribute = prog.getAttribute('aTexCoord'); var vertexOriginAttribute = prog.getAttribute('aOrigin'); //bind vetex positions diff --git a/src/core/renderer/geometry.js b/src/core/renderer/geometry.js index d01e3547..b76f002a 100755 --- a/src/core/renderer/geometry.js +++ b/src/core/renderer/geometry.js @@ -45,7 +45,6 @@ RendererGeometry.buildHeightmap = function(size) { var vertices = new Float32Array(numFaces * 3 * 3);//[]; var uvs = new Float32Array(numFaces * 3 * 2);//[]; - var USHRTMAX = 65535; var factor = 1.0 * size; var index = 0; var index2 = 0; @@ -84,7 +83,6 @@ RendererGeometry.buildPlane = function(size) { var vertices = new Float32Array(numFaces * 3 * 3);//[]; var uvs = new Float32Array(numFaces * 3 * 2);//[]; - var USHRTMAX = 65535; var factor = 1.0 / (size); var index = 0; var index2 = 0; diff --git a/src/core/renderer/gpu/bbox.js b/src/core/renderer/gpu/bbox.js index 7cc02b49..38827456 100755 --- a/src/core/renderer/gpu/bbox.js +++ b/src/core/renderer/gpu/bbox.js @@ -15,8 +15,10 @@ var GpuBBox = function(gpu, free) { this.vertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBuffer); + var vertices; + if (free) { - var vertices = [0,0,0, 0,0,1, + vertices = [0,0,0, 0,0,1, 0,0,1, 0,0,2, 0,0,2, 0,0,3, 0,0,3, 0,0,0, @@ -31,7 +33,7 @@ var GpuBBox = function(gpu, free) { 0,0,2, 0,0,6, 0,0,3, 0,0,7 ]; } else { - var vertices = [0,0,0, 1,0,0, + vertices = [0,0,0, 1,0,0, 1,0,0, 1,1,0, 1,1,0, 0,1,0, 0,1,0, 0,0,0, diff --git a/src/core/renderer/gpu/device.js b/src/core/renderer/gpu/device.js index 08fda4fe..ce721182 100755 --- a/src/core/renderer/gpu/device.js +++ b/src/core/renderer/gpu/device.js @@ -131,7 +131,7 @@ GpuDevice.prototype.useProgram = function(program, attributes, nextSampler) { } // - for (var i = 0, li = attributes.length; i < li; i++){ + for (i = 0, li = attributes.length; i < li; i++){ var index = program.getAttribute(attributes[i]); if (index != -1){ @@ -140,7 +140,7 @@ GpuDevice.prototype.useProgram = function(program, attributes, nextSampler) { } //enable or disable current attributes according to new attributes list - for (var i = 0, li = newAttributes.length; i < li; i++){ + for (i = 0, li = newAttributes.length; i < li; i++){ if (enabledAttributes[i] != newAttributes[i]) { if (newAttributes[i]) { this.gl.enableVertexAttribArray(i); @@ -193,30 +193,13 @@ GpuDevice.prototype.createState = function(state) { }; -GpuDevice.prototype.setState = function(state, directOffset) { - /* - if (this.currentState == state) { - - if (directOffset != null) { - //if (directOffset != this.currentOffset) { - this.currentOffset = directOffset; - this.gl.polygonOffset(-1.0, directOffset); - //} - } - - return; - } - - //this.gl.polygonOffset(-1.0, 0); - */ - +GpuDevice.prototype.setState = function(state) { if (!state) { return; } var gl = this.gl; var currentState = this.currentState; - //directOffset = directOffset || state.zoffset; if (currentState.blend != state.blend) { if (state.blend) { @@ -235,17 +218,7 @@ GpuDevice.prototype.setState = function(state, directOffset) { gl.disable(gl.STENCIL_TEST); } } -/* - if (currentState.zoffset != directOffset) { - if (directOffset != 0) { - gl.polygonOffset(-1.0, directOffset); - gl.enable(gl.POLYGON_OFFSET_FILL); - } else { - gl.disable(gl.POLYGON_OFFSET_FILL); - } - this.currentOffset = directOffset; - } -*/ + if (currentState.zwrite != state.zwrite) { if (state.zwrite) { gl.depthMask(true); diff --git a/src/core/renderer/gpu/font.js b/src/core/renderer/gpu/font.js index 42a31259..d63eb0ea 100755 --- a/src/core/renderer/gpu/font.js +++ b/src/core/renderer/gpu/font.js @@ -49,7 +49,7 @@ GpuFont.prototype.generate = function(font, size) { //utDrawFilledRect(0, 0, textureLX, textureLY, [0,0,0,255]); - var fontSize = 10; + //var fontSize = 10; ctx.beginPath(); ctx.font = size + 'pt ' + font; ctx.textAlign = 'left'; @@ -68,29 +68,26 @@ GpuFont.prototype.generate = function(font, size) { var x = space; var y = space; - var cly = Math.floor(ctx.measureText('e').width * 2.5); - var clxe = Math.floor(ctx.measureText('e').width); - //var clxe = Math.floor(ctx.measureText("ee").width); this.chars = []; this.space = cly; this.size = size; this.font = font; - var codes = []; + var codes = [], i, li; - for (var i = 33; i < 191; i++) { + for (i = 33; i < 191; i++) { codes.push(i); } - for (var i = 192; i < 688; i++) { + for (i = 192; i < 688; i++) { codes.push(i); } codes = codes.concat(0x20, 0x2026, 0x2018, 0x2019, 0x201a, 0x201b, 0x201c, 0x201d, 0x201e, 0x2032, 0x2033, 0x203c); - for (var i = 0, li = codes.length; i < li; i++) { + for (i = 0, li = codes.length; i < li; i++) { var c = String.fromCharCode(codes[i]); var clx2 = Math.round(ctx.measureText(c).width); var clx = clx2 + ctx.lineWidth; diff --git a/src/core/renderer/gpu/group.js b/src/core/renderer/gpu/group.js index a50957ed..7914aec0 100755 --- a/src/core/renderer/gpu/group.js +++ b/src/core/renderer/gpu/group.js @@ -65,7 +65,7 @@ GpuGroup.prototype.size = function() { }; -GpuGroup.prototype.getZbufferOffset = function(params) { +GpuGroup.prototype.getZbufferOffset = function() { return this.size; }; @@ -329,20 +329,20 @@ GpuGroup.prototype.draw = function(mv, mvp, applyOrigin) { } if (applyOrigin) { + var origin; var mvp2 = mat4.create(); var mv2 = mat4.create(); - var pos = this.renderer.position; var transform = this.renderer.layerGroupTransform[this.id]; if (transform != null) { - var origin = transform[1]; + origin = transform[1]; origin = [origin[0] - pos[0], origin[1] - pos[1], origin[2]]; mat4.multiply(math.translationMatrix(origin[0], origin[1], origin[2]), transform[0], mv2); mat4.multiply(mv, mv2, mv2); } else { - var origin = [this.origin[0] - pos[0], this.origin[1] - pos[1], this.origin[2]]; + origin = [this.origin[0] - pos[0], this.origin[1] - pos[1], this.origin[2]]; mat4.multiply(mv, math.translationMatrix(origin[0], origin[1], origin[2]), mv2); } @@ -351,11 +351,7 @@ GpuGroup.prototype.draw = function(mv, mvp, applyOrigin) { mvp = mvp2; } - var gl = this.gl; - var gpu = this.gpu; - var cameraPos = this.renderer.cameraPosition; - var jobZBuffer = this.renderer.jobZBuffer; var jobZBufferSize = this.renderer.jobZBufferSize; diff --git a/src/core/renderer/gpu/mesh.js b/src/core/renderer/gpu/mesh.js index e96e48d3..71e279fd 100755 --- a/src/core/renderer/gpu/mesh.js +++ b/src/core/renderer/gpu/mesh.js @@ -9,8 +9,6 @@ var GpuMesh = function(gpu, meshData, fileSize, core) { this.uvBuffer = null; this.uv2Buffer = null; - var timer = performance.now(); - var vertices = meshData.vertices; var uvs = meshData.uvs; var uvs2 = meshData.uvs2; @@ -102,10 +100,6 @@ GpuMesh.prototype.draw = function(program, attrVertex, attrUV, attrUV2, attrBary if (gl == null || !this.valid) { return; } - - if (!this.vertexBuffer) { - gl = gl; - } //bind vetex positions var vertexAttribute = program.getAttribute(attrVertex); diff --git a/src/core/renderer/gpu/pixel-line3.js b/src/core/renderer/gpu/pixel-line3.js index 94ec78f7..9faba227 100755 --- a/src/core/renderer/gpu/pixel-line3.js +++ b/src/core/renderer/gpu/pixel-line3.js @@ -5,7 +5,6 @@ var GpuPixelLine3 = function(gpu, core, lines, maxLines, joins, joinSides) { this.gl = gpu.gl; this.core = core; - var timer = performance.now(); var gl = this.gl; if (gl == null){ @@ -30,20 +29,21 @@ GpuPixelLine3.prototype.kill = function() { GpuPixelLine3.prototype.init = function() { + var i; if (this.lines) { - if (this.joins) { - this.addCircle(0, this.joinSides); - } - - for (var i = 0; i < this.maxLines; i++) { + if (this.joins) { + this.addCircle(0, this.joinSides); + } + + for (i = 0; i < this.maxLines; i++) { this.addLine(i, i+1); if (this.joins) { - this.addCircle(i+1, this.joinSides); + this.addCircle(i+1, this.joinSides); } } } else if (this.joins) { - for (var i = 0; i <= this.maxLines; i++) { + for (i = 0; i <= this.maxLines; i++) { this.addCircle(i, this.joinSides); } } diff --git a/src/core/renderer/gpu/texture.js b/src/core/renderer/gpu/texture.js index bc95b190..31ffdf2b 100755 --- a/src/core/renderer/gpu/texture.js +++ b/src/core/renderer/gpu/texture.js @@ -98,8 +98,6 @@ GpuTexture.prototype.createFromData = function(lx, ly, data, filter, repeat) { GpuTexture.prototype.createFromImage = function(image, filter, repeat) { var gl = this.gl; - var timer = performance.now(); - this.texture = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, this.texture); diff --git a/src/core/renderer/init.js b/src/core/renderer/init.js index a9d4a3d6..844908a1 100755 --- a/src/core/renderer/init.js +++ b/src/core/renderer/init.js @@ -87,7 +87,7 @@ RendererInit.prototype.initHeightmap = function() { var meshData = RendererGeometry.buildHeightmap(5); renderer.heightmapMesh = new GpuMesh(gpu, meshData, null, this.core); - var meshData = RendererGeometry.buildPlane(16); + meshData = RendererGeometry.buildPlane(16); renderer.planeMesh = new GpuMesh(gpu, meshData, null, this.core); // create heightmap texture @@ -140,14 +140,12 @@ RendererInit.prototype.initTestMap = function() { var gpu = this.gpu; // create red texture - var size = 16; + var size = 16, i, j, li, lj, index; var data = new Uint8Array( size * size * 4 ); - for (var i = 0; i < size; i++) { - for (var j = 0; j < size; j++) { - - var index = (i*size+j)*4; - + for (i = 0; i < size; i++) { + for (j = 0; j < size; j++) { + index = (i*size+j)*4; data[index] = 255; data[index + 1] = 0; data[index + 2] = 0; @@ -158,11 +156,11 @@ RendererInit.prototype.initTestMap = function() { renderer.redTexture = new GpuTexture(gpu); renderer.redTexture.createFromData(size, size, data); - var data = new Uint8Array( size * size * 4 ); + data = new Uint8Array( size * size * 4 ); - for (var i = 0; i < size; i++) { - for (var j = 0; j < size; j++) { - var index = (i*size+j)*4; + for (i = 0; i < size; i++) { + for (j = 0; j < size; j++) { + index = (i*size+j)*4; data[index] = 255; data[index + 1] = 255; data[index + 2] = 255; @@ -173,11 +171,11 @@ RendererInit.prototype.initTestMap = function() { renderer.whiteTexture = new GpuTexture(gpu); renderer.whiteTexture.createFromData(size, size, data); - var data = new Uint8Array( size * size * 4 ); + data = new Uint8Array( size * size * 4 ); - for (var i = 0; i < size; i++) { - for (var j = 0; j < size; j++) { - var index = (i*size+j)*4; + for (i = 0; i < size; i++) { + for (j = 0; j < size; j++) { + index = (i*size+j)*4; data[index] = 0; data[index + 1] = 0; data[index + 2] = 0; @@ -190,7 +188,7 @@ RendererInit.prototype.initTestMap = function() { var sizeX = 64; var sizeY = 8; - var data = new Uint8Array( sizeX * sizeY * 4 ); + data = new Uint8Array( sizeX * sizeY * 4 ); var chars = [ '............................................................', @@ -204,14 +202,12 @@ RendererInit.prototype.initTestMap = function() { // create red texture - var data = new Uint8Array( sizeX * sizeY * 4 ); + data = new Uint8Array( sizeX * sizeY * 4 ); //clear texture - for (var i = 0; i < sizeY; i++) { - for (var j = 0; j < sizeX; j++) { - - var index = (i*sizeX+j)*4; - + for (i = 0; i < sizeY; i++) { + for (j = 0; j < sizeX; j++) { + index = (i*sizeX+j)*4; data[index] = 0; data[index + 1] = 0; data[index + 2] = 0; @@ -219,13 +215,11 @@ RendererInit.prototype.initTestMap = function() { } } - for (var i = 0, li = chars.length; i < li; i++) { - + for (i = 0, li = chars.length; i < li; i++) { var string = chars[i]; - for (var j = 0, lj = string.length; j < lj; j++) { - - var index = (i*sizeX+j)*4; + for (j = 0, lj = string.length; j < lj; j++) { + index = (i*sizeX+j)*4; if (string.charAt(j) != '.') { data[index] = 255; @@ -243,8 +237,6 @@ RendererInit.prototype.initTestMap = function() { RendererInit.prototype.initTextMap = function() { var renderer = this.renderer; - var sizeX = 64; - var sizeY = 8; //font texture var texture = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAACACAMAAADTa0c4AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRFAAAA////pdmf3QAABIFJREFUeNrsnNuyqzAIhsP7v/Se6Yxra0L4OUVNCzetVqP5DAQItrVOiLg95739NnfOaR99RDj6esBw+CKZXiMK4PiuBkAcANoHAP3J5fzzAV2jePQIt6f4Ndb/MIChlVcCEFpAACZPfN4KUAF0/ufboDW3AuBMFgBwHTCfg2ftYgDUKBuA1ABuHKvA2P+5XdONIEt7BO2o2MdlAJoTQOsV6GEAswt0Zq/bsBhdeQQkqEDMwmIAnJHzA8i3ASkWRFKBbADyLGB3mlYD6DyhA4DfBlgsBDtirUPcBgC5woStYMgVtgKATWcB6DskKUEkGFLYrGw3+l3ydR16wKbbPDlWp4Xfo9vZwR1jtOMA6GkABrdvNmt1Vluy6pyvxu4Xt62fquyTggCTsIkCoIuv8gAA08w+ATBXAdSRY56xPDFPx/VPWFZp5v65kFMPgFjP70YASMfRsDn01xLPcwkRq1HLMoK647hR8v+nId74MQBjvIbUQePra42ZVXVcBCR3mIY89mYAlNGLflqA0V1seosCQNMg80B0bsLGAIDNwvFyiqu66ngVGGMGVBwyWwIwpty2DqEr/qf0Bq+DbjYkkcr4VUoOxiRjrYn3YY5SC4BQB/cF0Lq4kD1RCJ+tN4g6Jps5zfWu+QmSz9sUABkA0BIAXocmBwCJ99MDIASATkmtLQAIft4IgE/ZDStZ59yQbOQQAGZWYMbZ3FFCAGRHnwHQznegGAE+zwxNi8kALCOgS9tzAC4jYG1Qo0myRm0Ae/z8eleqewBoZLwfUswCsbT1KgBZD6QAzAEoXUe3K+xxVf2uLf5U3nBeMPRyACW/LtrwVX989id3PRQOG5Io6vh9XwC6stHIdGdJozun03lxNlwvH4u6UgDM8/LmJyx7ak12feEebaXmUwCOYJWk1JcYKsl74HL74wAaH93NqkE1FSKXc4cv0AjaPEEPgE4ru/ieWdvzVq/4psG3AYDFHlEAioQCuEgMgPjK1VDrqlkbTABAiQBGK38B0BlBSf9xtiAJQDM4NtDqMlaeyduTtkDjHgAtEQBj5ZGK2QE0aCcMAIxLSw0WVYlGDgOQXWE+afouAM0S398O4Nej3wIQf4cIHSfz9pbWugyep4MFIAFARvspbm8BcE2DOdvWnCJQAWFhJ/hKzh4AaB2A7NxedKmLPc+6PN4cL2S8GYC1QMIEQJvmFsJfxdvkEQAoLV4AogBS8/kNvdXlWe5GKhABvQUAZASDALJffY1XfsrToFXFbvYD1gBo6wC8LR7/uvj9CwHcfWuoUJItsVl5nwWAnhxxqsXatUq0OYCcaS/fkbK61u5H8jwAuUIEZXHNL1Jmub5oSKZWiDR9FttM4HEAigqRpn8TeB2AuWNiByAXSHCGbB7/3qYCfgCgPgADEEskbjCCaJDB/+kR6wP4P1Obl8jsBwDUB4yAxqKkthaATjX0KmCtDyCxm+yIMLjCbwBgrg94FYC3h8vLPPmfAVBSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlLy9fJPgAEAvWMULbGsSjwAAAAASUVORK5CYII='; @@ -302,7 +294,7 @@ RendererInit.prototype.initSkydome = function() { renderer.skydomeMesh = new GpuMesh(this.gpu, meshData, null, this.core); //this.skydomeTexture = new GpuTexture(this.gpu, "./skydome.jpg", this.core); - var meshData = RendererGeometry.buildSkydome(128, 256); + meshData = RendererGeometry.buildSkydome(128, 256); // var meshData = RendererGeometry.buildSkydome(256, 512); renderer.atmoMesh = new GpuMesh(this.gpu, meshData, null, this.core); }; diff --git a/src/core/renderer/interface.js b/src/core/renderer/interface.js index e9d27af0..4b547ae9 100755 --- a/src/core/renderer/interface.js +++ b/src/core/renderer/interface.js @@ -64,21 +64,21 @@ RendererInterface.prototype.createTexture = function(options) { } var filter = options['filter'] || 'linear'; - var repeat = options['repeat'] || false; + var repeat = options['repeat'] || false, texture; if (source instanceof Uint8Array) { var width = options['width']; var height = options['height']; if (width && height) { - var texture = new GpuTexture(this.gpu); + texture = new GpuTexture(this.gpu); texture.createFromData(width, height, source, filter, repeat); return texture; } } if (source instanceof Image) { - var texture = new GpuTexture(this.gpu); + texture = new GpuTexture(this.gpu); texture.createFromImage(source, filter, repeat); return texture; } @@ -147,12 +147,12 @@ RendererInterface.prototype.removeResource = function(resource) { }; -RendererInterface.prototype.addJob = function(options) { +RendererInterface.prototype.addJob = function(/*options*/) { return this; }; -RendererInterface.prototype.clearJobs = function(options) { +RendererInterface.prototype.clearJobs = function(/*options*/) { return this; }; @@ -166,7 +166,7 @@ RendererInterface.prototype.drawMesh = function(options) { return this; } - var shaderAttributes = options['shaderAttributes']; + //var shaderAttributes = options['shaderAttributes']; var vertexAttr = options['vertex'] || 'aPosition'; var uvAttr = options['uv'] || 'aTexCoord'; var uv2Attr = options['normal'] || 'aNormal'; @@ -203,6 +203,7 @@ RendererInterface.prototype.drawMesh = function(options) { case 'shaded': uvAttr = null; + // eslint-disable-next-line case 'textured': case 'textured-and-shaded': @@ -354,12 +355,12 @@ RendererInterface.prototype.drawLineString = function(options) { }; -RendererInterface.prototype.drawJobs = function(options) { +RendererInterface.prototype.drawJobs = function(/*options*/) { return this; }; -RendererInterface.prototype.drawBBox = function(options) { +RendererInterface.prototype.drawBBox = function(/*options*/) { return this; }; @@ -409,7 +410,7 @@ RendererInterface.prototype.getCanvasCoords = function(point, mvp) { }; -RendererInterface.prototype.getCanvasSize = function(point, mvp) { +RendererInterface.prototype.getCanvasSize = function() { return this.renderer.curSize.slice(); }; diff --git a/src/core/renderer/renderer.js b/src/core/renderer/renderer.js index 3d4b8df4..d23d72ba 100755 --- a/src/core/renderer/renderer.js +++ b/src/core/renderer/renderer.js @@ -121,6 +121,7 @@ var Renderer = function(core, div, onUpdate, onResize, config) { this.gpu.init(); //intit resources + // eslint-disable-next-line var init = new RenderInit(this); this.draw = new RenderDraw(this); @@ -235,7 +236,7 @@ Renderer.prototype.project2 = function(point, mvp) { }; -Renderer.prototype.project = function(point, mvp) { +Renderer.prototype.project = function(point) { //get mode-view-projection matrix var mvp = this.camera.getMvpMatrix(); @@ -308,7 +309,7 @@ Renderer.prototype.getScreenRay = function(screenX, screenY) { }; -Renderer.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { +Renderer.prototype.hitTestGeoLayers = function(screenX, screenY) { var gl = this.gpu.gl; //conver screen coords to texture coords @@ -332,9 +333,9 @@ Renderer.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { var pixel = this.geoHitmapTexture.readFramebufferPixels(x, this.hitmapSize - y - 1, 1, 1); //convert rgb values into depth - var id = (pixel[0]) + (pixel[1]<<8) + (pixel[2]<<16);// + (pixel[3]*16581375.0); + //var id = (pixel[0]) + (pixel[1]<<8) + (pixel[2]<<16);// + (pixel[3]*16581375.0); - var surfaceHit = !(pixel[0] == 255 && pixel[1] == 255 && pixel[2] == 255 && pixel[3] == 255); + surfaceHit = !(pixel[0] == 255 && pixel[1] == 255 && pixel[2] == 255 && pixel[3] == 255); // console.log(JSON.stringify([pixel[0], pixel[1], pixel[2], pixel[3], surfaceHit])); @@ -349,12 +350,12 @@ Renderer.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { Renderer.prototype.switchToFramebuffer = function(type) { - var gl = this.gpu.gl; + var gl = this.gpu.gl, size, width, height; switch(type) { case 'base': - var width = this.oldSize[0]; - var height = this.oldSize[1]; + width = this.oldSize[0]; + height = this.oldSize[1]; gl.clearColor(0.0, 0.0, 0.0, 1.0); @@ -378,7 +379,7 @@ Renderer.prototype.switchToFramebuffer = function(type) { gl.clearColor(1.0,1.0, 1.0, 1.0); gl.enable(gl.DEPTH_TEST); - var size = this.hitmapSize; + size = this.hitmapSize; //clear screen gl.viewport(0, 0, size, size); @@ -402,15 +403,15 @@ Renderer.prototype.switchToFramebuffer = function(type) { this.hoverFeatureCounter = 0; - var size = this.hitmapSize; + size = this.hitmapSize; //set texture framebuffer this.gpu.setFramebuffer(this.geoHitmapTexture); - var oldSize = [ this.curSize[0], this.curSize[1] ]; + //var oldSize = [ this.curSize[0], this.curSize[1] ]; - var width = size; - var height = size; + width = size; + height = size; gl.clearColor(1.0,1.0, 1.0, 1.0); gl.enable(gl.DEPTH_TEST); @@ -538,7 +539,7 @@ Renderer.prototype.saveScreenshot = function(output, filename, filetype) { var byteString = atob(dataURI.split(',')[1]); // separate out the mime component - var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; + //var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; // write the bytes of the string to an ArrayBuffer var ab = new ArrayBuffer(byteString.length); diff --git a/src/core/utils/matrix.js b/src/core/utils/matrix.js index fb0ed4d6..fa4d7382 100755 --- a/src/core/utils/matrix.js +++ b/src/core/utils/matrix.js @@ -193,7 +193,7 @@ vec3.normalize3 = function (a, i, b, j) { }; -vec3.normalize4 = function (a, b, dd) { +vec3.normalize4 = function (a, b) { b || (b = a); var c = a[0], d = a[1], @@ -1061,7 +1061,8 @@ mat4.lookAt = function (a, b, c, d) { k = h * b - i * j; i = i * c - f * b; f = f * j - h * c; - if (m = Math.sqrt(k * k + i * i + f * f)) { + m = Math.sqrt(k * k + i * i + f * f); + if (m) { m = 1 / m; k *= m; i *= m; @@ -1070,7 +1071,8 @@ mat4.lookAt = function (a, b, c, d) { h = j * f - b * i; l = b * k - c * f; o = c * i - j * k; - if (m = Math.sqrt(h * h + l * l + o * o)) { + m = Math.sqrt(h * h + l * l + o * o); + if (m) { m = 1 / m; h *= m; l *= m; diff --git a/src/core/utils/utils.js b/src/core/utils/utils.js index 2a1933fa..146fd469 100755 --- a/src/core/utils/utils.js +++ b/src/core/utils/utils.js @@ -181,6 +181,7 @@ utils.loadJSON = function(path, onLoaded, onError, skipParse, withCredentials, x //var parsedData = skipParse ? data : eval("("+data+")"); parsedData = JSON.parse(data); } catch(e) { + // eslint-disable-next-line console.log('JSON Parse Error ('+path+'): ' + (e['message'] ? e['message'] : '')); if (onError ) { @@ -291,7 +292,7 @@ utils.loadBinary = function(path, onLoaded, onError, withCredentials, xhrParams, }; -utils.headRequest = function(url, onLoaded, onError, withCredentials, xhrParams, responseType) { +utils.headRequest = function(url, onLoaded, onError, withCredentials, xhrParams) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = (function (){