From cedc497e8123210b951402a477156da62fcf6c75 Mon Sep 17 00:00:00 2001 From: David Levinsky Date: Fri, 28 Apr 2017 09:38:12 +0200 Subject: [PATCH 1/3] single quotes --- src/browser/autopilot/autopilot.js | 26 +- src/browser/browser.js | 280 +-- src/browser/control-mode/control-mode.js | 10 +- src/browser/control-mode/map-observer.js | 84 +- src/browser/control-mode/pano.js | 18 +- src/browser/index.js | 6 +- src/browser/presenter/presenter.js | 334 ++-- src/browser/ui/control/compass.js | 20 +- src/browser/ui/control/credits.js | 88 +- src/browser/ui/control/fallback.js | 2 +- src/browser/ui/control/fullscreen.js | 8 +- src/browser/ui/control/holder.js | 6 +- src/browser/ui/control/layers.js | 2 +- src/browser/ui/control/link.js | 20 +- src/browser/ui/control/loading.js | 60 +- src/browser/ui/control/map.js | 4 +- src/browser/ui/control/popup.js | 10 +- src/browser/ui/control/search.js | 102 +- src/browser/ui/control/space.js | 30 +- src/browser/ui/control/zoom.js | 14 +- src/browser/ui/element/element.js | 218 +-- src/browser/ui/element/event.js | 268 +-- src/browser/ui/ui.js | 22 +- src/browser/utility/dom.js | 12 +- src/core/core.js | 82 +- src/core/index.js | 4 +- src/core/inspector/graphs.js | 322 ++-- src/core/inspector/input.js | 358 ++-- src/core/inspector/inspector.js | 98 +- src/core/inspector/layers.js | 656 +++---- src/core/inspector/stats.js | 156 +- src/core/inspector/stylesheets.js | 132 +- src/core/map/bound-layer.js | 102 +- src/core/map/camera.js | 12 +- src/core/map/config.js | 34 +- src/core/map/convert.js | 48 +- src/core/map/credit.js | 16 +- src/core/map/draw-tiles.js | 136 +- src/core/map/draw.js | 128 +- src/core/map/geodata-processor/processor.js | 12 +- .../map/geodata-processor/worker-globals.js | 10 +- .../geodata-processor/worker-linestring.js | 116 +- src/core/map/geodata-processor/worker-main.js | 286 +-- .../map/geodata-processor/worker-message.js | 4 +- .../geodata-processor/worker-pointarray.js | 180 +- .../map/geodata-processor/worker-polygon.js | 56 +- .../map/geodata-processor/worker-style.js | 828 ++++----- src/core/map/geodata-processor/worker-text.js | 20 +- src/core/map/geodata-view.js | 94 +- src/core/map/geodata.js | 6 +- src/core/map/interface.js | 56 +- src/core/map/map.js | 276 +-- src/core/map/measure.js | 60 +- src/core/map/mesh.js | 136 +- src/core/map/metanode.js | 46 +- src/core/map/metatile.js | 30 +- src/core/map/position.js | 20 +- src/core/map/refframe.js | 74 +- src/core/map/render-slots.js | 10 +- src/core/map/resource-node.js | 6 +- src/core/map/srs.js | 118 +- src/core/map/stylesheet.js | 2 +- src/core/map/submesh.js | 16 +- src/core/map/subtexture.js | 148 +- src/core/map/surface-sequence.js | 20 +- src/core/map/surface-tile.js | 44 +- src/core/map/surface-tree.js | 48 +- src/core/map/surface.js | 128 +- src/core/map/texture.js | 126 +- src/core/map/trajectory.js | 150 +- src/core/map/url.js | 48 +- src/core/map/view.js | 14 +- src/core/map/virtual-surface.js | 44 +- src/core/renderer/draw.js | 528 +++--- src/core/renderer/geometry.js | 4 +- src/core/renderer/gpu/bbox.js | 54 +- src/core/renderer/gpu/device.js | 12 +- src/core/renderer/gpu/font.js | 38 +- src/core/renderer/gpu/group.js | 226 +-- src/core/renderer/gpu/pixel-line3.js | 6 +- src/core/renderer/gpu/program.js | 4 +- src/core/renderer/gpu/shaders.js | 1582 ++++++++--------- src/core/renderer/gpu/texture.js | 54 +- src/core/renderer/init.js | 80 +- src/core/renderer/interface.js | 260 +-- src/core/renderer/renderer.js | 100 +- src/core/utils/math.js | 16 +- src/core/utils/matrix.js | 8 +- src/core/utils/platform.js | 146 +- src/core/utils/url.js | 30 +- src/core/utils/utils.js | 232 +-- 91 files changed, 5270 insertions(+), 5270 deletions(-) diff --git a/src/browser/autopilot/autopilot.js b/src/browser/autopilot/autopilot.js index 0c9bf137..cc3716ba 100755 --- a/src/browser/autopilot/autopilot.js +++ b/src/browser/autopilot/autopilot.js @@ -22,7 +22,7 @@ var Autopilot = function(browser) { Autopilot.prototype.setAutorotate = function(speed) { if (this.autoRotate != speed) { - this.browser.callListener("autorotate-changed", { "autorotate" : speed}); + this.browser.callListener('autorotate-changed', { 'autorotate' : speed}); } this.autoRotate = speed; @@ -53,7 +53,7 @@ Autopilot.prototype.flyToDAH = function(distance, azimuth, height, options) { options = options || {}; var trajectory = map.generatePIHTrajectory(map.getPosition(), distance, azimuth, height, options); - this.setTrajectory(trajectory, options["samplePeriod"] || 10, options); + this.setTrajectory(trajectory, options['samplePeriod'] || 10, options); }; @@ -65,7 +65,7 @@ Autopilot.prototype.flyTo = function(position, options) { options = options || {}; var trajectory = map.generateTrajectory(map.getPosition(), position, options); - this.setTrajectory(trajectory, options["samplePeriod"] || 10, options); + this.setTrajectory(trajectory, options['samplePeriod'] || 10, options); }; @@ -89,20 +89,20 @@ Autopilot.prototype.setTrajectory = function(trajectory, sampleDuration, options this.setAutorotate(0); this.setAutopan(0,0); - this.speed = options["speed"] || 1.0; + this.speed = options['speed'] || 1.0; if (this.finished) { this.lastControlMode = this.browser.getControlMode().getCurrentControlMode(); } - this.browser.getControlMode().setCurrentControlMode("disabled"); + this.browser.getControlMode().setCurrentControlMode('disabled'); this.trajectory = trajectory; this.sampleDuration = sampleDuration; //this. - this.browser.callListener("fly-start", { "startPosition" : this.trajectory[0], - "endPosition" : this.trajectory[this.trajectory.length - 1], - "options" : options - }); + this.browser.callListener('fly-start', { 'startPosition' : this.trajectory[0], + 'endPosition' : this.trajectory[this.trajectory.length - 1], + 'options' : options + }); this.timeStart = performance.now(); this.finished = false; @@ -146,9 +146,9 @@ Autopilot.prototype.tick = function() { map.setPosition(this.trajectory[sampleIndex]); //console.log(JSON.stringify(this.trajectory[sampleIndex])); - this.browser.callListener("fly-progress", { "position" : this.trajectory[sampleIndex], - "progress" : 100 * (sampleIndex / totalSamples) - }); + this.browser.callListener('fly-progress', { 'position' : this.trajectory[sampleIndex], + 'progress' : 100 * (sampleIndex / totalSamples) + }); } else { map.setPosition(this.trajectory[totalSamples]); @@ -156,7 +156,7 @@ Autopilot.prototype.tick = function() { } if (sampleIndex >= this.trajectory.length) { - this.browser.callListener("fly-end", { "position" : this.trajectory[totalSamples] }); + this.browser.callListener('fly-end', { 'position' : this.trajectory[totalSamples] }); this.browser.getControlMode().setCurrentControlMode(this.lastControlMode); this.finished = true; diff --git a/src/browser/browser.js b/src/browser/browser.js index d5bbbc07..4179a2d6 100755 --- a/src/browser/browser.js +++ b/src/browser/browser.js @@ -26,20 +26,20 @@ var Browser = function(element, config) { this.setConfigParams(config, true); this.originalConfig = JSON.parse(JSON.stringify(config)); - this.element = (typeof element === "string") ? document.getElementById(element) : element; + this.element = (typeof element === 'string') ? document.getElementById(element) : element; this.ui = new UI(this, this.element); - element = (typeof element !== "string") ? element : document.getElementById(element); + element = (typeof element !== 'string') ? element : document.getElementById(element); if (!checkSupport()) { - this.ui.setControlDisplayState("fallback", true); + this.ui.setControlDisplayState('fallback', true); return; } this.core = new CoreInterface(this.ui.getMapControl().getMapElement().getElement(), config); if (this.core == null) { - this.ui.setControlDisplayState("fallback", true); + this.ui.setControlDisplayState('fallback', true); return; } @@ -53,16 +53,16 @@ var Browser = function(element, config) { this.controlMode = new ControlMode(this, this.ui); this.presenter = new Presenter(this, config); - this.on("map-loaded", this.onMapLoaded.bind(this)); - this.on("map-unloaded", this.onMapUnloaded.bind(this)); - this.on("map-update", this.onMapUpdate.bind(this)); - this.on("map-position-changed", this.onMapPositionChanged.bind(this)); - this.on("map-position-fixed-height-changed", this.onMapPositionFixedHeightChanged.bind(this)); - this.on("map-position-panned", this.onMapPositionPanned.bind(this)); - this.on("map-position-rotated", this.onMapPositionRotated.bind(this)); - this.on("map-position-zoomed", this.onMapPositionZoomed.bind(this)); + this.on('map-loaded', this.onMapLoaded.bind(this)); + this.on('map-unloaded', this.onMapUnloaded.bind(this)); + this.on('map-update', this.onMapUpdate.bind(this)); + this.on('map-position-changed', this.onMapPositionChanged.bind(this)); + this.on('map-position-fixed-height-changed', this.onMapPositionFixedHeightChanged.bind(this)); + this.on('map-position-panned', this.onMapPositionPanned.bind(this)); + this.on('map-position-rotated', this.onMapPositionRotated.bind(this)); + this.on('map-position-zoomed', this.onMapPositionZoomed.bind(this)); - this.on("tick", this.onTick.bind(this)); + this.on('tick', this.onTick.bind(this)); }; @@ -121,10 +121,10 @@ Browser.prototype.onMapLoaded = function(event) { this.mapLoaded = true; //overwrite browser options - var options = event["browserOptions"] || {}; + var options = event['browserOptions'] || {}; var originalOptions = this.originalConfig; for (var key in originalOptions) { - if (typeof options[key] !== "undefined") { + if (typeof options[key] !== 'undefined') { options[key] = originalOptions[key]; } } @@ -141,7 +141,7 @@ Browser.prototype.onMapLoaded = function(event) { Browser.prototype.getLinkWithCurrentPos = function() { var map = this.getMap(); if (map == null) { - return ""; + return ''; } //get url params @@ -149,44 +149,44 @@ Browser.prototype.getLinkWithCurrentPos = function() { //get position string var p = map.getPosition(); - p = map.convertPositionHeightMode(p, "fix", true); + p = map.convertPositionHeightMode(p, 'fix', true); - var s = ""; - s += p.getViewMode() + ","; + var s = ''; + s += p.getViewMode() + ','; var c = p.getCoords(); - s += c[0].toFixed(6) + "," + c[1].toFixed(6) + "," + p.getHeightMode() + "," + c[2].toFixed(2) + ","; + s += c[0].toFixed(6) + ',' + c[1].toFixed(6) + ',' + p.getHeightMode() + ',' + c[2].toFixed(2) + ','; var o = p.getOrientation(); - s += o[0].toFixed(2) + "," + o[1].toFixed(2) + "," + o[2].toFixed(2) + ","; - s += p.getViewExtent().toFixed(2) + "," + p.getFov().toFixed(2); + s += o[0].toFixed(2) + ',' + o[1].toFixed(2) + ',' + o[2].toFixed(2) + ','; + s += p.getViewExtent().toFixed(2) + ',' + p.getFov().toFixed(2); //replace old value with new one - params["pos"] = s; + params['pos'] = s; if (this.mapInteracted) { - if (params["rotate"] || this.getConfigParam("rotate")) { - params["rotate"] = "0"; + if (params['rotate'] || this.getConfigParam('rotate')) { + params['rotate'] = '0'; } - var pan = this.getConfigParam("pan"); - if (params["pan"] || (pan && (pan[0] || pan[1]))) { - params["pan"] = "0,0"; + var pan = this.getConfigParam('pan'); + if (params['pan'] || (pan && (pan[0] || pan[1]))) { + params['pan'] = '0,0'; } } //convert prameters to url parameters string - s = ""; + s = ''; for (var key in params) { - s += ((s.length > 0) ? "&" : "") + key + "=" + params[key]; + s += ((s.length > 0) ? '&' : '') + key + '=' + params[key]; } //separete base url and url params - var urlParts = window.location.href.split("?"); + var urlParts = window.location.href.split('?'); if (urlParts.length > 1) { - var extraParts = urlParts[1].split("#"); //is there anchor? - return urlParts[0] + "?" + s + (extraParts[1] || ""); + var extraParts = urlParts[1].split('#'); //is there anchor? + return urlParts[0] + '?' + s + (extraParts[1] || ''); } else { - return urlParts[0] + "?" + s; + return urlParts[0] + '?' + s; } }; @@ -262,7 +262,7 @@ Browser.prototype.initConfig = function(data) { positionInUrl : false, positionUrlHistory : false, constrainCamera : true, - navigationMode : "free", + navigationMode : 'free', controlCompass : true, controlZoom : true, controlSpace : true, @@ -285,7 +285,7 @@ Browser.prototype.initConfig = function(data) { Browser.prototype.setConfigParams = function(params, ignoreCore) { - if (typeof params === "object" && params !== null) { + if (typeof params === 'object' && params !== null) { for (var key in params) { this.setConfigParam(key, params[key]); @@ -309,73 +309,73 @@ Browser.prototype.updateUI = function(key) { Browser.prototype.setConfigParam = function(key, value, ignoreCore) { switch (key) { - case "pos": - case "position": - this.config.position = value; - if (this.map) { - this.map.setPosition(this.config.position); - } - break; + case 'pos': + case 'position': + this.config.position = value; + if (this.map) { + this.map.setPosition(this.config.position); + } + break; - case "view": - this.config.view = value; - if (this.map) { - this.map.setView(this.config.view); - } - break; - - case "panAllowed": this.config.panAllowed = utils.validateBool(value, true); break; - case "rotationAllowed": this.config.rotationAllowed = utils.validateBool(value, true); break; - case "zoomAllowed": this.config.zoomAllowed = utils.validateBool(value, true); break; - case "jumpAllowed": this.config.jumpAllowed = utils.validateBool(value, false); break; - case "constrainCamera": this.config.constrainCamera = utils.validateBool(value, true); break; - case "navigationMode": this.config.navigationMode = value; break; - case "positionInUrl": this.config.positionInUrl = utils.validateBool(value, false); break; - case "positionUrlHistory": this.config.positionUrlHistory = utils.validateBool(value, false); break; - case "controlCompass": this.config.controlCompass = utils.validateBool(value, true); this.updateUI(key); break; - case "controlZoom": this.config.controlZoom = utils.validateBool(value, true); this.updateUI(key); break; - case "controlMeasure": this.config.controlMeasure = utils.validateBool(value, false); this.updateUI(key); break; - case "controlScale": this.config.controlScale = utils.validateBool(value, true); this.updateUI(key); break; - case "controlLayers": this.config.controlLayers = utils.validateBool(value, false); this.updateUI(key); break; - case "controlSpace": this.config.controlSpace = utils.validateBool(value, false); this.updateUI(key); break; - case "controlSearch": this.config.controlSearch = utils.validateBool(value, false); this.updateUI(key); break; - case "controlLink": this.config.controlLink = utils.validateBool(value, false); this.updateUI(key); break; - case "controlLogo": this.config.controlLogo = utils.validateBool(value, false); this.updateUI(key); break; - case "controlFullscreen": this.config.controlFullscreen = utils.validateBool(value, true); this.updateUI(key); break; - case "controlCredits": this.config.controlCredits = utils.validateBool(value, true); this.updateUI(key); break; - case "controlLoading": this.config.controlLoading = utils.validateBool(value, true); this.updateUI(key); break; - case "controlSearchElement": this.config.controlSearchElement = value; this.updateUI(key); break; - case "controlSearchValue": this.config.controlSearchValue = /*utils.validateString(*/value/*, null)*/; this.updateUI(key); break; - case "minViewExtent": this.config.minViewExtent = utils.validateNumber(value, 0.01, Number.MAXINTEGER, 100); break; - case "maxViewExtent": this.config.maxViewExtent = utils.validateNumber(value, 0.01, Number.MAXINTEGER, Number.MAXINTEGER); break; - case "sensitivity": this.config.sensitivity = utils.validateNumberArray(value, 3, [0,0,0], [10, 10, 10], [1, 0.12, 0.05]); break; - case "inertia": this.config.inertia = utils.validateNumberArray(value, 3, [0,0,0], [0.99, 0.99, 0.99], [0.85, 0.9, 0.7]); break; - case "rotate": - this.config.autoRotate = utils.validateNumber(value, Number.NEGATIVEINFINITY, Number.POSITIVEINFINITY, 0); - if (this.map && this.autopilot) { - this.autopilot.setAutorotate(this.config.autoRotate); - } - break; - case "pan": - if (Array.isArray(value) && value.length == 2){ - this.config.autoPan = [ - utils.validateNumber(value[0], Number.NEGATIVEINFINITY, Number.POSITIVEINFINITY, 0), - utils.validateNumber(value[1], -360, 360, 0) - ]; - } - - if (this.map && this.autopilot) { - this.autopilot.setAutorotate(this.config.autoRotate); - } - break; + case 'view': + this.config.view = value; + if (this.map) { + this.map.setView(this.config.view); + } + break; + + case 'panAllowed': this.config.panAllowed = utils.validateBool(value, true); break; + case 'rotationAllowed': this.config.rotationAllowed = utils.validateBool(value, true); break; + case 'zoomAllowed': this.config.zoomAllowed = utils.validateBool(value, true); break; + case 'jumpAllowed': this.config.jumpAllowed = utils.validateBool(value, false); break; + case 'constrainCamera': this.config.constrainCamera = utils.validateBool(value, true); break; + case 'navigationMode': this.config.navigationMode = value; break; + case 'positionInUrl': this.config.positionInUrl = utils.validateBool(value, false); break; + case 'positionUrlHistory': this.config.positionUrlHistory = utils.validateBool(value, false); break; + case 'controlCompass': this.config.controlCompass = utils.validateBool(value, true); this.updateUI(key); break; + case 'controlZoom': this.config.controlZoom = utils.validateBool(value, true); this.updateUI(key); break; + case 'controlMeasure': this.config.controlMeasure = utils.validateBool(value, false); this.updateUI(key); break; + case 'controlScale': this.config.controlScale = utils.validateBool(value, true); this.updateUI(key); break; + case 'controlLayers': this.config.controlLayers = utils.validateBool(value, false); this.updateUI(key); break; + case 'controlSpace': this.config.controlSpace = utils.validateBool(value, false); this.updateUI(key); break; + case 'controlSearch': this.config.controlSearch = utils.validateBool(value, false); this.updateUI(key); break; + case 'controlLink': this.config.controlLink = utils.validateBool(value, false); this.updateUI(key); break; + case 'controlLogo': this.config.controlLogo = utils.validateBool(value, false); this.updateUI(key); break; + case 'controlFullscreen': this.config.controlFullscreen = utils.validateBool(value, true); this.updateUI(key); break; + case 'controlCredits': this.config.controlCredits = utils.validateBool(value, true); this.updateUI(key); break; + case 'controlLoading': this.config.controlLoading = utils.validateBool(value, true); this.updateUI(key); break; + case 'controlSearchElement': this.config.controlSearchElement = value; this.updateUI(key); break; + case 'controlSearchValue': this.config.controlSearchValue = /*utils.validateString(*/value/*, null)*/; this.updateUI(key); break; + case 'minViewExtent': this.config.minViewExtent = utils.validateNumber(value, 0.01, Number.MAXINTEGER, 100); break; + case 'maxViewExtent': this.config.maxViewExtent = utils.validateNumber(value, 0.01, Number.MAXINTEGER, Number.MAXINTEGER); break; + case 'sensitivity': this.config.sensitivity = utils.validateNumberArray(value, 3, [0,0,0], [10, 10, 10], [1, 0.12, 0.05]); break; + case 'inertia': this.config.inertia = utils.validateNumberArray(value, 3, [0,0,0], [0.99, 0.99, 0.99], [0.85, 0.9, 0.7]); break; + case 'rotate': + this.config.autoRotate = utils.validateNumber(value, Number.NEGATIVEINFINITY, Number.POSITIVEINFINITY, 0); + if (this.map && this.autopilot) { + this.autopilot.setAutorotate(this.config.autoRotate); + } + break; + case 'pan': + if (Array.isArray(value) && value.length == 2){ + this.config.autoPan = [ + utils.validateNumber(value[0], Number.NEGATIVEINFINITY, Number.POSITIVEINFINITY, 0), + utils.validateNumber(value[1], -360, 360, 0) + ]; + } + + if (this.map && this.autopilot) { + this.autopilot.setAutorotate(this.config.autoRotate); + } + break; } if (ignoreCore) { - if ((key.indexOf("map") == 0 || key.indexOf("mario") == 0 || key.indexOf("authorization") == 0) && this.core.getMap()) { + if ((key.indexOf('map') == 0 || key.indexOf('mario') == 0 || key.indexOf('authorization') == 0) && this.core.getMap()) { this.core.getMap().setConfigParam(key, value); } - if (key.indexOf("renderer") == 0) { + if (key.indexOf('renderer') == 0) { this.core.getRenderer().setConfigParam(key, value); } } @@ -384,61 +384,61 @@ Browser.prototype.setConfigParam = function(key, value, ignoreCore) { Browser.prototype.getConfigParam = function(key) { switch (key) { - case "pos": - case "position": + case 'pos': + case 'position': - if (this.map) { - this.map.getPosition(); - } else { - return this.config.position; - } + if (this.map) { + this.map.getPosition(); + } else { + return this.config.position; + } - break; + break; - case "view": + case 'view': - if (this.map) { - return this.map.getView(); - } else { - return this.config.view; - } + if (this.map) { + return this.map.getView(); + } else { + return this.config.view; + } - case "panAllowed": return this.config.panAllowed; - case "rotationAllowed": return this.config.rotationAllowed; - case "zoomAllowed": return this.config.zoomAllowed; - case "jumpAllowed": return this.config.jumpAllowed; - case "sensitivity": return this.config.sensitivity; - case "inertia": return this.config.inertia; - case "navigationMode": return this.config.navigationMode; - case "constrainCamera": return this.config.constrainCamera; - case "positionInUrl": return this.config.positionInUrl; - case "positionUrlHistory": return this.config.positionUrlHistory; - case "controlCompass": return this.config.controlCompass; - case "controlZoom": return this.config.controlZoom; - case "controlMeasure": return this.config.controlMeasure; - case "controlScale": return this.config.controlScale; - case "controlLayers": return this.config.controlLayers; - case "controlSpace": return this.config.controlSpace; - case "controlSearch": return this.config.controlSearch; - case "controlLink": return this.config.controlLink; - case "controlLogo": return this.config.controlLogo; - case "controlFullscreen": return this.config.controlFullscreen; - case "controlCredits": return this.config.controlCredits; - case "controlLoading": return this.config.controlLoading; - case "controlSearchElement": return this.config.controlSearchElement; - case "controlSearchValue": return this.config.controlSearchValue; - case "minViewExtent": return this.config.minViewExtent; - case "maxViewExtent": return this.config.maxViewExtent; - case "rotate": return this.config.autoRotate; - case "pan": return this.config.autoPan; + case 'panAllowed': return this.config.panAllowed; + case 'rotationAllowed': return this.config.rotationAllowed; + case 'zoomAllowed': return this.config.zoomAllowed; + case 'jumpAllowed': return this.config.jumpAllowed; + case 'sensitivity': return this.config.sensitivity; + case 'inertia': return this.config.inertia; + case 'navigationMode': return this.config.navigationMode; + case 'constrainCamera': return this.config.constrainCamera; + case 'positionInUrl': return this.config.positionInUrl; + case 'positionUrlHistory': return this.config.positionUrlHistory; + case 'controlCompass': return this.config.controlCompass; + case 'controlZoom': return this.config.controlZoom; + case 'controlMeasure': return this.config.controlMeasure; + case 'controlScale': return this.config.controlScale; + case 'controlLayers': return this.config.controlLayers; + case 'controlSpace': return this.config.controlSpace; + case 'controlSearch': return this.config.controlSearch; + case 'controlLink': return this.config.controlLink; + case 'controlLogo': return this.config.controlLogo; + case 'controlFullscreen': return this.config.controlFullscreen; + case 'controlCredits': return this.config.controlCredits; + case 'controlLoading': return this.config.controlLoading; + case 'controlSearchElement': return this.config.controlSearchElement; + case 'controlSearchValue': return this.config.controlSearchValue; + case 'minViewExtent': return this.config.minViewExtent; + case 'maxViewExtent': return this.config.maxViewExtent; + case 'rotate': return this.config.autoRotate; + case 'pan': return this.config.autoPan; } if (ignoreCore) { - if (key.indexOf("map") == 0 && this.core.getMap()) { + if (key.indexOf('map') == 0 && this.core.getMap()) { return this.core.getMap().getConfigParam(key, value); } - if (key.indexOf("renderer") == 0) { + if (key.indexOf('renderer') == 0) { return this.core.getRenderer().getConfigParam(key, value); } } diff --git a/src/browser/control-mode/control-mode.js b/src/browser/control-mode/control-mode.js index 0a6ff7b1..301418ab 100755 --- a/src/browser/control-mode/control-mode.js +++ b/src/browser/control-mode/control-mode.js @@ -69,8 +69,8 @@ ControlMode.prototype.setCurrentControlMode = function(id, options) { this.currentControlMode = newMode; // call reset - if (newMode["reset"]) { - newMode["reset"](options); + if (newMode['reset']) { + newMode['reset'](options); } }; @@ -165,9 +165,9 @@ ControlMode.prototype.onTick = function(event) { // Private metod ControlMode.prototype.updateModifierKeys = function(event) { - this.altKey = event.getModifierKey("alt"); - this.shiftKey = event.getModifierKey("shift"); - this.ctrlKey = event.getModifierKey("ctrl"); + this.altKey = event.getModifierKey('alt'); + this.shiftKey = event.getModifierKey('shift'); + this.ctrlKey = event.getModifierKey('ctrl'); //console.log("alt:" + this.altKey + " ctrl:" + this.ctrlKey + " shift:" + this.shiftKey); }; diff --git a/src/browser/control-mode/map-observer.js b/src/browser/control-mode/map-observer.js index 7638bef0..880a11d7 100755 --- a/src/browser/control-mode/map-observer.js +++ b/src/browser/control-mode/map-observer.js @@ -15,14 +15,14 @@ var ControlModeMapObserver = function(browser) { this.orientationDeltas = []; this.viewExtentDeltas = []; - this["drag"] = this.drag; - this["wheel"] = this.wheel; - this["tick"] = this.tick; - this["reset"] = this.reset; - this["keyup"] = this.keyup; - this["keydown"] = this.keydown; - this["keypress"] = this.keypress; - this["doubleclick"] = this.doubleclick; + this['drag'] = this.drag; + this['wheel'] = this.wheel; + this['tick'] = this.tick; + this['reset'] = this.reset; + this['keyup'] = this.keyup; + this['keydown'] = this.keydown; + this['keypress'] = this.keypress; + this['doubleclick'] = this.doubleclick; this.retinaFactor = 1.0 / Math.max(1.0,(window.devicePixelRatio || 1) - 1); }; @@ -49,28 +49,28 @@ ControlModeMapObserver.prototype.drag = function(event) { if (touches == 2) {//} && /*event.getDragButton("middle")*/ zoom != 0 && this.config.zoomAllowed) { - if (pos.getViewMode() != "obj") { + if (pos.getViewMode() != 'obj') { return; } - if (event.getTouchParameter("touchMode") == "pan" && this.config.rotationAllowed) { - var pan = event.getTouchParameter("touchPanDelta"); + if (event.getTouchParameter('touchMode') == 'pan' && this.config.rotationAllowed) { + var pan = event.getTouchParameter('touchPanDelta'); var sensitivity = this.config.sensitivity[1] * this.retinaFactor; this.orientationDeltas.push([delta[0] * sensitivity, - -delta[1] * sensitivity, 0]); - this.browser.callListener("map-position-rotated", {}); + -delta[1] * sensitivity, 0]); + this.browser.callListener('map-position-rotated', {}); } else if (this.config.zoomAllowed) { - var factor = 1.0 + (event.getTouchParameter("touchDistanceDelta") > 1.0 ? -1 : 1)*0.01; + var factor = 1.0 + (event.getTouchParameter('touchDistanceDelta') > 1.0 ? -1 : 1)*0.01; this.viewExtentDeltas.push(factor); this.reduceFloatingHeight(0.8); - this.browser.callListener("map-position-zoomed", {}); + this.browser.callListener('map-position-zoomed', {}); } - } else if ((event.getDragButton("left") && !modifierKey) + } else if ((event.getDragButton('left') && !modifierKey) && this.config.panAllowed) { //pan - if (pos.getHeightMode() == "fix") { - var pos2 = map.convertPositionHeightMode(pos, "float", true); + if (pos.getHeightMode() == 'fix') { + var pos2 = map.convertPositionHeightMode(pos, 'float', true); if (pos2 != null) { pos = pos2; this.setPosition(pos); @@ -81,21 +81,21 @@ ControlModeMapObserver.prototype.drag = function(event) { var fovCorrection = (fov > 0.01 && fov < 179) ? (1.0 / Math.tan(math.radians(fov*0.5))) : 1.0; var azimuth = math.radians(azimuthDistance[0]); var forward = [Math.sin(azimuth), //direction vector x - Math.cos(azimuth), //direction vector y - azimuthDistance[1] * fovCorrection * sensitivity, azimuthDistance[0], //distance and azimut - coords[0], coords[1]]; //coords + Math.cos(azimuth), //direction vector y + azimuthDistance[1] * fovCorrection * sensitivity, azimuthDistance[0], //distance and azimut + coords[0], coords[1]]; //coords this.coordsDeltas.push(forward); this.reduceFloatingHeight(0.9); - this.browser.callListener("map-position-panned", {}); + this.browser.callListener('map-position-panned', {}); } - } else if (((touches <= 1 && event.getDragButton("right")) || event.getDragButton("middle") || modifierKey) + } else if (((touches <= 1 && event.getDragButton('right')) || event.getDragButton('middle') || modifierKey) && this.config.rotationAllowed) { //rotate var sensitivity = this.config.sensitivity[1] * this.retinaFactor; this.orientationDeltas.push([delta[0] * sensitivity, - -delta[1] * sensitivity, 0]); - this.browser.callListener("map-position-rotated", {}); + -delta[1] * sensitivity, 0]); + this.browser.callListener('map-position-rotated', {}); } }; @@ -120,13 +120,13 @@ ControlModeMapObserver.prototype.wheel = function(event) { pos.setFov(fov); map.setPosition(pos); } else { - if (pos.getViewMode() != "obj") { + if (pos.getViewMode() != 'obj') { return; } this.viewExtentDeltas.push(factor); this.reduceFloatingHeight(0.8); - this.browser.callListener("map-position-zoomed", {}); + this.browser.callListener('map-position-zoomed', {}); } }; @@ -149,17 +149,17 @@ ControlModeMapObserver.prototype.doubleclick = function(event) { var coords = event.getMouseCoords(); //get hit coords with fixed height - var mapCoords = map.getHitCoords(coords[0], coords[1], "fix"); + var mapCoords = map.getHitCoords(coords[0], coords[1], 'fix'); if (mapCoords) { var pos = map.getPosition(); pos.setCoords(mapCoords); - pos = map.convertPositionHeightMode(pos, "fix"); + pos = map.convertPositionHeightMode(pos, 'fix'); pos.setHeight(mapCoords[2]); //pos = map.convertPositionHeightMode(pos, "fix"); //pos.setPositionHeight(0); - this.browser.autopilot.flyTo(pos, {"mode" : "direct", "maxDuration" : 2000 }); + this.browser.autopilot.flyTo(pos, {'mode' : 'direct', 'maxDuration' : 2000 }); } }; @@ -189,8 +189,8 @@ ControlModeMapObserver.prototype.reduceFloatingHeight = function(factor) { var pos = map.getPosition(); var coords = pos.getCoords(); - if (pos.getHeightMode() == "float" && - pos.getViewMode() == "obj") { + if (pos.getHeightMode() == 'float' && + pos.getViewMode() == 'obj') { if (coords[2] != 0) { coords[2] *= factor; @@ -208,8 +208,8 @@ ControlModeMapObserver.prototype.reduceFloatingHeight = function(factor) { ControlModeMapObserver.prototype.isNavigationSRSProjected = function() { var map = this.browser.getMap(); var rf = map.getReferenceFrame(); - var srs = map.getSrsInfo(rf["navigationSrs"]); - return (srs) ? (srs["type"] == "projected") : false; + var srs = map.getSrsInfo(rf['navigationSrs']); + return (srs) ? (srs['type'] == 'projected') : false; }; @@ -282,7 +282,7 @@ ControlModeMapObserver.prototype.tick = function(event) { //console.log("tick: " + azimuth + " " + distance); //apply final azimuth and distance - if (this.config.navigationMode == "free") { + if (this.config.navigationMode == 'free') { var correction = pos.getOrientation()[0]; pos = map.movePositionCoordsTo(pos, (this.isNavigationSRSProjected() ? -1 : 1) * azimuth, distance); correction = pos.getOrientation()[0] - correction; @@ -432,13 +432,13 @@ function constrainMapPosition(browser, pos) { var distance = (pos.getViewExtent()*0.5) / Math.tan(math.radians(pos.getFov()*0.5)); //reduce tilt whe you are far off the planet - if (pos.getViewMode() == "obj") { + if (pos.getViewMode() == 'obj') { var rf = map.getReferenceFrame(); - var srs = map.getSrsInfo(rf["navigationSrs"]); + var srs = map.getSrsInfo(rf['navigationSrs']); - if (srs["a"]) { - var factor = Math.min(distance / (srs["a"]*0.5), 1.0); + if (srs['a']) { + var factor = Math.min(distance / (srs['a']*0.5), 1.0); var maxTilt = 20 + ((-90) - 20) * factor; var minTilt = -90; @@ -457,7 +457,7 @@ function constrainMapPosition(browser, pos) { } //do not allow camera under terrain - var camPos = map.getPositionCameraCoords(pos, "float"); + var camPos = map.getPositionCameraCoords(pos, 'float'); //var cameraConstrainDistance = 1; var cameraConstrainDistance = (minVE*0.5) / Math.tan(math.radians(pos.getFov()*0.5)); cameraConstrainDistance *= 0.5; //divice by 2 to alow 45deg tilt in maximum zoom @@ -479,7 +479,7 @@ function constrainMapPosition(browser, pos) { o[1] = value; pos.setOrientation(o); - if (map.getPositionCameraCoords(pos, "float")[2] < hmax) { + if (map.getPositionCameraCoords(pos, 'float')[2] < hmax) { return getFinalOrientation(start, value, level+1); } else { return getFinalOrientation(value, end, level+1); @@ -493,7 +493,7 @@ function constrainMapPosition(browser, pos) { } return pos; -}; +} export {ControlModeMapObserver, constrainMapPosition}; diff --git a/src/browser/control-mode/pano.js b/src/browser/control-mode/pano.js index 7f8f3676..23b955ae 100755 --- a/src/browser/control-mode/pano.js +++ b/src/browser/control-mode/pano.js @@ -16,15 +16,15 @@ var ControlModePano = function(browser) { this.impulse = [0, 0]; - this["drag"] = this.drag; - this["down"] = this.drag; - this["up"] = this.drag; - this["wheel"] = this.wheel; - this["tick"] = this.tick; - this["reset"] = this.reset; - this["keyup"] = this.keyup; - this["keydown"] = this.keydown; - this["keypress"] = this.keypress; + this['drag'] = this.drag; + this['down'] = this.drag; + this['up'] = this.drag; + this['wheel'] = this.wheel; + this['tick'] = this.tick; + this['reset'] = this.reset; + this['keyup'] = this.keyup; + this['keydown'] = this.keydown; + this['keypress'] = this.keypress; }; diff --git a/src/browser/index.js b/src/browser/index.js index 79991f41..b777e7f2 100644 --- a/src/browser/index.js +++ b/src/browser/index.js @@ -17,11 +17,11 @@ var proj4 = Proj4; function browser (element, config) { var browserInterface = new BrowserInterface(element, config); return browserInterface.core ? browserInterface : null; -}; +} function getBrowserVersion() { // return "Browser: 2.0.0, Core: " + getCoreVersion(); - return "" + getCoreVersion(); -}; + return '' + getCoreVersion(); +} export {vec2,vec3,vec4,mat3,mat4,math,utils,getCoreVersion,checkSupport,browser,getBrowserVersion,proj4}; diff --git a/src/browser/presenter/presenter.js b/src/browser/presenter/presenter.js index 254bca9d..6129707b 100644 --- a/src/browser/presenter/presenter.js +++ b/src/browser/presenter/presenter.js @@ -14,16 +14,16 @@ var Presenter = function(browser, config) { this.actualNode = 0; this.maxNodes = 1; this.animTime = 600; // Default css transition time - this.currentToolbox = "right"; // Default toolbox (right | wide) + this.currentToolbox = 'right'; // Default toolbox (right | wide) this.browser = browser; this.id = []; this.current = null; - this.presenter = (typeof config["presenter"] !== "undefined") ? JSON.parse(JSON.stringify(config["presenter"])) : {}; - this.presenterAutoplay = config["presenterAutoplay"]; + this.presenter = (typeof config['presenter'] !== 'undefined') ? JSON.parse(JSON.stringify(config['presenter'])) : {}; + this.presenterAutoplay = config['presenterAutoplay']; - if (typeof this.presenter !== "undefined") { + if (typeof this.presenter !== 'undefined') { this.playPresentation(); } }; @@ -32,7 +32,7 @@ var Presenter = function(browser, config) { Presenter.prototype.addPresentation = function(id, source) { if (Object.keys(this.presenter).length !== 0) { this.presenter[id] = source; - } else if (typeof id !== "undefined") { + } else if (typeof id !== 'undefined') { this.presenter = {}; this.presenter[id] = source; } @@ -40,21 +40,21 @@ Presenter.prototype.addPresentation = function(id, source) { Presenter.prototype.removePresentation = function(id) { - if (typeof id !== "undefined") { + if (typeof id !== 'undefined') { if (this.getCurrentPresentation() == id) { this.stopPresentation(); this.current = null; } delete this.presenter[id]; - return("Removed presentation id: "+id); + return('Removed presentation id: '+id); } else { if (this.getCurrentPresentation() !== null) { this.stopPresentation(); } this.presenter = {}; // Remove all presentations - this.presenterAutoplay = ""; + this.presenterAutoplay = ''; this.current = null; - return("All presentations removed."); + return('All presentations removed.'); } }; @@ -71,16 +71,16 @@ Presenter.prototype.getCurrentPresentationType = function() { Presenter.prototype.playPresentation = function(id) { this.stopPresentation(); - if (this.presenterAutoplay !== undefined && typeof id === "undefined") { + if (this.presenterAutoplay !== undefined && typeof id === 'undefined') { id = this.presenterAutoplay; - } else if (typeof id === "undefined" && this.presenter !== undefined && Object.keys(this.presenter).length > 0) { + } else if (typeof id === 'undefined' && this.presenter !== undefined && Object.keys(this.presenter).length > 0) { for (var key in this.presenter) { id = key; break; } } - if (typeof id !== "undefined" && Object.keys(this.presenter).indexOf(id) != -1) { + if (typeof id !== 'undefined' && Object.keys(this.presenter).indexOf(id) != -1) { this.current = id; this.readTextInput(id); return true; @@ -92,11 +92,11 @@ Presenter.prototype.playPresentation = function(id) { Presenter.prototype.stopPresentation = function() { var current = this.getCurrentPresentation(); - this.currentToolbox = "right"; + this.currentToolbox = 'right'; if (current !== null) { this.current = null; this.browser.ui.removeControl(current); - this.container.getElementsByTagName("article")[0].parentNode.parentNode.parentNode.remove(); + this.container.getElementsByTagName('article')[0].parentNode.parentNode.parentNode.remove(); return true; } return false; @@ -107,8 +107,8 @@ Presenter.prototype.listPresentations = function(id) { if (Object.keys(this.presenter).length === 0) { return []; } - if (typeof id !== "undefined") { - if (this.presenter[id] !== "undefined") { + if (typeof id !== 'undefined') { + if (this.presenter[id] !== 'undefined') { return this.presenter[id]; } else { return null; @@ -125,12 +125,12 @@ Presenter.prototype.listPresentations = function(id) { Presenter.prototype.initPresentation = function(id, HTMLtemplate) { var obj = this; - var templatePanelPrefix = "
"; - var templatePanelSuffix = "
"; + var templatePanelPrefix = '
'; + var templatePanelSuffix = '
'; var templatePanel = templatePanelPrefix + HTMLtemplate + templatePanelSuffix; - var templateSubtitlesPrefix = "
" - + "
"; - var templateSubtitlesSuffix = "
"; + var templateSubtitlesPrefix = '
' + + '
'; + var templateSubtitlesSuffix = '
'; var templateSubtitles = templateSubtitlesPrefix + HTMLtemplate + templateSubtitlesSuffix; var template = templatePanel + templateSubtitles; var ctrlDelve = this.browser.ui.addControl(id, template); @@ -138,7 +138,7 @@ Presenter.prototype.initPresentation = function(id, HTMLtemplate) { this.setContainer(ctrlDelve); // Set all tags to have onclick - this.aTags = this.container.getElementsByTagName("a"); + this.aTags = this.container.getElementsByTagName('a'); for (var i = 0; i < this.aTags.length; i++) { this.aTags[i].onclick = function() { obj.linksDecode(this); @@ -162,45 +162,45 @@ Presenter.prototype.readTextInput = function(id) { var hash = /^#.*$/; var str = /(= 0 && this.actualNode < this.maxNodes) { if (!init) { - if (this.currentToolbox == "right") { + if (this.currentToolbox == 'right') { this.handleArticle(this.actualNode); - } else if (this.currentToolbox == "wide") { + } else if (this.currentToolbox == 'wide') { this.handleSubtitlesPosition(this.actualNode); } } - if (typeof lastNode !== "undefined") { + if (typeof lastNode !== 'undefined') { this.maxNodes = lastNode; } - this.linksDecode(this.container.getElementsByTagName("section")[this.actualNode]); + this.linksDecode(this.container.getElementsByTagName('section')[this.actualNode]); return true; } else { @@ -326,42 +326,42 @@ Presenter.prototype.nextArticle = function(node, init, lastNode) { Presenter.prototype.useToolbox = function() { - var type = this.container.getElementsByTagName("article")[0].getAttribute("data-mln-style"); + var type = this.container.getElementsByTagName('article')[0].getAttribute('data-mln-style'); if (type === null) { - type = "right"; + type = 'right'; } - var rightPanel = this.container.getElementsByClassName("vts-presenter panelContainer")[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 rightPanel = this.container.getElementsByClassName('vts-presenter panelContainer')[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'); this.currentToolbox = type; - subtitles.setAttribute("style", "opacity: 0;"); - subtitles.setAttribute("class", "vts-presenter subtitlesContainer"); - if (type == "right") { - rightPanel.style.display = "block"; + subtitles.setAttribute('style', 'opacity: 0;'); + subtitles.setAttribute('class', 'vts-presenter subtitlesContainer'); + if (type == 'right') { + rightPanel.style.display = 'block'; setTimeout(function() { rightPanel.style.opacity = 1; }, 20); - swipeControl[0].style.display = "block"; - swipeControl[1].style.display = "block"; + 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 - this.sectionTags[i].style.height = this.maxHeight + "px"; + this.sectionTags[i].style.height = this.maxHeight + 'px'; } this.nextArticle(0); - } else if (type == "wide") { - subtitles.style.display = "block"; + } else if (type == 'wide') { + subtitles.style.display = 'block'; setTimeout(function() { subtitles.style.opacity = 1; }, 20); - rightPanel.style.display = "none"; + rightPanel.style.display = 'none'; rightPanel.style.opacity = 0; - swipeControl[0].style.display = "none"; - swipeControl[1].style.display = "none"; + 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 - this.sectionTags[i].style.height = "auto"; + this.sectionTags[i].style.height = 'auto'; } this.handleSubtitlesPosition(0, true); } @@ -377,25 +377,25 @@ Presenter.prototype.setContainer = function(c) { Presenter.prototype.renderControl = function() { // Set every
tag excluding the first one to not to be displayed - this.sectionTags = this.container.getElementsByClassName("vts-presenter toolboxContainer")[0].querySelectorAll("section"); + this.sectionTags = this.container.getElementsByClassName('vts-presenter toolboxContainer')[0].querySelectorAll('section'); - var swipeControlUp = this.container.getElementsByClassName("vts-presenter swipeControl")[0]; - var swipeControlDw = this.container.getElementsByClassName("vts-presenter swipeControl")[1]; + var swipeControlUp = this.container.getElementsByClassName('vts-presenter swipeControl')[0]; + var swipeControlDw = this.container.getElementsByClassName('vts-presenter swipeControl')[1]; - var nextButton = document.createElement("button"); - nextButton.innerHTML = "
"; - nextButton.setAttribute("type","button"); - nextButton.setAttribute("class","vts-presenter-btnDw"); + var nextButton = document.createElement('button'); + nextButton.innerHTML = '
'; + nextButton.setAttribute('type','button'); + nextButton.setAttribute('class','vts-presenter-btnDw'); nextButton.onclick = (function(){ - this.nextArticle("+1"); + this.nextArticle('+1'); }).bind(this); - var prevButton = document.createElement("button"); - prevButton.innerHTML = "
"; - prevButton.setAttribute("type","button"); - prevButton.setAttribute("class","vts-presenter-btnUp"); + var prevButton = document.createElement('button'); + prevButton.innerHTML = '
'; + prevButton.setAttribute('type','button'); + prevButton.setAttribute('class','vts-presenter-btnUp'); prevButton.onclick = (function(){ - this.nextArticle("-1"); + this.nextArticle('-1'); }).bind(this); // End of all buttons and other controllers @@ -407,10 +407,10 @@ Presenter.prototype.renderControl = function() { var offsetTop = this.maxHeight + this.swipeOffset; - this.container.getElementsByClassName("vts-presenter panelContainer")[0].style.height = (offsetTop + this.swipeOffset) + "px"; - swipeControlDw.style.top = offsetTop +"px"; - swipeControlUp.style.opacity = "1"; - swipeControlDw.style.opacity = "1"; + this.container.getElementsByClassName('vts-presenter panelContainer')[0].style.height = (offsetTop + this.swipeOffset) + 'px'; + swipeControlDw.style.top = offsetTop +'px'; + swipeControlUp.style.opacity = '1'; + swipeControlDw.style.opacity = '1'; // init now setTimeout((function() { @@ -428,87 +428,87 @@ Presenter.prototype.getElementsTrueHeight = function(elems) { } for (var i = 0; i < elems.length; i++) { - elems[i].style.height = this.maxHeight + "px"; + elems[i].style.height = this.maxHeight + 'px'; } }; Presenter.prototype.handleArticle = function(node) { - var rightPanel = this.container.getElementsByClassName("vts-presenter toolboxContainer")[0]; - var btnUp = this.container.getElementsByClassName("vts-presenter-btnUp")[0]; - var btnDw = this.container.getElementsByClassName("vts-presenter-btnDw")[0]; + var rightPanel = this.container.getElementsByClassName('vts-presenter toolboxContainer')[0]; + var btnUp = this.container.getElementsByClassName('vts-presenter-btnUp')[0]; + var btnDw = this.container.getElementsByClassName('vts-presenter-btnDw')[0]; var articleClass = (function(a) { - this.container.getElementsByClassName("vts-presenter toolboxContainer")[0].querySelectorAll("article")[0].setAttribute("class",a); + this.container.getElementsByClassName('vts-presenter toolboxContainer')[0].querySelectorAll('article')[0].setAttribute('class',a); }).bind(this); var actualHeight = this.maxHeight * this.actualNode * -1; - btnUp.setAttribute("class","vts-presenter-btnUp"); - btnDw.setAttribute("class","vts-presenter-btnDw"); + btnUp.setAttribute('class','vts-presenter-btnUp'); + btnDw.setAttribute('class','vts-presenter-btnDw'); if (node === 0) { - btnUp.setAttribute("class","vts-presenter-btnUp vts-presenter hidden"); + btnUp.setAttribute('class','vts-presenter-btnUp vts-presenter hidden'); } else if (node === this.maxNodes-1) { - btnDw.setAttribute("class","vts-presenter-btnDw vts-presenter hidden"); + btnDw.setAttribute('class','vts-presenter-btnDw vts-presenter hidden'); } - this.container.getElementsByTagName("article")[0].setAttribute("style","top: "+actualHeight+"px"); + this.container.getElementsByTagName('article')[0].setAttribute('style','top: '+actualHeight+'px'); if (this.actualNode === 0) { /* handle right panel stuff */ - rightPanel.style.height = (this.maxHeight + this.swipeOffset) + "px"; + rightPanel.style.height = (this.maxHeight + this.swipeOffset) + 'px'; rightPanel.style.top = 0; - articleClass("vts-presenter"); + articleClass('vts-presenter'); /* done - now add some cosmetic attributes */ - this.container.getElementsByClassName("vts-presenter swipeControl")[0].style.height = 0; - this.container.getElementsByTagName("article")[0].style.top = 0; - this.container.getElementsByTagName("section")[0].style.height = (this.maxHeight + (this.swipeOffset - this.firstTitleMargin)) + "px"; + this.container.getElementsByClassName('vts-presenter swipeControl')[0].style.height = 0; + this.container.getElementsByTagName('article')[0].style.top = 0; + this.container.getElementsByTagName('section')[0].style.height = (this.maxHeight + (this.swipeOffset - this.firstTitleMargin)) + 'px'; } else { /* handle right panel stuff */ - rightPanel.style.height = this.maxHeight + "px"; - rightPanel.style.top = this.swipeOffset + "px"; - articleClass("vts-presenter nonFirst"); + rightPanel.style.height = this.maxHeight + 'px'; + rightPanel.style.top = this.swipeOffset + 'px'; + articleClass('vts-presenter nonFirst'); /* done - now add some cosmetic attributes */ - this.container.getElementsByClassName("vts-presenter swipeControl")[0].style.height = this.swipeOffset + "px"; - this.container.getElementsByTagName("section")[0].style.height = (this.maxHeight + this.swipeOffset) + "px"; + this.container.getElementsByClassName('vts-presenter swipeControl')[0].style.height = this.swipeOffset + 'px'; + this.container.getElementsByTagName('section')[0].style.height = (this.maxHeight + this.swipeOffset) + 'px'; } return true; }; Presenter.prototype.handleSubtitlesPosition = function(node, init) { - if (typeof node === "undefined") { + if (typeof node === 'undefined') { node = 0; } - var subtitlesContainer = this.container.getElementsByClassName("vts-presenter subtitlesContainer")[0]; + var subtitlesContainer = this.container.getElementsByClassName('vts-presenter subtitlesContainer')[0]; var leftButton = subtitlesContainer.childNodes[0]; var rightButton = subtitlesContainer.childNodes[1]; - var sections = subtitlesContainer.childNodes[4].querySelectorAll("article")[0].querySelectorAll("section"); - var swipeSubtitles = this.container.getElementsByClassName("vts-presenter swipeSubtitles"); + var sections = subtitlesContainer.childNodes[4].querySelectorAll('article')[0].querySelectorAll('section'); + var swipeSubtitles = this.container.getElementsByClassName('vts-presenter swipeSubtitles'); this.linksDecode(sections[node]); // clean all previous states - sections[node].removeAttribute("style"); - subtitlesContainer.setAttribute("class","vts-presenter subtitlesContainer"); - subtitlesContainer.removeAttribute("onclick"); - swipeSubtitles[0].removeAttribute("onclick"); - swipeSubtitles[1].removeAttribute("onclick"); - swipeSubtitles[0].removeAttribute("style"); - swipeSubtitles[1].removeAttribute("style"); - leftButton.removeAttribute("onclick"); - rightButton.removeAttribute("onclick"); - leftButton.setAttribute("class", "vts-presenter hidden"); - rightButton.setAttribute("class", "vts-presenter hidden"); + sections[node].removeAttribute('style'); + subtitlesContainer.setAttribute('class','vts-presenter subtitlesContainer'); + subtitlesContainer.removeAttribute('onclick'); + swipeSubtitles[0].removeAttribute('onclick'); + swipeSubtitles[1].removeAttribute('onclick'); + swipeSubtitles[0].removeAttribute('style'); + swipeSubtitles[1].removeAttribute('style'); + leftButton.removeAttribute('onclick'); + rightButton.removeAttribute('onclick'); + leftButton.setAttribute('class', 'vts-presenter hidden'); + rightButton.setAttribute('class', 'vts-presenter hidden'); for (var i = 0; i < sections.length; i++) { sections[i].style.opacity = 0; if (this.subtitlesHeights[i] === undefined) { - sections[i].style.display = "block"; + sections[i].style.display = 'block'; this.subtitlesHeights[i] = sections[i].offsetHeight; - sections[i].style.display = "none"; + sections[i].style.display = 'none'; } if (i !== node) { this.hideSections(sections[i]); @@ -516,59 +516,59 @@ Presenter.prototype.handleSubtitlesPosition = function(node, init) { } this.showSections(sections[node]); - var sectionType = sections[node].getAttribute("data-mln-style"); + var sectionType = sections[node].getAttribute('data-mln-style'); if (sectionType == undefined) { - sectionType = "full"; + sectionType = 'full'; } - if (sectionType == "full") { + if (sectionType == 'full') { swipeSubtitles[0].style.opacity = 0; swipeSubtitles[1].style.opacity = 0; - swipeSubtitles[0].style.cursor = "default"; - swipeSubtitles[1].style.cursor = "default"; + swipeSubtitles[0].style.cursor = 'default'; + swipeSubtitles[1].style.cursor = 'default'; if (node === 0) { - leftButton.setAttribute("class", "vts-presenter hidden"); - rightButton.setAttribute("class", "vts-presenter"); + leftButton.setAttribute('class', 'vts-presenter hidden'); + rightButton.setAttribute('class', 'vts-presenter'); rightButton.onclick = (function() { this.nextArticle(1); }).bind(this); - rightButton.innerHTML = "Continue"; + rightButton.innerHTML = 'Continue'; } else if (node === sections.length - 2) { // One more before end - leftButton.setAttribute("class", "vts-presenter"); + leftButton.setAttribute('class', 'vts-presenter'); leftButton.onclick = (function() { - this.nextArticle("-1"); + this.nextArticle('-1'); }).bind(this); - leftButton.innerHTML = "Back"; - rightButton.setAttribute("class", "vts-presenter"); + leftButton.innerHTML = 'Back'; + rightButton.setAttribute('class', 'vts-presenter'); rightButton.onclick = (function() { - this.nextArticle("+1"); + this.nextArticle('+1'); }).bind(this); - rightButton.innerHTML = "Explore"; + rightButton.innerHTML = 'Explore'; } - if (typeof init === "undefined") { - subtitlesContainer.setAttribute("style", "display: block;"); + if (typeof init === 'undefined') { + subtitlesContainer.setAttribute('style', 'display: block;'); } - subtitlesContainer.setAttribute("class","vts-presenter subtitlesContainer full"); - } else if (sectionType == "title") { + subtitlesContainer.setAttribute('class','vts-presenter subtitlesContainer full'); + } else if (sectionType == 'title') { swipeSubtitles[0].style.opacity = 1; swipeSubtitles[1].style.opacity = 1; swipeSubtitles[0].onclick = (function() { - this.nextArticle("-1"); + this.nextArticle('-1'); }).bind(this); swipeSubtitles[1].onclick = (function() { - this.nextArticle("+1"); + this.nextArticle('+1'); }).bind(this); - leftButton.setAttribute("class", "vts-presenter hidden"); - rightButton.setAttribute("class", "vts-presenter hidden"); - subtitlesContainer.style.height = this.subtitlesHeights[node] + "px"; - subtitlesContainer.setAttribute("class","vts-presenter subtitlesContainer title"); + leftButton.setAttribute('class', 'vts-presenter hidden'); + rightButton.setAttribute('class', 'vts-presenter hidden'); + subtitlesContainer.style.height = this.subtitlesHeights[node] + 'px'; + subtitlesContainer.setAttribute('class','vts-presenter subtitlesContainer title'); - } else if (sectionType == "mini") { - subtitlesContainer.setAttribute("style", "display: block;"); - subtitlesContainer.setAttribute("class","vts-presenter subtitlesContainer mini"); - leftButton.setAttribute("class", "vts-presenter hidden"); - rightButton.setAttribute("class", "vts-presenter hidden"); + } else if (sectionType == 'mini') { + subtitlesContainer.setAttribute('style', 'display: block;'); + subtitlesContainer.setAttribute('class','vts-presenter subtitlesContainer mini'); + leftButton.setAttribute('class', 'vts-presenter hidden'); + rightButton.setAttribute('class', 'vts-presenter hidden'); } }; @@ -576,14 +576,14 @@ Presenter.prototype.handleSubtitlesPosition = function(node, init) { Presenter.prototype.hideSections = function(elem) { setTimeout(function() { - elem.style.display = "none"; + elem.style.display = 'none'; }, this.animTime); }; Presenter.prototype.showSections = function(elem) { setTimeout(function() { - elem.style.display = "block"; + elem.style.display = 'block'; setTimeout(function() { elem.style.opacity = 1; }, 50); diff --git a/src/browser/ui/control/compass.js b/src/browser/ui/control/compass.js index 2d62b0eb..927bf0a3 100755 --- a/src/browser/ui/control/compass.js +++ b/src/browser/ui/control/compass.js @@ -7,7 +7,7 @@ var dom = Dom_; var UIControlCompass = function(ui, visible) { this.ui = ui; this.browser = ui.browser; - this.control = this.ui.addControl("compass", + this.control = this.ui.addControl('compass', '
' + '
' @@ -24,16 +24,16 @@ var UIControlCompass = function(ui, visible) { + '
', visible); - var compass = this.control.getElement("vts-compass"); + var compass = this.control.getElement('vts-compass'); compass.setDraggableState(true); - compass.on("drag", this.onDrag.bind(this)); - compass.on("dblclick", this.onDoubleClick.bind(this)); + compass.on('drag', this.onDrag.bind(this)); + compass.on('dblclick', this.onDoubleClick.bind(this)); - this.image = this.control.getElement("vts-compass-compass"); - this.image2 = this.control.getElement("vts-compass-compass2"); - this.image3 = this.control.getElement("vts-compass-compass3"); + this.image = this.control.getElement('vts-compass-compass'); + this.image2 = this.control.getElement('vts-compass-compass2'); + this.image3 = this.control.getElement('vts-compass-compass3'); - this.lastStyle = ""; + this.lastStyle = ''; }; @@ -45,7 +45,7 @@ UIControlCompass.prototype.update = function() { var pos = map.getPosition(); var orientation = pos.getOrientation(); - var value = "rotateX("+(Math.round(orientation[1]+90)*0.7)+"deg) " + "rotateZ("+Math.round(-orientation[0]-45)+"deg)"; + var value = 'rotateX('+(Math.round(orientation[1]+90)*0.7)+'deg) ' + 'rotateZ('+Math.round(-orientation[0]-45)+'deg)'; if (value != this.lastStyle) { this.lastStyle = value; @@ -69,7 +69,7 @@ UIControlCompass.prototype.onDrag = function(event) { if (controller.orientationDeltas) { controller.orientationDeltas.push([delta[0] * sensitivity, - -delta[1] * sensitivity, 0]); + -delta[1] * sensitivity, 0]); } }; diff --git a/src/browser/ui/control/credits.js b/src/browser/ui/control/credits.js index aea848cf..41c4d0d2 100755 --- a/src/browser/ui/control/credits.js +++ b/src/browser/ui/control/credits.js @@ -2,31 +2,31 @@ var UIControlCredits = function(ui, visible) { this.ui = ui; this.browser = ui.browser; - this.control = this.ui.addControl("credits", + this.control = this.ui.addControl('credits', '
' + '
', visible); - this.lastHTML = ""; - this.lastHTML2 = ""; - this.lastHTML3 = ""; - this.credits = this.control.getElement("vts-credits"); + this.lastHTML = ''; + this.lastHTML2 = ''; + this.lastHTML3 = ''; + this.credits = this.control.getElement('vts-credits'); }; UIControlCredits.prototype.getCreditsString = function(array, separator, full) { var map = this.browser.getMap(); - var html = ""; - var copyright = "©" + (new Date().getFullYear()); + var html = ''; + var copyright = '©' + (new Date().getFullYear()); var li = array.length; - var plain = ""; + var plain = ''; var more = false; for (var i = 0; i < li; i++) { var creditInfo = map.getCreditInfo(array[i]); - if (creditInfo["plain"]) { - plain += creditInfo["plain"]; + if (creditInfo['plain']) { + plain += creditInfo['plain']; } } @@ -38,8 +38,8 @@ UIControlCredits.prototype.getCreditsString = function(array, separator, full) { for (var i = 0; i < li; i++) { var creditInfo = map.getCreditInfo(array[i]); - if (creditInfo["html"]) { - html += creditInfo["html"]; + if (creditInfo['html']) { + html += creditInfo['html']; } if (i + 1 < li) { @@ -57,50 +57,50 @@ UIControlCredits.prototype.update = function() { return; } - var html = ""; - var html2 = ""; - var html3 = ""; + var html = ''; + var html2 = ''; + var html3 = ''; var credits = map.getCurrentCredits(); - if (credits["imagery"].length > 0) { - var res = this.getCreditsString(credits["imagery"], ", "); - html += "
"; - html += "
Imagery: " + res[0] + "
"; - html += res[1] ? "
and others
" : ""; - html += "
"; - html += "
"; - var html2 = "
"; - html2 += this.getCreditsString(credits["imagery"], "
", true)[0] + "
"; + if (credits['imagery'].length > 0) { + var res = this.getCreditsString(credits['imagery'], ', '); + html += '
'; + html += '
Imagery: ' + res[0] + '
'; + html += res[1] ? '
and others
' : ''; + html += '
'; + html += '
'; + var html2 = '
'; + html2 += this.getCreditsString(credits['imagery'], '
', true)[0] + '
'; } - if (credits["mapdata"].length > 0) { - var res = this.getCreditsString(credits["mapdata"], ", "); - html += "
"; - html += "
Map Data: " + res[0] + "
"; - html += res[1] ? "
and others
" : ""; - html += "
"; - html += "
"; - var html3 = "
"; - html3 += this.getCreditsString(credits["mapdata"], "
", true)[0] + "
"; + if (credits['mapdata'].length > 0) { + var res = this.getCreditsString(credits['mapdata'], ', '); + html += '
'; + html += '
Map Data: ' + res[0] + '
'; + html += res[1] ? '
and others
' : ''; + html += '
'; + html += '
'; + var html3 = '
'; + html3 += this.getCreditsString(credits['mapdata'], '
', true)[0] + '
'; } - html += "
"; - html += ""; - html += "
"; - html += "
"; + html += '
'; + html += '
Powered by
'; + html += '
'; + html += '
'; if (this.lastHTML != html) { this.lastHTML = html; this.credits.setHtml(html); - var butt = this.control.getElement("vts-credits-imagery-more"); + var butt = this.control.getElement('vts-credits-imagery-more'); if (butt) { - butt.on("click", this.onMoreButton.bind(this, butt, "2")); + butt.on('click', this.onMoreButton.bind(this, butt, '2')); } - butt = this.control.getElement("vts-credits-mapdata-more"); + butt = this.control.getElement('vts-credits-mapdata-more'); if (butt) { - butt.on("click", this.onMoreButton.bind(this, butt, "3")); + butt.on('click', this.onMoreButton.bind(this, butt, '3')); } } @@ -127,14 +127,14 @@ UIControlCredits.prototype.update = function() { UIControlCredits.prototype.onMoreButton = function(butt, html) { var rect = butt.getRect(); - if (html == "2") { + if (html == '2') { html = this.lastHTML2; } else { html = this.lastHTML3; } - this.ui.popup.show({"right" : Math.max(0,(rect["fromRight"]-rect["width"])) + "px", - "bottom" : (rect["fromBottom"]+7) + "px"}, html); + this.ui.popup.show({'right' : Math.max(0,(rect['fromRight']-rect['width'])) + 'px', + 'bottom' : (rect['fromBottom']+7) + 'px'}, html); }; diff --git a/src/browser/ui/control/fallback.js b/src/browser/ui/control/fallback.js index f6690922..3f98ba29 100755 --- a/src/browser/ui/control/fallback.js +++ b/src/browser/ui/control/fallback.js @@ -2,7 +2,7 @@ var UIControlFallback = function(ui, visible) { this.ui = ui; - this.control = this.ui.addControl("fallback", + this.control = this.ui.addControl('fallback', '
' + '
' diff --git a/src/browser/ui/control/fullscreen.js b/src/browser/ui/control/fullscreen.js index b1c9dc45..4e17857e 100755 --- a/src/browser/ui/control/fullscreen.js +++ b/src/browser/ui/control/fullscreen.js @@ -7,13 +7,13 @@ var dom = Dom_; var UIControlFullscreen = function(ui, visible) { this.ui = ui; - this.control = this.ui.addControl("fullscreen", + this.control = this.ui.addControl('fullscreen', '' , visible); - var img = this.control.getElement("vts-fullscreen"); - img.on("click", this.onClick.bind(this)); - img.on("dblclick", this.onDoNothing.bind(this)); + var img = this.control.getElement('vts-fullscreen'); + img.on('click', this.onClick.bind(this)); + img.on('dblclick', this.onDoNothing.bind(this)); this.enabled = false; }; diff --git a/src/browser/ui/control/holder.js b/src/browser/ui/control/holder.js index bab8d73e..781eafc4 100755 --- a/src/browser/ui/control/holder.js +++ b/src/browser/ui/control/holder.js @@ -12,7 +12,7 @@ var UIControlHolder = function(ui, html, visible, parentElement) { this.visible = (visible != null) ? visible : true; //create holder element - this.element = document.createElement("div"); + this.element = document.createElement('div'); this.setVisible(this.visible); //set element content @@ -34,7 +34,7 @@ UIControlHolder.prototype.setHtml = function(html) { //store all elements with id attribute to the table for (var i = 0, li = allElements.length; i < li; i++) { - var id = allElements[i].getAttribute("id"); + var id = allElements[i].getAttribute('id'); if (id !== null) { //store element to the table @@ -50,7 +50,7 @@ UIControlHolder.prototype.getElement = function(id) { UIControlHolder.prototype.setVisible = function(state) { - this.element.style.display = state ? "block" : "none"; + this.element.style.display = state ? 'block' : 'none'; this.visible = state; }; diff --git a/src/browser/ui/control/layers.js b/src/browser/ui/control/layers.js index 33488ab2..f9bb0aeb 100755 --- a/src/browser/ui/control/layers.js +++ b/src/browser/ui/control/layers.js @@ -1,7 +1,7 @@ var UIControlLayers = function(ui, visible) { this.ui = ui; - this.control = this.ui.addControl("layers", + this.control = this.ui.addControl('layers', '
', visible); }; diff --git a/src/browser/ui/control/link.js b/src/browser/ui/control/link.js index bdc5702f..b8080ae4 100755 --- a/src/browser/ui/control/link.js +++ b/src/browser/ui/control/link.js @@ -8,7 +8,7 @@ var dom = Dom_; var UIControlLink = function(ui, visible) { this.ui = ui; this.browser = ui.browser; - this.control = this.ui.addControl("link", + this.control = this.ui.addControl('link', ''; } 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" +'
'; + 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' +'
'; } } break; - case "Polygons": - case "Processing": + case 'Polygons': + case 'Processing': { var max = 0; var min = 99999999999; var total = 0; var realCount = 0; - var values = (this.graph == "Polygons") ? stats.graphsPolygons : stats.graphsBuild; + var values = (this.graph == 'Polygons') ? stats.graphsPolygons : stats.graphsBuild; for (var i = 0; i < samples; i++) { max = values[i] > max ? values[i] : max; @@ -484,7 +484,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { var index = samplesIndex + i; index %= samples; - ctx.fillStyle="#007700"; + ctx.fillStyle='#007700'; ctx.fillRect(i*factorX, height, 1, -(values[index])*factorY); } @@ -500,7 +500,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { break; - case "LODs": + case 'LODs': { var max = 0; var values = stats.graphsLODs; @@ -511,7 +511,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { var factorY = height / max; - ctx.fillStyle="#000000"; + ctx.fillStyle='#000000'; ctx.fillRect(0, 0, width, height); for (var i = 0; i < samples; i++) { @@ -527,7 +527,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { for (var j = 0, lj = lods.length; j < lj; j++) { if (lods[j]) { - ctx.fillStyle="hsl("+((j*23)%360)+",100%,50%)"; + ctx.fillStyle='hsl('+((j*23)%360)+',100%,50%)'; var value = Math.round((lods[j])*factorY); ctx.fillRect(i*factorX, y, 1, -value); y -= value; @@ -539,7 +539,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { if (this.showCursor) { var index = (this.cursorIndex + samplesIndex) % samples; - var str = "LODs:" + values[index][0]; + var str = 'LODs:' + values[index][0]; var lods = values[index][1]; for (var j = 0, lj = lods.length; j < lj; j++) { @@ -549,14 +549,14 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { } } else { - var str = "LODs:" + values[index][0]; + var str = 'LODs:' + values[index][0]; } str += '
'; } break; - case "Flux": + case 'Flux': { var maxCount = 0; var maxSize = 0; @@ -622,7 +622,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { var y2Up = base2; var y2Down = base2+1; - ctx.fillStyle="#0000aa"; + ctx.fillStyle='#0000aa'; ctx.fillRect(i*factorX, y1Up, 1, -(valuesTextures[index][0][0])*factorY); ctx.fillRect(i*factorX, y1Down, 1, (valuesTextures[index][1][0])*factorY); @@ -634,7 +634,7 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { y2Up -= (valuesTextures[index][0][1])*factorY2; y2Down += (valuesTextures[index][1][1])*factorY2; - ctx.fillStyle="#007700"; + ctx.fillStyle='#007700'; ctx.fillRect(i*factorX, y1Up, 1, -(valuesMeshes[index][0][0])*factorY); ctx.fillRect(i*factorX, y1Down, 1, (valuesMeshes[index][1][0])*factorY); @@ -646,16 +646,16 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { y2Up -= (valuesMeshes[index][0][1])*factorY2; y2Down += (valuesMeshes[index][1][1])*factorY2; - ctx.fillStyle="#009999"; + ctx.fillStyle='#009999'; ctx.fillRect(i*factorX, y1Up, 1, -(valuesGeodata[index][0][0])*factorY); ctx.fillRect(i*factorX, y1Down, 1, (valuesGeodata[index][1][0])*factorY); ctx.fillRect(i*factorX, y2Up, 1, -(valuesGeodata[index][0][1])*factorY2); ctx.fillRect(i*factorX, y2Down, 1, (valuesGeodata[index][1][1])*factorY2); - ctx.fillStyle="#aaaaaa"; + ctx.fillStyle='#aaaaaa'; ctx.fillRect(0, Math.floor(height*0.5), width, 1); - ctx.fillStyle="#dddddd"; + ctx.fillStyle='#dddddd'; ctx.fillRect(0, base, width, 1); ctx.fillRect(0, base2, width, 1); } @@ -663,20 +663,20 @@ 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]; - 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); - str += '   Geodata Count +/-: ' + valuesGeodata[index][0][0] + "/" + valuesGeodata[index][1][0]; - str += '   Size +/-: ' + (valuesGeodata[index][0][1]/1024/1024).toFixed(2) + "/" + (valuesGeodata[index][1][1]/1024/1024).toFixed(2); + var 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); + str += '   Geodata Count +/-: ' + valuesGeodata[index][0][0] + '/' + valuesGeodata[index][1][0]; + 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 += '   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); - str += '   Geodata Count +/-: ' + maxGeodataPlusCount + "/" + maxGeodataMinusCount; - str += '   Size +/-: ' + (maxGeodataPlusSize/1024/1024).toFixed(2) + "/" + (maxGeodataMinusSize/1024/1024).toFixed(2); + var 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); + str += '   Geodata Count +/-: ' + maxGeodataPlusCount + '/' + maxGeodataMinusCount; + str += '   Size +/-: ' + (maxGeodataPlusSize/1024/1024).toFixed(2) + '/' + (maxGeodataMinusSize/1024/1024).toFixed(2); str += ''; } @@ -686,13 +686,13 @@ InspectorGraphs.prototype.updateGraphs = function(stats, ignoreRefresh) { } if (this.showCursor) { - ctx.fillStyle="#aa00aa"; + ctx.fillStyle='#aa00aa'; var index = (this.cursorIndex) % samples; ctx.fillRect(Math.floor(index*factorX)-1, 0, 1, height); ctx.fillRect(Math.floor(index*factorX)+1, 0, 1, height); } - document.getElementById("vts-graphs-info2").innerHTML = str; + document.getElementById('vts-graphs-info2').innerHTML = str; }; diff --git a/src/core/inspector/input.js b/src/core/inspector/input.js index e4013232..873ec320 100755 --- a/src/core/inspector/input.js +++ b/src/core/inspector/input.js @@ -17,9 +17,9 @@ InspectorInput.prototype.init = function() { //document.addEventListener("click", this.onKeyClick.bind(this), false); //keyboard events - document.addEventListener("keyup", this.onKeyUp.bind(this), false); - document.addEventListener("keypress", this.onKeyPress.bind(this), false); - document.addEventListener("keydown", this.onKeyDown.bind(this), false); + document.addEventListener('keyup', this.onKeyUp.bind(this), false); + document.addEventListener('keypress', this.onKeyPress.bind(this), false); + document.addEventListener('keydown', this.onKeyDown.bind(this), false); }; @@ -76,9 +76,9 @@ InspectorInput.prototype.onKeyUp = function(event, press) { if (this.shiftDown) { if (this.ctrlDown) { switch(keyCode) { - case 68: - case 100: - inspector.preventDefault(event); break; //key D pressed + case 68: + case 100: + inspector.preventDefault(event); break; //key D pressed } } } @@ -86,39 +86,39 @@ InspectorInput.prototype.onKeyUp = function(event, press) { if (this.shiftDown && press !== true) { switch(keyCode) { - case 76: - case 108: - /*this.showMenu(); this.toolbarItemSelected('link'); done();*/ break; //key L pressed + case 76: + case 108: + /*this.showMenu(); this.toolbarItemSelected('link'); done();*/ break; //key L pressed - case 71: - case 103: - /*this.showMenu(); this.toolbarItemSelected('position'); done();*/ break; //key G pressed + case 71: + case 103: + /*this.showMenu(); this.toolbarItemSelected('position'); done();*/ break; //key G pressed - case 65: - case 97: - /*this.engine.setAutorotate(1);*/ break; //key A pressed + case 65: + case 97: + /*this.engine.setAutorotate(1);*/ break; //key A pressed } if (this.ctrlDown) { switch(keyCode) { - case 68: - case 100: + case 68: + case 100: - inspector.enableInspector(); + inspector.enableInspector(); //load image - if (!inspector.circleImage) { - inspector.circleImage = utils.loadImage( - "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QAAAAAAAD5Q7t/AAAACW9GRnMAAAAgAAAA4ACD+EAUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA/UlEQVRYw+2VPwqDMBTG3dz1Am56EnH2XLroETxGuwc3Z7cOdhY8QJpfSUBspUvStJAPPggvD973/uQligICAgL+DKViqygUV02hbaXLwJlio7gpyhNu2idzEXwwgfI8H+u6vnZdN/V9P3EuimLcCRlsiyArGcfxjWDLsmzyAGzc4aNFNDZ7/iw7AeQH4LNrh5WZYLgkJTaZCyHuVVVdkiSZ0zSdOWMzlaBFWkRrQ4A4Zk/A4wBie1MFYUMAz0wybCYAmR8FUAlzj6+2r18TgM2VAO8tOB1Cyk7mrofQ+zP0voheVjHtIBjDxjrmvCu7k1Xs/TP6ie84ICDAGR5uCYdPo0MWiAAAAABJRU5ErkJggg==", + if (!inspector.circleImage) { + inspector.circleImage = utils.loadImage( + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QAAAAAAAD5Q7t/AAAACW9GRnMAAAAgAAAA4ACD+EAUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA/UlEQVRYw+2VPwqDMBTG3dz1Am56EnH2XLroETxGuwc3Z7cOdhY8QJpfSUBspUvStJAPPggvD973/uQligICAgL+DKViqygUV02hbaXLwJlio7gpyhNu2idzEXwwgfI8H+u6vnZdN/V9P3EuimLcCRlsiyArGcfxjWDLsmzyAGzc4aNFNDZ7/iw7AeQH4LNrh5WZYLgkJTaZCyHuVVVdkiSZ0zSdOWMzlaBFWkRrQ4A4Zk/A4wBie1MFYUMAz0wybCYAmR8FUAlzj6+2r18TgM2VAO8tOB1Cyk7mrofQ+zP0voheVjHtIBjDxjrmvCu7k1Xs/TP6ie84ICDAGR5uCYdPo0MWiAAAAABJRU5ErkJggg==', //"http://maps.google.com/mapfiles/kml/shapes/placemarkcircle.png", (function(){ - this.inspector.circleTexture = this.core.getRendererInterface().createTexture({ "source": inspector.circleImage }); + this.inspector.circleTexture = this.core.getRendererInterface().createTexture({ 'source': inspector.circleImage }); }).bind(this) ); - } + } - this.diagnosticMode = true; hit = true; break; //key D pressed + this.diagnosticMode = true; hit = true; break; //key D pressed } } @@ -127,24 +127,24 @@ InspectorInput.prototype.onKeyUp = function(event, press) { switch(keyCode) { - case 67: - case 99: - map.config.mapDegradeHorizon = !map.config.mapDegradeHorizon; + case 67: + case 99: + map.config.mapDegradeHorizon = !map.config.mapDegradeHorizon; //this.measureMode = !this.measureMode; //this.measurePoints = []; //var pos = this.core.hitTest(this.mouseX, this.mouseY, "all"); //console.log("hit pos: " + pos[0] + " " + pos[1] + " " + pos[2] + " " + pos[3] + " d " + pos[4]); //key T pressed - break; //key C pressed + break; //key C pressed - case 49: /*this.core.setControlMode("manual"); done();*/ break; //key 1 pressed - case 50: /*this.core.setControlMode("drone"); done();*/ break; //key 2 pressed - case 51: /*this.core.setControlMode("observer"); done();*/ break; //key 3 pressed + case 49: /*this.core.setControlMode("manual"); done();*/ break; //key 1 pressed + case 50: /*this.core.setControlMode("drone"); done();*/ break; //key 2 pressed + case 51: /*this.core.setControlMode("observer"); done();*/ break; //key 3 pressed - case 48: //key 0 pressed + case 48: //key 0 pressed /*this.core.setOption("noForwardMovement" , !this.core.getOption("noForwardMovement"));*/ - break; + break; //case 84: //key T pressed //case 116: @@ -153,64 +153,64 @@ InspectorInput.prototype.onKeyUp = function(event, press) { this.core.logTile(pos);*/ //break; - case 72: - case 104: - debug.heightmapOnly = !debug.heightmapOnly; + case 72: + case 104: + debug.heightmapOnly = !debug.heightmapOnly; /* var pos = map.getPosition(); pos.setHeight(pos.setHeight() * 0.9); map.setPosition(pos);*/ - break; //key H pressed - - case 81: - case 113: - var pos = map.getPosition(); - console.log("pos-before: " + JSON.stringify(pos.pos)); - map.convertPositionViewMode(pos, (pos.getViewMode() == "obj") ? "subj" : "obj"); - console.log("new mode: " + pos.getViewMode()); - console.log("pos-after: " + JSON.stringify(pos.pos)); - map.setPosition(pos); - /*this.core.saveScreenshot(pos);*/ break; //key Q pressed - - case 80: - case 112: - map.renderer.saveScreenshot("file", "vts-screenshot.png", "png"); break; //key P pressed - - case 83: - case 115: - inspector.stats.switchPanel(); break; //key S pressed - - case 86: - case 118: - inspector.layers.switchPanel(); break; //key V pressed - - case 69: - case 101: - inspector.stylesheets.switchPanel(); break; //key E pressed - - case 84: - case 116: - inspector.replay.switchPanel(); break; //key T pressed - - case 66: - case 98: - debug.drawBBoxes = !debug.drawBBoxes; break; //key B pressed - - case 87: - case 119: - var value = debug.drawWireframe + 1; - debug.drawWireframe = value > 2 ? 0 : value; - break; //key W pressed - - case 70: - case 102: - debug.drawWireframe = debug.drawWireframe != 3 ? 3 : 0; - break; //key F pressed - - case 77: - case 109: + break; //key H pressed + + case 81: + case 113: + var pos = map.getPosition(); + console.log('pos-before: ' + JSON.stringify(pos.pos)); + map.convertPositionViewMode(pos, (pos.getViewMode() == 'obj') ? 'subj' : 'obj'); + console.log('new mode: ' + pos.getViewMode()); + console.log('pos-after: ' + JSON.stringify(pos.pos)); + map.setPosition(pos); + /*this.core.saveScreenshot(pos);*/ break; //key Q pressed + + case 80: + case 112: + map.renderer.saveScreenshot('file', 'vts-screenshot.png', 'png'); break; //key P pressed + + case 83: + case 115: + inspector.stats.switchPanel(); break; //key S pressed + + case 86: + case 118: + inspector.layers.switchPanel(); break; //key V pressed + + case 69: + case 101: + inspector.stylesheets.switchPanel(); break; //key E pressed + + case 84: + case 116: + inspector.replay.switchPanel(); break; //key T pressed + + case 66: + case 98: + debug.drawBBoxes = !debug.drawBBoxes; break; //key B pressed + + case 87: + case 119: + var value = debug.drawWireframe + 1; + debug.drawWireframe = value > 2 ? 0 : value; + break; //key W pressed + + case 70: + case 102: + debug.drawWireframe = debug.drawWireframe != 3 ? 3 : 0; + break; //key F pressed + + case 77: + case 109: //map.drawMaxLod = !map.drawMaxLod; //map.config.mapGeocentCulling2 = !map.config.mapGeocentCulling2; @@ -254,43 +254,43 @@ InspectorInput.prototype.onKeyUp = function(event, press) { //map.zFactor2 += 0.1; //0.000001; //console.log("zfactor " + map.zFactor2 + " zz: " + map.renderer.getZoffsetFactor([map.zFactor2, 0, 0])); - map.loaderSuspended = !map.loaderSuspended; - console.log("loader state " + map.loaderSuspended); + map.loaderSuspended = !map.loaderSuspended; + console.log('loader state ' + map.loaderSuspended); - break; //key M pressed + break; //key M pressed - case 74: - case 106: - debug.drawEarth = !debug.drawEarth; hit = true; break; //key X pressed - break; //key J pressed + case 74: + case 106: + debug.drawEarth = !debug.drawEarth; hit = true; break; //key X pressed + break; //key J pressed - case 88: - case 120: - debug.config.mapFog = !debug.config.mapFog; hit = true; break; //key X pressed + case 88: + case 120: + debug.config.mapFog = !debug.config.mapFog; hit = true; break; //key X pressed - case 82: - case 114: - inspector.graphs.switchPanel(); break; //key R pressed + case 82: + case 114: + inspector.graphs.switchPanel(); break; //key R pressed - case 79: - case 111: - map.camera.camera.setOrtho(!map.camera.camera.getOrtho()); break; //key O pressed + case 79: + case 111: + map.camera.camera.setOrtho(!map.camera.camera.getOrtho()); break; //key O pressed - case 76: - case 108: - inspector.drawRadar = !inspector.drawRadar; break; //key L pressed + case 76: + case 108: + inspector.drawRadar = !inspector.drawRadar; break; //key L pressed - case 90: - case 122: - debug.ignoreTexelSize = !debug.ignoreTexelSize; break; //key Z pressed + case 90: + case 122: + debug.ignoreTexelSize = !debug.ignoreTexelSize; break; //key Z pressed - case 78: - case 110: - inspector.shakeCamera = !inspector.shakeCamera; break; //key N pressed + case 78: + case 110: + inspector.shakeCamera = !inspector.shakeCamera; break; //key N pressed - default: - blockHit = false; - break; + default: + blockHit = false; + break; } @@ -304,23 +304,23 @@ InspectorInput.prototype.onKeyUp = function(event, press) { var blockHit = true; switch(keyCode) { - case 43: - case 107: - if (inspector.radarLod == null) { inspector.radarLod = 8;} - inspector.radarLod++; /*console.log("radarLOD: " + this.radarLod);*/ break; //key mun + pressed - - case 45: - case 109: - if (inspector.radarLod == null) { inspector.radarLod = 8;} - inspector.radarLod = Math.max(0,inspector.radarLod-1); /*console.log("radarLOD: " + this.radarLod);*/ break; //key mun - pressed - - case 42: - case 106: - inspector.radarLod = null; /*console.log("radarLOD: auto");*/ break; //key mun * pressed - - default: - blockHit = false; - break; + case 43: + case 107: + if (inspector.radarLod == null) { inspector.radarLod = 8;} + inspector.radarLod++; /*console.log("radarLOD: " + this.radarLod);*/ break; //key mun + pressed + + case 45: + case 109: + if (inspector.radarLod == null) { inspector.radarLod = 8;} + inspector.radarLod = Math.max(0,inspector.radarLod-1); /*console.log("radarLOD: " + this.radarLod);*/ break; //key mun - pressed + + case 42: + case 106: + inspector.radarLod = null; /*console.log("radarLOD: auto");*/ break; //key mun * pressed + + default: + blockHit = false; + break; } if (blockHit) { @@ -329,72 +329,72 @@ InspectorInput.prototype.onKeyUp = function(event, press) { } if (this.diagnosticMode && debug.drawBBoxes && !this.shiftDown && !press) { - var blockHit = true; + var blockHit = true; switch(keyCode) { - case 76: - case 108: - debug.drawLods = !debug.drawLods; break; //key L pressed + case 76: + case 108: + debug.drawLods = !debug.drawLods; break; //key L pressed - case 80: - case 112: - debug.drawPositions = !debug.drawPositions; break; //key P pressed + case 80: + case 112: + debug.drawPositions = !debug.drawPositions; break; //key P pressed - case 84: - case 116: - debug.drawTextureSize = !debug.drawTextureSize; break; //key T pressed + case 84: + case 116: + debug.drawTextureSize = !debug.drawTextureSize; break; //key T pressed - case 70: - case 102: - debug.drawFaceCount = !debug.drawFaceCount; break; //key F pressed + case 70: + case 102: + debug.drawFaceCount = !debug.drawFaceCount; break; //key F pressed - case 68: - case 100: - debug.drawDistance = !debug.drawDistance; break; //key D pressed + case 68: + case 100: + debug.drawDistance = !debug.drawDistance; break; //key D pressed - case 78: - case 110: - debug.drawNodeInfo = !debug.drawNodeInfo; break; //key N pressed + case 78: + case 110: + debug.drawNodeInfo = !debug.drawNodeInfo; break; //key N pressed - case 77: - case 109: - debug.drawMeshBBox = !debug.drawMeshBBox; break; //key M pressed + case 77: + case 109: + debug.drawMeshBBox = !debug.drawMeshBBox; break; //key M pressed - case 73: - case 105: - debug.drawIndices = !debug.drawIndices; break; //key I pressed + case 73: + case 105: + debug.drawIndices = !debug.drawIndices; break; //key I pressed - case 66: - case 98: - debug.drawBoundLayers = !debug.drawBoundLayers; break; //key B pressed + case 66: + case 98: + debug.drawBoundLayers = !debug.drawBoundLayers; break; //key B pressed - case 83: - case 115: - debug.drawSurfaces = !debug.drawSurfaces; break; //key S pressed + case 83: + case 115: + debug.drawSurfaces = !debug.drawSurfaces; break; //key S pressed - case 67: - case 99: - debug.drawCredits = !debug.drawCredits; break; //key C pressed + case 67: + case 99: + debug.drawCredits = !debug.drawCredits; break; //key C pressed - case 79: - case 111: - debug.drawOrder = !debug.drawOrder; break; //key O pressed + case 79: + case 111: + debug.drawOrder = !debug.drawOrder; break; //key O pressed - case 69: - case 101: - debug.debugTextSize = (debug.debugTextSize == 2.0) ? 3.0 : 2.0; break; //key E pressed + case 69: + case 101: + debug.debugTextSize = (debug.debugTextSize == 2.0) ? 3.0 : 2.0; break; //key E pressed - case 88: - case 120: - map.config.mapPreciseBBoxTest = !map.config.mapPreciseBBoxTest; break; //key X pressed + case 88: + case 120: + map.config.mapPreciseBBoxTest = !map.config.mapPreciseBBoxTest; break; //key X pressed - case 90: - case 122: - map.config.mapPreciseDistanceTest = !map.config.mapPreciseDistanceTest; break; //key Z pressed + case 90: + case 122: + map.config.mapPreciseDistanceTest = !map.config.mapPreciseDistanceTest; break; //key Z pressed - default: - blockHit = false; - break; + default: + blockHit = false; + break; } if (blockHit) { diff --git a/src/core/inspector/inspector.js b/src/core/inspector/inspector.js index ba2096cf..1e5575a4 100755 --- a/src/core/inspector/inspector.js +++ b/src/core/inspector/inspector.js @@ -51,7 +51,7 @@ Inspector.prototype.enableInspector = function() { this.replay.init(); this.stylesheets.init(); - this.core.on("map-update", this.onMapUpdate.bind(this)); + this.core.on('map-update', this.onMapUpdate.bind(this)); this.enabled = true; } }; @@ -113,12 +113,12 @@ Inspector.prototype.onMapUpdate = function(string) { } renderer.drawLineString({ - "points" : slines, - "size" : 2.0, - "color" : [0,128,255,255], - "depthTest" : false, - "blend" : false - }); + 'points' : slines, + 'size' : 2.0, + 'color' : [0,128,255,255], + 'depthTest' : false, + 'blend' : false + }); var lines = this.replay.cameraLines3; for (var i = 0, li = lines.length; i < li; i++) { @@ -128,12 +128,12 @@ Inspector.prototype.onMapUpdate = function(string) { } renderer.drawLineString({ - "points" : slines, - "size" : 2.0, - "color" : [0,255,128,255], - "depthTest" : false, - "blend" : false - }); + 'points' : slines, + 'size' : 2.0, + 'color' : [0,255,128,255], + 'depthTest' : false, + 'blend' : false + }); } var lines = this.replay.cameraLines2; @@ -144,12 +144,12 @@ Inspector.prototype.onMapUpdate = function(string) { } renderer.drawLineString({ - "points" : slines, - "size" : 2.0, - "color" : [0,255,255,255], - "depthTest" : false, - "blend" : false - }); + 'points' : slines, + 'size' : 2.0, + 'color' : [0,255,255,255], + 'depthTest' : false, + 'blend' : false + }); } @@ -183,7 +183,7 @@ Inspector.prototype.onMapUpdate = function(string) { ]; //multiply cube matrix with camera view matrix - mat4.multiply(cameInfo["view-matrix"], mv, mv); + mat4.multiply(cameInfo['view-matrix'], mv, mv); var norm = [ 0,0,0, @@ -198,15 +198,15 @@ Inspector.prototype.onMapUpdate = function(string) { //draw cube renderer.drawMesh({ - "mesh" : this.replay.frustumMesh, - "texture" : null, - "shader" : "shaded", - "shader-variables" : { - "uMV" : ["mat4", mv], - "uNorm" : ["mat3", norm], - "uMaterial" : ["mat4", material] - } - }); + 'mesh' : this.replay.frustumMesh, + 'texture' : null, + 'shader' : 'shaded', + 'shader-variables' : { + 'uMV' : ['mat4', mv], + 'uNorm' : ['mat3', norm], + 'uMaterial' : ['mat4', material] + } + }); } if (this.drawRadar && this.circleTexture) { @@ -241,7 +241,7 @@ Inspector.prototype.onMapUpdate = function(string) { var pos2 = map.movePositionCoordsTo(pos, math.degrees(a), l); var coords = pos2.getCoords(); - var screenCoords = map.convertCoordsFromNavToCanvas([coords[0], coords[1], 0], "float", this.radarLod); + var screenCoords = map.convertCoordsFromNavToCanvas([coords[0], coords[1], 0], 'float', this.radarLod); cbuffer[j * count + i] = screenCoords; } @@ -256,12 +256,12 @@ Inspector.prototype.onMapUpdate = function(string) { } renderer.drawLineString({ - "points" : lbuffer, - "size" : 2.0, - "color" : [0,255,255,255], - "depthTest" : false, - "blend" : false - }); + 'points' : lbuffer, + 'size' : 2.0, + 'color' : [0,255,255,255], + 'depthTest' : false, + 'blend' : false + }); } @@ -271,24 +271,24 @@ Inspector.prototype.onMapUpdate = function(string) { } renderer.drawLineString({ - "points" : lbuffer, - "size" : 2.0, - "color" : [0,255,255,255], - "depthTest" : false, - "blend" : false - }); + 'points' : lbuffer, + 'size' : 2.0, + 'color' : [0,255,255,255], + 'depthTest' : false, + 'blend' : false + }); } for (var i = 0, li = cbuffer.length; i < li; i++) { var p = cbuffer[i]; renderer.drawImage({ - "rect" : [p[0]-10, p[1]-10, 20, 20], - "texture" : this.circleTexture, - "color" : [255,0,255,255], - "depth" : p[2], - "depthTest" : false, - "blend" : true - }); + 'rect' : [p[0]-10, p[1]-10, 20, 20], + 'texture' : this.circleTexture, + 'color' : [255,0,255,255], + 'depth' : p[2], + 'depthTest' : false, + 'blend' : true + }); } } }; diff --git a/src/core/inspector/layers.js b/src/core/inspector/layers.js index ef251a13..d63ba606 100755 --- a/src/core/inspector/layers.js +++ b/src/core/inspector/layers.js @@ -8,166 +8,166 @@ var InspectorLayers = function(inspector) { InspectorLayers.prototype.init = function() { var inspector = this.inspector; inspector.addStyle( - "#vts-layers-panel {" - + "font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;" - + "display: none;" - + "padding:15px;" - + "font-size: 14px;" - + "position: absolute;" - + "right: 10px;" - + "bottom: 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-layers-panel button {" - + "max-width: 23px;" - + "max-height: 21px;" - + "}" - - + "#vts-layers-panel-title {" - + "margin-bottom: 3px;" - + "}" - - + "#vts-layers-views-panel {" - + "margin-top: 5px;" - + "float: left;" - + "}" - - + "#vts-layers-views-items {" - + "width: 191px;" - + "overflow-y: scroll;" - + "overflow-x: hidden;" - + "height: 200px;" - + "border: 1px solid #ddd;" - + "}" + '#vts-layers-panel {' + + 'font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;' + + 'display: none;' + + 'padding:15px;' + + 'font-size: 14px;' + + 'position: absolute;' + + 'right: 10px;' + + 'bottom: 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-layers-panel button {' + + 'max-width: 23px;' + + 'max-height: 21px;' + + '}' + + + '#vts-layers-panel-title {' + + 'margin-bottom: 3px;' + + '}' + + + '#vts-layers-views-panel {' + + 'margin-top: 5px;' + + 'float: left;' + + '}' + + + '#vts-layers-views-items {' + + 'width: 191px;' + + 'overflow-y: scroll;' + + 'overflow-x: hidden;' + + 'height: 200px;' + + 'border: 1px solid #ddd;' + + '}' - + "#vts-layers-surfaces-panel {" - + "margin-top: 5px;" - + "float: left;" - + "}" + + '#vts-layers-surfaces-panel {' + + 'margin-top: 5px;' + + 'float: left;' + + '}' - + "#vts-layers-surfaces-items {" - + "width: 150px;" - + "overflow-y: scroll;" - + "overflow-x: hidden;" - + "height: 200px;" - + "border-top: 1px solid #ddd;" - + "border-bottom: 1px solid #ddd;" - + "}" + + '#vts-layers-surfaces-items {' + + 'width: 150px;' + + 'overflow-y: scroll;' + + 'overflow-x: hidden;' + + 'height: 200px;' + + 'border-top: 1px solid #ddd;' + + 'border-bottom: 1px solid #ddd;' + + '}' - + "#vts-layers-boundlayers-panel {" - + "margin-top: 5px;" - + "float: left;" - + "}" - - + "#vts-layers-boundlayers-items {" - + "width: 250px;" - + "overflow-y: scroll;" - + "overflow-x: hidden;" - + "height: 200px;" - + "border: 1px solid #ddd;" - + "border-right: none;" - + "}" - - + "#vts-layers-freelayers-panel {" - + "margin-top: 5px;" - + "float: left;" - + "}" - - + "#vts-layers-freelayers-items {" - + "width: 150px;" - + "overflow-y: scroll;" - + "overflow-x: hidden;" - + "height: 200px;" - + "border: 1px solid #ddd;" - + "}" - - + "#vts-layers-fl-properties-panel {" - + "margin-top: 5px;" - + "float: left;" - + "}" - - + "#vts-layers-fl-properties-items {" - + "width: 250px;" - + "overflow-y: scroll;" - + "overflow-x: hidden;" - + "height: 200px;" - + "border: 1px solid #ddd;" - + "border-right: none;" - + "}" - - + "#vts-layers-json-panel {" - + "margin-top: 5px;" - + "float: right;" - + "}" - - + "#vts-layers-json-text {" - + "width: 200px;" - + "resize: none;" - + "height: 180px;" - + "border: 1px solid #ddd;" - + "white-space: nowrap;" - + "padding: 0px;" - + "}" - - + "#vts-layers-json-text2 {" - + "width: 200px;" - + "height: 21px;" - + "border: 1px solid #ddd;" - + "}" + + '#vts-layers-boundlayers-panel {' + + 'margin-top: 5px;' + + 'float: left;' + + '}' + + + '#vts-layers-boundlayers-items {' + + 'width: 250px;' + + 'overflow-y: scroll;' + + 'overflow-x: hidden;' + + 'height: 200px;' + + 'border: 1px solid #ddd;' + + 'border-right: none;' + + '}' + + + '#vts-layers-freelayers-panel {' + + 'margin-top: 5px;' + + 'float: left;' + + '}' + + + '#vts-layers-freelayers-items {' + + 'width: 150px;' + + 'overflow-y: scroll;' + + 'overflow-x: hidden;' + + 'height: 200px;' + + 'border: 1px solid #ddd;' + + '}' + + + '#vts-layers-fl-properties-panel {' + + 'margin-top: 5px;' + + 'float: left;' + + '}' + + + '#vts-layers-fl-properties-items {' + + 'width: 250px;' + + 'overflow-y: scroll;' + + 'overflow-x: hidden;' + + 'height: 200px;' + + 'border: 1px solid #ddd;' + + 'border-right: none;' + + '}' + + + '#vts-layers-json-panel {' + + 'margin-top: 5px;' + + 'float: right;' + + '}' + + + '#vts-layers-json-text {' + + 'width: 200px;' + + 'resize: none;' + + 'height: 180px;' + + 'border: 1px solid #ddd;' + + 'white-space: nowrap;' + + 'padding: 0px;' + + '}' + + + '#vts-layers-json-text2 {' + + 'width: 200px;' + + 'height: 21px;' + + 'border: 1px solid #ddd;' + + '}' - + ".vts-layers-panel-title {" - + "margin: 0px;" - + "margin-bottom: 5px;" - + "}" - - + ".vts-layers-item {" - + "width: 100%;" - + "}" + + '.vts-layers-panel-title {' + + 'margin: 0px;' + + 'margin-bottom: 5px;' + + '}' + + + '.vts-layers-item {' + + 'width: 100%;' + + '}' - + ".vts-layers-item input[type=number]{" - + "width: 43px;" - + "}" + + '.vts-layers-item input[type=number]{' + + 'width: 43px;' + + '}' - + ".vts-layers-name {" - + "width: 120px;" - + "display: inline-block;" - + "overflow: hidden;" - + "text-overflow: ellipsis;" - + "white-space: nowrap;" - + "}" - - + ".vts-layers-name2 {" - + "width: 126px;" - + "display: inline-block;" - + "overflow: hidden;" - + "text-overflow: ellipsis;" - + "white-space: nowrap;" - + "}" + + '.vts-layers-name {' + + 'width: 120px;' + + 'display: inline-block;' + + 'overflow: hidden;' + + 'text-overflow: ellipsis;' + + 'white-space: nowrap;' + + '}' + + + '.vts-layers-name2 {' + + 'width: 126px;' + + 'display: inline-block;' + + 'overflow: hidden;' + + 'text-overflow: ellipsis;' + + 'white-space: nowrap;' + + '}' - + "#vts-layers-fl-properties-style {" - + "width: 175px;" - + "height: 21px;" - + "}" - - + ".vts-surface-item {" - + "width: 100%;" - + "overflow: hidden;" - + "text-overflow: ellipsis;" - + "white-space: nowrap;" - + "}" + + '#vts-layers-fl-properties-style {' + + 'width: 175px;' + + 'height: 21px;' + + '}' + + + '.vts-surface-item {' + + 'width: 100%;' + + 'overflow: hidden;' + + 'text-overflow: ellipsis;' + + 'white-space: nowrap;' + + '}' ); - this.element = document.createElement("div"); - this.element.id = "vts-layers-panel"; - this.element.innerHTML = "" + this.element = document.createElement('div'); + this.element.id = 'vts-layers-panel'; + this.element.innerHTML = '' + '

Named Views:

' + '
' + '

Surfaces:

' @@ -183,26 +183,26 @@ InspectorLayers.prototype.init = function() { + '
'; this.core.element.appendChild(this.element); - this.viewItems = document.getElementById("vts-layers-views-items"); - this.surfacesItems = document.getElementById("vts-layers-surfaces-items"); - this.boundLayersItems = document.getElementById("vts-layers-boundlayers-items"); - this.freeLayersItems = document.getElementById("vts-layers-freelayers-items"); - this.freeLayersPropertiesItems = document.getElementById("vts-layers-fl-properties-items"); - this.jsonText = document.getElementById("vts-layers-json-text"); - this.jsonText2 = document.getElementById("vts-layers-json-text2"); - - 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.viewItems = document.getElementById('vts-layers-views-items'); + this.surfacesItems = document.getElementById('vts-layers-surfaces-items'); + this.boundLayersItems = document.getElementById('vts-layers-boundlayers-items'); + this.freeLayersItems = document.getElementById('vts-layers-freelayers-items'); + this.freeLayersPropertiesItems = document.getElementById('vts-layers-fl-properties-items'); + this.jsonText = document.getElementById('vts-layers-json-text'); + this.jsonText2 = document.getElementById('vts-layers-json-text2'); + + 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.views = []; this.panelVisible = false; this.panelInitialized = false; - this.currentView = ""; - this.currentSurface = ""; - this.currentFreeLayer = ""; + this.currentView = ''; + this.currentSurface = ''; + this.currentFreeLayer = ''; }; @@ -213,12 +213,12 @@ InspectorLayers.prototype.initViews = function() { } var views = map.getNamedViews(); - var id = "--initial--"; + var id = '--initial--'; this.views[id] = { - surfaces : {}, - freeLayers : {}, - original : JSON.parse(JSON.stringify(map.getView())) - }; + surfaces : {}, + freeLayers : {}, + original : JSON.parse(JSON.stringify(map.getView())) + }; for (var i = 0, li = views.length; i < li; i++) { var view = views[i]; @@ -282,13 +282,13 @@ InspectorLayers.prototype.initViews = function() { view.freeLayers[id] = { enabled : false, style : null, - originalStyle : freeLayerInfo["style"], + originalStyle : freeLayerInfo['style'], depthShift : 0, layers : states }; } - var viewSurfaces = view.original["surfaces"]; + var viewSurfaces = view.original['surfaces']; for (var skey in viewSurfaces) { var layers = viewSurfaces[skey]; @@ -298,18 +298,18 @@ InspectorLayers.prototype.initViews = function() { surface.enabled = true; for (var i = 0, li = layers.length; i < li; i++) { - if (typeof layers[i] === "string") { + if (typeof layers[i] === 'string') { var 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 id = layers[i]['id']; var 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; + surface.layers[index].alpha = layers[i]['alpha'] ? (parseFloat(layers[i]['alpha'])*100) : 100; surface.layers.splice(i, 0, surface.layers.splice(index, 1)[0]); } } @@ -317,7 +317,7 @@ InspectorLayers.prototype.initViews = function() { } } - var viewfreeLayers = view.original["freeLayers"]; + var viewfreeLayers = view.original['freeLayers']; for (var skey in viewfreeLayers) { var freeLayerProperties = viewfreeLayers[skey]; @@ -325,27 +325,27 @@ InspectorLayers.prototype.initViews = function() { if (view.freeLayers[skey]) { var freeLayer = view.freeLayers[skey]; freeLayer.enabled = true; - freeLayer.depthShift = freeLayerProperties["depthShift"] || 0; + freeLayer.depthShift = freeLayerProperties['depthShift'] || 0; freeLayer.depthShift *= 100; - freeLayer.style = freeLayerProperties["style"]; + freeLayer.style = freeLayerProperties['style']; //freeLayer.originalStyle = freeLayer.style; var layers = []; freeLayer.layers = layers; for (var i = 0, li = layers.length; i < li; i++) { - if (typeof layers[i] === "string") { + if (typeof layers[i] === 'string') { var 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 id = layers[i]['id']; var 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; + freeLayer.layers[index].alpha = layers[i]['alpha'] ? (parseFloat(layers[i]['alpha'])*100) : 100; freeLayer.layers.splice(i, 0, surface.layers.splice(index, 1)[0]); } } @@ -375,7 +375,7 @@ InspectorLayers.prototype.buildViews = function() { } var views = this.views; - var html = ""; + var html = ''; for (var key in views) { html += '
' @@ -388,11 +388,11 @@ InspectorLayers.prototype.buildViews = function() { this.viewItems.innerHTML = html; for (var key in views) { - htmlId = "vts-views-cbutton-" + key; - document.getElementById(htmlId).onclick = this.switchView.bind(this, key, htmlId, "clone"); - htmlId = "vts-views-xbutton-" + key; - document.getElementById(htmlId).onclick = this.switchView.bind(this, key, htmlId, "remove"); - var htmlId = "vts-views-item-" + key; + htmlId = 'vts-views-cbutton-' + key; + document.getElementById(htmlId).onclick = this.switchView.bind(this, key, htmlId, 'clone'); + htmlId = 'vts-views-xbutton-' + key; + document.getElementById(htmlId).onclick = this.switchView.bind(this, key, htmlId, 'remove'); + var htmlId = 'vts-views-item-' + key; document.getElementById(htmlId).onclick = this.selectView.bind(this, key); } }; @@ -401,7 +401,7 @@ InspectorLayers.prototype.buildViews = function() { InspectorLayers.prototype.buildSurfaces = function() { var view = this.views[this.currentView]; var surfaces = view.surfaces; - var html = ""; + var html = ''; var firstKey = null; for (var key in surfaces) { @@ -418,15 +418,15 @@ InspectorLayers.prototype.buildSurfaces = function() { for (var key in surfaces) { if (surfaces[key].enabled) { - var htmlId = "vts-surface-checkbox-" + key; + var htmlId = 'vts-surface-checkbox-' + key; document.getElementById(htmlId).checked = true; } } for (var key in surfaces) { - var htmlId = "vts-surface-checkbox-" + key; + var htmlId = 'vts-surface-checkbox-' + key; document.getElementById(htmlId).onchange = this.switchSurface.bind(this, key, htmlId); - var htmlId = "vts-surface-item-" + key; + var htmlId = 'vts-surface-item-' + key; document.getElementById(htmlId).onclick = this.selectSurface.bind(this, key); } }; @@ -435,12 +435,12 @@ InspectorLayers.prototype.buildSurfaces = function() { InspectorLayers.prototype.buildBoundLayers = function(id) { var view = this.views[this.currentView]; var layers = view.surfaces[id].layers; - var html = ""; + var html = ''; for (var i = 0, li = layers.length; i < li; i++) { var layer = layers[i]; - html += '
' + html += '
' + '
' + layer.id + '
' + '' + '' @@ -451,14 +451,14 @@ InspectorLayers.prototype.buildBoundLayers = function(id) { this.boundLayersItems.innerHTML = html; for (var i = 0, li = layers.length; i < li; i++) { - var htmlId = "vts-boundlayer-checkbox-" + layers[i].id; - document.getElementById(htmlId).onchange = this.switchBoundLayer.bind(this, layers[i].id, htmlId, "enable"); - htmlId = "vts-boundlayer-spinner-" + layers[i].id; - document.getElementById(htmlId).onchange = this.switchBoundLayer.bind(this, layers[i].id, htmlId, "alpha"); - htmlId = "vts-boundlayer-ubutton-" + layers[i].id; - document.getElementById(htmlId).onclick = this.switchBoundLayer.bind(this, layers[i].id, htmlId, "up"); - htmlId = "vts-boundlayer-dbutton-" + layers[i].id; - document.getElementById(htmlId).onclick = this.switchBoundLayer.bind(this, layers[i].id, htmlId, "down"); + var htmlId = 'vts-boundlayer-checkbox-' + layers[i].id; + document.getElementById(htmlId).onchange = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'enable'); + htmlId = 'vts-boundlayer-spinner-' + layers[i].id; + document.getElementById(htmlId).onchange = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'alpha'); + htmlId = 'vts-boundlayer-ubutton-' + layers[i].id; + document.getElementById(htmlId).onclick = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'up'); + htmlId = 'vts-boundlayer-dbutton-' + layers[i].id; + document.getElementById(htmlId).onclick = this.switchBoundLayer.bind(this, layers[i].id, htmlId, 'down'); } }; @@ -466,21 +466,21 @@ InspectorLayers.prototype.buildBoundLayers = function(id) { InspectorLayers.prototype.buildFreeLayers = function() { var view = this.views[this.currentView]; var layers = view.freeLayers; - var html = ""; + var html = ''; for (var key in layers) { var layer = layers[key]; html += '
' + key + '
'; + + (layers[key].enabled ? 'checked' : '') + '/>' + key + '
'; } this.freeLayersItems.innerHTML = html; for (var key in layers) { - var htmlId = "vts-freelayer-checkbox-" + key; + var htmlId = 'vts-freelayer-checkbox-' + key; document.getElementById(htmlId).onchange = this.switchFreeLayer.bind(this, key, htmlId); - var htmlId = "vts-freelayer-item-" + key; + var htmlId = 'vts-freelayer-item-' + key; document.getElementById(htmlId).onclick = this.selectFreeLayer.bind(this, key); } }; @@ -490,76 +490,76 @@ 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 = ''; if (!map || !map.getFreeLayer(id)) { return; } var layerInfo = map.getFreeLayer(id).getInfo(); - var layerType = layerInfo["type"]; + var layerType = layerInfo['type']; switch(layerType) { - case "mesh": - case "mesh-tiles": + case 'mesh': + case 'mesh-tiles': - html += '
' + "DepthShift:" + '
' + html += '
' + 'DepthShift:' + '
' + '' + '
'; - html += '
' + "BoundLayers:" + '
'; + html += '
' + 'BoundLayers:' + '
'; - for (var i = 0, li = layers.length; i < li; i++) { - var layer = layers[i]; + for (var i = 0, li = layers.length; i < li; i++) { + var layer = layers[i]; - html += '
' + html += '
' + '
' + layer.id + '
' + '' + '' + '' + '
'; - } + } - this.freeLayersPropertiesItems.innerHTML = html; + this.freeLayersPropertiesItems.innerHTML = html; - var htmlId = "vts-fl-properties-depth-shift"; - document.getElementById(htmlId).onchange = this.switchFreeLayerProperty.bind(this, htmlId, "depthShift"); + var 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; - 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"); - htmlId = "vts-fl-properties-ubutton-" + layers[i].id; - document.getElementById(htmlId).onclick = this.switchFreeLayerBoundLayer.bind(this, layers[i].id, htmlId, "up"); - htmlId = "vts-fl-properties-dbutton-" + layers[i].id; - document.getElementById(htmlId).onclick = this.switchFreeLayerBoundLayer.bind(this, layers[i].id, htmlId, "down"); - } + for (var i = 0, li = layers.length; i < li; i++) { + var 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'); + htmlId = 'vts-fl-properties-ubutton-' + layers[i].id; + document.getElementById(htmlId).onclick = this.switchFreeLayerBoundLayer.bind(this, layers[i].id, htmlId, 'up'); + htmlId = 'vts-fl-properties-dbutton-' + layers[i].id; + document.getElementById(htmlId).onclick = this.switchFreeLayerBoundLayer.bind(this, layers[i].id, htmlId, 'down'); + } - break; + break; - case "geodata": - case "geodata-tiles": + case 'geodata': + case 'geodata-tiles': - html += '
' + "Style:" + '
' + html += '
' + 'Style:' + '
' + '' + html += '' + '
'; - this.freeLayersPropertiesItems.innerHTML = html; + this.freeLayersPropertiesItems.innerHTML = html; - var htmlId = "vts-layers-fl-properties-style"; - document.getElementById(htmlId).onchange = this.switchFreeLayerProperty.bind(this, htmlId, "style"); + var htmlId = 'vts-layers-fl-properties-style'; + document.getElementById(htmlId).onchange = this.switchFreeLayerProperty.bind(this, htmlId, 'style'); - break; + break; } }; @@ -571,15 +571,15 @@ InspectorLayers.prototype.selectView = function(id) { //deselect previous if (this.currentView) { - var element = document.getElementById("vts-views-item-" + this.currentView); + var element = document.getElementById('vts-views-item-' + this.currentView); if (element) { - element.style.backgroundColor = "initial"; + element.style.backgroundColor = 'initial'; } } //select new one - var element = document.getElementById("vts-views-item-" + id); - element.style.backgroundColor = "#ddd"; + var element = document.getElementById('vts-views-item-' + id); + element.style.backgroundColor = '#ddd'; this.currentView = id; //this.buildBoundLayers(this.currentSurface); @@ -597,44 +597,44 @@ InspectorLayers.prototype.switchView = function(id, htmlId, action) { for (var key in this.views) { if (key == id) { switch(action) { - case "clone": + case 'clone': //layers[i].enabled = element.checked; - var i = 2; + var i = 2; - while(true) { - if (!views[id + " #" + i]) { - views[id + " #" + i] = JSON.parse(JSON.stringify(views[id])); - break; - } - i++; - } + while(true) { + if (!views[id + ' #' + i]) { + views[id + ' #' + i] = JSON.parse(JSON.stringify(views[id])); + break; + } + i++; + } - this.buildViews(); + this.buildViews(); - break; - case "remove": + break; + case 'remove': - var count = 0; + var count = 0; - for (var key in views) { - count++; - } + for (var key in views) { + count++; + } - if (count > 1) { - delete views[id]; - this.buildViews(); - - if (this.currentView == id) { - for (var key in views) { - this.selectView(key); - break; - } - } else { - this.selectView(this.currentView); + if (count > 1) { + delete views[id]; + this.buildViews(); + + if (this.currentView == id) { + for (var key in views) { + this.selectView(key); + break; } + } else { + this.selectView(this.currentView); } + } - break; + break; } break; @@ -654,13 +654,13 @@ InspectorLayers.prototype.switchSurface = function(id, htmlId) { InspectorLayers.prototype.selectSurface = function(id, htmlId) { //deselect previous if (this.currentSurface) { - var element = document.getElementById("vts-surface-item-" + this.currentSurface); - element.style.backgroundColor = "initial"; + var element = document.getElementById('vts-surface-item-' + this.currentSurface); + element.style.backgroundColor = 'initial'; } //select new one - var element = document.getElementById("vts-surface-item-" + id); - element.style.backgroundColor = "#ddd"; + var element = document.getElementById('vts-surface-item-' + id); + element.style.backgroundColor = '#ddd'; this.currentSurface = id; this.buildBoundLayers(this.currentSurface); }; @@ -674,20 +674,20 @@ InspectorLayers.prototype.switchBoundLayer = function(id, htmlId, action) { for (var i = 0, li = layers.length; i < li; i++) { if (layers[i].id == id) { switch(action) { - case "enable": - layers[i].enabled = element.checked; - break; - case "alpha": - layers[i].alpha = parseInt(element.value, 10); - break; - case "up": - layers.splice(Math.max(0,i-1), 0, layers.splice(i, 1)[0]); - this.selectSurface(this.currentSurface); - break; - case "down": - layers.splice(Math.max(0,i+1), 0, layers.splice(i, 1)[0]); - this.selectSurface(this.currentSurface); - break; + case 'enable': + layers[i].enabled = element.checked; + break; + case 'alpha': + layers[i].alpha = parseInt(element.value, 10); + break; + case 'up': + layers.splice(Math.max(0,i-1), 0, layers.splice(i, 1)[0]); + this.selectSurface(this.currentSurface); + break; + case 'down': + layers.splice(Math.max(0,i+1), 0, layers.splice(i, 1)[0]); + this.selectSurface(this.currentSurface); + break; } break; @@ -709,13 +709,13 @@ InspectorLayers.prototype.switchFreeLayer = function(id, htmlId) { InspectorLayers.prototype.selectFreeLayer = function(id, htmlId) { //deselect previous if (this.currentFreeLayer) { - var element = document.getElementById("vts-freelayer-item-" + this.currentFreeLayer); - element.style.backgroundColor = "initial"; + var element = document.getElementById('vts-freelayer-item-' + this.currentFreeLayer); + element.style.backgroundColor = 'initial'; } //select new one - var element = document.getElementById("vts-freelayer-item-" + id); - element.style.backgroundColor = "#ddd"; + var element = document.getElementById('vts-freelayer-item-' + id); + element.style.backgroundColor = '#ddd'; this.currentFreeLayer = id; this.buildFreeLayerProperties(this.currentFreeLayer); }; @@ -729,20 +729,20 @@ InspectorLayers.prototype.switchFreeLayerBoundLayer = function(id, htmlId, actio for (var i = 0, li = layers.length; i < li; i++) { if (layers[i].id == id) { switch(action) { - case "enable": - layers[i].enabled = element.checked; - break; - case "alpha": - layers[i].alpha = parseInt(element.value, 10); - break; - case "up": - layers.splice(Math.max(0,i-1), 0, layers.splice(i, 1)[0]); - this.selectFreeLayer(this.currentFreeLayer); - break; - case "down": - layers.splice(Math.max(0,i+1), 0, layers.splice(i, 1)[0]); - this.selectFreeLayer(this.currentFreeLayer); - break; + case 'enable': + layers[i].enabled = element.checked; + break; + case 'alpha': + layers[i].alpha = parseInt(element.value, 10); + break; + case 'up': + layers.splice(Math.max(0,i-1), 0, layers.splice(i, 1)[0]); + this.selectFreeLayer(this.currentFreeLayer); + break; + case 'down': + layers.splice(Math.max(0,i+1), 0, layers.splice(i, 1)[0]); + this.selectFreeLayer(this.currentFreeLayer); + break; } break; @@ -759,12 +759,12 @@ InspectorLayers.prototype.switchFreeLayerProperty = function(htmlId, action) { var layer = view.freeLayers[this.currentFreeLayer]; switch(action) { - case "depthShift": - layer.depthShift = parseInt(element.value, 10); - break; - case "style": - layer.style = element.value; - break; + case 'depthShift': + layer.depthShift = parseInt(element.value, 10); + break; + case 'style': + layer.style = element.value; + break; } this.applyMapView(); @@ -773,8 +773,8 @@ InspectorLayers.prototype.switchFreeLayerProperty = function(htmlId, action) { InspectorLayers.prototype.applyMapView = function(jsonOnly) { var view = { - "surfaces" : {}, - "freeLayers" : {} + 'surfaces' : {}, + 'freeLayers' : {} }; var sourceView = this.views[this.currentView]; @@ -789,14 +789,14 @@ InspectorLayers.prototype.applyMapView = function(jsonOnly) { if (layers[i].enabled) { if (layers[i].alpha < 100) { - surfaceBoundLayers.push({"id":layers[i].id, "alpha":(layers[i].alpha*0.01).toFixed(2)}); + surfaceBoundLayers.push({'id':layers[i].id, 'alpha':(layers[i].alpha*0.01).toFixed(2)}); } else { surfaceBoundLayers.push(layers[i].id); } } } - view["surfaces"][key] = surfaceBoundLayers; + view['surfaces'][key] = surfaceBoundLayers; } } @@ -811,31 +811,31 @@ InspectorLayers.prototype.applyMapView = function(jsonOnly) { if (layers[i].enabled) { if (layers[i].alpha < 100) { - freeLayerBoundLayers.push({"id":layers[i].id, "alpha":parseFloat((layers[i].alpha*0.01).toFixed(2))}); + freeLayerBoundLayers.push({'id':layers[i].id, 'alpha':parseFloat((layers[i].alpha*0.01).toFixed(2))}); } else { freeLayerBoundLayers.push(layers[i].id); } } } - view["freeLayers"][key] = {}; + view['freeLayers'][key] = {}; if (freeLayerBoundLayers.length > 0) { - view["freeLayers"][key]["boundLayers"] = freeLayerBoundLayers; + view['freeLayers'][key]['boundLayers'] = freeLayerBoundLayers; } if (freeLayers[key].style && freeLayers[key].style != freeLayers[key].originalStyle) { - view["freeLayers"][key]["style"] = freeLayers[key].style; + view['freeLayers'][key]['style'] = freeLayers[key].style; } if (freeLayers[key].depthShift != 0) { - view["freeLayers"][key]["depthShift"] = parseFloat((freeLayers[key].depthShift*0.01).toFixed(2)); + view['freeLayers'][key]['depthShift'] = parseFloat((freeLayers[key].depthShift*0.01).toFixed(2)); } } } - this.jsonText.value = JSON.stringify(view, null, " "); + this.jsonText.value = JSON.stringify(view, null, ' '); this.jsonText2.value = encodeURIComponent(JSON.stringify(view)); if (!jsonOnly) { @@ -850,14 +850,14 @@ InspectorLayers.prototype.applyMapView = function(jsonOnly) { InspectorLayers.prototype.showPanel = function() { - this.element.style.display = "block"; + this.element.style.display = 'block'; this.panelVisible = true; this.updatePanel(); }; InspectorLayers.prototype.hidePanel = function() { - this.element.style.display = "none"; + this.element.style.display = 'none'; this.panelVisible = false; }; diff --git a/src/core/inspector/stats.js b/src/core/inspector/stats.js index d39f887c..13c74f80 100755 --- a/src/core/inspector/stats.js +++ b/src/core/inspector/stats.js @@ -12,73 +12,73 @@ var InspectorStats = function(inspector) { InspectorStats.prototype.init = function() { var inspector = this.inspector; inspector.addStyle( - "#vts-stats-panel {" - + "font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;" - + "display: none;" - + "padding:15px;" - + "width: 305px;" - + "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-stats-panel-info {" - + "margin-top: 5px;" - + "margin-bottom: 3px;" - + "overflow: hidden;" - + "}" - - + "#vts-stats-panel-info table {" - + "color:#000000;" - + "text-align: left;" - + "font-size: 12px;" - + "}" - - + "#vts-stats-panel-info table td {" - + "vertical-align: top;" - + "}" - - + "#vts-stats-panel-pos {" - + "width: 100%;" - + "}" + '#vts-stats-panel {' + + 'font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;' + + 'display: none;' + + 'padding:15px;' + + 'width: 305px;' + + '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-stats-panel-info {' + + 'margin-top: 5px;' + + 'margin-bottom: 3px;' + + 'overflow: hidden;' + + '}' + + + '#vts-stats-panel-info table {' + + 'color:#000000;' + + 'text-align: left;' + + 'font-size: 12px;' + + '}' + + + '#vts-stats-panel-info table td {' + + 'vertical-align: top;' + + '}' + + + '#vts-stats-panel-pos {' + + 'width: 100%;' + + '}' ); - this.element = document.createElement("div"); - this.element.id = "vts-stats-panel"; + this.element = document.createElement('div'); + this.element.id = 'vts-stats-panel'; this.element.innerHTML = 'Render statistics    v' + getCoreVersion() + ''+ '

'+ ''; this.core.element.appendChild(this.element); - this.infoElement = document.getElementById("vts-stats-panel-info"); - this.posElement = document.getElementById("vts-stats-panel-pos"); + this.infoElement = document.getElementById('vts-stats-panel-info'); + this.posElement = document.getElementById('vts-stats-panel-pos'); - 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.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.panelVisible = false; }; InspectorStats.prototype.showPanel = function() { - this.element.style.display = "block"; + this.element.style.display = 'block'; this.panelVisible = true; }; InspectorStats.prototype.hidePanel = function() { - this.element.style.display = "none"; + this.element.style.display = 'none'; this.panelVisible = false; }; @@ -99,43 +99,43 @@ InspectorStats.prototype.updateStatsPanel = function(stats) { var inspector = this.inspector; var text2 = - "FPS: " + Math.round(stats.fps) + "
" + - "Render time: " + Math.round(stats.renderTime*1000) + "
" + - " - resources: " + Math.round(stats.gpuRenderUsed/(1024*1024)) + "MB
" + + 'FPS: ' + Math.round(stats.fps) + '
' + + 'Render time: ' + Math.round(stats.renderTime*1000) + '
' + + ' - resources: ' + Math.round(stats.gpuRenderUsed/(1024*1024)) + 'MB
' + //" - resources: " + (stats.gpuRenderUsed) + " --- " + (stats.gpuRenderUsed / stats.drawnTiles) + "
" + - "GPU Cache: " + Math.round(stats.gpuUsed/(1024*1024)) + "MB
" + - " - textures: " + Math.round(stats.gpuTextures/(1024*1024)) + "MB
" + - " - meshes: " + Math.round(stats.gpuMeshes/(1024*1024)) + "MB
" + - " - geodata: " + Math.round(stats.gpuGeodata/(1024*1024)) + "MB
" + - "CPU Cache: " + Math.round(stats.resourcesUsed/(1024*1024)) + "MB
" + - "Metaile Cache: " + Math.round(stats.metaUsed/(1024*1024)) + "MB
" + + 'GPU Cache: ' + Math.round(stats.gpuUsed/(1024*1024)) + 'MB
' + + ' - textures: ' + Math.round(stats.gpuTextures/(1024*1024)) + 'MB
' + + ' - meshes: ' + Math.round(stats.gpuMeshes/(1024*1024)) + 'MB
' + + ' - geodata: ' + Math.round(stats.gpuGeodata/(1024*1024)) + 'MB
' + + 'CPU Cache: ' + Math.round(stats.resourcesUsed/(1024*1024)) + 'MB
' + + 'Metaile Cache: ' + Math.round(stats.metaUsed/(1024*1024)) + 'MB
' + // "FOV: " + Math.round(this.core.getOption("fov")) + " deg
" + // "viewHeight: " + Math.round(this.core.getOption("viewHeight")) + " m
" + // "distance: " + Math.round(this.core.renderer.cameraDistance) + " m
" + - "Draw calls: " + (stats.drawCalls) + "
" + - "Polygons: " + (stats.drawnFaces) + "

" + - "Terrain Height: " + (stats.heightTerrain.toFixed(2)) + "
" + - "- float: " + (stats.heightDelta.toFixed(2)) + "
" + - "- desired lod: " + (stats.heightLod.toFixed(2)) + "
" + - "- used lod: " + (stats.heightNode.toFixed(2)) + "
" + - "- used source: " + ((stats.heightClass == 2 ? "navtile" : stats.heightClass == 1 ? "node": "---") ) + "
" + - "Terrain Radar Lod: " + (inspector.radarLod) + "

" + - "Loaded/Errors: " + (stats.loadedCount) + " / " + (stats.loadErrorCount) + "
" + - "Load time: " + ((stats.loadLast - stats.loadFirst)*0.001).toFixed(2) + "s
"; - - var text3 = "Metatiles: " + (stats.processedMetatiles) +"
"+ - "Metanodes: " + (stats.processedNodes) + " / " + (stats.usedNodes) + "
"+ - "GeodataTiles: " + (stats.drawnGeodataTiles) +"

" + + 'Draw calls: ' + (stats.drawCalls) + '
' + + 'Polygons: ' + (stats.drawnFaces) + '

' + + 'Terrain Height: ' + (stats.heightTerrain.toFixed(2)) + '
' + + '- float: ' + (stats.heightDelta.toFixed(2)) + '
' + + '- desired lod: ' + (stats.heightLod.toFixed(2)) + '
' + + '- used lod: ' + (stats.heightNode.toFixed(2)) + '
' + + '- used source: ' + ((stats.heightClass == 2 ? 'navtile' : stats.heightClass == 1 ? 'node': '---') ) + '
' + + 'Terrain Radar Lod: ' + (inspector.radarLod) + '

' + + 'Loaded/Errors: ' + (stats.loadedCount) + ' / ' + (stats.loadErrorCount) + '
' + + 'Load time: ' + ((stats.loadLast - stats.loadFirst)*0.001).toFixed(2) + 's
'; + + var text3 = 'Metatiles: ' + (stats.processedMetatiles) +'
'+ + 'Metanodes: ' + (stats.processedNodes) + ' / ' + (stats.usedNodes) + '
'+ + 'GeodataTiles: ' + (stats.drawnGeodataTiles) +'

' + - "Tiles: " + (stats.drawnTiles) +"
"; + 'Tiles: ' + (stats.drawnTiles) +'
'; for (var i =0, li = stats.renderedLods.length; i < li; i++) { if (stats.renderedLods[i]) { - text3 += "LOD " + i + ": " + (stats.renderedLods[i]) +"
"; + text3 += 'LOD ' + i + ': ' + (stats.renderedLods[i]) +'
'; } } - var text = "
" + text2 + "" + text3 + "
"; + var text = '
' + text2 + '' + text3 + '
'; this.infoElement.innerHTML = text; @@ -143,13 +143,13 @@ InspectorStats.prototype.updateStatsPanel = function(stats) { if (map != null) { var p = map.getPosition(); - var s = ""; - s += p.getViewMode() + ","; + var s = ''; + s += p.getViewMode() + ','; var c = p.getCoords(); - s += c[0] + "," + c[1] + "," + p.getHeightMode() + "," + c[2].toFixed(2) + ","; + s += c[0] + ',' + c[1] + ',' + p.getHeightMode() + ',' + c[2].toFixed(2) + ','; var o = p.getOrientation(); - s += o[0].toFixed(2) + "," + o[1].toFixed(2) + "," + o[2].toFixed(2) + ","; - s += p.getViewExtent().toFixed(2) + "," + p.getFov().toFixed(2); + s += o[0].toFixed(2) + ',' + o[1].toFixed(2) + ',' + o[2].toFixed(2) + ','; + s += p.getViewExtent().toFixed(2) + ',' + p.getFov().toFixed(2); //var value = JSON.stringify(p.pos); diff --git a/src/core/inspector/stylesheets.js b/src/core/inspector/stylesheets.js index c31ecfc9..e0cbb411 100755 --- a/src/core/inspector/stylesheets.js +++ b/src/core/inspector/stylesheets.js @@ -8,49 +8,49 @@ var InspectorStylesheets = function(inspector) { InspectorStylesheets.prototype.init = function() { var inspector = this.inspector; inspector.addStyle( - "#vts-stylesheets-panel {" - + "font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;" - + "display: none;" - + "padding:15px;" - + "width: 1200px;" - + "height: 350px;" - + "font-size: 14px;" - + "position: absolute;" - + "right: 10px;" - + "bottom: 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-stylesheets-panel-header {" - + "width: 100%;" - + "height: 28px;" - + "}" - - + "#vts-stylesheets-panel-combo {" - + "width: 1115px;" - + "height: 21px;" - + "}" - - + "#vts-stylesheets-panel-button {" - + "float: right;" - + "}" - - + "#vts-stylesheets-panel-text {" - + "width: 100%;" - + "height: 300px;" - + "resize: none;" - + "white-space: nowrap;" - + "}" + '#vts-stylesheets-panel {' + + 'font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;' + + 'display: none;' + + 'padding:15px;' + + 'width: 1200px;' + + 'height: 350px;' + + 'font-size: 14px;' + + 'position: absolute;' + + 'right: 10px;' + + 'bottom: 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-stylesheets-panel-header {' + + 'width: 100%;' + + 'height: 28px;' + + '}' + + + '#vts-stylesheets-panel-combo {' + + 'width: 1115px;' + + 'height: 21px;' + + '}' + + + '#vts-stylesheets-panel-button {' + + 'float: right;' + + '}' + + + '#vts-stylesheets-panel-text {' + + 'width: 100%;' + + 'height: 300px;' + + 'resize: none;' + + 'white-space: nowrap;' + + '}' ); - this.element = document.createElement("div"); - this.element.id = "vts-stylesheets-panel"; + this.element = document.createElement('div'); + this.element.id = 'vts-stylesheets-panel'; this.element.innerHTML = '
' + '' @@ -61,17 +61,17 @@ InspectorStylesheets.prototype.init = function() { //this.inspectorElement.appendChild(this.element); this.core.element.appendChild(this.element); - this.optionsElement = document.getElementById("vts-stylesheets-panel-combo"); + this.optionsElement = document.getElementById('vts-stylesheets-panel-combo'); this.optionsElement.onchange = this.onComboSwitched.bind(this); - this.textElement = document.getElementById("vts-stylesheets-panel-text"); + this.textElement = document.getElementById('vts-stylesheets-panel-text'); - document.getElementById("vts-stylesheets-panel-button").onclick = this.onUpdate.bind(this); + document.getElementById('vts-stylesheets-panel-button').onclick = this.onUpdate.bind(this); - 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.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.panelVisible = false; }; @@ -79,13 +79,13 @@ InspectorStylesheets.prototype.init = function() { InspectorStylesheets.prototype.showPanel = function() { this.buildStylesheetsCombo(); - this.element.style.display = "block"; + this.element.style.display = 'block'; this.panelVisible = true; }; InspectorStylesheets.prototype.hidePanel = function() { - this.element.style.display = "none"; + this.element.style.display = 'none'; this.panelVisible = false; }; @@ -122,28 +122,28 @@ InspectorStylesheets.prototype.onUpdate = function() { InspectorStylesheets.prototype.niceStyleFormat = function(data) { if (!data) { - return ""; + return ''; } data = data.data; //return JSON.stringify(data, null, " "); - var tmp = ""; - tmp += "{\n"; + var tmp = ''; + tmp += '{\n'; var elements = []; - if (data["constants"]) { - elements.push("constants"); + if (data['constants']) { + elements.push('constants'); } - if (data["bitmaps"]) { - elements.push("bitmaps"); + if (data['bitmaps']) { + elements.push('bitmaps'); } - if (data["layers"]) { - elements.push("layers"); + if (data['layers']) { + elements.push('layers'); } for (var j = 0, lj = elements.length; j < lj; j++) { @@ -158,7 +158,7 @@ InspectorStylesheets.prototype.niceStyleFormat = function(data) { } for (var i = 0, li = buff.length; i < li; i++) { - if (type == "layers") { + if (type == 'layers') { var element2 = element[buff[i]]; @@ -170,19 +170,19 @@ InspectorStylesheets.prototype.niceStyleFormat = function(data) { tmp += ' "' + buff[i] + '": {\n'; for (var k = 0, lk = buff2.length; k < lk; k++) { - tmp += ' "' + buff2[k] + '": ' + JSON.stringify(element2[buff2[k]]) + (k == (lk - 1) ? "" : ",") + "\n"; + tmp += ' "' + buff2[k] + '": ' + JSON.stringify(element2[buff2[k]]) + (k == (lk - 1) ? '' : ',') + '\n'; } - tmp += " }" + (i == (li - 1) ? "" : ",\n"); + tmp += ' }' + (i == (li - 1) ? '' : ',\n'); } else { - tmp += ' "' + buff[i] + '": ' + JSON.stringify(element[buff[i]]) + (i == (li - 1) ? "" : ",") + "\n"; + tmp += ' "' + buff[i] + '": ' + JSON.stringify(element[buff[i]]) + (i == (li - 1) ? '' : ',') + '\n'; } } - tmp += "\n }" + (j == (lj - 1) ? "" : ",\n"); + tmp += '\n }' + (j == (lj - 1) ? '' : ',\n'); } - tmp += "\n}"; + tmp += '\n}'; return tmp; }; @@ -194,7 +194,7 @@ InspectorStylesheets.prototype.buildStylesheetsCombo = function() { return; } - var html = ""; + var html = ''; var styles = map.getStylesheets(); diff --git a/src/core/map/bound-layer.js b/src/core/map/bound-layer.js index 587e4816..10d7a7b3 100755 --- a/src/core/map/bound-layer.js +++ b/src/core/map/bound-layer.js @@ -25,18 +25,18 @@ var MapBoundLayer = function(map, json, id) { this.ready = false; //hack - if (id == "esri-world-imagery") { - json["availability"] = { + if (id == 'esri-world-imagery') { + json['availability'] = { // "type" : "negative-type", // "mime": "image/png" // "type" : "negative-code", // "codes": [301, 302, 404] - "type" : "negative-size", - "size": 2521 - }; + 'type' : 'negative-size', + 'size': 2521 + }; } - if (typeof json === "string") { + if (typeof json === 'string') { this.jsonUrl = this.map.url.processUrl(json); this.baseUrl = utilsUrl_.getBase(this.jsonUrl); this.baseUrlSchema = utilsUrl_.getSchema(this.jsonUrl); @@ -61,61 +61,61 @@ var MapBoundLayer = function(map, json, id) { MapBoundLayer.prototype.parseJson = function(json) { - this.numberId = json["id"] || null; - this.type = json["type"] || "raster"; - this.url = this.processUrl(json["url"], ""); - this.tileSize = json["tileSize"] || [256,256]; - this.lodRange = json["lodRange"] || [0,0]; - this.tileRange = json["tileRange"] || [[0,0],[0,0]]; - this.metaUrl = this.processUrl(json["metaUrl"]); - this.maskUrl = this.processUrl(json["maskUrl"]); - this.isTransparent = json["isTransparent"] || false; - this.credits = json["credits"] || []; + this.numberId = json['id'] || null; + this.type = json['type'] || 'raster'; + this.url = this.processUrl(json['url'], ''); + this.tileSize = json['tileSize'] || [256,256]; + this.lodRange = json['lodRange'] || [0,0]; + this.tileRange = json['tileRange'] || [[0,0],[0,0]]; + this.metaUrl = this.processUrl(json['metaUrl']); + this.maskUrl = this.processUrl(json['maskUrl']); + this.isTransparent = json['isTransparent'] || false; + this.credits = json['credits'] || []; this.creditsUrl = null; this.specificity = Math.pow(2,this.lodRange[0]) / ((this.tileRange[1][0] - this.tileRange[1][0]+1)*(this.tileRange[1][1] - this.tileRange[1][1]+1)); - this.availability = json["availability"] ? {} : null; + this.availability = json['availability'] ? {} : null; if (this.availability) { - var p = json["availability"]; - this.availability.type = p["type"]; - this.availability.mime = p["mime"]; - this.availability.codes = p["codes"]; - this.availability.size = p["size"]; + var p = json['availability']; + this.availability.type = p['type']; + this.availability.mime = p['mime']; + this.availability.codes = p['codes']; + this.availability.size = p['size']; //this.availability.coverageUrl = p["coverageUrl"]; } if (this.metaUrl && this.maskUrl) { this.availability = { - type : "metatile" + type : 'metatile' }; } switch(typeof this.credits) { - case "string": - this.creditsUrl = this.credits; - this.credits = []; - break; + case 'string': + this.creditsUrl = this.credits; + this.credits = []; + break; - case "object": + case 'object': - if (!Array.isArray(this.credits)) { - var credits = this.credits; - this.credits = []; + if (!Array.isArray(this.credits)) { + var credits = this.credits; + this.credits = []; - for (var key in credits){ - this.map.addCredit(key, new MapCredit(this.map, credits[key])); - this.credits.push(key); - } + for (var key in credits){ + this.map.addCredit(key, new MapCredit(this.map, credits[key])); + this.credits.push(key); } + } - for (var i = 0, li = this.credits.length; i < li; i++) { - var credit = this.map.getCreditById(this.credits[i]); + 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; + break; } }; @@ -135,15 +135,15 @@ MapBoundLayer.prototype.getOptions = function() { MapBoundLayer.prototype.getInfo = function() { return { - "type" : this.type, - "url" : this.url, - "tileSize" : this.tileSize, - "credits" : this.credits, - "lodRange" : this.lodRange, - "tileRange" : this.tileRange, - "mataUrl" : this.metaUrl, - "maskUrl" : this.maskUrl, - "isTransparent" : this.isTransparent + 'type' : this.type, + 'url' : this.url, + 'tileSize' : this.tileSize, + 'credits' : this.credits, + 'lodRange' : this.lodRange, + 'tileRange' : this.tileRange, + 'mataUrl' : this.metaUrl, + 'maskUrl' : this.maskUrl, + 'isTransparent' : this.isTransparent }; }; @@ -155,11 +155,11 @@ MapBoundLayer.prototype.processUrl = function(url, fallback) { url = url.trim(); - if (url.indexOf("://") != -1) { //absolute + if (url.indexOf('://') != -1) { //absolute return url; - } else if (url.indexOf("//") == 0) { //absolute without schema + } else if (url.indexOf('//') == 0) { //absolute without schema return this.baseUrlSchema + url; - } else if (url.indexOf("/") == 0) { //absolute without host + } else if (url.indexOf('/') == 0) { //absolute without host return this.baseUrlOrigin + url; } else { //relative return this.baseUrl + url; diff --git a/src/core/map/camera.js b/src/core/map/camera.js index 8befa451..436b1014 100755 --- a/src/core/map/camera.js +++ b/src/core/map/camera.js @@ -22,7 +22,7 @@ var MapCamera = function(map) { MapCamera.prototype.update = function() { - var controlMode = "observer"; + var controlMode = 'observer'; var map = this.map; var position = [0,0,0]; var orientation = map.position.getOrientation(); @@ -42,7 +42,7 @@ MapCamera.prototype.update = function() { //console.log("terrain height:" + surfaceHeight[0] + " pos height:" + map.position.getHeight()); - if (map.position.getHeightMode() == "float") { + if (map.position.getHeightMode() == 'float') { height += surfaceHeight[0]; } @@ -73,11 +73,11 @@ MapCamera.prototype.update = function() { //convert nav coords to physical var coords = map.position.getCoords(); - var worldPos = map.convert.convertCoords([coords[0], coords[1], height], "navigation", "physical"); + var worldPos = map.convert.convertCoords([coords[0], coords[1], height], 'navigation', 'physical'); this.center = [worldPos[0], worldPos[1], worldPos[2]]; - worldPos[0] += camInfo.orbitCoords[0]; - worldPos[1] += camInfo.orbitCoords[1]; - worldPos[2] += camInfo.orbitCoords[2]; + worldPos[0] += camInfo.orbitCoords[0]; + worldPos[1] += camInfo.orbitCoords[1]; + worldPos[2] += camInfo.orbitCoords[2]; this.camera.setPosition([0,0,0]); //always zeros this.position = worldPos; diff --git a/src/core/map/config.js b/src/core/map/config.js index ae59921b..1390c4ac 100755 --- a/src/core/map/config.js +++ b/src/core/map/config.js @@ -45,8 +45,8 @@ MapConfig.prototype.parseConfig = function() { MapConfig.prototype.afterConfigParsed = function() { - if (this.mapConfig["position"] != null) { - this.map.setPosition(this.mapConfig["position"], false); + if (this.mapConfig['position'] != null) { + this.map.setPosition(this.mapConfig['position'], false); } this.map.setView(this.map.initialView); @@ -54,7 +54,7 @@ MapConfig.prototype.afterConfigParsed = function() { MapConfig.prototype.parseSrses = function() { - var srses = this.mapConfig["srses"]; + var srses = this.mapConfig['srses']; this.map.srses = {}; if (srses == null) { @@ -70,7 +70,7 @@ MapConfig.prototype.parseSrses = function() { MapConfig.prototype.parseReferenceFrame = function() { - var rf = this.mapConfig["referenceFrame"]; + var rf = this.mapConfig['referenceFrame']; if (rf == null) { return false; @@ -87,7 +87,7 @@ MapConfig.prototype.parseReferenceFrame = function() { MapConfig.prototype.parseCredits = function() { - var credits = this.mapConfig["credits"]; + var credits = this.mapConfig['credits']; this.map.credits = {}; if (credits == null) { @@ -103,7 +103,7 @@ MapConfig.prototype.parseCredits = function() { MapConfig.prototype.parseSurfaces = function() { - var surfaces = this.mapConfig["surfaces"]; + var surfaces = this.mapConfig['surfaces']; this.map.surfaces = []; if (surfaces == null) { @@ -120,7 +120,7 @@ MapConfig.prototype.parseSurfaces = function() { MapConfig.prototype.parseVirtualSurfaces = function() { - var surfaces = this.mapConfig["virtualSurfaces"]; + var surfaces = this.mapConfig['virtualSurfaces']; this.map.virtualSurfaces = []; if (!this.map.config.mapVirtualSurfaces) { @@ -141,7 +141,7 @@ MapConfig.prototype.parseVirtualSurfaces = function() { MapConfig.prototype.parseViews = function() { - var views = this.mapConfig["namedViews"]; + var views = this.mapConfig['namedViews']; this.map.namedViews = []; if (views != null) { @@ -150,7 +150,7 @@ MapConfig.prototype.parseViews = function() { } } - var view = this.mapConfig["view"]; + var view = this.mapConfig['view']; if (view == null) { return true; } @@ -161,7 +161,7 @@ MapConfig.prototype.parseViews = function() { MapConfig.prototype.parseGlues = function() { - var glues = this.mapConfig["glue"]; + var glues = this.mapConfig['glue']; this.map.glues = []; if (glues == null) { @@ -169,8 +169,8 @@ MapConfig.prototype.parseGlues = function() { } for (var i = 0, li = glues.length; i < li; i++) { - var surface = new MapSurface(this.map, glues[i], "glue"); - this.map.addGlue(surface.id.join(";"), surface); + var surface = new MapSurface(this.map, glues[i], 'glue'); + this.map.addGlue(surface.id.join(';'), surface); } return true; @@ -178,7 +178,7 @@ MapConfig.prototype.parseGlues = function() { MapConfig.prototype.parseBoundLayers = function() { - var layers = this.mapConfig["boundLayers"]; + var layers = this.mapConfig['boundLayers']; this.map.boundLayers = []; if (layers == null) { @@ -195,7 +195,7 @@ MapConfig.prototype.parseBoundLayers = function() { MapConfig.prototype.parseFreeLayers = function() { - var layers = this.mapConfig["freeLayers"]; + var layers = this.mapConfig['freeLayers']; this.map.freeLayers = []; if (layers == null) { @@ -203,7 +203,7 @@ MapConfig.prototype.parseFreeLayers = function() { } for (var key in layers) { - var layer = new MapSurface(this.map, layers[key], "free"); + var layer = new MapSurface(this.map, layers[key], 'free'); this.map.addFreeLayer(key, layer); } @@ -212,7 +212,7 @@ MapConfig.prototype.parseFreeLayers = function() { MapConfig.prototype.parseStylesheets = function() { - var styles = this.mapConfig["stylesheets"]; + var styles = this.mapConfig['stylesheets']; this.map.stylesheets = []; if (styles == null) { @@ -234,7 +234,7 @@ MapConfig.prototype.parseParams = function() { MapConfig.prototype.parseBrowserOptions = function() { - var options = this.mapConfig["browserOptions"]; + var options = this.mapConfig['browserOptions']; this.map.browserOptions = {}; if (options == null) { diff --git a/src/core/map/convert.js b/src/core/map/convert.js index 169e2efc..340f2aee 100755 --- a/src/core/map/convert.js +++ b/src/core/map/convert.js @@ -15,7 +15,7 @@ var MapConvert = function(map) { this.map = map; this.config = map.config; this.measure = map.measure; - this.isProjected = this.map.getNavigationSrs().isProjected() + this.isProjected = this.map.getNavigationSrs().isProjected(); }; @@ -34,12 +34,12 @@ MapConvert.prototype.movePositionCoordsTo = function(position, azimuth, distance var forward = [-Math.sin(yaw), Math.cos(yaw)]; position.setCoords2([coords[0] + (forward[0]*distance), - coords[1] + (forward[1]*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); + var geod = new GeographicLib.Geodesic.Geodesic(navigationSrsInfo['a'], + (navigationSrsInfo['a'] / navigationSrsInfo['b']) - 1.0); var r = geod.Direct(coords[1], coords[0], azimuth, distance); position.setCoords2([r.lon2, r.lat2]); @@ -52,7 +52,7 @@ MapConvert.prototype.movePositionCoordsTo = function(position, azimuth, distance //orientation[0] -= (r.azi1 - r.azi2); //if (!skipOrientation) { - position.setOrientation(orientation); + position.setOrientation(orientation); //} //console.log("azimuthCorrection: " + azimuthCorrectionFactor); @@ -69,10 +69,10 @@ MapConvert.prototype.convertPositionViewMode = function(position, mode) { return position; } - if (mode == "obj") { - if (position.getHeightMode() == "float") { + if (mode == 'obj') { + if (position.getHeightMode() == 'float') { var covertToFloat = true; - this.convertPositionHeightMode(position, "fix", true); + this.convertPositionHeightMode(position, 'fix', true); } var distance = position.getViewDistance(); @@ -103,10 +103,10 @@ MapConvert.prototype.convertPositionViewMode = function(position, mode) { position.setCoords(coords); if (covertToFloat) { - this.convertPositionHeightMode(position, "float", true); + this.convertPositionHeightMode(position, 'float', true); } - } else if (mode == "subj") { + } else if (mode == 'subj') { var coords = this.getPositionCameraCoords(position, position.getHeightMode()); position.setCoords(coords); @@ -132,10 +132,10 @@ MapConvert.prototype.convertPositionHeightMode = function(position, mode, noPrec } //set new height - if (mode == "float") { + if (mode == 'float') { position.pos[3] = mode; position.pos[4] = position.pos[4] - height[0]; - } else if (mode == "fix") { + } else if (mode == 'fix') { position.pos[3] = mode; position.pos[4] = position.pos[4] + height[0]; } @@ -149,13 +149,13 @@ 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); - if (position.getViewMode() == "obj") { + if (position.getViewMode() == 'obj') { var coords = position.getCoords(); var terrainHeight = 0; var lod = -1; //convert height to fix - if (position.getHeightMode() == "float") { + if (position.getHeightMode() == 'float') { lod = this.measure.getOptimalHeightLod(coords, position.getViewExtent(), this.config.mapNavSamplesPerViewExtent); var surfaceHeight = this.measure.getSurfaceHeight(coords, lod); terrainHeight = surfaceHeight[0]; @@ -172,15 +172,15 @@ MapConvert.prototype.getPositionCameraCoords = function(position, heightMode) { coords[1] += camInfo.orbitCoords[1]; coords[2] += camInfo.orbitCoords[2] + terrainHeight; } else { - var worldPos = this.convertCoords([coords[0], coords[1], coords[2] + terrainHeight], "navigation", "physical"); + var worldPos = this.convertCoords([coords[0], coords[1], coords[2] + terrainHeight], 'navigation', 'physical'); worldPos[0] += camInfo.orbitCoords[0]; worldPos[1] += camInfo.orbitCoords[1]; worldPos[2] += camInfo.orbitCoords[2];// + terrainHeight; - coords = this.convertCoords(worldPos, "physical", "navigation"); + coords = this.convertCoords(worldPos, 'physical', 'navigation'); } - if (heightMode == "fix") { + if (heightMode == 'fix') { return coords; } else { //get float height for new coords @@ -205,7 +205,7 @@ MapConvert.prototype.getPositionCameraCoords = function(position, heightMode) { var coords = position.getCoords(); - if (heightMode == "fix") { + if (heightMode == 'fix') { coords[2] += surfaceHeight[0]; } else { coords[2] -= surfaceHeight[0]; @@ -220,26 +220,26 @@ MapConvert.prototype.getPositionCameraCoords = function(position, heightMode) { MapConvert.prototype.getPositionPhysCoords = function(position, lod) { var coords = position.getCoords(); - if (position.getHeightMode() == "float") { + if (position.getHeightMode() == 'float') { lod = (lod != null) ? lod : this.measure.getOptimalHeightLod(position.getCoords(), position.getViewExtent(), this.config.mapNavSamplesPerViewExtent); var surfaceHeight = this.measure.getSurfaceHeight(position.getCoords(), lod); coords[2] += surfaceHeight[0]; } - return this.convertCoords(coords, "navigation", "physical"); + return this.convertCoords(coords, 'navigation', 'physical'); }; MapConvert.prototype.getPositionCameraSpaceCoords = function(position, lod) { var coords = position.getCoords(); - if (position.getHeightMode() == "float") { + if (position.getHeightMode() == 'float') { lod = (lod != null) ? lod : this.measure.getOptimalHeightLod(position.getCoords(), position.getViewExtent(), this.config.mapNavSamplesPerViewExtent); var surfaceHeight = this.measure.getSurfaceHeight(position.getCoords(), lod); coords[2] += surfaceHeight[0]; } - var worldPos = this.convertCoords(coords, "navigation", "physical"); + var worldPos = this.convertCoords(coords, 'navigation', 'physical'); var camPos = this.map.camera.position; worldPos[0] -= camPos[0]; worldPos[1] -= camPos[1]; @@ -254,8 +254,8 @@ MapConvert.prototype.getPositionCanvasCoords = function(position, lod, physical) var camPos = this.map.camera.position; var coords = position.getCoords(); var worldPos = [coords[0] - camPos[0], - coords[1] - camPos[1], - coords[2] - camPos[2]]; + coords[1] - camPos[1], + coords[2] - camPos[2]]; } else { var worldPos = this.getPositionCameraSpaceCoords(position, lod); } diff --git a/src/core/map/credit.js b/src/core/map/credit.js index 7db5564c..a0d3046c 100755 --- a/src/core/map/credit.js +++ b/src/core/map/credit.js @@ -6,10 +6,10 @@ var utils = utils_; var MapCredit = function(map, json) { this.map = map; - this.id = json["id"] || null; - this.notice = json["notice"] || null; - this.copyrighted = json["copyrighted"] || true; - this.url = json["url"] || null; + this.id = json['id'] || null; + this.notice = json['notice'] || null; + this.copyrighted = json['copyrighted'] || true; + this.url = json['url'] || null; this.html = utils.simpleWikiLinks(this.notice); this.plain = utils.simpleWikiLinks(this.notice); }; @@ -17,12 +17,12 @@ var MapCredit = function(map, json) { MapCredit.prototype.getInfo = function() { return { - "id" : this.id, - "notice" : this.notice, + 'id' : this.id, + 'notice' : this.notice, //"copyrighted" : this.copyrighted, //"url" : this.url - "html" : this.html, - "plain" : this.plain + 'html' : this.html, + 'plain' : this.plain }; }; diff --git a/src/core/map/draw-tiles.js b/src/core/map/draw-tiles.js index 134c9ee0..0de26f9e 100755 --- a/src/core/map/draw-tiles.js +++ b/src/core/map/draw-tiles.js @@ -8,7 +8,7 @@ var MapGeodataView = MapGeodataView_; var MapDrawTiles = function(map, draw) { this.map = map; this.config = map.config; - this.isProjected = this.map.getNavigationSrs().isProjected() + this.isProjected = this.map.getNavigationSrs().isProjected(); this.stats = map.stats; this.draw = draw; this.debug = draw.debug; @@ -226,16 +226,16 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, } tile.drawCommands[0].push({ - type : "submesh", + type : 'submesh', mesh : tile.surfaceMesh, submesh : i, texture : tile.surfaceTextures[i], - material : "internal-nofog" + material : 'internal-nofog' }); } tile.drawCommands[0].push({ - type : "state", + type : 'state', state : draw.drawBlendedTileState }); @@ -258,26 +258,26 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, } tile.drawCommands[0].push({ - type : "submesh", + type : 'submesh', mesh : tile.surfaceMesh, submesh : i, texture : texture, - material : "external-nofog", + material : 'external-nofog', alpha : bounds.alpha[layers[j]][1] }); } } tile.drawCommands[0].push({ - type : "submesh", + type : 'submesh', mesh : tile.surfaceMesh, submesh : i, texture : null, - material : "fog" + material : 'fog' }); tile.drawCommands[0].push({ - type : "state", + type : 'state', state : draw.drawTileState }); } else { @@ -299,11 +299,11 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, } tile.drawCommands[0].push({ - type : "submesh", + type : 'submesh', mesh : tile.surfaceMesh, submesh : i, texture : texture, - material : "external" + material : 'external' }); } } @@ -333,11 +333,11 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, //draw mesh tile.drawCommands[0].push({ - type : "submesh", + type : 'submesh', mesh : tile.surfaceMesh, submesh : i, texture : texture, - material : "external" + material : 'external' }); } } @@ -352,19 +352,19 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, //draw mesh tile.drawCommands[0].push({ - type : "submesh", + type : 'submesh', mesh : tile.surfaceMesh, submesh : i, texture : tile.surfaceTextures[i], - material : "internal" + material : 'internal' }); } else { tile.drawCommands[0].push({ - type : "submesh", + type : 'submesh', mesh : tile.surfaceMesh, submesh : i, texture : null, - material : "flat" + material : 'flat' }); } @@ -377,13 +377,13 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, var path = tile.resourceSurface.getTextureUrl(tile.id, i); tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true); } //else { - tile.drawCommands[0].push({ - type : "submesh", - mesh : tile.surfaceMesh, - submesh : i, - texture : tile.surfaceTextures[i], - material : "internal" - }); + tile.drawCommands[0].push({ + type : 'submesh', + mesh : tile.surfaceMesh, + submesh : i, + texture : tile.surfaceTextures[i], + material : 'internal' + }); //} } } @@ -394,22 +394,22 @@ MapDrawTiles.prototype.drawMeshTile = function(tile, node, cameraPos, pixelSize, var path = tile.resourceSurface.getTextureUrl(tile.id, i); tile.surfaceTextures[i] = tile.resources.getTexture(path, null, null, null, tile, true); } //else { - tile.drawCommands[0].push({ - type : "submesh", - mesh : tile.surfaceMesh, - submesh : i, - texture : tile.surfaceTextures[i], - material : "internal" - }); + tile.drawCommands[0].push({ + type : 'submesh', + mesh : tile.surfaceMesh, + submesh : i, + texture : tile.surfaceTextures[i], + material : 'internal' + }); //} } //depth path tile.drawCommands[1].push({ - type : "submesh", + type : 'submesh', mesh : tile.surfaceMesh, submesh : i, - material : "depth" + material : 'depth' }); } @@ -468,15 +468,15 @@ MapDrawTiles.prototype.drawGeodataTile = function(tile, node, cameraPos, pixelSi var navtile = this.tree.findNavTile(tile.id); if (navtile && navtile.surface) { - var navtileStr = navtile.surface.getNavUrl(navtile.id) + ";" - + navtile.id[0] + "-" + navtile.id[1] + "-" + navtile.id[2] + ";" - + navtile.metanode.minHeight + ";" + navtile.metanode.maxHeight; + var navtileStr = navtile.surface.getNavUrl(navtile.id) + ';' + + navtile.id[0] + '-' + navtile.id[1] + '-' + navtile.id[2] + ';' + + navtile.metanode.minHeight + ';' + navtile.metanode.maxHeight; path = tile.surface.getGeodataUrl(tile.id, encodeURIComponent(navtileStr)); } } if (!path) { - path = tile.resourceSurface.getGeodataUrl(tile.id, ""); + path = tile.resourceSurface.getGeodataUrl(tile.id, ''); } tile.surfaceGeodata = tile.resources.getGeodata(path, {tile:tile, surface:tile.surface}); @@ -540,10 +540,10 @@ MapDrawTiles.prototype.drawGeodataTile = function(tile, node, cameraPos, pixelSi } //if (tile.drawCommands[channel].length == 0) { - tile.drawCommands[channel][0] = { - type : "geodata", - geodataView : tile.surfaceGeodataView - }; + tile.drawCommands[channel][0] = { + type : 'geodata', + geodataView : tile.surfaceGeodataView + }; //} return tile.surfaceGeodataView.isReady(); } @@ -768,7 +768,7 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe //if (this.drawCredits) { // node.drawBBox2(cameraPos); //} else { - node.drawBBox(cameraPos); + node.drawBBox(cameraPos); //} } @@ -778,9 +778,9 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe var max = node.bbox.max; var 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]], + [(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()); pos[2] = pos[2] * 0.9992; @@ -792,9 +792,9 @@ 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( - [(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]], + [(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()); /* @@ -810,13 +810,13 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe //draw lods if (debug.drawLods) { - text = "" + tile.id[0]; + text = '' + tile.id[0]; this.drawText(Math.round(pos[0]-this.getTextSize(4*factor, text)*0.5), Math.round(pos[1]-4*factor), 4*factor, text, [1,0,0,1], pos[2]); } //draw indices if (debug.drawIndices) { - var text = "" + tile.id[1] + " " + tile.id[2]; + var 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]); } @@ -826,33 +826,33 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe //var 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]); - 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 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; 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]); + 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]); 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"); + var 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; + var 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); if (node.alien) { - text = "[A]" + text; + text = '[A]' + text; } 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]); } @@ -864,7 +864,7 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe for (var i = 0, li = surface.id.length; i < li; i++) { if (tile.boundsDebug[surface.id[i]]) { - var text = "< " + surface.id[i] + " >"; + var 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 + " >"; + var 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,38 +882,38 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe } if (debug.drawCredits) { - var text = "{ "; + var text = '{ '; for (var key in tile.imageryCredits) { if (tile.imageryCredits[key]) { - text += key + ":" + tile.imageryCredits[key] + ", "; + text += key + ':' + tile.imageryCredits[key] + ', '; } } for (var key in tile.glueImageryCredits) { if (!tile.imageryCredits[key]) { - text += key + ":" + tile.glueImageryCredits[key] + ", "; + text += key + ':' + tile.glueImageryCredits[key] + ', '; //text += key + ", "; } } - text += "}"; + text += '}'; 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]); } //draw distance if (debug.drawDistance) { - var text = "" + tile.distance.toFixed(2) + " " + tile.texelSize.toFixed(3) + " " + node.pixelSize.toFixed(3); - text += "--" + tile.texelSize2.toFixed(3); + var 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]); } //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 += "-" + node.minHeight + "/" + node.maxHeight+ "-" + Math.floor(node.minZ) + "/" + Math.floor(node.maxZ)+ "-" + Math.floor(node.surrogatez); + 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 += '-' + 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]); } @@ -926,7 +926,7 @@ MapDrawTiles.prototype.drawTileInfo = function(tile, node, cameraPos, mesh, pixe var texture = tile.surfaceTextures[i]; if (texture && texture.gpuTexture) { - var text = "[" + i + "]: " + texture.gpuTexture.width + " x " + texture.gpuTexture.height; + var 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 6e9f2159..ed9fb0a8 100755 --- a/src/core/map/draw.js +++ b/src/core/map/draw.js @@ -16,7 +16,7 @@ var MapGeodata = MapGeodata_; var MapDraw = function(map) { this.map = map; this.config = map.config; - this.isProjected = map.getNavigationSrs().isProjected() + this.isProjected = map.getNavigationSrs().isProjected(); this.isGeocent = map.isGeocent; this.renderer = map.renderer; @@ -50,7 +50,7 @@ var MapDraw = function(map) { drawFog : this.config.mapFog, debugTextSize : 2.0, ignoreTexelSize : false - } + }; this.fogDensity = 0; this.zFactor = 0; @@ -65,9 +65,9 @@ var MapDraw = function(map) { this.drawCounter = 0; this.drawChannel = 0; - this.drawChannelNames = ["base", "hit"]; + this.drawChannelNames = ['base', 'hit']; - this.planetRadius = this.isGeocent ? map.getNavigationSrs().getSrsInfo()["a"] : 100; + this.planetRadius = this.isGeocent ? map.getNavigationSrs().getSrsInfo()['a'] : 100; this.tileBuffer = new Array(500); this.processBuffer = new Array(60000); this.processBuffer2 = new Array(60000); @@ -132,9 +132,9 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { gpu.setViewport(); map.visibleCredits = { - imagery : {}, - glueImagery : {}, - mapdata : {} + imagery : {}, + glueImagery : {}, + mapdata : {} }; } @@ -356,7 +356,7 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { if (layer.ready && layer.tree && (!layer.geodata || (layer.stylesheet && layer.stylesheet.isReady())) && this.drawChannel == 0) { - if (layer.type == "geodata") { + if (layer.type == 'geodata') { this.drawMonoliticGeodata(layer); } else { layer.tree.draw(camInfo); @@ -422,18 +422,18 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { } //draw skydome before geodata - if (!projected && debug.drawFog && map.referenceFrame.id == "melown2015") { + if (!projected && debug.drawFog && map.referenceFrame.id == 'melown2015') { //var camInfo = this.measure.getPositionCameraInfo(this.position, true); var navigationSrsInfo = map.getNavigationSrs().getSrsInfo(); - var earthRadius = navigationSrsInfo["a"]; + var earthRadius = navigationSrsInfo['a']; var atmoSize = 50000; 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 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(); @@ -515,20 +515,20 @@ MapDraw.prototype.drawMap = function(skipFreeLayers) { MapDraw.prototype.drawHitmap = function() { this.drawChannel = 1; - this.renderer.switchToFramebuffer("depth"); + this.renderer.switchToFramebuffer('depth'); this.map.renderSlots.processRenderSlots(); - this.renderer.switchToFramebuffer("base"); + this.renderer.switchToFramebuffer('base'); this.drawChannel = 0; }; MapDraw.prototype.drawGeodataHitmap = function() { this.renderer.gpu.setState(this.drawTileState); - this.renderer.switchToFramebuffer("geo"); + this.renderer.switchToFramebuffer('geo'); //this.renderer.onlyHitLayers = true; this.renderer.draw.drawGpuJobs(); //this.renderer.onlyHitLayers = false; - this.renderer.switchToFramebuffer("base"); + this.renderer.switchToFramebuffer('base'); this.geoHitMapDirty = false; }; @@ -541,29 +541,29 @@ MapDraw.prototype.areDrawCommandsReady = function(commands, priority, doNotLoad, var command = commands[i]; switch (command.type) { - case "submesh": + case 'submesh': - var mesh = command.mesh; - var texture = command.texture; + var mesh = command.mesh; + var texture = command.texture; - var meshReady = (mesh && mesh.isReady(doNotLoad, priority, checkGpu)); - var textureReady = (!texture || (texture && texture.isReady(doNotLoad, priority, checkGpu))); + var meshReady = (mesh && mesh.isReady(doNotLoad, priority, checkGpu)); + var textureReady = (!texture || (texture && texture.isReady(doNotLoad, priority, checkGpu))); - if (!(meshReady && textureReady) ) { - ready = false; - } + if (!(meshReady && textureReady) ) { + ready = false; + } - break; + break; - case "geodata": + case 'geodata': - var geodataView = command.geodataView; + var geodataView = command.geodataView; - if (!(geodataView && geodataView.isReady(doNotLoad, priority, checkGpu))) { - ready = false; - } + if (!(geodataView && geodataView.isReady(doNotLoad, priority, checkGpu))) { + ready = false; + } - break; + break; } } @@ -582,55 +582,55 @@ MapDraw.prototype.processDrawCommands = function(cameraPos, commands, priority, var command = commands[i]; switch (command.type) { - case "state": - this.renderer.gpu.setState(command.state); - break; + case 'state': + this.renderer.gpu.setState(command.state); + break; - case "submesh": + case 'submesh': //this.renderer.gpu.setState(this.drawBlendedTileState); - var mesh = command.mesh; - var texture = command.texture; + var mesh = command.mesh; + var texture = command.texture; - var meshReady = (mesh && mesh.isReady(doNotLoad, priority)); - var textureReady = (!texture || (texture && texture.isReady(doNotLoad, priority))); + var meshReady = (mesh && mesh.isReady(doNotLoad, priority)); + var textureReady = (!texture || (texture && texture.isReady(doNotLoad, priority))); - if (meshReady && textureReady) { + if (meshReady && textureReady) { //debug bbox - if (this.debug.drawBBoxes && this.debug.drawMeshBBox) { - mesh.submeshes[command.submesh].drawBBox(cameraPos); - } + if (this.debug.drawBBoxes && this.debug.drawMeshBBox) { + mesh.submeshes[command.submesh].drawBBox(cameraPos); + } - if (!texture) { - var material = command.material; - switch (material) { + if (!texture) { + var material = command.material; + switch (material) { //case "fog": - case "external": - case "internal": - material = "flat"; - break; - } - mesh.drawSubmesh(cameraPos, command.submesh, texture, material, command.alpha); - } else { - mesh.drawSubmesh(cameraPos, command.submesh, texture, command.material, command.alpha); + case 'external': + case 'internal': + material = 'flat'; + break; } - + mesh.drawSubmesh(cameraPos, command.submesh, texture, material, command.alpha); } else { - i = i; - //this should not happen + mesh.drawSubmesh(cameraPos, command.submesh, texture, command.material, command.alpha); } + + } else { + i = i; + //this should not happen + } - break; + break; - case "geodata": + case 'geodata': - var geodataView = command.geodataView; + var geodataView = command.geodataView; - if (geodataView && geodataView.isReady(doNotLoad, priority, true)) { - geodataView.draw(cameraPos); - } + if (geodataView && geodataView.isReady(doNotLoad, priority, true)) { + geodataView.draw(cameraPos); + } - break; + break; } } }; @@ -646,7 +646,7 @@ MapDraw.prototype.drawMonoliticGeodata = function(surface) { } if (surface.monoGeodata == null) { - if (typeof surface.geodataUrl === "object") { + if (typeof surface.geodataUrl === 'object') { var path = surface.geodataUrl; } else { var path = surface.getMonoGeodataUrl(surface.id); diff --git a/src/core/map/geodata-processor/processor.js b/src/core/map/geodata-processor/processor.js index 4db91cf1..f83ff046 100755 --- a/src/core/map/geodata-processor/processor.js +++ b/src/core/map/geodata-processor/processor.js @@ -6,14 +6,14 @@ var MapGeodataProcessor = function(surface, listener) { this.listener = listener; this.ready = true; - var worker = require("worker-loader?inline&fallback=false!./worker-main"); + var worker = require('worker-loader?inline&fallback=false!./worker-main'); // var worker = require("worker-loader?inline!./worker-main"); //debug worker this.processWorker = new worker; this.processWorker.onerror = function(event){ - throw new Error(event.message + " (" + event.filename + ":" + event.lineno + ")"); + throw new Error(event.message + ' (' + event.filename + ':' + event.lineno + ')'); }; this.processWorker.onmessage = this.onMessage.bind(this); @@ -45,12 +45,12 @@ MapGeodataProcessor.prototype.onMessage = function(message) { message = message.data; - var command = message["command"]; + var command = message['command']; //console.log("onmessage"); //if (typeof message === "string" && message == "ready") { - if (command == "ready") { + if (command == 'ready') { this.ready = true; //console.log("ready"); } @@ -73,10 +73,10 @@ MapGeodataProcessor.prototype.sendCommand = function(command, data, tile) { this.ready = false; - var message = {"command": command, "data":data}; + var message = {'command': command, 'data':data}; if (tile && tile.id) { - message["lod"] = tile.id[0]; + message['lod'] = tile.id[0]; } this.processWorker.postMessage(message); diff --git a/src/core/map/geodata-processor/worker-globals.js b/src/core/map/geodata-processor/worker-globals.js index 62b614b2..65ac2d81 100755 --- a/src/core/map/geodata-processor/worker-globals.js +++ b/src/core/map/geodata-processor/worker-globals.js @@ -34,7 +34,7 @@ function clamp(value, min, max) { } return value; -}; +} function vec3Normalize(a, b) { @@ -61,7 +61,7 @@ function vec3Normalize(a, b) { b[1] = d * g; b[2] = e * g; return b; -}; +} function vec3Length(a) { @@ -69,7 +69,7 @@ function vec3Length(a) { c = a[1]; a = a[2]; return Math.sqrt(b * b + c * c + a * a); -}; +} function vec3Cross(a, b, c) { @@ -84,7 +84,7 @@ function vec3Cross(a, b, c) { c[1] = a * g - d * b; c[2] = d * f - e * g; return c; -}; +} function vec3AnyPerpendicular(a, b) { @@ -105,7 +105,7 @@ function vec3AnyPerpendicular(a, b) { } return b; -}; +} export {globals, clamp, vec3Normalize, vec3Length, vec3Cross, vec3AnyPerpendicular}; \ No newline at end of file diff --git a/src/core/map/geodata-processor/worker-linestring.js b/src/core/map/geodata-processor/worker-linestring.js index 7026eaa8..44de83cf 100755 --- a/src/core/map/geodata-processor/worker-linestring.js +++ b/src/core/map/geodata-processor/worker-linestring.js @@ -1,13 +1,13 @@ import {globals as globals_, vec3Normalize as vec3Normalize_, vec3Length as vec3Length_, vec3Cross as vec3Cross_, - vec3AnyPerpendicular as vec3AnyPerpendicular_} from "./worker-globals.js"; + vec3AnyPerpendicular as vec3AnyPerpendicular_} from './worker-globals.js'; import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, - getLayerExpresionValue as getLayerExpresionValue_} from "./worker-style.js"; + getLayerExpresionValue as getLayerExpresionValue_} from './worker-style.js'; import {addText as addText_, addTextOnPath as addTextOnPath_, setFont as setFont_, addStreetTextOnPath as addStreetTextOnPath_, areTextCharactersAvailable as areTextCharactersAvailable_, - getCharVerticesCount as getCharVerticesCount_} from "./worker-text.js"; + getCharVerticesCount as getCharVerticesCount_} from './worker-text.js'; var globals = globals_, vec3Normalize = vec3Normalize_, vec3Length = vec3Length_, vec3Cross = vec3Cross_, vec3AnyPerpendicular = vec3AnyPerpendicular_; @@ -17,10 +17,10 @@ var addText = addText_, addTextOnPath = addTextOnPath_, setFont = setFont_, addStreetTextOnPath = addStreetTextOnPath_, areTextCharactersAvailable = areTextCharactersAvailable_, getCharVerticesCount = getCharVerticesCount_; -import {processPolygonPass as processPolygonPass_} from "./worker-polygon.js"; +import {processPolygonPass as processPolygonPass_} from './worker-polygon.js'; var processPolygonPass = processPolygonPass_; -import {postGroupMessage as postGroupMessage_} from "./worker-message.js"; +import {postGroupMessage as postGroupMessage_} from './worker-message.js'; var postGroupMessage = postGroupMessage_; //get rid of compiler mess @@ -28,37 +28,37 @@ var postGroupMessage = postGroupMessage_; var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) { - var lines = lineString["lines"] || []; + var lines = lineString['lines'] || []; if (lines.length == 0) { return; } - var line = getLayerPropertyValue(style, "line", lineString, lod); - var lineLabel = getLayerPropertyValue(style, "line-label", lineString, lod); + var line = getLayerPropertyValue(style, 'line', lineString, lod); + var lineLabel = getLayerPropertyValue(style, 'line-label', lineString, lod); if (!line && !lineLabel) { return; } - var hoverEvent = getLayerPropertyValue(style, "hover-event", lineString, lod); - var clickEvent = getLayerPropertyValue(style, "click-event", lineString, lod); - var drawEvent = getLayerPropertyValue(style, "draw-event", lineString, lod); - var enterEvent = getLayerPropertyValue(style, "enter-event", lineString, lod); - var leaveEvent = getLayerPropertyValue(style, "leave-event", lineString, lod); + var hoverEvent = getLayerPropertyValue(style, 'hover-event', lineString, lod); + var clickEvent = getLayerPropertyValue(style, 'click-event', lineString, lod); + var drawEvent = getLayerPropertyValue(style, 'draw-event', lineString, lod); + var enterEvent = getLayerPropertyValue(style, 'enter-event', lineString, lod); + var leaveEvent = getLayerPropertyValue(style, 'leave-event', lineString, lod); - var zbufferOffset = getLayerPropertyValue(style, "zbuffer-offset", lineString, lod); + var zbufferOffset = getLayerPropertyValue(style, 'zbuffer-offset', lineString, lod); - var lineFlat = getLayerPropertyValue(style, "line-flat", lineString, lod); - var lineColor = getLayerPropertyValue(style, "line-color", lineString, lod); - var lineWidth = 0.5 * getLayerPropertyValue(style, "line-width", lineString, lod); + var lineFlat = getLayerPropertyValue(style, 'line-flat', lineString, lod); + var lineColor = getLayerPropertyValue(style, 'line-color', lineString, lod); + var lineWidth = 0.5 * getLayerPropertyValue(style, 'line-width', lineString, lod); - var lineStyle = getLayerPropertyValue(style, "line-style", lineString, lod); - var lineStyleTexture = getLayerPropertyValue(style, "line-style-texture", lineString, lod); - var lineStyleBackground = getLayerPropertyValue(style, "line-style-background", lineString, lod); + var lineStyle = getLayerPropertyValue(style, 'line-style', lineString, lod); + var lineStyleTexture = getLayerPropertyValue(style, 'line-style-texture', lineString, lod); + var lineStyleBackground = getLayerPropertyValue(style, 'line-style-background', lineString, lod); - var lineLabel = getLayerPropertyValue(style, "line-label", lineString, lod); - var lineLabelSize = getLayerPropertyValue(style, "line-label-size", lineString, lod); + var lineLabel = getLayerPropertyValue(style, 'line-label', lineString, lod); + var lineLabelSize = getLayerPropertyValue(style, 'line-label-size', lineString, lod); //console.log("lineflat: "+lineFlat); //var lineWidth = Math.pow(2, 23 - lod) / 32; @@ -144,7 +144,7 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) p1 = [p1[0] * forceScale[0], p1[1] * forceScale[1], p1[2] * forceScale[2]]; } - var texturedLine = (lineStyle != "solid"); + var texturedLine = (lineStyle != 'solid'); var dlines = false; @@ -538,28 +538,28 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) var hitable = hoverEvent || clickEvent || enterEvent || leaveEvent; if (line) { - var messageData = {"command":"addRenderJob", "vertexBuffer": vertexBuffer, - "color":lineColor, "z-index":zIndex, "center": center, "normalBuffer": normalBuffer, - "hover-event":hoverEvent, "click-event":clickEvent, "draw-event":drawEvent, - "hitable":hitable, "state":globals.hitState, "eventInfo":eventInfo, - "enter-event":enterEvent, "leave-event":leaveEvent, "zbuffer-offset":zbufferOffset, - "line-width":lineWidth*2, "lod":(globals.autoLod ? null : globals.tileLod) }; + var messageData = {'command':'addRenderJob', 'vertexBuffer': vertexBuffer, + 'color':lineColor, 'z-index':zIndex, 'center': center, 'normalBuffer': normalBuffer, + 'hover-event':hoverEvent, 'click-event':clickEvent, 'draw-event':drawEvent, + 'hitable':hitable, 'state':globals.hitState, 'eventInfo':eventInfo, + 'enter-event':enterEvent, 'leave-event':leaveEvent, 'zbuffer-offset':zbufferOffset, + 'line-width':lineWidth*2, 'lod':(globals.autoLod ? null : globals.tileLod) }; if (lineFlat) { - messageData["type"] = texturedLine ? "flat-tline" : "flat-line"; + messageData['type'] = texturedLine ? 'flat-tline' : 'flat-line'; } else { - messageData["type"] = texturedLine ? "pixel-tline" : "pixel-line"; + messageData['type'] = texturedLine ? 'pixel-tline' : 'pixel-line'; } if (texturedLine) { if (lineStyleTexture != null) { - messageData["texture"] = [globals.stylesheetBitmaps[lineStyleTexture[0]], lineStyleTexture[1], lineStyleTexture[2]]; - messageData["background"] = lineStyleBackground; + messageData['texture'] = [globals.stylesheetBitmaps[lineStyleTexture[0]], lineStyleTexture[1], lineStyleTexture[2]]; + messageData['background'] = lineStyleBackground; } } var signature = JSON.stringify({ - type: messageData["type"], + type: messageData['type'], color : lineColor, zIndex : zIndex, zOffset : zbufferOffset, @@ -584,10 +584,10 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) }; var processLineLabel = function(lineLabelPoints, lineLabelPoints2, lineString, center, lod, style, zIndex, eventInfo) { - var labelColor = getLayerPropertyValue(style, "line-label-color", lineString, lod); - var labelSource = getLayerPropertyValue(style, "line-label-source", lineString, lod); - var labelSize = getLayerPropertyValue(style, "line-label-size", lineString, lod); - var labelOffset = getLayerPropertyValue(style, "line-label-offset", lineString, lod); + var labelColor = getLayerPropertyValue(style, 'line-label-color', lineString, lod); + var labelSource = getLayerPropertyValue(style, 'line-label-source', lineString, lod); + var labelSize = getLayerPropertyValue(style, 'line-label-size', lineString, lod); + var labelOffset = getLayerPropertyValue(style, 'line-label-offset', lineString, lod); //console.log("label size: " + lod + " " + labelSize); @@ -598,27 +598,27 @@ var processLineLabel = function(lineLabelPoints, lineLabelPoints2, lineString, c var labelText = getLayerExpresionValue(style, labelSource, lineString, lod); - if (labelSource == "$name") { - if (!areTextCharactersAvailable(labelText, globals.fonts["default"])) { - var labelText2 = getLayerExpresionValue(style, "$name:en", lineString, lod); + if (labelSource == '$name') { + if (!areTextCharactersAvailable(labelText, globals.fonts['default'])) { + var labelText2 = getLayerExpresionValue(style, '$name:en', lineString, lod); - if (areTextCharactersAvailable(labelText2, globals.fonts["default"])) { + if (areTextCharactersAvailable(labelText2, globals.fonts['default'])) { labelText = labelText2; } } } - if (!labelText || labelText == "") { + if (!labelText || labelText == '') { return; } - var hoverEvent = getLayerPropertyValue(style, "hover-event", lineString, lod); - var clickEvent = getLayerPropertyValue(style, "click-event", lineString, lod); - var drawEvent = getLayerPropertyValue(style, "draw-event", lineString, lod); - var enterEvent = getLayerPropertyValue(style, "enter-event", lineString, lod); - var leaveEvent = getLayerPropertyValue(style, "leave-event", lineString, lod); + var hoverEvent = getLayerPropertyValue(style, 'hover-event', lineString, lod); + var clickEvent = getLayerPropertyValue(style, 'click-event', lineString, lod); + var drawEvent = getLayerPropertyValue(style, 'draw-event', lineString, lod); + var enterEvent = getLayerPropertyValue(style, 'enter-event', lineString, lod); + var leaveEvent = getLayerPropertyValue(style, 'leave-event', lineString, lod); - var zbufferOffset = getLayerPropertyValue(style, "zbuffer-offset", lineString, lod); + var zbufferOffset = getLayerPropertyValue(style, 'zbuffer-offset', lineString, lod); var bufferSize = getCharVerticesCount() * labelText.length * 2; var vertexBuffer = new Float32Array(bufferSize); @@ -629,22 +629,22 @@ var processLineLabel = function(lineLabelPoints, lineLabelPoints2, lineString, c var hitable = hoverEvent || clickEvent || enterEvent || leaveEvent; var index = 0; - var index = addStreetTextOnPath(lineLabelPoints, labelText, labelSize, globals.fonts["default"], labelOffset, vertexBuffer, texcoordsBuffer, index); - index = addStreetTextOnPath(lineLabelPoints2, labelText, labelSize, globals.fonts["default"], labelOffset, vertexBuffer, texcoordsBuffer, index); + var index = addStreetTextOnPath(lineLabelPoints, labelText, labelSize, globals.fonts['default'], labelOffset, vertexBuffer, texcoordsBuffer, index); + index = addStreetTextOnPath(lineLabelPoints2, labelText, labelSize, globals.fonts['default'], labelOffset, vertexBuffer, texcoordsBuffer, index); var signature = JSON.stringify({ - type: "line-label", + type: 'line-label', color : labelColor, zIndex : zIndex, zOffset : zbufferOffset }); - postGroupMessage({"command":"addRenderJob", "type": "line-label", "vertexBuffer": vertexBuffer, - "texcoordsBuffer": texcoordsBuffer, "color":labelColor, "z-index":zIndex, "center": center, - "hover-event":hoverEvent, "click-event":clickEvent, "draw-event":drawEvent, - "enter-event":enterEvent, "leave-event":leaveEvent, "zbuffer-offset":zbufferOffset, - "hitable":hitable, "state":globals.hitState, "eventInfo":eventInfo, - "lod":(globals.autoLod ? null : globals.tileLod) }, [vertexBuffer.buffer, texcoordsBuffer.buffer], signature); + postGroupMessage({'command':'addRenderJob', 'type': 'line-label', 'vertexBuffer': vertexBuffer, + 'texcoordsBuffer': texcoordsBuffer, 'color':labelColor, 'z-index':zIndex, 'center': center, + 'hover-event':hoverEvent, 'click-event':clickEvent, 'draw-event':drawEvent, + 'enter-event':enterEvent, 'leave-event':leaveEvent, 'zbuffer-offset':zbufferOffset, + 'hitable':hitable, 'state':globals.hitState, 'eventInfo':eventInfo, + 'lod':(globals.autoLod ? null : globals.tileLod) }, [vertexBuffer.buffer, texcoordsBuffer.buffer], signature); }; export {processLineStringPass, processLineLabel}; diff --git a/src/core/map/geodata-processor/worker-main.js b/src/core/map/geodata-processor/worker-main.js index cfcbf5dc..642ebd16 100755 --- a/src/core/map/geodata-processor/worker-main.js +++ b/src/core/map/geodata-processor/worker-main.js @@ -1,23 +1,23 @@ -import {globals as globals_} from "./worker-globals.js"; +import {globals as globals_} from './worker-globals.js'; var globals = globals_; -import {setFont as setFont_} from "./worker-text.js"; +import {setFont as setFont_} from './worker-text.js'; var setFont = setFont_; import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, getLayerExpresionValue as getLayerExpresionValue_, - processStylesheet as processStylesheet_, getFilterResult as getFilterResult_} from "./worker-style.js"; + processStylesheet as processStylesheet_, getFilterResult as getFilterResult_} from './worker-style.js'; var getLayer = getLayer_, getLayerPropertyValue = getLayerPropertyValue_, getLayerExpresionValue = getLayerExpresionValue_, processStylesheet = processStylesheet_, getFilterResult = getFilterResult_; -import {processLineStringPass as processLineStringPass_, processLineLabel as processLineLabel_} from "./worker-linestring.js"; +import {processLineStringPass as processLineStringPass_, processLineLabel as processLineLabel_} from './worker-linestring.js'; var processLineStringPass = processLineStringPass_, processLineLabel = processLineLabel_; -import {processPointArrayPass as processPointArrayPass_} from "./worker-pointarray.js"; +import {processPointArrayPass as processPointArrayPass_} from './worker-pointarray.js'; var processPointArrayPass = processPointArrayPass_; -import {processPolygonPass as processPolygonPass_} from "./worker-polygon.js"; +import {processPolygonPass as processPolygonPass_} from './worker-polygon.js'; var processPolygonPass = processPolygonPass_; //get rid of compiler mess @@ -26,43 +26,43 @@ var processPolygonPass = processPolygonPass_; function processLayerFeaturePass(type, feature, lod, layer, zIndex, eventInfo) { switch(type) { - case "line-string": - if (getLayerPropertyValue(layer, "point", feature, lod) || - getLayerPropertyValue(layer, "label", feature, lod)) { - processPointArrayPass(feature, lod, layer, zIndex, eventInfo); - } + case 'line-string': + if (getLayerPropertyValue(layer, 'point', feature, lod) || + getLayerPropertyValue(layer, 'label', feature, lod)) { + processPointArrayPass(feature, lod, layer, zIndex, eventInfo); + } - processLineStringPass(feature, lod, layer, zIndex, eventInfo); - break; + processLineStringPass(feature, lod, layer, zIndex, eventInfo); + break; - case "point-array": - processPointArrayPass(feature, lod, layer, zIndex, eventInfo); + case 'point-array': + processPointArrayPass(feature, lod, layer, zIndex, eventInfo); /*if (getLayerPropertyValue(layer, "line", feature, lod) || getLayerPropertyValue(layer, "line-label", feature, lod)) { processLineStringPass(feature, lod, layer, zIndex, eventInfo); }*/ - break; + break; - case "polygon": - processPolygonPass(feature, lod, style, zIndex, eventInfo); - break; + case 'polygon': + processPolygonPass(feature, lod, style, zIndex, eventInfo); + break; } -}; +} function processFeature(type, feature, lod, featureIndex, featureType, group) { //loop layers for (var key in globals.stylesheetLayers) { var layer = globals.stylesheetLayers[key]; - var filter = getLayerPropertyValue(layer, "filter", feature, lod); + var filter = getLayerPropertyValue(layer, 'filter', feature, lod); - feature.properties = feature["properties"] || {}; + feature.properties = feature['properties'] || {}; - if (feature["id"]) { - feature.properties["#id"] = feature["id"]; + if (feature['id']) { + feature.properties['#id'] = feature['id']; } if (!filter || getFilterResult(filter, feature, featureType, group)) { @@ -72,20 +72,20 @@ function processFeature(type, feature, lod, featureIndex, featureType, group) { } function processLayerFeatureMultipass(type, feature, lod, layer, featureIndex, eventInfo) { - var multiPass = getLayerPropertyValue(layer, "next-pass", feature, lod); + var multiPass = getLayerPropertyValue(layer, 'next-pass', feature, lod); if (multiPass != null) { for (var i = 0, li = multiPass.length; i < li; i++) { var zIndex = multiPass[i][0]; var layer = getLayer(multiPass[i][1], type, featureIndex); - var visible = getLayerPropertyValue(layer, "visible", feature, lod); + var visible = getLayerPropertyValue(layer, 'visible', feature, lod); if (!visible) { continue; } - var hoverLayerId = getLayerPropertyValue(layer, "hover-layer", feature, lod); - var hoverlayer = (hoverLayerId != "") ? getLayer(hoverLayerId, type, featureIndex) : null; + var hoverLayerId = getLayerPropertyValue(layer, 'hover-layer', feature, lod); + var hoverlayer = (hoverLayerId != '') ? getLayer(hoverLayerId, type, featureIndex) : null; if (hoverlayer != null) { var lastHitState = globals.hitState; @@ -100,13 +100,13 @@ function processLayerFeatureMultipass(type, feature, lod, layer, featureIndex, e } } } -}; +} function processLayerFeature(type, feature, lod, layer, featureIndex) { //var layer = getLayer(feature["style"], type, featureIndex); - var visible = getLayerPropertyValue(layer, "visible", feature, lod); - var zIndex = getLayerPropertyValue(layer, "z-index", feature, lod); + var visible = getLayerPropertyValue(layer, 'visible', feature, lod); + var zIndex = getLayerPropertyValue(layer, 'z-index', feature, lod); if (!visible) { return; @@ -114,8 +114,8 @@ function processLayerFeature(type, feature, lod, layer, featureIndex) { var eventInfo = feature.properties; - var hoverLayerId = getLayerPropertyValue(layer, "hover-layer", feature, lod); - var hoverlayer = (hoverLayerId != "") ? getLayer(hoverLayerId, type, featureIndex) : null; + var hoverLayerId = getLayerPropertyValue(layer, 'hover-layer', feature, lod); + var hoverlayer = (hoverLayerId != '') ? getLayer(hoverLayerId, type, featureIndex) : null; if (hoverlayer != null) { globals.hitState = 1; @@ -129,13 +129,13 @@ function processLayerFeature(type, feature, lod, layer, featureIndex) { processLayerFeaturePass(type, feature, lod, layer, zIndex, eventInfo); processLayerFeatureMultipass(type, feature, lod, layer, featureIndex, eventInfo); } -}; +} function processGroup(group, lod) { - var groupId = group["id"] || ""; + var groupId = group['id'] || ''; - var bbox = group["bbox"]; + var bbox = group['bbox']; if (!bbox) { return; } @@ -146,51 +146,51 @@ function processGroup(group, lod) { globals.bboxMax = bboxMax; var bboxDelta = [bbox[1][0] - bbox[0][0], - bbox[1][1] - bbox[0][1], - bbox[1][2] - bbox[0][2]]; - var bboxResolution = group["resolution"] || 4096; + bbox[1][1] - bbox[0][1], + bbox[1][2] - bbox[0][2]]; + var bboxResolution = group['resolution'] || 4096; globals.groupOrigin = [0,0,0]; globals.forceScale = [bboxDelta[0] / bboxResolution, - bboxDelta[1] / bboxResolution, - bboxDelta[2] / bboxResolution]; + bboxDelta[1] / bboxResolution, + bboxDelta[2] / bboxResolution]; - postMessage({"command":"beginGroup", "id": group["id"], "bbox": [bboxMin, bboxMax], "origin": bboxMin}); + postMessage({'command':'beginGroup', 'id': group['id'], 'bbox': [bboxMin, bboxMax], 'origin': bboxMin}); - var points = group["points"] || []; + var points = group['points'] || []; //process points for (var i = 0, li = points.length; i < li; i++) { - processFeature("point-array", points[i], lod, i, "point", groupId); + processFeature('point-array', points[i], lod, i, 'point', groupId); } - var lines = group["lines"] || []; + var lines = group['lines'] || []; //process lines for (var i = 0, li = lines.length; i < li; i++) { - processFeature("line-string", lines[i], lod, i, "line", groupId); + processFeature('line-string', lines[i], lod, i, 'line', groupId); } - var polygons = group["polygons"] || []; + var polygons = group['polygons'] || []; //process polygons for (var i = 0, li = polygons.length; i < li; i++) { - processFeature("polygon", polygons[i], lod, i, "polygon", groupId); + processFeature('polygon', polygons[i], lod, i, 'polygon', groupId); } if (globals.groupOptimize) { optimizeGroupMessages(); } - postMessage({"command":"endGroup"}); -}; + postMessage({'command':'endGroup'}); +} function processGeodata(data, lod) { //console.log("processGeodata"); //create object from JSON - if ((typeof data) == "string") { + if ((typeof data) == 'string') { try { var geodata = JSON.parse(data); } catch (e) { @@ -202,7 +202,7 @@ function processGeodata(data, lod) { if (geodata) { - var groups = geodata["groups"] || []; + var groups = geodata['groups'] || []; //process layers for (var i = 0, li = groups.length; i < li; i++) { @@ -211,7 +211,7 @@ function processGeodata(data, lod) { } //console.log("processGeodata-ready"); -}; +} function optimizeGroupMessages() { //loop messages @@ -222,97 +222,97 @@ function optimizeGroupMessages() { for (var i = 0, li = globals.messageBufferIndex; i < li; i++) { var message = messages[i]; var job = message.job; - var type = job["type"]; + var type = job['type']; var signature = message.signature; - if (!message["hitable"] && !message.reduced && //!message["culling"] && - !(type == "icon" || type == "label")) { + if (!message['hitable'] && !message.reduced && //!message["culling"] && + !(type == 'icon' || type == 'label')) { switch(type) { - case "flat-line": - var vbufferSize = job["vertexBuffer"].length; + case 'flat-line': + var vbufferSize = job['vertexBuffer'].length; - for (var j = i + 1; j < li; j++) { - var message2 = messages[j]; + for (var j = i + 1; j < li; j++) { + var message2 = messages[j]; - if (message2.signature == signature) { - message2.reduced = true; - vbufferSize += message2.job["vertexBuffer"].length; - } + if (message2.signature == signature) { + message2.reduced = true; + vbufferSize += message2.job['vertexBuffer'].length; } + } - var vbuffer = new Float32Array(vbufferSize); - var index = 0; + var vbuffer = new Float32Array(vbufferSize); + var index = 0; - for (var j = i; j < li; j++) { - var message2 = messages[j]; - var job2 = message2.job; + for (var j = i; j < li; j++) { + var message2 = messages[j]; + var job2 = message2.job; - if (message2.signature == signature) { - var buff = job2["vertexBuffer"]; - job2["vertexBuffer"] = null; - for (var k = 0, lk = buff.length; k < lk; k++) { - vbuffer[index+k] = buff[k]; - } - index+= lk; + if (message2.signature == signature) { + var buff = job2['vertexBuffer']; + job2['vertexBuffer'] = null; + for (var k = 0, lk = buff.length; k < lk; k++) { + vbuffer[index+k] = buff[k]; } + index+= lk; } + } - job["vertexBuffer"] = vbuffer; - message.arrays = [vbuffer.buffer]; - break; + job['vertexBuffer'] = vbuffer; + message.arrays = [vbuffer.buffer]; + break; - case "pixel-line": - case "line-label": - var vbufferSize = job["vertexBuffer"].length; + case 'pixel-line': + case 'line-label': + var vbufferSize = job['vertexBuffer'].length; - for (var j = i + 1; j < li; j++) { - var message2 = messages[j]; + for (var j = i + 1; j < li; j++) { + var message2 = messages[j]; - if (message2.signature == signature) { - message2.reduced = true; - vbufferSize += message2.job["vertexBuffer"].length; - } + if (message2.signature == signature) { + message2.reduced = true; + vbufferSize += message2.job['vertexBuffer'].length; } + } - var vbuffer = new Float32Array(vbufferSize); - var nbuffer = new Float32Array(vbufferSize); - var index = 0; + var vbuffer = new Float32Array(vbufferSize); + var nbuffer = new Float32Array(vbufferSize); + var index = 0; - for (var j = i; j < li; j++) { - var message2 = messages[j]; - var job2 = message2.job; + for (var j = i; j < li; j++) { + var message2 = messages[j]; + var job2 = message2.job; - if (message2.signature == signature) { - var buff = job2["vertexBuffer"]; - job2["vertexBuffer"] = null; + if (message2.signature == signature) { + var buff = job2['vertexBuffer']; + job2['vertexBuffer'] = null; - if (type == "line-label") { - var buff2 = job2["texcoordsBuffer"]; - job2["texcoordsBuffer"] = null; - } else { - var buff2 = job2["normalBuffer"]; - job2["normalBuffer"] = null; - } + if (type == 'line-label') { + var buff2 = job2['texcoordsBuffer']; + job2['texcoordsBuffer'] = null; + } else { + var buff2 = job2['normalBuffer']; + job2['normalBuffer'] = null; + } - for (var k = 0, lk = buff.length; k < lk; k++) { - vbuffer[index+k] = buff[k]; - nbuffer[index+k] = buff2[k]; - } - index+= lk; + for (var k = 0, lk = buff.length; k < lk; k++) { + vbuffer[index+k] = buff[k]; + nbuffer[index+k] = buff2[k]; } + index+= lk; } + } - job["vertexBuffer"] = vbuffer; + job['vertexBuffer'] = vbuffer; - if (type == "line-label") { - job["texcoordsBuffer"] = nbuffer; - } else { - job["normalBuffer"] = nbuffer; - } + if (type == 'line-label') { + job['texcoordsBuffer'] = nbuffer; + } else { + job['normalBuffer'] = nbuffer; + } - message.arrays = [vbuffer.buffer, nbuffer.buffer]; - break; + message.arrays = [vbuffer.buffer, nbuffer.buffer]; + break; } //messages2[index2] = message; @@ -338,42 +338,42 @@ function optimizeGroupMessages() { //console.log("total: " + messageBufferIndex + " reduced: " + reduced); globals.messageBufferIndex = 0; -}; +} self.onmessage = function (e) { var message = e.data; - var command = message["command"]; - var data = message["data"]; + var command = message['command']; + var data = message['data']; //console.log("workeronmessage: " + command); switch(command) { - case "setStylesheet": - if (data) { - globals.geocent = data["geocent"] || false; - processStylesheet(data["data"]); - } - postMessage({"command" : "ready"}); - break; - - case "setFont": - setFont(data); - postMessage({"command" : "ready"}); - break; - - case "processGeodata": - globals.tileLod = message["lod"] || 0; - data = JSON.parse(data); - processGeodata(data, globals.tileLod); + case 'setStylesheet': + if (data) { + globals.geocent = data['geocent'] || false; + processStylesheet(data['data']); + } + postMessage({'command' : 'ready'}); + break; + + case 'setFont': + setFont(data); + postMessage({'command' : 'ready'}); + break; + + case 'processGeodata': + globals.tileLod = message['lod'] || 0; + data = JSON.parse(data); + processGeodata(data, globals.tileLod); - if (globals.groupOptimize) { - optimizeGroupMessages(); - } + if (globals.groupOptimize) { + optimizeGroupMessages(); + } - postMessage({"command" : "allProcessed"}); - postMessage({"command" : "ready"}); - break; + postMessage({'command' : 'allProcessed'}); + postMessage({'command' : 'ready'}); + break; } }; diff --git a/src/core/map/geodata-processor/worker-message.js b/src/core/map/geodata-processor/worker-message.js index bcbf0e42..5770b6da 100755 --- a/src/core/map/geodata-processor/worker-message.js +++ b/src/core/map/geodata-processor/worker-message.js @@ -1,5 +1,5 @@ -import {globals as globals_} from "./worker-globals.js"; +import {globals as globals_} from './worker-globals.js'; //get rid of compiler mess var globals = globals_; @@ -23,7 +23,7 @@ function postGroupMessage(message, arrays, signature) { } else { postMessage(message, arrays); } -}; +} export {postGroupMessage}; diff --git a/src/core/map/geodata-processor/worker-pointarray.js b/src/core/map/geodata-processor/worker-pointarray.js index 93f34c50..ef1379d1 100755 --- a/src/core/map/geodata-processor/worker-pointarray.js +++ b/src/core/map/geodata-processor/worker-pointarray.js @@ -1,16 +1,16 @@ -import {globals as globals_, clamp as clamp_} from "./worker-globals.js"; +import {globals as globals_, clamp as clamp_} from './worker-globals.js'; var globals = globals_, clamp = clamp_; -import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, getLayerExpresionValue as getLayerExpresionValue_} from "./worker-style.js"; +import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, getLayerExpresionValue as getLayerExpresionValue_} from './worker-style.js'; var getLayer = getLayer_, getLayerPropertyValue = getLayerPropertyValue_, getLayerExpresionValue = getLayerExpresionValue_; import {addText as addText_, addTextOnPath as addTextOnPath_, setFont as setFont_, getSplitIndex as getSplitIndex_, getFontFactor as getFontFactor_, getTextLength as getTextLength_, - areTextCharactersAvailable as areTextCharactersAvailable_, getCharVerticesCount as getCharVerticesCount_, getLineHeight as getLineHeight_} from "./worker-text.js"; + areTextCharactersAvailable as areTextCharactersAvailable_, getCharVerticesCount as getCharVerticesCount_, getLineHeight as getLineHeight_} from './worker-text.js'; var addText = addText_, addTextOnPath = addTextOnPath_, setFont = setFont_, getSplitIndex = getSplitIndex_, getFontFactor = getFontFactor_, getTextLength = getTextLength_, areTextCharactersAvailable = areTextCharactersAvailable_, getCharVerticesCount = getCharVerticesCount_, getLineHeight = getLineHeight_; -import {postGroupMessage as postGroupMessage_} from "./worker-message.js"; +import {postGroupMessage as postGroupMessage_} from './worker-message.js'; var postGroupMessage = postGroupMessage_; //get rid of compiler mess @@ -19,11 +19,11 @@ var postGroupMessage = postGroupMessage_; var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) { var pointsGroups = []; - if (pointArray["lines"]) { //use lines as points - pointsGroups = pointArray["lines"] || []; + if (pointArray['lines']) { //use lines as points + pointsGroups = pointArray['lines'] || []; } else { - if (pointArray["points"]) { - pointsGroups = [pointArray["points"]]; + if (pointArray['points']) { + pointsGroups = [pointArray['points']]; } } @@ -32,37 +32,37 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) } //debugger - var visibility = getLayerPropertyValue(style, "visibility", pointArray, lod); - var culling = getLayerPropertyValue(style, "culling", pointArray, lod); - var hoverEvent = getLayerPropertyValue(style, "hover-event", pointArray, lod); - var clickEvent = getLayerPropertyValue(style, "click-event", pointArray, lod); - var drawEvent = getLayerPropertyValue(style, "draw-event", pointArray, lod); - var enterEvent = getLayerPropertyValue(style, "enter-event", pointArray, lod); - var leaveEvent = getLayerPropertyValue(style, "leave-event", pointArray, lod); - - var zbufferOffset = getLayerPropertyValue(style, "zbuffer-offset", pointArray, lod); - - var point = getLayerPropertyValue(style, "point", pointArray, lod); - var pointFlat = getLayerPropertyValue(style, "point-flat", pointArray, lod); - var pointColor = getLayerPropertyValue(style, "point-color", pointArray, lod); - var pointRadius = 0.5 * getLayerPropertyValue(style, "point-radius", pointArray, lod); + var visibility = getLayerPropertyValue(style, 'visibility', pointArray, lod); + var culling = getLayerPropertyValue(style, 'culling', pointArray, lod); + var hoverEvent = getLayerPropertyValue(style, 'hover-event', pointArray, lod); + var clickEvent = getLayerPropertyValue(style, 'click-event', pointArray, lod); + var drawEvent = getLayerPropertyValue(style, 'draw-event', pointArray, lod); + var enterEvent = getLayerPropertyValue(style, 'enter-event', pointArray, lod); + var leaveEvent = getLayerPropertyValue(style, 'leave-event', pointArray, lod); + + var zbufferOffset = getLayerPropertyValue(style, 'zbuffer-offset', pointArray, lod); + + var point = getLayerPropertyValue(style, 'point', pointArray, lod); + var pointFlat = getLayerPropertyValue(style, 'point-flat', pointArray, lod); + var pointColor = getLayerPropertyValue(style, 'point-color', pointArray, lod); + var pointRadius = 0.5 * getLayerPropertyValue(style, 'point-radius', pointArray, lod); //zIndex = (zIndex !== null) ? zIndex : getLayerPropertyValue(style, "z-index", pointArray, lod); - var icon = getLayerPropertyValue(style, "icon", pointArray, lod); + var icon = getLayerPropertyValue(style, 'icon', pointArray, lod); if (icon) { - var source = getLayerPropertyValue(style, "icon-source", pointArray, lod); + var source = getLayerPropertyValue(style, 'icon-source', pointArray, lod); if (source) { var bufferSize = getCharVerticesCount() * pointsGroups.length; var bufferSize2 = getCharVerticesCount(true) * pointsGroups.length; var iconData = { - color : getLayerPropertyValue(style, "icon-color", pointArray, lod), - scale : getLayerPropertyValue(style, "icon-scale", pointArray, lod), - offset : getLayerPropertyValue(style, "icon-offset", pointArray, lod), - stick : getLayerPropertyValue(style, "icon-stick", pointArray, lod), - origin : getLayerPropertyValue(style, "icon-origin", pointArray, lod), - source : getLayerPropertyValue(style, "icon-source", pointArray, lod), + color : getLayerPropertyValue(style, 'icon-color', pointArray, lod), + scale : getLayerPropertyValue(style, 'icon-scale', pointArray, lod), + offset : getLayerPropertyValue(style, 'icon-offset', pointArray, lod), + stick : getLayerPropertyValue(style, 'icon-stick', pointArray, lod), + origin : getLayerPropertyValue(style, 'icon-origin', pointArray, lod), + source : getLayerPropertyValue(style, 'icon-source', pointArray, lod), vertexBuffer : new Float32Array(bufferSize), originBuffer : new Float32Array(bufferSize2), texcoordsBuffer : new Float32Array(bufferSize), @@ -74,34 +74,34 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) } } - var label = getLayerPropertyValue(style, "label", pointArray, lod); + var label = getLayerPropertyValue(style, 'label', pointArray, lod); if (label) { - var source = getLayerPropertyValue(style, "label-source", pointArray, lod); + var source = getLayerPropertyValue(style, 'label-source', pointArray, lod); var text = getLayerExpresionValue(style, source, pointArray, lod); - var size = getLayerPropertyValue(style, "label-size", pointArray, lod); + var size = getLayerPropertyValue(style, 'label-size', pointArray, lod); - if (source == "$name") { - if (!areTextCharactersAvailable(text, globals.fonts["default"])) { - var text2 = getLayerExpresionValue(style, "$name:en", pointArray, lod); + if (source == '$name') { + if (!areTextCharactersAvailable(text, globals.fonts['default'])) { + var text2 = getLayerExpresionValue(style, '$name:en', pointArray, lod); - if (areTextCharactersAvailable(text2, globals.fonts["default"])) { + if (areTextCharactersAvailable(text2, globals.fonts['default'])) { text = text2; } } } - if (text && text != "" && Math.abs(size) > 0.0001) { + if (text && text != '' && Math.abs(size) > 0.0001) { var bufferSize = getCharVerticesCount() * text.length * pointsGroups.length; var bufferSize2 = getCharVerticesCount(true) * text.length * pointsGroups.length; var labelData = { - color : getLayerPropertyValue(style, "label-color", pointArray, lod), + color : getLayerPropertyValue(style, 'label-color', pointArray, lod), size : size, - offset : getLayerPropertyValue(style, "label-offset", pointArray, lod), - stick : getLayerPropertyValue(style, "label-stick", pointArray, lod), - origin : getLayerPropertyValue(style, "label-origin", pointArray, lod), - align : getLayerPropertyValue(style, "label-align", pointArray, lod), + offset : getLayerPropertyValue(style, 'label-offset', pointArray, lod), + stick : getLayerPropertyValue(style, 'label-stick', pointArray, lod), + origin : getLayerPropertyValue(style, 'label-origin', pointArray, lod), + align : getLayerPropertyValue(style, 'label-align', pointArray, lod), text : text, - width : getLayerPropertyValue(style, "label-width", pointArray, lod), + width : getLayerPropertyValue(style, 'label-width', pointArray, lod), vertexBuffer : new Float32Array(bufferSize), originBuffer : new Float32Array(bufferSize2), texcoordsBuffer : new Float32Array(bufferSize), @@ -264,58 +264,58 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) if (point) { if (pointFlat) { - postGroupMessage({"command":"addRenderJob", "type": "flat-line", "vertexBuffer": vertexBuffer, - "color":pointColor, "z-index":zIndex, "visibility": visibility, "center": center, - "hover-event":hoverEvent, "click-event":clickEvent, "draw-event":drawEvent, - "enter-event":enterEvent, "leave-event":leaveEvent, "zbuffer-offset":zbufferOffset, - "hitable":hitable, "state":globals.hitState, "eventInfo":eventInfo, - "lod":(globals.autoLod ? null : globals.tileLod) }, [vertexBuffer.buffer]); + postGroupMessage({'command':'addRenderJob', 'type': 'flat-line', 'vertexBuffer': vertexBuffer, + 'color':pointColor, 'z-index':zIndex, 'visibility': visibility, 'center': center, + 'hover-event':hoverEvent, 'click-event':clickEvent, 'draw-event':drawEvent, + 'enter-event':enterEvent, 'leave-event':leaveEvent, 'zbuffer-offset':zbufferOffset, + 'hitable':hitable, 'state':globals.hitState, 'eventInfo':eventInfo, + 'lod':(globals.autoLod ? null : globals.tileLod) }, [vertexBuffer.buffer]); } else { - postGroupMessage({"command":"addRenderJob", "type": "pixel-line", "vertexBuffer": vertexBuffer, - "normalBuffer": normalBuffer, "color":pointColor, "z-index":zIndex, - "visibility": visibility, "center": center, - "hover-event":hoverEvent, "click-event":clickEvent, "draw-event":drawEvent, - "enter-event":enterEvent, "leave-event":leaveEvent, "zbuffer-offset":zbufferOffset, - "hitable":hitable, "state":globals.hitState, "eventInfo":eventInfo, - "lod":(globals.autoLod ? null : globals.tileLod) }, [vertexBuffer.buffer, normalBuffer.buffer]); + postGroupMessage({'command':'addRenderJob', 'type': 'pixel-line', 'vertexBuffer': vertexBuffer, + 'normalBuffer': normalBuffer, 'color':pointColor, 'z-index':zIndex, + 'visibility': visibility, 'center': center, + 'hover-event':hoverEvent, 'click-event':clickEvent, 'draw-event':drawEvent, + 'enter-event':enterEvent, 'leave-event':leaveEvent, 'zbuffer-offset':zbufferOffset, + 'hitable':hitable, 'state':globals.hitState, 'eventInfo':eventInfo, + 'lod':(globals.autoLod ? null : globals.tileLod) }, [vertexBuffer.buffer, normalBuffer.buffer]); } } if (icon && iconData.vertexBuffer.length > 0) { - postGroupMessage({"command":"addRenderJob", "type": "icon", "vertexBuffer": iconData.vertexBuffer, - "originBuffer": iconData.originBuffer, "texcoordsBuffer": iconData.texcoordsBuffer, - "icon":globals.stylesheetBitmaps[iconData.source[0]], "color":iconData.color, "z-index":zIndex, - "visibility": visibility, "culling": culling, "center": center, "stick": iconData.stick, - "hover-event":hoverEvent, "click-event":clickEvent, "draw-event":drawEvent, - "enter-event":enterEvent, "leave-event":leaveEvent, "zbuffer-offset":zbufferOffset, - "hitable":hitable, "state":globals.hitState, "eventInfo":eventInfo, - "lod":(globals.autoLod ? null : globals.tileLod) }, [iconData.vertexBuffer.buffer, iconData.originBuffer.buffer, iconData.texcoordsBuffer.buffer]); + postGroupMessage({'command':'addRenderJob', 'type': 'icon', 'vertexBuffer': iconData.vertexBuffer, + 'originBuffer': iconData.originBuffer, 'texcoordsBuffer': iconData.texcoordsBuffer, + 'icon':globals.stylesheetBitmaps[iconData.source[0]], 'color':iconData.color, 'z-index':zIndex, + 'visibility': visibility, 'culling': culling, 'center': center, 'stick': iconData.stick, + 'hover-event':hoverEvent, 'click-event':clickEvent, 'draw-event':drawEvent, + 'enter-event':enterEvent, 'leave-event':leaveEvent, 'zbuffer-offset':zbufferOffset, + 'hitable':hitable, 'state':globals.hitState, 'eventInfo':eventInfo, + 'lod':(globals.autoLod ? null : globals.tileLod) }, [iconData.vertexBuffer.buffer, iconData.originBuffer.buffer, iconData.texcoordsBuffer.buffer]); } if (label && labelData.vertexBuffer.length > 0) { - postGroupMessage({"command":"addRenderJob", "type": "label", "vertexBuffer": labelData.vertexBuffer, - "originBuffer": labelData.originBuffer, "texcoordsBuffer": labelData.texcoordsBuffer, - "color":labelData.color, "z-index":zIndex, "visibility": visibility, "culling": culling, - "center": center, "stick": labelData.stick, - "hover-event":hoverEvent, "click-event":clickEvent, "draw-event":drawEvent, - "enter-event":enterEvent, "leave-event":leaveEvent, "zbuffer-offset":zbufferOffset, - "hitable":hitable, "state":globals.hitState, "eventInfo":eventInfo, - "lod":(globals.autoLod ? null : globals.tileLod) }, [labelData.vertexBuffer.buffer, labelData.originBuffer.buffer, labelData.texcoordsBuffer.buffer]); + postGroupMessage({'command':'addRenderJob', 'type': 'label', 'vertexBuffer': labelData.vertexBuffer, + 'originBuffer': labelData.originBuffer, 'texcoordsBuffer': labelData.texcoordsBuffer, + 'color':labelData.color, 'z-index':zIndex, 'visibility': visibility, 'culling': culling, + 'center': center, 'stick': labelData.stick, + 'hover-event':hoverEvent, 'click-event':clickEvent, 'draw-event':drawEvent, + 'enter-event':enterEvent, 'leave-event':leaveEvent, 'zbuffer-offset':zbufferOffset, + 'hitable':hitable, 'state':globals.hitState, 'eventInfo':eventInfo, + 'lod':(globals.autoLod ? null : globals.tileLod) }, [labelData.vertexBuffer.buffer, labelData.originBuffer.buffer, labelData.texcoordsBuffer.buffer]); } }; var getOriginOffset = function(origin, width, height) { switch(origin) { - case "top-left": return [0, 0]; - case "top-right": return [-width, 0]; - case "top-center": return [-width*0.5, 0]; - case "center-left": return [0, -height*0.5]; - case "center-right": return [-width, -height*0.5]; - case "center-center": return [-width*0.5, -height*0.5]; - case "bottom-left": return [0, -height]; - case "bottom-right": return [-width, -height]; - case "bottom-center": return [-width*0.5, -height]; + case 'top-left': return [0, 0]; + case 'top-right': return [-width, 0]; + case 'top-center': return [-width*0.5, 0]; + case 'center-left': return [0, -height*0.5]; + case 'center-right': return [-width, -height*0.5]; + case 'center-center': return [-width*0.5, -height*0.5]; + case 'bottom-left': return [0, -height]; + case 'bottom-right': return [-width, -height]; + case 'bottom-center': return [-width*0.5, -height]; } }; @@ -430,7 +430,7 @@ var processLabel = function(point, labelData) { var index = labelData.index; var index2 = labelData.index2; var lastIndex = index; - var text = "" + labelData.text; + var text = '' + labelData.text; //split by new line var lines = text.match(/[^\r\n]+/g); @@ -443,7 +443,7 @@ var processLabel = function(point, labelData) { var line= lines[i]; do { - var splitIndex = getSplitIndex(line, labelData.width, getFontFactor(labelData.size, globals.fonts["default"]), globals.fonts["default"]); + var splitIndex = getSplitIndex(line, labelData.width, getFontFactor(labelData.size, globals.fonts['default']), globals.fonts['default']); if (line.length == splitIndex) { lines2.push(line); @@ -461,13 +461,13 @@ var processLabel = function(point, labelData) { var x = 0; var y = 0; var textLength = 0; - var lineHeight = getLineHeight(labelData.size, globals.fonts["default"]); + var lineHeight = getLineHeight(labelData.size, globals.fonts['default']); var maxWidth = 0; var lineWidths = []; //get max width for (var i = 0, li = lines2.length; i < li; i++) { - lineWidths[i] = getTextLength(lines2[i], getFontFactor(labelData.size, globals.fonts["default"]), globals.fonts["default"]); + lineWidths[i] = getTextLength(lines2[i], getFontFactor(labelData.size, globals.fonts['default']), globals.fonts['default']); maxWidth = Math.max(lineWidths[i], maxWidth); } @@ -477,12 +477,12 @@ var processLabel = function(point, labelData) { //maxWidth = Math.max(textWidth, maxWidth); switch(labelData.align) { - case "left": x = 0; break; - case "right": x = maxWidth - textWidth; break; - case "center": x = (maxWidth - textWidth)*0.5; break; + case 'left': x = 0; break; + case 'right': x = maxWidth - textWidth; break; + case 'center': x = (maxWidth - textWidth)*0.5; break; } - index = addText([x,y,0], [1,0,0], lines2[i], labelData.size, globals.fonts["default"], vertexBuffer, texcoordsBuffer, true, index); + index = addText([x,y,0], [1,0,0], lines2[i], labelData.size, globals.fonts['default'], vertexBuffer, texcoordsBuffer, true, index); y -= lineHeight; } diff --git a/src/core/map/geodata-processor/worker-polygon.js b/src/core/map/geodata-processor/worker-polygon.js index c2b313f2..c9490e4c 100755 --- a/src/core/map/geodata-processor/worker-polygon.js +++ b/src/core/map/geodata-processor/worker-polygon.js @@ -1,53 +1,53 @@ -import {globals as globals_} from "./worker-globals.js"; +import {globals as globals_} from './worker-globals.js'; var globals = globals_; -import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, getLayerExpresionValue as getLayerExpresionValue_} from "./worker-style.js"; +import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, getLayerExpresionValue as getLayerExpresionValue_} from './worker-style.js'; var getLayer = getLayer_, getLayerPropertyValue = getLayerPropertyValue_, getLayerExpresionValue = getLayerExpresionValue_; -import {postGroupMessage as postGroupMessage_} from "./worker-message.js"; +import {postGroupMessage as postGroupMessage_} from './worker-message.js'; var postGroupMessage = postGroupMessage_; //get rid of compiler mess var processPolygonPass = function(polygon, lod, style, zIndex, eventInfo) { - var vertices = polygon["vertices"] || []; + var vertices = polygon['vertices'] || []; if (vertices.length == 0) { return; } // borders as points - if (getLayerPropertyValue(style, "point", polygon, lod) || - getLayerPropertyValue(style, "label", polygon, lod)) { - processPolygonLines(polygon, vertices, lod, style, zIndex, eventInfo, false); + if (getLayerPropertyValue(style, 'point', polygon, lod) || + getLayerPropertyValue(style, 'label', polygon, lod)) { + processPolygonLines(polygon, vertices, lod, style, zIndex, eventInfo, false); } // borders as lines - if (getLayerPropertyValue(style, "line", polygon, lod) || - getLayerPropertyValue(style, "line-label", polygon, lod)) { - processPolygonLines(polygon, vertices, lod, style, zIndex, eventInfo, true); + if (getLayerPropertyValue(style, 'line', polygon, lod) || + getLayerPropertyValue(style, 'line-label', polygon, lod)) { + processPolygonLines(polygon, vertices, lod, style, zIndex, eventInfo, true); } - var spolygon = getLayerPropertyValue(style, "polygon", polygon, lod); + var spolygon = getLayerPropertyValue(style, 'polygon', polygon, lod); if (!spolygon) { return; } - var surface = polygon["surface"] || []; + var surface = polygon['surface'] || []; if (surface.length == 0) { return; } - var hoverEvent = getLayerPropertyValue(style, "hover-event", polygon, lod); - var clickEvent = getLayerPropertyValue(style, "click-event", polygon, lod); - var drawEvent = getLayerPropertyValue(style, "draw-event", polygon, lod); - var enterEvent = getLayerPropertyValue(style, "enter-event", polygon, lod); - var leaveEvent = getLayerPropertyValue(style, "leave-event", polygon, lod); + var hoverEvent = getLayerPropertyValue(style, 'hover-event', polygon, lod); + var clickEvent = getLayerPropertyValue(style, 'click-event', polygon, lod); + var drawEvent = getLayerPropertyValue(style, 'draw-event', polygon, lod); + var enterEvent = getLayerPropertyValue(style, 'enter-event', polygon, lod); + var leaveEvent = getLayerPropertyValue(style, 'leave-event', polygon, lod); - var zbufferOffset = getLayerPropertyValue(style, "zbuffer-offset", polygon, lod); + var zbufferOffset = getLayerPropertyValue(style, 'zbuffer-offset', polygon, lod); - var polygonColor = getLayerPropertyValue(style, "polygon-color", polygon, lod); + var polygonColor = getLayerPropertyValue(style, 'polygon-color', polygon, lod); var center = [0,0,0]; @@ -104,12 +104,12 @@ var processPolygonPass = function(polygon, lod, style, zIndex, eventInfo) { var hitable = hoverEvent || clickEvent || enterEvent || leaveEvent; - var messageData = {"command":"addRenderJob", "type": "flat-line", "vertexBuffer": vertexBuffer, - "color":polygonColor, "z-index":zIndex, "center": center, - "hover-event":hoverEvent, "click-event":clickEvent, "draw-event":drawEvent, - "hitable":hitable, "state":globals.hitState, "eventInfo":eventInfo, - "enter-event":enterEvent, "leave-event":leaveEvent, "zbuffer-offset":zbufferOffset, - "lod":(globals.autoLod ? null : globals.tileLod) }; + var messageData = {'command':'addRenderJob', 'type': 'flat-line', 'vertexBuffer': vertexBuffer, + 'color':polygonColor, 'z-index':zIndex, 'center': center, + 'hover-event':hoverEvent, 'click-event':clickEvent, 'draw-event':drawEvent, + 'hitable':hitable, 'state':globals.hitState, 'eventInfo':eventInfo, + 'enter-event':enterEvent, 'leave-event':leaveEvent, 'zbuffer-offset':zbufferOffset, + 'lod':(globals.autoLod ? null : globals.tileLod) }; postGroupMessage(messageData); }; @@ -117,7 +117,7 @@ var processPolygonPass = function(polygon, lod, style, zIndex, eventInfo) { var createEmptyFeatureFromPolygon = function(polygon) { var feature = {}; for(var key in polygon) { - if(key != "surface" && key != "vertices" && key != "borders") { + if(key != 'surface' && key != 'vertices' && key != 'borders') { feature[key] = polygon[key]; } } @@ -125,7 +125,7 @@ var createEmptyFeatureFromPolygon = function(polygon) { }; var processPolygonLines = function(polygon, vertices, lod, style, zIndex, eventInfo, processLines) { - var borders = polygon["borders"] || []; + var borders = polygon['borders'] || []; if (borders.length == 0) { return; } @@ -149,7 +149,7 @@ var processPolygonLines = function(polygon, vertices, lod, style, zIndex, eventI points[pointsCount] = points[0]; } } - feature["points"] = points; + feature['points'] = points; if(processLines) { processLineStringPass(feature, lod, style, zIndex, eventInfo); } diff --git a/src/core/map/geodata-processor/worker-style.js b/src/core/map/geodata-processor/worker-style.js index 93c8ae53..f76f8d1b 100755 --- a/src/core/map/geodata-processor/worker-style.js +++ b/src/core/map/geodata-processor/worker-style.js @@ -1,5 +1,5 @@ -import {globals as globals_} from "./worker-globals.js"; +import {globals as globals_} from './worker-globals.js'; //get rid of compiler mess var globals = globals_; @@ -8,7 +8,7 @@ var globals = globals_; var getLayer = function(layerId, featureType, index) { var layer = globals.stylesheetData.layers[layerId]; if (layer == null) { - logError("wrong-Layer", layerId, null, null, index, featureType); + logError('wrong-Layer', layerId, null, null, index, featureType); return {}; } else { return layer; @@ -19,23 +19,23 @@ var getLayer = function(layerId, featureType, index) { var getLayerExpresionValue = function(layer, value, feature, lod) { switch(typeof value) { - case "string": + case 'string': - if (value.length > 0) { + if (value.length > 0) { //is it feature property? - switch (value.charAt(0)) { + switch (value.charAt(0)) { - case "$": - var finalValue = feature.properties[value.substr(1)]; - if (typeof finalValue == "undefined") { - logError("wrong-expresion", layer["$$layer-id"], value, value, null, "feature-property"); - } - - return finalValue; + case '$': + var finalValue = feature.properties[value.substr(1)]; + if (typeof finalValue == 'undefined') { + logError('wrong-expresion', layer['$$layer-id'], value, value, null, 'feature-property'); } + + return finalValue; } + } - break; + break; } return value; @@ -46,133 +46,133 @@ var getLayerPropertyValue = function(layer, key, feature, lod) { var value = layer[key]; switch(typeof value) { - case "string": + case 'string': - if (value.length > 0) { + if (value.length > 0) { //is it feature property? - if (value.charAt(0) == "$") { - var finalValue = feature.properties[value.substr(1)]; - if (finalValue != null) { - return finalValue; - } else { - logError("wrong-object", layer["$$layer-id"], key, value, null, "feature-property"); - getDefaultLayerPropertyValue(key); - } + if (value.charAt(0) == '$') { + var finalValue = feature.properties[value.substr(1)]; + if (finalValue != null) { + return finalValue; + } else { + logError('wrong-object', layer['$$layer-id'], key, value, null, 'feature-property'); + getDefaultLayerPropertyValue(key); } } + } - return value; + return value; - break; + break; - case "object": + case 'object': //is it null? - if (value == null) { - return getDefaultLayerPropertyValue(key); - } + if (value == null) { + return getDefaultLayerPropertyValue(key); + } //is it array (rgb, rgba, vec2)? - if (Array.isArray(value)) { + if (Array.isArray(value)) { - if (key == "icon-source" && globals.stylesheetBitmaps[value[0]] == null) { - logError("wrong-object", layer["$$layer-id"], key, value, null, "bitmap"); - return getDefaultLayerPropertyValue(key); - } - - return value; + if (key == 'icon-source' && globals.stylesheetBitmaps[value[0]] == null) { + logError('wrong-object', layer['$$layer-id'], key, value, null, 'bitmap'); + return getDefaultLayerPropertyValue(key); } + return value; + } + //debugger - var stops = null; - var lodScaledArray = null; + var stops = null; + var lodScaledArray = null; - if (value["lod-scaled"] != null) { - var array = value["lod-scaled"]; + if (value['lod-scaled'] != null) { + var array = value['lod-scaled']; - if ((typeof array[1]) == "number") { - return array[1] * Math.pow(2*array[2], array[0] - lod); - } + if ((typeof array[1]) == 'number') { + return array[1] * Math.pow(2*array[2], array[0] - lod); + } - stops = array[1]; - lodScaledArray = array; + stops = array[1]; + lodScaledArray = array; - } else { - stops = value["discrete"] || value["linear"]; - } + } else { + stops = value['discrete'] || value['linear']; + } - var lastLod = stops[0][0]; - var lastValue = stops[0][1]; - var valueType = (typeof lastValue); - var newValue = lastValue; + var lastLod = stops[0][0]; + var lastValue = stops[0][1]; + var valueType = (typeof lastValue); + var newValue = lastValue; - for (var i = 0, li = stops.length; i <= li; i++) { + for (var i = 0, li = stops.length; i <= li; i++) { - if (i == li) { + if (i == li) { + newValue = lastValue; + break; + } + + if (stops[i][0] > lod) { + + if (value['discrete'] != null || lodScaledArray != null) { //no interpolation newValue = lastValue; break; - } + } else { //interpolate - if (stops[i][0] > lod) { + currentLod = stops[i][0]; + currentValue = stops[i][1]; - if (value["discrete"] != null || lodScaledArray != null) { //no interpolation - newValue = lastValue; + if (currentLod == lastLod) { //end of array no interpolation needed break; - } else { //interpolate - - currentLod = stops[i][0]; - currentValue = stops[i][1]; - - if (currentLod == lastLod) { //end of array no interpolation needed - break; - } + } - switch(valueType) { + switch(valueType) { - case "boolean": - lastValue = lastValue ? 1 : 0; - currentValue = lastValue ? 1 : 0; - var newValue = lastValue + (currentValue - lastValue) * ((lod - lastLod) / (currentLod - lastLod)); + case 'boolean': + lastValue = lastValue ? 1 : 0; + currentValue = lastValue ? 1 : 0; + var newValue = lastValue + (currentValue - lastValue) * ((lod - lastLod) / (currentLod - lastLod)); - newValue = newValue > 0.5 ? true : false; - break; + newValue = newValue > 0.5 ? true : false; + break; - case "number": + case 'number': //debugger - var newValue = lastValue + (currentValue - lastValue) * ((lod - lastLod) / (currentLod - lastLod)); - break; - - case "object": - var newValue = []; + var newValue = lastValue + (currentValue - lastValue) * ((lod - lastLod) / (currentLod - lastLod)); + break; - for (var j = 0, lj= lastValue.length; j < lj; j++) { - newValue[j] = lastValue[j] + (currentValue[j] - lastValue[j]) * ((lod - lastLod) / (currentLod - lastLod)); - } + case 'object': + var newValue = []; - break; + for (var j = 0, lj= lastValue.length; j < lj; j++) { + newValue[j] = lastValue[j] + (currentValue[j] - lastValue[j]) * ((lod - lastLod) / (currentLod - lastLod)); } break; } - } - lastLod = stops[i][0]; - lastValue = stops[i][1]; + break; + } } - if (lodScaledArray != null) { - newValue *= Math.pow(2*lodScaledArray[2], lodScaledArray[0] - lod); - } + lastLod = stops[i][0]; + lastValue = stops[i][1]; + } - return newValue; + if (lodScaledArray != null) { + newValue *= Math.pow(2*lodScaledArray[2], lodScaledArray[0] - lod); + } - break; + return newValue; - case "number": - case "boolean": - return value; + break; + + case 'number': + case 'boolean': + return value; } return getDefaultLayerPropertyValue(key); @@ -181,19 +181,19 @@ var getLayerPropertyValue = function(layer, key, feature, lod) { var inheritLayer = function(layerId, layer, layerData, stylesheetLayersData, depth) { if (depth > 100) { - logError("custom", "infinite inherit loop in Layer: " + layerId); + logError('custom', 'infinite inherit loop in Layer: ' + layerId); return; } //do we need inherite Layer? - if (layerData["inherit"] != null) { + if (layerData['inherit'] != null) { //get inherited Layer - var LayerToInherit = stylesheetLayersData["layers"][layerData["inherit"]]; + var LayerToInherit = stylesheetLayersData['layers'][layerData['inherit']]; if (LayerToInherit != null) { - if (LayerToInherit["inherit"] != null) { - inheritLayer(layerData["inherit"], layer, LayerToInherit, stylesheetLayersData, depth++); + if (LayerToInherit['inherit'] != null) { + inheritLayer(layerData['inherit'], layer, LayerToInherit, stylesheetLayersData, depth++); } //copy inherited Layer properties @@ -201,7 +201,7 @@ var inheritLayer = function(layerId, layer, layerData, stylesheetLayersData, dep layer[key] = LayerToInherit[key]; } } else { - logError("wrong-object", layerId, "inherit", LayerToInherit, "Layer"); + logError('wrong-object', layerId, 'inherit', LayerToInherit, 'Layer'); return getDefaultLayerPropertyValue(key); } } @@ -210,7 +210,7 @@ var inheritLayer = function(layerId, layer, layerData, stylesheetLayersData, dep var copyLayer = function(layerId, layer, layerData, stylesheetLayersData) { //do we need inherite Layer? - if (layerData["inherit"] != null) { + if (layerData['inherit'] != null) { inheritLayer(layerId, layer, layerData, stylesheetLayersData, 0); } @@ -221,45 +221,45 @@ var copyLayer = function(layerId, layer, layerData, stylesheetLayersData) { } //store layer id - layer["$$layer-id"] = layerId; + layer['$$layer-id'] = layerId; }; var logError = function(errorType, layerId, key, value, index, subkey) { - if ((typeof value) == "object") { + if ((typeof value) == 'object') { value = JSON.stringify(value); } var str = null; switch(errorType) { - case "wrong-property-value": - str = "Error: wrong layer property " + (subkey ? ("'" + subkey + "'") : "") + ": " + layerId + "." + key + " = " + value; - break; + case 'wrong-property-value': + str = 'Error: wrong layer property ' + (subkey ? ('"' + subkey + '"') : '') + ': ' + layerId + '.' + key + ' = ' + value; + break; - case "wrong-property-value[]": - str = "Error: wrong layer property " + (subkey ? ("'" + subkey + "'") : "") + "["+index+"]: " + layerId + "." + key + " = " + value; - break; + case 'wrong-property-value[]': + str = 'Error: wrong layer property ' + (subkey ? ('"' + subkey + '"') : '') + '['+index+']: ' + layerId + '.' + key + ' = ' + value; + break; - case "wrong-object": - str = "Error: reffered "+ subkey + " does not exist: " + layerId + "." + key + " = " + value; - break; + case 'wrong-object': + str = 'Error: reffered '+ subkey + ' does not exist: ' + layerId + '.' + key + ' = ' + value; + break; - case "wrong-object[]": - str = "Error: reffered "+ subkey + " does not exist: " + layerId + "." + key + "["+index+"] = " + value; - break; + case 'wrong-object[]': + str = 'Error: reffered '+ subkey + ' does not exist: ' + layerId + '.' + key + '['+index+'] = ' + value; + break; - case "wrong-Layer": - str = "Error: reffered "+ subkey + " Layer does not exist: " + subkey + "["+index+"].Layer = " + layerId; - break; + case 'wrong-Layer': + str = 'Error: reffered '+ subkey + ' Layer does not exist: ' + subkey + '['+index+'].Layer = ' + layerId; + break; - case "wrong-bitmap": - str = "Error: wrong definition of bitmap: " + layerId; - break; + case 'wrong-bitmap': + str = 'Error: wrong definition of bitmap: ' + layerId; + break; - case "custom": - str = "Error: " + layerId; - break; + case 'custom': + str = 'Error: ' + layerId; + break; } if (str) { @@ -270,17 +270,17 @@ var logError = function(errorType, layerId, key, value, index, subkey) { var validateValue = function(layerId, key, value, type, arrayLength, min, max) { //check interpolator - if (value != null && (typeof value) == "object" && (value["discrete"] != null || value["linear"] != null || value["lod-scaled"] != null)) { + if (value != null && (typeof value) == 'object' && (value['discrete'] != null || value['linear'] != null || value['lod-scaled'] != null)) { var stops = null; var lodScaled = false; - if (value["lod-scaled"] != null) { + if (value['lod-scaled'] != null) { - var array = value["lod-scaled"]; + var array = value['lod-scaled']; - if (!((typeof array) == "object" && Array.isArray(array) && array.length >= 2)) { - logError("wrong-property-value", layerId, key, value, null, "[]"); + if (!((typeof array) == 'object' && Array.isArray(array) && array.length >= 2)) { + logError('wrong-property-value', layerId, key, value, null, '[]'); return getDefaultLayerPropertyValue(key); } @@ -288,12 +288,12 @@ var validateValue = function(layerId, key, value, type, arrayLength, min, max) { array[2] = 1; } - if (!((typeof array[0]) == "number" && (typeof array[2]) == "number")) { - logError("wrong-property-value", layerId, key, value, null, "[]"); + if (!((typeof array[0]) == 'number' && (typeof array[2]) == 'number')) { + logError('wrong-property-value', layerId, key, value, null, '[]'); return getDefaultLayerPropertyValue(key); } - if ((typeof array[1]) == "number") { + if ((typeof array[1]) == 'number') { return value; } @@ -301,12 +301,12 @@ var validateValue = function(layerId, key, value, type, arrayLength, min, max) { lodScaled = true; } else { - stops = value["discrete"] || value["linear"]; + stops = value['discrete'] || value['linear']; } //if stops exist then check if they are array - if (stops == null || !((typeof stops) == "object" && Array.isArray(stops) && stops.length > 0)) { - logError("wrong-property-value", layerId, key, value, null, "[]"); + if (stops == null || !((typeof stops) == 'object' && Array.isArray(stops) && stops.length > 0)) { + logError('wrong-property-value', layerId, key, value, null, '[]'); return getDefaultLayerPropertyValue(key); } @@ -319,28 +319,28 @@ var validateValue = function(layerId, key, value, type, arrayLength, min, max) { var stopItem = stops[i]; //is stop array[2]? - if(!(stopItem != null && (typeof stopItem) == "object" && Array.isArray(stopItem) && stopItem.length != 2)) { + if(!(stopItem != null && (typeof stopItem) == 'object' && Array.isArray(stopItem) && stopItem.length != 2)) { //store fist stop type if (stopsValueType == null) { stopsValueType = typeof stopItem[1]; - if (lodScaled && stopsValueType != "number") { - logError("wrong-property-value[]", layerId, key, value, i, "[]"); + if (lodScaled && stopsValueType != 'number') { + logError('wrong-property-value[]', layerId, key, value, i, '[]'); return getDefaultLayerPropertyValue(key); } } //check lod value and type of value - if(!((typeof stopItem[0]) == "number" && (typeof stopItem[1]) == stopsValueType)) { - logError("wrong-property-value[]", layerId, key, value, i, "[]"); + if(!((typeof stopItem[0]) == 'number' && (typeof stopItem[1]) == stopsValueType)) { + logError('wrong-property-value[]', layerId, key, value, i, '[]'); return getDefaultLayerPropertyValue(key); } //check number value - if (stopsValueType == "number") { + if (stopsValueType == 'number') { if (stopItem[1] > max || stopItem[1] < min) { - logError("wrong-property-value[]", layerId, key, value, i, "[]"); + logError('wrong-property-value[]', layerId, key, value, i, '[]'); return getDefaultLayerPropertyValue(key); } } @@ -357,8 +357,8 @@ var validateValue = function(layerId, key, value, type, arrayLength, min, max) { //check value type if ((typeof value) != type) { //check for exceptions - if (!(value === null && (key == "icon-source" || key == "visibility"))) { - logError("wrong-property-value", layerId, key, value); + if (!(value === null && (key == 'icon-source' || key == 'visibility'))) { + logError('wrong-property-value', layerId, key, value); return getDefaultLayerPropertyValue(key); } } @@ -366,139 +366,139 @@ var validateValue = function(layerId, key, value, type, arrayLength, min, max) { //check value switch(typeof value) { - case "object": + case 'object': //accepted cases for null value - if (value === null && (key == "line-style-texture" || key == "icon-source" || key == "visibility" || key == "next-pass")) { - return value; - } + if (value === null && (key == 'line-style-texture' || key == 'icon-source' || key == 'visibility' || key == 'next-pass')) { + return value; + } //check multipasss - if (key == "next-pass") { - if (Array.isArray(value) && value.length > 0) { + if (key == 'next-pass') { + if (Array.isArray(value) && value.length > 0) { - for (var i = 0; i < li; i++) { - var valueItem = value[i]; + for (var i = 0; i < li; i++) { + var valueItem = value[i]; - if (typeof valueItem == "object" && + if (typeof valueItem == 'object' && Array.isArray(valueItem) && valueItem.length == 2 && - typeof valueItem[0] == "number" && - typeof valueItem[1] == "string") { + typeof valueItem[0] == 'number' && + typeof valueItem[1] == 'string') { - if (stylesheetLayersData["layers"][valueItem[1]] == null) { + if (stylesheetLayersData['layers'][valueItem[1]] == null) { - } - - } else { - logError("wrong-property-value[]", layerId, key, value, i); - return getDefaultLayerPropertyValue(key); } - } - } else { - logError("wrong-property-value", layerId, key, value); - return getDefaultLayerPropertyValue(key); + } else { + logError('wrong-property-value[]', layerId, key, value, i); + return getDefaultLayerPropertyValue(key); + } } + + } else { + logError('wrong-property-value', layerId, key, value); + return getDefaultLayerPropertyValue(key); } + } //check array - if (arrayLength != null) { - if (Array.isArray(value) && value.length == arrayLength) { + if (arrayLength != null) { + if (Array.isArray(value) && value.length == arrayLength) { //validate array values - var i = 0; - - if (key == "icon-source" || key == "line-style-texture") { - if (typeof value[0] != "string") { - logError("wrong-property-value[]", layerId, key, value, 0); - return getDefaultLayerPropertyValue(key); - } - - if (globals.stylesheetBitmaps[value[0]] == null) { - logError("wrong-object", layerId, key, value, null, "bitmap"); - return getDefaultLayerPropertyValue(key); - } + var i = 0; - i = 1; + if (key == 'icon-source' || key == 'line-style-texture') { + if (typeof value[0] != 'string') { + logError('wrong-property-value[]', layerId, key, value, 0); + return getDefaultLayerPropertyValue(key); } - for (li = value.length; i < li; i++) { - if (typeof value[i] != "number") { - logError("wrong-property-value[]", layerId, key, value, i); - return getDefaultLayerPropertyValue(key); - } + if (globals.stylesheetBitmaps[value[0]] == null) { + logError('wrong-object', layerId, key, value, null, 'bitmap'); + return getDefaultLayerPropertyValue(key); } - return value; - } else { - logError("wrong-property-value", layerId, key, value); - return getDefaultLayerPropertyValue(key); + i = 1; } + + for (li = value.length; i < li; i++) { + if (typeof value[i] != 'number') { + logError('wrong-property-value[]', layerId, key, value, i); + return getDefaultLayerPropertyValue(key); + } + } + + return value; + } else { + logError('wrong-property-value', layerId, key, value); + return getDefaultLayerPropertyValue(key); } + } - return value; + return value; - case "string": + case 'string': //validate line Layer enum - if (key == "line-style") { - switch(value) { - case "solid": - case "texture": return value; - default: - logError("wrong-property-value", layerId, key, value); - return getDefaultLayerPropertyValue(key); - } + if (key == 'line-style') { + switch(value) { + case 'solid': + case 'texture': return value; + default: + logError('wrong-property-value', layerId, key, value); + return getDefaultLayerPropertyValue(key); } + } //validate origin enum - if (key == "label-origin" || key == "icon-origin") { - switch(value) { - case "top-left": - case "top-right": - case "top-center": - case "center-left": - case "center-right": - case "center-center": - case "bottom-left": - case "bottom-right": - case "bottom-center": return value; - default: - logError("wrong-property-value", layerId, key, value); - return getDefaultLayerPropertyValue(key); - } + if (key == 'label-origin' || key == 'icon-origin') { + switch(value) { + case 'top-left': + case 'top-right': + case 'top-center': + case 'center-left': + case 'center-right': + case 'center-center': + case 'bottom-left': + case 'bottom-right': + case 'bottom-center': return value; + default: + logError('wrong-property-value', layerId, key, value); + return getDefaultLayerPropertyValue(key); } + } //validate align enum - if (key == "label-align") { - switch(value) { - case "left": - case "right": - case "center": return value; - default: - logError("wrong-property-value", layerId, key, value); - return getDefaultLayerPropertyValue(key); - } + if (key == 'label-align') { + switch(value) { + case 'left': + case 'right': + case 'center': return value; + default: + logError('wrong-property-value', layerId, key, value); + return getDefaultLayerPropertyValue(key); } + } - return value; + return value; - case "number": + case 'number': //console.log("num2"); - if (value > max || value < min) { - logError("wrong-property-value", layerId, key, value); - return getDefaultLayerPropertyValue(key); - } + if (value > max || value < min) { + logError('wrong-property-value', layerId, key, value); + return getDefaultLayerPropertyValue(key); + } //console.log("num3"); - return value; + return value; - case "boolean": - return value; + case 'boolean': + return value; } }; @@ -510,64 +510,64 @@ var validateLayerPropertyValue = function(layerId, key, value) { switch(key) { //case "filter" : return validateValue(layerId, key, value, "string"); break; - case "inherit" : return validateValue(layerId, key, value, "string"); break; - - case "line": return validateValue(layerId, key, value, "boolean"); break; - case "line-flat": return validateValue(layerId, key, value, "boolean"); break; - case "line-width": return validateValue(layerId, key, value, "number", null, 0.0001, Number.MAXVALUE); break; - case "line-color": return validateValue(layerId, key, value, "object", 4, 0, 255); break; - case "line-style": return validateValue(layerId, key, value, "string"); break; - case "line-style-texture": return validateValue(layerId, key, value, "object", 3, -Number.MAXVALUE, Number.MAXVALUE); break; - case "line-style-background": return validateValue(layerId, key, value, "object", 4, 0, 255); break; - - case "line-label": return validateValue(layerId, key, value, "boolean"); break; - case "line-label-source": return validateValue(layerId, key, value, "string"); break; - case "line-label-color": return validateValue(layerId, key, value, "object", 4, 0, 255); break; - case "line-label-size": return validateValue(layerId, key, value, "number", null, 0.0001, Number.MAXVALUE); break; - case "line-label-offset": return validateValue(layerId, key, value, "number", null, -Number.MAXVALUE, Number.MAXVALUE); break; - - case "point": return validateValue(layerId, key, value, "boolean"); break; - case "point-flat": return validateValue(layerId, key, value, "boolean"); break; - case "point-radius": return validateValue(layerId, key, value, "number", null, 0.0001, Number.MAXVALUE); break; - case "point-Layer": return validateValue(layerId, key, value, "string"); break; - - case "point-color": return validateValue(layerId, key, value, "object", 4, 0, 255); break; - - case "icon": return validateValue(layerId, key, value, "boolean"); break; - case "icon-source": return validateValue(layerId, key, value, "object", 5, -Number.MAXVALUE, Number.MAXVALUE); break; - case "icon-scale": return validateValue(layerId, key, value, "number", null, 0.0001, Number.MAXVALUE); break; - case "icon-offset": return validateValue(layerId, key, value, "object", 2, -Number.MAXVALUE, Number.MAXVALUE); break; - case "icon-origin": return validateValue(layerId, key, value, "string"); break; - case "icon-stick": return validateValue(layerId, key, value, "object", 7, -Number.MAXVALUE, Number.MAXVALUE); break; - case "icon-color": return validateValue(layerId, key, value, "object", 4, 0, 255); break; - - case "label": return validateValue(layerId, key, value, "boolean"); break; - case "label-color": return validateValue(layerId, key, value, "object", 4, 0, 255); break; - case "label-source": return validateValue(layerId, key, value, "string"); break; - case "label-size": return validateValue(layerId, key, value, "number", null, 0.0001, Number.MAXVALUE); break; - case "label-offset": return validateValue(layerId, key, value, "object", 2, -Number.MAXVALUE, Number.MAXVALUE); break; - case "label-origin": return validateValue(layerId, key, value, "string"); break; - case "label-align": return validateValue(layerId, key, value, "string"); break; - case "label-stick": return validateValue(layerId, key, value, "object", 7, -Number.MAXVALUE, Number.MAXVALUE); break; - case "label-width": return validateValue(layerId, key, value, "number", null, 0.0001, Number.MAXVALUE); break; - - case "polygon": return validateValue(styleId, key, value, "boolean"); break; - case "polygon-color": return validateValue(styleId, key, value, "object", 4, 0, 255); break; - - case "z-index": return validateValue(layerId, key, value, "number", null, -Number.MAXVALUE, Number.MAXVALUE); break; - case "zbuffer-offset": return validateValue(layerId, key, value, "object", 3, 0, Number.MAXVALUE); break; - - case "hover-event": return validateValue(layerId, key, value, "boolean"); break; - case "hover-layer": return validateValue(layerId, key, value, "string"); break; - case "enter-event": return validateValue(layerId, key, value, "boolean"); break; - case "leave-event": return validateValue(layerId, key, value, "boolean"); break; - case "click-event": return validateValue(layerId, key, value, "boolean"); break; - case "draw-event": return validateValue(layerId, key, value, "boolean"); break; - - case "visible": return validateValue(layerId, key, value, "boolean"); break; - case "visibility": return validateValue(layerId, key, value, "number", null, 0.0001, Number.MAXVALUE); break; - case "culling": return validateValue(layerId, key, value, "number", 180, 0.0001, 180); break; - case "next-pass": return validateValue(layerId, key, value, "object"); break; + case 'inherit' : return validateValue(layerId, key, value, 'string'); break; + + case 'line': return validateValue(layerId, key, value, 'boolean'); break; + case 'line-flat': return validateValue(layerId, key, value, 'boolean'); break; + case 'line-width': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; + case 'line-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; + case 'line-style': return validateValue(layerId, key, value, 'string'); break; + case 'line-style-texture': return validateValue(layerId, key, value, 'object', 3, -Number.MAXVALUE, Number.MAXVALUE); break; + case 'line-style-background': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; + + case 'line-label': return validateValue(layerId, key, value, 'boolean'); break; + case 'line-label-source': return validateValue(layerId, key, value, 'string'); break; + case 'line-label-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; + case 'line-label-size': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; + case 'line-label-offset': return validateValue(layerId, key, value, 'number', null, -Number.MAXVALUE, Number.MAXVALUE); break; + + case 'point': return validateValue(layerId, key, value, 'boolean'); break; + case 'point-flat': return validateValue(layerId, key, value, 'boolean'); break; + case 'point-radius': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; + case 'point-Layer': return validateValue(layerId, key, value, 'string'); break; + + case 'point-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; + + case 'icon': return validateValue(layerId, key, value, 'boolean'); break; + case 'icon-source': return validateValue(layerId, key, value, 'object', 5, -Number.MAXVALUE, Number.MAXVALUE); break; + case 'icon-scale': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; + case 'icon-offset': return validateValue(layerId, key, value, 'object', 2, -Number.MAXVALUE, Number.MAXVALUE); break; + case 'icon-origin': return validateValue(layerId, key, value, 'string'); break; + case 'icon-stick': return validateValue(layerId, key, value, 'object', 7, -Number.MAXVALUE, Number.MAXVALUE); break; + case 'icon-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; + + case 'label': return validateValue(layerId, key, value, 'boolean'); break; + case 'label-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; + case 'label-source': return validateValue(layerId, key, value, 'string'); break; + case 'label-size': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; + case 'label-offset': return validateValue(layerId, key, value, 'object', 2, -Number.MAXVALUE, Number.MAXVALUE); break; + case 'label-origin': return validateValue(layerId, key, value, 'string'); break; + case 'label-align': return validateValue(layerId, key, value, 'string'); break; + case 'label-stick': return validateValue(layerId, key, value, 'object', 7, -Number.MAXVALUE, Number.MAXVALUE); break; + case 'label-width': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; + + case 'polygon': return validateValue(styleId, key, value, 'boolean'); break; + case 'polygon-color': return validateValue(styleId, key, value, 'object', 4, 0, 255); break; + + case 'z-index': return validateValue(layerId, key, value, 'number', null, -Number.MAXVALUE, Number.MAXVALUE); break; + case 'zbuffer-offset': return validateValue(layerId, key, value, 'object', 3, 0, Number.MAXVALUE); break; + + case 'hover-event': return validateValue(layerId, key, value, 'boolean'); break; + case 'hover-layer': return validateValue(layerId, key, value, 'string'); break; + case 'enter-event': return validateValue(layerId, key, value, 'boolean'); break; + case 'leave-event': return validateValue(layerId, key, value, 'boolean'); break; + case 'click-event': return validateValue(layerId, key, value, 'boolean'); break; + case 'draw-event': return validateValue(layerId, key, value, 'boolean'); break; + + case 'visible': return validateValue(layerId, key, value, 'boolean'); break; + case 'visibility': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; + case 'culling': return validateValue(layerId, key, value, 'number', 180, 0.0001, 180); break; + case 'next-pass': return validateValue(layerId, key, value, 'object'); break; } return value; //custom property @@ -576,65 +576,65 @@ var validateLayerPropertyValue = function(layerId, key, value) { var getDefaultLayerPropertyValue = function(key) { switch(key) { - case "filter": return null; - - case "inherit": return ""; - - case "line": return false; - case "line-flat": return false; - case "line-width": return 1; - case "line-color": return [255,255,255,255]; - case "line-style": return "solid"; - case "line-style-texture": return null; - case "line-style-background": return [0,0,0,0]; - - case "line-label": return false; - case "line-label-color": return [255,255,255,255]; - case "line-label-source": return "$name"; - case "line-label-size": return 1; - case "line-label-offset": return 0; - - case "point": return false; - case "point-flat": return false; - case "point-radius": return 1; - case "point-Layer": return "solid"; - case "point-color": return [255,255,255,255]; - - case "icon": return false; - case "icon-source": return null; - case "icon-scale": return 1; - case "icon-offset": return [0,0]; - case "icon-origin": return "bottom-center"; - case "icon-stick": return [0,0,0,255,255,255,255]; - case "icon-color": return [255,255,255,255]; - - case "label": return false; - case "label-color": return [255,255,255,255]; - case "label-source": return "$name"; - case "label-size": return 10; - case "label-offset": return [0,0]; - case "label-origin": return "bottom-center"; - case "label-align": return "center"; - case "label-stick": return [0,0,0,255,255,255,255]; - case "label-width": return 200; + case 'filter': return null; + + case 'inherit': return ''; + + case 'line': return false; + case 'line-flat': return false; + case 'line-width': return 1; + case 'line-color': return [255,255,255,255]; + case 'line-style': return 'solid'; + case 'line-style-texture': return null; + case 'line-style-background': return [0,0,0,0]; + + case 'line-label': return false; + case 'line-label-color': return [255,255,255,255]; + case 'line-label-source': return '$name'; + case 'line-label-size': return 1; + case 'line-label-offset': return 0; + + case 'point': return false; + case 'point-flat': return false; + case 'point-radius': return 1; + case 'point-Layer': return 'solid'; + case 'point-color': return [255,255,255,255]; + + case 'icon': return false; + case 'icon-source': return null; + case 'icon-scale': return 1; + case 'icon-offset': return [0,0]; + case 'icon-origin': return 'bottom-center'; + case 'icon-stick': return [0,0,0,255,255,255,255]; + case 'icon-color': return [255,255,255,255]; + + case 'label': return false; + case 'label-color': return [255,255,255,255]; + case 'label-source': return '$name'; + case 'label-size': return 10; + case 'label-offset': return [0,0]; + case 'label-origin': return 'bottom-center'; + case 'label-align': return 'center'; + case 'label-stick': return [0,0,0,255,255,255,255]; + case 'label-width': return 200; - case "polygon": return false; - case "polygon-color": return [255,255,255,255]; - - case "z-index": return 0; - case "zbuffer-offset": return [0,0,0]; - - case "hover-event": return false; - case "hover-layer": return ""; - case "enter-event": return false; - case "leave-event": return false; - case "click-event": return false; - case "draw-event": return false; - - case "visible": return true; - case "visibility": return 0; - case "culling": return 180; - case "next-pass": return null; + case 'polygon': return false; + case 'polygon-color': return [255,255,255,255]; + + case 'z-index': return 0; + case 'zbuffer-offset': return [0,0,0]; + + case 'hover-event': return false; + case 'hover-layer': return ''; + case 'enter-event': return false; + case 'leave-event': return false; + case 'click-event': return false; + case 'draw-event': return false; + + case 'visible': return true; + case 'visibility': return 0; + case 'culling': return 180; + case 'next-pass': return null; } }; @@ -645,82 +645,82 @@ function getFilterResult(filter, feature, featureType, group) { } switch(filter[0]) { - case "all": - var result = true; - for (var i = 1, li = filter.length; i < li; i++) { - result = result && getFilterResult(filter[i], feature, featureType, group); - } + case 'all': + var result = true; + for (var i = 1, li = filter.length; i < li; i++) { + result = result && getFilterResult(filter[i], feature, featureType, group); + } - return result; + return result; - case "any": - var result = false; - for (var i = 1, li = filter.length; i < li; i++) { - result = result || getFilterResult(filter[i], feature, featureType, group); - } + case 'any': + var result = false; + for (var i = 1, li = filter.length; i < li; i++) { + result = result || getFilterResult(filter[i], feature, featureType, group); + } - return result; + return result; - case "none": - var result = true; - for (var i = 1, li = filter.length; i < li; i++) { - result = result && getFilterResult(filter[i], feature, featureType, group); - } + case 'none': + var result = true; + for (var i = 1, li = filter.length; i < li; i++) { + result = result && getFilterResult(filter[i], feature, featureType, group); + } - return (!result); + return (!result); - case "skip": return false; + case 'skip': return false; } var value; switch(filter[1]) { - case "#type": value = featureType; break; - case "#group": value = group; break; - default: - var filterValue = filter[1]; + case '#type': value = featureType; break; + case '#group': value = group; break; + default: + var filterValue = filter[1]; - if (filterValue && filterValue.length > 0) { + if (filterValue && filterValue.length > 0) { //is it feature property? - switch (filterValue.charAt(0)) { - case "$": value = feature.properties[filterValue.substr(1)]; break; - case "@": value = globals.stylesheetConstants[filterValue]; break; - default: - value = feature.properties[filterValue]; //fallback for old format - } + switch (filterValue.charAt(0)) { + case '$': value = feature.properties[filterValue.substr(1)]; break; + case '@': value = globals.stylesheetConstants[filterValue]; break; + default: + value = feature.properties[filterValue]; //fallback for old format } + } } switch(filter[0]) { - case "==": return (value == filter[2]); - case "!=": return (value != filter[2]); - case ">=": return (value >= filter[2]); - case "<=": return (value <= filter[2]); - case ">": return (value > filter[2]); - case "<": return (value < filter[2]); + case '==': return (value == filter[2]); + case '!=': return (value != filter[2]); + case '>=': return (value >= filter[2]); + case '<=': return (value <= filter[2]); + case '>': return (value > filter[2]); + case '<': return (value < filter[2]); - case "has": return (typeof value != "undefined"); - case "!has": return (typeof value == "undefined"); + case 'has': return (typeof value != 'undefined'); + case '!has': return (typeof value == 'undefined'); - case "in": - for (var i = 2, li = filter.length; i < li; i++) { - if (filter[i] == value) { - return true; - } - } - return false; + case 'in': + for (var i = 2, li = filter.length; i < li; i++) { + if (filter[i] == value) { + return true; + } + } + return false; - case "!in": - for (var i = 2, li = filter.length; i < li; i++) { - if (filter[i] == value) { - return false; - } - } - return true; + case '!in': + for (var i = 2, li = filter.length; i < li; i++) { + if (filter[i] == value) { + return false; + } + } + return true; } return false; -}; +} var processLayer = function(layerId, layerData, stylesheetLayersData) { @@ -737,15 +737,15 @@ var processLayer = function(layerId, layerData, stylesheetLayersData) { var value = layer[key]; //replace constant with value - if ((typeof value) == "string") { + if ((typeof value) == 'string') { if (value.length > 0) { //is it constant? - if (value.charAt(0) == "@") { + if (value.charAt(0) == '@') { if (globals.stylesheetConstants[value] != null) { //replace constant with value layer[key] = globals.stylesheetConstants[value]; } else { - logError("wrong-object", layerId, key, value, null, "constant"); + logError('wrong-object', layerId, key, value, null, 'constant'); //replace constant with deafault value layer[key] = getDefaultLayerPropertyValue(key); @@ -768,24 +768,24 @@ var processLayer = function(layerId, layerData, stylesheetLayersData) { var processStylesheet = function(stylesheetLayersData) { globals.stylesheetBitmaps = {}; - globals.stylesheetConstants = stylesheetLayersData["constants"] || {}; + globals.stylesheetConstants = stylesheetLayersData['constants'] || {}; //get bitmaps - var bitmaps = stylesheetLayersData["bitmaps"] || {}; + var bitmaps = stylesheetLayersData['bitmaps'] || {}; //build map for (var key in bitmaps) { var bitmap = bitmaps[key]; var skip = false; - if ((typeof bitmap) == "string") { - bitmap = {"url":bitmap}; - } else if((typeof bitmap) == "object"){ - if (bitmap["url"] == null) { - logError("wrong-bitmap", key); + if ((typeof bitmap) == 'string') { + bitmap = {'url':bitmap}; + } else if((typeof bitmap) == 'object'){ + if (bitmap['url'] == null) { + logError('wrong-bitmap', key); } } else { - logError("wrong-bitmap", key); + logError('wrong-bitmap', key); } if (!skip) { @@ -794,14 +794,14 @@ var processStylesheet = function(stylesheetLayersData) { } //load bitmaps - postMessage({"command":"loadBitmaps", "bitmaps": globals.stylesheetBitmaps}); + postMessage({'command':'loadBitmaps', 'bitmaps': globals.stylesheetBitmaps}); //get layers globals.stylesheetData = { layers : {} }; - var layers = stylesheetLayersData["layers"] || {}; + var layers = stylesheetLayersData['layers'] || {}; //console.log(JSON.stringify(Layers)); diff --git a/src/core/map/geodata-processor/worker-text.js b/src/core/map/geodata-processor/worker-text.js index c86cc715..5fcba93e 100755 --- a/src/core/map/geodata-processor/worker-text.js +++ b/src/core/map/geodata-processor/worker-text.js @@ -1,6 +1,6 @@ import {globals as globals_, clamp as clamp_, vec3Normalize as vec3Normalize_, - vec3Length as vec3Length_, vec3Cross as vec3Cross_, vec3AnyPerpendicular as vec3AnyPerpendicular_} from "./worker-globals.js"; + vec3Length as vec3Length_, vec3Cross as vec3Cross_, vec3AnyPerpendicular as vec3AnyPerpendicular_} from './worker-globals.js'; //get rid of compiler mess var globals = globals_, clamp = clamp_, @@ -9,10 +9,10 @@ var globals = globals_, clamp = clamp_, var setFont = function(fontData) { - globals_.fonts["default"] = { - chars : fontData["chars"], - space : fontData["space"], - size : fontData["size"] + globals_.fonts['default'] = { + chars : fontData['chars'], + space : fontData['space'], + size : fontData['size'] }; }; @@ -216,8 +216,8 @@ var addTextOnPath = function(points, distance, text, size, textVector, font, ver //average dir var dir = [(posAndDir2[1][0] + posAndDir[1][0])*0.5, - (posAndDir2[1][1] + posAndDir[1][1])*0.5, - (posAndDir2[1][2] + posAndDir[1][2])*0.5]; + (posAndDir2[1][1] + posAndDir[1][1])*0.5, + (posAndDir2[1][2] + posAndDir[1][2])*0.5]; vec3Normalize(dir); @@ -351,8 +351,8 @@ var getPathPositionAndDirection = function(points, distance) { var factor = (distance - l) / (ll); var p = [p1[0] + dir[0] * factor, - p1[1] + dir[1] * factor, - p1[2] + dir[2] * factor]; + p1[1] + dir[1] * factor, + p1[2] + dir[2] * factor]; vec3Normalize(dir); @@ -409,7 +409,7 @@ var getPathTextVector = function(points, shift, text, factor, font) { var areTextCharactersAvailable = function(text, font) { - if (!text || text == "") { + if (!text || text == '') { return false; } diff --git a/src/core/map/geodata-view.js b/src/core/map/geodata-view.js index c1496e1c..8bbd403a 100755 --- a/src/core/map/geodata-view.js +++ b/src/core/map/geodata-view.js @@ -24,13 +24,13 @@ var MapGeodataView = function(map, geodata, extraInfo) { if (!this.surface.geodataProcessor) { var processor = new MapGeodataProcessor(this, this.onGeodataProcessorMessage.bind(this)); - processor.sendCommand("setStylesheet", { "data" : this.surface.stylesheet.data, "geocent" : (!this.map.getNavigationSrs().isProjected()) } ); - processor.sendCommand("setFont", {"chars" : this.renderer.font.chars, "space" : this.renderer.font.space, "size" : this.renderer.font.size}); + processor.sendCommand('setStylesheet', { 'data' : this.surface.stylesheet.data, 'geocent' : (!this.map.getNavigationSrs().isProjected()) } ); + processor.sendCommand('setFont', {'chars' : this.renderer.font.chars, 'space' : this.renderer.font.space, 'size' : this.renderer.font.size}); this.surface.geodataProcessor = processor; this.map.geodataProcessors.push(processor); } else { if (this.surface.styleChanged) { - this.surface.geodataProcessor.sendCommand("setStylesheet", { "data" : this.surface.stylesheet.data, "geocent" : (!this.map.getNavigationSrs().isProjected()) } ); + this.surface.geodataProcessor.sendCommand('setStylesheet', { 'data' : this.surface.stylesheet.data, 'geocent' : (!this.map.getNavigationSrs().isProjected()) } ); this.surface.styleChanged = false; } } @@ -82,66 +82,66 @@ MapGeodataView.prototype.onGeodataProcessorMessage = function(command, message, switch (command) { - case "beginGroup": + case 'beginGroup': - if (task) { - this.currentGpuGroup = new GpuGroup(message["id"], message["bbox"], message["origin"], this.gpu, this.renderer); - this.gpuGroups.push(this.currentGpuGroup); - } else { - this.map.markDirty(); - this.map.addProcessingTask(this.onGeodataProcessorMessage.bind(this, command, message, true)); - } + if (task) { + this.currentGpuGroup = new GpuGroup(message['id'], message['bbox'], message['origin'], this.gpu, this.renderer); + this.gpuGroups.push(this.currentGpuGroup); + } else { + this.map.markDirty(); + this.map.addProcessingTask(this.onGeodataProcessorMessage.bind(this, command, message, true)); + } - break; + break; - case "addRenderJob": + case 'addRenderJob': - if (task) { - if (this.currentGpuGroup) { - var t = performance.now(); - this.currentGpuGroup.addRenderJob(message); - this.stats.renderBuild += performance.now() - t; - } //else { + if (task) { + if (this.currentGpuGroup) { + var t = performance.now(); + this.currentGpuGroup.addRenderJob(message); + this.stats.renderBuild += performance.now() - t; + } //else { //message = message; //} - } else { - this.map.markDirty(); - this.map.addProcessingTask(this.onGeodataProcessorMessage.bind(this, command, message, true)); - } + } else { + this.map.markDirty(); + this.map.addProcessingTask(this.onGeodataProcessorMessage.bind(this, command, message, true)); + } - break; + break; - case "endGroup": + case 'endGroup': - if (task) { - if (this.currentGpuGroup) { + if (task) { + if (this.currentGpuGroup) { //this.currentGpuGroup.optimize(); - this.size += this.currentGpuGroup.size; - } //else { - } else { - this.map.markDirty(); - this.map.addProcessingTask(this.onGeodataProcessorMessage.bind(this, command, message, true)); - } + this.size += this.currentGpuGroup.size; + } //else { + } else { + this.map.markDirty(); + this.map.addProcessingTask(this.onGeodataProcessorMessage.bind(this, command, message, true)); + } - break; + break; - case "allProcessed": - this.map.markDirty(); - this.gpuCacheItem = this.map.gpuCache.insert(this.killGeodataView.bind(this, true), this.size); + case 'allProcessed': + this.map.markDirty(); + this.gpuCacheItem = this.map.gpuCache.insert(this.killGeodataView.bind(this, true), this.size); - this.stats.gpuGeodata += this.size; - this.stats.graphsFluxGeodata[0][0]++; - this.stats.graphsFluxGeodata[0][1] += this.size; + this.stats.gpuGeodata += this.size; + this.stats.graphsFluxGeodata[0][0]++; + this.stats.graphsFluxGeodata[0][1] += this.size; //console.log("geodata: " + this.size + " total: " + this.stats.gpuGeodata); - this.geodataProcessor.busy = false; - this.ready = true; - break; + this.geodataProcessor.busy = false; + this.ready = true; + break; - case "ready": - this.map.markDirty(); + case 'ready': + this.map.markDirty(); //this.ready = true; - break; + break; } }; @@ -159,7 +159,7 @@ MapGeodataView.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu) if (this.geodata.isReady(doNotLoad, priority, doNotCheckGpu) && this.geodataProcessor.isReady()) { this.killedByCache = false; this.geodataProcessor.setListener(this.onGeodataProcessorMessage.bind(this)); - this.geodataProcessor.sendCommand("processGeodata", this.geodata.geodata, this.tile); + this.geodataProcessor.sendCommand('processGeodata', this.geodata.geodata, this.tile); this.geodataProcessor.busy = true; } } diff --git a/src/core/map/geodata.js b/src/core/map/geodata.js index 669164a5..9ed6c425 100755 --- a/src/core/map/geodata.js +++ b/src/core/map/geodata.js @@ -44,7 +44,7 @@ MapGeodata.prototype.killGeodata = function(killedByCache) { } //if (this.gpuSubmeshes.length == 0) { - this.loadState = 0; + this.loadState = 0; //} this.size = 0; @@ -72,7 +72,7 @@ MapGeodata.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu) { //add to loading queue or top position in queue - if (typeof this.mapLoaderUrl === "object") { //use geodata directly + if (typeof this.mapLoaderUrl === 'object') { //use geodata directly this.geodata = JSON.stringify(this.mapLoaderUrl); this.loadState = 2; this.cacheItem = this.map.resourcesCache.insert(this.killGeodata.bind(this, true), this.geodata.length); @@ -100,7 +100,7 @@ MapGeodata.prototype.scheduleLoad = function(priority) { //this.mapLoaderUrl = this.map.url.makeUrl(this.tile.surface.meshUrl, {lod:this.tile.id[0], ix:this.tile.id[1], iy:this.tile.id[2] }); //} - this.map.loader.load(this.mapLoaderUrl, this.onLoad.bind(this), priority, this.extraInfo.tile, "geodata"); + this.map.loader.load(this.mapLoaderUrl, this.onLoad.bind(this), priority, this.extraInfo.tile, 'geodata'); }; diff --git a/src/core/map/interface.js b/src/core/map/interface.js index 63615b43..9f68b893 100755 --- a/src/core/map/interface.js +++ b/src/core/map/interface.js @@ -115,7 +115,7 @@ MapInterface.prototype.getReferenceFrame = function() { MapInterface.prototype.addFreeLayer = function(id, options) { - var layer = new MapSurface(this.map, options, "free"); + var layer = new MapSurface(this.map, options, 'free'); this.map.addFreeLayer(id, layer); }; @@ -177,25 +177,25 @@ MapInterface.prototype.convertCoords = function(sourceSrs, destinationSrs, coord MapInterface.prototype.convertCoordsFromNavToPhys = function(pos, mode, lod) { - var p = ["obj", pos[0], pos[1], mode, pos[2], 0, 0, 0, 10, 55 ]; + var p = ['obj', pos[0], pos[1], mode, pos[2], 0, 0, 0, 10, 55 ]; return this.map.convert.getPositionPhysCoords((new MapPosition(p)), lod); }; MapInterface.prototype.convertCoordsFromNavToCanvas = function(pos, mode, lod) { - var p = ["obj", pos[0], pos[1], mode, pos[2], 0, 0, 0, 10, 55 ]; + var p = ['obj', pos[0], pos[1], mode, pos[2], 0, 0, 0, 10, 55 ]; return this.map.convert.getPositionCanvasCoords((new MapPosition(p)), lod); }; MapInterface.prototype.convertCoordsFromPhysToCanvas = function(pos) { - var p = ["obj", pos[0], pos[1], "fix", pos[2], 0, 0, 0, 10, 55 ]; + var p = ['obj', pos[0], pos[1], 'fix', pos[2], 0, 0, 0, 10, 55 ]; return this.map.convert.getPositionCanvasCoords((new MapPosition(p)), null, true); }; MapInterface.prototype.convertCoordsFromNavToCameraSpace = function(pos, mode, lod) { - var p = ["obj", pos[0], pos[1], mode, pos[2], 0, 0, 0, 10, 55 ]; + var p = ['obj', pos[0], pos[1], mode, pos[2], 0, 0, 0, 10, 55 ]; return this.map.convert.getPositionCameraSpaceCoords((new MapPosition(p)), lod); }; @@ -244,13 +244,13 @@ MapInterface.prototype.getNED = function(coords) { MapInterface.prototype.getCameraInfo = function() { var camera = this.map.camera; return { - "projectionMatrix" : camera.camera.projection.slice(), - "viewMatrix" : camera.camera.modelview.slice(), - "view-projectionMatrix" : camera.camera.mvp.slice(), - "rotationMatrix" : camera.camera.rotationview.slice(), - "position" : this.map.camera.position.slice(), - "vector" : this.map.camera.vector.slice(), - "distance" : this.map.camera.distance + 'projectionMatrix' : camera.camera.projection.slice(), + 'viewMatrix' : camera.camera.modelview.slice(), + 'view-projectionMatrix' : camera.camera.mvp.slice(), + 'rotationMatrix' : camera.camera.rotationview.slice(), + 'position' : this.map.camera.position.slice(), + 'vector' : this.map.camera.vector.slice(), + 'distance' : this.map.camera.distance }; }; @@ -274,9 +274,9 @@ MapInterface.prototype.generateTrajectory = function(p1, p2, options) { MapInterface.prototype.generatePIHTrajectory = function(position, azimuth, distance, options) { var p = new MapPosition(position); - options["distance"] = distance; - options["azimuth"] = azimuth; - options["distanceAzimuth"] = true; + options['distance'] = distance; + options['azimuth'] = azimuth; + options['distanceAzimuth'] = true; return (new MapTrajectory(this.map, p, p, options)).generate(); }; @@ -374,19 +374,19 @@ MapInterface.prototype.getStats = function() { } return { - "bestMeshTexelSize" : this.map.bestMeshTexelSize, - "bestGeodataTexelSize" : this.map.bestGeodataTexelSize, - "downloading" : this.map.loader.downloading.length, - "lastDownload" : this.map.loader.lastDownloadTime, - "surfaces" : this.map.tree.surfaceSequence.length, - "freeLayers" : this.map.freeLayerSequence.length, - "texelSizeFit" : this.map.texelSizeFit, - "loadMode" : this.map.config.mapLoadMode, - "processingTasks" : this.map.processingTasks.length, - "busyWorkers" : busyWorkers, - "dirty" : this.map.dirty, - "drawnTiles" : this.map.stats.drawnTiles, - "drawnGeodataTiles" : this.map.stats.drawnGeodataTiles + 'bestMeshTexelSize' : this.map.bestMeshTexelSize, + 'bestGeodataTexelSize' : this.map.bestGeodataTexelSize, + 'downloading' : this.map.loader.downloading.length, + 'lastDownload' : this.map.loader.lastDownloadTime, + 'surfaces' : this.map.tree.surfaceSequence.length, + 'freeLayers' : this.map.freeLayerSequence.length, + 'texelSizeFit' : this.map.texelSizeFit, + 'loadMode' : this.map.config.mapLoadMode, + 'processingTasks' : this.map.processingTasks.length, + 'busyWorkers' : busyWorkers, + 'dirty' : this.map.dirty, + 'drawnTiles' : this.map.stats.drawnTiles, + 'drawnGeodataTiles' : this.map.stats.drawnGeodataTiles }; }; diff --git a/src/core/map/map.js b/src/core/map/map.js index 5e0bcf0b..2e7bda58 100755 --- a/src/core/map/map.js +++ b/src/core/map/map.js @@ -53,7 +53,7 @@ var Map = function(core, mapConfig, path, config) { this.url = new MapUrl(this, path); - this.position = new MapPosition(["obj", 0, 0, "fix", 0, 0, 0, 0, 0, 0]); + this.position = new MapPosition(['obj', 0, 0, 'fix', 0, 0, 0, 0, 0, 0]); this.lastPosition = this.position.clone(); this.srses = {}; @@ -74,7 +74,7 @@ var Map = function(core, mapConfig, path, config) { this.initialView = null; this.currentView = new MapView(this, {}); - this.currentViewString = ""; + this.currentViewString = ''; this.namedViews = []; this.viewCounter = 0; @@ -134,7 +134,7 @@ var Map = function(core, mapConfig, path, config) { this.draw.setupDetailDegradation(); this.renderSlots = new MapRenderSlots(this); - this.renderSlots.addRenderSlot("map", this.drawMap.bind(this), true); + this.renderSlots.addRenderSlot('map', this.drawMap.bind(this), true); }; @@ -184,12 +184,12 @@ Map.prototype.setupCache = function() { Map.prototype.getCoreInterface = function() { - return this.core.interface; + return this.core.interface; }; Map.prototype.getRendererInterface = function() { - return this.core.interface.getRendererInterface(); + return this.core.interface.getRendererInterface(); }; @@ -308,9 +308,9 @@ Map.prototype.getVisibleCredits = function() { } while(!sorted); return { - "3D" : [], - "imagery" : imageryArray, - "mapdata" : mapdataArray + '3D' : [], + 'imagery' : imageryArray, + 'mapdata' : mapdataArray }; }; @@ -450,8 +450,8 @@ Map.prototype.getMapsSrs = function(srs) { } //is it proj4 string? - if (srs.indexOf("+proj") != -1) { - return new MapSrs(this, {"srsDef":srs}); + if (srs.indexOf('+proj') != -1) { + return new MapSrs(this, {'srsDef':srs}); } //search existing srs @@ -479,10 +479,10 @@ Map.prototype.setView = function(view, forceRefresh) { return; } - if (typeof view === "string") { + if (typeof view === 'string') { view = view.trim(); - if (view.charAt(0) == "{") { + if (view.charAt(0) == '{') { try { view = JSON.parse(view); } catch(e){ @@ -518,12 +518,12 @@ Map.prototype.setView = function(view, forceRefresh) { if (freeLayer) { - freeLayer.zFactor = freeLayers[key]["depthShift"] || 0; + freeLayer.zFactor = freeLayers[key]['depthShift'] || 0; this.freeLayerSequence.push(freeLayer); - if (freeLayers[key]["style"]) { - freeLayer.setStyle(freeLayers[key]["style"]); + if (freeLayers[key]['style']) { + freeLayer.setStyle(freeLayers[key]['style']); } else { freeLayer.setStyle(freeLayer.originalStyle); } @@ -561,10 +561,10 @@ Map.prototype.getStylesheetData = function(id, data) { var stylesheet = this.getStylesheet(id); if (stylesheet) { - return {"url":stylesheet.url, "data": stylesheet.data}; + return {'url':stylesheet.url, 'data': stylesheet.data}; } - return {"url":null, "data":{}}; + return {'url':null, 'data':{}}; }; @@ -583,7 +583,7 @@ Map.prototype.setStylesheetData = function(id, data) { if (freeLayer && freeLayer.geodata && freeLayer.stylesheet == stylesheet) { if (freeLayer.geodataProcessor) { - freeLayer.geodataProcessor.sendCommand("setStylesheet", { "data" : freeLayer.stylesheet.data, "geocent" : (!this.getNavigationSrs().isProjected()) }); + freeLayer.geodataProcessor.sendCommand('setStylesheet', { 'data' : freeLayer.stylesheet.data, 'geocent' : (!this.getNavigationSrs().isProjected()) }); } freeLayer.geodataCounter++; @@ -690,7 +690,7 @@ Map.prototype.getPosition = function() { Map.prototype.setConfigParams = function(params) { - if (typeof params === "object" && params !== null) { + if (typeof params === 'object' && params !== null) { for (var key in params) { this.setConfigParam(key, params[key]); } @@ -700,82 +700,82 @@ Map.prototype.setConfigParams = function(params) { Map.prototype.setConfigParam = function(key, value) { switch (key) { - case "map": this.config.map = utils.validateString(value, null); break; - case "mapCache": this.config.mapCache = utils.validateNumber(value, 10, Number.MAXINTEGER, 900); this.setupCache(); break; - case "mapGPUCache": this.config.mapGPUCache = utils.validateNumber(value, 10, Number.MAXINTEGER, 360); this.setupCache(); break; - case "mapMetatileCache": this.config.mapMetatileCache = utils.validateNumber(value, 10, Number.MAXINTEGER, 60); this.setupCache(); break; - case "mapTexelSizeFit": this.config.mapTexelSizeFit = utils.validateNumber(value, 0.0001, Number.MAXINTEGER, 1.1); break; - case "mapLowresBackground": this.config.mapLowresBackground = utils.validateNumber(value, 0, Number.MAXINTEGER, 0); break; - case "mapDownloadThreads": this.config.mapDownloadThreads = utils.validateNumber(value, 1, Number.MAXINTEGER, 6); break; - case "mapMaxProcessingTime": this.config.mapMaxProcessingTime = utils.validateNumber(value, 1, Number.MAXINTEGER, 1000/20); break; - case "mapMobileMode": this.config.mapMobileMode = utils.validateBool(value, false); this.setupMobileMode(); break; - case "mapMobileModeAutodect": this.config.mapMobileModeAutodect = utils.validateBool(value, false); break; - case "mapMobileDetailDegradation": this.config.mapMobileDetailDegradation = utils.validateNumber(value, 1, Number.MAXINTEGER, 2); break; - case "mapNavSamplesPerViewExtent": this.config.mapNavSamplesPerViewExtent = utils.validateNumber(value, 0.00000000001, Number.MAXINTEGER, 4); break; - case "mapFog": this.config.mapFog = utils.validateBool(value, false); break; - case "mapIgnoreNavtiles": this.config.mapIgnoreNavtiles = utils.validateBool(value, false); break; - case "mapAllowHires": this.config.mapAllowHires = utils.validateBool(value, true); break; - case "mapAllowLowres": this.config.mapAllowLowres = utils.validateBool(value, true); break; - case "mapAllowSmartSwitching": this.config.mapAllowSmartSwitching = utils.validateBool(value, true); break; - case "mapDisableCulling": this.config.mapDisableCulling = utils.validateBool(value, false); break; - case "mapPreciseCulling": this.config.mapPreciseCulling = utils.validateBool(value, false); break; - case "mapHeightLodBlend": this.config.mapHeightLodBlend = utils.validateBool(value, true); break; - case "mapHeightNodeBlend": this.config.mapHeightNodeBlend = utils.validateBool(value, true); break; - case "mapBasicTileSequence": this.config.mapBasicTileSequence = utils.validateBool(value, true); break; - case "mapSmartNodeParsing": this.config.mapSmartNodeParsing = utils.validateBool(value, true); break; - case "mapStoreLoadStats": this.config.mapStoreLoadStats = utils.validateBool(value, true); if (this.draw && this.draw.replay) this.draw.replay.storeLoaded = this.config.mapStoreLoadStats; break; - case "mapXhrImageLoad": this.config.mapXhrImageLoad = utils.validateBool(value, false); break; - case "mapLoadMode": this.config.mapLoadMode = utils.validateString(value, "topdown"); break; - case "mapGeodataLoadMode": this.config.mapGeodataLoadMode = utils.validateString(value, "fit"); break; - case "mapPreciseBBoxTest": this.config.mapPreciseBBoxTest = utils.validateBool(value, true); break; - case "mapPreciseDistanceTest": this.config.mapPreciseDistanceTest = utils.validateBool(value, false); break; - case "mapHeightfiledWhenUnloaded": this.config.mapHeightfiledWhenUnloaded= utils.validateBool(value, false); break; - case "mapForceMetatileV3": this.config.mapForceMetatileV3= utils.validateBool(value, false); break; - case "mapVirtualSurfaces": this.config.mapVirtualSurfaces = utils.validateBool(value, true); break; - case "mapDegradeHorizon": this.config.mapDegradeHorizon = utils.validateBool(value, true); break; - case "mapDegradeHorizonParams": this.config.mapDegradeHorizonParams = utils.validateNumberArray(value, 4, [0,1,1,1], [Number.MAXVALUE, Number.MAXVALUE, Number.MAXVALUE], [1, 3000, 15000, 7000]); break; - case "mario": this.config.mario = utils.validateBool(value, true); break; + case 'map': this.config.map = utils.validateString(value, null); break; + case 'mapCache': this.config.mapCache = utils.validateNumber(value, 10, Number.MAXINTEGER, 900); this.setupCache(); break; + case 'mapGPUCache': this.config.mapGPUCache = utils.validateNumber(value, 10, Number.MAXINTEGER, 360); this.setupCache(); break; + case 'mapMetatileCache': this.config.mapMetatileCache = utils.validateNumber(value, 10, Number.MAXINTEGER, 60); this.setupCache(); break; + case 'mapTexelSizeFit': this.config.mapTexelSizeFit = utils.validateNumber(value, 0.0001, Number.MAXINTEGER, 1.1); break; + case 'mapLowresBackground': this.config.mapLowresBackground = utils.validateNumber(value, 0, Number.MAXINTEGER, 0); break; + case 'mapDownloadThreads': this.config.mapDownloadThreads = utils.validateNumber(value, 1, Number.MAXINTEGER, 6); break; + case 'mapMaxProcessingTime': this.config.mapMaxProcessingTime = utils.validateNumber(value, 1, Number.MAXINTEGER, 1000/20); break; + case 'mapMobileMode': this.config.mapMobileMode = utils.validateBool(value, false); this.setupMobileMode(); break; + case 'mapMobileModeAutodect': this.config.mapMobileModeAutodect = utils.validateBool(value, false); break; + case 'mapMobileDetailDegradation': this.config.mapMobileDetailDegradation = utils.validateNumber(value, 1, Number.MAXINTEGER, 2); break; + case 'mapNavSamplesPerViewExtent': this.config.mapNavSamplesPerViewExtent = utils.validateNumber(value, 0.00000000001, Number.MAXINTEGER, 4); break; + case 'mapFog': this.config.mapFog = utils.validateBool(value, false); break; + case 'mapIgnoreNavtiles': this.config.mapIgnoreNavtiles = utils.validateBool(value, false); break; + case 'mapAllowHires': this.config.mapAllowHires = utils.validateBool(value, true); break; + case 'mapAllowLowres': this.config.mapAllowLowres = utils.validateBool(value, true); break; + case 'mapAllowSmartSwitching': this.config.mapAllowSmartSwitching = utils.validateBool(value, true); break; + case 'mapDisableCulling': this.config.mapDisableCulling = utils.validateBool(value, false); break; + case 'mapPreciseCulling': this.config.mapPreciseCulling = utils.validateBool(value, false); break; + case 'mapHeightLodBlend': this.config.mapHeightLodBlend = utils.validateBool(value, true); break; + case 'mapHeightNodeBlend': this.config.mapHeightNodeBlend = utils.validateBool(value, true); break; + case 'mapBasicTileSequence': this.config.mapBasicTileSequence = utils.validateBool(value, true); break; + case 'mapSmartNodeParsing': this.config.mapSmartNodeParsing = utils.validateBool(value, true); break; + case 'mapStoreLoadStats': this.config.mapStoreLoadStats = utils.validateBool(value, true); if (this.draw && this.draw.replay) this.draw.replay.storeLoaded = this.config.mapStoreLoadStats; break; + case 'mapXhrImageLoad': this.config.mapXhrImageLoad = utils.validateBool(value, false); break; + case 'mapLoadMode': this.config.mapLoadMode = utils.validateString(value, 'topdown'); break; + case 'mapGeodataLoadMode': this.config.mapGeodataLoadMode = utils.validateString(value, 'fit'); break; + case 'mapPreciseBBoxTest': this.config.mapPreciseBBoxTest = utils.validateBool(value, true); break; + case 'mapPreciseDistanceTest': this.config.mapPreciseDistanceTest = utils.validateBool(value, false); break; + case 'mapHeightfiledWhenUnloaded': this.config.mapHeightfiledWhenUnloaded= utils.validateBool(value, false); break; + case 'mapForceMetatileV3': this.config.mapForceMetatileV3= utils.validateBool(value, false); break; + case 'mapVirtualSurfaces': this.config.mapVirtualSurfaces = utils.validateBool(value, true); break; + case 'mapDegradeHorizon': this.config.mapDegradeHorizon = utils.validateBool(value, true); break; + case 'mapDegradeHorizonParams': this.config.mapDegradeHorizonParams = utils.validateNumberArray(value, 4, [0,1,1,1], [Number.MAXVALUE, Number.MAXVALUE, Number.MAXVALUE], [1, 3000, 15000, 7000]); break; + case 'mario': this.config.mario = utils.validateBool(value, true); break; } }; Map.prototype.getConfigParam = function(key) { switch (key) { - case "map": return this.config.map; - case "mapCache": return this.config.mapCache; - case "mapGPUCache": return this.config.mapGPUCache; - case "mapMetatileCache": return this.config.mapMetatileCache; - case "mapTexelSizeFit": return this.config.mapTexelSizeFit; - case "mapLowresBackground": return this.config.mapLowresBackground; - case "mapDownloadThreads": return this.config.mapDownloadThreads; - case "mapMaxProcessingTime": return this.config.mapMaxProcessingTime; - case "mapMobileMode": return this.config.mapMobileMode; - case "mapMobileModeAutodect": return this.config.mapMobileModeAutodect; - case "mapMobileDetailDegradation": return this.config.mapMobileDetailDegradation; - case "mapNavSamplesPerViewExtent": return this.config.mapNavSamplesPerViewExtent; - case "mapFog": return this.config.mapFog; - case "mapIgnoreNavtiles": return this.config.mapIgnoreNavtiles; - case "mapAllowHires": return this.config.mapAllowHires; - case "mapAllowLowres": return this.config.mapAllowLowres; - case "mapAllowSmartSwitching": return this.config.mapAllowSmartSwitching; - case "mapDisableCulling": return this.config.mapDisableCulling; - case "mapPreciseCulling": return this.config.mapPreciseCulling; - case "mapHeightLodBlend": return this.config.mapHeightLodBlend; - case "mapHeightNodeBlend": return this.config.mapHeightNodeBlend; - case "mapBasicTileSequence": return this.config.mapBasicTileSequence; - case "mapSmartNodeParsing": return this.config.mapSmartNodeParsing; - case "mapStoreLoadStats": return this.config.mapStoreLoadStats; - case "mapXhrImageLoad": return this.config.mapXhrImageLoad; - case "mapLoadMode": return this.config.mapLoadMode; - case "mapGeodataLoadMode": return this.config.mapGeodataLoadMode; - case "mapPreciseBBoxTest": return this.config.mapPreciseBBoxTest; - case "mapPreciseDistanceTest": return this.config.mapPreciseDistanceTest; - case "mapHeightfiledWhenUnloaded": return this.config.mapHeightfiledWhenUnloaded; - case "mapForceMetatileV3": return this.config.mapForceMetatileV3; - case "mapVirtualSurfaces": return this.config.mapVirtualSurfaces; - case "mapDegradeHorizon": return this.config.mapDegradeHorizon; - case "mapDegradeHorizonParams": return this.config.mapDegradeHorizonParams; - case "mario": return this.config.mario; + case 'map': return this.config.map; + case 'mapCache': return this.config.mapCache; + case 'mapGPUCache': return this.config.mapGPUCache; + case 'mapMetatileCache': return this.config.mapMetatileCache; + case 'mapTexelSizeFit': return this.config.mapTexelSizeFit; + case 'mapLowresBackground': return this.config.mapLowresBackground; + case 'mapDownloadThreads': return this.config.mapDownloadThreads; + case 'mapMaxProcessingTime': return this.config.mapMaxProcessingTime; + case 'mapMobileMode': return this.config.mapMobileMode; + case 'mapMobileModeAutodect': return this.config.mapMobileModeAutodect; + case 'mapMobileDetailDegradation': return this.config.mapMobileDetailDegradation; + case 'mapNavSamplesPerViewExtent': return this.config.mapNavSamplesPerViewExtent; + case 'mapFog': return this.config.mapFog; + case 'mapIgnoreNavtiles': return this.config.mapIgnoreNavtiles; + case 'mapAllowHires': return this.config.mapAllowHires; + case 'mapAllowLowres': return this.config.mapAllowLowres; + case 'mapAllowSmartSwitching': return this.config.mapAllowSmartSwitching; + case 'mapDisableCulling': return this.config.mapDisableCulling; + case 'mapPreciseCulling': return this.config.mapPreciseCulling; + case 'mapHeightLodBlend': return this.config.mapHeightLodBlend; + case 'mapHeightNodeBlend': return this.config.mapHeightNodeBlend; + case 'mapBasicTileSequence': return this.config.mapBasicTileSequence; + case 'mapSmartNodeParsing': return this.config.mapSmartNodeParsing; + case 'mapStoreLoadStats': return this.config.mapStoreLoadStats; + case 'mapXhrImageLoad': return this.config.mapXhrImageLoad; + case 'mapLoadMode': return this.config.mapLoadMode; + case 'mapGeodataLoadMode': return this.config.mapGeodataLoadMode; + case 'mapPreciseBBoxTest': return this.config.mapPreciseBBoxTest; + case 'mapPreciseDistanceTest': return this.config.mapPreciseDistanceTest; + case 'mapHeightfiledWhenUnloaded': return this.config.mapHeightfiledWhenUnloaded; + case 'mapForceMetatileV3': return this.config.mapForceMetatileV3; + case 'mapVirtualSurfaces': return this.config.mapVirtualSurfaces; + case 'mapDegradeHorizon': return this.config.mapDegradeHorizon; + case 'mapDegradeHorizonParams': return this.config.mapDegradeHorizonParams; + case 'mario': return this.config.mario; } }; @@ -820,24 +820,24 @@ Map.prototype.getHitCoords = function(screenX, screenY, mode, lod) { var 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]]; - t = vec3.dot(a, planeNormal) / d; + var 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; - if (t >= 0) { - if (!cameraSpaceCoords[3] || t < cameraSpaceCoords[5]) { - worldPos = [ (ray[0] * t) + cameraPos[0], - (ray[1] * t) + cameraPos[1], - (ray[2] * t) + cameraPos[2] ]; + if (t >= 0) { + if (!cameraSpaceCoords[3] || t < cameraSpaceCoords[5]) { + worldPos = [ (ray[0] * t) + cameraPos[0], + (ray[1] * t) + cameraPos[1], + (ray[2] * t) + cameraPos[2] ]; - fallbackUsed = true; - } + fallbackUsed = true; } + } //} } else /*if (false)*/ { //elipsoid fallback var navigationSrsInfo = this.getNavigationSrs().getSrsInfo(); - var planetRadius = navigationSrsInfo["b"] + this.referenceFrame.getGlobalHeightRange()[0]; + 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 @@ -853,8 +853,8 @@ Map.prototype.getHitCoords = function(screenX, screenY, mode, lod) { if (!cameraSpaceCoords[3] || t < cameraSpaceCoords[5]) { worldPos = [ (ray[0] * t) + cameraPos[0], - (ray[1] * t) + cameraPos[1], - (ray[2] * t) + cameraPos[2] ]; + (ray[1] * t) + cameraPos[1], + (ray[2] * t) + cameraPos[2] ]; fallbackUsed = true; } @@ -867,13 +867,13 @@ Map.prototype.getHitCoords = function(screenX, screenY, mode, lod) { if (!fallbackUsed) { worldPos = [ cameraSpaceCoords[0] + cameraPos[0], - cameraSpaceCoords[1] + cameraPos[1], - cameraSpaceCoords[2] + cameraPos[2] ]; + cameraSpaceCoords[1] + cameraPos[1], + cameraSpaceCoords[2] + cameraPos[2] ]; } - var navCoords = this.convert.convertCoords(worldPos, "physical", "navigation"); + var navCoords = this.convert.convertCoords(worldPos, 'physical', 'navigation'); - if (mode == "float") { + if (mode == 'float') { var lod = (lod != null) ? lod : this.measure.getOptimalHeightLod(navCoords, 100, this.config.mapNavSamplesPerViewExtent); var surfaceHeight = this.measure.getSurfaceHeight(navCoords, lod); navCoords[2] -= surfaceHeight[0]; @@ -907,29 +907,29 @@ Map.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { var id = (res[1]) + (res[2]<<8); var elementId = (res[3]) + (res[4]<<8); - var feature = this.hoverFeatureList[id]; + var feature = this.hoverFeatureList[id]; - if (mode == "hover") { + if (mode == 'hover') { this.lastHoverFeature = this.hoverFeature; this.lastHoverFeatureId = this.hoverFeatureId; - if (feature && feature[3]) { - this.hoverFeature = feature; - this.hoverFeatureId = (feature != null) ? feature[0]["#id"] : null; - } else { - this.hoverFeature = null; - this.hoverFeatureId = null; - } + if (feature && feature[3]) { + this.hoverFeature = feature; + this.hoverFeatureId = (feature != null) ? feature[0]['#id'] : null; + } else { + this.hoverFeature = null; + this.hoverFeatureId = null; + } var relatedEvents = []; if (this.hoverFeatureId != this.lastHoverFeatureId) { if (this.lastHoverFeatureId != null) { - relatedEvents.push(["leave", this.lastHoverFeature, this.lastHoverFeatureId]); + relatedEvents.push(['leave', this.lastHoverFeature, this.lastHoverFeatureId]); } if (this.hoverFeatureId != null) { - relatedEvents.push(["enter", this.hoverFeature, this.hoverFeatureId]); + relatedEvents.push(['enter', this.hoverFeature, this.hoverFeatureId]); } this.dirty = true; @@ -942,7 +942,7 @@ Map.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { } } - if (mode == "click") { + if (mode == 'click') { //this.hoverFeatureId = (this.hoverFeature != null) ? this.hoverFeature["id"] : null; if (feature != null && feature[2]) { @@ -954,7 +954,7 @@ Map.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { } else { var relatedEvents = []; - if (mode == "hover") { + if (mode == 'hover') { this.lastHoverFeature = this.hoverFeature; this.lastHoverFeatureId = this.hoverFeatureId; this.hoverFeature = null; @@ -962,7 +962,7 @@ Map.prototype.hitTestGeoLayers = function(screenX, screenY, mode) { if (this.lastHoverFeatureId != null) { if (this.lastHoverFeatureId != null) { - relatedEvents.push(["leave", this.lastHoverFeature, this.lastHoverFeatureId]); + relatedEvents.push(['leave', this.lastHoverFeature, this.lastHoverFeatureId]); } this.dirty = true; @@ -1046,18 +1046,18 @@ Map.prototype.update = function() { } } - if (this.div != null && this.div.style.visibility == "hidden"){ + if (this.div != null && this.div.style.visibility == 'hidden'){ //loop heartbeat //window.requestAnimFrame(this.update.bind(this)); return; } if (!this.position.isSame(this.lastPosition)) { - this.core.callListener("map-position-changed", {"position":this.position.toArray(), "last-position":this.lastPosition.toArray()}); + this.core.callListener('map-position-changed', {'position':this.position.toArray(), 'last-position':this.lastPosition.toArray()}); } if (this.camera.lastTerrainHeight != this.camera.terrainHeight) { - this.core.callListener("map-position-fixed-height-changed", {"height":this.camera.terrainHeight, "last-height":this.camera.lastTerrainHeight}); + this.core.callListener('map-position-fixed-height-changed', {'height':this.camera.terrainHeight, 'last-height':this.camera.lastTerrainHeight}); } this.lastPosition = this.position.clone(); @@ -1087,7 +1087,7 @@ Map.prototype.update = function() { this.loader.update(); - this.core.callListener("map-update", {}); + this.core.callListener('map-update', {}); //this.renderer.gpu.setState(this.drawTileState); //this.renderer.gpu.gl.disable(this.renderer.gpu.gl.BLEND); @@ -1102,11 +1102,11 @@ Map.prototype.update = function() { //this.updateGeoHitmap = this.dirty; if (this.hoverEvent != null) { - var result = this.hitTestGeoLayers(this.hoverEvent[0], this.hoverEvent[1], "hover"); + var 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()), - "camera-coords":result[0][1], "state": this.hoverEvent[3] }, true); + this.core.callListener('geo-feature-hover', {'feature': result[0][0], 'canvas-coords':this.renderer.project2(result[0][1], this.camera.getMvpMatrix()), + 'camera-coords':result[0][1], 'state': this.hoverEvent[3] }, true); } var relatedEvents = result[2]; @@ -1116,15 +1116,15 @@ Map.prototype.update = function() { var event = relatedEvents[i]; switch(event[0]) { - case "enter": - this.core.callListener("geo-feature-enter", {"feature": event[1][0], "canvas-coords":this.renderer.project2(event[1][1], this.camera.getMvpMatrix()), - "camera-coords":event[1][1], "state": this.hoverEvent[3] }, true); - break; - - case "leave": - this.core.callListener("geo-feature-leave", {"feature":event[1][0], "canvas-coords":this.renderer.project2(event[1][1], this.camera.getMvpMatrix()), - "camera-coords":event[1][1], "state": this.hoverEvent[3] }, true); - break; + case 'enter': + this.core.callListener('geo-feature-enter', {'feature': event[1][0], 'canvas-coords':this.renderer.project2(event[1][1], this.camera.getMvpMatrix()), + 'camera-coords':event[1][1], 'state': this.hoverEvent[3] }, true); + break; + + case 'leave': + this.core.callListener('geo-feature-leave', {'feature':event[1][0], 'canvas-coords':this.renderer.project2(event[1][1], this.camera.getMvpMatrix()), + 'camera-coords':event[1][1], 'state': this.hoverEvent[3] }, true); + break; } } } @@ -1136,11 +1136,11 @@ Map.prototype.update = function() { } if (this.clickEvent != null) { - var result = this.hitTestGeoLayers(this.clickEvent[0], this.clickEvent[1], "click"); + var 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()), - "camera-coords":result[0][1], "state": this.clickEvent[2] }, true); + this.core.callListener('geo-feature-click', {'feature': result[0][0], 'canvas-coords':this.renderer.project2(result[0][1], this.camera.getMvpMatrix()), + 'camera-coords':result[0][1], 'state': this.clickEvent[2] }, true); } this.clickEvent = null; diff --git a/src/core/map/measure.js b/src/core/map/measure.js index a10a4032..ae45a23f 100755 --- a/src/core/map/measure.js +++ b/src/core/map/measure.js @@ -16,7 +16,7 @@ var MapMeasure = function(map) { this.getPhysicalSrs = this.map.getPhysicalSrs(); this.navigationSrs = this.map.getNavigationSrs(); this.navigationSrsInfo = this.navigationSrs.getSrsInfo(); - this.isProjected = this.navigationSrs.isProjected() + this.isProjected = this.navigationSrs.isProjected(); var res = this.getSpatialDivisionNodeDepths(); @@ -226,7 +226,7 @@ MapMeasure.prototype.getSurfaceHeightNodeOnly = function(coords, lod, storeStats if (metanode != null) { // && metanode.id[0] == lod){ var center = metanode.bbox.center(); - center = this.convert.convertCoords(center, "physical", "navigation"); + center = this.convert.convertCoords(center, 'physical', 'navigation'); //console.log("lod2: " + lod + " nodelod: " + metanode.id[0] + " h: " + center[2]/1.55); @@ -239,7 +239,7 @@ MapMeasure.prototype.getSurfaceHeightNodeOnly = function(coords, lod, storeStats if (this.config.mapHeightLodBlend && metanode.id[0] > 0 && params.parent && params.parent.metanode) { - var center2 = this.convert.convertCoords(params.parent.metanode.bbox.center(), "physical", "navigation"); + 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; @@ -403,7 +403,7 @@ MapMeasure.prototype.getSpatialDivisionNodeFromId = function(id) { var nx = id[1] >> shift; var ny = id[2] >> shift; - return this.map.referenceFrame.nodesMap["" + this.maxDivisionNodeDepth + "." + nx + "." + ny]; + return this.map.referenceFrame.nodesMap['' + this.maxDivisionNodeDepth + '.' + nx + '.' + ny]; }; @@ -518,7 +518,7 @@ MapMeasure.prototype.getDistance = function(coords, coords2, includingHeight) { var r = geod.Inverse(coords[1], coords[0], coords2[1], coords2[0]); - if (d > (navigationSrsInfo["a"] * 2 * Math.PI) / 4007.5) { //aprox 10km for earth + if (d > (navigationSrsInfo['a'] * 2 * Math.PI) / 4007.5) { //aprox 10km for earth if (includingHeight) { return [Math.sqrt(r.s12*r.s12 + dz*dz), -r.az1]; } else { @@ -537,8 +537,8 @@ MapMeasure.prototype.getDistance = function(coords, coords2, includingHeight) { MapMeasure.prototype.getGeodesic = function() { var navigationSrsInfo = this.navigationSrsInfo; - var geodesic = new GeographicLib.Geodesic.Geodesic(navigationSrsInfo["a"], - (navigationSrsInfo["a"] / navigationSrsInfo["b"]) - 1.0); + var geodesic = new GeographicLib.Geodesic.Geodesic(navigationSrsInfo['a'], + (navigationSrsInfo['a'] / navigationSrsInfo['b']) - 1.0); return geodesic; }; @@ -559,11 +559,11 @@ MapMeasure.prototype.getAzimuthCorrection = function(coords, coords2) { MapMeasure.prototype.getNED = function(coords, returnMatrix) { - var centerCoords = this.convert.convertCoords([coords[0], coords[1], 0], "navigation", "physical"); + var centerCoords = this.convert.convertCoords([coords[0], coords[1], 0], 'navigation', 'physical'); 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"); + 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'); } else { var cy = (coords[1] + 90) - 0.0001; var cx = (coords[0] + 180) + 0.0001; @@ -573,25 +573,25 @@ 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"); + var 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"); + var 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"); + 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'); } } var up = [upCoords[0] - centerCoords[0], - upCoords[1] - centerCoords[1], - upCoords[2] - centerCoords[2]]; + upCoords[1] - centerCoords[1], + upCoords[2] - centerCoords[2]]; var right = [rightCoords[0] - centerCoords[0], - rightCoords[1] - centerCoords[1], - rightCoords[2] - centerCoords[2]]; + rightCoords[1] - centerCoords[1], + rightCoords[2] - centerCoords[2]]; var dir = [0,0,0]; vec3.normalize(up); @@ -607,11 +607,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 centerCoords = this.convert.convertCoords([coords[0], coords[1], 0], 'navigation', 'physical'); 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"); + 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'); } else { //get NED for latlon coordinates //http://www.mathworks.com/help/aeroblks/directioncosinematrixeceftoned.html @@ -651,25 +651,25 @@ 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"); + var 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"); + var 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"); + 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'); } } var up = [upCoords[0] - centerCoords[0], - upCoords[1] - centerCoords[1], - upCoords[2] - centerCoords[2]]; + upCoords[1] - centerCoords[1], + upCoords[2] - centerCoords[2]]; var right = [rightCoords[0] - centerCoords[0], - rightCoords[1] - centerCoords[1], - rightCoords[2] - centerCoords[2]]; + rightCoords[1] - centerCoords[1], + rightCoords[2] - centerCoords[2]]; var dir = [0,0,0]; vec3.normalize(up); @@ -710,7 +710,7 @@ 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); - if (position.getViewMode() == "obj") { + if (position.getViewMode() == 'obj') { var orbitPos = [0, -distance, 0]; mat4.multiplyVec3(tmpMatrix, orbitPos); } else { diff --git a/src/core/map/mesh.js b/src/core/map/mesh.js index 55f3ccbd..1cb6cba5 100755 --- a/src/core/map/mesh.js +++ b/src/core/map/mesh.js @@ -171,7 +171,7 @@ MapMesh.prototype.scheduleLoad = function(priority) { this.mapLoaderUrl = this.map.url.makeUrl(this.tile.resourceSurface.meshUrl, {lod:this.tile.id[0], ix:this.tile.id[1], iy:this.tile.id[2] }); } - this.map.loader.load(this.mapLoaderUrl, this.onLoad.bind(this), priority, this.tile, "mesh"); + this.map.loader.load(this.mapLoaderUrl, this.onLoad.bind(this), priority, this.tile, 'mesh'); }; @@ -260,12 +260,12 @@ MapMesh.prototype.parseMapMesh = function (stream) { //parase header var streamData = stream.data; - var magic = ""; + var magic = ''; magic += String.fromCharCode(streamData.getUint8(stream.index, true)); stream.index += 1; magic += String.fromCharCode(streamData.getUint8(stream.index, true)); stream.index += 1; - if (magic != "ME") { + if (magic != 'ME') { return false; } @@ -276,7 +276,7 @@ MapMesh.prototype.parseMapMesh = function (stream) { } //if (this.version >= 3) { - stream.uint8Data = new Uint8Array(stream.buffer); + stream.uint8Data = new Uint8Array(stream.buffer); //} this.meanUndulation = streamData.getFloat64(stream.index, true); stream.index += 8; @@ -343,68 +343,68 @@ MapMesh.prototype.drawSubmesh = function (cameraPos, index, texture, type, alpha var texcoordsAttr = null; var texcoords2Attr = null; var drawWireframe = draw.debug.drawWireframe; - var attributes = (drawWireframe != 0) ? ["aPosition", "aBarycentric"] : ["aPosition"]; + var attributes = (drawWireframe != 0) ? ['aPosition', 'aBarycentric'] : ['aPosition']; - if (type == "depth") { + if (type == 'depth') { program = renderer.progDepthTile; //texcoordsAttr = "aTexCoord"; - } else if (type == "flat") { + } else if (type == 'flat') { program = renderer.progFlatShadeTile; } else { if (drawWireframe > 0) { switch (drawWireframe) { - case 2: program = renderer.progWireframeTile2; break; - case 3: program = renderer.progFlatShadeTile; break; - case 1: + case 2: program = renderer.progWireframeTile2; break; + case 3: program = renderer.progFlatShadeTile; break; + case 1: - switch(type) { - case "internal": - case "internal-nofog": - program = renderer.progWireframeTile; - texcoordsAttr = "aTexCoord"; - attributes.push("aTexCoord"); - break; + switch(type) { + case 'internal': + case 'internal-nofog': + program = renderer.progWireframeTile; + texcoordsAttr = 'aTexCoord'; + attributes.push('aTexCoord'); + break; - case "external": - case "external-nofog": - program = renderer.progWireframeTile3; - texcoords2Attr = "aTexCoord2"; - attributes.push("aTexCoord2"); - break; + case 'external': + case 'external-nofog': + program = renderer.progWireframeTile3; + texcoords2Attr = 'aTexCoord2'; + attributes.push('aTexCoord2'); + break; - case "fog": - return; - } + case 'fog': + return; + } break; } } else { switch(type) { - case "internal": - case "internal-nofog": - program = renderer.progTile; - texcoordsAttr = "aTexCoord"; - attributes.push("aTexCoord"); - break; + case 'internal': + case 'internal-nofog': + program = renderer.progTile; + texcoordsAttr = 'aTexCoord'; + attributes.push('aTexCoord'); + break; - case "external": - case "external-nofog": - program = renderer.progTile2; + case 'external': + case 'external-nofog': + program = renderer.progTile2; - if (texture) { - gpuMask = texture.getGpuMaskTexture(); - if (gpuMask) { - program = renderer.progTile3; - } - } + if (texture) { + gpuMask = texture.getGpuMaskTexture(); + if (gpuMask) { + program = renderer.progTile3; + } + } - texcoords2Attr = "aTexCoord2"; - attributes.push("aTexCoord2"); - break; + texcoords2Attr = 'aTexCoord2'; + attributes.push('aTexCoord2'); + break; - case "fog": - program = renderer.progFogTile; - break; + case 'fog': + program = renderer.progFogTile; + break; } } } @@ -429,7 +429,7 @@ MapMesh.prototype.drawSubmesh = function (cameraPos, index, texture, type, alpha } else { return; } - } else if (type != "fog" && type != "depth" && type != "flat") { + } else if (type != 'fog' && type != 'depth' && type != 'flat') { return; } @@ -437,35 +437,35 @@ MapMesh.prototype.drawSubmesh = function (cameraPos, index, texture, type, alpha mat4.multiply(renderer.camera.getModelviewMatrix(), submesh.getWorldMatrix(cameraPos, this.mBuffer2), mv); var proj = renderer.camera.getProjectionMatrix(); - program.setMat4("uMV", mv); - program.setMat4("uProj", proj); + program.setMat4('uMV', mv); + program.setMat4('uProj', proj); if (drawWireframe == 0) { switch(type) { - case "internal": - case "fog": + case 'internal': + case 'fog': //program.setFloat("uFogDensity", this.map.fogDensity); - program.setVec4("uParams", [draw.zFactor, draw.fogDensity, 0, 0]); - break; + program.setVec4('uParams', [draw.zFactor, draw.fogDensity, 0, 0]); + break; - case "internal-nofog": + case 'internal-nofog': //program.setFloat("uFogDensity", 0); - program.setVec4("uParams", [draw.zFactor, 0, 0, 0]); - break; + program.setVec4('uParams', [draw.zFactor, 0, 0, 0]); + break; - case "external": - program.setFloat("uAlpha", 1); + case 'external': + program.setFloat('uAlpha', 1); //program.setFloat("uFogDensity", this.map.fogDensity); - program.setVec4("uParams", [draw.zFactor, draw.fogDensity, 0, 0]); - program.setVec4("uTransform", texture.getTransform()); - break; + program.setVec4('uParams', [draw.zFactor, draw.fogDensity, 0, 0]); + program.setVec4('uTransform', texture.getTransform()); + break; - case "external-nofog": - program.setFloat("uAlpha", alpha); + case 'external-nofog': + program.setFloat('uAlpha', alpha); //program.setFloat("uFogDensity", 0); - program.setVec4("uParams", [draw.zFactor, 0, 0, 0]); - program.setVec4("uTransform", texture.getTransform()); - break; + program.setVec4('uParams', [draw.zFactor, 0, 0, 0]); + program.setVec4('uTransform', texture.getTransform()); + break; } } @@ -479,7 +479,7 @@ MapMesh.prototype.drawSubmesh = function (cameraPos, index, texture, type, alpha //this.map.renderer.gpu.gl.polygonOffset(-1.0, this.map.zShift); //this.map.renderer.gpu.gl.enable(this.map.renderer.gpu.gl.POLYGON_OFFSET_FILL); - gpuSubmesh.draw(program, "aPosition", texcoordsAttr, texcoords2Attr, drawWireframe != 0 ? "aBarycentric" : null); + gpuSubmesh.draw(program, 'aPosition', texcoordsAttr, texcoords2Attr, drawWireframe != 0 ? 'aBarycentric' : null); //this.map.renderer.gpu.gl.disable(this.map.renderer.gpu.gl.POLYGON_OFFSET_FILL); diff --git a/src/core/map/metanode.js b/src/core/map/metanode.js index 281e32b3..8bb39375 100755 --- a/src/core/map/metanode.js +++ b/src/core/map/metanode.js @@ -218,7 +218,7 @@ struct Metanode { var nodeSize2 = stream.index - lastIndex; //if (!this.map.config.mapSmartNodeParsing) { - this.generateCullingHelpers(); + this.generateCullingHelpers(); //} }; @@ -251,15 +251,15 @@ MapMetanode.prototype.clone = function() { // if (this.map.config.mapGeocentCulling) { - node.diskPos = this.diskPos; - node.diskNormal = this.diskNormal; - node.diskAngle = this.diskAngle; - node.diskAngle2 = this.diskAngle2; - node.diskAngle2A = this.diskAngle2A; - node.diskDistance = this.diskDistance; - node.bbox2 = this.bbox2; + node.diskPos = this.diskPos; + node.diskNormal = this.diskNormal; + node.diskAngle = this.diskAngle; + node.diskAngle2 = this.diskAngle2; + node.diskAngle2A = this.diskAngle2A; + node.diskDistance = this.diskDistance; + node.bbox2 = this.bbox2; - node.divisionNode = this.divisionNode; + node.divisionNode = this.divisionNode; // } @@ -581,7 +581,7 @@ MapMetanode.prototype.drawBBox = function(cameraPos) { var renderer = this.map.renderer; - renderer.gpu.useProgram(renderer.progBBox, ["aPosition"]); + renderer.gpu.useProgram(renderer.progBBox, ['aPosition']); var mvp = mat4.create(); var mv = mat4.create(); @@ -591,10 +591,10 @@ MapMetanode.prototype.drawBBox = function(cameraPos) { var proj = renderer.camera.getProjectionMatrix(); mat4.multiply(proj, mv, mvp); - renderer.progBBox.setMat4("uMVP", mvp); + renderer.progBBox.setMat4('uMVP', mvp); //draw bbox - renderer.bboxMesh.draw(renderer.progBBox, "aPosition"); + renderer.bboxMesh.draw(renderer.progBBox, 'aPosition'); }; @@ -620,9 +620,9 @@ MapMetanode.prototype.drawBBox2 = function(cameraPos) { } - renderer.gpu.useProgram(prog, ["aPosition"]); + renderer.gpu.useProgram(prog, ['aPosition']); - prog.setFloatArray("uPoints", buffer); + prog.setFloatArray('uPoints', buffer); //var mvp = mat4.create(); //var mv = mat4.create(); @@ -634,10 +634,10 @@ MapMetanode.prototype.drawBBox2 = function(cameraPos) { var mvp = renderer.camera.getMvpMatrix(); - prog.setMat4("uMVP", mvp); + prog.setMat4('uMVP', mvp); //draw bbox - renderer.bboxMesh2.draw(prog, "aPosition"); + renderer.bboxMesh2.draw(prog, 'aPosition'); }; /* @@ -675,7 +675,7 @@ MapMetanode.prototype.drawPlane = function(cameraPos, tile) { return; } - renderer.gpu.useProgram(renderer.progPlane, ["aPosition", "aTexCoord"]); + renderer.gpu.useProgram(renderer.progPlane, ['aPosition', 'aTexCoord']); var mvp = mat4.create(); var mv = renderer.camera.getModelviewMatrix(); @@ -695,9 +695,9 @@ MapMetanode.prototype.drawPlane = function(cameraPos, tile) { var prog = renderer.progPlane; - prog.setMat4("uMV", mv); - prog.setMat4("uProj", proj); - prog.setFloatArray("uPoints", buffer); + prog.setMat4('uMV', mv); + prog.setMat4('uProj', proj); + prog.setFloatArray('uPoints', buffer); var minTile = 32; var embed = 8; @@ -710,15 +710,15 @@ MapMetanode.prototype.drawPlane = function(cameraPos, tile) { //prog.setVec4("uParams", [0,0,1/15,0]); //prog.setVec4("uParams", [(minTile / step1),0,1/15,(minTile / step2)]); - prog.setVec4("uParams", [step1, 0, 1/15, step2]); + prog.setVec4('uParams', [step1, 0, 1/15, step2]); //prog.setVec4("uParams2", [(minTile / step1), (minTile / step2), blend, 0]); - prog.setVec4("uParams2", [0, 0, blend, 0]); + prog.setVec4('uParams2', [0, 0, blend, 0]); renderer.gpu.bindTexture(renderer.heightmapTexture); //draw bbox - renderer.planeMesh.draw(renderer.progPlane, "aPosition", "aTexCoord"); + renderer.planeMesh.draw(renderer.progPlane, 'aPosition', 'aTexCoord'); }; diff --git a/src/core/map/metatile.js b/src/core/map/metatile.js index 1c2219ce..8987d73e 100755 --- a/src/core/map/metatile.js +++ b/src/core/map/metatile.js @@ -92,15 +92,15 @@ MapMetatile.prototype.isReady = function (/*doNotLoad,*/ priority) { //} else { //not loaded //add to loading queue or top position in queue - if (this.loadState == 3) { //loadError - if (this.loadErrorCounter <= this.map.config.mapLoadErrorMaxRetryCount && + if (this.loadState == 3) { //loadError + if (this.loadErrorCounter <= this.map.config.mapLoadErrorMaxRetryCount && performance.now() > this.loadErrorTime + this.map.config.mapLoadErrorRetryTime) { - this.scheduleLoad(priority); - } - } else { - this.scheduleLoad(priority); + this.scheduleLoad(priority); } + } else { + this.scheduleLoad(priority); + } //} } //else load in progress @@ -151,7 +151,7 @@ MapMetatile.prototype.scheduleLoad = function() { this.mapLoaderUrl = this.surface.getMetaUrl(this.id); } - this.map.loader.load(this.mapLoaderUrl, this.onLoad.bind(this), null, this.tile, "metatile"); + this.map.loader.load(this.mapLoaderUrl, this.onLoad.bind(this), null, this.tile, 'metatile'); }; @@ -232,12 +232,12 @@ MapMetatile.prototype.parseMetatatile = function(stream) { */ var streamData = stream.data; - var magic = ""; + var magic = ''; magic += String.fromCharCode(streamData.getUint8(stream.index, true)); stream.index += 1; magic += String.fromCharCode(streamData.getUint8(stream.index, true)); stream.index += 1; - if (magic != "MT") { + if (magic != 'MT') { return; } @@ -353,9 +353,9 @@ MapMetatile.prototype.applyMetatatileBitplanes = function() { if (bitplane[byteIndex] & bitMask) { switch(i) { - case 0: - this.nodes[y*this.sizex+x].alien = true; - break; + case 0: + this.nodes[y*this.sizex+x].alien = true; + break; } } } @@ -376,9 +376,9 @@ MapMetatile.prototype.applyMetatanodeBitplanes = function(x, y) { if (bitplane[byteIndex] & bitMask) { switch(i) { - case 0: - this.nodes[y*this.sizex+x].alien = true; - break; + case 0: + this.nodes[y*this.sizex+x].alien = true; + break; } } } diff --git a/src/core/map/position.js b/src/core/map/position.js index 5bcc06ce..1fba2841 100755 --- a/src/core/map/position.js +++ b/src/core/map/position.js @@ -114,7 +114,7 @@ MapPosition.prototype.getHeightMode = function() { MapPosition.prototype.check = function(mode) { //check pich - if (this.getViewMode() == "obj") { + if (this.getViewMode() == 'obj') { this.pos[6] = math.clamp(this.pos[6], -90.0, 90.0); } else { this.pos[6] = math.clamp(this.pos[6], -90.0, 90.0); @@ -142,21 +142,21 @@ MapPosition.prototype.isSame = function(pos) { MapPosition.prototype.validate = function() { var pos = this.pos; - if (pos[0] == "fixed") { //old format - pos[0] = "obj"; + if (pos[0] == 'fixed') { //old format + pos[0] = 'obj'; pos[9] = pos[8]; pos[8] = pos[7]; pos[7] = pos[6]; pos[6] = pos[5]; pos[5] = pos[4]; pos[4] = pos[3]; - pos[3] = "fix"; + pos[3] = 'fix'; } - pos[0] = (pos[0] == "obj" || pos[0] == "subj") ? pos[0] : "obj"; + pos[0] = (pos[0] == 'obj' || pos[0] == 'subj') ? pos[0] : 'obj'; pos[1] = (pos[1] != null) ? pos[1] : 0; pos[2] = (pos[2] != null) ? pos[2] : 0; - pos[3] = (pos[3] == "fix" || pos[3] == "fixed" || pos[3] == "float") ? pos[3] : "float"; + pos[3] = (pos[3] == 'fix' || pos[3] == 'fixed' || pos[3] == 'float') ? pos[3] : 'float'; pos[4] = (pos[4] != null) ? pos[4] : 0; pos[5] = (pos[5] != null) ? pos[5] : 0; pos[6] = (pos[6] != null) ? pos[6] : -90; @@ -164,15 +164,15 @@ MapPosition.prototype.validate = function() { pos[8] = (pos[8] != null) ? pos[8] : 900; pos[9] = (pos[9] != null) ? pos[9] : 55; - pos[3] = (pos[3] == "fixed") ? "fix" : pos[3]; + pos[3] = (pos[3] == 'fixed') ? 'fix' : pos[3]; }; MapPosition.prototype.toString = function() { var p = this.pos; - return p[0] + ", " + p[1].toFixed(0) + ", " + p[2].toFixed(0) + ", " + p[3] + ", " + p[4].toFixed(0) - + ", " + p[5].toFixed(0) + ", " + p[6].toFixed(0) + ", " + p[7].toFixed(0) + ", " - + ", " + p[8].toFixed(0) + ", " + p[9].toFixed(0); + return p[0] + ', ' + p[1].toFixed(0) + ', ' + p[2].toFixed(0) + ', ' + p[3] + ', ' + p[4].toFixed(0) + + ', ' + p[5].toFixed(0) + ', ' + p[6].toFixed(0) + ', ' + p[7].toFixed(0) + ', ' + + ', ' + p[8].toFixed(0) + ', ' + p[9].toFixed(0); }; diff --git a/src/core/map/refframe.js b/src/core/map/refframe.js index 51470b1e..2aa59db9 100755 --- a/src/core/map/refframe.js +++ b/src/core/map/refframe.js @@ -9,49 +9,49 @@ var MapRefFrame = function(map, json) { this.map = map; this.proj4 = map.proj4; this.valid = false; - this.id = json["id"] || null; - this.description = json["description"] || ""; + this.id = json['id'] || null; + this.description = json['description'] || ''; this.nodesMap = []; - var model = json["model"]; + var model = json['model']; if (model == null) { return; } this.model = { - physicalSrs : map.getMapsSrs(model["physicalSrs"]), - navigationSrs : map.getMapsSrs(model["navigationSrs"]), - publicSrs : map.getMapsSrs(model["publicSrs"]) + physicalSrs : map.getMapsSrs(model['physicalSrs']), + navigationSrs : map.getMapsSrs(model['navigationSrs']), + publicSrs : map.getMapsSrs(model['publicSrs']) }; this.params = {}; - if (json["parameters"] != null) { - var params = json["parameters"]; - this.params.metaBinaryOrder = params["metaBinaryOrder"] || 1; - this.params.navDelta = params["navDelta"] || 8; + if (json['parameters'] != null) { + var params = json['parameters']; + this.params.metaBinaryOrder = params['metaBinaryOrder'] || 1; + this.params.navDelta = params['navDelta'] || 8; } - var division = json["division"]; + var division = json['division']; if (division == null) { return; } this.division = { - rootLod : division["rootLod"] || 0, - arity : division["arity"] || null, - heightRange : division["heightRange"] || [0,1] + rootLod : division['rootLod'] || 0, + arity : division['arity'] || null, + heightRange : division['heightRange'] || [0,1] }; - var extents = this.parseSpaceExtents(division["extents"]); + var extents = this.parseSpaceExtents(division['extents']); this.division.extents = extents; map.spaceExtentSize = [extents.ur[0] - extents.ll[0], extents.ur[1] - extents.ll[1], extents.ur[2] - extents.ll[2]]; map.spaceExtentOffset = extents.ll; - var divisionNodes = division["nodes"]; + var divisionNodes = division['nodes']; this.division.nodes = []; if (divisionNodes == null) { @@ -62,7 +62,7 @@ var MapRefFrame = function(map, json) { for (var i = 0, li = divisionNodes.length; i < li; i++) { var node = this.parseNode(divisionNodes[i]); - this.nodesMap["" + node.id[0] + "." + node.id[1] + "." + node.id[2]] = node; + this.nodesMap['' + node.id[0] + '.' + node.id[1] + '.' + node.id[2]] = node; this.division.nodes.push(node); } @@ -72,10 +72,10 @@ var MapRefFrame = function(map, json) { MapRefFrame.prototype.getInfo = function() { return { - "id" : this.id, - "physicalSrs" : this.model.physicalSrs.id, - "navigationSrs" : this.model.navigationSrs.id, - "publicSrs" : this.model.publicSrs.id + 'id' : this.id, + 'physicalSrs' : this.model.physicalSrs.id, + 'navigationSrs' : this.model.navigationSrs.id, + 'publicSrs' : this.model.publicSrs.id }; }; @@ -87,21 +87,21 @@ MapRefFrame.prototype.getGlobalHeightRange = function() { MapRefFrame.prototype.parseNode = function(nodeData) { var node = { - srs : nodeData["srs"], - partitioning : nodeData["partitioning"] + srs : nodeData['srs'], + partitioning : nodeData['partitioning'] }; - node.extents = this.parseExtents(nodeData["extents"]); + node.extents = this.parseExtents(nodeData['extents']); - var nodeId = nodeData["id"]; + var nodeId = nodeData['id']; if (nodeId == null) { return; } node.id = { - lod : nodeId["lod"] || 0, - position : nodeId["position"] || [0,0] + lod : nodeId['lod'] || 0, + position : nodeId['position'] || [0,0] }; return new MapDivisionNode(this.map, [node.id.lod, node.id.position[0], node.id.position[1]], @@ -115,8 +115,8 @@ MapRefFrame.prototype.parseExtents = function(extentsData) { } return { - ll : extentsData["ll"] || [0,0], - ur : extentsData["ur"] || [1,1] + ll : extentsData['ll'] || [0,0], + ur : extentsData['ur'] || [1,1] }; }; @@ -127,8 +127,8 @@ MapRefFrame.prototype.parseSpaceExtents = function(extentsData) { } return { - ll : extentsData["ll"] || [0,0,0], - ur : extentsData["ur"] || [1,1,1] + ll : extentsData['ll'] || [0,0,0], + ur : extentsData['ur'] || [1,1,1] }; }; @@ -142,15 +142,15 @@ MapRefFrame.prototype.convertCoords = function(coords, source, destination) { var sourceSrs, destinationSrs; switch(source) { - case "public": sourceSrs = this.model.publicSrs; break; - case "physical": sourceSrs = this.model.physicalSrs; break; - case "navigation": sourceSrs = this.model.navigationSrs; break; + case 'public': sourceSrs = this.model.publicSrs; break; + case 'physical': sourceSrs = this.model.physicalSrs; break; + case 'navigation': sourceSrs = this.model.navigationSrs; break; } switch(destination) { - case "public": destinationSrs = this.model.publicSrs; break; - case "physical": destinationSrs = this.model.physicalSrs; break; - case "navigation": destinationSrs = this.model.navigationSrs; break; + case 'public': destinationSrs = this.model.publicSrs; break; + case 'physical': destinationSrs = this.model.physicalSrs; break; + case 'navigation': destinationSrs = this.model.navigationSrs; break; } return sourceSrs.convertCoordsTo(coords, destinationSrs); diff --git a/src/core/map/render-slots.js b/src/core/map/render-slots.js index d32135ac..c2c570c9 100755 --- a/src/core/map/render-slots.js +++ b/src/core/map/render-slots.js @@ -11,9 +11,9 @@ var MapRenderSlots = function(map) { MapRenderSlots.prototype.createRenderSlot = function(id, callback, enabled) { return { id:id, - callback:callback, - enabled : enabled - }; + callback:callback, + enabled : enabled + }; }; @@ -28,8 +28,8 @@ MapRenderSlots.prototype.getRenderSlotIndex = function(id) { MapRenderSlots.prototype.checkRenderSlotId = function(id) { - if (id == "after-map-render") { - return "map"; + if (id == 'after-map-render') { + return 'map'; } else { return id; } diff --git a/src/core/map/resource-node.js b/src/core/map/resource-node.js index 82a0bdf0..c14b2a93 100755 --- a/src/core/map/resource-node.js +++ b/src/core/map/resource-node.js @@ -59,9 +59,9 @@ MapResourceNode.prototype.addChild = function(index) { var childId = [id[0] + 1, id[1] << 1, id[2] << 1]; switch (index) { - case 1: childId[1]++; break; - case 2: childId[2]++; break; - case 3: childId[1]++; childId[2]++; break; + case 1: childId[1]++; break; + case 2: childId[2]++; break; + case 3: childId[1]++; childId[2]++; break; } this.children[index] = new MapResourceNode(this.map, this, childId); diff --git a/src/core/map/srs.js b/src/core/map/srs.js index 3dd8c406..19899a43 100755 --- a/src/core/map/srs.js +++ b/src/core/map/srs.js @@ -13,14 +13,14 @@ var MapSrs = function(map, id, json) { this.map = map; this.id = id; this.proj4 = map.proj4; - this.comment = json["comment"] || null; - this.srsDef = json["srsDef"] || null; - this.srsModifiers = json["srsModifiers"] || []; - this.type = json["type"] || "projected"; - this.vdatum = json["vdatum"] || "orthometric"; + this.comment = json['comment'] || null; + this.srsDef = json['srsDef'] || null; + this.srsModifiers = json['srsModifiers'] || []; + this.type = json['type'] || 'projected'; + this.vdatum = json['vdatum'] || 'orthometric'; //this.srsDefEllps = json["srsDefEllps"] || ""; - this.srsDef = json["srsDefEllps"] || this.srsDef; - this.periodicity = this.parsePeriodicity(json["periodicity"]); + this.srsDef = json['srsDefEllps'] || this.srsDef; + this.periodicity = this.parsePeriodicity(json['periodicity']); this.srsInfo = this.proj4(this.srsDef).info(); this.geoidGrid = null; this.geoidGridMap = null; @@ -28,19 +28,19 @@ var MapSrs = function(map, id, json) { this.latlonProj4 = null; this.proj4Cache = {}; - if (json["geoidGrid"]) { - var geoidGridData = json["geoidGrid"]; + if (json['geoidGrid']) { + var geoidGridData = json['geoidGrid']; this.geoidGrid = { - definition : geoidGridData["definition"] || null, - srsDefEllps : geoidGridData["srsDefEllps"] || null, - valueRange : geoidGridData["valueRange"] || [0,1] + definition : geoidGridData['definition'] || null, + srsDefEllps : geoidGridData['srsDefEllps'] || null, + valueRange : geoidGridData['valueRange'] || [0,1] }; - if (geoidGridData["extents"]) { + if (geoidGridData['extents']) { this.geoidGrid.extents = { - ll : geoidGridData["extents"]["ll"], - ur : geoidGridData["extents"]["ur"] + ll : geoidGridData['extents']['ll'], + ur : geoidGridData['extents']['ur'] }; } else { this.geoidGrid.extents = { @@ -59,8 +59,8 @@ var MapSrs = function(map, id, json) { } } - if (this.type == "geographic") { - this.spheroid = json["spheroid"] || null; + if (this.type == 'geographic') { + this.spheroid = json['spheroid'] || null; if (this.spheroid == null) { //TODO: return error @@ -75,8 +75,8 @@ MapSrs.prototype.parsePeriodicity = function(periodicityData) { } var periodicity = { - "type" : periodicityData["type"] || "", - "period" : periodicityData["period"] || 0 + 'type' : periodicityData['type'] || '', + 'period' : periodicityData['period'] || 0 }; return periodicity; @@ -85,14 +85,14 @@ MapSrs.prototype.parsePeriodicity = function(periodicityData) { MapSrs.prototype.getInfo = function() { return { - "comment" : this.comment, - "srsDef" : this.srsDef, - "srsModifiers" : this.srsModifiers, - "type" : this.type, - "vdatum" : this.vdatum, - "srsDefEllps" : this.srsDef, - "a" : this.srsInfo["a"], - "b" : this.srsInfo["b"] + 'comment' : this.comment, + 'srsDef' : this.srsDef, + 'srsModifiers' : this.srsModifiers, + 'type' : this.type, + 'vdatum' : this.vdatum, + 'srsDefEllps' : this.srsDef, + 'a' : this.srsInfo['a'], + 'b' : this.srsInfo['b'] }; }; @@ -114,7 +114,7 @@ MapSrs.prototype.isGeoidGridReady = function() { MapSrs.prototype.isProjected = function() { - return (this.type == "projected"); + return (this.type == 'projected'); }; @@ -179,15 +179,15 @@ MapSrs.prototype.getGeoidGridDelta = function(coords, original) { MapSrs.prototype.getVerticalAdjustmentFactor = function(coords) { - if (this.srsModifiers.indexOf("adjustVertical") != -1) { + if (this.srsModifiers.indexOf('adjustVertical') != -1) { var info = this.getSrsInfo(); //convert coords to latlon - var latlonProj = "+proj=longlat " + - " +alpha=0" + - " +gamma=0 +a=" + info["a"] + - " +b=" + info["b"] + - " +x0=0 +y0=0"; + var latlonProj = '+proj=longlat ' + + ' +alpha=0' + + ' +gamma=0 +a=' + info['a'] + + ' +b=' + info['b'] + + ' +x0=0 +y0=0'; if (!this.latlonProj4) { this.latlonProj4 = this.proj4(latlonProj, null, null, true); @@ -196,8 +196,8 @@ MapSrs.prototype.getVerticalAdjustmentFactor = function(coords) { var coords2 = this.proj4(this.srsProj4, this.latlonProj4, [coords[0], coords[1]]); //move coors 1000m - var geod = new GeographicLib.Geodesic.Geodesic(info["a"], - (info["a"] / info["b"]) - 1.0); + var geod = new GeographicLib.Geodesic.Geodesic(info['a'], + (info['a'] / info['b']) - 1.0); var r = geod.Direct(coords2[1], coords2[0], 90, 1000); @@ -224,7 +224,7 @@ MapSrs.prototype.getVerticalAdjustmentFactor = function(coords) { MapSrs.prototype.convertCoordsTo = function(coords, srs, skipVerticalAdjust) { this.isReady(); - if (typeof srs !== "string") { + if (typeof srs !== 'string') { if (srs.id == this.id) { return coords.slice(); } @@ -234,10 +234,10 @@ MapSrs.prototype.convertCoordsTo = function(coords, srs, skipVerticalAdjust) { coords = coords.slice(); - var stringSrs = (typeof srs === "string"); + var stringSrs = (typeof srs === 'string'); //if (!skipVerticalAdjust && stringSrs) { - coords[2] = this.getOriginalHeight(coords); + coords[2] = this.getOriginalHeight(coords); //} var srsDef = (stringSrs) ? srs : srs.srsProj4; @@ -314,7 +314,7 @@ MapSrs.prototype.convertCoordsToFast = function(coords, srs, skipVerticalAdjust, MapSrs.prototype.convertCoordsFrom = function(coords, srs) { this.isReady(); - if (typeof srs !== "string") { + if (typeof srs !== 'string') { if (srs.id == this.id) { return coords.slice(); } @@ -324,12 +324,12 @@ MapSrs.prototype.convertCoordsFrom = function(coords, srs) { coords = coords.slice(); - if (typeof srs !== "string") { + if (typeof srs !== 'string') { coords[2] = srs.getOriginalHeight(coords); } - var srsDef = (typeof srs === "string") ? srs : srs.srsProj4; - var srsDef2 = (typeof srs === "string") ? srs : srs.srsDef; + var srsDef = (typeof srs === 'string') ? srs : srs.srsProj4; + var srsDef2 = (typeof srs === 'string') ? srs : srs.srsDef; //var coords2 = this.proj4(srsDef, this.srsProj4, coords); @@ -349,20 +349,20 @@ MapSrs.prototype.convertCoordsFrom = function(coords, srs) { MapSrs.prototype.phi2z = function(eccent, ts) { - var HALFPI = Math.PI*0.5; - var eccnth = 0.5 * eccent; - var con, dphi; - var phi = HALFPI - 2 * Math.atan(ts); - for (var i = 0; i <= 15; i++) { - con = eccent * Math.sin(phi); - dphi = HALFPI - 2 * Math.atan(ts * (Math.pow(((1 - con) / (1 + con)), eccnth))) - phi; - phi += dphi; - if (Math.abs(dphi) <= 0.0000000001) { - return phi; + var HALFPI = Math.PI*0.5; + var eccnth = 0.5 * eccent; + var con, dphi; + var phi = HALFPI - 2 * Math.atan(ts); + for (var i = 0; i <= 15; i++) { + con = eccent * Math.sin(phi); + dphi = HALFPI - 2 * Math.atan(ts * (Math.pow(((1 - con) / (1 + con)), eccnth))) - phi; + phi += dphi; + if (Math.abs(dphi) <= 0.0000000001) { + return phi; + } } - } //console.log("phi2z has NoConvergence"); - return -9999; + return -9999; }; @@ -411,19 +411,19 @@ MapSrs.prototype.convertWGSToGeocent = function(coords, srs, coords2, index, ind ** test, it should be wrapped by Math.cos() and Math.sin(). NFW for PROJ.4, Sep/2001. */ if (Latitude < -HALFPI && Latitude > -1.001 * HALFPI) { - Latitude = -HALFPI; + Latitude = -HALFPI; } else if (Latitude > HALFPI && Latitude < 1.001 * HALFPI) { - Latitude = HALFPI; + Latitude = HALFPI; } else if ((Latitude < -HALFPI) || (Latitude > HALFPI)) { /* Latitude out of range */ //..reportError('geocent:lat out of range:' + Latitude); - return null; + return null; } if (Longitude > Math.PI) { - Longitude -= (2 * Math.PI); + Longitude -= (2 * Math.PI); } SinLat = Math.sin(Latitude); diff --git a/src/core/map/stylesheet.js b/src/core/map/stylesheet.js index 501c2e24..aaf2fb3e 100755 --- a/src/core/map/stylesheet.js +++ b/src/core/map/stylesheet.js @@ -16,7 +16,7 @@ var MapStylesheet = function(map, id, url) { this.size = 0; this.fileSize = 0; - if (typeof url === "object") { + if (typeof url === 'object') { this.data = url; this.loadState = 2; } else { diff --git a/src/core/map/submesh.js b/src/core/map/submesh.js index 0824389c..8c391abf 100755 --- a/src/core/map/submesh.js +++ b/src/core/map/submesh.js @@ -608,11 +608,11 @@ MapSubmesh.prototype.fileSize = function () { MapSubmesh.prototype.buildGpuMesh = function () { return new GpuMesh(this.map.renderer.gpu, { - bbox: this.bbox, - vertices: this.vertices, - uvs: this.internalUVs, - uvs2: this.externalUVs - }, 1, this.map.core); + bbox: this.bbox, + vertices: this.vertices, + uvs: this.internalUVs, + uvs2: this.externalUVs + }, 1, this.map.core); }; @@ -644,7 +644,7 @@ MapSubmesh.prototype.getWorldMatrix = function(geoPos, matrix) { MapSubmesh.prototype.drawBBox = function(cameraPos) { var renderer = this.map.renderer; - renderer.gpu.useProgram(renderer.progBBox, ["aPosition"]); + renderer.gpu.useProgram(renderer.progBBox, ['aPosition']); var mvp = mat4.create(); var mv = mat4.create(); @@ -654,10 +654,10 @@ MapSubmesh.prototype.drawBBox = function(cameraPos) { var proj = renderer.camera.getProjectionMatrix(); mat4.multiply(proj, mv, mvp); - renderer.progBBox.setMat4("uMVP", mvp); + renderer.progBBox.setMat4('uMVP', mvp); //draw bbox - renderer.bboxMesh.draw(renderer.progBBox, "aPosition"); + renderer.bboxMesh.draw(renderer.progBBox, 'aPosition'); }; diff --git a/src/core/map/subtexture.js b/src/core/map/subtexture.js index 6442613c..370a1209 100755 --- a/src/core/map/subtexture.js +++ b/src/core/map/subtexture.js @@ -118,44 +118,44 @@ MapSubtexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu, t doNotLoad = doNotLoad || doNotUseGpu; if (this.neverReady) { - return false; + return false; } switch (texture.checkType) { - case "negative-type": - case "negative-code": - case "negative-size": + case 'negative-type': + case 'negative-code': + case 'negative-size': - if (this.checkStatus != 2) { - this.checkType = texture.checkType; - this.checkValue = texture.checkValue; - - if (this.checkStatus == 0) { - this.scheduleHeadRequest(priority, (this.checkType == "negative-size")); - } else if (this.checkStatus == 3) { //loadError - if (this.loadErrorCounter <= this.map.config.mapLoadErrorMaxRetryCount && + if (this.checkStatus != 2) { + this.checkType = texture.checkType; + this.checkValue = texture.checkValue; + + if (this.checkStatus == 0) { + this.scheduleHeadRequest(priority, (this.checkType == 'negative-size')); + } else if (this.checkStatus == 3) { //loadError + if (this.loadErrorCounter <= this.map.config.mapLoadErrorMaxRetryCount && performance.now() > this.loadErrorTime + this.map.config.mapLoadErrorRetryTime) { - this.scheduleHeadRequest(priority, (this.checkType == "negative-size")); - } - } else if (this.checkStatus == -1) { + this.scheduleHeadRequest(priority, (this.checkType == 'negative-size')); + } + } else if (this.checkStatus == -1) { - if (texture.extraInfo) { //find at least texture with lower resolution - if (!texture.extraBound) { - texture.extraBound = { tile: texture.extraInfo.tile, layer: texture.extraInfo.layer}; - texture.setBoundTexture(texture.extraBound.tile.parent, texture.extraBound.layer); - } + if (texture.extraInfo) { //find at least texture with lower resolution + if (!texture.extraBound) { + texture.extraBound = { tile: texture.extraInfo.tile, layer: texture.extraInfo.layer}; + texture.setBoundTexture(texture.extraBound.tile.parent, texture.extraBound.layer); + } - while (texture.extraBound.texture.extraBound || texture.extraBound.texture.checkStatus == -1) { + while (texture.extraBound.texture.extraBound || texture.extraBound.texture.checkStatus == -1) { //while (texture.extraBound.texture.checkStatus == -1) { - texture.setBoundTexture(texture.extraBound.sourceTile.parent, texture.extraBound.layer); - } + texture.setBoundTexture(texture.extraBound.sourceTile.parent, texture.extraBound.layer); } } - - return false; } + + return false; + } - break; + break; } if (this.loadState == 2) { //loaded @@ -240,7 +240,7 @@ MapSubtexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu, t MapSubtexture.prototype.scheduleLoad = function(priority, header) { - this.map.loader.load(this.mapLoaderUrl, this.onLoad.bind(this, header), priority, this.tile, this.internal ? "texture-in" : "texture-ex"); + this.map.loader.load(this.mapLoaderUrl, this.onLoad.bind(this, header), priority, this.tile, this.internal ? 'texture-in' : 'texture-ex'); }; @@ -258,7 +258,7 @@ MapSubtexture.prototype.onLoad = function(header, url, onLoaded, onError) { } if (this.map.config.mapXhrImageLoad) { - utils.loadBinary(url, this.onBinaryLoaded.bind(this), onerror, (utils.useCredentials ? (this.mapLoaderUrl.indexOf(this.map.url.baseUrl) != -1) : false), this.map.core.xhrParams, "blob"); + utils.loadBinary(url, this.onBinaryLoaded.bind(this), onerror, (utils.useCredentials ? (this.mapLoaderUrl.indexOf(this.map.url.baseUrl) != -1) : false), this.map.core.xhrParams, 'blob'); } else { this.image = utils.loadImage(url, onload, onerror, (this.map.core.tokenCookieHost ? (url.indexOf(this.map.core.tokenCookieHost) != -1) : false)); } @@ -289,7 +289,7 @@ MapSubtexture.prototype.onLoadError = function(killBlob) { MapSubtexture.prototype.onBinaryLoaded = function(data) { - if (this.fastHeaderCheck && this.checkType && this.checkType != "metatile") { + if (this.fastHeaderCheck && this.checkType && this.checkType != 'metatile') { this.onHeadLoaded(null, data, null /*status*/); if (this.checkStatus == -1) { @@ -338,7 +338,7 @@ MapSubtexture.prototype.scheduleHeadRequest = function(priority, downloadAll) { if (this.map.config.mapXhrImageLoad && this.fastHeaderCheck) { this.scheduleLoad(priority, true); } else { - this.map.loader.load(this.mapLoaderUrl, this.onLoadHead.bind(this, downloadAll), priority, this.tile, this.internal, this.internal ? "texture-in" : "texture-ex"); + this.map.loader.load(this.mapLoaderUrl, this.onLoadHead.bind(this, downloadAll), priority, this.tile, this.internal, this.internal ? 'texture-in' : 'texture-ex'); } }; @@ -353,9 +353,9 @@ MapSubtexture.prototype.onLoadHead = function(downloadAll, url, onLoaded, onErro this.checkStatus = 1; if (downloadAll) { - utils.loadBinary(url, onload, onerror, (utils.useCredentials ? (this.mapLoaderUrl.indexOf(this.map.url.baseUrl) != -1) : false), this.map.core.xhrParams, "blob"); + utils.loadBinary(url, onload, onerror, (utils.useCredentials ? (this.mapLoaderUrl.indexOf(this.map.url.baseUrl) != -1) : false), this.map.core.xhrParams, 'blob'); } else { - utils.headRequest(url, onload, onerror, (utils.useCredentials ? (this.mapLoaderUrl.indexOf(this.map.url.baseUrl) != -1) : false), this.map.core.xhrParams, "blob"); + utils.headRequest(url, onload, onerror, (utils.useCredentials ? (this.mapLoaderUrl.indexOf(this.map.url.baseUrl) != -1) : false), this.map.core.xhrParams, 'blob'); } }; @@ -390,61 +390,61 @@ MapSubtexture.prototype.onHeadLoaded = function(downloadAll, data, status) { if (this.map.config.mapXhrImageLoad && this.fastHeaderCheck) { switch (this.checkType) { - case "negative-size": - if (data) { - if (data.size == this.checkValue) { - this.checkStatus = -1; - } + case 'negative-size': + if (data) { + if (data.size == this.checkValue) { + this.checkStatus = -1; } - break; + } + break; - case "negative-type": - if (data) { - if (data.type == this.checkValue) { - this.checkStatus = -1; - } + case 'negative-type': + if (data) { + if (data.type == this.checkValue) { + this.checkStatus = -1; } - break; + } + break; - case "negative-code": - if (status) { - if (this.checkValue.indexOf(status) != -1) { - this.checkStatus = -1; - } + case 'negative-code': + if (status) { + if (this.checkValue.indexOf(status) != -1) { + this.checkStatus = -1; } - break; + } + break; } } else { switch (this.checkType) { - case "negative-size": - if (data) { - if (data.byteLength == this.checkValue) { - this.checkStatus = -1; - } + case 'negative-size': + if (data) { + if (data.byteLength == this.checkValue) { + this.checkStatus = -1; } - break; + } + break; - case "negative-type": - if (data) { - if (!data.indexOf) { - data = data; - } + case 'negative-type': + if (data) { + if (!data.indexOf) { + data = data; + } - if (data.indexOf(this.checkValue) != -1) { - this.checkStatus = -1; - } + if (data.indexOf(this.checkValue) != -1) { + this.checkStatus = -1; } - break; + } + break; - case "negative-code": - if (status) { - if (this.checkValue.indexOf(status) != -1) { - this.checkStatus = -1; - } + case 'negative-code': + if (status) { + if (this.checkValue.indexOf(status) != -1) { + this.checkStatus = -1; } - break; + } + break; } this.mapLoaderCallLoaded(); @@ -454,7 +454,7 @@ MapSubtexture.prototype.onHeadLoaded = function(downloadAll, data, status) { MapSubtexture.prototype.buildGpuTexture = function () { this.gpuTexture = new GpuTexture(this.map.renderer.gpu, null, this.map.core); - this.gpuTexture.createFromImage(this.image, "linear", false); + this.gpuTexture.createFromImage(this.image, 'linear', false); this.stats.gpuTextures += this.gpuTexture.size; this.stats.graphsFluxTexture[0][0]++; @@ -465,10 +465,10 @@ MapSubtexture.prototype.buildGpuTexture = function () { MapSubtexture.prototype.buildHeightMap = function () { - var canvas = document.createElement("canvas"); + var canvas = document.createElement('canvas'); canvas.width = this.image.naturalWidth; canvas.height = this.image.naturalHeight; - var ctx = canvas.getContext("2d"); + var ctx = canvas.getContext('2d'); ctx.drawImage(this.image, 0, 0); this.imageData = ctx.getImageData(0, 0, this.image.naturalWidth, this.image.naturalHeight).data; this.imageExtents = [this.image.naturalWidth, this.image.naturalHeight]; diff --git a/src/core/map/surface-sequence.js b/src/core/map/surface-sequence.js index f565e6b0..2de0b0dd 100755 --- a/src/core/map/surface-sequence.js +++ b/src/core/map/surface-sequence.js @@ -38,7 +38,7 @@ MapSurfaceSequence.prototype.generateSurfaceSequence = function(tree, surfaces) if (vsurfaceCount >= 1) { //do we have virtual surface? strId.sort(); - strId = strId.join(";"); + strId = strId.join(';'); var surface = this.map.virtualSurfaces[strId]; if (surface) { @@ -195,18 +195,18 @@ MapSurfaceSequence.prototype.generateBoundLayerSequence = function() { for (var i = 0, li = surfaceLayers.length; i < li; i++) { var item = surfaceLayers[i]; - if (typeof item === "string") { + if (typeof item === 'string') { var layer = this.map.getBoundLayerById(item); if (layer) { surface.boundLayerSequence.push([layer, 1]); } } else { - var layer = this.map.getBoundLayerById(item["id"]); + var layer = this.map.getBoundLayerById(item['id']); if (layer) { var alpha = 1; - if (typeof item["alpha"] !== "undefined") { - alpha = item["alpha"]; + if (typeof item['alpha'] !== 'undefined') { + alpha = item['alpha']; } surface.boundLayerSequence.push([layer, alpha]); @@ -223,25 +223,25 @@ MapSurfaceSequence.prototype.generateBoundLayerSequence = function() { if (freeLayer != null && freeLayer.ready) { freeLayer.boundLayerSequence = []; - var boundLayers = freeLayersProperties["boundLayers"]; + var boundLayers = freeLayersProperties['boundLayers']; if (boundLayers && Array.isArray(boundLayers)) { for (var i = 0, li = boundLayers.length; i < li; i++) { var item = boundLayers[i]; - if (typeof item === "string") { + if (typeof item === 'string') { var layer = this.map.getBoundLayerById(item); if (layer) { freeLayer.boundLayerSequence.push([layer, 1]); } } else { - var layer = this.map.getBoundLayerById(item["id"]); + var layer = this.map.getBoundLayerById(item['id']); if (layer) { var alpha = 1; - if (typeof item["alpha"] !== "undefined") { - alpha = item["alpha"]; + if (typeof item['alpha'] !== 'undefined') { + alpha = item['alpha']; } freeLayer.boundLayerSequence.push([layer, alpha]); diff --git a/src/core/map/surface-tile.js b/src/core/map/surface-tile.js index 0d081621..515292a1 100755 --- a/src/core/map/surface-tile.js +++ b/src/core/map/surface-tile.js @@ -235,9 +235,9 @@ MapSurfaceTile.prototype.addChild = function(index) { var childId = [id[0] + 1, id[1] << 1, id[2] << 1]; switch (index) { - case 1: childId[1]++; break; - case 2: childId[2]++; break; - case 3: childId[1]++; childId[2]++; break; + case 1: childId[1]++; break; + case 2: childId[2]++; break; + case 3: childId[1]++; childId[2]++; break; } this.children[index] = new MapSurfaceTile(this.map, this, childId); @@ -1057,7 +1057,7 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { //if (this.map.drawLods) { h = this.metanode.minZ; } - var coordsRes = [[h],[h],[h],[h],[h],[h],[h],[h]]; + var coordsRes = [[h],[h],[h],[h],[h],[h],[h],[h]]; //middle[2] = h; //middle = node.getPhysicalCoords(middle, true); @@ -1127,15 +1127,15 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { if (!border2) { mnode.border2 = [ - (border[0] + border[1] + border[3] + border[4]) * 0.25, - (border[1] + border[4]) * 0.5, - (border[2] + border[1] + border[5] + border[4]) * 0.25, - (border[3] + border[4]) * 0.5, + (border[0] + border[1] + border[3] + border[4]) * 0.25, + (border[1] + border[4]) * 0.5, + (border[2] + border[1] + border[5] + border[4]) * 0.25, + (border[3] + border[4]) * 0.5, mnode.minZ, - (border[5] + border[4]) * 0.5, - (border[6] + border[7] + border[3] + border[4]) * 0.25, - (border[7] + border[4]) * 0.5, - (border[8] + border[7] + border[5] + border[4]) * 0.25 + (border[5] + border[4]) * 0.5, + (border[6] + border[7] + border[3] + border[4]) * 0.25, + (border[7] + border[4]) * 0.5, + (border[8] + border[7] + border[5] + border[4]) * 0.25 ]; } @@ -1258,16 +1258,16 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { if (hasPoles && node.isPole) { var factor = map.poleRadiusFactor; var prog = renderer.progPlane2; - renderer.gpu.useProgram(prog, ["aPosition", "aTexCoord"]); - prog.setVec4("uParams4", [-sx, -sy, map.poleRadius, 0]); + renderer.gpu.useProgram(prog, ['aPosition', 'aTexCoord']); + prog.setVec4('uParams4', [-sx, -sy, map.poleRadius, 0]); } else { var prog = renderer.progPlane; - renderer.gpu.useProgram(prog, ["aPosition", "aTexCoord"]); + renderer.gpu.useProgram(prog, ['aPosition', 'aTexCoord']); } - prog.setMat4("uMV", mv); - prog.setMat4("uProj", proj); - prog.setFloatArray("uPoints", buffer); + prog.setMat4('uMV', mv); + prog.setMat4('uProj', proj); + prog.setFloatArray('uPoints', buffer); /* var lx = (ur[0] - ll[0]); @@ -1298,14 +1298,14 @@ MapSurfaceTile.prototype.drawGrid = function(cameraPos, divNode, angle) { var px = (ll[0] - node.extents.ll[0]) * lx * llx; var py = (ur[1] - node.extents.ll[1]) * ly * lly; - prog.setVec4("uParams", [step1 * factor, this.map.fogDensity, 1/15, node.gridStep2 * factor]); - prog.setVec4("uParams3", [(py - Math.floor(py)), (px - Math.floor(px)), lly, llx]); - prog.setVec4("uParams2", [0, 0, node.gridBlend, 0]); + prog.setVec4('uParams', [step1 * factor, this.map.fogDensity, 1/15, node.gridStep2 * factor]); + prog.setVec4('uParams3', [(py - Math.floor(py)), (px - Math.floor(px)), lly, llx]); + prog.setVec4('uParams2', [0, 0, node.gridBlend, 0]); renderer.gpu.bindTexture(renderer.heightmapTexture); //draw bbox - renderer.planeMesh.draw(prog, "aPosition", "aTexCoord"); + renderer.planeMesh.draw(prog, 'aPosition', 'aTexCoord'); }; diff --git a/src/core/map/surface-tree.js b/src/core/map/surface-tree.js index 6e4eae27..fa9cd331 100755 --- a/src/core/map/surface-tree.js +++ b/src/core/map/surface-tree.js @@ -149,7 +149,7 @@ MapSurfaceTree.prototype.draw = function() { if (periodicity != null) { this.drawSurface([0,0,0]); - if (periodicity.type == "X") { + if (periodicity.type == 'X') { this.drawSurface([periodicity.period,0,0]); this.drawSurface([-periodicity.period,0,0]); } @@ -164,9 +164,9 @@ MapSurfaceTree.prototype.draw = function() { } switch(mode) { - case "topdown": this.drawSurface([0,0,0]); break; - case "fit": this.drawSurfaceFit([0,0,0]); break; - case "fitonly": this.drawSurfaceFitOnly([0,0,0]); break; + case 'topdown': this.drawSurface([0,0,0]); break; + case 'fit': this.drawSurfaceFit([0,0,0]); break; + case 'fitonly': this.drawSurfaceFitOnly([0,0,0]); break; } } }; @@ -215,7 +215,7 @@ MapSurfaceTree.prototype.logTileInfo = function(tile, node, cameraPos) { tile.updateTexelSize(); // console.log("tile: " + JSON.stringify(tile.id) + " visible: " + visible + " texelsize: " + tile.texelSize); - 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); + 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); }; @@ -402,8 +402,8 @@ MapSurfaceTree.prototype.drawSurface = function(shift) { /*var n = childrenBuffer[j].metanode.divisionNode; if ((n.id[0] == 1 && n.id[1] == 1 && n.id[2] == 0)) {*/ - newProcessBuffer[newProcessBufferIndex] = childrenBuffer[j]; - newProcessBufferIndex++; + newProcessBuffer[newProcessBufferIndex] = childrenBuffer[j]; + newProcessBufferIndex++; /*}*/ } @@ -569,7 +569,7 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { //if (this.map.drawSurfaceTile(child, child.metanode, cameraPos, child.texelSize, priority, true, false)) { //readyCount++; //child.updateTexelSize(); - childrenBuffer.push(child); + childrenBuffer.push(child); //} else { //check children @@ -613,8 +613,8 @@ MapSurfaceTree.prototype.drawSurfaceFitOnly = function(shift) { //var n = childrenBuffer[j].metanode.divisionNode; //if ((n.id[0] == 1 && n.id[1] == 1 && n.id[2] == 0)) { - newProcessBuffer[newProcessBufferIndex] = childrenBuffer[j]; - newProcessBufferIndex++; + newProcessBuffer[newProcessBufferIndex] = childrenBuffer[j]; + newProcessBufferIndex++; //} } } else { @@ -1063,7 +1063,7 @@ MapSurfaceTree.prototype.traceHeightChild = function(tile, params, res) { var coords = params.coords; var extents = params.extents; var center = [(extents.ll[0] + extents.ur[0]) *0.5, - (extents.ll[1] + extents.ur[1]) *0.5]; + (extents.ll[1] + extents.ur[1]) *0.5]; //ul,ur,ll,lr //deside in which quadrant are provided coodinates @@ -1119,16 +1119,16 @@ MapSurfaceTree.prototype.traceHeightTileByMap = function(tile, params, priority) if (!tile.heightMap) { //if (!preventLoad) { //if (!tile.surface || tile.surface.virtual) { - if (!tile.surface || !tile.resourceSurface) { //surface.virtual) { - return false; //is it best way how to do it? - } + if (!tile.surface || !tile.resourceSurface) { //surface.virtual) { + return false; //is it best way how to do it? + } - if (!tile.resourceSurface.getNavUrl) { //virtual surface is as resource surface. Is it bug??!! - return false; //is it best way how to do it? - } + if (!tile.resourceSurface.getNavUrl) { //virtual surface is as resource surface. Is it bug??!! + return false; //is it best way how to do it? + } - var path = tile.resourceSurface.getNavUrl(tile.id); - tile.heightMap = tile.resources.getTexture(path, true); + var path = tile.resourceSurface.getNavUrl(tile.id); + tile.heightMap = tile.resources.getTexture(path, true); //} } else { if (tile.heightMap.isReady() == true) { @@ -1181,7 +1181,7 @@ MapSurfaceTree.prototype.traceHeightTileByNodeOnly = function(tile, params, prio MapSurfaceTree.prototype.getNodeById = function(id) { var tile = this.surfaceTree; - var createNonexisted = true; + var createNonexisted = true; if (tile == null) { return; @@ -1215,15 +1215,15 @@ MapSurfaceTree.prototype.getNodeById = function(id) { tile = tile.children[index]; } - if (!tile) { - return; - } + if (!tile) { + return; + } if (!tile.isMetanodeReady(this, 0)) { return; } - var node = tile.metanode; + var node = tile.metanode; tile.metanode.metatile.used(); return node; diff --git a/src/core/map/surface.js b/src/core/map/surface.js index 47e7647c..506937b8 100755 --- a/src/core/map/surface.js +++ b/src/core/map/surface.js @@ -18,13 +18,13 @@ var utilsUrl = utilsUrl_; var MapSurface = function(map, json, type) { this.map = map; this.id = null; - this.type = "basic"; + this.type = 'basic'; this.metaBinaryOrder = 1; - this.metaUrl = ""; - this.navUrl = ""; + this.metaUrl = ''; + this.navUrl = ''; this.navDelta = 1; - this.meshUrl = ""; - this.textureUrl = ""; + this.meshUrl = ''; + this.textureUrl = ''; this.baseUrl = this.map.url.baseUrl; this.baseUrlSchema = this.map.url.baseUrlSchema; this.baseUrlOrigin = this.map.url.baseUrlOrigin; @@ -32,8 +32,8 @@ var MapSurface = function(map, json, type) { this.tileRange = [[0,0],[0,0]]; this.textureLayer = null; this.boundLayerSequence = []; - this.glue = (type == "glue"); - this.free = (type == "free"); + this.glue = (type == 'glue'); + this.free = (type == 'free'); this.virtual = false; this.zFactor = 0; this.ready = false; @@ -57,7 +57,7 @@ var MapSurface = function(map, json, type) { this.tree = null; } - if (typeof json === "string") { + if (typeof json === 'string') { this.jsonUrl = this.map.url.processUrl(json); this.baseUrl = utilsUrl_.getBase(this.jsonUrl); this.baseUrlSchema = utilsUrl_.getSchema(this.jsonUrl); @@ -81,26 +81,26 @@ var MapSurface = function(map, json, type) { MapSurface.prototype.parseJson = function(json) { - this.id = json["id"] || null; - this.type = json["type"] || "basic"; - this.metaBinaryOrder = json["metaBinaryOrder"] || 1; - this.metaUrl = this.processUrl(json["metaUrl"], ""); - this.navUrl = this.processUrl(json["navUrl"], ""); - this.navDelta = json["navDelta"] || 1; - this.meshUrl = this.processUrl(json["meshUrl"], ""); - this.textureUrl = this.processUrl(json["textureUrl"], ""); - this.geodataUrl = this.processUrl(json["geodataUrl"] || json["geodata"], ""); - this.lodRange = json["lodRange"] || [0,0]; - this.tileRange = json["tileRange"] || [[0,0],[0,0]]; - this.textureLayer = json["textureLayer"] || null; - this.geodata = (this.type == "geodata" || this.type == "geodata-tiles"); - this.credits = json["credits"] || []; + this.id = json['id'] || null; + this.type = json['type'] || 'basic'; + this.metaBinaryOrder = json['metaBinaryOrder'] || 1; + this.metaUrl = this.processUrl(json['metaUrl'], ''); + this.navUrl = this.processUrl(json['navUrl'], ''); + this.navDelta = json['navDelta'] || 1; + this.meshUrl = this.processUrl(json['meshUrl'], ''); + this.textureUrl = this.processUrl(json['textureUrl'], ''); + this.geodataUrl = this.processUrl(json['geodataUrl'] || json['geodata'], ''); + this.lodRange = json['lodRange'] || [0,0]; + this.tileRange = json['tileRange'] || [[0,0],[0,0]]; + this.textureLayer = json['textureLayer'] || null; + this.geodata = (this.type == 'geodata' || this.type == 'geodata-tiles'); + this.credits = json['credits'] || []; this.creditsUrl = null; - this.displaySize = json["displaySize"] || 256; + this.displaySize = json['displaySize'] || 256; - if (json["extents"]) { - var ll = json["extents"]["ll"]; - var ur = json["extents"]["ur"]; + if (json['extents']) { + var ll = json['extents']['ll']; + var ur = json['extents']['ur']; this.extents = new BBox(ll[0], ll[1], ll[2], ur[0], ur[1], ur[2]); } else { this.extents = new BBox(0,0,0,1,1,1); @@ -109,40 +109,40 @@ MapSurface.prototype.parseJson = function(json) { this.specificity = Math.pow(2,this.lodRange[0]) / ((this.tileRange[1][0] - this.tileRange[1][0]+1)*(this.tileRange[1][1] - this.tileRange[1][1]+1)); switch(typeof this.credits) { - case "string": - this.creditsUrl = this.credits; - this.credits = []; - break; + case 'string': + this.creditsUrl = this.credits; + this.credits = []; + break; - case "object": + case 'object': - if (!Array.isArray(this.credits)) { - var credits = this.credits; - this.credits = []; + if (!Array.isArray(this.credits)) { + var credits = this.credits; + this.credits = []; - for (var key in credits){ - this.map.addCredit(key, new MapCredit(this.map, credits[key])); - this.credits.push(key); - } + for (var key in credits){ + this.map.addCredit(key, new MapCredit(this.map, credits[key])); + this.credits.push(key); } + } - 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); - } + 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; + break; } - if (this.geodataUrl && (typeof this.geodataUrl === "string") && this.geodataUrl.indexOf("{geonavtile}") != -1) { + if (this.geodataUrl && (typeof this.geodataUrl === 'string') && this.geodataUrl.indexOf('{geonavtile}') != -1) { //this.geodataNavtileInfo = true; this.geodataNavtileInfo = false; } //load stylesheet if (this.geodata) { - var style = json["style"]; + var style = json['style']; this.originalStyle = style; if (style) { @@ -186,23 +186,23 @@ MapSurface.prototype.getOptions = function() { MapSurface.prototype.getInfo = function() { if (this.geodata) { return { - "type" : this.type, - "metaUrl" : this.metaUrl, - "geodataUrl" : this.geodataUrl, - "lodRange" : this.lodRange, - "tileRange" : this.tileRange, - "style" : this.originalStyle + 'type' : this.type, + 'metaUrl' : this.metaUrl, + 'geodataUrl' : this.geodataUrl, + 'lodRange' : this.lodRange, + 'tileRange' : this.tileRange, + 'style' : this.originalStyle }; } else { return { - "type" : this.type, - "metaUrl" : this.metaUrl, - "navUrl" : this.navUrl, - "meshUrl" : this.meshUrl, - "textureUrl" : this.textureUrl, - "lodRange" : this.lodRange, - "tileRange" : this.tileRange, - "textureLayer" : this.textureLayer + 'type' : this.type, + 'metaUrl' : this.metaUrl, + 'navUrl' : this.navUrl, + 'meshUrl' : this.meshUrl, + 'textureUrl' : this.textureUrl, + 'lodRange' : this.lodRange, + 'tileRange' : this.tileRange, + 'textureLayer' : this.textureLayer }; } }; @@ -213,17 +213,17 @@ MapSurface.prototype.processUrl = function(url, fallback) { return fallback; } - if (typeof url !== "string") { + if (typeof url !== 'string') { return url; } url = url.trim(); - if (url.indexOf("://") != -1) { //absolute + if (url.indexOf('://') != -1) { //absolute return url; - } else if (url.indexOf("//") == 0) { //absolute without schema + } else if (url.indexOf('//') == 0) { //absolute without schema return this.baseUrlSchema + url; - } else if (url.indexOf("/") == 0) { //absolute without host + } else if (url.indexOf('/') == 0) { //absolute without host return this.baseUrlOrigin + url; } else { //relative return this.baseUrl + url; @@ -347,7 +347,7 @@ MapSurface.prototype.getNavUrl = function(id, skipBaseUrl) { MapSurface.prototype.getNavTemplate = function(id, skipBaseUrl) { - if (this.navUrl.indexOf("//") != -1){ + if (this.navUrl.indexOf('//') != -1){ return this.navUrl; } else { this.map.url.baseUrl + url; diff --git a/src/core/map/texture.js b/src/core/map/texture.js index 266ccdc3..68fc85ae 100755 --- a/src/core/map/texture.js +++ b/src/core/map/texture.js @@ -41,9 +41,9 @@ var MapTexture = function(map, path, heightMap, extraBound, extraInfo, tile, int if (layer.availability) { this.checkType = layer.availability.type; switch (this.checkType) { - case "negative-type": this.checkValue = layer.availability.mime; break; - case "negative-code": this.checkValue = layer.availability.codes; break; - case "negative-size": this.checkValue = layer.availability.size; break; + case 'negative-type': this.checkValue = layer.availability.mime; break; + case 'negative-code': this.checkValue = layer.availability.codes; break; + case 'negative-size': this.checkValue = layer.availability.size; break; } } } @@ -153,85 +153,85 @@ MapTexture.prototype.isReady = function(doNotLoad, priority, doNotCheckGpu) { }*/ switch (this.checkType) { - case "metatile": - - if (this.checkStatus != 2) { - if (this.checkStatus == 0) { - if (this.extraInfo && this.extraInfo.tile) { - var metaresources = this.extraInfo.tile.boundmetaresources; - if (!metaresources) { - metaresources = this.map.resourcesTree.findAgregatedNode(this.extraInfo.tile.id, 8); - this.extraInfo.tile.boundmetaresources = metaresources; - } + case 'metatile': + + if (this.checkStatus != 2) { + if (this.checkStatus == 0) { + if (this.extraInfo && this.extraInfo.tile) { + var metaresources = this.extraInfo.tile.boundmetaresources; + if (!metaresources) { + metaresources = this.map.resourcesTree.findAgregatedNode(this.extraInfo.tile.id, 8); + this.extraInfo.tile.boundmetaresources = metaresources; + } - var layer = this.extraInfo.layer; - var path = this.extraInfo.metaPath; + var layer = this.extraInfo.layer; + var path = this.extraInfo.metaPath; - if(!this.extraInfo.metaPath) { - var path = layer.getMetatileUrl(metaresources.id); - this.extraInfo.metaPath = path; - } + if(!this.extraInfo.metaPath) { + var path = layer.getMetatileUrl(metaresources.id); + this.extraInfo.metaPath = path; + } - var texture = metaresources.getTexture(path, true, null, null, this.tile, this.internal); + var texture = metaresources.getTexture(path, true, null, null, this.tile, this.internal); - if (this.maskTexture) { - if (this.maskTexture.isReady(doNotLoad, priority, doNotCheckGpu, this)) { - this.checkStatus = 2; - } - } else { - if (texture.isReady(doNotLoad, priority, doNotCheckGpu)) { - var tile = this.extraInfo.tile; - var value = texture.getHeightMapValue(tile.id[1] & 255, tile.id[2] & 255); - this.checkStatus = (value & 128) ? 2 : -1; + if (this.maskTexture) { + if (this.maskTexture.isReady(doNotLoad, priority, doNotCheckGpu, this)) { + this.checkStatus = 2; + } + } else { + if (texture.isReady(doNotLoad, priority, doNotCheckGpu)) { + var tile = this.extraInfo.tile; + var value = texture.getHeightMapValue(tile.id[1] & 255, tile.id[2] & 255); + this.checkStatus = (value & 128) ? 2 : -1; - if (this.checkStatus == 2) { - if (!(value & 64)) { //load mask - var path = layer.getMaskUrl(tile.id); - this.maskTexture = tile.resources.getTexture(path, null, null, null, this.tile, this.internal); - this.checkStatus = 0; - tile.resetDrawCommands = true; - this.map.markDirty(); - } + if (this.checkStatus == 2) { + if (!(value & 64)) { //load mask + var path = layer.getMaskUrl(tile.id); + this.maskTexture = tile.resources.getTexture(path, null, null, null, this.tile, this.internal); + this.checkStatus = 0; + tile.resetDrawCommands = true; + this.map.markDirty(); } } } } } + } - if (this.checkStatus == -1) { - if (!this.extraBound) { - var parent = this.extraInfo.tile.parent; - if (parent.id[0] < this.extraInfo.layer.lodRange[0]) { - this.neverReady = true; - this.extraInfo.tile.resetDrawCommands = true; - this.map.markDirty(); - return false; - } - - this.extraBound = { tile: this.extraInfo.tile, layer: this.extraInfo.layer}; - this.setBoundTexture(this.extraBound.tile.parent, this.extraBound.layer); - this.checkMask = true; + if (this.checkStatus == -1) { + if (!this.extraBound) { + var parent = this.extraInfo.tile.parent; + if (parent.id[0] < this.extraInfo.layer.lodRange[0]) { + this.neverReady = true; + this.extraInfo.tile.resetDrawCommands = true; + this.map.markDirty(); + return false; } - while (this.extraBound.texture.extraBound || this.extraBound.texture.checkStatus == -1) { + this.extraBound = { tile: this.extraInfo.tile, layer: this.extraInfo.layer}; + this.setBoundTexture(this.extraBound.tile.parent, this.extraBound.layer); + this.checkMask = true; + } + + while (this.extraBound.texture.extraBound || this.extraBound.texture.checkStatus == -1) { //while (this.extraBound.texture.checkStatus == -1) { - var parent = this.extraBound.sourceTile.parent; - if (parent.id[0] < this.extraBound.layer.lodRange[0]) { - this.neverReady = true; - this.extraBound.tile.resetDrawCommands = true; - this.map.markDirty(); - return false; - } - - this.setBoundTexture(parent, this.extraBound.layer); + var parent = this.extraBound.sourceTile.parent; + if (parent.id[0] < this.extraBound.layer.lodRange[0]) { + this.neverReady = true; + this.extraBound.tile.resetDrawCommands = true; + this.map.markDirty(); + return false; } + + this.setBoundTexture(parent, this.extraBound.layer); } - - return false; } + + return false; + } - break; + break; } var maskState = true; diff --git a/src/core/map/trajectory.js b/src/core/map/trajectory.js index 568fc1cb..ce9de95e 100755 --- a/src/core/map/trajectory.js +++ b/src/core/map/trajectory.js @@ -14,19 +14,19 @@ var MapTrajectory = function(map, p1, p2, options) { var hm1 = this.p1.getHeightMode(); var hm2 = this.p2.getHeightMode(); - if (hm1 == "fix" && hm2 == "float") { - this.p1 = this.map.convert.convertPositionHeightMode(this.p1, "float", true); - } else if (hm1 == "float" && hm2 == "fix") { - this.p1 = this.map.convert.convertPositionHeightMode(this.p1, "fix", true); + if (hm1 == 'fix' && hm2 == 'float') { + this.p1 = this.map.convert.convertPositionHeightMode(this.p1, 'float', true); + } else if (hm1 == 'float' && hm2 == 'fix') { + this.p1 = this.map.convert.convertPositionHeightMode(this.p1, 'fix', true); } var vm1 = this.p1.getViewMode(); var vm2 = this.p2.getViewMode(); - if (vm1 == "subj" && vm2 == "obj") { - this.p2 = this.map.convert.convertPositionViewMode(this.p2, "subj"); - } else if (vm1 == "obj" && vm2 == "subj") { - this.p1 = this.map.convert.convertPositionViewMode(this.p1, "subj"); + if (vm1 == 'subj' && vm2 == 'obj') { + this.p2 = this.map.convert.convertPositionViewMode(this.p2, 'subj'); + } else if (vm1 == 'obj' && vm2 == 'subj') { + this.p1 = this.map.convert.convertPositionViewMode(this.p1, 'subj'); } this.p1.pos[5] = this.p1.pos[5] < 0 ? (360 + (this.p1.pos[5] % 360)) : (this.p1.pos[5] % 360); @@ -34,40 +34,40 @@ var MapTrajectory = function(map, p1, p2, options) { this.pp1 = this.p1.clone(); - this.mode = options["mode"] || "auto"; - this.submode = options["submode"] || "none"; - this.submode = "none"; - this.maxHeight = options["maxHeight"] || 1000000000; - this.minDuration = options["minDuration"] || 0; - this.maxDuration = options["maxDuration"] || 10000; - this.samplePeriod = options["samplePeriod"] || 10; - this.fade = options["fade"] || "none"; - this.fadePower = options["fadePower"] || 1; + this.mode = options['mode'] || 'auto'; + this.submode = options['submode'] || 'none'; + this.submode = 'none'; + this.maxHeight = options['maxHeight'] || 1000000000; + this.minDuration = options['minDuration'] || 0; + this.maxDuration = options['maxDuration'] || 10000; + this.samplePeriod = options['samplePeriod'] || 10; + this.fade = options['fade'] || 'none'; + this.fadePower = options['fadePower'] || 1; - this.pv = options["pv"] || 0.15; + this.pv = options['pv'] || 0.15; if (!this.map.getNavigationSrs().isProjected()) { this.geodesic = this.map.measure.getGeodesic(); } - if (options["distanceAzimuth"]) { + if (options['distanceAzimuth']) { this.distanceAzimuth = true; this.pp2 = this.p1.clone(); - if (options["destHeight"]) { - this.pp2.setHeight(options["destHeight"]); + if (options['destHeight']) { + this.pp2.setHeight(options['destHeight']); } - if (options["destOrientation"]) { - this.pp2.setHeight(options["destOrientation"]); + if (options['destOrientation']) { + this.pp2.setHeight(options['destOrientation']); } - if (options["destFov"]) { - this.pp2.setHeight(options["destFov"]); + if (options['destFov']) { + this.pp2.setHeight(options['destFov']); } - this.geoAzimuth = options["azimuth"] || 0; - this.geoDistance = options["distance"] || 100; + this.geoAzimuth = options['azimuth'] || 0; + this.geoDistance = options['distance'] || 100; this.distance = this.geoDistance; this.azimuth = this.geoAzimuth % 360; this.azimuth = (this.azimuth < 0) ? (360 + this.azimuth) : this.azimuth; @@ -96,12 +96,12 @@ var MapTrajectory = function(map, p1, p2, options) { this.detectMode(); this.detectDuration(); - this.detectFlightHeight(options["height"]); + this.detectFlightHeight(options['height']); }; MapTrajectory.prototype.detectFlightHeight = function(flightHeight) { - if (this.mode == "ballistic") { + if (this.mode == 'ballistic') { this.flightHeight = Math.max(this.pp1.getHeight(), this.pp2.getHeight()); this.flightHeight += flightHeight || (this.distance * 0.5); this.flightHeight = Math.min(this.flightHeight, this.maxHeight); @@ -111,8 +111,8 @@ MapTrajectory.prototype.detectFlightHeight = function(flightHeight) { MapTrajectory.prototype.detectMode = function() { - if (this.mode == "auto") { - this.mode = (this.distance > 2000) ? "ballistic" : "direct"; + if (this.mode == 'auto') { + this.mode = (this.distance > 2000) ? 'ballistic' : 'direct'; } }; @@ -142,13 +142,13 @@ MapTrajectory.prototype.detectDuration = function() { this.duration = 10000; } - if (this.mode != "direct") { - this.duration *= 1.8; - this.headingDuration *= 1.8; + if (this.mode != 'direct') { + this.duration *= 1.8; + this.headingDuration *= 1.8; } } - if (this.mode != "direct") { + if (this.mode != 'direct') { var minDuration = 3 * this.headingDuration; this.duration = Math.max(this.duration, minDuration); @@ -172,44 +172,44 @@ MapTrajectory.prototype.generate = function() { var p = this.pp1.clone(); - if (this.mode == "direct") { + if (this.mode == 'direct') { var x = factor; switch(this.fade) { - case "in": - switch(this.fadePower) { - case 1: factor = x*x; break; - case 2: factor = x*x*x; break; - case 3: factor = x*x*x*x; break; - case 4: factor = x*x*x*x*x; break; - case 5: factor = x*x*x*x*x*x; break; - case 6: factor = x*x*x*x*x*x*x; break; - } - break; - - case "out": - x = 1 - x; - switch(this.fadePower) { - case 1: factor = 1 - (x*x); break; - case 2: factor = 1 - (x*x*x); break; - case 3: factor = 1 - (x*x*x*x); break; - case 4: factor = 1 - (x*x*x*x*x); break; - case 5: factor = 1 - (x*x*x*x*x*x); break; - case 6: factor = 1 - (x*x*x*x*x*x*x); break; - } - break; - - case "inout": - switch(this.fadePower) { - case 1: factor = x*x*(3 - 2*x); break; - case 2: factor = x*x*x * (x * (6*x - 15) + 10); break; - case 3: factor = x*x*(3 - 2*x); x = factor; factor = x*x*(3 - 2*x); break; - case 4: factor = x*x*x * (x * (6*x - 15) + 10); x = factor; factor = x*x*x * (x * (6*x - 15) + 10); break; - case 5: factor = x*x*(3 - 2*x); x = factor; factor = x*x*(3 - 2*x); x = factor; factor = x*x*(3 - 2*x); break; - case 6: factor = x*x*x * (x * (6*x - 15) + 10); x = factor; factor = x*x*x * (x * (6*x - 15) + 10); x = factor; factor = x*x*x * (x * (6*x - 15) + 10); break; - } - break; + case 'in': + switch(this.fadePower) { + case 1: factor = x*x; break; + case 2: factor = x*x*x; break; + case 3: factor = x*x*x*x; break; + case 4: factor = x*x*x*x*x; break; + case 5: factor = x*x*x*x*x*x; break; + case 6: factor = x*x*x*x*x*x*x; break; + } + break; + + case 'out': + x = 1 - x; + switch(this.fadePower) { + case 1: factor = 1 - (x*x); break; + case 2: factor = 1 - (x*x*x); break; + case 3: factor = 1 - (x*x*x*x); break; + case 4: factor = 1 - (x*x*x*x*x); break; + case 5: factor = 1 - (x*x*x*x*x*x); break; + case 6: factor = 1 - (x*x*x*x*x*x*x); break; + } + break; + + case 'inout': + switch(this.fadePower) { + case 1: factor = x*x*(3 - 2*x); break; + case 2: factor = x*x*x * (x * (6*x - 15) + 10); break; + case 3: factor = x*x*(3 - 2*x); x = factor; factor = x*x*(3 - 2*x); break; + case 4: factor = x*x*x * (x * (6*x - 15) + 10); x = factor; factor = x*x*x * (x * (6*x - 15) + 10); break; + case 5: factor = x*x*(3 - 2*x); x = factor; factor = x*x*(3 - 2*x); x = factor; factor = x*x*(3 - 2*x); break; + case 6: factor = x*x*x * (x * (6*x - 15) + 10); x = factor; factor = x*x*x * (x * (6*x - 15) + 10); x = factor; factor = x*x*x * (x * (6*x - 15) + 10); break; + } + break; } p.setCoords(this.getInterpolatedCoords(factor)); @@ -235,7 +235,7 @@ MapTrajectory.prototype.generate = function() { //factor2 includes slow start and end of flight var factor2 = this.getSmoothFactor(time); - if (this.submode == "piha") { + if (this.submode == 'piha') { var distanceFactor = (this.distance / this.duration * (time - this.duration / (2 * Math.PI) * Math.sin(2 * Math.PI / this.duration * time))) / this.distance; @@ -305,12 +305,12 @@ MapTrajectory.prototype.getInterpolatedCoords = function(factor) { return [ res.lon2, res.lat2, - c1[2] + (c2[2] - c1[2]) * factor, azimut]; + c1[2] + (c2[2] - c1[2]) * factor, azimut]; } else { return [ c1[0] + (c2[0] - c1[0]) * factor, - c1[1] + (c2[1] - c1[1]) * factor, - c1[2] + (c2[2] - c1[2]) * factor ]; + c1[1] + (c2[1] - c1[1]) * factor, + c1[2] + (c2[2] - c1[2]) * factor ]; } }; @@ -329,8 +329,8 @@ MapTrajectory.prototype.getInterpolatedOrinetation = function(o1, o2, factor) { } return [ o1[0] + od1 * factor, - o1[1] + od2 * factor, - o1[2] + od3 * factor ]; + o1[1] + od2 * factor, + o1[2] + od3 * factor ]; }; diff --git a/src/core/map/url.js b/src/core/map/url.js index 4a6acd07..60802351 100755 --- a/src/core/map/url.js +++ b/src/core/map/url.js @@ -19,8 +19,8 @@ var MapUrl = function(map, path) { }; -MapUrl.prototype["quad"] = function(lod, ix, iy) { - var quadKey = ""; +MapUrl.prototype['quad'] = function(lod, ix, iy) { + var quadKey = ''; //ty = Math.pow(2,zoom - 1) - ty; for (var i = lod; i > 0; i--) { var digit = 0; @@ -40,7 +40,7 @@ MapUrl.prototype["quad"] = function(lod, ix, iy) { }; -MapUrl.prototype["msDigit"] = function(iy, ix) { +MapUrl.prototype['msDigit'] = function(iy, ix) { return (((iy & 3) << 1) + (ix & 1)); }; @@ -48,26 +48,26 @@ MapUrl.prototype["msDigit"] = function(iy, ix) { MapUrl.prototype.hex = function(v, n) { var s = v.toString(16); while (s.length < 8) { - s = "0" + s; + s = '0' + s; } return s; }; -MapUrl.prototype["ppx"] = function(lod, ix) { +MapUrl.prototype['ppx'] = function(lod, ix) { return this.hex(ix << (28 - lod), 7); }; -MapUrl.prototype["ppy"] = function(lod, iy) { +MapUrl.prototype['ppy'] = function(lod, iy) { return this.hex((1 << 28) - ((iy + 1) << (28 - lod)), 7); }; MapUrl.prototype.processUrlFunction = function(id, counter, string) { - if (typeof string == "string") { - if (string.indexOf("quad") != -1) { - var string2 = "(function(lod,x,y,loclod,locx,locy){" + string.replace("quad", "return this.quad") + "})"; + if (typeof string == 'string') { + if (string.indexOf('quad') != -1) { + var string2 = '(function(lod,x,y,loclod,locx,locy){' + string.replace('quad', 'return this.quad') + '})'; try { var fc = eval(string2).bind(this); @@ -75,8 +75,8 @@ MapUrl.prototype.processUrlFunction = function(id, counter, string) { } catch(e) { return string; } - } else if (string.indexOf("msdigit") != -1) { - var string2 = "(function(x,y,loclod,locx,locy){" + string.replace("msdigit", "return this.msDigit") + "})"; + } else if (string.indexOf('msdigit') != -1) { + var string2 = '(function(x,y,loclod,locx,locy){' + string.replace('msdigit', 'return this.msDigit') + '})'; try { var fc = eval(string2).bind(this); @@ -85,7 +85,7 @@ MapUrl.prototype.processUrlFunction = function(id, counter, string) { return string; } - } else if (string.indexOf("alt") != -1) { + } else if (string.indexOf('alt') != -1) { var result = /\(([^)]*)\)/.exec(string); @@ -99,9 +99,9 @@ MapUrl.prototype.processUrlFunction = function(id, counter, string) { return string; - } else if (string.indexOf("ppx") != -1) { + } else if (string.indexOf('ppx') != -1) { - var string2 = "(function(lod,x,loclod,locx){" + string.replace("ppx", "return this.ppx") + "})"; + var string2 = '(function(lod,x,loclod,locx){' + string.replace('ppx', 'return this.ppx') + '})'; try { var fc = eval(string2).bind(this); @@ -110,9 +110,9 @@ MapUrl.prototype.processUrlFunction = function(id, counter, string) { return string; } - } else if (string.indexOf("ppy") != -1) { + } else if (string.indexOf('ppy') != -1) { - var string2 = "(function(lod,y,loclod,locy){" + string.replace("ppy", "return this.ppy") + "})"; + var string2 = '(function(lod,y,loclod,locy){' + string.replace('ppy', 'return this.ppy') + '})'; try { var fc = eval(string2).bind(this); @@ -198,14 +198,14 @@ MapUrl.prototype.makeUrl = function(templ, id, subId, skipBaseUrl) { //remove white spaces from template templ = templ.replace(/ /g, ''); - var url = utils.simpleFmtObjOrCall(templ, {"lod":id.lod, "x":id.ix, "y":id.iy, "sub": subId, - "locx":locx, "locy":locy, "loclod":loclod, "geonavtile": subId, - "hereappid": "abcde", "hereappcode":"12345"}, + var url = utils.simpleFmtObjOrCall(templ, {'lod':id.lod, 'x':id.ix, 'y':id.iy, 'sub': subId, + 'locx':locx, 'locy':locy, 'loclod':loclod, 'geonavtile': subId, + 'hereappid': 'abcde', 'hereappcode':'12345'}, this.processUrlFunction.bind(this, id2, this.urlCounter)); this.urlCounter++; - skipBaseUrl = (url.indexOf("//") != -1); + skipBaseUrl = (url.indexOf('//') != -1); /* //useful for debug var tmp; @@ -218,7 +218,7 @@ MapUrl.prototype.makeUrl = function(templ, id, subId, skipBaseUrl) { */ if (skipBaseUrl) { - if (url.indexOf("//") == 0) { + if (url.indexOf('//') == 0) { return this.baseUrlSchema + url; } else { return url; @@ -236,11 +236,11 @@ MapUrl.prototype.processUrl = function(url, fallback) { url = url.trim(); - if (url.indexOf("://") != -1) { //absolute + if (url.indexOf('://') != -1) { //absolute return url; - } else if (url.indexOf("//") == 0) { //absolute without schema + } else if (url.indexOf('//') == 0) { //absolute without schema return this.baseUrlSchema + url; - } else if (url.indexOf("/") == 0) { //absolute without host + } else if (url.indexOf('/') == 0) { //absolute without host return this.baseUrlOrigin + url; } else { //relative return this.baseUrl + url; diff --git a/src/core/map/view.js b/src/core/map/view.js index 5c26ce45..12c92d74 100755 --- a/src/core/map/view.js +++ b/src/core/map/view.js @@ -7,13 +7,13 @@ var MapView = function(map, json) { MapView.prototype.parse = function(json) { - this.description = json["description"] || ""; + this.description = json['description'] || ''; //this.boundLayers = json["boundLayers"] || []; - this.freeLayers = json["freeLayers"] || {}; + this.freeLayers = json['freeLayers'] || {}; this.surfaces = {}; - if (json["surfaces"]) { - var surfaces = json["surfaces"]; + if (json['surfaces']) { + var surfaces = json['surfaces']; if (Array.isArray(surfaces)) { //convert from old version for (var i = 0, li = surfaces.length; i < li; i++) { this.surfaces[surfaces[i]] = []; @@ -35,10 +35,10 @@ MapView.prototype.parse = function(json) { MapView.prototype.getInfo = function() { return { - "description" : JSON.parse(JSON.stringify(this.description)), - "surfaces" : JSON.parse(JSON.stringify(this.surfaces)), + 'description' : JSON.parse(JSON.stringify(this.description)), + 'surfaces' : JSON.parse(JSON.stringify(this.surfaces)), //"boundLayers" : JSON.parse(JSON.stringify(this.boundLayers)), - "freeLayers" : JSON.parse(JSON.stringify(this.freeLayers)) + 'freeLayers' : JSON.parse(JSON.stringify(this.freeLayers)) }; }; diff --git a/src/core/map/virtual-surface.js b/src/core/map/virtual-surface.js index 230fc5ff..28ba2910 100755 --- a/src/core/map/virtual-surface.js +++ b/src/core/map/virtual-surface.js @@ -10,8 +10,8 @@ var utils = utils_; var MapVirtualSurface = function(map, json, type) { this.map = map; this.id = null; - this.metaUrl = ""; - this.mappingUrl = ""; + this.metaUrl = ''; + this.mappingUrl = ''; this.baseUrl = this.map.url.baseUrl; this.baseUrlSchema = this.map.url.baseUrlSchema; this.baseUrlOrigin = this.map.url.baseUrlOrigin; @@ -25,22 +25,22 @@ var MapVirtualSurface = function(map, json, type) { MapVirtualSurface.prototype.parseJson = function(json) { - this.id = json["id"] || null; - this.metaUrl = this.processUrl(json["metaUrl"], ""); - this.mappingUrl = this.processUrl(json["mapping"], ""); - this.lodRange = json["lodRange"] || [0,0]; - this.tileRange = json["tileRange"] || [[0,0],[0,0]]; - this.strId = this.id ? this.id.join(";") : null; + this.id = json['id'] || null; + this.metaUrl = this.processUrl(json['metaUrl'], ''); + this.mappingUrl = this.processUrl(json['mapping'], ''); + this.lodRange = json['lodRange'] || [0,0]; + this.tileRange = json['tileRange'] || [[0,0],[0,0]]; + this.strId = this.id ? this.id.join(';') : null; if (this.id) { var tmp = this.id.slice(); tmp.sort(); - this.strId = tmp.join(";"); + this.strId = tmp.join(';'); } - if (json["extents"]) { - var ll = json["extents"]["ll"]; - var ur = json["extents"]["ur"]; + if (json['extents']) { + var ll = json['extents']['ll']; + var ur = json['extents']['ur']; this.extents = new BBox(ll[0], ll[1], ll[2], ur[0], ur[1], ur[2]); } else { this.extents = new BBox(0,0,0,1,1,1); @@ -66,11 +66,11 @@ MapVirtualSurface.prototype.onMappingFileLoadError = function(data) { MapVirtualSurface.prototype.parseMappingFile = function(data) { var index = 0; - var magic = ""; + var magic = ''; magic += String.fromCharCode(data.getUint8(index, true)); index += 1; magic += String.fromCharCode(data.getUint8(index, true)); index += 1; - if (magic != "TM") { + if (magic != 'TM') { return false; } @@ -92,7 +92,7 @@ MapVirtualSurface.prototype.parseMappingFile = function(data) { if (id.length == 1) { //get surface this.surfaces.push(this.map.getSurface(id[0])); } else { //get glue - this.surfaces.push(this.map.getGlue(id.join(";"))); + this.surfaces.push(this.map.getGlue(id.join(';'))); } } @@ -102,10 +102,10 @@ MapVirtualSurface.prototype.parseMappingFile = function(data) { MapVirtualSurface.prototype.getInfo = function() { return { - "metaUrl" : this.metaUrl, - "mapping" : this.mappingUrl, - "lodRange" : this.lodRange, - "tileRange" : this.tileRange + 'metaUrl' : this.metaUrl, + 'mapping' : this.mappingUrl, + 'lodRange' : this.lodRange, + 'tileRange' : this.tileRange }; }; @@ -117,11 +117,11 @@ MapVirtualSurface.prototype.processUrl = function(url, fallback) { url = url.trim(); - if (url.indexOf("://") != -1) { //absolute + if (url.indexOf('://') != -1) { //absolute return url; - } else if (url.indexOf("//") == 0) { //absolute without schema + } else if (url.indexOf('//') == 0) { //absolute without schema return this.baseUrlSchema + url; - } else if (url.indexOf("/") == 0) { //absolute without host + } else if (url.indexOf('/') == 0) { //absolute without host return this.baseUrlOrigin + url; } else { //relative return this.baseUrl + url; diff --git a/src/core/renderer/draw.js b/src/core/renderer/draw.js index ddb3073f..b8b3d7f4 100755 --- a/src/core/renderer/draw.js +++ b/src/core/renderer/draw.js @@ -42,16 +42,16 @@ RendererDraw.prototype.drawSkydome = function(texture, shader) { mat4.multiply(mvp, normMat, mvp); - gpu.useProgram(shader, ["aPosition", "aTexCoord"]); + gpu.useProgram(shader, ['aPosition', 'aTexCoord']); gpu.bindTexture(texture); // this.gpu.bindTexture(this.hitmapTexture); - shader.setSampler("uSampler", 0); - shader.setMat4("uMVP", mvp); + shader.setSampler('uSampler', 0); + shader.setMat4('uMVP', mvp); gl.depthMask(false); - renderer.skydomeMesh.draw(shader, "aPosition", "aTexCoord"); + renderer.skydomeMesh.draw(shader, 'aPosition', 'aTexCoord'); gl.depthMask(true); gl.enable(gl.CULL_FACE); @@ -85,15 +85,15 @@ RendererDraw.prototype.drawTBall = function(position, size, shader, texture, siz mat4.multiply(mvp, normMat, mvp); //var shader = this.progStardome; - gpu.useProgram(shader, ["aPosition", "aTexCoord"]); + gpu.useProgram(shader, ['aPosition', 'aTexCoord']); gpu.bindTexture(texture || renderer.redTexture); - shader.setSampler("uSampler", 0); - shader.setMat4("uMVP", mvp); + shader.setSampler('uSampler', 0); + shader.setMat4('uMVP', mvp); //this.atmoMesh.draw(shader, "aPosition", null /*"aTexCoord"*/); //this.atmoMesh.draw(shader, "aPosition", "aTexCoord"); - renderer.skydomeMesh.draw(shader, "aPosition", "aTexCoord"); + renderer.skydomeMesh.draw(shader, 'aPosition', 'aTexCoord'); renderer.renderedPolygons += renderer.skydomeMesh.getPolygons(); @@ -135,33 +135,33 @@ RendererDraw.prototype.drawBall = function(position, size, shader, params, param //var shader = this.progStardome; - gpu.useProgram(shader, ["aPosition"]); + gpu.useProgram(shader, ['aPosition']); gpu.bindTexture(renderer.redTexture); - shader.setSampler("uSampler", 0); - shader.setMat4("uProj", proj); - shader.setMat4("uMV", mv); + shader.setSampler('uSampler', 0); + shader.setMat4('uProj', proj); + shader.setMat4('uMV', mv); if (normals) { - shader.setMat3("uNorm", norm); + shader.setMat3('uNorm', norm); gl.cullFace(gl.FRONT); //gl.disable(gl.DEPTH_TEST); } if (params) { - shader.setVec4("uParams", params); + shader.setVec4('uParams', params); } if (params2) { - shader.setVec4("uParams2", params2); + shader.setVec4('uParams2', params2); } if (params2) { - shader.setVec4("uParams3", params3); + shader.setVec4('uParams3', params3); } - renderer.atmoMesh.draw(shader, "aPosition", null /*"aTexCoord"*/); + renderer.atmoMesh.draw(shader, 'aPosition', null /*"aTexCoord"*/); renderer.renderedPolygons += renderer.skydomeMesh.getPolygons(); @@ -202,19 +202,19 @@ RendererDraw.prototype.drawBall2 = function(position, size, shader, nfactor, dir //var shader = this.progStardome; - gpu.useProgram(shader, ["aPosition"]); + gpu.useProgram(shader, ['aPosition']); gpu.bindTexture(renderer.redTexture); - shader.setSampler("uSampler", 0); - shader.setMat4("uProj", proj); - shader.setMat4("uMV", mv); - shader.setMat3("uNorm", norm); - shader.setFloat("uNFactor", nfactor); - shader.setVec3("uCenter", position); + shader.setSampler('uSampler', 0); + shader.setMat4('uProj', proj); + shader.setMat4('uMV', mv); + shader.setMat3('uNorm', norm); + shader.setFloat('uNFactor', nfactor); + shader.setVec3('uCenter', position); //shader.setVec3("uDir", dir); - shader.setVec2("uRadius", [size, radius2]); + shader.setVec2('uRadius', [size, radius2]); - renderer.atmoMesh.draw(shader, "aPosition", null /*"aTexCoord"*/); + renderer.atmoMesh.draw(shader, 'aPosition', null /*"aTexCoord"*/); renderer.renderedPolygons += renderer.skydomeMesh.getPolygons(); }; @@ -267,13 +267,13 @@ RendererDraw.prototype.drawLineString = function(points, size, color, depthTest, var prog = renderer.progLine4; - gpu.useProgram(prog, ["aPosition"]); - prog.setMat4("uMVP", renderer.imageProjectionMatrix); - prog.setVec3("uScale", [(2 / renderer.curSize[0]), (2 / renderer.curSize[1]), size*0.5]); - prog.setVec4("uColor", (color != null ? color : [255,255,255,255])); - prog.setVec3("uPoints", plineBuffer); + gpu.useProgram(prog, ['aPosition']); + prog.setMat4('uMVP', renderer.imageProjectionMatrix); + prog.setVec3('uScale', [(2 / renderer.curSize[0]), (2 / renderer.curSize[1]), size*0.5]); + prog.setVec4('uColor', (color != null ? color : [255,255,255,255])); + prog.setVec3('uPoints', plineBuffer); - renderer.plines.draw(prog, "aPosition", totalPoints); + renderer.plines.draw(prog, 'aPosition', totalPoints); if (useState !== true) { if (depthTest !== true) { @@ -324,26 +324,26 @@ RendererDraw.prototype.drawImage = function(x, y, lx, ly, texture, color, depth, var prog = renderer.progImage; - gpu.useProgram(prog, ["aPosition"]); + gpu.useProgram(prog, ['aPosition']); gpu.bindTexture(texture); var vertices = renderer.rectVerticesBuffer; gl.bindBuffer(gl.ARRAY_BUFFER, vertices); - gl.vertexAttribPointer(prog.getAttribute("aPosition"), vertices.itemSize, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(prog.getAttribute('aPosition'), vertices.itemSize, gl.FLOAT, false, 0, 0); var indices = renderer.rectIndicesBuffer; gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indices); - prog.setMat4("uProjectionMatrix", renderer.imageProjectionMatrix); + prog.setMat4('uProjectionMatrix', renderer.imageProjectionMatrix); - prog.setMat4("uData", [ + prog.setMat4('uData', [ x, y, 0, 0, x + lx, y, 1, 0, x + lx, y + ly, 1, 1, x, y + ly, 0, 1 ]); - prog.setVec4("uColor", (color != null ? color : [1,1,1,1])); - prog.setFloat("uDepth", depth != null ? depth : 0); + prog.setVec4('uColor', (color != null ? color : [1,1,1,1])); + prog.setFloat('uDepth', depth != null ? depth : 0); gl.drawElements(gl.TRIANGLES, indices.numItems, gl.UNSIGNED_SHORT, 0); @@ -391,29 +391,29 @@ RendererDraw.prototype.drawBillboard = function(mvp, texture, color, depthTest, var prog = renderer.progImage; - gpu.useProgram(prog, ["aPosition", "aTexCoord"]); + gpu.useProgram(prog, ['aPosition', 'aTexCoord']); gpu.bindTexture(texture); - prog.setSampler("uSampler", 0); + prog.setSampler('uSampler', 0); var vertices = renderer.rectVerticesBuffer; gl.bindBuffer(gl.ARRAY_BUFFER, vertices); - gl.vertexAttribPointer(prog.getAttribute("aPosition"), vertices.itemSize, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(prog.getAttribute('aPosition'), vertices.itemSize, gl.FLOAT, false, 0, 0); var indices = renderer.rectIndicesBuffer; gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indices); - prog.setMat4("uProjectionMatrix", mvp); + prog.setMat4('uProjectionMatrix', mvp); var x = 0, y = 0, lx = 1, ly = 1; - prog.setMat4("uData", [ + prog.setMat4('uData', [ x, y, 0, 0, x + lx, y, 1, 0, x + lx, y + ly, 1, 1, x, y + ly, 0, 1 ]); - prog.setVec4("uColor", (color != null ? color : [1,1,1,1])); - prog.setFloat("uDepth", 0); + prog.setVec4('uColor', (color != null ? color : [1,1,1,1])); + prog.setFloat('uDepth', 0); gl.drawElements(gl.TRIANGLES, indices.numItems, gl.UNSIGNED_SHORT, 0); @@ -447,26 +447,26 @@ RendererDraw.prototype.drawFlatImage = function(x, y, lx, ly, texture, color, de var prog = renderer.progImage; - gpu.useProgram(prog, ["aPosition"]); + gpu.useProgram(prog, ['aPosition']); gpu.bindTexture(texture); var vertices = renderer.rectVerticesBuffer; gl.bindBuffer(gl.ARRAY_BUFFER, vertices); - gl.vertexAttribPointer(prog.getAttribute("aPosition"), vertices.itemSize, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(prog.getAttribute('aPosition'), vertices.itemSize, gl.FLOAT, false, 0, 0); var indices = renderer.rectIndicesBuffer; gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indices); - prog.setMat4("uProjectionMatrix", renderer.imageProjectionMatrix); + prog.setMat4('uProjectionMatrix', renderer.imageProjectionMatrix); - prog.setMat4("uData", [ + prog.setMat4('uData', [ x, y, 0, 0, x + lx, y, 1, 0, x + lx, y + ly, 1, 1, x, y + ly, 0, 1 ]); - prog.setVec4("uColor", (color != null ? color : [1,1,1,1])); - prog.setFloat("uDepth", depth != null ? depth : 0); + prog.setVec4('uColor', (color != null ? color : [1,1,1,1])); + prog.setFloat('uDepth', depth != null ? depth : 0); gl.drawElements(gl.TRIANGLES, indices.numItems, gl.UNSIGNED_SHORT, 0); }; @@ -496,20 +496,20 @@ RendererDraw.prototype.drawText = function(x, y, size, text, color, depth, useSt var prog = renderer.progImage; - gpu.useProgram(prog, ["aPosition"]); + gpu.useProgram(prog, ['aPosition']); gpu.bindTexture(renderer.textTexture2); //this.gpu.bindTexture(this.textTexture2); var vertices = renderer.rectVerticesBuffer; gl.bindBuffer(gl.ARRAY_BUFFER, vertices); - gl.vertexAttribPointer(prog.getAttribute("aPosition"), vertices.itemSize, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(prog.getAttribute('aPosition'), vertices.itemSize, gl.FLOAT, false, 0, 0); var indices = renderer.rectIndicesBuffer; gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indices); - prog.setMat4("uProjectionMatrix", renderer.imageProjectionMatrix); - prog.setVec4("uColor", color); - prog.setFloat("uDepth", depth != null ? depth : 0); + prog.setMat4('uProjectionMatrix', renderer.imageProjectionMatrix); + prog.setVec4('uColor', color); + prog.setFloat('uDepth', depth != null ? depth : 0); //size *= 2; @@ -528,7 +528,7 @@ RendererDraw.prototype.drawText = function(x, y, size, text, color, depth, useSt var charPosX = (char & 15) << 4; var charPosY = (char >> 4) << 4; - prog.setMat4("uData", [ + prog.setMat4('uData', [ x-2, y-2, (charPosX * texelX), (charPosY * texelY), x-2 + lx, y-2, ((charPosX+15) * texelX), (charPosY * texelY), x-2 + lx, y + sizeY+1, ((charPosX + 15) * texelX), ((charPosY+15) * texelY), @@ -543,35 +543,35 @@ RendererDraw.prototype.drawText = function(x, y, size, text, color, depth, useSt charPosY = (char >> 4) << 4; switch(char) { - case 12: - case 14: - case 27: //: - case 28: //; - case 64: //' - case 73: //i - case 76: //l - case 84: //t - - prog.setMat4("uData", [ - x, y, (charPosX * texelX), (charPosY * texelY), - x + sizeX2, y, ((charPosX+8) * texelX), (charPosY * texelY), - x + sizeX2, y + sizeY, ((charPosX + 8) * texelX), ((charPosY+16) * texelY), - x, y + sizeY, (charPosX * texelX), ((charPosY+16) * texelY) ]); - - x += sizeX2; - break; - - default: - - prog.setMat4("uData", [ - x, y, (charPosX * texelX), (charPosY * texelY), - x + sizeX, y, ((charPosX+15) * texelX), (charPosY * texelY), - x + sizeX, y + sizeY, ((charPosX + 15) * texelX), ((charPosY+16) * texelY), - x, y + sizeY, (charPosX * texelX), ((charPosY+16) * texelY) ]); - - x += sizeX; + case 12: + case 14: + case 27: //: + case 28: //; + case 64: //' + case 73: //i + case 76: //l + case 84: //t + + prog.setMat4('uData', [ + x, y, (charPosX * texelX), (charPosY * texelY), + x + sizeX2, y, ((charPosX+8) * texelX), (charPosY * texelY), + x + sizeX2, y + sizeY, ((charPosX + 8) * texelX), ((charPosY+16) * texelY), + x, y + sizeY, (charPosX * texelX), ((charPosY+16) * texelY) ]); + + x += sizeX2; + break; + + default: + + prog.setMat4('uData', [ + x, y, (charPosX * texelX), (charPosY * texelY), + x + sizeX, y, ((charPosX+15) * texelX), (charPosY * texelY), + x + sizeX, y + sizeY, ((charPosX + 15) * texelX), ((charPosY+16) * texelY), + x, y + sizeY, (charPosX * texelX), ((charPosY+16) * texelY) ]); + + x += sizeX; - break; + break; } gl.drawElements(gl.TRIANGLES, indices.numItems, gl.UNSIGNED_SHORT, 0); @@ -597,20 +597,20 @@ RendererDraw.prototype.getTextSize = function(size, text) { var char = text.charCodeAt(i) - 32; switch(char) { - case 12: - case 14: - case 27: //: - case 28: //; - case 64: //' - case 73: //i - case 76: //l - case 84: //t - x += sizeX2; - break; - - default: - x += sizeX; - break; + case 12: + case 14: + case 27: //: + case 28: //; + case 64: //' + case 73: //i + case 76: //l + case 84: //t + x += sizeX2; + break; + + default: + x += sizeX; + break; } } @@ -803,18 +803,18 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel } if (job.state != 0) { - var id = job.eventInfo["#id"]; + var id = job.eventInfo['#id']; if (id != null && renderer.hoverFeature != null) { if (job.state == 1){ // 1 = no hover state - if (renderer.hoverFeature[0]["#id"] == id) { //are we hovering over feature? + if (renderer.hoverFeature[0]['#id'] == id) { //are we hovering over feature? return; } } else { // 2 = hover state - if (renderer.hoverFeature[0]["#id"] != id) { //are we hovering over feature? + if (renderer.hoverFeature[0]['#id'] != id) { //are we hovering over feature? return; } @@ -839,192 +839,192 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel } switch(job.type) { - case "flat-line": - if (hitmapRender) { - gpu.setState(renderer.stencilLineHitState); - } else { - gpu.setState(renderer.stencilLineState); - } - + case 'flat-line': + if (hitmapRender) { + gpu.setState(renderer.stencilLineHitState); + } else { gpu.setState(renderer.stencilLineState); - var prog = renderer.progLine; + } + + gpu.setState(renderer.stencilLineState); + var prog = renderer.progLine; - gpu.useProgram(prog, ["aPosition"]); - prog.setVec4("uColor", color); - prog.setMat4("uMVP", mvp, renderer.getZoffsetFactor(job.zbufferOffset)); + gpu.useProgram(prog, ['aPosition']); + prog.setVec4('uColor', color); + prog.setMat4('uMVP', mvp, renderer.getZoffsetFactor(job.zbufferOffset)); - var vertexPositionAttribute = prog.getAttribute("aPosition"); + var vertexPositionAttribute = prog.getAttribute('aPosition'); //bind vetex positions - gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); - gl.vertexAttribPointer(vertexPositionAttribute, job.vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); + gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); + gl.vertexAttribPointer(vertexPositionAttribute, job.vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); //draw polygons - gl.drawArrays(gl.TRIANGLES, 0, job.vertexPositionBuffer.numItems); + gl.drawArrays(gl.TRIANGLES, 0, job.vertexPositionBuffer.numItems); - break; + break; - case "flat-tline": - case "pixel-line": - case "pixel-tline": - if (hitmapRender) { - gpu.setState(renderer.stencilLineHitState); - } else { - gpu.setState(renderer.stencilLineState); - } + case 'flat-tline': + case 'pixel-line': + case 'pixel-tline': + if (hitmapRender) { + gpu.setState(renderer.stencilLineHitState); + } else { + gpu.setState(renderer.stencilLineState); + } - var prog = job.program; - var texture = null; - var textureParams = [0,0,0,0]; + var prog = job.program; + var texture = null; + var textureParams = [0,0,0,0]; - if (job.type != "pixel-line") { + if (job.type != 'pixel-line') { - if (hitmapRender) { - texture = renderer.whiteTexture; - } else { - var t = job.texture; - - if (t == null || t[0] == null) { - return; - } - - texture = t[0]; - textureParams = [0, t[1]/t[0].height, (t[1]+t[2])/t[0].height, 0]; - - if (job.type == "flat-tline") { - textureParams[0] = 1/job.lineWidth/(texture.width/t[2]); - } else { - var 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; - } - } + if (hitmapRender) { + texture = renderer.whiteTexture; + } else { + var t = job.texture; - if (!texture.loaded) { + if (t == null || t[0] == null) { return; } - gpu.bindTexture(texture); + texture = t[0]; + textureParams = [0, t[1]/t[0].height, (t[1]+t[2])/t[0].height, 0]; + + if (job.type == 'flat-tline') { + textureParams[0] = 1/job.lineWidth/(texture.width/t[2]); + } else { + var 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; + } } - gpu.useProgram(prog, ["aPosition","aNormal"]); - prog.setVec4("uColor", color); - prog.setVec2("uScale", screenPixelSize); - prog.setMat4("uMVP", mvp, renderer.getZoffsetFactor(job.zbufferOffset)); + if (!texture.loaded) { + return; + } - if (job.type != "pixel-line") { - if (job.background != null) { - prog.setVec4("uColor2", job.background); - } - prog.setVec4("uParams", textureParams); - prog.setSampler("uSampler", 0); + gpu.bindTexture(texture); + } + + gpu.useProgram(prog, ['aPosition','aNormal']); + prog.setVec4('uColor', color); + prog.setVec2('uScale', screenPixelSize); + prog.setMat4('uMVP', mvp, renderer.getZoffsetFactor(job.zbufferOffset)); + + if (job.type != 'pixel-line') { + if (job.background != null) { + prog.setVec4('uColor2', job.background); } + prog.setVec4('uParams', textureParams); + prog.setSampler('uSampler', 0); + } - var vertexPositionAttribute = prog.getAttribute("aPosition"); - var vertexNormalAttribute = prog.getAttribute("aNormal"); + var vertexPositionAttribute = prog.getAttribute('aPosition'); + var vertexNormalAttribute = prog.getAttribute('aNormal'); //bind vetex positions - gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); - gl.vertexAttribPointer(vertexPositionAttribute, job.vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); + gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); + gl.vertexAttribPointer(vertexPositionAttribute, job.vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); //bind vetex normals - gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexNormalBuffer); - gl.vertexAttribPointer(vertexNormalAttribute, job.vertexNormalBuffer.itemSize, gl.FLOAT, false, 0, 0); + gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexNormalBuffer); + gl.vertexAttribPointer(vertexNormalAttribute, job.vertexNormalBuffer.itemSize, gl.FLOAT, false, 0, 0); //draw polygons - gl.drawArrays(gl.TRIANGLES, 0, job.vertexPositionBuffer.numItems); + gl.drawArrays(gl.TRIANGLES, 0, job.vertexPositionBuffer.numItems); - break; + break; - case "line-label": - if (hitmapRender) { - gpu.setState(renderer.lineLabelHitState); - } else { - gpu.setState(renderer.lineLabelState); - } + case 'line-label': + if (hitmapRender) { + gpu.setState(renderer.lineLabelHitState); + } else { + gpu.setState(renderer.lineLabelState); + } - var texture = hitmapRender ? renderer.whiteTexture : renderer.font.texture; + var 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; + var prog = renderer.progText; - gpu.bindTexture(texture); + gpu.bindTexture(texture); - gpu.useProgram(prog, ["aPosition", "aTexCoord"]); - prog.setSampler("uSampler", 0); - prog.setMat4("uMVP", mvp, renderer.getZoffsetFactor(job.zbufferOffset)); - prog.setVec4("uVec", renderer.labelVector); - prog.setVec4("uColor", color); + gpu.useProgram(prog, ['aPosition', 'aTexCoord']); + prog.setSampler('uSampler', 0); + prog.setMat4('uMVP', mvp, renderer.getZoffsetFactor(job.zbufferOffset)); + prog.setVec4('uVec', renderer.labelVector); + prog.setVec4('uColor', color); //prog.setVec2("uScale", screenPixelSize); - var vertexPositionAttribute = prog.getAttribute("aPosition"); - var vertexTexcoordAttribute = prog.getAttribute("aTexCoord"); + var vertexPositionAttribute = prog.getAttribute('aPosition'); + var vertexTexcoordAttribute = prog.getAttribute('aTexCoord'); //bind vetex positions - gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); - gl.vertexAttribPointer(vertexPositionAttribute, job.vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); + gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); + gl.vertexAttribPointer(vertexPositionAttribute, job.vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); //bind vetex texcoords - gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexTexcoordBuffer); - gl.vertexAttribPointer(vertexTexcoordAttribute, job.vertexTexcoordBuffer.itemSize, gl.FLOAT, false, 0, 0); + gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexTexcoordBuffer); + gl.vertexAttribPointer(vertexTexcoordAttribute, job.vertexTexcoordBuffer.itemSize, gl.FLOAT, false, 0, 0); //draw polygons - gl.drawArrays(gl.TRIANGLES, 0, job.vertexPositionBuffer.numItems); + gl.drawArrays(gl.TRIANGLES, 0, job.vertexPositionBuffer.numItems); - break; + break; - case "icon": - case "label": - if (hitmapRender) { - gpu.setState(renderer.lineLabelHitState); - } else { - gpu.setState(renderer.lineLabelState); - } + case 'icon': + case 'label': + if (hitmapRender) { + gpu.setState(renderer.lineLabelHitState); + } else { + gpu.setState(renderer.lineLabelState); + } - var texture = hitmapRender ? renderer.whiteTexture : job.texture; + var texture = hitmapRender ? renderer.whiteTexture : job.texture; - if (!texture.loaded) { - return; - } + if (!texture.loaded) { + return; + } - 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]]; - - if (job.visibility != 0) { - var l = vec3.length(camVec); - if (l > job.visibility) { - return; - } - - l = 1/l; - camVec[0] *= l; - camVec[1] *= l; - camVec[2] *= l; - } else { - vec3.normalize(camVec); - } - - job.normal = [0,0,0]; - vec3.normalize(job.center, job.normal); - - var a = -vec3.dot(camVec, job.normal); - if (a < Math.cos(math.radians(job.culling))) { - 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]]; + 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]]; + + if (job.visibility != 0) { var l = vec3.length(camVec); if (l > job.visibility) { return; } + + l = 1/l; + camVec[0] *= l; + camVec[1] *= l; + camVec[2] *= l; + } else { + vec3.normalize(camVec); } + + job.normal = [0,0,0]; + vec3.normalize(job.center, job.normal); + + var a = -vec3.dot(camVec, job.normal); + if (a < Math.cos(math.radians(job.culling))) { + 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); + if (l > job.visibility) { + return; + } + } //console.log(""+JSON.stringify(renderer.cameraPosition)); @@ -1033,55 +1033,55 @@ RendererDraw.prototype.drawGpuJob = function(gpu, gl, renderer, job, screenPixel //job.visibility //} - gpu.setState(renderer.lineLabelState); + gpu.setState(renderer.lineLabelState); - var stickShift = 0; + var stickShift = 0; - if (job.stick[0] != 0) { - var s = job.stick; - stickShift = renderer.cameraTiltFator * s[0]; + if (job.stick[0] != 0) { + var s = job.stick; + stickShift = renderer.cameraTiltFator * s[0]; - if (stickShift < s[1]) { - stickShift = 0; - } else if (s[2] != 0) { - var pp = renderer.project2(job.center, mvp); - pp[0] = Math.round(pp[0]); + if (stickShift < s[1]) { + stickShift = 0; + } else if (s[2] != 0) { + var pp = renderer.project2(job.center, mvp); + pp[0] = Math.round(pp[0]); - this.drawLineString([[pp[0], pp[1], pp[2]], [pp[0], pp[1]-stickShift, pp[2]]], s[2], [s[3], s[4], s[5], s[6]], null, null, null, true); - } + this.drawLineString([[pp[0], pp[1], pp[2]], [pp[0], pp[1]-stickShift, pp[2]]], s[2], [s[3], s[4], s[5], s[6]], null, null, null, true); } + } - var prog = renderer.progIcon; + var prog = renderer.progIcon; - gpu.bindTexture(texture); + gpu.bindTexture(texture); - gpu.useProgram(prog, ["aPosition", "aTexCoord", "aOrigin"]); - prog.setSampler("uSampler", 0); - prog.setMat4("uMVP", mvp, renderer.getZoffsetFactor(job.zbufferOffset)); - prog.setVec4("uScale", [screenPixelSize[0], screenPixelSize[1], (job.type == "label" ? 1.0 : 1.0 / texture.width), stickShift*2]); - prog.setVec4("uColor", color); + gpu.useProgram(prog, ['aPosition', 'aTexCoord', 'aOrigin']); + prog.setSampler('uSampler', 0); + prog.setMat4('uMVP', mvp, renderer.getZoffsetFactor(job.zbufferOffset)); + prog.setVec4('uScale', [screenPixelSize[0], screenPixelSize[1], (job.type == 'label' ? 1.0 : 1.0 / texture.width), stickShift*2]); + prog.setVec4('uColor', color); //prog.setVec2("uScale", screenPixelSize); - var vertexPositionAttribute = prog.getAttribute("aPosition"); - var vertexTexcoordAttribute = prog.getAttribute("aTexCoord"); - var vertexOriginAttribute = prog.getAttribute("aOrigin"); + var vertexPositionAttribute = prog.getAttribute('aPosition'); + var vertexTexcoordAttribute = prog.getAttribute('aTexCoord'); + var vertexOriginAttribute = prog.getAttribute('aOrigin'); //bind vetex positions - gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); - gl.vertexAttribPointer(vertexPositionAttribute, job.vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); + gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexPositionBuffer); + gl.vertexAttribPointer(vertexPositionAttribute, job.vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); //bind vetex texcoordds - gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexTexcoordBuffer); - gl.vertexAttribPointer(vertexTexcoordAttribute, job.vertexTexcoordBuffer.itemSize, gl.FLOAT, false, 0, 0); + gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexTexcoordBuffer); + gl.vertexAttribPointer(vertexTexcoordAttribute, job.vertexTexcoordBuffer.itemSize, gl.FLOAT, false, 0, 0); //bind vetex origin - gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexOriginBuffer); - gl.vertexAttribPointer(vertexOriginAttribute, job.vertexOriginBuffer.itemSize, gl.FLOAT, false, 0, 0); + gl.bindBuffer(gl.ARRAY_BUFFER, job.vertexOriginBuffer); + gl.vertexAttribPointer(vertexOriginAttribute, job.vertexOriginBuffer.itemSize, gl.FLOAT, false, 0, 0); //draw polygons - gl.drawArrays(gl.TRIANGLES, 0, job.vertexPositionBuffer.numItems); + gl.drawArrays(gl.TRIANGLES, 0, job.vertexPositionBuffer.numItems); - break; + break; } }; diff --git a/src/core/renderer/geometry.js b/src/core/renderer/geometry.js index d2d131e1..d01e3547 100755 --- a/src/core/renderer/geometry.js +++ b/src/core/renderer/geometry.js @@ -158,8 +158,8 @@ RendererGeometry.spherePos = function(lon, lat) { lon *= 2*Math.PI; return [Math.cos(lon)*Math.sin(lat)*0.5 + 0.5, - Math.sin(lon)*Math.sin(lat)*0.5 + 0.5, - Math.cos(lat) * 0.5 + 0.5]; + Math.sin(lon)*Math.sin(lat)*0.5 + 0.5, + Math.cos(lat) * 0.5 + 0.5]; }; diff --git a/src/core/renderer/gpu/bbox.js b/src/core/renderer/gpu/bbox.js index fa30097e..7cc02b49 100755 --- a/src/core/renderer/gpu/bbox.js +++ b/src/core/renderer/gpu/bbox.js @@ -17,34 +17,34 @@ var GpuBBox = function(gpu, free) { if (free) { var 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, - - 0,0,4, 0,0,5, - 0,0,5, 0,0,6, - 0,0,6, 0,0,7, - 0,0,7, 0,0,4, - - 0,0,0, 0,0,4, - 0,0,1, 0,0,5, - 0,0,2, 0,0,6, - 0,0,3, 0,0,7 ]; + 0,0,1, 0,0,2, + 0,0,2, 0,0,3, + 0,0,3, 0,0,0, + + 0,0,4, 0,0,5, + 0,0,5, 0,0,6, + 0,0,6, 0,0,7, + 0,0,7, 0,0,4, + + 0,0,0, 0,0,4, + 0,0,1, 0,0,5, + 0,0,2, 0,0,6, + 0,0,3, 0,0,7 ]; } else { - var 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, - - 0,0,1, 1,0,1, - 1,0,1, 1,1,1, - 1,1,1, 0,1,1, - 0,1,1, 0,0,1, - - 0,0,0, 0,0,1, - 1,0,0, 1,0,1, - 1,1,0, 1,1,1, - 0,1,0, 0,1,1 ]; + var 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, + + 0,0,1, 1,0,1, + 1,0,1, 1,1,1, + 1,1,1, 0,1,1, + 0,1,1, 0,0,1, + + 0,0,0, 0,0,1, + 1,0,0, 1,0,1, + 1,1,0, 1,1,1, + 0,1,0, 0,1,1 ]; } gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); diff --git a/src/core/renderer/gpu/device.js b/src/core/renderer/gpu/device.js index d55f4ea4..08fda4fe 100755 --- a/src/core/renderer/gpu/device.js +++ b/src/core/renderer/gpu/device.js @@ -21,7 +21,7 @@ var GpuDevice = function(div, size, keepFrameBuffer, antialias) { GpuDevice.prototype.init = function() { - this.canvas = document.createElement("canvas"); + this.canvas = document.createElement('canvas'); if (this.canvas == null) { //canvas not supported @@ -30,7 +30,7 @@ GpuDevice.prototype.init = function() { this.canvas.width = this.curSize[0]; this.canvas.height = this.curSize[1]; - this.canvas.style.display = "block"; + this.canvas.style.display = 'block'; if (this.canvas.getContext == null) { //canvas not supported @@ -38,7 +38,7 @@ GpuDevice.prototype.init = function() { } try { - this.gl = this.canvas.getContext("webgl", {preserveDrawingBuffer: this.keepFrameBuffer, antialias: this.antialias, stencil: true}) || this.canvas.getContext("experimental-webgl", {preserveDrawingBuffer: this.keepFrameBuffer}); + this.gl = this.canvas.getContext('webgl', {preserveDrawingBuffer: this.keepFrameBuffer, antialias: this.antialias, stencil: true}) || this.canvas.getContext('experimental-webgl', {preserveDrawingBuffer: this.keepFrameBuffer}); } catch(e) { //webgl not supported } @@ -104,7 +104,7 @@ GpuDevice.prototype.clear = function(clearDepth, clearColor, color) { // if (this.keepFrameBuffer) { // this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT ); // } else { - this.gl.clear((clearColor ? this.gl.COLOR_BUFFER_BIT : 0) | + this.gl.clear((clearColor ? this.gl.COLOR_BUFFER_BIT : 0) | (clearDepth ? this.gl.DEPTH_BUFFER_BIT : 0) ); // } }; @@ -116,10 +116,10 @@ GpuDevice.prototype.useProgram = function(program, attributes, nextSampler) { this.gl.useProgram(program.program); this.currentProgram = program; - program.setSampler("uSampler", 0); + program.setSampler('uSampler', 0); if (nextSampler) { - program.setSampler("uSampler2", 1); + program.setSampler('uSampler2', 1); } var newAttributes = this.newAttributes; diff --git a/src/core/renderer/gpu/font.js b/src/core/renderer/gpu/font.js index 786c659e..42a31259 100755 --- a/src/core/renderer/gpu/font.js +++ b/src/core/renderer/gpu/font.js @@ -29,7 +29,7 @@ GpuFont.prototype.kill = function() { GpuFont.prototype.generate = function(font, size) { if (font == null) { - font = "Arial, 'Helvetica Neue', Helvetica, sans-serif"; //"Calibri"; + font = 'Arial, "Helvetica Neue", Helvetica, sans-serif'; //"Calibri"; } if (size == null) { @@ -51,16 +51,16 @@ GpuFont.prototype.generate = function(font, size) { var fontSize = 10; ctx.beginPath(); - ctx.font = size + "pt " + font; - ctx.textAlign = "left"; - ctx.textBaseline = "top"; + ctx.font = size + 'pt ' + font; + ctx.textAlign = 'left'; + ctx.textBaseline = 'top'; // ctx.fillStyle = "@white"; // ctx.fillStyle = [0,0,0,255]; - ctx.fillStyle = "#ffffff"; - ctx.strokeStyle = "#000000"; + ctx.fillStyle = '#ffffff'; + ctx.strokeStyle = '#000000'; ctx.lineWidth = 5; - ctx.lineCap = "round"; - ctx.lineJoin = "round"; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; var lineSpace = Math.round(ctx.lineWidth*0.5); @@ -69,8 +69,8 @@ GpuFont.prototype.generate = function(font, size) { var y = space; - var cly = Math.floor(ctx.measureText("e").width * 2.5); - var clxe = Math.floor(ctx.measureText("e").width); + 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 = []; @@ -104,14 +104,14 @@ GpuFont.prototype.generate = function(font, size) { ctx.fillText(c, x+lineSpace, y); this.chars[codes[i]] = { - u1 : x * fx, - v1 : y * fy, - u2 : (x + clx) * fx, - v2 : (y + cly) * fy, - lx : clx, - ly : cly, - step : (clx-2) - }; + u1 : x * fx, + v1 : y * fy, + u2 : (x + clx) * fx, + v2 : (y + cly) * fy, + lx : clx, + ly : cly, + step : (clx-2) + }; x += clx + space; } @@ -120,7 +120,7 @@ GpuFont.prototype.generate = function(font, size) { this.texture = new GpuTexture(this.gpu, null); //this.texture.createFromData(textureLX, textureLY, this.image); - this.texture.createFromImage(this.image, "linear"); + this.texture.createFromImage(this.image, 'linear'); this.texture.width = textureLX; this.texture.height = textureLY; this.texture.size = textureLX * textureLY * 4; diff --git a/src/core/renderer/gpu/group.js b/src/core/renderer/gpu/group.js index 5be35cfe..a50957ed 100755 --- a/src/core/renderer/gpu/group.js +++ b/src/core/renderer/gpu/group.js @@ -33,28 +33,28 @@ GpuGroup.prototype.kill = function() { var job = this.jobs[i]; switch(job.type) { - case "flat-line": - if (job.vertexPositionBuffer) this.gl.deleteBuffer(job.vertexPositionBuffer); - break; - - case "flat-tline": - case "pixel-line": - case "pixel-tline": - if (job.vertexPositionBuffer) this.gl.deleteBuffer(job.vertexPositionBuffer); - if (job.vertexNormalBuffer) this.gl.deleteBuffer(job.vertexNormalBuffer); - break; - - case "line-label": - if (job.vertexPositionBuffer) this.gl.deleteBuffer(job.vertexPositionBuffer); - if (job.vertexTexcoordBuffer) this.gl.deleteBuffer(job.vertexTexcoordBuffer); - break; - - case "icon": - case "label": - if (job.vertexPositionBuffer) this.gl.deleteBuffer(job.vertexPositionBuffer); - if (job.vertexTexcoordBuffer) this.gl.deleteBuffer(job.vertexTexcoordBuffer); - if (job.vertexOriginBuffer) this.gl.deleteBuffer(job.vertexOriginBuffer); - break; + case 'flat-line': + if (job.vertexPositionBuffer) this.gl.deleteBuffer(job.vertexPositionBuffer); + break; + + case 'flat-tline': + case 'pixel-line': + case 'pixel-tline': + if (job.vertexPositionBuffer) this.gl.deleteBuffer(job.vertexPositionBuffer); + if (job.vertexNormalBuffer) this.gl.deleteBuffer(job.vertexNormalBuffer); + break; + + case 'line-label': + if (job.vertexPositionBuffer) this.gl.deleteBuffer(job.vertexPositionBuffer); + if (job.vertexTexcoordBuffer) this.gl.deleteBuffer(job.vertexTexcoordBuffer); + break; + + case 'icon': + case 'label': + if (job.vertexPositionBuffer) this.gl.deleteBuffer(job.vertexPositionBuffer); + if (job.vertexTexcoordBuffer) this.gl.deleteBuffer(job.vertexTexcoordBuffer); + if (job.vertexOriginBuffer) this.gl.deleteBuffer(job.vertexOriginBuffer); + break; } } }; @@ -73,26 +73,26 @@ GpuGroup.prototype.getZbufferOffset = function(params) { GpuGroup.prototype.addLineJob = function(data) { var gl = this.gl; - var vertices = data["vertexBuffer"]; - var color = data["color"]; + var vertices = data['vertexBuffer']; + var color = data['color']; var f = 1.0/255; var job = {}; - job.type = "flat-line"; - job.program = data["program"]; + job.type = 'flat-line'; + job.program = data['program']; job.color = [color[0]*f, color[1]*f, color[2]*f, color[3]*f]; - job.zIndex = data["z-index"] + 256; - job.clickEvent = data["click-event"]; - job.hoverEvent = data["hover-event"]; - job.enterEvent = data["enter-event"]; - job.leaveEvent = data["leave-event"]; - job.hitable = data["hitable"]; - job.eventInfo = data["eventInfo"]; - job.state = data["state"]; - job.center = data["center"]; - job.lod = data["lod"]; - job.lineWidth = data["line-width"]; - job.zbufferOffset = data["zbuffer-offset"]; + job.zIndex = data['z-index'] + 256; + job.clickEvent = data['click-event']; + job.hoverEvent = data['hover-event']; + job.enterEvent = data['enter-event']; + job.leaveEvent = data['leave-event']; + job.hitable = data['hitable']; + job.eventInfo = data['eventInfo']; + job.state = data['state']; + job.center = data['center']; + job.lod = data['lod']; + job.lineWidth = data['line-width']; + job.zbufferOffset = data['zbuffer-offset']; job.reduced = false; job.ready = true; @@ -115,36 +115,36 @@ GpuGroup.prototype.addLineJob = function(data) { GpuGroup.prototype.addExtentedLineJob = function(data) { var gl = this.gl; - var vertices = data["vertexBuffer"]; - var normals = data["normalBuffer"]; - var color = data["color"]; + var vertices = data['vertexBuffer']; + var normals = data['normalBuffer']; + var color = data['color']; var f = 1.0/255; var job = {}; - job.type = data["type"]; - job.program = data["program"]; + job.type = data['type']; + job.program = data['program']; job.color = [color[0]*f, color[1]*f, color[2]*f, color[3]*f]; - job.zIndex = data["z-index"] + 256; - job.clickEvent = data["click-event"]; - job.hoverEvent = data["hover-event"]; - job.hitable = data["hitable"]; - job.eventInfo = data["eventInfo"]; - job.enterEvent = data["enter-event"]; - job.leaveEvent = data["leave-event"]; - job.state = data["state"]; - job.center = data["center"]; - job.lod = data["lod"]; - job.lineWidth = data["line-width"]; - job.zbufferOffset = data["zbuffer-offset"]; + job.zIndex = data['z-index'] + 256; + job.clickEvent = data['click-event']; + job.hoverEvent = data['hover-event']; + job.hitable = data['hitable']; + job.eventInfo = data['eventInfo']; + job.enterEvent = data['enter-event']; + job.leaveEvent = data['leave-event']; + job.state = data['state']; + job.center = data['center']; + job.lod = data['lod']; + job.lineWidth = data['line-width']; + job.zbufferOffset = data['zbuffer-offset']; job.reduced = false; job.ready = true; - if (data["texture"] != null) { - var texture = data["texture"]; + if (data['texture'] != null) { + var texture = data['texture']; var bitmap = texture[0]; - job.texture = [this.renderer.getBitmap(bitmap["url"], bitmap["filter"] || "linear", bitmap["tiled"] || false), - texture[1], texture[2], texture[3], texture[4]]; - var background = data["background"]; + job.texture = [this.renderer.getBitmap(bitmap['url'], bitmap['filter'] || 'linear', bitmap['tiled'] || false), + texture[1], texture[2], texture[3], texture[4]]; + var background = data['background']; if (background[3] != 0) { job.background = [background[0]*f, background[1]*f, background[2]*f, background[3]*f]; @@ -152,9 +152,9 @@ GpuGroup.prototype.addExtentedLineJob = function(data) { } switch(job.type) { - case "flat-tline": job.program = (background[3] != 0) ? this.renderer.progTBLine : this.renderer.progTLine; break; - case "pixel-line": job.program = this.renderer.progLine3; break; - case "pixel-tline": job.program = (background[3] != 0) ? this.renderer.progTPBLine : this.renderer.progTPLine; break; + case 'flat-tline': job.program = (background[3] != 0) ? this.renderer.progTBLine : this.renderer.progTLine; break; + case 'pixel-line': job.program = this.renderer.progLine3; break; + case 'pixel-tline': job.program = (background[3] != 0) ? this.renderer.progTPBLine : this.renderer.progTPLine; break; } //create vertex buffer @@ -185,26 +185,26 @@ GpuGroup.prototype.addExtentedLineJob = function(data) { GpuGroup.prototype.addLineLabelJob = function(data) { var gl = this.gl; - var vertices = data["vertexBuffer"]; - var texcoords = data["texcoordsBuffer"]; - var color = data["color"]; + var vertices = data['vertexBuffer']; + var texcoords = data['texcoordsBuffer']; + var color = data['color']; var f = 1.0/255; var job = {}; - job.type = "line-label"; - job.program = data["program"]; + job.type = 'line-label'; + job.program = data['program']; job.color = [color[0]*f, color[1]*f, color[2]*f, color[3]*f]; - job.zIndex = data["z-index"] + 256; - job.clickEvent = data["click-event"]; - job.hoverEvent = data["hover-event"]; - job.enterEvent = data["enter-event"]; - job.leaveEvent = data["leave-event"]; - job.hitable = data["hitable"]; - job.eventInfo = data["eventInfo"]; - job.state = data["state"]; - job.center = data["center"]; - job.lod = data["lod"]; - job.zbufferOffset = data["zbuffer-offset"]; + job.zIndex = data['z-index'] + 256; + job.clickEvent = data['click-event']; + job.hoverEvent = data['hover-event']; + job.enterEvent = data['enter-event']; + job.leaveEvent = data['leave-event']; + job.hitable = data['hitable']; + job.eventInfo = data['eventInfo']; + job.state = data['state']; + job.center = data['center']; + job.lod = data['lod']; + job.zbufferOffset = data['zbuffer-offset']; job.reduced = false; job.ready = true; @@ -236,37 +236,37 @@ GpuGroup.prototype.addLineLabelJob = function(data) { GpuGroup.prototype.addIconJob = function(data, label) { var gl = this.gl; - var vertices = data["vertexBuffer"]; - var texcoords = data["texcoordsBuffer"]; - var origins = data["originBuffer"]; - var color = data["color"]; - var s = data["stick"]; + var vertices = data['vertexBuffer']; + var texcoords = data['texcoordsBuffer']; + var origins = data['originBuffer']; + var color = data['color']; + var s = data['stick']; var f = 1.0/255; var job = {}; - job.type = label ? "label" : "icon"; - job.program = data["program"]; + job.type = label ? 'label' : 'icon'; + job.program = data['program']; job.color = [color[0]*f, color[1]*f, color[2]*f, color[3]*f]; - job.zIndex = data["z-index"] + 256; - job.visibility = data["visibility"]; - job.culling = data["culling"]; - job.clickEvent = data["click-event"]; - job.hoverEvent = data["hover-event"]; - job.enterEvent = data["enter-event"]; - job.leaveEvent = data["leave-event"]; - job.hitable = data["hitable"]; - job.eventInfo = data["eventInfo"]; - job.state = data["state"]; - job.center = data["center"]; + job.zIndex = data['z-index'] + 256; + job.visibility = data['visibility']; + job.culling = data['culling']; + job.clickEvent = data['click-event']; + job.hoverEvent = data['hover-event']; + job.enterEvent = data['enter-event']; + job.leaveEvent = data['leave-event']; + job.hitable = data['hitable']; + job.eventInfo = data['eventInfo']; + job.state = data['state']; + job.center = data['center']; job.stick = [s[0], s[1], s[2], s[3]*f, s[4]*f, s[5]*f, s[6]*f]; - job.lod = data["lod"]; - job.zbufferOffset = data["zbuffer-offset"]; + job.lod = data['lod']; + job.zbufferOffset = data['zbuffer-offset']; job.reduced = false; job.ready = true; if (label !== true) { - var icon = data["icon"]; - job.texture = this.renderer.getBitmap(icon["url"], icon["filter"] || "linear", icon["tiled"] || false); + var icon = data['icon']; + job.texture = this.renderer.getBitmap(icon['url'], icon['filter'] || 'linear', icon['tiled'] || false); } else { job.texture = this.renderer.font.texture; } @@ -308,15 +308,15 @@ GpuGroup.prototype.addIconJob = function(data, label) { GpuGroup.prototype.addRenderJob = function(data) { - switch(data["type"]) { - case "flat-line": this.addLineJob(data); break; - case "flat-tline": this.addExtentedLineJob(data); break; - case "pixel-line": this.addExtentedLineJob(data); break; - case "pixel-tline": this.addExtentedLineJob(data); break; - case "line-label": this.addLineLabelJob(data); break; - case "icon": this.addIconJob(data); break; - case "label": this.addIconJob(data, true); break; - case "optimize": this.optimaze(data); break; + switch(data['type']) { + case 'flat-line': this.addLineJob(data); break; + case 'flat-tline': this.addExtentedLineJob(data); break; + case 'pixel-line': this.addExtentedLineJob(data); break; + case 'pixel-tline': this.addExtentedLineJob(data); break; + case 'line-label': this.addLineLabelJob(data); break; + case 'icon': this.addIconJob(data); break; + case 'label': this.addIconJob(data, true); break; + case 'optimize': this.optimaze(data); break; } }; @@ -364,11 +364,11 @@ GpuGroup.prototype.draw = function(mv, mvp, applyOrigin) { for (var i = 0, li = this.jobs.length; i < li; i++) { var job = this.jobs[i]; - if ((job.type == "icon" || job.type == "label") && job.visibility > 0) { + if ((job.type == 'icon' || job.type == 'label') && job.visibility > 0) { var center = job.center; if (vec3.length([center[0]-cameraPos[0], - center[1]-cameraPos[1], - center[2]-cameraPos[2]]) > job.visibility) { + center[1]-cameraPos[1], + center[2]-cameraPos[2]]) > job.visibility) { continue; } } diff --git a/src/core/renderer/gpu/pixel-line3.js b/src/core/renderer/gpu/pixel-line3.js index 6fd2911a..94ec78f7 100755 --- a/src/core/renderer/gpu/pixel-line3.js +++ b/src/core/renderer/gpu/pixel-line3.js @@ -32,15 +32,15 @@ GpuPixelLine3.prototype.kill = function() { GpuPixelLine3.prototype.init = function() { if (this.lines) { if (this.joins) { - this.addCircle(0, this.joinSides); + this.addCircle(0, this.joinSides); } for (var i = 0; i < this.maxLines; i++) { this.addLine(i, i+1); - if (this.joins) { + if (this.joins) { this.addCircle(i+1, this.joinSides); - } + } } } else if (this.joins) { for (var i = 0; i <= this.maxLines; i++) { diff --git a/src/core/renderer/gpu/program.js b/src/core/renderer/gpu/program.js index 36558da0..83ef159d 100755 --- a/src/core/renderer/gpu/program.js +++ b/src/core/renderer/gpu/program.js @@ -31,7 +31,7 @@ GpuProgram.prototype.createShader = function(source, vertexShader) { gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - alert("An error occurred compiling the shaders: " + gl.getShaderInfoLog(shader)); + alert('An error occurred compiling the shaders: ' + gl.getShaderInfoLog(shader)); return null; } @@ -52,7 +52,7 @@ GpuProgram.prototype.createProgram = function(vertex, fragment) { gl.linkProgram(program); if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { - alert("Unable to initialize the shader program."); + alert('Unable to initialize the shader program.'); } gl.useProgram(program); diff --git a/src/core/renderer/gpu/shaders.js b/src/core/renderer/gpu/shaders.js index 0e2b3cf7..0a5f5db2 100755 --- a/src/core/renderer/gpu/shaders.js +++ b/src/core/renderer/gpu/shaders.js @@ -2,315 +2,315 @@ var GpuShaders = {}; GpuShaders.bboxVertexShader = - "attribute vec3 aPosition;\n"+ - "uniform mat4 uMVP;\n"+ - "void main(){ \n"+ - "gl_Position = uMVP * vec4(aPosition, 1.0);\n"+ - "}"; + 'attribute vec3 aPosition;\n'+ + 'uniform mat4 uMVP;\n'+ + 'void main(){ \n'+ + 'gl_Position = uMVP * vec4(aPosition, 1.0);\n'+ + '}'; GpuShaders.bbox2VertexShader = - "attribute vec3 aPosition;\n"+ - "uniform mat4 uMVP;\n"+ - "uniform float uPoints[8*3];\n"+ - "void main(){ \n"+ - "int index = int(aPosition.z) * 3; \n"+ - "gl_Position = uMVP * vec4(uPoints[index], uPoints[index+1], uPoints[index+2], 1.0);\n"+ - "}"; + 'attribute vec3 aPosition;\n'+ + 'uniform mat4 uMVP;\n'+ + 'uniform float uPoints[8*3];\n'+ + 'void main(){ \n'+ + 'int index = int(aPosition.z) * 3; \n'+ + 'gl_Position = uMVP * vec4(uPoints[index], uPoints[index+1], uPoints[index+2], 1.0);\n'+ + '}'; -GpuShaders.bboxFragmentShader = "precision mediump float;\n"+ - "void main() {\n"+ - "gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n"+ - "}"; +GpuShaders.bboxFragmentShader = 'precision mediump float;\n'+ + 'void main() {\n'+ + 'gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n'+ + '}'; GpuShaders.lineVertexShader = - "attribute vec3 aPosition;\n"+ - "uniform mat4 uMVP;\n"+ - "void main(){ \n"+ - "gl_Position = uMVP * vec4(aPosition, 1.0);\n"+ - "}"; + 'attribute vec3 aPosition;\n'+ + 'uniform mat4 uMVP;\n'+ + 'void main(){ \n'+ + 'gl_Position = uMVP * vec4(aPosition, 1.0);\n'+ + '}'; -GpuShaders.lineFragmentShader = "precision mediump float;\n"+ - "uniform vec4 uColor;\n"+ - "void main() {\n"+ - "gl_FragColor = uColor;\n"+ - "}"; +GpuShaders.lineFragmentShader = 'precision mediump float;\n'+ + 'uniform vec4 uColor;\n'+ + 'void main() {\n'+ + 'gl_FragColor = uColor;\n'+ + '}'; GpuShaders.line3VertexShader = - "attribute vec4 aPosition;\n"+ - "attribute vec4 aNormal;\n"+ - "uniform mat4 uMVP;\n"+ - "uniform vec2 uScale;\n"+ - "void main(){ \n"+ - "vec4 pp0 = (uMVP * vec4(aPosition.xyz, 1.0));\n"+ - "if (aNormal.w == 0.0) {\n"+ - "gl_Position = pp0 + vec4((vec3(aNormal.x*uScale.x*pp0.w, aNormal.y*uScale.y*pp0.w, 0.0)), 0.0);\n"+ - "} else {\n"+ - "vec2 pp1 = pp0.xy / pp0.w;\n"+ - "vec4 pp3 = (uMVP * vec4(aNormal.xyz, 1.0));\n"+ - "vec2 pp2 = pp3.xy / pp3.w;\n"+ - "vec2 n = normalize(pp2 - pp1);\n"+ - "gl_Position = pp0 + vec4((vec3(-n.y*uScale.x*aNormal.w*pp0.w, n.x*uScale.y*aNormal.w*pp0.w, 0.0)), 0.0);\n"+ - "}\n"+ - "}"; - - -GpuShaders.line3FragmentShader = "precision mediump float;\n"+ - "uniform vec4 uColor;\n"+ - "void main() {\n"+ - "gl_FragColor = uColor;\n"+ - "}"; + 'attribute vec4 aPosition;\n'+ + 'attribute vec4 aNormal;\n'+ + 'uniform mat4 uMVP;\n'+ + 'uniform vec2 uScale;\n'+ + 'void main(){ \n'+ + 'vec4 pp0 = (uMVP * vec4(aPosition.xyz, 1.0));\n'+ + 'if (aNormal.w == 0.0) {\n'+ + 'gl_Position = pp0 + vec4((vec3(aNormal.x*uScale.x*pp0.w, aNormal.y*uScale.y*pp0.w, 0.0)), 0.0);\n'+ + '} else {\n'+ + 'vec2 pp1 = pp0.xy / pp0.w;\n'+ + 'vec4 pp3 = (uMVP * vec4(aNormal.xyz, 1.0));\n'+ + 'vec2 pp2 = pp3.xy / pp3.w;\n'+ + 'vec2 n = normalize(pp2 - pp1);\n'+ + 'gl_Position = pp0 + vec4((vec3(-n.y*uScale.x*aNormal.w*pp0.w, n.x*uScale.y*aNormal.w*pp0.w, 0.0)), 0.0);\n'+ + '}\n'+ + '}'; + + +GpuShaders.line3FragmentShader = 'precision mediump float;\n'+ + 'uniform vec4 uColor;\n'+ + 'void main() {\n'+ + 'gl_FragColor = uColor;\n'+ + '}'; GpuShaders.line4VertexShader = - "attribute vec3 aPosition;\n"+ - "uniform mat4 uMVP;\n"+ - "uniform vec3 uScale;\n"+ - "uniform vec3 uPoints[32];\n"+ - "void main(){ \n"+ - "vec4 pp0 = (uMVP * vec4(uPoints[int(aPosition.x)], 1.0));\n"+ - "if (aPosition.y < 0.0) {\n"+ - "if (aPosition.y == -1.0) {\n"+ - "gl_Position = pp0;\n"+ - "} else {\n"+ - "gl_Position = pp0 + vec4((vec3(-sin(aPosition.z)*uScale.x*uScale.z, cos(aPosition.z)*uScale.y*uScale.z, 0.0)), 0.0);\n"+ - "}\n"+ - "} else {\n"+ - "vec2 pp1 = pp0.xy / pp0.w;\n"+ - "vec4 pp3 = (uMVP * vec4(uPoints[int(aPosition.y)], 1.0));\n"+ - "vec2 pp2 = pp3.xy / pp3.w;\n"+ - "vec2 n = normalize(pp2 - pp1);\n"+ - "gl_Position = pp0 + vec4((vec3(-n.y*uScale.x*aPosition.z*uScale.z, n.x*uScale.y*aPosition.z*uScale.z, 0.0)), 0.0);\n"+ - "}\n"+ - "}"; - - -GpuShaders.line4FragmentShader = "precision mediump float;\n"+ - "uniform vec4 uColor;\n"+ - "void main() {\n"+ - "gl_FragColor = uColor;\n"+ - "}"; + 'attribute vec3 aPosition;\n'+ + 'uniform mat4 uMVP;\n'+ + 'uniform vec3 uScale;\n'+ + 'uniform vec3 uPoints[32];\n'+ + 'void main(){ \n'+ + 'vec4 pp0 = (uMVP * vec4(uPoints[int(aPosition.x)], 1.0));\n'+ + 'if (aPosition.y < 0.0) {\n'+ + 'if (aPosition.y == -1.0) {\n'+ + 'gl_Position = pp0;\n'+ + '} else {\n'+ + 'gl_Position = pp0 + vec4((vec3(-sin(aPosition.z)*uScale.x*uScale.z, cos(aPosition.z)*uScale.y*uScale.z, 0.0)), 0.0);\n'+ + '}\n'+ + '} else {\n'+ + 'vec2 pp1 = pp0.xy / pp0.w;\n'+ + 'vec4 pp3 = (uMVP * vec4(uPoints[int(aPosition.y)], 1.0));\n'+ + 'vec2 pp2 = pp3.xy / pp3.w;\n'+ + 'vec2 n = normalize(pp2 - pp1);\n'+ + 'gl_Position = pp0 + vec4((vec3(-n.y*uScale.x*aPosition.z*uScale.z, n.x*uScale.y*aPosition.z*uScale.z, 0.0)), 0.0);\n'+ + '}\n'+ + '}'; + + +GpuShaders.line4FragmentShader = 'precision mediump float;\n'+ + 'uniform vec4 uColor;\n'+ + 'void main() {\n'+ + 'gl_FragColor = uColor;\n'+ + '}'; GpuShaders.tlineVertexShader = - "attribute vec4 aPosition;\n"+ - "attribute vec4 aNormal;\n"+ - "uniform mat4 uMVP;\n"+ - "uniform vec2 uScale;\n"+ - "uniform vec4 uParams;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main(){ \n"+ - "vec4 p=vec4(aPosition.xyz, 1.0);\n"+ - "p.xy+=aNormal.xy;\n"+ - "if (aNormal.w == 0.0){\n"+ - "float tcy=(uParams[1]+uParams[2])*0.5;\n"+ - "float tdy=uParams[1]-tcy;\n"+ - "float ty=(aNormal.x == 0.0 && aNormal.y == 0.0)?tcy:tcy+tdy*cos(aNormal.z);\n"+ + 'attribute vec4 aPosition;\n'+ + 'attribute vec4 aNormal;\n'+ + 'uniform mat4 uMVP;\n'+ + 'uniform vec2 uScale;\n'+ + 'uniform vec4 uParams;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main(){ \n'+ + 'vec4 p=vec4(aPosition.xyz, 1.0);\n'+ + 'p.xy+=aNormal.xy;\n'+ + 'if (aNormal.w == 0.0){\n'+ + 'float tcy=(uParams[1]+uParams[2])*0.5;\n'+ + 'float tdy=uParams[1]-tcy;\n'+ + 'float ty=(aNormal.x == 0.0 && aNormal.y == 0.0)?tcy:tcy+tdy*cos(aNormal.z);\n'+ // "float ty=tcy;\n"+ - "vTexCoord=vec2(abs(aPosition.w)*uParams[0], ty);\n"+ - "} else {\n"+ - "vTexCoord=vec2(abs(aPosition.w)*uParams[0], aPosition.w < 0.0 ? uParams[1] : uParams[2]);\n"+ - "}\n"+ + 'vTexCoord=vec2(abs(aPosition.w)*uParams[0], ty);\n'+ + '} else {\n'+ + 'vTexCoord=vec2(abs(aPosition.w)*uParams[0], aPosition.w < 0.0 ? uParams[1] : uParams[2]);\n'+ + '}\n'+ - "gl_Position = uMVP * p;\n"+ - "}"; + 'gl_Position = uMVP * p;\n'+ + '}'; GpuShaders.tplineVertexShader = - "attribute vec4 aPosition;\n"+ - "attribute vec4 aNormal;\n"+ - "uniform mat4 uMVP;\n"+ - "uniform vec2 uScale;\n"+ - "uniform vec4 uParams;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main(){ \n"+ - "vec4 pp0 = (uMVP * vec4(aPosition.xyz, 1.0));\n"+ - "vTexCoord=vec2(abs(aPosition.w)*uParams[0], aPosition.w < 0.0 ? uParams[1] : uParams[2]);\n"+ + 'attribute vec4 aPosition;\n'+ + 'attribute vec4 aNormal;\n'+ + 'uniform mat4 uMVP;\n'+ + 'uniform vec2 uScale;\n'+ + 'uniform vec4 uParams;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main(){ \n'+ + 'vec4 pp0 = (uMVP * vec4(aPosition.xyz, 1.0));\n'+ + 'vTexCoord=vec2(abs(aPosition.w)*uParams[0], aPosition.w < 0.0 ? uParams[1] : uParams[2]);\n'+ // "vTexCoord=vec2((abs(aPosition.w)) / (pp0.z/10.0), aPosition.w < 0.0 ? 0.0001 : 0.9999);\n"+ - "if (aNormal.w == 0.0) {\n"+ - "gl_Position = pp0 + vec4((vec3(aNormal.x*uScale.x*pp0.w, aNormal.y*uScale.y*pp0.w, 0.0)), 0.0);\n"+ - "} else {\n"+ - "vec2 pp1 = pp0.xy / pp0.w;\n"+ - "vec4 pp3 = (uMVP * vec4(aNormal.xyz, 1.0));\n"+ - "vec2 pp2 = pp3.xy / pp3.w;\n"+ - "vec2 n = normalize(pp2 - pp1);\n"+ - "gl_Position = pp0 + vec4((vec3(-n.y*uScale.x*aNormal.w*pp0.w, n.x*uScale.y*aNormal.w*pp0.w, 0.0)), 0.0);\n"+ - "}\n"+ - "}"; - - -GpuShaders.tlineFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform vec4 uColor;\n"+ - "uniform vec4 uColor2;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main() {\n"+ - "vec4 c=texture2D(uSampler, vTexCoord)*uColor;\n"+ + 'if (aNormal.w == 0.0) {\n'+ + 'gl_Position = pp0 + vec4((vec3(aNormal.x*uScale.x*pp0.w, aNormal.y*uScale.y*pp0.w, 0.0)), 0.0);\n'+ + '} else {\n'+ + 'vec2 pp1 = pp0.xy / pp0.w;\n'+ + 'vec4 pp3 = (uMVP * vec4(aNormal.xyz, 1.0));\n'+ + 'vec2 pp2 = pp3.xy / pp3.w;\n'+ + 'vec2 n = normalize(pp2 - pp1);\n'+ + 'gl_Position = pp0 + vec4((vec3(-n.y*uScale.x*aNormal.w*pp0.w, n.x*uScale.y*aNormal.w*pp0.w, 0.0)), 0.0);\n'+ + '}\n'+ + '}'; + + +GpuShaders.tlineFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform vec4 uColor;\n'+ + 'uniform vec4 uColor2;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main() {\n'+ + 'vec4 c=texture2D(uSampler, vTexCoord)*uColor;\n'+ // "if(c.w < 0.01){ discard; }\n"+ - "gl_FragColor = c;\n"+ - "}"; + 'gl_FragColor = c;\n'+ + '}'; -GpuShaders.tblineFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform vec4 uColor;\n"+ - "uniform vec4 uColor2;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main() {\n"+ - "vec4 c=texture2D(uSampler, vTexCoord)*uColor;\n"+ - "vec4 c2=uColor2;\n"+ - "c.xyz*=c.w; c2.xyz*=c2.w;\n"+ - "c=mix(c,c2,1.0-c.w);\n"+ - "c.xyz/=(c.w+0.00001);\n"+ - "gl_FragColor = c;\n"+ - "}"; +GpuShaders.tblineFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform vec4 uColor;\n'+ + 'uniform vec4 uColor2;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main() {\n'+ + 'vec4 c=texture2D(uSampler, vTexCoord)*uColor;\n'+ + 'vec4 c2=uColor2;\n'+ + 'c.xyz*=c.w; c2.xyz*=c2.w;\n'+ + 'c=mix(c,c2,1.0-c.w);\n'+ + 'c.xyz/=(c.w+0.00001);\n'+ + 'gl_FragColor = c;\n'+ + '}'; GpuShaders.polygonVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec3 aNormal;\n"+ - "uniform mat4 uMVP;\n"+ - "uniform mat4 uRot;\n"+ - "uniform vec4 uColor;\n"+ - "varying vec4 vColor;\n"+ - "void main(){ \n"+ - "float l = dot((uRot*vec4(aNormal,1.0)).xyz, vec3(0.0,0.0,1.0)) * 0.5;\n"+ - "vec3 c = uColor.xyz;\n"+ - "c = (l > 0.0) ? mix(c,vec3(1.0,1.0,1.0),l) : mix(vec3(0.0,0.0,0.0),c,1.0+l);\n"+ - "vColor = vec4(c, uColor.w);\n"+ - "gl_Position = uMVP * vec4(aPosition, 1.0);\n"+ - "}"; - - -GpuShaders.polygonFragmentShader = "precision mediump float;\n"+ - "varying vec4 vColor;\n"+ - "void main() {\n"+ - "gl_FragColor = vColor;\n"+ - "}"; + 'attribute vec3 aPosition;\n'+ + 'attribute vec3 aNormal;\n'+ + 'uniform mat4 uMVP;\n'+ + 'uniform mat4 uRot;\n'+ + 'uniform vec4 uColor;\n'+ + 'varying vec4 vColor;\n'+ + 'void main(){ \n'+ + 'float l = dot((uRot*vec4(aNormal,1.0)).xyz, vec3(0.0,0.0,1.0)) * 0.5;\n'+ + 'vec3 c = uColor.xyz;\n'+ + 'c = (l > 0.0) ? mix(c,vec3(1.0,1.0,1.0),l) : mix(vec3(0.0,0.0,0.0),c,1.0+l);\n'+ + 'vColor = vec4(c, uColor.w);\n'+ + 'gl_Position = uMVP * vec4(aPosition, 1.0);\n'+ + '}'; + + +GpuShaders.polygonFragmentShader = 'precision mediump float;\n'+ + 'varying vec4 vColor;\n'+ + 'void main() {\n'+ + 'gl_FragColor = vColor;\n'+ + '}'; GpuShaders.textVertexShader = - "attribute vec4 aPosition;\n"+ - "attribute vec4 aTexCoord;\n"+ - "uniform mat4 uMVP;\n"+ - "uniform vec4 uVec;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main(){ \n"+ - "vTexCoord = aTexCoord.xy;\n"+ - "if (dot(uVec.xyz, vec3(aTexCoord.z, aTexCoord.w, aPosition.w)) < 0.0) {\n"+ - "gl_Position = uMVP * vec4(2.0, 0.0, 0.0, 1.0);\n"+ - "}else{\n"+ - "gl_Position = uMVP * vec4(aPosition.xyz, 1.0);\n"+ - "}\n"+ - "}"; + 'attribute vec4 aPosition;\n'+ + 'attribute vec4 aTexCoord;\n'+ + 'uniform mat4 uMVP;\n'+ + 'uniform vec4 uVec;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main(){ \n'+ + 'vTexCoord = aTexCoord.xy;\n'+ + 'if (dot(uVec.xyz, vec3(aTexCoord.z, aTexCoord.w, aPosition.w)) < 0.0) {\n'+ + 'gl_Position = uMVP * vec4(2.0, 0.0, 0.0, 1.0);\n'+ + '}else{\n'+ + 'gl_Position = uMVP * vec4(aPosition.xyz, 1.0);\n'+ + '}\n'+ + '}'; GpuShaders.textVertexShader2 = - "attribute vec3 aPosition;\n"+ - "attribute vec4 aTexCoord;\n"+ - "uniform mat4 uMVP;\n"+ - "uniform vec4 uPosition;\n"+ - "uniform float uDepth;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main(){ \n"+ - "vTexCoord = aTexCoord.xy;\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec4 aTexCoord;\n'+ + 'uniform mat4 uMVP;\n'+ + 'uniform vec4 uPosition;\n'+ + 'uniform float uDepth;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main(){ \n'+ + 'vTexCoord = aTexCoord.xy;\n'+ //"gl_Position = uMVP * vec4(aPosition, 1.0);\n"+ - "gl_Position = uMVP*vec4(aPosition[0]+uPosition[0],-aPosition[1]+uPosition[1],uPosition[2],1.0);\n"+ - "}"; + 'gl_Position = uMVP*vec4(aPosition[0]+uPosition[0],-aPosition[1]+uPosition[1],uPosition[2],1.0);\n'+ + '}'; GpuShaders.iconVertexShader = - "attribute vec4 aPosition;\n"+ - "attribute vec4 aTexCoord;\n"+ - "attribute vec3 aOrigin;\n"+ - "uniform mat4 uMVP;\n"+ - "uniform vec4 uScale;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main(){ \n"+ - "vTexCoord = aTexCoord.xy * uScale[2];\n"+ - "vec4 pos = (uMVP * vec4(aOrigin, 1.0));\n"+ + 'attribute vec4 aPosition;\n'+ + 'attribute vec4 aTexCoord;\n'+ + 'attribute vec3 aOrigin;\n'+ + 'uniform mat4 uMVP;\n'+ + 'uniform vec4 uScale;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main(){ \n'+ + 'vTexCoord = aTexCoord.xy * uScale[2];\n'+ + 'vec4 pos = (uMVP * vec4(aOrigin, 1.0));\n'+ //"pos.xy = pos.xy / pos.w;\n"+ - "gl_Position = pos + vec4(aPosition.x*uScale.x*pos.w, (aPosition.y+uScale.w)*uScale.y*pos.w, 0.0, 0.0);\n"+ - "}"; + 'gl_Position = pos + vec4(aPosition.x*uScale.x*pos.w, (aPosition.y+uScale.w)*uScale.y*pos.w, 0.0, 0.0);\n'+ + '}'; -GpuShaders.textFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform vec4 uColor;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main() {\n"+ - "vec4 c=texture2D(uSampler, vTexCoord);\n"+ - "if(c.w < 0.01){ discard; }\n"+ - "gl_FragColor = c*uColor;\n"+ - "}"; +GpuShaders.textFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform vec4 uColor;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main() {\n'+ + 'vec4 c=texture2D(uSampler, vTexCoord);\n'+ + 'if(c.w < 0.01){ discard; }\n'+ + 'gl_FragColor = c*uColor;\n'+ + '}'; GpuShaders.skydomeVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "uniform mat4 uMVP;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main(){ \n"+ - "gl_Position = uMVP * vec4(aPosition, 1.0);\n"+ - "vTexCoord = aTexCoord;\n"+ - "}"; - - -GpuShaders.skydomeFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "varying vec2 vTexCoord;\n"+ - "const vec4 gray = vec4(0.125, 0.125, 0.125, 1.0);\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'uniform mat4 uMVP;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main(){ \n'+ + 'gl_Position = uMVP * vec4(aPosition, 1.0);\n'+ + 'vTexCoord = aTexCoord;\n'+ + '}'; + + +GpuShaders.skydomeFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'const vec4 gray = vec4(0.125, 0.125, 0.125, 1.0);\n'+ // "const vec4 gray = vec4(1.0, 1.0, 1.0, 1.0);\n"+ - "void main() {\n"+ + 'void main() {\n'+ //"float fade = smoothstep(0.49, 0.52, vTexCoord.t);\n"+ - "float fade = smoothstep(0.51, 0.55, vTexCoord.t);\n"+ - "gl_FragColor = mix(texture2D(uSampler, vTexCoord), gray, fade);\n"+ + 'float fade = smoothstep(0.51, 0.55, vTexCoord.t);\n'+ + 'gl_FragColor = mix(texture2D(uSampler, vTexCoord), gray, fade);\n'+ //"gl_FragColor = vec4(0.9, 0.9, 0.9, 1.0);\n"+ //"gl_FragColor = vec4(vTexCoord.x, vTexCoord.y, 0.9, 1.0);\n"+ - "}"; + '}'; -GpuShaders.stardomeFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "varying vec2 vTexCoord;\n"+ - "void main() {\n"+ - "gl_FragColor = texture2D(uSampler, vTexCoord);\n"+ - "}"; +GpuShaders.stardomeFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'void main() {\n'+ + 'gl_FragColor = texture2D(uSampler, vTexCoord);\n'+ + '}'; GpuShaders.atmoVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform mat3 uNorm;\n"+ - "varying vec3 vNormal;\n"+ - "varying vec4 vPosition;\n"+ - "void main(){ \n"+ - "vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "vec4 c = uMV * vec4(aPosition, 1.0);\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform mat3 uNorm;\n'+ + 'varying vec3 vNormal;\n'+ + 'varying vec4 vPosition;\n'+ + 'void main(){ \n'+ + 'vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'vec4 c = uMV * vec4(aPosition, 1.0);\n'+ // "vNormal = uNorm * (aPosition.xyz - vec3(0.5));\n"+ - "vNormal = (aPosition.xyz - vec3(0.5));\n"+ + 'vNormal = (aPosition.xyz - vec3(0.5));\n'+ - "vPosition = camSpacePos;\n"+ - "}"; + 'vPosition = camSpacePos;\n'+ + '}'; -GpuShaders.atmoFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ +GpuShaders.atmoFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ // "uniform float uNFactor;\n"+ - "uniform vec4 uParams;\n"+ //[radius, atmoSize, 0 ,0] - "uniform vec4 uParams2;\n"+ //[radius, atmoSize, 0 ,0] - "varying vec4 vPosition;\n"+ - "varying vec3 vNormal;\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "const vec4 fogColor2 = vec4(72.0/255.0, 154.0/255.0, 255.0/255.0, 1.0);\n"+ - "void main() {\n"+ + 'uniform vec4 uParams;\n'+ //[radius, atmoSize, 0 ,0] + 'uniform vec4 uParams2;\n'+ //[radius, atmoSize, 0 ,0] + 'varying vec4 vPosition;\n'+ + 'varying vec3 vNormal;\n'+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'const vec4 fogColor2 = vec4(72.0/255.0, 154.0/255.0, 255.0/255.0, 1.0);\n'+ + 'void main() {\n'+ // "vec3 ldir = normalize(-vPosition.xyz);\n"+ // "vec4 c = texture2D(uSampler, vec2(0,0));\n"+ //"c.y = 1.0+dot(normalize(vNormal),ldir)*4.0;\n"+ @@ -319,77 +319,77 @@ GpuShaders.atmoFragmentShader = "precision mediump float;\n"+ //"c = mix(vec4(0.0,0.0,0.0,1.0),fogColor, 1.0 - clamp(-l, 0.0, uParams[1]) / uParams[1]);\n"+ // "float l = dot(normalize(vNormal),ldir);\n"+ - "float l = dot(normalize(vNormal),-uParams2.xyz);\n"+ + 'float l = dot(normalize(vNormal),-uParams2.xyz);\n'+ //"l = cos(acos(l) - uParams.x);\n"+ //anguler shift // "l = (1.0-(abs(l)));\n"+ // "l = (1.0-pow(abs(l),2.0));\n"+ // "l += pow(l,2.0);\n"+ - "l = (1.0-pow(abs(l),uParams.x));\n"+ + 'l = (1.0-pow(abs(l),uParams.x));\n'+ //"l = clamp(pow(l,12.0)*uParams.w, 0.0, 1.0);\n"+ // "vec4 c = vec4(fogColor.xyz*pow(0.85 - l, 13.0), 1.0);\n"+ - "vec4 c = vec4(mix(fogColor2.xyz, fogColor.xyz, l), l);\n"+ + 'vec4 c = vec4(mix(fogColor2.xyz, fogColor.xyz, l), l);\n'+ - "gl_FragColor = c;\n"+ - "}"; - - -GpuShaders.atmoFragmentShader2 = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform float uNFactor;\n"+ - "uniform vec2 uRadius;\n"+ - "uniform vec3 uPos;\n"+ - "varying vec4 vPosition;\n"+ - "varying vec3 vNormal;\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "vec3 ldir = normalize(-vPosition.xyz);\n"+ - "vec3 diff = uPos;\n"+ - "float a = dot(ldir, ldir);\n"+ - "float b = 2 * dot(ldir, diff);\n"+ - "float c = dot(diff, diff) - (uRadius[0] * uRadius[0]);\n"+ - "float i = 0;\n"+ - "float discr = b * b - 4 * a * c;\n"+ - "if (discr > 0.0) {}\n"+ - - "}\n"+ + 'gl_FragColor = c;\n'+ + '}'; + + +GpuShaders.atmoFragmentShader2 = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform float uNFactor;\n'+ + 'uniform vec2 uRadius;\n'+ + 'uniform vec3 uPos;\n'+ + 'varying vec4 vPosition;\n'+ + 'varying vec3 vNormal;\n'+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'vec3 ldir = normalize(-vPosition.xyz);\n'+ + 'vec3 diff = uPos;\n'+ + 'float a = dot(ldir, ldir);\n'+ + 'float b = 2 * dot(ldir, diff);\n'+ + 'float c = dot(diff, diff) - (uRadius[0] * uRadius[0]);\n'+ + 'float i = 0;\n'+ + 'float discr = b * b - 4 * a * c;\n'+ + 'if (discr > 0.0) {}\n'+ + + '}\n'+ //"vec4 c = texture2D(uSampler, vec2(0,0));\n"+ //"c.y = 1.0+dot(normalize(vNormal),ldir)*4.0;\n"+ //"float l = dot(normalize(vNormal*uNFactor),ldir);\n"+ //"c = mix(vec4(0.0,0.0,0.0,1.0),fogColor,max(0.0,-l*3.0));\n"+ - "gl_FragColor = fogColor;\n"+ - "}"; + 'gl_FragColor = fogColor;\n'+ + '}'; GpuShaders.atmoVertexShader3 = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "uniform mat4 uMV, uProj;\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'uniform mat4 uMV, uProj;\n'+ //"uniform mat3 uNorm;\n"+ - "uniform vec4 uParams;\n"+ //[surfaceRadius, surfaceRadius, strech ,safetyfactor] - "uniform vec4 uParams2;\n"+ //[cameraPos, 1] + 'uniform vec4 uParams;\n'+ //[surfaceRadius, surfaceRadius, strech ,safetyfactor] + 'uniform vec4 uParams2;\n'+ //[cameraPos, 1] - "varying vec2 vTexcoords;\n"+ + 'varying vec2 vTexcoords;\n'+ - "void main(){ \n"+ - "gl_Position = uProj * (uMV * vec4(aPosition, 1.0));\n"+ + 'void main(){ \n'+ + 'gl_Position = uProj * (uMV * vec4(aPosition, 1.0));\n'+ - "vec3 position = (aPosition.xyz - vec3(0.5)) * vec3(uParams.w * 2.0);\n"+ - "vec4 camPos = uParams2;\n"+ - "float SurfaceRadius = uParams.x;\n"+ - "float AtmosphereRadius = uParams.y;\n"+ - "float StretchAmt = uParams.z;\n"+ + 'vec3 position = (aPosition.xyz - vec3(0.5)) * vec3(uParams.w * 2.0);\n'+ + 'vec4 camPos = uParams2;\n'+ + 'float SurfaceRadius = uParams.x;\n'+ + 'float AtmosphereRadius = uParams.y;\n'+ + 'float StretchAmt = uParams.z;\n'+ //"oPosition = mul(Po, WorldViewProj);\n"+ //"float radius = length(position);\n"+ //"float radius2 = radius * radius;\n"+ - "float camHeight = length(camPos.xyz);\n"+ - "vec3 camToPos = position - camPos.xyz;\n"+ - "float farDist = length(camToPos);\n"+ + 'float camHeight = length(camPos.xyz);\n'+ + 'vec3 camToPos = position - camPos.xyz;\n'+ + 'float farDist = length(camToPos);\n'+ //"vec3 normal = normalize(position);\n"+ @@ -405,43 +405,43 @@ GpuShaders.atmoVertexShader3 = //"vec3 nearNormal = normalize(nearPos);\n"+ // get distance to surface horizon - "float altitude = max(0.0,camHeight - SurfaceRadius);\n"+ - "float horizonDist = sqrt((altitude*altitude) + (2.0 * SurfaceRadius * altitude));\n"+ - "float maxDot = horizonDist / camHeight;\n"+ + 'float altitude = max(0.0,camHeight - SurfaceRadius);\n'+ + 'float horizonDist = sqrt((altitude*altitude) + (2.0 * SurfaceRadius * altitude));\n'+ + 'float maxDot = horizonDist / camHeight;\n'+ // get distance to atmosphere horizon - use max(0,...) because we can go into the atmosphere - "altitude = max(0.0,camHeight - AtmosphereRadius);\n"+ - "horizonDist = sqrt((altitude*altitude) + (2.0 * AtmosphereRadius * altitude));\n"+ + 'altitude = max(0.0,camHeight - AtmosphereRadius);\n'+ + 'horizonDist = sqrt((altitude*altitude) + (2.0 * AtmosphereRadius * altitude));\n'+ // without this, the shift between inside and outside atmosphere is jarring - "float tweakAmount = 0.1;\n"+ - "float minDot = max(tweakAmount,horizonDist / camHeight);\n"+ + 'float tweakAmount = 0.1;\n'+ + 'float minDot = max(tweakAmount,horizonDist / camHeight);\n'+ // scale minDot from 0 to -1 as we enter the atmosphere - "float minDot2 = ((camHeight - SurfaceRadius) * (1.0 / (AtmosphereRadius - SurfaceRadius))) - (1.0 - tweakAmount);\n"+ - "minDot = min(minDot, minDot2);\n"+ + 'float minDot2 = ((camHeight - SurfaceRadius) * (1.0 / (AtmosphereRadius - SurfaceRadius))) - (1.0 - tweakAmount);\n'+ + 'minDot = min(minDot, minDot2);\n'+ // get dot product of the vertex we're looking out - "float posDot = dot(camToPos / farDist,-camPos.xyz / camHeight) - minDot;\n"+ + 'float posDot = dot(camToPos / farDist,-camPos.xyz / camHeight) - minDot;\n'+ // calculate the height from surface in range 0..1 - "float height = posDot * (1.0 / (maxDot - minDot));\n"+ + 'float height = posDot * (1.0 / (maxDot - minDot));\n'+ - "vTexcoords.y = height;\n"+ + 'vTexcoords.y = height;\n'+ - "height -= min(0.0,minDot2 + ((1.0 + StretchAmt) * minDot2));\n"+ - "vTexcoords.x = height;\n"+ - "}"; + 'height -= min(0.0,minDot2 + ((1.0 + StretchAmt) * minDot2));\n'+ + 'vTexcoords.x = height;\n'+ + '}'; -GpuShaders.atmoFragmentShader3 = "precision mediump float;\n"+ - "varying vec2 vTexcoords;\n"+ - "uniform vec4 uParams3;\n"+ //[treshold, mutiplier, 0,0] - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "const vec4 fogColor2 = vec4(72.0/255.0, 154.0/255.0, 255.0/255.0, 1.0);\n"+ - "const vec4 fogColor3 = vec4(0.0/255.0, 0.0/255.0, 0.0/255.0, 1.0);\n"+ +GpuShaders.atmoFragmentShader3 = 'precision mediump float;\n'+ + 'varying vec2 vTexcoords;\n'+ + 'uniform vec4 uParams3;\n'+ //[treshold, mutiplier, 0,0] + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'const vec4 fogColor2 = vec4(72.0/255.0, 154.0/255.0, 255.0/255.0, 1.0);\n'+ + 'const vec4 fogColor3 = vec4(0.0/255.0, 0.0/255.0, 0.0/255.0, 1.0);\n'+ - "void main() {\n"+ + 'void main() {\n'+ // "gl_FragColor = vec4(1.0 - exp(((fogColor * vTexcoords.x) * (1.0 + vTexcoords.y)) * -1.5));\n"+ // "gl_FragColor = vec4(vec3(fract(vTexcoords.y)),1.0);\n"+ // "gl_FragColor = vec4(vec3(1.0),fract(vTexcoords.y));\n"+ @@ -450,581 +450,581 @@ GpuShaders.atmoFragmentShader3 = "precision mediump float;\n"+ // "gl_FragColor = vec4(vec3(vTexcoords.y),1.0);\n"+ //"gl_FragColor = vec4(fogColor.xyz, vTexcoords.y);\n"+ - "float l = vTexcoords.y;\n"+ - "if (l > uParams3.z){ discard; } else {\n"+ - "float l2 = clamp((l*l)*0.9+0.1, 0.0, 1.5);\n"+ - "gl_FragColor = vec4(mix(fogColor2.xyz, fogColor.xyz, l2), l);\n"+ + 'float l = vTexcoords.y;\n'+ + 'if (l > uParams3.z){ discard; } else {\n'+ + 'float l2 = clamp((l*l)*0.9+0.1, 0.0, 1.5);\n'+ + 'gl_FragColor = vec4(mix(fogColor2.xyz, fogColor.xyz, l2), l);\n'+ - "if (l > uParams3.x){ gl_FragColor.xyz = mix(gl_FragColor.xyz, fogColor3.xyz, (l-uParams3.x)*uParams3.y); }\n"+ + 'if (l > uParams3.x){ gl_FragColor.xyz = mix(gl_FragColor.xyz, fogColor3.xyz, (l-uParams3.x)*uParams3.y); }\n'+ // "gl_FragColor = vec4(vec3(1.0),1.0 - exp(((fogColor * vTexcoords.x) * (1.0 + vTexcoords.y)) * -1.5));\n"+ - "}"+ + '}'+ - "}"; + '}'; //heightmap tile GpuShaders.heightmapVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform float uFogDensity;\n"+ - "uniform mat4 uGridMat;\n"+ - "uniform float uGridStep1, uGridStep2;\n"+ - "const int HMSize = 5;\n"+ - "const float HMSize1 = float(HMSize-1);\n"+ - "uniform float uHeight[HMSize*HMSize];\n"+ - "varying vec2 vTexCoord1;\n"+ - "varying vec2 vTexCoord2;\n"+ - "varying float vFogFactor;\n"+ - "float round(float x) { return floor(x + 0.5); }\n"+ - "void main() {\n"+ - "vec3 pos = aPosition;\n"+ - "float z = uHeight[int(round(pos.y*HMSize1)*float(HMSize) + round(pos.x*HMSize1))];\n"+ - "vec4 camSpacePos = uMV * vec4(pos.xy, z, 1.0);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uFogDensity * camDist);\n"+ - "vec4 gridCoord = uGridMat * vec4(pos, 1.0);\n"+ - "vTexCoord1 = aTexCoord;\n"+ - "vTexCoord1 = gridCoord.xy * vec2(uGridStep1);\n"+ - "vTexCoord2 = gridCoord.xy * vec2(uGridStep2);\n"+ - "}"; - - -GpuShaders.heightmapFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform float uGridBlend;\n"+ - "varying vec2 vTexCoord1;\n"+ - "varying vec2 vTexCoord2;\n"+ - "varying float vFogFactor;\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform float uFogDensity;\n'+ + 'uniform mat4 uGridMat;\n'+ + 'uniform float uGridStep1, uGridStep2;\n'+ + 'const int HMSize = 5;\n'+ + 'const float HMSize1 = float(HMSize-1);\n'+ + 'uniform float uHeight[HMSize*HMSize];\n'+ + 'varying vec2 vTexCoord1;\n'+ + 'varying vec2 vTexCoord2;\n'+ + 'varying float vFogFactor;\n'+ + 'float round(float x) { return floor(x + 0.5); }\n'+ + 'void main() {\n'+ + 'vec3 pos = aPosition;\n'+ + 'float z = uHeight[int(round(pos.y*HMSize1)*float(HMSize) + round(pos.x*HMSize1))];\n'+ + 'vec4 camSpacePos = uMV * vec4(pos.xy, z, 1.0);\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uFogDensity * camDist);\n'+ + 'vec4 gridCoord = uGridMat * vec4(pos, 1.0);\n'+ + 'vTexCoord1 = aTexCoord;\n'+ + 'vTexCoord1 = gridCoord.xy * vec2(uGridStep1);\n'+ + 'vTexCoord2 = gridCoord.xy * vec2(uGridStep2);\n'+ + '}'; + + +GpuShaders.heightmapFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform float uGridBlend;\n'+ + 'varying vec2 vTexCoord1;\n'+ + 'varying vec2 vTexCoord2;\n'+ + 'varying float vFogFactor;\n'+ // "const vec4 fogColor = vec4(1, 1, 1, 1);\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "vec4 gridColor = mix(texture2D(uSampler, vTexCoord1), texture2D(uSampler, vTexCoord2), uGridBlend);\n"+ - "gl_FragColor = mix(fogColor, gridColor, vFogFactor);\n"+ - "}"; + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'vec4 gridColor = mix(texture2D(uSampler, vTexCoord1), texture2D(uSampler, vTexCoord2), uGridBlend);\n'+ + 'gl_FragColor = mix(fogColor, gridColor, vFogFactor);\n'+ + '}'; //depth encoded heightmap tile GpuShaders.heightmapDepthVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform float uFogDensity;\n"+ - "uniform mat4 uGridMat;\n"+ - "uniform float uGridStep1, uGridStep2;\n"+ - "const int HMSize = 5;\n"+ - "const float HMSize1 = float(HMSize-1);\n"+ - "uniform float uHeight[HMSize*HMSize];\n"+ - "varying vec2 vTexCoord1;\n"+ - "varying vec2 vTexCoord2;\n"+ - "varying float vDepth;\n"+ - "float round(float x) { return floor(x + 0.5); }\n"+ - "void main() {\n"+ - "vec3 pos = aPosition;\n"+ - "float z = uHeight[int(round(pos.y*HMSize1)*float(HMSize) + round(pos.x*HMSize1))];\n"+ - "vec4 camSpacePos = uMV * vec4(pos.xy, z, 1.0);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vDepth = camDist;\n"+ - "vec4 gridCoord = uGridMat * vec4(pos, 1.0);\n"+ - "vTexCoord1 = aTexCoord;\n"+ - "vTexCoord1 = gridCoord.xy * vec2(uGridStep1);\n"+ - "vTexCoord2 = gridCoord.xy * vec2(uGridStep2);\n"+ - "}"; - - -GpuShaders.heightmapDepthFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform float uGridBlend;\n"+ - "varying vec2 vTexCoord1;\n"+ - "varying vec2 vTexCoord2;\n"+ - "varying float vDepth;\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform float uFogDensity;\n'+ + 'uniform mat4 uGridMat;\n'+ + 'uniform float uGridStep1, uGridStep2;\n'+ + 'const int HMSize = 5;\n'+ + 'const float HMSize1 = float(HMSize-1);\n'+ + 'uniform float uHeight[HMSize*HMSize];\n'+ + 'varying vec2 vTexCoord1;\n'+ + 'varying vec2 vTexCoord2;\n'+ + 'varying float vDepth;\n'+ + 'float round(float x) { return floor(x + 0.5); }\n'+ + 'void main() {\n'+ + 'vec3 pos = aPosition;\n'+ + 'float z = uHeight[int(round(pos.y*HMSize1)*float(HMSize) + round(pos.x*HMSize1))];\n'+ + 'vec4 camSpacePos = uMV * vec4(pos.xy, z, 1.0);\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vDepth = camDist;\n'+ + 'vec4 gridCoord = uGridMat * vec4(pos, 1.0);\n'+ + 'vTexCoord1 = aTexCoord;\n'+ + 'vTexCoord1 = gridCoord.xy * vec2(uGridStep1);\n'+ + 'vTexCoord2 = gridCoord.xy * vec2(uGridStep2);\n'+ + '}'; + + +GpuShaders.heightmapDepthFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform float uGridBlend;\n'+ + 'varying vec2 vTexCoord1;\n'+ + 'varying vec2 vTexCoord2;\n'+ + 'varying float vDepth;\n'+ // "const vec4 fogColor = vec4(1, 1, 1, 1);\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ //"vec4 gridColor = mix(texture2D(uSampler, vTexCoord1), texture2D(uSampler, vTexCoord2), uGridBlend);\n"+ - "gl_FragColor = fract(vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) * vDepth) + (-0.5/255.0);\n"+ + 'gl_FragColor = fract(vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) * vDepth) + (-0.5/255.0);\n'+ //"gl_FragColor = mix(fogColor, gridColor, vFogFactor);\n"+ - "}"; + '}'; GpuShaders.planeVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "uniform mat4 uMV, uProj;\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'uniform mat4 uMV, uProj;\n'+ // "uniform vec4 uParams;\n"+ //[zfactor, fogDensity, indexFactor, 0] // "uniform vec4 uParams2;\n"+ //[uGridStep1, uGridStep2, uGridBlend, 0] - "uniform vec4 uParams;\n"+ //[uGridStep1, fogDensity, indexFactor, uGridStep2] - "uniform vec4 uParams3;\n"+ //[px, py, sx, sy] - "uniform float uPoints[9*3];\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec2 vTexCoord2;\n"+ - "varying float vFogFactor;\n"+ - "vec3 quadPoint(int i1, int i2, int i3, float t, float t2) {\n"+ - "float p1x = uPoints[i1], p1y = uPoints[i1+1], p1z = uPoints[i1+2];\n"+ - "float p3x = uPoints[i3], p3y = uPoints[i3+1], p3z = uPoints[i3+2];\n"+ - "float p2x = 2.0*uPoints[i2]-p1x*0.5-p3x*0.5;\n"+ - "float p2y = 2.0*uPoints[i2+1]-p1y*0.5-p3y*0.5;\n"+ - "float p2z = 2.0*uPoints[i2+2]-p1z*0.5-p3z*0.5;\n"+ - "return vec3(t2*t2*p1x+2.0*t2*t*p2x+t*t*p3x, t2*t2*p1y+2.0*t2*t*p2y+t*t*p3y, t2*t2*p1z+2.0*t2*t*p2z+t*t*p3z); }\n"+ - "void main() {\n"+ - "vec3 indices = aPosition;\n"+ - "float t = aPosition.y * uParams[2];\n"+ //vertical index - "float t2 = (1.0-t);\n"+ - "vec3 p1 = quadPoint(0, 3, 6, t, t2);\n"+ - "vec3 p2 = quadPoint(9, 9+3, 9+6, t, t2);\n"+ - "vec3 p3 = quadPoint(18, 18+3, 18+6, t, t2);\n"+ - "t = aPosition.x * uParams[2];\n"+ //horizontal index - "t2 = (1.0-t);\n"+ - "float p2x = 2.0*p2.x-p1.x*0.5-p3.x*0.5;\n"+ - "float p2y = 2.0*p2.y-p1.y*0.5-p3.y*0.5;\n"+ - "float p2z = 2.0*p2.z-p1.z*0.5-p3.z*0.5;\n"+ - "vec4 p = vec4(t2*t2*p1.x+2.0*t2*t*p2x+t*t*p3.x, t2*t2*p1.y+2.0*t2*t*p2y+t*t*p3.y, t2*t2*p1.z+2.0*t2*t*p2z+t*t*p3.z, 1);\n"+ - "vec4 camSpacePos = uMV * p;\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uParams[1] * camDist);\n"+ - "vec2 uv = aTexCoord;\n"+ - "uv.x = uv.x * uParams3[2] + uParams3[0];\n"+ - "uv.y = uv.y * uParams3[3] + uParams3[1];\n"+ - "vTexCoord = uv;\n"+ - "}"; - - -GpuShaders.planeFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform vec4 uParams2;\n"+ //[uGridStep1, uGridStep2, uGridBlend, 0] - "varying vec2 vTexCoord;\n"+ - "varying float vFogFactor;\n"+ + 'uniform vec4 uParams;\n'+ //[uGridStep1, fogDensity, indexFactor, uGridStep2] + 'uniform vec4 uParams3;\n'+ //[px, py, sx, sy] + 'uniform float uPoints[9*3];\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec2 vTexCoord2;\n'+ + 'varying float vFogFactor;\n'+ + 'vec3 quadPoint(int i1, int i2, int i3, float t, float t2) {\n'+ + 'float p1x = uPoints[i1], p1y = uPoints[i1+1], p1z = uPoints[i1+2];\n'+ + 'float p3x = uPoints[i3], p3y = uPoints[i3+1], p3z = uPoints[i3+2];\n'+ + 'float p2x = 2.0*uPoints[i2]-p1x*0.5-p3x*0.5;\n'+ + 'float p2y = 2.0*uPoints[i2+1]-p1y*0.5-p3y*0.5;\n'+ + 'float p2z = 2.0*uPoints[i2+2]-p1z*0.5-p3z*0.5;\n'+ + 'return vec3(t2*t2*p1x+2.0*t2*t*p2x+t*t*p3x, t2*t2*p1y+2.0*t2*t*p2y+t*t*p3y, t2*t2*p1z+2.0*t2*t*p2z+t*t*p3z); }\n'+ + 'void main() {\n'+ + 'vec3 indices = aPosition;\n'+ + 'float t = aPosition.y * uParams[2];\n'+ //vertical index + 'float t2 = (1.0-t);\n'+ + 'vec3 p1 = quadPoint(0, 3, 6, t, t2);\n'+ + 'vec3 p2 = quadPoint(9, 9+3, 9+6, t, t2);\n'+ + 'vec3 p3 = quadPoint(18, 18+3, 18+6, t, t2);\n'+ + 't = aPosition.x * uParams[2];\n'+ //horizontal index + 't2 = (1.0-t);\n'+ + 'float p2x = 2.0*p2.x-p1.x*0.5-p3.x*0.5;\n'+ + 'float p2y = 2.0*p2.y-p1.y*0.5-p3.y*0.5;\n'+ + 'float p2z = 2.0*p2.z-p1.z*0.5-p3.z*0.5;\n'+ + 'vec4 p = vec4(t2*t2*p1.x+2.0*t2*t*p2x+t*t*p3.x, t2*t2*p1.y+2.0*t2*t*p2y+t*t*p3.y, t2*t2*p1.z+2.0*t2*t*p2z+t*t*p3.z, 1);\n'+ + 'vec4 camSpacePos = uMV * p;\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uParams[1] * camDist);\n'+ + 'vec2 uv = aTexCoord;\n'+ + 'uv.x = uv.x * uParams3[2] + uParams3[0];\n'+ + 'uv.y = uv.y * uParams3[3] + uParams3[1];\n'+ + 'vTexCoord = uv;\n'+ + '}'; + + +GpuShaders.planeFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform vec4 uParams2;\n'+ //[uGridStep1, uGridStep2, uGridBlend, 0] + 'varying vec2 vTexCoord;\n'+ + 'varying float vFogFactor;\n'+ // "const vec4 fogColor = vec4(0.8274, 0.9137, 0.9725, 1.0);\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "vec4 c = mix(texture2D(uSampler, vTexCoord), texture2D(uSampler, vTexCoord*8.0), uParams2[2]);\n"+ - "gl_FragColor = mix(fogColor, c, vFogFactor);\n"+ - "}"; + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'vec4 c = mix(texture2D(uSampler, vTexCoord), texture2D(uSampler, vTexCoord*8.0), uParams2[2]);\n'+ + 'gl_FragColor = mix(fogColor, c, vFogFactor);\n'+ + '}'; GpuShaders.planeVertex2Shader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "uniform mat4 uMV, uProj;\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'uniform mat4 uMV, uProj;\n'+ // "uniform vec4 uParams;\n"+ //[zfactor, fogDensity, indexFactor, 0] // "uniform vec4 uParams2;\n"+ //[uGridStep1, uGridStep2, uGridBlend, 0] - "uniform vec4 uParams;\n"+ //[uGridStep1, fogDensity, indexFactor, uGridStep2] - "uniform vec4 uParams3;\n"+ //[px, py, sx, sy] - "uniform float uPoints[9*3];\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec2 vTexCoord2;\n"+ - "varying float vFogFactor;\n"+ - "vec3 quadPoint(int i1, int i2, int i3, float t, float t2) {\n"+ - "float p1x = uPoints[i1], p1y = uPoints[i1+1], p1z = uPoints[i1+2];\n"+ - "float p3x = uPoints[i3], p3y = uPoints[i3+1], p3z = uPoints[i3+2];\n"+ - "float p2x = 2.0*uPoints[i2]-p1x*0.5-p3x*0.5;\n"+ - "float p2y = 2.0*uPoints[i2+1]-p1y*0.5-p3y*0.5;\n"+ - "float p2z = 2.0*uPoints[i2+2]-p1z*0.5-p3z*0.5;\n"+ - "return vec3(t2*t2*p1x+2.0*t2*t*p2x+t*t*p3x, t2*t2*p1y+2.0*t2*t*p2y+t*t*p3y, t2*t2*p1z+2.0*t2*t*p2z+t*t*p3z); }\n"+ - "void main() {\n"+ - "vec3 indices = aPosition;\n"+ - "float t = aPosition.y * uParams[2];\n"+ //vertical index - "float t2 = (1.0-t);\n"+ - "vec3 p1 = quadPoint(0, 3, 6, t, t2);\n"+ - "vec3 p2 = quadPoint(9, 9+3, 9+6, t, t2);\n"+ - "vec3 p3 = quadPoint(18, 18+3, 18+6, t, t2);\n"+ - "t = aPosition.x * uParams[2];\n"+ //horizontal index - "t2 = (1.0-t);\n"+ - "float p2x = 2.0*p2.x-p1.x*0.5-p3.x*0.5;\n"+ - "float p2y = 2.0*p2.y-p1.y*0.5-p3.y*0.5;\n"+ - "float p2z = 2.0*p2.z-p1.z*0.5-p3.z*0.5;\n"+ - "vec4 p = vec4(t2*t2*p1.x+2.0*t2*t*p2x+t*t*p3.x, t2*t2*p1.y+2.0*t2*t*p2y+t*t*p3.y, t2*t2*p1.z+2.0*t2*t*p2z+t*t*p3.z, 1);\n"+ - "vec4 camSpacePos = uMV * p;\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uParams[1] * camDist);\n"+ - "vec2 uv = aTexCoord;\n"+ - "uv.x = uv.x * uParams3[2] + uParams3[0];\n"+ - "uv.y = uv.y * uParams3[3] + uParams3[1];\n"+ - "vTexCoord = uv;\n"+ - "vTexCoord2 = p.xy;\n"+ - "}"; - - -GpuShaders.planeFragment2Shader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform vec4 uParams2;\n"+ //[uGridStep1, uGridStep2, uGridBlend, 0] - "uniform vec4 uParams4;\n"+ //[pole-x, pole-y, pole-radius, 0] - "varying vec2 vTexCoord;\n"+ - "varying vec2 vTexCoord2;\n"+ - "varying float vFogFactor;\n"+ + 'uniform vec4 uParams;\n'+ //[uGridStep1, fogDensity, indexFactor, uGridStep2] + 'uniform vec4 uParams3;\n'+ //[px, py, sx, sy] + 'uniform float uPoints[9*3];\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec2 vTexCoord2;\n'+ + 'varying float vFogFactor;\n'+ + 'vec3 quadPoint(int i1, int i2, int i3, float t, float t2) {\n'+ + 'float p1x = uPoints[i1], p1y = uPoints[i1+1], p1z = uPoints[i1+2];\n'+ + 'float p3x = uPoints[i3], p3y = uPoints[i3+1], p3z = uPoints[i3+2];\n'+ + 'float p2x = 2.0*uPoints[i2]-p1x*0.5-p3x*0.5;\n'+ + 'float p2y = 2.0*uPoints[i2+1]-p1y*0.5-p3y*0.5;\n'+ + 'float p2z = 2.0*uPoints[i2+2]-p1z*0.5-p3z*0.5;\n'+ + 'return vec3(t2*t2*p1x+2.0*t2*t*p2x+t*t*p3x, t2*t2*p1y+2.0*t2*t*p2y+t*t*p3y, t2*t2*p1z+2.0*t2*t*p2z+t*t*p3z); }\n'+ + 'void main() {\n'+ + 'vec3 indices = aPosition;\n'+ + 'float t = aPosition.y * uParams[2];\n'+ //vertical index + 'float t2 = (1.0-t);\n'+ + 'vec3 p1 = quadPoint(0, 3, 6, t, t2);\n'+ + 'vec3 p2 = quadPoint(9, 9+3, 9+6, t, t2);\n'+ + 'vec3 p3 = quadPoint(18, 18+3, 18+6, t, t2);\n'+ + 't = aPosition.x * uParams[2];\n'+ //horizontal index + 't2 = (1.0-t);\n'+ + 'float p2x = 2.0*p2.x-p1.x*0.5-p3.x*0.5;\n'+ + 'float p2y = 2.0*p2.y-p1.y*0.5-p3.y*0.5;\n'+ + 'float p2z = 2.0*p2.z-p1.z*0.5-p3.z*0.5;\n'+ + 'vec4 p = vec4(t2*t2*p1.x+2.0*t2*t*p2x+t*t*p3.x, t2*t2*p1.y+2.0*t2*t*p2y+t*t*p3.y, t2*t2*p1.z+2.0*t2*t*p2z+t*t*p3.z, 1);\n'+ + 'vec4 camSpacePos = uMV * p;\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uParams[1] * camDist);\n'+ + 'vec2 uv = aTexCoord;\n'+ + 'uv.x = uv.x * uParams3[2] + uParams3[0];\n'+ + 'uv.y = uv.y * uParams3[3] + uParams3[1];\n'+ + 'vTexCoord = uv;\n'+ + 'vTexCoord2 = p.xy;\n'+ + '}'; + + +GpuShaders.planeFragment2Shader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform vec4 uParams2;\n'+ //[uGridStep1, uGridStep2, uGridBlend, 0] + 'uniform vec4 uParams4;\n'+ //[pole-x, pole-y, pole-radius, 0] + 'varying vec2 vTexCoord;\n'+ + 'varying vec2 vTexCoord2;\n'+ + 'varying float vFogFactor;\n'+ // "const vec4 fogColor = vec4(0.8274, 0.9137, 0.9725, 1.0);\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "if (length(uParams4.xy - vTexCoord2.xy) > uParams4.z){ discard; }"+ - "vec4 c = mix(texture2D(uSampler, vTexCoord), texture2D(uSampler, vTexCoord*8.0), uParams2[2]);\n"+ - "gl_FragColor = mix(fogColor, c, vFogFactor);\n"+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'if (length(uParams4.xy - vTexCoord2.xy) > uParams4.z){ discard; }'+ + 'vec4 c = mix(texture2D(uSampler, vTexCoord), texture2D(uSampler, vTexCoord*8.0), uParams2[2]);\n'+ + 'gl_FragColor = mix(fogColor, c, vFogFactor);\n'+ //"gl_FragColor = mix(texture2D(uSampler, vTexCoord), texture2D(uSampler, vTexCoord*8.0), uParams2[2]);\n"+ - "}"; + '}'; //textured tile mesh GpuShaders.tileVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform vec4 uParams;\n"+ //[zfactor, fogDensity, 0, 0] - "varying vec2 vTexCoord;\n"+ - "varying float vFogFactor;\n"+ - "void main() {\n"+ - "vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform vec4 uParams;\n'+ //[zfactor, fogDensity, 0, 0] + 'varying vec2 vTexCoord;\n'+ + 'varying float vFogFactor;\n'+ + 'void main() {\n'+ + 'vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n'+ // "gl_Position = uProj * camSpacePos; gl_Position.z*=1.0+uParams[0]*abs(gl_Position.w/gl_Position.z);\n"+ // "gl_Position = uProj * camSpacePos; gl_Position.z*=1.0+uParams[0]*abs(gl_Position.z/gl_Position.w);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uParams[1] * camDist);\n"+ - "vTexCoord = aTexCoord;\n"+ - "}"; - -GpuShaders.tileFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying float vFogFactor;\n"+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uParams[1] * camDist);\n'+ + 'vTexCoord = aTexCoord;\n'+ + '}'; + +GpuShaders.tileFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying float vFogFactor;\n'+ // "const vec4 fogColor = vec4(0.8274, 0.9137, 0.9725, 1.0);\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "gl_FragColor = mix(fogColor, texture2D(uSampler, vTexCoord), vFogFactor);\n"+ - "}"; + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'gl_FragColor = mix(fogColor, texture2D(uSampler, vTexCoord), vFogFactor);\n'+ + '}'; //textured tile mesh GpuShaders.tile2VertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord2;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform vec4 uParams;\n"+ //[zfactor, fogDensity, 0, 0] - "uniform vec4 uTransform;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying float vFogFactor;\n"+ - "void main() {\n"+ - "vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord2;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform vec4 uParams;\n'+ //[zfactor, fogDensity, 0, 0] + 'uniform vec4 uTransform;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying float vFogFactor;\n'+ + 'void main() {\n'+ + 'vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n'+ // "gl_Position = uProj * camSpacePos; gl_Position.z*=1.0+uParams[0]*abs(gl_Position.w/gl_Position.z);\n"+ // "gl_Position = uProj * camSpacePos; gl_Position.z*=1.0+uParams[0]*abs(gl_Position.z/gl_Position.w);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uParams[1] * camDist);\n"+ - "vTexCoord = vec2(uTransform[0] * aTexCoord2[0] + uTransform[2], uTransform[1] * aTexCoord2[1] + uTransform[3]);\n"+ - "}"; - - -GpuShaders.tile2FragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform float uAlpha;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying float vFogFactor;\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "vec4 c = texture2D(uSampler, vTexCoord);\n"+ - "gl_FragColor = mix(fogColor, c, vFogFactor);\n"+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uParams[1] * camDist);\n'+ + 'vTexCoord = vec2(uTransform[0] * aTexCoord2[0] + uTransform[2], uTransform[1] * aTexCoord2[1] + uTransform[3]);\n'+ + '}'; + + +GpuShaders.tile2FragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform float uAlpha;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying float vFogFactor;\n'+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'vec4 c = texture2D(uSampler, vTexCoord);\n'+ + 'gl_FragColor = mix(fogColor, c, vFogFactor);\n'+ //"gl_FragColor = texture2D(uSampler, vTexCoord);\n"+ - "gl_FragColor[3] = c.w * uAlpha;\n"+ - "}"; - - -GpuShaders.tile3FragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "uniform sampler2D uSampler2;\n"+ - "uniform float uAlpha;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying float vFogFactor;\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "vec4 c = texture2D(uSampler, vTexCoord);\n"+ - "vec4 c2 = texture2D(uSampler2, vTexCoord);\n"+ - "gl_FragColor = mix(fogColor, c, vFogFactor);\n"+ + 'gl_FragColor[3] = c.w * uAlpha;\n'+ + '}'; + + +GpuShaders.tile3FragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'uniform sampler2D uSampler2;\n'+ + 'uniform float uAlpha;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying float vFogFactor;\n'+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'vec4 c = texture2D(uSampler, vTexCoord);\n'+ + 'vec4 c2 = texture2D(uSampler2, vTexCoord);\n'+ + 'gl_FragColor = mix(fogColor, c, vFogFactor);\n'+ //"gl_FragColor = texture2D(uSampler, vTexCoord);\n"+ - "gl_FragColor[3] = c.w * uAlpha * c2.x;\n"+ - "}"; + 'gl_FragColor[3] = c.w * uAlpha * c2.x;\n'+ + '}'; //fog only tile mesh GpuShaders.fogTileVertexShader = - "attribute vec3 aPosition;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform float uFogDensity;\n"+ - "varying float vFogFactor;\n"+ - "void main() {\n"+ - "vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uFogDensity * camDist);\n"+ - "}"; - - -GpuShaders.fogTileFragmentShader = "precision mediump float;\n"+ - "varying float vFogFactor;\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "gl_FragColor = vec4(fogColor.xyz, 1.0-vFogFactor);\n"+ - "}"; + 'attribute vec3 aPosition;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform float uFogDensity;\n'+ + 'varying float vFogFactor;\n'+ + 'void main() {\n'+ + 'vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uFogDensity * camDist);\n'+ + '}'; + + +GpuShaders.fogTileFragmentShader = 'precision mediump float;\n'+ + 'varying float vFogFactor;\n'+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'gl_FragColor = vec4(fogColor.xyz, 1.0-vFogFactor);\n'+ + '}'; //textured shaded tile mesh GpuShaders.tileTShadedVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "attribute vec3 aNormal;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform mat3 uNorm;\n"+ - "uniform float uFogDensity;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec4 vPosition;\n"+ - "varying vec3 vNormal;\n"+ - "varying float vFogFactor;\n"+ - "void main() {\n"+ - "vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uFogDensity * camDist);\n"+ - "vTexCoord = aTexCoord;\n"+ - "vPosition = camSpacePos;\n"+ - "vNormal = aNormal * uNorm;\n"+ - "}"; - - -GpuShaders.tileTShadedFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec4 vPosition;\n"+ - "varying vec3 vNormal;\n"+ - "uniform mat4 uMaterial;\n"+ - "varying float vFogFactor;\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "vec3 ldir = normalize(-vPosition.xyz);\n"+ - "vec3 normal = normalize(vNormal);\n"+ - "vec3 eyeDir = ldir;\n"+ - "vec3 refDir = reflect(-ldir, normal);\n"+ - "float specW = min(1.0, pow(max(dot(refDir, eyeDir), 0.0), uMaterial[3][0]));\n"+ - "float diffW = min(1.0, max(dot(normal, ldir), 0.0));\n"+ - "vec4 lcolor = uMaterial[0]+(uMaterial[1]*diffW)+(uMaterial[2]*specW);\n"+ - "vec4 tcolor = texture2D(uSampler, vTexCoord);\n"+ - "gl_FragColor = mix(fogColor, vec4(lcolor.xyz*(1.0/255.0), 1.0) * tcolor, vFogFactor);\n"+ - "}"; - - -GpuShaders.tileShadedFragmentShader = "precision mediump float;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec4 vPosition;\n"+ - "varying vec3 vNormal;\n"+ - "uniform mat4 uMaterial;\n"+ - "varying float vFogFactor;\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "void main() {\n"+ - "vec3 ldir = normalize(-vPosition.xyz);\n"+ - "vec3 normal = normalize(vNormal);\n"+ - "vec3 eyeDir = ldir;\n"+ - "vec3 refDir = reflect(-ldir, normal);\n"+ - "float specW = min(1.0,pow(max(dot(refDir, eyeDir), 0.0), uMaterial[3][0]));\n"+ - "float diffW = min(1.0,max(dot(normal, ldir), 0.0));\n"+ - "vec4 lcolor = uMaterial[0]+(uMaterial[1]*diffW)+(uMaterial[2]*specW);\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'attribute vec3 aNormal;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform mat3 uNorm;\n'+ + 'uniform float uFogDensity;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec4 vPosition;\n'+ + 'varying vec3 vNormal;\n'+ + 'varying float vFogFactor;\n'+ + 'void main() {\n'+ + 'vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uFogDensity * camDist);\n'+ + 'vTexCoord = aTexCoord;\n'+ + 'vPosition = camSpacePos;\n'+ + 'vNormal = aNormal * uNorm;\n'+ + '}'; + + +GpuShaders.tileTShadedFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec4 vPosition;\n'+ + 'varying vec3 vNormal;\n'+ + 'uniform mat4 uMaterial;\n'+ + 'varying float vFogFactor;\n'+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'vec3 ldir = normalize(-vPosition.xyz);\n'+ + 'vec3 normal = normalize(vNormal);\n'+ + 'vec3 eyeDir = ldir;\n'+ + 'vec3 refDir = reflect(-ldir, normal);\n'+ + 'float specW = min(1.0, pow(max(dot(refDir, eyeDir), 0.0), uMaterial[3][0]));\n'+ + 'float diffW = min(1.0, max(dot(normal, ldir), 0.0));\n'+ + 'vec4 lcolor = uMaterial[0]+(uMaterial[1]*diffW)+(uMaterial[2]*specW);\n'+ + 'vec4 tcolor = texture2D(uSampler, vTexCoord);\n'+ + 'gl_FragColor = mix(fogColor, vec4(lcolor.xyz*(1.0/255.0), 1.0) * tcolor, vFogFactor);\n'+ + '}'; + + +GpuShaders.tileShadedFragmentShader = 'precision mediump float;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec4 vPosition;\n'+ + 'varying vec3 vNormal;\n'+ + 'uniform mat4 uMaterial;\n'+ + 'varying float vFogFactor;\n'+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'void main() {\n'+ + 'vec3 ldir = normalize(-vPosition.xyz);\n'+ + 'vec3 normal = normalize(vNormal);\n'+ + 'vec3 eyeDir = ldir;\n'+ + 'vec3 refDir = reflect(-ldir, normal);\n'+ + 'float specW = min(1.0,pow(max(dot(refDir, eyeDir), 0.0), uMaterial[3][0]));\n'+ + 'float diffW = min(1.0,max(dot(normal, ldir), 0.0));\n'+ + 'vec4 lcolor = uMaterial[0]+(uMaterial[1]*diffW)+(uMaterial[2]*specW);\n'+ //"gl_FragColor = vec4(lcolor.xyz*(1.0/255.0),1.0);\n"+ - "gl_FragColor = mix(fogColor, vec4(lcolor.xyz*(1.0/255.0), 1.0), vFogFactor);\n"+ + 'gl_FragColor = mix(fogColor, vec4(lcolor.xyz*(1.0/255.0), 1.0), vFogFactor);\n'+ //"gl_FragColor = mix(fogColor, vec4(lcolor.xyz*(1.0/255.0), 1.0), vFogFactor); gl_FragColor.w=uMaterial[3][1]*(1.0/255.0);\n"+ - "}"; + '}'; //flat shade tile mesh GpuShaders.tileFlatShadeVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "attribute vec3 aBarycentric;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform float uFogDensity;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec3 vBarycentric;\n"+ - "varying float vFogFactor;\n"+ - "void main() {\n"+ - "vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uFogDensity * camDist);\n"+ - "vTexCoord = aTexCoord;\n"+ - "vBarycentric = camSpacePos.xyz;\n"+ - "}"; - - -GpuShaders.tileFlatShadeFragmentShader = "precision mediump float;\n"+ - "#extension GL_OES_standard_derivatives : enable\n"+ - "uniform sampler2D uSampler;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec3 vBarycentric;\n"+ - "varying float vFogFactor;\n"+ - "void main() {\n"+ - "#ifdef GL_OES_standard_derivatives\n"+ - "vec3 nx = dFdx(vBarycentric);\n"+ - "vec3 ny = dFdy(vBarycentric);\n"+ - "vec3 normal=normalize(cross(nx,ny));\n"+ - "gl_FragColor = vec4(vec3(max(0.0,normal.z*(204.0/255.0))+(32.0/255.0)),1.0);\n"+ - "#else\n"+ - "gl_FragColor = vec4(1.0,1.0,1.0,1.0);\n"+ - "#endif\n"+ - "}"; + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'attribute vec3 aBarycentric;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform float uFogDensity;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec3 vBarycentric;\n'+ + 'varying float vFogFactor;\n'+ + 'void main() {\n'+ + 'vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uFogDensity * camDist);\n'+ + 'vTexCoord = aTexCoord;\n'+ + 'vBarycentric = camSpacePos.xyz;\n'+ + '}'; + + +GpuShaders.tileFlatShadeFragmentShader = 'precision mediump float;\n'+ + '#extension GL_OES_standard_derivatives : enable\n'+ + 'uniform sampler2D uSampler;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec3 vBarycentric;\n'+ + 'varying float vFogFactor;\n'+ + 'void main() {\n'+ + '#ifdef GL_OES_standard_derivatives\n'+ + 'vec3 nx = dFdx(vBarycentric);\n'+ + 'vec3 ny = dFdy(vBarycentric);\n'+ + 'vec3 normal=normalize(cross(nx,ny));\n'+ + 'gl_FragColor = vec4(vec3(max(0.0,normal.z*(204.0/255.0))+(32.0/255.0)),1.0);\n'+ + '#else\n'+ + 'gl_FragColor = vec4(1.0,1.0,1.0,1.0);\n'+ + '#endif\n'+ + '}'; //textured wire frame tile mesh GpuShaders.tileWireframeVertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord;\n"+ - "attribute vec3 aBarycentric;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform float uFogDensity;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec3 vBarycentric;\n"+ - "varying float vFogFactor;\n"+ - "void main() {\n"+ - "vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uFogDensity * camDist);\n"+ - "vTexCoord = aTexCoord;\n"+ - "vBarycentric = aBarycentric;\n"+ - "}"; - - -GpuShaders.tileWireframeFragmentShader = "precision mediump float;\n"+ - "#extension GL_OES_standard_derivatives : enable\n"+ - "uniform sampler2D uSampler;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec3 vBarycentric;\n"+ - "varying float vFogFactor;\n"+ + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord;\n'+ + 'attribute vec3 aBarycentric;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform float uFogDensity;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec3 vBarycentric;\n'+ + 'varying float vFogFactor;\n'+ + 'void main() {\n'+ + 'vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uFogDensity * camDist);\n'+ + 'vTexCoord = aTexCoord;\n'+ + 'vBarycentric = aBarycentric;\n'+ + '}'; + + +GpuShaders.tileWireframeFragmentShader = 'precision mediump float;\n'+ + '#extension GL_OES_standard_derivatives : enable\n'+ + 'uniform sampler2D uSampler;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec3 vBarycentric;\n'+ + 'varying float vFogFactor;\n'+ // "const vec4 fogColor = vec4(1, 1, 1, 1);\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "float edgeFactor(){\n"+ - "#ifdef GL_OES_standard_derivatives\n"+ - "vec3 d = fwidth(vBarycentric);\n"+ - "vec3 a3 = smoothstep(vec3(0.0), d*1.0, vBarycentric);\n"+ - "return min(min(a3.x, a3.y), a3.z);\n"+ - "#else\n"+ - "float a = min(min(vBarycentric.x, vBarycentric.y), vBarycentric.z);\n"+ - "return a > 0.1 ? 1.0 : smoothstep(0.0,1.0,a*10.0);\n"+ - "#endif\n"+ - "}\n"+ - "void main() {\n"+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'float edgeFactor(){\n'+ + '#ifdef GL_OES_standard_derivatives\n'+ + 'vec3 d = fwidth(vBarycentric);\n'+ + 'vec3 a3 = smoothstep(vec3(0.0), d*1.0, vBarycentric);\n'+ + 'return min(min(a3.x, a3.y), a3.z);\n'+ + '#else\n'+ + 'float a = min(min(vBarycentric.x, vBarycentric.y), vBarycentric.z);\n'+ + 'return a > 0.1 ? 1.0 : smoothstep(0.0,1.0,a*10.0);\n'+ + '#endif\n'+ + '}\n'+ + 'void main() {\n'+ //"gl_FragColor = vec4( mix(vec3(0.0), vec3(0.5), edgeFactor()) , 1.0);\n"+ - "gl_FragColor = mix(fogColor, vec4( mix(vec3(0.0), texture2D(uSampler, vTexCoord).rgb, edgeFactor()) , 1.0), vFogFactor);\n"+ + 'gl_FragColor = mix(fogColor, vec4( mix(vec3(0.0), texture2D(uSampler, vTexCoord).rgb, edgeFactor()) , 1.0), vFogFactor);\n'+ //"gl_FragColor = mix(fogColor, texture2D(uSampler, vTexCoord), vFogFactor);\n"+ - "}"; + '}'; -GpuShaders.tileWireframe2FragmentShader = "precision mediump float;\n"+ - "#extension GL_OES_standard_derivatives : enable\n"+ - "uniform sampler2D uSampler;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec3 vBarycentric;\n"+ - "varying float vFogFactor;\n"+ +GpuShaders.tileWireframe2FragmentShader = 'precision mediump float;\n'+ + '#extension GL_OES_standard_derivatives : enable\n'+ + 'uniform sampler2D uSampler;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec3 vBarycentric;\n'+ + 'varying float vFogFactor;\n'+ // "const vec4 fogColor = vec4(1, 1, 1, 1);\n"+ - "const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n"+ - "float edgeFactor(){\n"+ - "#ifdef GL_OES_standard_derivatives\n"+ - "vec3 d = fwidth(vBarycentric);\n"+ - "vec3 a3 = smoothstep(vec3(0.0), d*1.0, vBarycentric);\n"+ - "return min(min(a3.x, a3.y), a3.z);\n"+ - "#else\n"+ - "float a = min(min(vBarycentric.x, vBarycentric.y), vBarycentric.z);\n"+ - "return a > 0.1 ? 1.0 : smoothstep(0.0,1.0,a*10.0);\n"+ - "#endif\n"+ - "}\n"+ - "void main() {\n"+ + 'const vec4 fogColor = vec4(216.0/255.0, 232.0/255.0, 243.0/255.0, 1.0);\n'+ + 'float edgeFactor(){\n'+ + '#ifdef GL_OES_standard_derivatives\n'+ + 'vec3 d = fwidth(vBarycentric);\n'+ + 'vec3 a3 = smoothstep(vec3(0.0), d*1.0, vBarycentric);\n'+ + 'return min(min(a3.x, a3.y), a3.z);\n'+ + '#else\n'+ + 'float a = min(min(vBarycentric.x, vBarycentric.y), vBarycentric.z);\n'+ + 'return a > 0.1 ? 1.0 : smoothstep(0.0,1.0,a*10.0);\n'+ + '#endif\n'+ + '}\n'+ + 'void main() {\n'+ //"gl_FragColor = vec4( mix(vec3(0.0), vec3(0.5), edgeFactor()) , 1.0);\n"+ - "if (edgeFactor() < 0.5){ gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); } else { discard; }"+ + 'if (edgeFactor() < 0.5){ gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); } else { discard; }'+ //"gl_FragColor = mix(vec4(0.0, 0.0, 0.0, 1.0), vec4(0.0, 0.0, 0.0, 0.0), edgeFactor());\n"+ - "}"; + '}'; //textured wire frame tile mesh GpuShaders.tileWireframe3VertexShader = - "attribute vec3 aPosition;\n"+ - "attribute vec2 aTexCoord2;\n"+ - "attribute vec3 aBarycentric;\n"+ - "uniform mat4 uMV, uProj;\n"+ - "uniform float uFogDensity;\n"+ - "varying vec2 vTexCoord;\n"+ - "varying vec3 vBarycentric;\n"+ - "varying float vFogFactor;\n"+ - "void main() {\n"+ - "vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vFogFactor = exp(uFogDensity * camDist);\n"+ - "vTexCoord = aTexCoord2;\n"+ - "vBarycentric = aBarycentric;\n"+ - "}"; + 'attribute vec3 aPosition;\n'+ + 'attribute vec2 aTexCoord2;\n'+ + 'attribute vec3 aBarycentric;\n'+ + 'uniform mat4 uMV, uProj;\n'+ + 'uniform float uFogDensity;\n'+ + 'varying vec2 vTexCoord;\n'+ + 'varying vec3 vBarycentric;\n'+ + 'varying float vFogFactor;\n'+ + 'void main() {\n'+ + 'vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vFogFactor = exp(uFogDensity * camDist);\n'+ + 'vTexCoord = aTexCoord2;\n'+ + 'vBarycentric = aBarycentric;\n'+ + '}'; //depth encoded tile mesh GpuShaders.tileDepthVertexShader = - "attribute vec3 aPosition;\n"+ + 'attribute vec3 aPosition;\n'+ //"attribute vec2 aTexCoord;\n"+ - "uniform mat4 uMV, uProj;\n"+ + 'uniform mat4 uMV, uProj;\n'+ //"uniform float uFogDensity;\n"+ //"varying vec2 vTexCoord;\n"+ - "varying float vDepth;\n"+ - "void main() {\n"+ - "vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n"+ - "gl_Position = uProj * camSpacePos;\n"+ - "float camDist = length(camSpacePos.xyz);\n"+ - "vDepth = camDist;\n"+ + 'varying float vDepth;\n'+ + 'void main() {\n'+ + 'vec4 camSpacePos = uMV * vec4(aPosition, 1.0);\n'+ + 'gl_Position = uProj * camSpacePos;\n'+ + 'float camDist = length(camSpacePos.xyz);\n'+ + 'vDepth = camDist;\n'+ //"vTexCoord = aTexCoord;\n"+ - "}"; + '}'; -GpuShaders.tileDepthFragmentShader = "precision mediump float;\n"+ - "uniform sampler2D uSampler;\n"+ - "varying float vDepth;\n"+ - "void main() {\n"+ +GpuShaders.tileDepthFragmentShader = 'precision mediump float;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'varying float vDepth;\n'+ + 'void main() {\n'+ // "gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);\n"+ - "gl_FragColor = fract(vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) * vDepth) + (-0.5/255.0);\n"+ + 'gl_FragColor = fract(vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) * vDepth) + (-0.5/255.0);\n'+ // "gl_FragColor.w=1.0;"+ // "gl_FragColor = fract(vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) * vDepth);\n"+ - "}"; + '}'; //used for 2d iamges -GpuShaders.imageVertexShader = "\n"+ - "attribute vec4 aPosition;\n"+ - "uniform mat4 uProjectionMatrix;\n"+ - "uniform mat4 uData;\n"+ - "uniform vec4 uColor;\n"+ - "uniform float uDepth;\n"+ - "varying vec4 vColor;\n"+ - "varying vec2 vTexcoords;\n"+ - "void main(void){\n"+ - "int i=int(aPosition.x);\n"+ +GpuShaders.imageVertexShader = '\n'+ + 'attribute vec4 aPosition;\n'+ + 'uniform mat4 uProjectionMatrix;\n'+ + 'uniform mat4 uData;\n'+ + 'uniform vec4 uColor;\n'+ + 'uniform float uDepth;\n'+ + 'varying vec4 vColor;\n'+ + 'varying vec2 vTexcoords;\n'+ + 'void main(void){\n'+ + 'int i=int(aPosition.x);\n'+ //"gl_Position=uProjectionMatrix*vec4(floor(uData[i][0]+0.1),floor(uData[i][1]+0.1),0.0,1.0);\n"+ //IE11 :( - "if(i==0) gl_Position=uProjectionMatrix*vec4(floor(uData[0][0]+0.1),floor(uData[0][1]+0.1),uDepth,1.0), vTexcoords=vec2(uData[0][2], uData[0][3]);\n"+ - "if(i==1) gl_Position=uProjectionMatrix*vec4(floor(uData[1][0]+0.1),floor(uData[1][1]+0.1),uDepth,1.0), vTexcoords=vec2(uData[1][2], uData[1][3]);\n"+ - "if(i==2) gl_Position=uProjectionMatrix*vec4(floor(uData[2][0]+0.1),floor(uData[2][1]+0.1),uDepth,1.0), vTexcoords=vec2(uData[2][2], uData[2][3]);\n"+ - "if(i==3) gl_Position=uProjectionMatrix*vec4(floor(uData[3][0]+0.1),floor(uData[3][1]+0.1),uDepth,1.0), vTexcoords=vec2(uData[3][2], uData[3][3]);\n"+ + 'if(i==0) gl_Position=uProjectionMatrix*vec4(floor(uData[0][0]+0.1),floor(uData[0][1]+0.1),uDepth,1.0), vTexcoords=vec2(uData[0][2], uData[0][3]);\n'+ + 'if(i==1) gl_Position=uProjectionMatrix*vec4(floor(uData[1][0]+0.1),floor(uData[1][1]+0.1),uDepth,1.0), vTexcoords=vec2(uData[1][2], uData[1][3]);\n'+ + 'if(i==2) gl_Position=uProjectionMatrix*vec4(floor(uData[2][0]+0.1),floor(uData[2][1]+0.1),uDepth,1.0), vTexcoords=vec2(uData[2][2], uData[2][3]);\n'+ + 'if(i==3) gl_Position=uProjectionMatrix*vec4(floor(uData[3][0]+0.1),floor(uData[3][1]+0.1),uDepth,1.0), vTexcoords=vec2(uData[3][2], uData[3][3]);\n'+ - "vec4 c=uColor;\n"+ - "c.w*=1.0;\n"+ - "vColor=c;\n"+ - "}"; + 'vec4 c=uColor;\n'+ + 'c.w*=1.0;\n'+ + 'vColor=c;\n'+ + '}'; -GpuShaders.imageFragmentShader = "precision mediump float;\n"+ - "varying vec4 vColor;\n"+ - "varying vec2 vTexcoords;\n"+ - "uniform sampler2D uSampler;\n"+ - "void main(void){\n"+ - "vec4 c=texture2D(uSampler, vec2(vTexcoords.x, vTexcoords.y) );\n"+ - "c*=vColor;\n"+ +GpuShaders.imageFragmentShader = 'precision mediump float;\n'+ + 'varying vec4 vColor;\n'+ + 'varying vec2 vTexcoords;\n'+ + 'uniform sampler2D uSampler;\n'+ + 'void main(void){\n'+ + 'vec4 c=texture2D(uSampler, vec2(vTexcoords.x, vTexcoords.y) );\n'+ + 'c*=vColor;\n'+ // "gl_FragColor = vec4(1.0,0.0,1.0,1.0);\n"+ - "if(c.w < 0.01){ discard; }\n"+ - "gl_FragColor = c;\n"+ + 'if(c.w < 0.01){ discard; }\n'+ + 'gl_FragColor = c;\n'+ // "gl_FragColor = vec4(vTexcoords.x, vTexcoords.y, 0.0, 1.0);\n"+ - "}"; + '}'; export default GpuShaders; diff --git a/src/core/renderer/gpu/texture.js b/src/core/renderer/gpu/texture.js index 748c7bb5..bc95b190 100755 --- a/src/core/renderer/gpu/texture.js +++ b/src/core/renderer/gpu/texture.js @@ -14,7 +14,7 @@ var GpuTexture = function(gpu, path, core, fileSize, direct, repeat, filter) { this.width = 0; this.height = 0; this.repeat = repeat || false; - this.filter = filter || "linear"; + this.filter = filter || 'linear'; this.image = null; this.loaded = false; @@ -63,19 +63,19 @@ GpuTexture.prototype.createFromData = function(lx, ly, data, filter, repeat) { var mipmaps = false; switch (filter) { - case "linear": - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - break; - case "trilinear": - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - mipmaps = true; - break; - default: - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - break; + case 'linear': + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + break; + case 'trilinear': + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + mipmaps = true; + break; + default: + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + break; } gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); @@ -116,19 +116,19 @@ GpuTexture.prototype.createFromImage = function(image, filter, repeat) { this.filter = filter; switch (filter) { - case "linear": - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - break; - case "trilinear": - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - mipmaps = true; - break; - default: - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - break; + case 'linear': + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + break; + case 'trilinear': + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + mipmaps = true; + break; + default: + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + break; } //gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); diff --git a/src/core/renderer/init.js b/src/core/renderer/init.js index 065ccc5e..a9d4a3d6 100755 --- a/src/core/renderer/init.js +++ b/src/core/renderer/init.js @@ -101,22 +101,22 @@ RendererInit.prototype.initHeightmap = function() { var index =(i*size+j)*4; if (i < halfLineWidth || i >= size-halfLineWidth || j < halfLineWidth || j >= size-halfLineWidth) { - data[index] = 255; - data[index + 1] = 255; - data[index + 2] = 255; - } else { - data[index] = 32; - data[index + 1] = 32; - data[index + 2] = 32; - } + data[index] = 255; + data[index + 1] = 255; + data[index + 2] = 255; + } else { + data[index] = 32; + data[index + 1] = 32; + data[index + 2] = 32; + } - data[index + 3] = 255; + data[index + 3] = 255; } } renderer.heightmapTexture = new GpuTexture(gpu); - renderer.heightmapTexture.createFromData(size, size, data, "trilinear", true); + renderer.heightmapTexture.createFromData(size, size, data, 'trilinear', true); }; @@ -148,10 +148,10 @@ RendererInit.prototype.initTestMap = function() { var index = (i*size+j)*4; - data[index] = 255; - data[index + 1] = 0; - data[index + 2] = 0; - data[index + 3] = 255; + data[index] = 255; + data[index + 1] = 0; + data[index + 2] = 0; + data[index + 3] = 255; } } @@ -163,10 +163,10 @@ RendererInit.prototype.initTestMap = function() { for (var i = 0; i < size; i++) { for (var j = 0; j < size; j++) { var index = (i*size+j)*4; - data[index] = 255; - data[index + 1] = 255; - data[index + 2] = 255; - data[index + 3] = 255; + data[index] = 255; + data[index + 1] = 255; + data[index + 2] = 255; + data[index + 3] = 255; } } @@ -178,10 +178,10 @@ RendererInit.prototype.initTestMap = function() { for (var i = 0; i < size; i++) { for (var j = 0; j < size; j++) { var index = (i*size+j)*4; - data[index] = 0; - data[index + 1] = 0; - data[index + 2] = 0; - data[index + 3] = 255; + data[index] = 0; + data[index + 1] = 0; + data[index + 2] = 0; + data[index + 3] = 255; } } @@ -193,13 +193,13 @@ RendererInit.prototype.initTestMap = function() { var data = new Uint8Array( sizeX * sizeY * 4 ); var chars = [ - "............................................................", - ".....xxxxx.......................xxxxx......................", - ".....xxxxx.......................xxxxx......................", - ".....xxxxx.......................xxxxx......................", - "xxxxxxxxxxxxxxxx............xxxxxxxxxxxxxxxx................", - "xxxxxxxxxxxxxxxx............xxxxxxxxxxxxxxxx................", - "............................................................" + '............................................................', + '.....xxxxx.......................xxxxx......................', + '.....xxxxx.......................xxxxx......................', + '.....xxxxx.......................xxxxx......................', + 'xxxxxxxxxxxxxxxx............xxxxxxxxxxxxxxxx................', + 'xxxxxxxxxxxxxxxx............xxxxxxxxxxxxxxxx................', + '............................................................' ]; @@ -212,10 +212,10 @@ RendererInit.prototype.initTestMap = function() { var index = (i*sizeX+j)*4; - data[index] = 0; - data[index + 1] = 0; - data[index + 2] = 0; - data[index + 3] = 0;//255; + data[index] = 0; + data[index + 1] = 0; + data[index + 2] = 0; + data[index + 3] = 0;//255; } } @@ -228,16 +228,16 @@ RendererInit.prototype.initTestMap = function() { var index = (i*sizeX+j)*4; if (string.charAt(j) != '.') { - data[index] = 255; - data[index + 1] = 255; - data[index + 2] = 255; - data[index + 3] = 255; + data[index] = 255; + data[index + 1] = 255; + data[index + 2] = 255; + data[index + 3] = 255; } } } renderer.lineTexture = new GpuTexture(gpu); - renderer.lineTexture.createFromData(sizeX, sizeY, data, "linear", true); + renderer.lineTexture.createFromData(sizeX, sizeY, data, 'linear', true); }; @@ -247,7 +247,7 @@ RendererInit.prototype.initTextMap = function() { 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="; + 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='; renderer.textTexture2 = new GpuTexture(this.gpu, texture, this.core, null, true); // create red texture @@ -278,7 +278,7 @@ RendererInit.prototype.initImage = function() { gl.bindBuffer(gl.ARRAY_BUFFER, renderer.rectVerticesBuffer); var vertices = [ 0, 0, 0, 1, 1, 0, 0, 1, - 2, 0, 0, 1, 3, 0, 0, 1 ]; + 2, 0, 0, 1, 3, 0, 0, 1 ]; gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); renderer.rectVerticesBuffer.itemSize = 4; diff --git a/src/core/renderer/interface.js b/src/core/renderer/interface.js index 4c3c804b..a52b2236 100755 --- a/src/core/renderer/interface.js +++ b/src/core/renderer/interface.js @@ -17,28 +17,28 @@ var RendererInterface = function(renderer) { RendererInterface.prototype.clear = function(options) { if (options != null) { - this.gpu.clear((options["clearDepth"] || true), - (options["clearColor"] || false), - (options["color"] || [255,255,255,255]), - ((options["depth"] != null) ? options["depth"] : 1.0) ); + this.gpu.clear((options['clearDepth'] || true), + (options['clearColor'] || false), + (options['color'] || [255,255,255,255]), + ((options['depth'] != null) ? options['depth'] : 1.0) ); } return this; }; RendererInterface.prototype.createState = function(options) { - if (options == null || typeof options !== "object") { + if (options == null || typeof options !== 'object') { return this; } var stateOptions = { - blend : (options["blend"] != null) ? options["blend"] : false, - stencil : (options["stencil"] != null) ? options["stencil"] : false, - zoffset : (options["zoffset"] != null) ? options["zoffset"] : 0, - zwrite : (options["zwrite"] != null) ? options["zwrite"] : true, - ztest : (options["ztest"] != null) ? options["ztest"] : true, - zequal : (options["zequal"] != null) ? options["zequal"] : true, - culling : (options["culling"] != null) ? options["culling"] : true + blend : (options['blend'] != null) ? options['blend'] : false, + stencil : (options['stencil'] != null) ? options['stencil'] : false, + zoffset : (options['zoffset'] != null) ? options['zoffset'] : 0, + zwrite : (options['zwrite'] != null) ? options['zwrite'] : true, + ztest : (options['ztest'] != null) ? options['ztest'] : true, + zequal : (options['zequal'] != null) ? options['zequal'] : true, + culling : (options['culling'] != null) ? options['culling'] : true }; return this.gpu.createState(stateOptions); @@ -54,21 +54,21 @@ RendererInterface.prototype.setState = function(state) { RendererInterface.prototype.createTexture = function(options) { - if (options == null || typeof options !== "object") { + if (options == null || typeof options !== 'object') { return null; } - var source = options["source"]; + var source = options['source']; if (source == null) { return null; } - var filter = options["filter"] || "linear"; - var repeat = options["repeat"] || false; + var filter = options['filter'] || 'linear'; + var repeat = options['repeat'] || false; if (source instanceof Uint8Array) { - var width = options["width"]; - var height = options["height"]; + var width = options['width']; + var height = options['height']; if (width && height) { var texture = new GpuTexture(this.gpu); @@ -96,21 +96,21 @@ RendererInterface.prototype.removeTexture = function(texture) { RendererInterface.prototype.createMesh = function(options) { - if (options == null || typeof options !== "object") { + if (options == null || typeof options !== 'object') { return null; } var data = { - vertices : options["vertices"], - uvs : options["uvs"], - uvs2 : options["normals"], - vertexSize : options["vertexSize"], - uvSize : options["uvSize"], - uv2Size : options["normalSize"] || 3, - vertexAttr : options["vertexAttr"], - uvAttr : options["uvAttr"], - uv2Attr : options["normalAttr"], - bbox : options["bbox"] + vertices : options['vertices'], + uvs : options['uvs'], + uvs2 : options['normals'], + vertexSize : options['vertexSize'], + uvSize : options['uvSize'], + uv2Size : options['normalSize'] || 3, + vertexAttr : options['vertexAttr'], + uvAttr : options['uvAttr'], + uv2Attr : options['normalAttr'], + bbox : options['bbox'] }; return new GpuMesh(this.gpu, data, 0, this.renderer.core); @@ -126,12 +126,12 @@ RendererInterface.prototype.removeMesh = function(mesh) { RendererInterface.prototype.createShader = function(options) { - if (options == null || typeof options !== "object") { + if (options == null || typeof options !== 'object') { return null; } - var vertexShader = options["vertexShader"]; - var fragmentShader = options["fragmentShader"]; + var vertexShader = options['vertexShader']; + var fragmentShader = options['fragmentShader']; if (vertexShader != null && fragmentShader) { return new GpuProgram(this.gpu, vertexShader, fragmentShader); @@ -158,69 +158,69 @@ RendererInterface.prototype.clearJobs = function(options) { RendererInterface.prototype.drawMesh = function(options) { - if (options == null || typeof options !== "object") { + if (options == null || typeof options !== 'object') { return this; } - if (!options["mesh"] == null || !options["shaderVariables"]) { + if (!options['mesh'] == null || !options['shaderVariables']) { return this; } - var shaderAttributes = options["shaderAttributes"]; - var vertexAttr = options["vertex"] || "aPosition"; - var uvAttr = options["uv"] || "aTexCoord"; - var uv2Attr = options["normal"] || "aNormal"; + var shaderAttributes = options['shaderAttributes']; + var vertexAttr = options['vertex'] || 'aPosition'; + var uvAttr = options['uv'] || 'aTexCoord'; + var uv2Attr = options['normal'] || 'aNormal'; - var shaderVariables = options["shaderVariables"]; - var shader = options["shader"] || "textured"; + var shaderVariables = options['shaderVariables']; + var shader = options['shader'] || 'textured'; var renderer = this.renderer; - var mesh = options["mesh"]; - var texture = options["texture"]; + var mesh = options['mesh']; + var texture = options['texture']; var mv = renderer.camera.getModelviewMatrix(); var proj = renderer.camera.getProjectionMatrix(); var fogDensity = renderer.fogDensity; - if (typeof shader === "string") { + if (typeof shader === 'string') { switch(shader) { - case "hit": + case 'hit': - if (!shaderVariables["uMV"]) { - shaderVariables["uMV"] = ["mat4", mv]; - } + if (!shaderVariables['uMV']) { + shaderVariables['uMV'] = ['mat4', mv]; + } - if (!shaderVariables["uProj"]) { - shaderVariables["uProj"] = ["mat4", proj]; - } + if (!shaderVariables['uProj']) { + shaderVariables['uProj'] = ['mat4', proj]; + } - uvAttr = null; - uv2Attr = null; - texture = null; - shader = renderer.progDepthTile;; - break; + uvAttr = null; + uv2Attr = null; + texture = null; + shader = renderer.progDepthTile; + break; - case "shaded": - uvAttr = null; + case 'shaded': + uvAttr = null; - case "textured": - case "textured-and-shaded": + case 'textured': + case 'textured-and-shaded': - if (!shaderVariables["uMV"]) { - shaderVariables["uMV"] = ["mat4", mv]; - } + if (!shaderVariables['uMV']) { + shaderVariables['uMV'] = ['mat4', mv]; + } - if (!shaderVariables["uProj"]) { - shaderVariables["uProj"] = ["mat4", proj]; - } + if (!shaderVariables['uProj']) { + shaderVariables['uProj'] = ['mat4', proj]; + } - if (!shaderVariables["uFogDensity"]) { - shaderVariables["uFogDensity"] = ["float", fogDensity]; - } + if (!shaderVariables['uFogDensity']) { + shaderVariables['uFogDensity'] = ['float', fogDensity]; + } - uv2Attr = (shader == "textured") ? null : "aNormal"; - shader = (shader == "textured") ? renderer.progTile : ((shader == "shaded") ? renderer.progShadedTile : renderer.progTShadedTile); - break; + uv2Attr = (shader == 'textured') ? null : 'aNormal'; + shader = (shader == 'textured') ? renderer.progTile : ((shader == 'shaded') ? renderer.progShadedTile : renderer.progTShadedTile); + break; } } @@ -239,30 +239,30 @@ RendererInterface.prototype.drawMesh = function(options) { if (item.length == 2) { switch(item[0]){ - case "floatArray": - shader.setFloatArray(key, item[1]); - break; - case "float": - shader.setFloat(key, item[1]); - break; - case "mat3": - shader.setMat3(key, item[1]); - break; - case "mat4": - shader.setMat4(key, item[1]); - break; - case "vec2": - shader.setVec2(key, item[1]); - break; - case "vec3": - shader.setVec3(key, item[1]); - break; - case "vec4": - shader.setVec4(key, item[1]); - break; - case "sampler": - shader.setSampler(key, item[1]); - break; + case 'floatArray': + shader.setFloatArray(key, item[1]); + break; + case 'float': + shader.setFloat(key, item[1]); + break; + case 'mat3': + shader.setMat3(key, item[1]); + break; + case 'mat4': + shader.setMat4(key, item[1]); + break; + case 'vec2': + shader.setVec2(key, item[1]); + break; + case 'vec3': + shader.setVec3(key, item[1]); + break; + case 'vec4': + shader.setVec4(key, item[1]); + break; + case 'sampler': + shader.setSampler(key, item[1]); + break; } } } @@ -278,72 +278,72 @@ RendererInterface.prototype.drawMesh = function(options) { RendererInterface.prototype.drawImage = function(options) { - if (options == null || typeof options !== "object") { + if (options == null || typeof options !== 'object') { return this; } - if (options["texture"] == null || options["rect"] == null) { + if (options['texture'] == null || options['rect'] == null) { return this; } - var rect = options["rect"]; - var color = options["color"] || [255,255,255,255]; - var depth = (options["depth"] != null) ? options["depth"] : 0; - var depthTest = (options["depthTest"] != null) ? options["depthTest"] : false; - var blend = (options["blend"] != null) ? options["blend"] : false; - var writeDepth = (options["writeDepth"] != null) ? options["writeDepth"] : false; - var useState = (options["useState"] != null) ? options["useState"] : false; + var rect = options['rect']; + var color = options['color'] || [255,255,255,255]; + var depth = (options['depth'] != null) ? options['depth'] : 0; + var depthTest = (options['depthTest'] != null) ? options['depthTest'] : false; + var blend = (options['blend'] != null) ? options['blend'] : false; + var writeDepth = (options['writeDepth'] != null) ? options['writeDepth'] : false; + var useState = (options['useState'] != null) ? options['useState'] : false; color[0] *= 1.0/255; color[1] *= 1.0/255; color[2] *= 1.0/255; color[3] *= 1.0/255; - this.renderer.draw.drawImage(rect[0], rect[1], rect[2], rect[3], options["texture"], color, depth, depthTest, blend, writeDepth, useState); + this.renderer.draw.drawImage(rect[0], rect[1], rect[2], rect[3], options['texture'], color, depth, depthTest, blend, writeDepth, useState); return this; }; RendererInterface.prototype.drawBillboard = function(options) { - if (options == null || typeof options !== "object") { + if (options == null || typeof options !== 'object') { return this; } - if (options["texture"] == null || options["mvp"] == null) { + if (options['texture'] == null || options['mvp'] == null) { return this; } - var mvp = options["mvp"]; - var color = options["color"] || [255,255,255,255]; - var depthTest = (options["depthTest"] != null) ? options["depthTest"] : false; - var blend = (options["blend"] != null) ? options["blend"] : false; - var writeDepth = (options["writeDepth"] != null) ? options["writeDepth"] : false; - var useState = (options["useState"] != null) ? options["useState"] : false; + var mvp = options['mvp']; + var color = options['color'] || [255,255,255,255]; + var depthTest = (options['depthTest'] != null) ? options['depthTest'] : false; + var blend = (options['blend'] != null) ? options['blend'] : false; + var writeDepth = (options['writeDepth'] != null) ? options['writeDepth'] : false; + var useState = (options['useState'] != null) ? options['useState'] : false; color[0] *= 1.0/255; color[1] *= 1.0/255; color[2] *= 1.0/255; color[3] *= 1.0/255; - this.renderer.draw.drawBillboard(mvp, options["texture"], color, depthTest, blend, writeDepth, useState); + this.renderer.draw.drawBillboard(mvp, options['texture'], color, depthTest, blend, writeDepth, useState); return this; }; RendererInterface.prototype.drawLineString = function(options) { - if (options == null || typeof options !== "object") { + if (options == null || typeof options !== 'object') { return this; } - if (options["points"] == null) { + if (options['points'] == null) { return this; } - var points = options["points"]; - var color = options["color"] || [255,255,255,255]; - var size = options["size"] || 2; - var depthTest = (options["depthTest"] != null) ? options["depthTest"] : false; - var blend = (options["blend"] != null) ? options["blend"] : false; - var writeDepth = (options["writeDepth"] != null) ? options["writeDepth"] : false; - var useState = (options["useState"] != null) ? options["useState"] : false; + var points = options['points']; + var color = options['color'] || [255,255,255,255]; + var size = options['size'] || 2; + var depthTest = (options['depthTest'] != null) ? options['depthTest'] : false; + var blend = (options['blend'] != null) ? options['blend'] : false; + var writeDepth = (options['writeDepth'] != null) ? options['writeDepth'] : false; + var useState = (options['useState'] != null) ? options['useState'] : false; color[0] *= 1.0/255; color[1] *= 1.0/255; color[2] *= 1.0/255; @@ -365,21 +365,21 @@ RendererInterface.prototype.drawBBox = function(options) { RendererInterface.prototype.drawDebugText = function(options) { - if (options == null || typeof options !== "object") { + if (options == null || typeof options !== 'object') { return this; } - var text = options["text"]; - var coords = options["coords"]; + var text = options['text']; + var coords = options['coords']; if (!text || !coords) { return this; } - var color = options["color"] || [255,255,255,255]; - var size = options["size"] || 16; - var depth = options["depth"]; - var useState = options["useState"] || false; + var color = options['color'] || [255,255,255,255]; + var size = options['size'] || 16; + var depth = options['depth']; + var useState = options['useState'] || false; color[0] *= 1.0/255; color[1] *= 1.0/255; color[2] *= 1.0/255; diff --git a/src/core/renderer/renderer.js b/src/core/renderer/renderer.js index 5667129c..d5ac081b 100755 --- a/src/core/renderer/renderer.js +++ b/src/core/renderer/renderer.js @@ -116,7 +116,7 @@ var Renderer = function(core, div, onUpdate, onResize, config) { this.lastHitPosition = [0,0,100]; this.logTilePos = null; - window.addEventListener("resize", (this.onResize).bind(this), false); + window.addEventListener('resize', (this.onResize).bind(this), false); this.gpu.init(); @@ -352,81 +352,81 @@ Renderer.prototype.switchToFramebuffer = function(type) { var gl = this.gpu.gl; switch(type) { - case "base": - var width = this.oldSize[0]; - var height = this.oldSize[1]; + case 'base': + var width = this.oldSize[0]; + var height = this.oldSize[1]; - gl.clearColor(0.0, 0.0, 0.0, 1.0); + gl.clearColor(0.0, 0.0, 0.0, 1.0); - this.gpu.setFramebuffer(null); + this.gpu.setFramebuffer(null); - this.camera.setAspect(width / height); - this.curSize = [width, height]; - this.gpu.resize(this.curSize, true); - this.camera.update(); + this.camera.setAspect(width / height); + this.curSize = [width, height]; + this.gpu.resize(this.curSize, true); + this.camera.update(); //this.updateCamera(); - this.onlyDepth = false; - this.onlyHitLayers = false; - break; + this.onlyDepth = false; + this.onlyHitLayers = false; + break; - case "depth": + case 'depth': //set texture framebuffer - this.gpu.setFramebuffer(this.hitmapTexture); + this.gpu.setFramebuffer(this.hitmapTexture); - this.oldSize = [ this.curSize[0], this.curSize[1] ]; + this.oldSize = [ this.curSize[0], this.curSize[1] ]; - gl.clearColor(1.0,1.0, 1.0, 1.0); - gl.enable(gl.DEPTH_TEST); + gl.clearColor(1.0,1.0, 1.0, 1.0); + gl.enable(gl.DEPTH_TEST); - var size = this.hitmapSize; + var size = this.hitmapSize; //clear screen - gl.viewport(0, 0, size, size); - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + gl.viewport(0, 0, size, size); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - this.curSize = [size, size]; + this.curSize = [size, size]; //this.gpu.resize(this.curSize, true); //var width = this.oldSize[0]; //var height = this.oldSize[1]; //this.camera.setAspect(width / height); - this.gpu.clear(); + this.gpu.clear(); //this.camera.setAspect(2.5); - this.camera.update(); - this.onlyDepth = true; - this.onlyHitLayers = false; - break; + this.camera.update(); + this.onlyDepth = true; + this.onlyHitLayers = false; + break; - case "geo": + case 'geo': - this.hoverFeatureCounter = 0; + this.hoverFeatureCounter = 0; - var size = this.hitmapSize; + var size = this.hitmapSize; //set texture framebuffer - this.gpu.setFramebuffer(this.geoHitmapTexture); + 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; + var width = size; + var height = size; - gl.clearColor(1.0,1.0, 1.0, 1.0); - gl.enable(gl.DEPTH_TEST); + gl.clearColor(1.0,1.0, 1.0, 1.0); + gl.enable(gl.DEPTH_TEST); //clear screen - gl.viewport(0, 0, size, size); - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + gl.viewport(0, 0, size, size); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - this.curSize = [width, height]; + this.curSize = [width, height]; //render scene - this.onlyHitLayers = true; + this.onlyHitLayers = true; - this.gpu.clear(); - this.camera.update(); - break; + this.gpu.clear(); + this.camera.update(); + break; } }; @@ -527,14 +527,14 @@ Renderer.prototype.saveScreenshot = function(output, filename, filetype) { imageData.data.set(data); context.putImageData(imageData, 0, 0); - filetype = filetype || "jpg"; + filetype = filetype || 'jpg'; //open image in new window - if (output == "file") { - var a = document.createElement("a"); + if (output == 'file') { + var a = document.createElement('a'); - var dataURI= canvas.toDataURL("image/" + filetype); + var dataURI= canvas.toDataURL('image/' + filetype); var byteString = atob(dataURI.split(',')[1]); // separate out the mime component @@ -558,8 +558,8 @@ Renderer.prototype.saveScreenshot = function(output, filename, filetype) { document.body.removeChild(a); window.URL.revokeObjectURL(url); }, 0); - } if (output == "tab") { - window.open(canvas.toDataURL("image/" + type)); + } if (output == 'tab') { + window.open(canvas.toDataURL('image/' + type)); } return imageData; @@ -567,7 +567,7 @@ Renderer.prototype.saveScreenshot = function(output, filename, filetype) { Renderer.prototype.getBitmap = function(url, filter, tiled) { - var id = url + "*" + filter + "*" + tiled; + var id = url + '*' + filter + '*' + tiled; var texture = this.bitmaps[id]; if (texture == null) { diff --git a/src/core/utils/math.js b/src/core/utils/math.js index c30f079b..f53da4a1 100755 --- a/src/core/utils/math.js +++ b/src/core/utils/math.js @@ -85,21 +85,21 @@ math.rotationMatrix = function(axis, angle) { 0, ca,-sa, 0, 0, sa, ca, 0, 0, 0, 0, 1 ]; - break; + break; case 1: m = [ ca, 0,-sa, 0, - 0, 1, 0, 0, + 0, 1, 0, 0, sa, 0, ca, 0, - 0, 0, 0, 1 ]; - break; + 0, 0, 0, 1 ]; + break; default: m = [ ca,-sa, 0, 0, sa, ca, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]; - break; + break; } mat4.transpose(m); @@ -110,9 +110,9 @@ math.rotationMatrix = function(axis, angle) { math.scaleMatrix = function(sx, sy, sz) { var m = [ sx, 0, 0, 0, - 0, sy, 0, 0, - 0, 0, sz, 0, - 0, 0, 0, 1 ]; + 0, sy, 0, 0, + 0, 0, sz, 0, + 0, 0, 0, 1 ]; mat4.transpose(m); return m; diff --git a/src/core/utils/matrix.js b/src/core/utils/matrix.js index a9a513fc..fb0ed4d6 100755 --- a/src/core/utils/matrix.js +++ b/src/core/utils/matrix.js @@ -297,7 +297,7 @@ vec3.lerp = function (a, b, c, d) { vec3.str = function (a) { - return "[" + a[0] + ", " + a[1] + ", " + a[2] + "]"; + return '[' + a[0] + ', ' + a[1] + ', ' + a[2] + ']'; }; @@ -399,7 +399,7 @@ mat3.toMat4 = function (a, b) { mat3.str = function (a) { - return "[" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + "]"; + return '[' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ']'; }; @@ -1098,7 +1098,7 @@ mat4.lookAt = function (a, b, c, d) { mat4.str = function (a) { - return "[" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ", " + a[9] + ", " + a[10] + ", " + a[11] + ", " + a[12] + ", " + a[13] + ", " + a[14] + ", " + a[15] + "]"; + return '[' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' + a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ']'; }; @@ -1309,7 +1309,7 @@ quat4.slerp = function (a, b, c, d) { quat4.str = function (a) { - return "[" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + "]"; + return '[' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ']'; }; export {vec2, vec3, vec4, mat3, mat4}; diff --git a/src/core/utils/platform.js b/src/core/utils/platform.js index ff26f713..1180971b 100755 --- a/src/core/utils/platform.js +++ b/src/core/utils/platform.js @@ -7,12 +7,12 @@ var platform = { var self = platform; - self.browser = self.searchString(self.dataBrowser) || "An unknown browser"; - self.version = self.searchVersion(navigator.userAgent.toLowerCase()) || self.searchVersion(navigator.appVersion) || "an unknown version"; - self.OS = self.searchString(self.dataOS) || "an unknown os: ua: " + navigator.userAgent + " pl: " + navigator.platform; + self.browser = self.searchString(self.dataBrowser) || 'An unknown browser'; + self.version = self.searchVersion(navigator.userAgent.toLowerCase()) || self.searchVersion(navigator.appVersion) || 'an unknown version'; + self.OS = self.searchString(self.dataOS) || 'an unknown os: ua: ' + navigator.userAgent + ' pl: ' + navigator.platform; - self.mobile = (self.OS == "iphone/ipod" || self.OS == "android" || self.OS == "ipad" || self.OS == "windows ce" || self.OS == "windows phone" || self.OS == "kindle"); - self.mobileAndroid = (self.OS == "android"); + self.mobile = (self.OS == 'iphone/ipod' || self.OS == 'android' || self.OS == 'ipad' || self.OS == 'windows ce' || self.OS == 'windows phone' || self.OS == 'kindle'); + self.mobileAndroid = (self.OS == 'android'); self.initialized = true; }, @@ -74,142 +74,142 @@ var platform = { dataBrowser: [ { string: navigator.userAgent, - subString: "chrome", - identity: "chrome" + subString: 'chrome', + identity: 'chrome' }, { string: navigator.userAgent, - subString: "firefox", - identity: "firefox" + subString: 'firefox', + identity: 'firefox' }, { string: navigator.vendor, - subString: "apple", - identity: "safari", - versionSearch: "version" + subString: 'apple', + identity: 'safari', + versionSearch: 'version' }, { prop: window.opera, - identity: "opera", - versionSearch: "version" + identity: 'opera', + versionSearch: 'version' }, { string: navigator.vendor, - subString: "icab", - identity: "icab" + subString: 'icab', + identity: 'icab' }, { string: navigator.vendor, - subString: "kde", - identity: "konqueror" + subString: 'kde', + identity: 'konqueror' }, { string: navigator.vendor, - subString: "camino", - identity: "camino" + subString: 'camino', + identity: 'camino' }, { // for newer Netscapes (6+) string: navigator.userAgent, - subString: "netscape", - identity: "netscape" + subString: 'netscape', + identity: 'netscape' }, { string: navigator.userAgent, - subString: "msie", - identity: "explorer", - versionSearch: "msie" + subString: 'msie', + identity: 'explorer', + versionSearch: 'msie' }, { string: navigator.userAgent, - subString: "trident/", - identity: "explorer", - version: "11" + subString: 'trident/', + identity: 'explorer', + version: '11' }, { string: navigator.userAgent, - subString: "edge/", - identity: "explorer", - version: "12" + subString: 'edge/', + identity: 'explorer', + version: '12' }, { string: navigator.userAgent, - subString: "omniweb", - versionSearch: "omniweb/", - identity: "omniweb" + subString: 'omniweb', + versionSearch: 'omniweb/', + identity: 'omniweb' }, { string: navigator.userAgent, - subString: "silk", - versionSearch: "silk/", - identity: "silk" + subString: 'silk', + versionSearch: 'silk/', + identity: 'silk' }, { string: navigator.userAgent, - subString: "gecko", - identity: "mozilla", - versionSearch: "rv" + subString: 'gecko', + identity: 'mozilla', + versionSearch: 'rv' }, { // for older Netscapes (4-) string: navigator.userAgent, - subString: "mozilla", - identity: "netscape", - versionSearch: "mozilla" + subString: 'mozilla', + identity: 'netscape', + versionSearch: 'mozilla' } ], dataOS : [ { - string: navigator.userAgent, - subString: "windows ce", - identity: "windows ce" + string: navigator.userAgent, + subString: 'windows ce', + identity: 'windows ce' }, { - string: navigator.userAgent, - subString: "windows phone", - identity: "windows phone" + string: navigator.userAgent, + subString: 'windows phone', + identity: 'windows phone' }, { string: navigator.platform, - subString: "win", - identity: "windows" + subString: 'win', + identity: 'windows' }, { string: navigator.platform, - subString: "mac", - identity: "mac" + subString: 'mac', + identity: 'mac' }, { - string: navigator.userAgent, - subString: "iphone", - identity: "iphone/ipod" + string: navigator.userAgent, + subString: 'iphone', + identity: 'iphone/ipod' }, { - string: navigator.userAgent, - subString: "ipod", - identity: "iphone/ipod" + string: navigator.userAgent, + subString: 'ipod', + identity: 'iphone/ipod' }, { - string: navigator.userAgent, - subString: "ipad", - identity: "ipad" + string: navigator.userAgent, + subString: 'ipad', + identity: 'ipad' }, { - string: navigator.userAgent, - subString: "android", - identity: "android" + string: navigator.userAgent, + subString: 'android', + identity: 'android' }, { - string: navigator.userAgent, - subString: "silk", - identity: "kindle" + string: navigator.userAgent, + subString: 'silk', + identity: 'kindle' }, { - string: navigator.userAgent, - subString: "blackberry", - identity: "blackberry" + string: navigator.userAgent, + subString: 'blackberry', + identity: 'blackberry' }, { string: navigator.platform, - subString: "linux", - identity: "linux" + subString: 'linux', + identity: 'linux' } ] diff --git a/src/core/utils/url.js b/src/core/utils/url.js index b6ba373e..e1f1f4e8 100644 --- a/src/core/utils/url.js +++ b/src/core/utils/url.js @@ -27,13 +27,13 @@ utilsUrl.getParamsFromUrl = function(url) { var parser = utilsUrl.parse(url); var queryString = {}; var query = parser['search'].substring(1); - var vars = query.split("&"); - if (!(vars.length == 1 && vars[0] == "")) { + var vars = query.split('&'); + if (!(vars.length == 1 && vars[0] == '')) { for (var i=0; i < vars.length; i++) { - var pair = vars[i].split("="); - if (typeof queryString[pair[0]] === "undefined") { + var pair = vars[i].split('='); + if (typeof queryString[pair[0]] === 'undefined') { queryString[pair[0]] = pair[1]; - } else if (typeof queryString[pair[0]] === "string") { + } else if (typeof queryString[pair[0]] === 'string') { var arr = [ queryString[pair[0]], pair[1] ]; queryString[pair[0]] = arr; } else { @@ -46,7 +46,7 @@ utilsUrl.getParamsFromUrl = function(url) { utilsUrl.getHost = function(url) { - var location = document.createElement("a"); + var location = document.createElement('a'); location.href = url; return location.hostname; }; @@ -54,12 +54,12 @@ utilsUrl.getHost = function(url) { utilsUrl.getSchema = function(url) { //if (window.location.href.indexOf("file://") != -1) { - if (url.indexOf("http://") != -1) { - return "http:"; - } else if (url.indexOf("https://") != -1) { - return "https:"; + if (url.indexOf('http://') != -1) { + return 'http:'; + } else if (url.indexOf('https://') != -1) { + return 'https:'; } else { - var location = document.createElement("a"); + var location = document.createElement('a'); location.href = url; return location.protocol; } @@ -67,7 +67,7 @@ utilsUrl.getSchema = function(url) { utilsUrl.getOrigin = function(url) { - var location = document.createElement("a"); + var location = document.createElement('a'); location.href = url; return location.origin; }; @@ -89,11 +89,11 @@ utilsUrl.getProcessUrl = function(url, originUrl) { var baseUrlSchema = utilsUrl.getSchema(originUrl); var baseUrlOrigin = utilsUrl.getOrigin(originUrl); - if (url.indexOf("://") != -1) { //absolute + if (url.indexOf('://') != -1) { //absolute return url; - } else if (url.indexOf("//") == 0) { //absolute without schema + } else if (url.indexOf('//') == 0) { //absolute without schema return baseUrlSchema + url; - } else if (url.indexOf("/") == 0) { //absolute without host + } else if (url.indexOf('/') == 0) { //absolute without host return baseUrlOrigin + url; } else { //relative return baseUrl + url; diff --git a/src/core/utils/utils.js b/src/core/utils/utils.js index b52258a1..2a1933fa 100755 --- a/src/core/utils/utils.js +++ b/src/core/utils/utils.js @@ -7,13 +7,13 @@ var math = math_; var utilsUrl = utilsUrl_; -var utils = {} +var utils = {}; utils.useCredentials = false; utils.instanceCounter = 0; utils.validateBool = function(value, defaultValue) { - if (typeof value === "boolean") { + if (typeof value === 'boolean') { return value; } else { return defaultValue; @@ -22,7 +22,7 @@ utils.validateBool = function(value, defaultValue) { utils.validateNumber = function(value, minValue, maxValue, defaultValue) { - if (typeof value === "number") { + if (typeof value === 'number') { return math.clamp(value, minValue, maxValue); } else { return defaultValue; @@ -43,7 +43,7 @@ utils.validateNumberArray = function(array, arraySize, minValues, maxValues, def utils.validateString = function(value, defaultValue) { - if (typeof value === "string") { + if (typeof value === 'string') { return value; } else { return defaultValue; @@ -52,16 +52,16 @@ utils.validateString = function(value, defaultValue) { utils.padNumber = function(n, width) { - var z = '0'; - - if (n < 0) { - n = (-n) + ''; - width--; //7 - return n.length >= width ? ("-" + n) : "-" + (new Array(width - n.length + 1).join(z) + n); - } else { - n = n + ''; - return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; - } + var z = '0'; + + if (n < 0) { + n = (-n) + ''; + width--; //7 + return n.length >= width ? ('-' + n) : '-' + (new Array(width - n.length + 1).join(z) + n); + } else { + n = n + ''; + return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; + } }; @@ -81,8 +81,8 @@ utils.decodeFloat16 = function(binary) { utils.simpleFmtObj = (function obj(str, obj) { - if (!str || str == "") { - return ""; + if (!str || str == '') { + return ''; } return str.replace(/\{([$a-zA-Z0-9][$a-zA-Z0-9]*)\}/g, function(s, match) { @@ -92,28 +92,28 @@ utils.simpleFmtObj = (function obj(str, obj) { utils.simpleWikiLinks = (function obj(str, plain) { - if (!str || str == "") { - return ""; + if (!str || str == '') { + return ''; } - var str2 = utils.simpleFmtObj(str, {"copy":"©", "Y": (new Date().getFullYear())}); + var str2 = utils.simpleFmtObj(str, {'copy':'©', 'Y': (new Date().getFullYear())}); return str2.replace(/\[([^\]]*)\]/g, function(s, match) { match = match.trim(); - var urls = match.split(" ");//, 1); + var urls = match.split(' ');//, 1); - if (urls[0].indexOf("//") != -1) { + if (urls[0].indexOf('//') != -1) { if (plain) { if (urls.length > 1) { - return "" + match.substring(urls[0].length); + return '' + match.substring(urls[0].length); } else { - return "" + urls[0]; + return '' + urls[0]; } } else { if (urls.length > 1) { - return "" + match.substring(urls[0].length)+""; + return '' + match.substring(urls[0].length)+''; } else { - return "" + urls[0]+""; + return '' + urls[0]+''; } } } @@ -124,8 +124,8 @@ utils.simpleWikiLinks = (function obj(str, plain) { utils.simpleFmtObjOrCall = (function obj(str, obj, call) { - if (!str || str == "") { - return ""; + if (!str || str == '') { + return ''; } return str.replace(/\{([$a-zA-Z(-9][$a-zA-Z(-9]*)\}/g, function(s, match) { @@ -138,10 +138,10 @@ utils.getABGRFromHexaCode = (function(code) { var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(code); return result ? - [ parseInt(result[4], 16), - parseInt(result[3], 16), - parseInt(result[2], 16), - parseInt(result[1], 16)] + [ parseInt(result[4], 16), + parseInt(result[3], 16), + parseInt(result[2], 16), + parseInt(result[1], 16)] : [0,0,0,255]; }); @@ -159,43 +159,43 @@ utils.loadJSON = function(path, onLoaded, onError, skipParse, withCredentials, x xhr.onreadystatechange = (function (){ switch (xhr.readyState) { - case 0 : // UNINITIALIZED - case 1 : // LOADING - case 2 : // LOADED - case 3 : // INTERACTIVE - break; - case 4 : // COMPLETED + case 0 : // UNINITIALIZED + case 1 : // LOADING + case 2 : // LOADED + case 3 : // INTERACTIVE + break; + case 4 : // COMPLETED - if (xhr.status >= 400 || xhr.status == 0) { - if (onError) { - onError(xhr.status); - } - break; + if (xhr.status >= 400 || xhr.status == 0) { + if (onError) { + onError(xhr.status); } + break; + } - var data = xhr.response; - var parsedData = data; + var data = xhr.response; + var parsedData = data; - if (!skipParse) { - try { + if (!skipParse) { + try { //var parsedData = skipParse ? data : eval("("+data+")"); - parsedData = JSON.parse(data); - } catch(e) { - console.log("JSON Parse Error ("+path+"): " + (e["message"] ? e["message"] : "")); + parsedData = JSON.parse(data); + } catch(e) { + console.log('JSON Parse Error ('+path+'): ' + (e['message'] ? e['message'] : '')); - if (onError ) { - onError(xhr.status); - } - - return; + if (onError ) { + onError(xhr.status); } - } - if (onLoaded) { - onLoaded(parsedData); + return; } + } + + if (onLoaded) { + onLoaded(parsedData); + } - break; + break; } }).bind(this); @@ -210,12 +210,12 @@ utils.loadJSON = function(path, onLoaded, onError, skipParse, withCredentials, x xhr.open('GET', path, true); xhr.withCredentials = withCredentials; - if (xhrParams && xhrParams["token"] /*&& xhrParams["tokenHeader"]*/) { + if (xhrParams && xhrParams['token'] /*&& xhrParams["tokenHeader"]*/) { //xhr.setRequestHeader(xhrParams["tokenHeader"], xhrParams["token"]); //old way - xhr.setRequestHeader("Accept", "token/" + xhrParams["token"] + ", */*"); + xhr.setRequestHeader('Accept', 'token/' + xhrParams['token'] + ', */*'); } - xhr.send(""); + xhr.send(''); }; @@ -225,28 +225,28 @@ utils.loadBinary = function(path, onLoaded, onError, withCredentials, xhrParams, xhr.onreadystatechange = (function (){ switch (xhr.readyState) { - case 0 : // UNINITIALIZED - case 1 : // LOADING - case 2 : // LOADED - case 3 : // INTERACTIVE + case 0 : // UNINITIALIZED + case 1 : // LOADING + case 2 : // LOADED + case 3 : // INTERACTIVE break; - case 4 : // COMPLETED + case 4 : // COMPLETED - if (xhr.status >= 400 || xhr.status == 0) { - if (onError) { - onError(xhr.status); - } - break; - } + if (xhr.status >= 400 || xhr.status == 0) { + if (onError) { + onError(xhr.status); + } + break; + } - var abuffer = xhr.response; + var abuffer = xhr.response; - if (!abuffer) { - if (onError) { - onError(); - } - break; - } + if (!abuffer) { + if (onError) { + onError(); + } + break; + } //if (!responseType || responseType == "arraybuffer") { //var data = new DataView(abuffer); @@ -254,22 +254,22 @@ utils.loadBinary = function(path, onLoaded, onError, withCredentials, xhrParams, // var data = abuffer; //} - if (onLoaded) { - onLoaded(abuffer); - } + if (onLoaded) { + onLoaded(abuffer); + } - break; + break; - default: + default: - if (onError) { - onError(); - } + if (onError) { + onError(); + } - break; - } + break; + } - }).bind(this); + }).bind(this); /* xhr.onerror = (function() { @@ -279,15 +279,15 @@ utils.loadBinary = function(path, onLoaded, onError, withCredentials, xhrParams, }).bind(this);*/ xhr.open('GET', path, true); - xhr.responseType = responseType ? responseType : "arraybuffer"; + xhr.responseType = responseType ? responseType : 'arraybuffer'; xhr.withCredentials = withCredentials; - if (xhrParams && xhrParams["token"] /*&& xhrParams["tokenHeader"]*/) { + if (xhrParams && xhrParams['token'] /*&& xhrParams["tokenHeader"]*/) { //xhr.setRequestHeader(xhrParams["tokenHeader"], xhrParams["token"]); //old way - xhr.setRequestHeader("Accept", "token/" + xhrParams["token"] + ", */*"); + xhr.setRequestHeader('Accept', 'token/' + xhrParams['token'] + ', */*'); } - xhr.send(""); + xhr.send(''); }; @@ -296,29 +296,29 @@ utils.headRequest = function(url, onLoaded, onError, withCredentials, xhrParams, xhr.onreadystatechange = (function (){ - switch (xhr.readyState) { - case 0 : // UNINITIALIZED - case 1 : // LOADING - case 2 : // LOADED - case 3 : // INTERACTIVE - break; - case 4 : // COMPLETED - if (onLoaded != null) { - onLoaded(xhr.getAllResponseHeaders(), xhr.status); + switch (xhr.readyState) { + case 0 : // UNINITIALIZED + case 1 : // LOADING + case 2 : // LOADED + case 3 : // INTERACTIVE + break; + case 4 : // COMPLETED + if (onLoaded != null) { + onLoaded(xhr.getAllResponseHeaders(), xhr.status); //onLoaded(xhr.getResponseHeader("X-VE-Tile-Info"), xhr.status); - } - break; + } + break; - default: + default: - if (onError != null) { - onError(); - } - - break; + if (onError != null) { + onError(); } + + break; + } - }).bind(this); + }).bind(this); xhr.onerror = (function() { if (onError != null) { @@ -330,12 +330,12 @@ utils.headRequest = function(url, onLoaded, onError, withCredentials, xhrParams, //xhr.responseType = responseType ? responseType : "arraybuffer"; xhr.withCredentials = withCredentials; - if (xhrParams && xhrParams["token"] /*&& xhrParams["tokenHeader"]*/) { + if (xhrParams && xhrParams['token'] /*&& xhrParams["tokenHeader"]*/) { //xhr.setRequestHeader(xhrParams["tokenHeader"], xhrParams["token"]); //old way - xhr.setRequestHeader("Accept", "token/" + xhrParams["token"] + ", */*"); + xhr.setRequestHeader('Accept', 'token/' + xhrParams['token'] + ', */*'); } - xhr.send(""); + xhr.send(''); }; @@ -345,7 +345,7 @@ utils.loadImage = function(url, onload, onerror, withCredentials, direct) { image.onload = onload; if (!direct){ - image.crossOrigin = withCredentials ? "use-credentials" : "anonymous"; + image.crossOrigin = withCredentials ? 'use-credentials' : 'anonymous'; } image.src = url; From 19a61cb9632f1950fb66ee552143d67e83e85372 Mon Sep 17 00:00:00 2001 From: David Levinsky Date: Fri, 28 Apr 2017 10:21:04 +0200 Subject: [PATCH 2/3] geodata code cleanup --- .../geodata-processor/worker-linestring.js | 299 +++++++++--------- src/core/map/geodata-processor/worker-main.js | 105 +++--- .../geodata-processor/worker-pointarray.js | 66 ++-- .../map/geodata-processor/worker-polygon.js | 25 +- .../map/geodata-processor/worker-style.js | 183 +++++------ src/core/map/geodata-processor/worker-text.js | 18 +- 6 files changed, 337 insertions(+), 359 deletions(-) diff --git a/src/core/map/geodata-processor/worker-linestring.js b/src/core/map/geodata-processor/worker-linestring.js index 44de83cf..02607b76 100755 --- a/src/core/map/geodata-processor/worker-linestring.js +++ b/src/core/map/geodata-processor/worker-linestring.js @@ -1,31 +1,23 @@ import {globals as globals_, vec3Normalize as vec3Normalize_, - vec3Length as vec3Length_, vec3Cross as vec3Cross_, + vec3Cross as vec3Cross_, vec3AnyPerpendicular as vec3AnyPerpendicular_} from './worker-globals.js'; -import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, +import {getLayerPropertyValue as getLayerPropertyValue_, getLayerExpresionValue as getLayerExpresionValue_} from './worker-style.js'; -import {addText as addText_, addTextOnPath as addTextOnPath_, - setFont as setFont_, addStreetTextOnPath as addStreetTextOnPath_, +import {addStreetTextOnPath as addStreetTextOnPath_, areTextCharactersAvailable as areTextCharactersAvailable_, getCharVerticesCount as getCharVerticesCount_} from './worker-text.js'; +import {postGroupMessage as postGroupMessage_} from './worker-message.js'; -var globals = globals_, vec3Normalize = vec3Normalize_, vec3Length = vec3Length_, +//get rid of compiler mess +var globals = globals_, vec3Normalize = vec3Normalize_, vec3Cross = vec3Cross_, vec3AnyPerpendicular = vec3AnyPerpendicular_; -var getLayer = getLayer_, getLayerPropertyValue = getLayerPropertyValue_, +var getLayerPropertyValue = getLayerPropertyValue_, getLayerExpresionValue = getLayerExpresionValue_; -var addText = addText_, addTextOnPath = addTextOnPath_, setFont = setFont_, - addStreetTextOnPath = addStreetTextOnPath_, areTextCharactersAvailable = areTextCharactersAvailable_, +var addStreetTextOnPath = addStreetTextOnPath_, areTextCharactersAvailable = areTextCharactersAvailable_, getCharVerticesCount = getCharVerticesCount_; - -import {processPolygonPass as processPolygonPass_} from './worker-polygon.js'; -var processPolygonPass = processPolygonPass_; - -import {postGroupMessage as postGroupMessage_} from './worker-message.js'; var postGroupMessage = postGroupMessage_; -//get rid of compiler mess - - var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) { var lines = lineString['lines'] || []; @@ -57,7 +49,6 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) var lineStyleTexture = getLayerPropertyValue(style, 'line-style-texture', lineString, lod); var lineStyleBackground = getLayerPropertyValue(style, 'line-style-background', lineString, lod); - var lineLabel = getLayerPropertyValue(style, 'line-label', lineString, lod); var lineLabelSize = getLayerPropertyValue(style, 'line-label-size', lineString, lod); //console.log("lineflat: "+lineFlat); @@ -67,6 +58,8 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) var index2 = 0; var skipJoins = (!lineFlat && lineWidth < 2.1); + var ii, i, li, p2, v, vv, l, n, nn, p1, p; + //console.log("lod: " + lod + " width: " + lineWidth); if (!skipJoins) { @@ -76,7 +69,7 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) var angle = 0, step = (2.0*Math.PI) / circleSides; - for (var i = 0; i < circleSides; i++) { + for (i = 0; i < circleSides; i++) { circleBuffer[i] = [-Math.sin(angle), Math.cos(angle)]; circleBuffer2[i] = angle; angle += step; @@ -88,7 +81,7 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) var totalPoints = 0; - for (var ii = 0; ii < lines.length; ii++) { + for (ii = 0; ii < lines.length; ii++) { if (Array.isArray(lines[ii])) { totalPoints += lines[ii].length; } @@ -119,7 +112,7 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) var tileY = globals.tileY; var forceScale = globals.forceScale; - for (var ii = 0; ii < lines.length; ii++) { + for (ii = 0; ii < lines.length; ii++) { if (!Array.isArray(lines[ii]) || !lines[ii].length) { continue; } @@ -133,8 +126,8 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) lineLabelStack.push({points: lineLabelPoints, points2 :lineLabelPoints2}); } - var p = points[0]; - var p1 = [p[0], p[1], p[2]]; + p = points[0]; + p1 = [p[0], p[1], p[2]]; if (forceOrigin) { p1 = [p1[0] - tileX, p1[1] - tileY, p1[2]]; @@ -152,10 +145,10 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) var distance2 = 0.001; //add lines - for (var i = 0, li = points.length - 1; i < li; i++) { + for (i = 0, li = points.length - 1; i < li; i++) { if (dlines) { - var p2 = points[i+1]; + p2 = points[i+1]; p2 = [p1[0] + p2[0], p1[1] + p2[1], p1[2] + p2[2]]; if (forceOrigin) { @@ -168,7 +161,7 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) } else { p1 = points[i]; - var p2 = points[i+1]; + p2 = points[i+1]; if (forceOrigin) { p1 = [p1[0] - tileX, p1[1] - tileY, p1[2]]; @@ -187,17 +180,17 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) //normalize vector to line width and rotate 90 degrees if (geocent) { //direction vector - var v = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]]; + v = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]]; //get line length - var l = Math.sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + l = Math.sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); distance2 += l; l = (l != 0) ? (1 / l) : 0; - var vv = [v[0]*l, v[1]*l, v[2]*l]; - var n = [0,0,0]; - var nn = [0,0,0]; + vv = [v[0]*l, v[1]*l, v[2]*l]; + n = [0,0,0]; + nn = [0,0,0]; vec3Normalize(bboxMin, nn); vec3Cross(nn, vv, n); @@ -205,15 +198,15 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) n = [n[0] * lineWidth, n[1] * lineWidth, n[2] * lineWidth]; } else { //direction vector - var v = [p2[0] - p1[0], p2[1] - p1[1], 0]; + v = [p2[0] - p1[0], p2[1] - p1[1], 0]; //get line length - var l = Math.sqrt(v[0]*v[0] + v[1]*v[1]); + l = Math.sqrt(v[0]*v[0] + v[1]*v[1]); distance2 += l; l = (l != 0) ? (lineWidth / l) : 0; - var n = [-v[1]*l, v[0]*l, 0]; + n = [-v[1]*l, v[0]*l, 0]; } //add polygon @@ -247,10 +240,10 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) } else { //direction vector - var v = [p2[0] - p1[0], p2[1] - p1[1], 0]; + v = [p2[0] - p1[0], p2[1] - p1[1], 0]; //get line length - var l = Math.sqrt(v[0]*v[0] + v[1]*v[1]); + l = Math.sqrt(v[0]*v[0] + v[1]*v[1]); distance2 += l; //console.log("distance("+i+"): " + distance + " " + distance2); @@ -259,7 +252,7 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) //normalize vector to line width and rotate 90 degrees l = (l != 0) ? (lineWidth / l) : 0; - var n = [-v[1]*l, v[0]*l,0]; + n = [-v[1]*l, v[0]*l,0]; if (joinParams != null) { joinParams[i] = (l != 0) ? Math.atan2(v[0], v[1]) + Math.PI *0.5 : 0; @@ -391,138 +384,133 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) p1 = p2; //only for dlines } - var p1 = [p[0], p[1], p[2]]; + p1 = [p[0], p[1], p[2]]; - if (true /*!skipJoins || lineLabel*/) { - - //add joins - for (var i = 0, li = points.length; i < li; i++) { - - if (forceOrigin) { - p1 = [p1[0] - tileX, p1[1] - tileY, p1[2]]; - } - - if (forceScale != null) { - p1 = [p1[0] * forceScale[0], p1[1] * forceScale[1], p1[2] * forceScale[2]]; + //add joins + for (i = 0, li = points.length; i < li; i++) { + + if (forceOrigin) { + p1 = [p1[0] - tileX, p1[1] - tileY, p1[2]]; + } + + if (forceScale != null) { + p1 = [p1[0] * forceScale[0], p1[1] * forceScale[1], p1[2] * forceScale[2]]; + } + + center[0] += p1[0]; + center[1] += p1[1]; + center[2] += p1[2]; + + if (!skipJoins) { + var angleShift = (joinParams != null) ? joinParams[i] : 0; + + if (geocent) { + vv = [0,0,0]; + nn = [0,0,0]; + vec3Normalize(bboxMin, nn); + vec3AnyPerpendicular(nn, vv); + vec3Normalize(vv); + vec3Cross(nn, vv, nn); } - center[0] += p1[0]; - center[1] += p1[1]; - center[2] += p1[2]; - - if (!skipJoins) { - var angleShift = (joinParams != null) ? joinParams[i] : 0; + for (var j = 0; j < circleSides; j++) { - if (geocent) { - var vv = [0,0,0]; - var nn = [0,0,0]; - vec3Normalize(bboxMin, nn); - vec3AnyPerpendicular(nn, vv); - vec3Normalize(vv); - vec3Cross(nn, vv, nn); - } - - for (var j = 0; j < circleSides; j++) { - - if (lineFlat && !texturedLine) { + if (lineFlat && !texturedLine) { + + vertexBuffer[index] = p1[0]; + vertexBuffer[index+1] = p1[1]; + vertexBuffer[index+2] = p1[2]; - vertexBuffer[index] = p1[0]; - vertexBuffer[index+1] = p1[1]; - vertexBuffer[index+2] = p1[2]; - - //add polygon - if (geocent) { - var dx = circleBuffer[j][0]; - var dy = circleBuffer[j][1]; - vertexBuffer[index+3] = p1[0] + (nn[0] * dx + vv[0] * dy) * lineWidth; - vertexBuffer[index+4] = p1[1] + (nn[1] * dx + vv[1] * dy) * lineWidth; - vertexBuffer[index+5] = p1[2] + (nn[2] * dx + vv[2] * dy) * lineWidth; - - dx = circleBuffer[j+1][0]; - dy = circleBuffer[j+1][1]; - vertexBuffer[index+6] = p1[0] + (nn[0] * dx + vv[0] * dy) * lineWidth; - vertexBuffer[index+7] = p1[1] + (nn[1] * dx + vv[1] * dy) * lineWidth; - vertexBuffer[index+8] = p1[2] + (nn[2] * dx + vv[2] * dy) * lineWidth; - } else { - - vertexBuffer[index+3] = p1[0] + circleBuffer[j][0] * lineWidth; - vertexBuffer[index+4] = p1[1] + circleBuffer[j][1] * lineWidth; - vertexBuffer[index+5] = p1[2]; - - vertexBuffer[index+6] = p1[0] + circleBuffer[j+1][0] * lineWidth; - vertexBuffer[index+7] = p1[1] + circleBuffer[j+1][1] * lineWidth; - vertexBuffer[index+8] = p1[2]; - } - - index += 9; + //add polygon + if (geocent) { + var dx = circleBuffer[j][0]; + var dy = circleBuffer[j][1]; + vertexBuffer[index+3] = p1[0] + (nn[0] * dx + vv[0] * dy) * lineWidth; + vertexBuffer[index+4] = p1[1] + (nn[1] * dx + vv[1] * dy) * lineWidth; + vertexBuffer[index+5] = p1[2] + (nn[2] * dx + vv[2] * dy) * lineWidth; + dx = circleBuffer[j+1][0]; + dy = circleBuffer[j+1][1]; + vertexBuffer[index+6] = p1[0] + (nn[0] * dx + vv[0] * dy) * lineWidth; + vertexBuffer[index+7] = p1[1] + (nn[1] * dx + vv[1] * dy) * lineWidth; + vertexBuffer[index+8] = p1[2] + (nn[2] * dx + vv[2] * dy) * lineWidth; } else { - //distance = vertexBuffer[(i >> 1) * lineVertices + ((i & 1) ? 11 : 3)]; - if (i != (li-1)) { - distance = vertexBuffer[i * lineVertices + 3]; - } else { - distance = vertexBuffer[(i - 1) * lineVertices + 11]; - } - //distance = vertexBuffer[((i == li) ? i - 1 : i) * lineVertices + 3]; - - //if (distance == null) { - // debugger - //} - - //console.log("distance-dot("+i+"): " + distance); + vertexBuffer[index+3] = p1[0] + circleBuffer[j][0] * lineWidth; + vertexBuffer[index+4] = p1[1] + circleBuffer[j][1] * lineWidth; + vertexBuffer[index+5] = p1[2]; - //add polygon - vertexBuffer[index] = p1[0]; - vertexBuffer[index+1] = p1[1]; - vertexBuffer[index+2] = p1[2]; - vertexBuffer[index+3] = distance; - normalBuffer[index2] = 0; - normalBuffer[index2+1] = 0; - normalBuffer[index2+2] = 0; - normalBuffer[index2+3] = 0; - - vertexBuffer[index+4] = p1[0]; - vertexBuffer[index+5] = p1[1]; - vertexBuffer[index+6] = p1[2]; - vertexBuffer[index+7] = distance; - normalBuffer[index2+4] = circleBuffer[j][0] * lineWidth; - normalBuffer[index2+5] = circleBuffer[j][1] * lineWidth; - normalBuffer[index2+6] = circleBuffer2[j] + angleShift; - normalBuffer[index2+7] = 0; - - vertexBuffer[index+8] = p1[0]; - vertexBuffer[index+9] = p1[1]; - vertexBuffer[index+10] = p1[2]; - vertexBuffer[index+11] = distance; - normalBuffer[index2+8] = circleBuffer[j+1][0] * lineWidth; - normalBuffer[index2+9] = circleBuffer[j+1][1] * lineWidth; - normalBuffer[index2+10] = circleBuffer2[j+1] + angleShift; - normalBuffer[index2+11] = 0; + vertexBuffer[index+6] = p1[0] + circleBuffer[j+1][0] * lineWidth; + vertexBuffer[index+7] = p1[1] + circleBuffer[j+1][1] * lineWidth; + vertexBuffer[index+8] = p1[2]; + } - index += 12; - index2 += 12; + index += 9; + + } else { + + //distance = vertexBuffer[(i >> 1) * lineVertices + ((i & 1) ? 11 : 3)]; + if (i != (li-1)) { + distance = vertexBuffer[i * lineVertices + 3]; + } else { + distance = vertexBuffer[(i - 1) * lineVertices + 11]; } - } - } + //distance = vertexBuffer[((i == li) ? i - 1 : i) * lineVertices + 3]; - if (lineLabel) { - var p = [p1[0], p1[1], p1[2] + lineLabelSize*0.1]; - lineLabelPoints[i] = p; - lineLabelPoints2[li - i - 1] = p; - } + //if (distance == null) { + // debugger + //} - if (dlines) { - var p2 = points[i+1]; - p1 = [p1[0] + p2[0], p1[1] + p2[1], p1[2] + p2[2]]; - } else { - p1 = points[i+1]; + //console.log("distance-dot("+i+"): " + distance); + + //add polygon + vertexBuffer[index] = p1[0]; + vertexBuffer[index+1] = p1[1]; + vertexBuffer[index+2] = p1[2]; + vertexBuffer[index+3] = distance; + normalBuffer[index2] = 0; + normalBuffer[index2+1] = 0; + normalBuffer[index2+2] = 0; + normalBuffer[index2+3] = 0; + + vertexBuffer[index+4] = p1[0]; + vertexBuffer[index+5] = p1[1]; + vertexBuffer[index+6] = p1[2]; + vertexBuffer[index+7] = distance; + normalBuffer[index2+4] = circleBuffer[j][0] * lineWidth; + normalBuffer[index2+5] = circleBuffer[j][1] * lineWidth; + normalBuffer[index2+6] = circleBuffer2[j] + angleShift; + normalBuffer[index2+7] = 0; + + vertexBuffer[index+8] = p1[0]; + vertexBuffer[index+9] = p1[1]; + vertexBuffer[index+10] = p1[2]; + vertexBuffer[index+11] = distance; + normalBuffer[index2+8] = circleBuffer[j+1][0] * lineWidth; + normalBuffer[index2+9] = circleBuffer[j+1][1] * lineWidth; + normalBuffer[index2+10] = circleBuffer2[j+1] + angleShift; + normalBuffer[index2+11] = 0; + + index += 12; + index2 += 12; + } } } - - - } + if (lineLabel) { + p = [p1[0], p1[1], p1[2] + lineLabelSize*0.1]; + lineLabelPoints[i] = p; + lineLabelPoints2[li - i - 1] = p; + } + + if (dlines) { + p2 = points[i+1]; + p1 = [p1[0] + p2[0], p1[1] + p2[1], p1[2] + p2[2]]; + } else { + p1 = points[i+1]; + } + } + } if (totalPoints > 0) { @@ -576,7 +564,7 @@ var processLineStringPass = function(lineString, lod, style, zIndex, eventInfo) //debugger if (lineLabel) { - for (var i = 0, li = lineLabelStack.length; i < li; i++) { + for (i = 0, li = lineLabelStack.length; i < li; i++) { processLineLabel(lineLabelStack[i].points, lineLabelStack[i].points2, lineString, center, lod, style, zIndex, eventInfo); } } @@ -596,11 +584,11 @@ var processLineLabel = function(lineLabelPoints, lineLabelPoints2, lineString, c return; } - var labelText = getLayerExpresionValue(style, labelSource, lineString, lod); + var labelText = getLayerExpresionValue(style, labelSource, lineString); if (labelSource == '$name') { if (!areTextCharactersAvailable(labelText, globals.fonts['default'])) { - var labelText2 = getLayerExpresionValue(style, '$name:en', lineString, lod); + var labelText2 = getLayerExpresionValue(style, '$name:en', lineString); if (areTextCharactersAvailable(labelText2, globals.fonts['default'])) { labelText = labelText2; @@ -627,7 +615,6 @@ var processLineLabel = function(lineLabelPoints, lineLabelPoints2, lineString, c //debugger var hitable = hoverEvent || clickEvent || enterEvent || leaveEvent; - var index = 0; var index = addStreetTextOnPath(lineLabelPoints, labelText, labelSize, globals.fonts['default'], labelOffset, vertexBuffer, texcoordsBuffer, index); index = addStreetTextOnPath(lineLabelPoints2, labelText, labelSize, globals.fonts['default'], labelOffset, vertexBuffer, texcoordsBuffer, index); diff --git a/src/core/map/geodata-processor/worker-main.js b/src/core/map/geodata-processor/worker-main.js index 642ebd16..b20c2a71 100755 --- a/src/core/map/geodata-processor/worker-main.js +++ b/src/core/map/geodata-processor/worker-main.js @@ -1,26 +1,20 @@ import {globals as globals_} from './worker-globals.js'; -var globals = globals_; - import {setFont as setFont_} from './worker-text.js'; -var setFont = setFont_; - import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, - getLayerExpresionValue as getLayerExpresionValue_, processStylesheet as processStylesheet_, getFilterResult as getFilterResult_} from './worker-style.js'; -var getLayer = getLayer_, getLayerPropertyValue = getLayerPropertyValue_, getLayerExpresionValue = getLayerExpresionValue_, - processStylesheet = processStylesheet_, getFilterResult = getFilterResult_; - -import {processLineStringPass as processLineStringPass_, processLineLabel as processLineLabel_} from './worker-linestring.js'; -var processLineStringPass = processLineStringPass_, processLineLabel = processLineLabel_; - +import {processLineStringPass as processLineStringPass_} from './worker-linestring.js'; import {processPointArrayPass as processPointArrayPass_} from './worker-pointarray.js'; -var processPointArrayPass = processPointArrayPass_; - import {processPolygonPass as processPolygonPass_} from './worker-polygon.js'; -var processPolygonPass = processPolygonPass_; //get rid of compiler mess +var globals = globals_; +var setFont = setFont_; +var getLayer = getLayer_, getLayerPropertyValue = getLayerPropertyValue_, + processStylesheet = processStylesheet_, getFilterResult = getFilterResult_; +var processLineStringPass = processLineStringPass_; +var processPointArrayPass = processPointArrayPass_; +var processPolygonPass = processPolygonPass_; function processLayerFeaturePass(type, feature, lod, layer, zIndex, eventInfo) { @@ -46,7 +40,7 @@ function processLayerFeaturePass(type, feature, lod, layer, zIndex, eventInfo) { break; case 'polygon': - processPolygonPass(feature, lod, style, zIndex, eventInfo); + processPolygonPass(feature, lod, layer, zIndex, eventInfo); break; } @@ -74,29 +68,31 @@ function processFeature(type, feature, lod, featureIndex, featureType, group) { function processLayerFeatureMultipass(type, feature, lod, layer, featureIndex, eventInfo) { var multiPass = getLayerPropertyValue(layer, 'next-pass', feature, lod); + var mylayer; + if (multiPass != null) { for (var i = 0, li = multiPass.length; i < li; i++) { var zIndex = multiPass[i][0]; - var layer = getLayer(multiPass[i][1], type, featureIndex); - var visible = getLayerPropertyValue(layer, 'visible', feature, lod); + mylayer = getLayer(multiPass[i][1], type, featureIndex); + var visible = getLayerPropertyValue(mylayer, 'visible', feature, lod); if (!visible) { continue; } - var hoverLayerId = getLayerPropertyValue(layer, 'hover-layer', feature, lod); + var hoverLayerId = getLayerPropertyValue(mylayer, 'hover-layer', feature, lod); var hoverlayer = (hoverLayerId != '') ? getLayer(hoverLayerId, type, featureIndex) : null; if (hoverlayer != null) { var lastHitState = globals.hitState; globals.hitState = 1; - processLayerFeaturePass(type, feature, lod, layer, zIndex, eventInfo); + processLayerFeaturePass(type, feature, lod, mylayer, zIndex, eventInfo); globals.hitState = 2; processLayerFeaturePass(type, feature, lod, hoverlayer, zIndex, eventInfo); globals.hitState = lastHitState; } else { //globals.hitState = 0; - processLayerFeaturePass(type, feature, lod, layer, zIndex, eventInfo); + processLayerFeaturePass(type, feature, lod, mylayer, zIndex, eventInfo); } } } @@ -133,6 +129,9 @@ function processLayerFeature(type, feature, lod, layer, featureIndex) { function processGroup(group, lod) { + + var i, li; + var groupId = group['id'] || ''; var bbox = group['bbox']; @@ -160,21 +159,21 @@ function processGroup(group, lod) { var points = group['points'] || []; //process points - for (var i = 0, li = points.length; i < li; i++) { + for (i = 0, li = points.length; i < li; i++) { processFeature('point-array', points[i], lod, i, 'point', groupId); } var lines = group['lines'] || []; //process lines - for (var i = 0, li = lines.length; i < li; i++) { + for (i = 0, li = lines.length; i < li; i++) { processFeature('line-string', lines[i], lod, i, 'line', groupId); } var polygons = group['polygons'] || []; //process polygons - for (var i = 0, li = polygons.length; i < li; i++) { + for (i = 0, li = polygons.length; i < li; i++) { processFeature('polygon', polygons[i], lod, i, 'polygon', groupId); } @@ -215,9 +214,10 @@ function processGeodata(data, lod) { function optimizeGroupMessages() { //loop messages - var index2 = 0; var messages = globals.messageBuffer; //var messages2 = globals.messageBuffer2; + // + var j, lk, k, message2, job2, vbufferSize, vbuffer, index, buff, buff2; for (var i = 0, li = globals.messageBufferIndex; i < li; i++) { var message = messages[i]; @@ -230,10 +230,10 @@ function optimizeGroupMessages() { switch(type) { case 'flat-line': - var vbufferSize = job['vertexBuffer'].length; + vbufferSize = job['vertexBuffer'].length; - for (var j = i + 1; j < li; j++) { - var message2 = messages[j]; + for (j = i + 1; j < li; j++) { + message2 = messages[j]; if (message2.signature == signature) { message2.reduced = true; @@ -241,17 +241,17 @@ function optimizeGroupMessages() { } } - var vbuffer = new Float32Array(vbufferSize); - var index = 0; + vbuffer = new Float32Array(vbufferSize); + index = 0; - for (var j = i; j < li; j++) { - var message2 = messages[j]; - var job2 = message2.job; + for (j = i; j < li; j++) { + message2 = messages[j]; + job2 = message2.job; if (message2.signature == signature) { - var buff = job2['vertexBuffer']; + buff = job2['vertexBuffer']; job2['vertexBuffer'] = null; - for (var k = 0, lk = buff.length; k < lk; k++) { + for (k = 0, lk = buff.length; k < lk; k++) { vbuffer[index+k] = buff[k]; } index+= lk; @@ -264,10 +264,10 @@ function optimizeGroupMessages() { case 'pixel-line': case 'line-label': - var vbufferSize = job['vertexBuffer'].length; + vbufferSize = job['vertexBuffer'].length; - for (var j = i + 1; j < li; j++) { - var message2 = messages[j]; + for (j = i + 1; j < li; j++) { + message2 = messages[j]; if (message2.signature == signature) { message2.reduced = true; @@ -275,27 +275,27 @@ function optimizeGroupMessages() { } } - var vbuffer = new Float32Array(vbufferSize); + vbuffer = new Float32Array(vbufferSize); var nbuffer = new Float32Array(vbufferSize); - var index = 0; + index = 0; - for (var j = i; j < li; j++) { - var message2 = messages[j]; - var job2 = message2.job; + for (j = i; j < li; j++) { + message2 = messages[j]; + job2 = message2.job; if (message2.signature == signature) { - var buff = job2['vertexBuffer']; + buff = job2['vertexBuffer']; job2['vertexBuffer'] = null; if (type == 'line-label') { - var buff2 = job2['texcoordsBuffer']; + buff2 = job2['texcoordsBuffer']; job2['texcoordsBuffer'] = null; } else { - var buff2 = job2['normalBuffer']; + buff2 = job2['normalBuffer']; job2['normalBuffer'] = null; } - for (var k = 0, lk = buff.length; k < lk; k++) { + for (k = 0, lk = buff.length; k < lk; k++) { vbuffer[index+k] = buff[k]; nbuffer[index+k] = buff2[k]; } @@ -315,28 +315,15 @@ function optimizeGroupMessages() { break; } - //messages2[index2] = message; - index2++; - postMessage(message.job, message.arrays); } else if (!message.reduced) { postMessage(message.job, message.arrays); - //messages2[index2] = message; - index2++; } } - //for (var i = 0, li = index2; i < li; i++) { - //var message = messages2[i]; - //postMessage(message.job, message.arrays); - //} - - //var reduced = messageBufferIndex - index2; - //console.log("total: " + messageBufferIndex + " reduced: " + reduced); - globals.messageBufferIndex = 0; } diff --git a/src/core/map/geodata-processor/worker-pointarray.js b/src/core/map/geodata-processor/worker-pointarray.js index ef1379d1..1affe83e 100755 --- a/src/core/map/geodata-processor/worker-pointarray.js +++ b/src/core/map/geodata-processor/worker-pointarray.js @@ -1,23 +1,21 @@ import {globals as globals_, clamp as clamp_} from './worker-globals.js'; -var globals = globals_, clamp = clamp_; - -import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, getLayerExpresionValue as getLayerExpresionValue_} from './worker-style.js'; -var getLayer = getLayer_, getLayerPropertyValue = getLayerPropertyValue_, getLayerExpresionValue = getLayerExpresionValue_; - -import {addText as addText_, addTextOnPath as addTextOnPath_, setFont as setFont_, getSplitIndex as getSplitIndex_, getFontFactor as getFontFactor_, getTextLength as getTextLength_, +import {getLayerPropertyValue as getLayerPropertyValue_, getLayerExpresionValue as getLayerExpresionValue_} from './worker-style.js'; +import {addText as addText_, getSplitIndex as getSplitIndex_, getFontFactor as getFontFactor_, getTextLength as getTextLength_, areTextCharactersAvailable as areTextCharactersAvailable_, getCharVerticesCount as getCharVerticesCount_, getLineHeight as getLineHeight_} from './worker-text.js'; -var addText = addText_, addTextOnPath = addTextOnPath_, setFont = setFont_, getSplitIndex = getSplitIndex_, getFontFactor = getFontFactor_, getTextLength = getTextLength_, - areTextCharactersAvailable = areTextCharactersAvailable_, getCharVerticesCount = getCharVerticesCount_, getLineHeight = getLineHeight_; - import {postGroupMessage as postGroupMessage_} from './worker-message.js'; -var postGroupMessage = postGroupMessage_; //get rid of compiler mess +var globals = globals_, clamp = clamp_; +var getLayerPropertyValue = getLayerPropertyValue_, getLayerExpresionValue = getLayerExpresionValue_; +var addText = addText_, getSplitIndex = getSplitIndex_, getFontFactor = getFontFactor_, getTextLength = getTextLength_, + areTextCharactersAvailable = areTextCharactersAvailable_, getCharVerticesCount = getCharVerticesCount_, getLineHeight = getLineHeight_; +var postGroupMessage = postGroupMessage_; var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) { var pointsGroups = []; + var i, li; if (pointArray['lines']) { //use lines as points pointsGroups = pointArray['lines'] || []; @@ -46,15 +44,17 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) var pointFlat = getLayerPropertyValue(style, 'point-flat', pointArray, lod); var pointColor = getLayerPropertyValue(style, 'point-color', pointArray, lod); var pointRadius = 0.5 * getLayerPropertyValue(style, 'point-radius', pointArray, lod); + + var source, bufferSize, bufferSize2; //zIndex = (zIndex !== null) ? zIndex : getLayerPropertyValue(style, "z-index", pointArray, lod); var icon = getLayerPropertyValue(style, 'icon', pointArray, lod); if (icon) { - var source = getLayerPropertyValue(style, 'icon-source', pointArray, lod); + source = getLayerPropertyValue(style, 'icon-source', pointArray, lod); if (source) { - var bufferSize = getCharVerticesCount() * pointsGroups.length; - var bufferSize2 = getCharVerticesCount(true) * pointsGroups.length; + bufferSize = getCharVerticesCount() * pointsGroups.length; + bufferSize2 = getCharVerticesCount(true) * pointsGroups.length; var iconData = { color : getLayerPropertyValue(style, 'icon-color', pointArray, lod), @@ -76,13 +76,13 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) var label = getLayerPropertyValue(style, 'label', pointArray, lod); if (label) { - var source = getLayerPropertyValue(style, 'label-source', pointArray, lod); - var text = getLayerExpresionValue(style, source, pointArray, lod); + source = getLayerPropertyValue(style, 'label-source', pointArray, lod); + var text = getLayerExpresionValue(style, source, pointArray); var size = getLayerPropertyValue(style, 'label-size', pointArray, lod); if (source == '$name') { if (!areTextCharactersAvailable(text, globals.fonts['default'])) { - var text2 = getLayerExpresionValue(style, '$name:en', pointArray, lod); + var text2 = getLayerExpresionValue(style, '$name:en', pointArray); if (areTextCharactersAvailable(text2, globals.fonts['default'])) { text = text2; @@ -90,8 +90,8 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) } } if (text && text != '' && Math.abs(size) > 0.0001) { - var bufferSize = getCharVerticesCount() * text.length * pointsGroups.length; - var bufferSize2 = getCharVerticesCount(true) * text.length * pointsGroups.length; + bufferSize = getCharVerticesCount() * text.length * pointsGroups.length; + bufferSize2 = getCharVerticesCount(true) * text.length * pointsGroups.length; var labelData = { color : getLayerPropertyValue(style, 'label-color', pointArray, lod), @@ -121,7 +121,7 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) var angle = 0, step = (2.0*Math.PI) / circleSides; - for (var i = 0; i < circleSides; i++) { + for (i = 0; i < circleSides; i++) { circleBuffer[i] = [-Math.sin(angle), Math.cos(angle)]; angle += step; } @@ -136,6 +136,8 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) var tileY = globals.tileY; var forceScale = globals.forceScale; + var pointsVertices, vertexBuffer, pointsNormals, normalBuffer; + for (var g = 0, gl = pointsGroups.length; g < gl; g++) { var points = pointsGroups[g]; @@ -148,19 +150,19 @@ var processPointArrayPass = function(pointArray, lod, style, zIndex, eventInfo) //allocate buffers if (!pointFlat) { - var pointsVertices = circleSides * 3 * 4; - var vertexBuffer = new Array(points.length * pointsVertices); - var pointsNormals = circleSides * 3 * 4; - var normalBuffer = new Array(points.length * pointsNormals); + pointsVertices = circleSides * 3 * 4; + vertexBuffer = new Array(points.length * pointsVertices); + pointsNormals = circleSides * 3 * 4; + normalBuffer = new Array(points.length * pointsNormals); } else { - var pointsVertices = circleSides * 3 * 3; - var vertexBuffer = new Array(points.length * pointsVertices); + pointsVertices = circleSides * 3 * 3; + vertexBuffer = new Array(points.length * pointsVertices); } var dpoints = false; //add ponints - for (var i = 0, li = points.length; i < li; i++) { + for (i = 0, li = points.length; i < li; i++) { if (forceOrigin) { p1 = [p1[0] - tileX, p1[1] - tileY, p1[2]]; @@ -435,13 +437,13 @@ var processLabel = function(point, labelData) { //split by new line var lines = text.match(/[^\r\n]+/g); var lines2 = []; - var align = false; //split lines by width for (var i = 0, li = lines.length; i < li; i++) { - var line= lines[i]; + var line = lines[i]; + // eslint-disable-next-line do { var splitIndex = getSplitIndex(line, labelData.width, getFontFactor(labelData.size, globals.fonts['default']), globals.fonts['default']); @@ -452,7 +454,6 @@ var processLabel = function(point, labelData) { lines2.push(line.substring(0,splitIndex)); line = line.substring(splitIndex+1); - align = true; } while(true); @@ -460,19 +461,18 @@ var processLabel = function(point, labelData) { var x = 0; var y = 0; - var textLength = 0; var lineHeight = getLineHeight(labelData.size, globals.fonts['default']); var maxWidth = 0; var lineWidths = []; //get max width - for (var i = 0, li = lines2.length; i < li; i++) { + for (i = 0, li = lines2.length; i < li; i++) { lineWidths[i] = getTextLength(lines2[i], getFontFactor(labelData.size, globals.fonts['default']), globals.fonts['default']); maxWidth = Math.max(lineWidths[i], maxWidth); } //generate text - for (var i = 0, li = lines2.length; i < li; i++) { + for (i = 0, li = lines2.length; i < li; i++) { var textWidth = lineWidths[i];//getTextLength(lines2[i], getFontFactor(labelData.size, fonts["default"]), fonts["default"]); //maxWidth = Math.max(textWidth, maxWidth); @@ -496,7 +496,7 @@ var processLabel = function(point, labelData) { var p3 = point[2]; //set origin buffer and apply offset - for (var i = lastIndex; i < index; i+=4) { + for (i = lastIndex; i < index; i+=4) { vertexBuffer[i] += offsetX; vertexBuffer[i+1] -= offsetY; diff --git a/src/core/map/geodata-processor/worker-polygon.js b/src/core/map/geodata-processor/worker-polygon.js index c9490e4c..47a766e7 100755 --- a/src/core/map/geodata-processor/worker-polygon.js +++ b/src/core/map/geodata-processor/worker-polygon.js @@ -1,14 +1,16 @@ -import {globals as globals_} from './worker-globals.js'; -var globals = globals_; - -import {getLayer as getLayer_, getLayerPropertyValue as getLayerPropertyValue_, getLayerExpresionValue as getLayerExpresionValue_} from './worker-style.js'; -var getLayer = getLayer_, getLayerPropertyValue = getLayerPropertyValue_, getLayerExpresionValue = getLayerExpresionValue_; +import {globals as globals_} from './worker-globals.js'; +import {getLayerPropertyValue as getLayerPropertyValue_} from './worker-style.js'; import {postGroupMessage as postGroupMessage_} from './worker-message.js'; -var postGroupMessage = postGroupMessage_; +import {processLineStringPass as processLineStringPass_} from './worker-linestring.js'; +import {processPointArrayPass as processPointArrayPass_} from './worker-pointarray.js'; //get rid of compiler mess - +var globals = globals_; +var getLayerPropertyValue = getLayerPropertyValue_; +var postGroupMessage = postGroupMessage_; +var processLineStringPass = processLineStringPass_; +var processPointArrayPass = processPointArrayPass_; var processPolygonPass = function(polygon, lod, style, zIndex, eventInfo) { var vertices = polygon['vertices'] || []; @@ -56,12 +58,13 @@ var processPolygonPass = function(polygon, lod, style, zIndex, eventInfo) { var vertexCount = trisCount * 3; var vertexBuffer = new Array (vertexCount * 3); - var dpoints = false; var surfaceI = 0; var index = 0; var p1; var offs; + var tileX = globals.tileX; + var tileY = globals.tileY; var forceOrigin = globals.forceOrigin; var forceScale = globals.forceScale; @@ -138,8 +141,7 @@ var processPolygonLines = function(polygon, vertices, lod, style, zIndex, eventI var points; if (processLines) { points = new Array(pointsCount + 1); - } - else { + } else { points = new Array(pointsCount); } for (var i = 0; i < pointsCount; i++) { @@ -152,8 +154,7 @@ var processPolygonLines = function(polygon, vertices, lod, style, zIndex, eventI feature['points'] = points; if(processLines) { processLineStringPass(feature, lod, style, zIndex, eventInfo); - } - else { + } else { processPointArrayPass(feature, lod, style, zIndex, eventInfo); } } diff --git a/src/core/map/geodata-processor/worker-style.js b/src/core/map/geodata-processor/worker-style.js index f76f8d1b..c7f643b2 100755 --- a/src/core/map/geodata-processor/worker-style.js +++ b/src/core/map/geodata-processor/worker-style.js @@ -16,7 +16,7 @@ var getLayer = function(layerId, featureType, index) { }; -var getLayerExpresionValue = function(layer, value, feature, lod) { +var getLayerExpresionValue = function(layer, value, feature) { switch(typeof value) { case 'string': @@ -63,8 +63,6 @@ var getLayerPropertyValue = function(layer, key, feature, lod) { return value; - break; - case 'object': //is it null? @@ -107,6 +105,8 @@ var getLayerPropertyValue = function(layer, key, feature, lod) { var valueType = (typeof lastValue); var newValue = lastValue; + var currentLod, currentValue; + for (var i = 0, li = stops.length; i <= li; i++) { if (i == li) { @@ -133,7 +133,7 @@ var getLayerPropertyValue = function(layer, key, feature, lod) { case 'boolean': lastValue = lastValue ? 1 : 0; currentValue = lastValue ? 1 : 0; - var newValue = lastValue + (currentValue - lastValue) * ((lod - lastLod) / (currentLod - lastLod)); + newValue = lastValue + (currentValue - lastValue) * ((lod - lastLod) / (currentLod - lastLod)); newValue = newValue > 0.5 ? true : false; break; @@ -141,11 +141,11 @@ var getLayerPropertyValue = function(layer, key, feature, lod) { case 'number': //debugger - var newValue = lastValue + (currentValue - lastValue) * ((lod - lastLod) / (currentLod - lastLod)); + newValue = lastValue + (currentValue - lastValue) * ((lod - lastLod) / (currentLod - lastLod)); break; case 'object': - var newValue = []; + newValue = []; for (var j = 0, lj= lastValue.length; j < lj; j++) { newValue[j] = lastValue[j] + (currentValue[j] - lastValue[j]) * ((lod - lastLod) / (currentLod - lastLod)); @@ -168,8 +168,6 @@ var getLayerPropertyValue = function(layer, key, feature, lod) { return newValue; - break; - case 'number': case 'boolean': return value; @@ -234,11 +232,11 @@ var logError = function(errorType, layerId, key, value, index, subkey) { switch(errorType) { case 'wrong-property-value': - str = 'Error: wrong layer property ' + (subkey ? ('"' + subkey + '"') : '') + ': ' + layerId + '.' + key + ' = ' + value; + str = 'Error: wrong layer property ' + (subkey ? ('\'' + subkey + '\'') : '') + ': ' + layerId + '.' + key + ' = ' + value; break; case 'wrong-property-value[]': - str = 'Error: wrong layer property ' + (subkey ? ('"' + subkey + '"') : '') + '['+index+']: ' + layerId + '.' + key + ' = ' + value; + str = 'Error: wrong layer property ' + (subkey ? ('\'' + subkey + '\'') : '') + '['+index+']: ' + layerId + '.' + key + ' = ' + value; break; case 'wrong-object': @@ -263,12 +261,15 @@ var logError = function(errorType, layerId, key, value, index, subkey) { } if (str) { - console.log(str); + throw str; } }; var validateValue = function(layerId, key, value, type, arrayLength, min, max) { + + var i, li; + //check interpolator if (value != null && (typeof value) == 'object' && (value['discrete'] != null || value['linear'] != null || value['lod-scaled'] != null)) { @@ -315,7 +316,7 @@ var validateValue = function(layerId, key, value, type, arrayLength, min, max) { if (stops != null) { var stopsValueType = null; - for (var i = 0, li = stops.length; i < li; i++) { + for (i = 0, li = stops.length; i < li; i++) { var stopItem = stops[i]; //is stop array[2]? @@ -377,20 +378,15 @@ var validateValue = function(layerId, key, value, type, arrayLength, min, max) { if (key == 'next-pass') { if (Array.isArray(value) && value.length > 0) { - for (var i = 0; i < li; i++) { + for (i = 0; i < li; i++) { var valueItem = value[i]; - if (typeof valueItem == 'object' && + if (!(typeof valueItem == 'object' && Array.isArray(valueItem) && valueItem.length == 2 && typeof valueItem[0] == 'number' && - typeof valueItem[1] == 'string') { - - if (stylesheetLayersData['layers'][valueItem[1]] == null) { + typeof valueItem[1] == 'string')) { - } - - } else { logError('wrong-property-value[]', layerId, key, value, i); return getDefaultLayerPropertyValue(key); } @@ -407,7 +403,7 @@ var validateValue = function(layerId, key, value, type, arrayLength, min, max) { if (Array.isArray(value) && value.length == arrayLength) { //validate array values - var i = 0; + i = 0; if (key == 'icon-source' || key == 'line-style-texture') { if (typeof value[0] != 'string') { @@ -510,64 +506,64 @@ var validateLayerPropertyValue = function(layerId, key, value) { switch(key) { //case "filter" : return validateValue(layerId, key, value, "string"); break; - case 'inherit' : return validateValue(layerId, key, value, 'string'); break; - - case 'line': return validateValue(layerId, key, value, 'boolean'); break; - case 'line-flat': return validateValue(layerId, key, value, 'boolean'); break; - case 'line-width': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; - case 'line-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; - case 'line-style': return validateValue(layerId, key, value, 'string'); break; - case 'line-style-texture': return validateValue(layerId, key, value, 'object', 3, -Number.MAXVALUE, Number.MAXVALUE); break; - case 'line-style-background': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; - - case 'line-label': return validateValue(layerId, key, value, 'boolean'); break; - case 'line-label-source': return validateValue(layerId, key, value, 'string'); break; - case 'line-label-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; - case 'line-label-size': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; - case 'line-label-offset': return validateValue(layerId, key, value, 'number', null, -Number.MAXVALUE, Number.MAXVALUE); break; - - case 'point': return validateValue(layerId, key, value, 'boolean'); break; - case 'point-flat': return validateValue(layerId, key, value, 'boolean'); break; - case 'point-radius': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; - case 'point-Layer': return validateValue(layerId, key, value, 'string'); break; - - case 'point-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; - - case 'icon': return validateValue(layerId, key, value, 'boolean'); break; - case 'icon-source': return validateValue(layerId, key, value, 'object', 5, -Number.MAXVALUE, Number.MAXVALUE); break; - case 'icon-scale': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; - case 'icon-offset': return validateValue(layerId, key, value, 'object', 2, -Number.MAXVALUE, Number.MAXVALUE); break; - case 'icon-origin': return validateValue(layerId, key, value, 'string'); break; - case 'icon-stick': return validateValue(layerId, key, value, 'object', 7, -Number.MAXVALUE, Number.MAXVALUE); break; - case 'icon-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; - - case 'label': return validateValue(layerId, key, value, 'boolean'); break; - case 'label-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); break; - case 'label-source': return validateValue(layerId, key, value, 'string'); break; - case 'label-size': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; - case 'label-offset': return validateValue(layerId, key, value, 'object', 2, -Number.MAXVALUE, Number.MAXVALUE); break; - case 'label-origin': return validateValue(layerId, key, value, 'string'); break; - case 'label-align': return validateValue(layerId, key, value, 'string'); break; - case 'label-stick': return validateValue(layerId, key, value, 'object', 7, -Number.MAXVALUE, Number.MAXVALUE); break; - case 'label-width': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; - - case 'polygon': return validateValue(styleId, key, value, 'boolean'); break; - case 'polygon-color': return validateValue(styleId, key, value, 'object', 4, 0, 255); break; - - case 'z-index': return validateValue(layerId, key, value, 'number', null, -Number.MAXVALUE, Number.MAXVALUE); break; - case 'zbuffer-offset': return validateValue(layerId, key, value, 'object', 3, 0, Number.MAXVALUE); break; - - case 'hover-event': return validateValue(layerId, key, value, 'boolean'); break; - case 'hover-layer': return validateValue(layerId, key, value, 'string'); break; - case 'enter-event': return validateValue(layerId, key, value, 'boolean'); break; - case 'leave-event': return validateValue(layerId, key, value, 'boolean'); break; - case 'click-event': return validateValue(layerId, key, value, 'boolean'); break; - case 'draw-event': return validateValue(layerId, key, value, 'boolean'); break; - - case 'visible': return validateValue(layerId, key, value, 'boolean'); break; - case 'visibility': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); break; - case 'culling': return validateValue(layerId, key, value, 'number', 180, 0.0001, 180); break; - case 'next-pass': return validateValue(layerId, key, value, 'object'); break; + case 'inherit' : return validateValue(layerId, key, value, 'string'); + + case 'line': return validateValue(layerId, key, value, 'boolean'); + case 'line-flat': return validateValue(layerId, key, value, 'boolean'); + case 'line-width': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); + case 'line-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); + case 'line-style': return validateValue(layerId, key, value, 'string'); + case 'line-style-texture': return validateValue(layerId, key, value, 'object', 3, -Number.MAXVALUE, Number.MAXVALUE); + case 'line-style-background': return validateValue(layerId, key, value, 'object', 4, 0, 255); + + case 'line-label': return validateValue(layerId, key, value, 'boolean'); + case 'line-label-source': return validateValue(layerId, key, value, 'string'); + case 'line-label-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); + case 'line-label-size': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); + case 'line-label-offset': return validateValue(layerId, key, value, 'number', null, -Number.MAXVALUE, Number.MAXVALUE); + + case 'point': return validateValue(layerId, key, value, 'boolean'); + case 'point-flat': return validateValue(layerId, key, value, 'boolean'); + case 'point-radius': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); + case 'point-Layer': return validateValue(layerId, key, value, 'string'); + + case 'point-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); + + case 'icon': return validateValue(layerId, key, value, 'boolean'); + case 'icon-source': return validateValue(layerId, key, value, 'object', 5, -Number.MAXVALUE, Number.MAXVALUE); + case 'icon-scale': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); + case 'icon-offset': return validateValue(layerId, key, value, 'object', 2, -Number.MAXVALUE, Number.MAXVALUE); + case 'icon-origin': return validateValue(layerId, key, value, 'string'); + case 'icon-stick': return validateValue(layerId, key, value, 'object', 7, -Number.MAXVALUE, Number.MAXVALUE); + case 'icon-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); + + case 'label': return validateValue(layerId, key, value, 'boolean'); + case 'label-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); + case 'label-source': return validateValue(layerId, key, value, 'string'); + case 'label-size': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); + case 'label-offset': return validateValue(layerId, key, value, 'object', 2, -Number.MAXVALUE, Number.MAXVALUE); + case 'label-origin': return validateValue(layerId, key, value, 'string'); + case 'label-align': return validateValue(layerId, key, value, 'string'); + case 'label-stick': return validateValue(layerId, key, value, 'object', 7, -Number.MAXVALUE, Number.MAXVALUE); + case 'label-width': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); + + case 'polygon': return validateValue(layerId, key, value, 'boolean'); + case 'polygon-color': return validateValue(layerId, key, value, 'object', 4, 0, 255); + + case 'z-index': return validateValue(layerId, key, value, 'number', null, -Number.MAXVALUE, Number.MAXVALUE); + case 'zbuffer-offset': return validateValue(layerId, key, value, 'object', 3, 0, Number.MAXVALUE); + + case 'hover-event': return validateValue(layerId, key, value, 'boolean'); + case 'hover-layer': return validateValue(layerId, key, value, 'string'); + case 'enter-event': return validateValue(layerId, key, value, 'boolean'); + case 'leave-event': return validateValue(layerId, key, value, 'boolean'); + case 'click-event': return validateValue(layerId, key, value, 'boolean'); + case 'draw-event': return validateValue(layerId, key, value, 'boolean'); + + case 'visible': return validateValue(layerId, key, value, 'boolean'); + case 'visibility': return validateValue(layerId, key, value, 'number', null, 0.0001, Number.MAXVALUE); + case 'culling': return validateValue(layerId, key, value, 'number', 180, 0.0001, 180); + case 'next-pass': return validateValue(layerId, key, value, 'object'); } return value; //custom property @@ -640,30 +636,33 @@ var getDefaultLayerPropertyValue = function(key) { function getFilterResult(filter, feature, featureType, group) { + + var result, i, li; + if (!filter || !Array.isArray(filter)) { return false; } switch(filter[0]) { case 'all': - var result = true; - for (var i = 1, li = filter.length; i < li; i++) { + result = true; + for (i = 1, li = filter.length; i < li; i++) { result = result && getFilterResult(filter[i], feature, featureType, group); } return result; case 'any': - var result = false; - for (var i = 1, li = filter.length; i < li; i++) { + result = false; + for (i = 1, li = filter.length; i < li; i++) { result = result || getFilterResult(filter[i], feature, featureType, group); } return result; case 'none': - var result = true; - for (var i = 1, li = filter.length; i < li; i++) { + result = true; + for (i = 1, li = filter.length; i < li; i++) { result = result && getFilterResult(filter[i], feature, featureType, group); } @@ -703,7 +702,7 @@ function getFilterResult(filter, feature, featureType, group) { case '!has': return (typeof value == 'undefined'); case 'in': - for (var i = 2, li = filter.length; i < li; i++) { + for (i = 2, li = filter.length; i < li; i++) { if (filter[i] == value) { return true; } @@ -711,7 +710,7 @@ function getFilterResult(filter, feature, featureType, group) { return false; case '!in': - for (var i = 2, li = filter.length; i < li; i++) { + for (i = 2, li = filter.length; i < li; i++) { if (filter[i] == value) { return false; } @@ -725,6 +724,7 @@ function getFilterResult(filter, feature, featureType, group) { var processLayer = function(layerId, layerData, stylesheetLayersData) { var layer = {}; + var key; //copy Layer and inherit Layer if needed copyLayer(layerId, layer, layerData, stylesheetLayersData); @@ -732,7 +732,7 @@ var processLayer = function(layerId, layerData, stylesheetLayersData) { //console.log(JSON.stringify(layer)); //replace constants and validate properties - for (var key in layer) { + for (key in layer) { var value = layer[key]; @@ -767,6 +767,9 @@ var processLayer = function(layerId, layerData, stylesheetLayersData) { var processStylesheet = function(stylesheetLayersData) { + + var key; + globals.stylesheetBitmaps = {}; globals.stylesheetConstants = stylesheetLayersData['constants'] || {}; @@ -774,7 +777,7 @@ var processStylesheet = function(stylesheetLayersData) { var bitmaps = stylesheetLayersData['bitmaps'] || {}; //build map - for (var key in bitmaps) { + for (key in bitmaps) { var bitmap = bitmaps[key]; var skip = false; @@ -808,7 +811,7 @@ var processStylesheet = function(stylesheetLayersData) { globals.stylesheetLayers = globals.stylesheetData.layers; //process layers - for (var key in layers) { + for (key in layers) { globals.stylesheetData.layers[key] = processLayer(key, layers[key], stylesheetLayersData); //console.log(JSON.stringify(stylesheetData.layers[key])); diff --git a/src/core/map/geodata-processor/worker-text.js b/src/core/map/geodata-processor/worker-text.js index 5fcba93e..816c4c7f 100755 --- a/src/core/map/geodata-processor/worker-text.js +++ b/src/core/map/geodata-processor/worker-text.js @@ -1,11 +1,11 @@ -import {globals as globals_, clamp as clamp_, vec3Normalize as vec3Normalize_, - vec3Length as vec3Length_, vec3Cross as vec3Cross_, vec3AnyPerpendicular as vec3AnyPerpendicular_} from './worker-globals.js'; +import {globals as globals_, vec3Normalize as vec3Normalize_, + vec3Length as vec3Length_, vec3Cross as vec3Cross_} from './worker-globals.js'; //get rid of compiler mess -var globals = globals_, clamp = clamp_, +var globals = globals_, vec3Normalize = vec3Normalize_, vec3Length = vec3Length_, - vec3Cross = vec3Cross_, vec3AnyPerpendicular = vec3AnyPerpendicular_; + vec3Cross = vec3Cross_; var setFont = function(fontData) { @@ -18,16 +18,17 @@ var setFont = function(fontData) { var addChar = function(pos, dir, verticalShift, char, factor, index, index2, textVector, font, vertexBuffer, texcoordsBuffer, flat) { - //normal to dir + + var n; if (globals.geocent && !flat) { - var n = [0,0,0]; + n = [0,0,0]; var nn = [0,0,0]; vec3Normalize(globals.bboxMin, nn); vec3Cross(nn, dir, n); } else { - var n = [-dir[1],dir[0],0]; + n = [-dir[1],dir[0],0]; } var p1 = [pos[0], pos[1], pos[2]]; @@ -181,14 +182,13 @@ var addTextOnPath = function(points, distance, text, size, textVector, font, ver } var p1 = points[0]; - var p2 = points[1]; var chars = font.chars; var factor = size / font.size; var newLineSpace = font.space * factor; var s = [p1[0], p1[1], p1[2]]; - var p1 = [p1[0], p1[1], p1[2]]; + p1 = [p1[0], p1[1], p1[2]]; var l = distance; for (var i = 0, li = text.length; i < li; i++) { From a69d695fc00b5042782757ab2855e2e2be0a7522 Mon Sep 17 00:00:00 2001 From: David Levinsky Date: Fri, 28 Apr 2017 10:35:53 +0200 Subject: [PATCH 3/3] version update --- package.json | 2 +- src/core/core.js | 2 +- src/core/index.js | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b23179a8..9ac6c82f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vts-browser-js", - "version": "2.1.2", + "version": "2.1.3", "description": "JavaScript WebGL 3D maps rendering engine", "main": "src/browser/index.js", "scripts": { diff --git a/src/core/core.js b/src/core/core.js index ce585bf8..31aa38c5 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -465,7 +465,7 @@ string getCoreVersion() */ function getCoreVersion(full) { - return (full ? 'Core: ' : '') + '2.1.2'; + return (full ? 'Core: ' : '') + '2.1.3'; } diff --git a/src/core/index.js b/src/core/index.js index 74dd1d3d..525c7f85 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -4,7 +4,6 @@ import {CoreInterface as CoreInterface_} from './interface'; import {vec2 as vec2_, vec3 as vec3_, vec4 as vec4_, mat3 as mat3_, mat4 as mat4_} from './utils/matrix'; import {utils as utils_} from './utils/utils'; import {math as math_} from './utils/math'; -import {Core as Core_} from './core'; //get rid of compiler mess var getCoreVersion = getCoreVersion_, checkSupport = checkSupport_; @@ -12,7 +11,6 @@ var CoreInterface = CoreInterface_; var vec2 = vec2_, vec3 = vec3_, vec4 = vec4_, mat3 = mat3_, mat4 = mat4_; var utils = utils_; var math = math_; -var Core = Core_; var proj4 = Proj4;