diff --git a/.babelrc b/.babelrc old mode 100644 new mode 100755 diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index bc189033..00000000 --- a/.eslintrc +++ /dev/null @@ -1,29 +0,0 @@ -{ - "ecmaFeatures": { - "globalReturn": true, - "jsx": true, - "modules": true - }, - "env": { - "browser": true, - "es6": true, - "node": true - }, - "globals": { - "document": false, - "escape": false, - "navigator": false, - "unescape": false, - "window": false, - "describe": true, - "before": true, - "it": true, - "expect": true, - "sinon": true - }, - "parser": "babel-eslint", - "plugins": [], - "rules": { - // ... lots of lots of rules here - } -} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md old mode 100644 new mode 100755 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index c13c2c23..48c431ba --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # VTS Browser JS The VTS Browser JS is a *JavaScript WebGL 3D maps rendering engine* used and -developed by Melown SE (http://melown.com) in their products. +developed by Melown Technologies SE (http://melown.com) in their products. The build system uses [webpack module bundler](http://webpack.github.io/). Typical development cycle starts with `npm install` for installation of @@ -61,7 +61,7 @@ The development server is serving local files at node_modules/.bin/webpack-dev-server ``` -And go to [http://localhost:8080/demos/browser/basic/](http://localhost:8080/demos/browser/basic/) +And go to [http://localhost:8080/demos/](http://localhost:8080/demos/) ## Makefile @@ -76,4 +76,4 @@ See the `LICENSE` file for VTS Browser JS license, run `webpack` and check the ## How to contribute -Check the [CONTRIBUTING.md](CONTRIBUTING.md) file. +Check out the [CONTRIBUTING.md](CONTRIBUTING.md) file. diff --git a/demos/basic/demo.js b/demos/basic/demo.js new file mode 100755 index 00000000..1eb320ce --- /dev/null +++ b/demos/basic/demo.js @@ -0,0 +1,13 @@ + +/* Basic example with 3D map */ + +(function startDemo() { + + // create map in the html div with id 'map-div' + // parameter 'map' sets path to the map which will be displayed + // you can create your own map on melown.com + var browser = vts.browser('map-div', { + map: 'https://cdn.melown.com/mario/store/melown2015/map-config/melown/VTS-Tutorial-map/mapConfig.json' + }); + +})(); diff --git a/demos/browser/basic/index.html b/demos/basic/index.html similarity index 63% rename from demos/browser/basic/index.html rename to demos/basic/index.html index 1718ca74..2ba78501 100755 --- a/demos/browser/basic/index.html +++ b/demos/basic/index.html @@ -1,9 +1,9 @@ VTS Browser - Basic - - - + + + diff --git a/demos/browser/basic/demo.js b/demos/browser/basic/demo.js deleted file mode 100755 index 3a3741dc..00000000 --- a/demos/browser/basic/demo.js +++ /dev/null @@ -1,6 +0,0 @@ - -(function startDemo() { - var browser = vts.browser('map-div', { - map: 'https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json' - }); -})(); diff --git a/demos/browser/flights/demo.js b/demos/browser/flights/demo.js deleted file mode 100755 index faedaa16..00000000 --- a/demos/browser/flights/demo.js +++ /dev/null @@ -1,43 +0,0 @@ -var browser = null; -var list = null; - -(function startDemo() { - browser = vts.browser("map-div", { - map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json", - position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 3764, 90 ] - }); - - if (!browser) { - console.log("Your web browser does not support WebGL"); - return; - } - - var panel = browser.ui.addControl("destination-panel", - '
' + - ' Destination A
' + - ' Destination B
' + - ' Destination C' + - '
'); - - list = panel.getElement("panel"); - list.on("change", onFlyToNewDestination); -})(); - - -function onFlyToNewDestination() { - if (browser.map) { //check whether map is loaded - switch (list.getElement().elements["destination"].value) { - case "a": - browser.autopilot.flyTo([ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 1764, 90 ]); - break; - - case "b": - browser.autopilot.flyTo([ "obj", 1679084, 6607401, "float", 0, -17, -57, 0, 1158, 90 ]); - break; - - case "c": - browser.autopilot.flyTo([ "obj", 1694920, 6608430, "float", 0, -24, -76, 0, 2049, 90 ]); - break; - } - } -} diff --git a/demos/browser/hit-surface/demo.js b/demos/browser/hit-surface/demo.js deleted file mode 100755 index bcbb23f0..00000000 --- a/demos/browser/hit-surface/demo.js +++ /dev/null @@ -1,85 +0,0 @@ -var browser = null; -var map = null; -var renderer = null; -var pointTexture = null; -var clickCoords = null; - - -(function startDemo() { - browser = vts.browser("map-div", { - map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json", - position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 964, 90 ] - }); - - if (!browser) { - console.log("Your web browser does not support WebGL"); - return; - } - - renderer = browser.renderer; - - //callback once is map config loaded - browser.on("map-loaded", onMapLoaded); - - //add mouse down callback - browser.ui.getMapElement().on('mousedown', onMouseDown); - - loadTexture(); -})(); - - -function loadTexture() { - //load icon used for displaing hit point - var pointImage = vts.utils.loadImage( - "http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png", - (function(){ - pointTexture = renderer.createTexture({ "source": pointImage }); - }).bind(this) - ); -} - - -function onMapLoaded() { - //add render slots - //render slots are called during map render - map = browser.map; - map.addRenderSlot("custom-points", onDrawPoints, true); - map.moveRenderSlotAfter("after-map-render", "custom-points"); -} - - -function onMouseDown(event) { - if (event.getMouseButton() == "left") { - var coords = event.getMouseCoords(); - - //get hit coords with fixed height - clickCoords = map.getHitCoords(coords[0], coords[1], "fixed"); - - //force map redraw to display hit point - map.redraw(); - } -} - - -function onDrawPoints(renderChannel) { - if (renderChannel == "hit") { - return; //do render points in to the hit texture - } - - if (clickCoords) { //draw hit point - //conver hit coords to canvas coords - coords = map.convertCoordsFromNavToCanvas(clickCoords, "fixed"); - - renderer.drawImage({ - "rect" : [coords[0]-12, coords[1]-12, 24, 24], - "texture" : pointTexture, - "color" : [255,0,0,255], - "depth" : coords[2], - "depth-test" : false, - "blend" : true - }); - } -}; - - - diff --git a/demos/browser/lines-and-images/demo.js b/demos/browser/lines-and-images/demo.js deleted file mode 100755 index f3b1ac76..00000000 --- a/demos/browser/lines-and-images/demo.js +++ /dev/null @@ -1,79 +0,0 @@ -var browser = null; -var renderer = null; -var map = null; - -(function startDemo() { - browser = vts.browser("map-div", { - map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json", - position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 1764, 90 ] - }); - - if (!browser) { - console.log("Your web browser does not support WebGL"); - return; - } - - renderer = browser.renderer; - - browser.on("map-loaded", onMapLoaded); - loadImage(); -})(); - - -var demoTexture = null; - - -function loadImage() { - var demoImage = vts.utils.loadImage( - "http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png", - (function(){ - demoTexture = renderer.createTexture({ "source": demoImage }); - })); -} - - -function onMapLoaded() { - map = browser.map; - map.addRenderSlot("custom-render", onCustomRender, true); - map.moveRenderSlotAfter("after-map-render", "custom-render"); -}; - - -function onCustomRender() { - if (demoTexture) { - var coords = map.convertCoordsFromNavToCanvas([1683559, 6604129, 0], "float"); - - var totalPoints = 32; - var points = new Array(totalPoints); - var p = [1683559, 6604129, 0]; - var scale = [400, 100]; - - for (var i = 0; i < totalPoints; i++) { - points[i] = map.convertCoordsFromNavToCanvas( - [p[0] + (i / totalPoints) * scale[0], - p[1] + Math.sin(2 * Math.PI * (i / totalPoints)) * scale[1], - p[2]], "float"); - } - - renderer.drawLineString({ - "points" : points, - "size" : 2.0, - "color" : [255,0,255,255], - "depth-test" : false, - "blend" : false - }); - - - renderer.drawImage({ - "rect" : [coords[0]-12, coords[1]-12, 24, 24], - "texture" : demoTexture, - "color" : [255,0,255,255], - "depth" : coords[2], - "depth-test" : false, - "blend" : true - }); - } -} - - - diff --git a/demos/browser/view-switch/demo.js b/demos/browser/view-switch/demo.js deleted file mode 100755 index e6bc458b..00000000 --- a/demos/browser/view-switch/demo.js +++ /dev/null @@ -1,46 +0,0 @@ -var browser = null; -var button = null; -var map = null; - - -(function startDemo() { - browser = vts.browser("map-div", { - map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json" - }); - - if (!browser) { - console.log("Your web browser does not support WebGL"); - return; - } - - var panel = browser.ui.addControl("view-panel", - '
' + - ' Base Map' + - '
'); - - button = panel.getElement("switch"); - button.on("change", onSwitchView); -})(); - - -function onSwitchView() { - if (browser.map) { //check whether map is loaded - if (button.getElement().checked) { - browser.map.setView({ - "surfaces": { - "grand": [], - "ev": [ "mapycz-base" ] - }, - "freelayers": [] - }); - } else { - browser.map.setView({ - "surfaces": { - "grand": [], - "ev": [] - }, - "freelayers": [] - }); - } - } -} diff --git a/demos/core/basic/demo.js b/demos/core/demo.js similarity index 71% rename from demos/core/basic/demo.js rename to demos/core/demo.js index baa039d5..c4d2515b 100755 --- a/demos/core/basic/demo.js +++ b/demos/core/demo.js @@ -4,28 +4,29 @@ var isMapProjected = false; (function startDemo() { - //check vadstena support (webgl) + //check vts-core support (webgl) if (!vts.checkSupport()) { - alert("VTS browser needs web browser with WebGL support."); + alert('VTS browser needs web browser with WebGL support.'); return; } - //init melown core - core = vts.core("map-div", { - map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json" - + // create map in the html div with id 'map-div' + // parameter 'map' sets path to the map which will be displayed + // you can create your own map on melown.com + core = vts.core('map-div', { + map: 'https://cdn.melown.com/mario/store/melown2015/map-config/melown/VTS-Tutorial-map/mapConfig.json' }); //callback once is map config loaded - core.on("map-loaded", onMapLoaded); + core.on('map-loaded', onMapLoaded); - //mouse events + //set mouse events callbacks document.onmousedown = onMouseDown; document.oncontextmenu = (function(){ return false;}); document.onmouseup = onMouseUp; document.onmousemove = onMouseMove; - window.addEventListener("DOMMouseScroll", onMouseWheel, true); - window.addEventListener("mousewheel", onMouseWheel, true); + window.addEventListener('DOMMouseScroll', onMouseWheel, true); + window.addEventListener('mousewheel', onMouseWheel, true); document.onselectstart = function(){ return false; }; //removes text cusor during draging })(); @@ -34,8 +35,8 @@ function onMapLoaded() { map = core.map; //check whether is map projected (used for navigation) var rf = map.getReferenceFrame(); - var srs = map.getSrsInfo(rf["navigationSrs"]); - isMapProjected = (srs) ? (srs["type"] == "projected") : false; + var srs = map.getSrsInfo(rf.navigationSrs); + isMapProjected = (srs) ? (srs.type == 'projected') : false; } @@ -98,22 +99,28 @@ function onMouseMove(event) { var pos = map.getPosition(); if (mouseLeftDown) { //pan + + //pan sensitivity + var sensitivity = 2; + //sensitivity have to be also + //affected by zoom (view extent) and fov + //get zoom factor - var sensitivity = 0.5; var viewExtent = pos.getViewExtent(); - var fov = pos.getFov()*0.5; - var zoomFactor = ((viewExtent * Math.tan(vts.math.radians(fov))) / 800) * sensitivity; - - //apply factor to deltas - dx *= zoomFactor; - dy *= zoomFactor; - + var fov = pos.getFov(); + var zoomFactor = ((viewExtent * Math.tan(vts.math.radians(fov*0.5))) / 800) * sensitivity; + + //get fov factor + var fovCorrection = (fov > 0.01 && fov < 179) ? (1.0 / Math.tan(vts.math.radians(fov*0.5))) : 1.0; + //get azimuth and distance - var distance = Math.sqrt(dx*dx + dy*dy); - var azimuth = vts.math.degrees(Math.atan2(dx, dy)) + pos.getOrientation()[0]; + //apply zoon a fov factors to distance + //distance means how far we move in direction of azimut + var distance = Math.sqrt(dx*dx + dy*dy) * zoomFactor * fovCorrection; + var azimuth = vts.math.degrees(Math.atan2(dx, dy)) - pos.getOrientation()[0]; - //move position + //move to new position pos = map.movePositionCoordsTo(pos, (isMapProjected ? 1 : -1) * azimuth, distance); pos = reduceFloatingHeight(pos, 0.8); map.setPosition(pos); @@ -123,7 +130,7 @@ function onMouseMove(event) { var orientation = pos.getOrientation(); var sensitivity_ = 0.4; - orientation[0] -= dx * sensitivity_; + orientation[0] += dx * sensitivity_; orientation[1] -= dy * sensitivity_; pos = pos.setOrientation(orientation); diff --git a/demos/core/hit-surface/demo.js b/demos/core/hit-surface/demo.js deleted file mode 100755 index 89da4ae2..00000000 --- a/demos/core/hit-surface/demo.js +++ /dev/null @@ -1,239 +0,0 @@ -var core = null; -var map = null; -var renderer = null; -var pointTexture = null; -var clickCoords = null; -var isMapProjected = false; - - -(function startDemo() { - //check vadstena support (webgl) - if (!vts.checkSupport()) { - alert("VTS browser needs web browser with WebGL support."); - return; - } - - //init melown core - core = vts.core("map-div", { - map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json", - position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 964, 90 ] - }); - - renderer = core.renderer; - - //callback once is map config loaded - core.on("map-loaded", onMapLoaded); - - //load icon used for displaing hit point - var pointImage = vts.utils.loadImage( - "http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png", - (function(){ - pointTexture = renderer.createTexture({ "source": pointImage }); - }).bind(this) - ); - - //mouse events - document.onmousedown = onMouseDown; - document.oncontextmenu = (function(){ return false;}); - document.onmouseup = onMouseUp; - document.onmousemove = onMouseMove; - window.addEventListener("DOMMouseScroll", onMouseWheel, true); - window.addEventListener("mousewheel", onMouseWheel, true); - document.onselectstart = function(){ return false; }; //removes text cusor during draging -})(); - - -function onMapLoaded() { - map = core.map; - //add render slot - //render slot is called during map render - map.addRenderSlot("custom-points", onDrawPoints, true); - map.moveRenderSlotAfter("after-map-render", "custom-points"); - - //check whether is map projected (used for navigation) - var rf = map.getReferenceFrame(); - var srs = map.getSrsInfo(rf["navigationSrs"]); - isMapProjected = (srs) ? (srs["type"] == "projected") : false; -} - - -function onDrawPoints(renderChannel) { - if (renderChannel == "hit") { - return; //do render points in to the hit texture - } - - if (clickCoords) { //draw hit point - //conver hit coords to canvas coords - coords = map.convertCoordsFromNavToCanvas(clickCoords, "fixed"); - - renderer.drawImage({ - "rect" : [coords[0]-12, coords[1]-12, 24, 24], - "texture" : pointTexture, - "color" : [255,0,0,255], - "depth" : coords[2], - "depth-test" : false, - "blend" : true - }); - } -}; - - -//mouse events -var mouseRightDown = false; -var mouseLeftDown = false; - -var mouseLx = 0; -var mouseLy = 0; - - -function onMouseDown(event) { - var right = false; - var e = event || window.event; - - if (e.which) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera - right = e.which == 3; - } else if (e.button) { // IE, Opera - right = e.button == 2; - } - - if (right == true) { - mouseRightDown = true; - } else { - mouseLeftDown = true; - } - - if (map && !right) { - var x = event.clientX; - var y = event.clientY; - - //get hit coords with fixed height - clickCoords = map.getHitCoords(x, y, "fixed"); - - //force map redraw to display hit point - map.redraw(); - } -} - - -function onMouseUp(event) { - var right = false; - var e = event || window.event; - - if (e.which) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera - right = e.which == 3; - } else if (e.button) { // IE, Opera - right = e.button == 2; - } - - if (right == true) { - mouseRightDown = false; - } else { - mouseLeftDown = false; - } -} - - -function onMouseMove(event) { - //get mouse coords - var x = event.clientX; - var y = event.clientY; - //get mouse deltas - var dx = (x - mouseLx); - var dy = (y - mouseLy); - //store coords - mouseLx = x; - mouseLy = y; - - if (map) { - var pos = map.getPosition(); - - if (mouseLeftDown) { //pan - - //get zoom factor - var sensitivity = 0.5; - var viewExtent = pos.getViewExtent(); - var fov = pos.getFov()*0.5; - var zoomFactor = ((viewExtent * Math.tan(vts.math.radians(fov))) / 800) * sensitivity; - - //apply factor to deltas - dx *= zoomFactor; - dy *= zoomFactor; - - //get azimuth and distance - var distance = Math.sqrt(dx*dx + dy*dy); - var azimuth = vts.math.degrees(Math.atan2(dx, dy)) + pos.getOrientation()[0]; - - //move position - pos = map.movePositionCoordsTo(pos, (isMapProjected ? 1 : -1) * azimuth, distance); - pos = reduceFloatingHeight(pos, 0.8); - map.setPosition(pos); - - } else if (mouseRightDown) { //rotate - - var orientation = pos.getOrientation(); - - var sensitivity_ = 0.4; - orientation[0] -= dx * sensitivity_; - orientation[1] -= dy * sensitivity_; - - pos = pos.setOrientation(orientation); - map.setPosition(pos); - } - } -} - - -function onMouseWheel(event) { - if (event.preventDefault) { - event.preventDefault(); - } - - event.returnValue = false; - - var delta = 0; - - if (event.wheelDelta) { - delta = event.wheelDelta / 120; - } - if (event.detail) { - delta = -event.detail / 3; - } - - if (isNaN(delta) == true) { - delta = 0; - } - - if (map) { - var pos = map.getPosition(); - - var viewExtent = pos.getViewExtent(); - - viewExtent *= 1.0 + (delta > 0 ? -1 : 1)*0.05; - - pos = pos.setViewExtent(viewExtent); - pos = reduceFloatingHeight(pos, 0.8); - map.setPosition(pos); - } -} - - -//used to to gradually reduce relative height over terrain -function reduceFloatingHeight(pos, factor) { - if (pos.getHeightMode() == "float" && - pos.getViewMode() == "obj") { - - var coords = pos.getCoords(); - if (coords[2] != 0) { - coords[2] *= factor; - - if (Math.abs(coords[2]) < 0.1) { - coords[2] = 0; - } - - pos.setCoords(coords); - } - } - - return pos; -}; - diff --git a/demos/core/basic/index.html b/demos/core/index.html similarity index 77% rename from demos/core/basic/index.html rename to demos/core/index.html index 38ba7e97..1d664a86 100755 --- a/demos/core/basic/index.html +++ b/demos/core/index.html @@ -1,8 +1,8 @@ VTS Browser - Basic - - + + diff --git a/demos/core/lines-and-images/demo.js b/demos/core/lines-and-images/demo.js deleted file mode 100755 index 7bad688f..00000000 --- a/demos/core/lines-and-images/demo.js +++ /dev/null @@ -1,273 +0,0 @@ -var core = null; -var map = null; -var renderer = null; -var demoTexture = null; -var isMapProjected = false; - - -(function startDemo() { - //check vadstena support (webgl) - if (!vts.checkSupport()) { - alert("VTS browser needs web browser with WebGL support."); - return; - } - - //init melown core - core = vts.core("map-div", { - map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json", - position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 1764, 90 ], - view : { - "surfaces": { - "grand": [], - "ev": [] - }, - "freelayers": [] - } - }); - - renderer = core.renderer; - - core.on("map-loaded", onMapLoaded); - - //load image - var demoImage = vts.utils.loadImage( - "http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png", - (function(){ - demoTexture = renderer.createTexture({ "source": demoImage }); - }).bind(this) - ); - - //mouse events - document.onmousedown = onMouseDown; - document.oncontextmenu = (function(){ return false;}); - document.onmouseup = onMouseUp; - document.onmousemove = onMouseMove; - window.addEventListener("DOMMouseScroll", onMouseWheel, true); - window.addEventListener("mousewheel", onMouseWheel, true); - document.onselectstart = function(){ return false; }; //removes text cusor during draging - - document.getElementById('switch').onchange = function() {switchMap();} -})(); - - -function onMapLoaded() { - map = core.map; - map.addRenderSlot("custom-render", onCustomRender, true); - map.moveRenderSlotAfter("after-map-render", "custom-render"); - - //check whether is map projected (used for navigation) - var rf = map.getReferenceFrame(); - var srs = map.getSrsInfo(rf["navigationSrs"]); - isMapProjected = (srs) ? (srs["type"] == "projected") : false; -}; - - -function onCustomRender() { - if (demoTexture) { - var coords = map.convertCoordsFromNavToCanvas([1683559, 6604129, 0], "float"); - - var totalPoints = 32; - var points = new Array(totalPoints); - var p = [1683559, 6604129, 0]; - var scale = [400, 100]; - - for (var i = 0; i < totalPoints; i++) { - points[i] = map.convertCoordsFromNavToCanvas( - [p[0] + (i / totalPoints) * scale[0], - p[1] + Math.sin(2 * Math.PI * (i / totalPoints)) * scale[1], - p[2]], "float"); - } - - renderer.drawLineString({ - "points" : points, - "size" : 2.0, - "color" : [255,0,255,255], - "depth-test" : false, - "blend" : false - }); - - - renderer.drawImage({ - "rect" : [coords[0]-12, coords[1]-12, 24, 24], - "texture" : demoTexture, - "color" : [255,0,255,255], - "depth" : coords[2], - "depth-test" : false, - "blend" : true - }); - } -} - - -function switchMap() { - if (map) { - if (document.getElementById("switch").checked) { - map.setView({ - "surfaces": { - "grand": [], - "ev": [ "mapycz-base" ] - }, - "freelayers": [] - }); - } else { - map.setView({ - "surfaces": { - "grand": [], - "ev": [] - }, - "freelayers": [] - }); - } - } -} - - -//mouse events -var mouseRightDown = false; -var mouseLeftDown = false; - -var mouseLx = 0; -var mouseLy = 0; - - -function onMouseDown(event) { - var right = false; - var e = event || window.event; - - if (e.which) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera - right = e.which == 3; - } else if (e.button) { // IE, Opera - right = e.button == 2; - } - - if (right == true) { - mouseRightDown = true; - } else { - mouseLeftDown = true; - } -} - - -function onMouseUp(event) { - var right = false; - var e = event || window.event; - - if (e.which) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera - right = e.which == 3; - } else if (e.button) { // IE, Opera - right = e.button == 2; - } - - if (right == true) { - mouseRightDown = false; - } else { - mouseLeftDown = false; - } -} - - -function onMouseMove(event) { - //get mouse coords - var x = event.clientX; - var y = event.clientY; - //get mouse deltas - var dx = (x - mouseLx); - var dy = (y - mouseLy); - //store coords - mouseLx = x; - mouseLy = y; - - if (map) { - var pos = map.getPosition(); - - if (mouseLeftDown) { //pan - - //get zoom factor - var sensitivity = 0.5; - var viewExtent = pos.getViewExtent(); - var fov = pos.getFov()*0.5; - var zoomFactor = ((viewExtent * Math.tan(vts.math.radians(fov))) / 800) * sensitivity; - - //apply factor to deltas - dx *= zoomFactor; - dy *= zoomFactor; - - //get azimuth and distance - var distance = Math.sqrt(dx*dx + dy*dy); - var azimuth = vts.math.degrees(Math.atan2(dx, dy)) + pos.getOrientation()[0]; - - //move position - pos = map.movePositionCoordsTo(pos, (isMapProjected ? 1 : -1) * azimuth, distance); - pos = reduceFloatingHeight(pos, 0.8); - map.setPosition(pos); - - } else if (mouseRightDown) { //rotate - - var orientation = pos.getOrientation(); - - var sensitivity_ = 0.4; - orientation[0] -= dx * sensitivity_; - orientation[1] -= dy * sensitivity_; - - pos = pos.setOrientation(orientation); - map.setPosition(pos); - } - } -} - - -function onMouseWheel(event) { - if (event.preventDefault) { - event.preventDefault(); - } - - event.returnValue = false; - - var delta = 0; - - if (event.wheelDelta) { - delta = event.wheelDelta / 120; - } - if (event.detail) { - delta = -event.detail / 3; - } - - if (isNaN(delta) == true) { - delta = 0; - } - - if (map) { - var pos = map.getPosition(); - - var viewExtent = pos.getViewExtent(); - - viewExtent *= 1.0 + (delta > 0 ? -1 : 1)*0.05; - - pos = pos.setViewExtent(viewExtent); - pos = reduceFloatingHeight(pos, 0.8); - map.setPosition(pos); - } -} - - -//used to to gradually reduce relative height over terrain -function reduceFloatingHeight(pos, factor) { - if (pos.getHeightMode() == "float" && - pos.getViewMode() == "obj") { - - var coords = pos.getCoords(); - if (coords[2] != 0) { - coords[2] *= factor; - - if (Math.abs(coords[2]) < 0.1) { - coords[2] = 0; - } - - pos.setCoords(coords); - } - } - - return pos; -}; - - diff --git a/demos/core/lines-and-images/index.html b/demos/core/lines-and-images/index.html deleted file mode 100755 index ea41837a..00000000 --- a/demos/core/lines-and-images/index.html +++ /dev/null @@ -1,31 +0,0 @@ - - - VTS Browser - Lines and Images - - - - - - - -
-
- -
- Base Map -
- - - - diff --git a/demos/core/meshes-hit-test/demo.js b/demos/core/meshes-hit-test/demo.js deleted file mode 100755 index 3f9819ee..00000000 --- a/demos/core/meshes-hit-test/demo.js +++ /dev/null @@ -1,385 +0,0 @@ -var core = null; -var map = null; -var renderer = null; -var woodTexture = null; -var pointTexture = null; -var cubeMesh = null; -var clickCoords = null; -var isMapProjected = false; - -(function startDemo() { - //check vadstena support (webgl) - if (!vts.checkSupport()) { - alert("VTS browser needs web browser with WebGL support."); - return; - } - - //init melown core - core = vts.core("map-div", { - map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json", - position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 964, 90 ] - }); - - renderer = core.renderer; - - //callback once is map config loaded - core.on("map-loaded", onMapLoaded); - - loadTextrures(); - - //create cube mesh - createCube(); - - //mouse events - document.onmousedown = onMouseDown; - document.oncontextmenu = (function(){ return false;}); - document.onmouseup = onMouseUp; - document.onmousemove = onMouseMove; - window.addEventListener("DOMMouseScroll", onMouseWheel, true); - window.addEventListener("mousewheel", onMouseWheel, true); - document.onselectstart = function(){ return false; }; //removes text cusor during draging -})(); - -function loadTextrures() { - //load texture used for cubes - var woodImage = vts.utils.loadImage("./wood.png", - (function(){ - woodTexture = renderer.createTexture({ "source": woodImage }); - }).bind(this) - ); - - //load icon used for displaing hit point - var pointImage = vts.utils.loadImage( - "http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png", - (function(){ - pointTexture = renderer.createTexture({ "source": pointImage }); - }).bind(this) - ); -} - -function createCube() { - var vertices = [ 1,1,1, -1,1,1, -1,-1,1, //top - -1,-1,1, 1,-1,1, 1,1,1, - - -1,1,-1, 1,1,-1, 1,-1,-1, //bottom - 1,-1,-1, -1,-1,-1, -1,1,-1, - - 1,-1,1, -1,-1,1, -1,-1,-1, //front - -1,-1,-1, 1,-1,-1, 1,-1,1, - - -1,1,1, 1,1,1, 1,1,-1, //back - 1,1,-1, -1,1,-1, -1,1,1, - - -1,-1,1, -1,1,1, -1,1,-1, //left - -1,1,-1, -1,-1,-1, -1,-1,1, - - 1,1,1, 1,-1,1, 1,-1,-1, //right - 1,-1,-1, 1,1,-1, 1,1,1 ]; - - var uvs = [ 0,0, 1,0, 1,1, //top - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //bottom - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //front - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //back - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //left - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //right - 1,1, 0,1, 0,0 ]; - - var normals = [ 0,0,1, 0,0,1, 0,0,1, //top - 0,0,1, 0,0,1, 0,0,1, - - 0,0,-1, 0,0,-1, 0,0,-1, //bottom - 0,0,-1, 0,0,-1, 0,0,-1, - - 0,-1,0, 0,-1,0, 0,-1,0, //front - 0,-1,0, 0,-1,0, 0,-1,0, - - 0,1,0, 0,1,0, 0,1,0, //back - 0,1,0, 0,1,0, 0,1,0, - - -1,0,0, -1,0,0, -1,0,0, //left - -1,0,0, -1,0,0, -1,0,0, - - 1,0,0, 1,0,0, 1,0,0, //right - 1,0,0, 1,0,0, 1,0,0 ]; - - cubeMesh = renderer.createMesh({ "vertices": vertices, "uvs": uvs, "normals": normals }); -} - -function drawCube(coords, scale, ambientColor, diffuseColor, specularColor, shininess, shader) { - var cameInfo = map.getCameraInfo(); - - //matrix which tranforms mesh position and scale - var mv = [ - scale, 0, 0, 0, - 0, scale, 0, 0, - 0, 0, scale, 0, - coords[0], coords[1], coords[2] + scale, 1 - ]; - - //setup material - var material = [ - ambientColor[0], ambientColor[1], ambientColor[2], 0, - diffuseColor[0], diffuseColor[1], diffuseColor[2], 0, - specularColor[0], specularColor[1], specularColor[2], 0, - shininess, 0, 0, 0 - ]; - - //multiply cube matrix with camera view matrix - vts.mat4.multiply(cameInfo["view-matrix"], mv, mv); - - var norm = [ - 0,0,0, - 0,0,0, - 0,0,0 - ]; - - //extract normal transformation matrix from model view matrix - vts.mat4.toInverseMat3(mv, norm); - - //draw cube - renderer.drawMesh({ - "mesh" : cubeMesh, - "texture" : woodTexture, - "shader" : shader, - "shader-variables" : { - "uMV" : ["mat4", mv], - "uNorm" : ["mat3", norm], - "uMaterial" : ["mat4", material] - } - }); -} - - -function onMapLoaded() { - map = core.map; - //add render slots - //render slots are called during map render - map.addRenderSlot("custom-meshes", onDrawMeshes, true); - map.addRenderSlot("custom-points", onDrawPoints, true); - map.moveRenderSlotAfter("after-map-render", "custom-meshes"); - map.moveRenderSlotAfter("custom-meshes", "custom-points"); - - //check whether is map projected (used for navigation) - var rf = map.getReferenceFrame(); - var srs = map.getSrsInfo(rf["navigationSrs"]); - isMapProjected = (srs) ? (srs["type"] == "projected") : false; -} - -function onDrawMeshes(renderChannel) { - if (woodTexture) { - var coords, shader; - - //draw textured cubes - shader = (renderChannel == "hit") ? "hit" : "textured-and-shaded"; - - coords = map.convertCoordsFromNavToCameraSpace([1683559, 6604129, 0], "float"); - drawCube(coords, 50, [255,128,128], [0,0,0], [0,0,0], 0, shader); - - coords = map.convertCoordsFromNavToCameraSpace([1683559+150, 6604129, 0], "float"); - drawCube(coords, 50, [0,0,0], [255,128,128], [0,0,0], 0, shader); - - coords = map.convertCoordsFromNavToCameraSpace([1683559+300, 6604129, 0], "float"); - drawCube(coords, 50, [0,0,0], [255,128,128], [255,255,255], 90, shader); - - //draw cubes without textures - shader = (renderChannel == "hit") ? "hit" : "shaded"; - - coords = map.convertCoordsFromNavToCameraSpace([1683559, 6604129+200, 0], "float"); - drawCube(coords, 50, [255,128,128], [0,0,0], [0,0,0], 0, shader); - - coords = map.convertCoordsFromNavToCameraSpace([1683559+150, 6604129+200, 0], "float"); - drawCube(coords, 50, [0,0,0], [255,128,128], [0,0,0], 0, shader); - - coords = map.convertCoordsFromNavToCameraSpace([1683559+300, 6604129+200, 0], "float"); - drawCube(coords, 50, [0,0,0], [255,128,128], [255,255,255], 90, shader); - } -} - -function onDrawPoints(renderChannel) { - if (renderChannel == "hit") { - return; //do render points in to the hit texture - } - - if (clickCoords) { //draw hit point - //conver hit coords to canvas coords - coords = map.convertCoordsFromNavToCanvas(clickCoords, "fixed"); - - renderer.drawImage({ - "rect" : [coords[0]-12, coords[1]-12, 24, 24], - "texture" : pointTexture, - "color" : [255,0,0,255], - "depth" : coords[2], - "depth-test" : false, - "blend" : true - }); - } -}; - -//mouse events -var mouseRightDown = false; -var mouseLeftDown = false; - -var mouseLx = 0; -var mouseLy = 0; - -function onMouseDown(event) { - var right = false; - var e = event || window.event; - - if (e.which) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera - right = e.which == 3; - } else if (e.button) { // IE, Opera - right = e.button == 2; - } - - if (right == true) { - mouseRightDown = true; - } else { - mouseLeftDown = true; - } - - if (map && !right) { - var x = event.clientX; - var y = event.clientY; - - //get hit coords with fixed height - clickCoords = map.getHitCoords(x, y, "fixed"); - - //force map redraw to display hit point - map.redraw(); - } -} - - -function onMouseUp(event) { - var right = false; - var e = event || window.event; - - if (e.which) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera - right = e.which == 3; - } else if (e.button) { // IE, Opera - right = e.button == 2; - } - - if (right == true) { - mouseRightDown = false; - } else { - mouseLeftDown = false; - } -} - - -function onMouseMove(event) { - //get mouse coords - var x = event.clientX; - var y = event.clientY; - //get mouse deltas - var dx = (x - mouseLx); - var dy = (y - mouseLy); - //store coords - mouseLx = x; - mouseLy = y; - - if (map) { - var pos = map.getPosition(); - - if (mouseLeftDown) { //pan - - //get zoom factor - var sensitivity = 0.5; - var viewExtent = pos.getViewExtent(); - var fov = pos.getFov()*0.5; - var zoomFactor = ((viewExtent * Math.tan(vts.math.radians(fov))) / 800) * sensitivity; - - //apply factor to deltas - dx *= zoomFactor; - dy *= zoomFactor; - - //get azimuth and distance - var distance = Math.sqrt(dx*dx + dy*dy); - var azimuth = vts.math.degrees(Math.atan2(dx, dy)) + pos.getOrientation()[0]; - - //move position - pos = map.movePositionCoordsTo(pos, (isMapProjected ? 1 : -1) * azimuth, distance); - pos = reduceFloatingHeight(pos, 0.8); - map.setPosition(pos); - - } else if (mouseRightDown) { //rotate - - var orientation = pos.getOrientation(); - - var sensitivity_ = 0.4; - orientation[0] -= dx * sensitivity_; - orientation[1] -= dy * sensitivity_; - - pos = pos.setOrientation(orientation); - map.setPosition(pos); - } - - - } -} - -function onMouseWheel(event) { - if (event.preventDefault) { - event.preventDefault(); - } - - event.returnValue = false; - - var delta = 0; - - if (event.wheelDelta) { - delta = event.wheelDelta / 120; - } - if (event.detail) { - delta = -event.detail / 3; - } - - if (isNaN(delta) == true) { - delta = 0; - } - - if (map) { - var pos = map.getPosition(); - - var viewExtent = pos.getViewExtent(); - - viewExtent *= 1.0 + (delta > 0 ? -1 : 1)*0.05; - - pos = pos.setViewExtent(viewExtent); - pos = reduceFloatingHeight(pos, 0.8); - map.setPosition(pos); - } -} - -//used to to gradually reduce relative height over terrain -function reduceFloatingHeight(pos, factor) { - if (pos.getHeightMode() == "float" && - pos.getViewMode() == "obj") { - - var coords = pos.getCoords(); - if (coords[2] != 0) { - coords[2] *= factor; - - if (Math.abs(coords[2]) < 0.1) { - coords[2] = 0; - } - - pos.setCoords(coords); - } - } - - return pos; -}; - diff --git a/demos/core/meshes/demo.js b/demos/core/meshes/demo.js deleted file mode 100755 index 901272ce..00000000 --- a/demos/core/meshes/demo.js +++ /dev/null @@ -1,340 +0,0 @@ -var core = null; -var map = null; -var renderer = null; -var woodTexture = null; -var cubeMesh = null; -var isMapProjected = false; - -(function startDemo() { - //check vadstena support (webgl) - if (!vts.checkSupport()) { - alert("VTS browser needs web browser with WebGL support."); - return; - } - - //init melown core - core = vts.core("map-div", { - map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json", - position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 964, 90 ] - }); - - renderer = core.renderer; - - //callback once is map config loaded - core.on("map-loaded", onMapLoaded); - - //load texture used for cubes - var woodImage = vts.utils.loadImage("./wood.png", - (function(){ - woodTexture = renderer.createTexture({ "source": woodImage }); - }).bind(this) - ); - - - //create cube mesh - createCube(); - - //mouse events - document.onmousedown = onMouseDown; - document.oncontextmenu = (function(){ return false;}); - document.onmouseup = onMouseUp; - document.onmousemove = onMouseMove; - window.addEventListener("DOMMouseScroll", onMouseWheel, true); - window.addEventListener("mousewheel", onMouseWheel, true); - document.onselectstart = function(){ return false; }; //removes text cusor during draging -})(); - - -function createCube() { - var vertices = [ 1,1,1, -1,1,1, -1,-1,1, //top - -1,-1,1, 1,-1,1, 1,1,1, - - -1,1,-1, 1,1,-1, 1,-1,-1, //bottom - 1,-1,-1, -1,-1,-1, -1,1,-1, - - 1,-1,1, -1,-1,1, -1,-1,-1, //front - -1,-1,-1, 1,-1,-1, 1,-1,1, - - -1,1,1, 1,1,1, 1,1,-1, //back - 1,1,-1, -1,1,-1, -1,1,1, - - -1,-1,1, -1,1,1, -1,1,-1, //left - -1,1,-1, -1,-1,-1, -1,-1,1, - - 1,1,1, 1,-1,1, 1,-1,-1, //right - 1,-1,-1, 1,1,-1, 1,1,1 ]; - - var uvs = [ 0,0, 1,0, 1,1, //top - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //bottom - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //front - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //back - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //left - 1,1, 0,1, 0,0, - - 0,0, 1,0, 1,1, //right - 1,1, 0,1, 0,0 ]; - - var normals = [ 0,0,1, 0,0,1, 0,0,1, //top - 0,0,1, 0,0,1, 0,0,1, - - 0,0,-1, 0,0,-1, 0,0,-1, //bottom - 0,0,-1, 0,0,-1, 0,0,-1, - - 0,-1,0, 0,-1,0, 0,-1,0, //front - 0,-1,0, 0,-1,0, 0,-1,0, - - 0,1,0, 0,1,0, 0,1,0, //back - 0,1,0, 0,1,0, 0,1,0, - - -1,0,0, -1,0,0, -1,0,0, //left - -1,0,0, -1,0,0, -1,0,0, - - 1,0,0, 1,0,0, 1,0,0, //right - 1,0,0, 1,0,0, 1,0,0 ]; - - cubeMesh = renderer.createMesh({ "vertices": vertices, "uvs": uvs, "normals": normals }); -} - -function drawCube(coords, scale, ambientColor, diffuseColor, specularColor, shininess, textured) { - var cameInfo = map.getCameraInfo(); - - //matrix which tranforms mesh position and scale - var mv = [ - scale, 0, 0, 0, - 0, scale, 0, 0, - 0, 0, scale, 0, - coords[0], coords[1], coords[2] + scale, 1 - ]; - - //setup material - var material = [ - ambientColor[0], ambientColor[1], ambientColor[2], 0, - diffuseColor[0], diffuseColor[1], diffuseColor[2], 0, - specularColor[0], specularColor[1], specularColor[2], 0, - shininess, 0, 0, 0 - ]; - - //multiply cube matrix with camera view matrix - vts.mat4.multiply(cameInfo["view-matrix"], mv, mv); - - var norm = [ - 0,0,0, - 0,0,0, - 0,0,0 - ]; - - //normal transformation matrix - vts.mat4.toInverseMat3(mv, norm); - - //draw cube - renderer.drawMesh({ - "mesh" : cubeMesh, - "texture" : woodTexture, - "shader" : textured ? "textured-and-shaded" : "shaded", - "shader-variables" : { - "uMV" : ["mat4", mv], - "uNorm" : ["mat3", norm], - "uMaterial" : ["mat4", material] - } - }); -} - - -function onMapLoaded() { - map = core.map; - //add render slots - //render slots are called during map render - map.addRenderSlot("custom-meshes", onDrawMeshes, true); - map.moveRenderSlotAfter("after-map-render", "custom-meshes"); - - //check whether is map projected (used for navigation) - var rf = map.getReferenceFrame(); - var srs = map.getSrsInfo(rf["navigationSrs"]); - isMapProjected = (srs) ? (srs["type"] == "projected") : false; -} - -function onDrawMeshes(renderChannel) { - if (renderChannel != "base") { - return; //draw only in base channel - } - - if (woodTexture) { - var coords; - - //draw textured cubes - coords = map.convertCoordsFromNavToCameraSpace([1683559, 6604129, 0], "float"); - drawCube(coords, 50, [255,128,128], [0,0,0], [0,0,0], 0, true); - - coords = map.convertCoordsFromNavToCameraSpace([1683559+150, 6604129, 0], "float"); - drawCube(coords, 50, [0,0,0], [255,128,128], [0,0,0], 0, true); - - coords = map.convertCoordsFromNavToCameraSpace([1683559+300, 6604129, 0], "float"); - drawCube(coords, 50, [0,0,0], [255,128,128], [255,255,255], 90, true); - - //draw cubes without textures - coords = map.convertCoordsFromNavToCameraSpace([1683559, 6604129+200, 0], "float"); - drawCube(coords, 50, [255,128,128], [0,0,0], [0,0,0], 0, false); - - coords = map.convertCoordsFromNavToCameraSpace([1683559+150, 6604129+200, 0], "float"); - drawCube(coords, 50, [0,0,0], [255,128,128], [0,0,0], 0, false); - - coords = map.convertCoordsFromNavToCameraSpace([1683559+300, 6604129+200, 0], "float"); - drawCube(coords, 50, [0,0,0], [255,128,128], [255,255,255], 90, false); - } -} - -//mouse events -var mouseRightDown = false; -var mouseLeftDown = false; - -var mouseLx = 0; -var mouseLy = 0; - -function onMouseDown(event) { - var right = false; - var e = event || window.event; - - if (e.which) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera - right = e.which == 3; - } else if (e.button) { // IE, Opera - right = e.button == 2; - } - - if (right == true) { - mouseRightDown = true; - } else { - mouseLeftDown = true; - } -} - - -function onMouseUp(event) { - var right = false; - var e = event || window.event; - - if (e.which) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera - right = e.which == 3; - } else if (e.button) { // IE, Opera - right = e.button == 2; - } - - if (right == true) { - mouseRightDown = false; - } else { - mouseLeftDown = false; - } -} - - -function onMouseMove(event) { - //get mouse coords - var x = event.clientX; - var y = event.clientY; - //get mouse deltas - var dx = (x - mouseLx); - var dy = (y - mouseLy); - //store coords - mouseLx = x; - mouseLy = y; - - if (map) { - var pos = map.getPosition(); - - if (mouseLeftDown) { //pan - - //get zoom factor - var sensitivity = 0.5; - var viewExtent = pos.getViewExtent(); - var fov = pos.getFov()*0.5; - var zoomFactor = ((viewExtent * Math.tan(vts.math.radians(fov))) / 800) * sensitivity; - - //apply factor to deltas - dx *= zoomFactor; - dy *= zoomFactor; - - //get azimuth and distance - var distance = Math.sqrt(dx*dx + dy*dy); - var azimuth = vts.math.degrees(Math.atan2(dx, dy)) + pos.getOrientation()[0]; - - //move position - pos = map.movePositionCoordsTo(pos, (isMapProjected ? 1 : -1) * azimuth, distance); - pos = reduceFloatingHeight(pos, 0.8); - map.setPosition(pos); - - } else if (mouseRightDown) { //rotate - - var orientation = pos.getOrientation(); - - var sensitivity_ = 0.4; - orientation[0] -= dx * sensitivity_; - orientation[1] -= dy * sensitivity_; - - pos = pos.setOrientation(orientation); - map.setPosition(pos); - } - - - } -} - -function onMouseWheel(event) { - if (event.preventDefault) { - event.preventDefault(); - } - - event.returnValue = false; - - var delta = 0; - - if (event.wheelDelta) { - delta = event.wheelDelta / 120; - } - if (event.detail) { - delta = -event.detail / 3; - } - - if (isNaN(delta) == true) { - delta = 0; - } - - if (map) { - var pos = map.getPosition(); - - var viewExtent = pos.getViewExtent(); - - viewExtent *= 1.0 + (delta > 0 ? -1 : 1)*0.05; - - pos = pos.setViewExtent(viewExtent); - pos = reduceFloatingHeight(pos, 0.8); - map.setPosition(pos); - } -} - -//used to to gradually reduce relative height over terrain -function reduceFloatingHeight(pos, factor) { - if (pos.getHeightMode() == "float" && - pos.getViewMode() == "obj") { - - var coords = pos.getCoords(); - if (coords[2] != 0) { - coords[2] *= factor; - - if (Math.abs(coords[2]) < 0.1) { - coords[2] = 0; - } - - pos.setCoords(coords); - } - } - - return pos; -}; - diff --git a/demos/core/meshes/index.html b/demos/core/meshes/index.html deleted file mode 100755 index a538d342..00000000 --- a/demos/core/meshes/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - VTS Browser - Meshes - - - - - - - -
-
- - - diff --git a/demos/core/meshes/wood.png b/demos/core/meshes/wood.png deleted file mode 100755 index 9ba9e6a7..00000000 Binary files a/demos/core/meshes/wood.png and /dev/null differ diff --git a/demos/flights/demo.js b/demos/flights/demo.js new file mode 100755 index 00000000..141a0806 --- /dev/null +++ b/demos/flights/demo.js @@ -0,0 +1,60 @@ +var browser = null; +var list = null; + +(function startDemo() { + // create map in the html div with id 'map-div' + // parameter 'map' sets path to the map which will be displayed + // you can create your own map on melown.com + // position parameter is described in documentation + // https://github.com/Melown/vts-browser-js/wiki/VTS-Browser-Map-API#position + browser = vts.browser('map-div', { + map: 'https://cdn.melown.com/mario/store/melown2015/map-config/melown/VTS-Tutorial-map/mapConfig.json', + position : [ 'obj', 84.93164,28.351981, 'fix', 2728.74, -109.06, -27.28, 0.00, 38255.68, 55.00 ] + }); + + //check whether browser is supported + if (!browser) { + console.log('Your web browser does not support WebGL'); + return; + } + + //create new UI panel + //html contetnt is in the form of string + //you can style html elements as usual + var panel = browser.ui.addControl('destinations-panel', + '
' + + ' Destination A
' + + ' Destination B
' + + ' Destination C' + + '
'); + + //get destinations-div element + //do not use document.getElementById, + //because element ids are changed to unique ids + list = panel.getElement('destinations-div'); + + //create event listener + //once button state is changed then + //onFlyToNewDestination function is called + list.on('change', onFlyToNewDestination); +})(); + +//this function uses autopilot to fly to the new position +function onFlyToNewDestination() { + if (browser.map) { //check whether map is loaded + //get selected destination and fyly to the new position + switch (list.getElement().elements['destination'].value) { + case "a": + browser.autopilot.flyTo([ 'obj', 84.931640, 28.351981, 'fix', 2728.74, -109.06, -27.28, 0.00, 10605.11, 55.00 ]); + break; + + case "b": + browser.autopilot.flyTo([ 'obj', 19.285509, -33.876371, 'fix', 711.90, 339.28, -31.75, 0.00, 68309.37, 55.00 ]); + break; + + case "c": + browser.autopilot.flyTo([ 'obj', -122.188130, 46.202126, 'fix', 882.39, 176.89, -15.98, 0.00, 10766.96, 55.00 ]); + break; + } + } +} diff --git a/demos/browser/flights/index.html b/demos/flights/index.html similarity index 77% rename from demos/browser/flights/index.html rename to demos/flights/index.html index 6b91489e..8f015d01 100755 --- a/demos/browser/flights/index.html +++ b/demos/flights/index.html @@ -1,12 +1,12 @@ VTS Browser - Flights - - - + + + + diff --git a/demos/switching-geodata/demo.js b/demos/switching-geodata/demo.js new file mode 100755 index 00000000..427328da --- /dev/null +++ b/demos/switching-geodata/demo.js @@ -0,0 +1,70 @@ +var browser = null; +var button = null; +var map = null; + +(function startDemo() { + // create map in the html div with id 'map-div' + // parameter 'map' sets path to the map which will be displayed + // you can create your own map on melown.com + // position format is described in documentation + // https://github.com/Melown/vts-browser-js/wiki/VTS-Browser-Map-API#position + browser = vts.browser('map-div', { + map: 'https://cdn.melown.com/mario/store/melown2015/map-config/melown/VTS-Tutorial-Map-4/mapConfig.json', + position : [ 'obj', 16.859804814132534, 48.487330129634145, 'float', 0.00, 0.99, -90.00, 310.56, 2339330.58, 55.00 ] + }); + + //check whether browser is supported + if (!browser) { + console.log('Your web browser does not support WebGL'); + return; + } + + //create new UI panel + //html contetnt is in the form of string + //you can style html element as usual + var panel = browser.ui.addControl('switch-panel', + '
' + + ' Hide geodata' + + '
'); + + //get switch element + //do not use document.getElementById, + //because element ids are changed to unique ids + button = panel.getElement('switch'); + + //create event listener + //once button state is changed then + //onSwitchView function is called + button.on('change', onSwitchView); +})(); + +//this function changes whether geodata will be displayed on not +function onSwitchView() { + if (browser.map) { //check whether map is loaded + if (button.getElement().checked) { //check switch state + //set map view without geodata + browser.map.setView({ + 'surfaces': { + 'melown-viewfinder-world': [ + 'bing-world', + 'bmng08-world' + ] + }, + 'freeLayers': {} + }); + } else { + //set map view with geodata + browser.map.setView({ + 'surfaces': { + 'melown-viewfinder-world': [ + 'bing-world', + 'bmng08-world' + ] + }, + 'freeLayers': { + 'mapzen-all-v1': {} + } + }); + } + } +} diff --git a/demos/browser/view-switch/index.html b/demos/switching-geodata/index.html similarity index 71% rename from demos/browser/view-switch/index.html rename to demos/switching-geodata/index.html index 34e42e46..6993abeb 100755 --- a/demos/browser/view-switch/index.html +++ b/demos/switching-geodata/index.html @@ -1,13 +1,13 @@ - VTS Browser - View Switch - - - + VTS Browser - Switching Geodata + + + + diff --git a/package.json b/package.json old mode 100644 new mode 100755 index 74877efd..b23179a8 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vts-browser-js", - "version": "2.0.3", + "version": "2.1.2", "description": "JavaScript WebGL 3D maps rendering engine", "main": "src/browser/index.js", "scripts": { @@ -30,11 +30,18 @@ "homepage": "https://github.com/melown/vts-browser-js#readme", "devDependencies": { "babel-core": "^6.24.0", + "babel-eslint": "^7.2.3", "babel-loader": "^6.4.1", "babel-preset-es2015": "^6.24.0", "chai": "^3.5.0", "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.27.3", + "eslint": "^3.19.0", + "eslint-config-airbnb": "^14.1.0", + "eslint-loader": "^1.7.1", + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-jsx-a11y": "^4.0.0", + "eslint-plugin-react": "^6.10.3", "extract-text-webpack-plugin": "^2.1.0", "html-webpack-plugin": "^2.28.0", "install": "^0.8.7", diff --git a/src/browser/autopilot/autopilot.js b/src/browser/autopilot/autopilot.js index 0c84b03c..0c9bf137 100755 --- a/src/browser/autopilot/autopilot.js +++ b/src/browser/autopilot/autopilot.js @@ -178,12 +178,3 @@ Autopilot.prototype.generatePIHTrajectory = function(position, azimuth, distance export default Autopilot; -/* -Autopilot.prototype["flyTo"] = Autopilot.prototype.flyTo; -Autopilot.prototype["flyTrajectory"] = Autopilot.prototype.flyTrajectory; -Autopilot.prototype["setAutorotate"] = Autopilot.prototype.setAutorotate; -Autopilot.prototype["getAutorotate"] = Autopilot.prototype.getAutorotate; -Autopilot.prototype["setAutopan"] = Autopilot.prototype.setAutopan; -Autopilot.prototype["getAutopan"] = Autopilot.prototype.getAutopan; -Autopilot.prototype["cancelFlight"] = Autopilot.prototype.cancelFlight; -*/ diff --git a/src/browser/control-mode/map-observer.js b/src/browser/control-mode/map-observer.js index 1a86dffd..7638bef0 100755 --- a/src/browser/control-mode/map-observer.js +++ b/src/browser/control-mode/map-observer.js @@ -56,8 +56,8 @@ ControlModeMapObserver.prototype.drag = function(event) { if (event.getTouchParameter("touchMode") == "pan" && this.config.rotationAllowed) { var pan = event.getTouchParameter("touchPanDelta"); var sensitivity = this.config.sensitivity[1] * this.retinaFactor; - this.orientationDeltas.push([-delta[0] * sensitivity, - -delta[1] * sensitivity, 0]); + this.orientationDeltas.push([delta[0] * sensitivity, + -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; @@ -80,10 +80,10 @@ ControlModeMapObserver.prototype.drag = function(event) { var fov = pos.getFov(); var fovCorrection = (fov > 0.01 && fov < 179) ? (1.0 / Math.tan(math.radians(fov*0.5))) : 1.0; var azimuth = math.radians(azimuthDistance[0]); - 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 + 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 this.coordsDeltas.push(forward); this.reduceFloatingHeight(0.9); @@ -93,8 +93,8 @@ ControlModeMapObserver.prototype.drag = function(event) { && this.config.rotationAllowed) { //rotate var sensitivity = this.config.sensitivity[1] * this.retinaFactor; - this.orientationDeltas.push([-delta[0] * sensitivity, - -delta[1] * sensitivity, 0]); + this.orientationDeltas.push([delta[0] * sensitivity, + -delta[1] * sensitivity, 0]); this.browser.callListener("map-position-rotated", {}); } }; @@ -225,7 +225,7 @@ ControlModeMapObserver.prototype.getAzimuthAndDistance = function(dx, dy) { dy *= zoomFactor; var distance = Math.sqrt(dx*dx + dy*dy); - var azimuth = math.degrees(Math.atan2(dx, dy)) + pos.getOrientation()[0]; + var azimuth = -math.degrees(Math.atan2(dx, dy)) + pos.getOrientation()[0]; return [azimuth, distance]; }; @@ -260,7 +260,7 @@ ControlModeMapObserver.prototype.tick = function(event) { azimuth = math.radians(azimuth); //console.log("correction: " + map.getAzimuthCorrection(coords2, coords) + " coords2: " + JSON.stringify(coords2) + " coords: " + JSON.stringify(coords)); - forward[0] += -Math.sin(azimuth) * delta[2]; + forward[0] += Math.sin(azimuth) * delta[2]; forward[1] += Math.cos(azimuth) * delta[2]; /* diff --git a/src/browser/interface.js b/src/browser/interface.js index b9d5028b..cf88f104 100755 --- a/src/browser/interface.js +++ b/src/browser/interface.js @@ -161,25 +161,3 @@ BrowserInterface.prototype.getParam = function(key) { export default BrowserInterface; - -//prevent minification -/* -Mel["MapBrowser"] = Mel.MapBrowser; -Mel["mapBrowser"] = Mel.MapBrowser; -BrowserInterface.prototype["getMap"] = BrowserInterface.prototype.getMap; -BrowserInterface.prototype["getRenderer"] = BrowserInterface.prototype.getRenderer; -BrowserInterface.prototype["getPresenter"] = BrowserInterface.prototype.getPresenter; -BrowserInterface.prototype["getAutopilot"] = BrowserInterface.prototype.getAutopilot; -BrowserInterface.prototype["getProj4"] = BrowserInterface.prototype.getProj4; -BrowserInterface.prototype["getUI"] = BrowserInterface.prototype.getUI; -BrowserInterface.prototype["destroy"] = BrowserInterface.prototype.destroy; -BrowserInterface.prototype["setControlMode"] = BrowserInterface.prototype.setControlMode; -BrowserInterface.prototype["getControlMode"] = BrowserInterface.prototype.getControlMode; -BrowserInterface.prototype["loadMap"] = BrowserInterface.prototype.loadMap; -BrowserInterface.prototype["destroyMap"] = BrowserInterface.prototype.destroyMap; -BrowserInterface.prototype["on"] = BrowserInterface.prototype.on; -BrowserInterface.prototype["setParams"] = BrowserInterface.prototype.setParams; -BrowserInterface.prototype["setParam"] = BrowserInterface.prototype.setParam; -BrowserInterface.prototype["getParam"] = BrowserInterface.prototype.getParam; -Mel["getBrowserVersion"] = Mel.getBrowserVersion; -*/ \ No newline at end of file diff --git a/src/browser/presenter/presenter.js b/src/browser/presenter/presenter.js index 4e06f10a..254bca9d 100644 --- a/src/browser/presenter/presenter.js +++ b/src/browser/presenter/presenter.js @@ -593,14 +593,3 @@ Presenter.prototype.showSections = function(elem) { export default Presenter; - -//prevent minification -/* -Presenter.prototype["addPresentation"] = Presenter.prototype.addPresentation; -Presenter.prototype["removePresentation"] = Presenter.prototype.removePresentation; -Presenter.prototype["getCurrentPresentation"] = Presenter.prototype.getCurrentPresentation; -Presenter.prototype["getCurrentPresentationType"] = Presenter.prototype.getCurrentPresentationType; -Presenter.prototype["playPresentation"] = Presenter.prototype.playPresentation; -Presenter.prototype["stopPresentation"] = Presenter.prototype.stopPresentation; -Presenter.prototype["listPresentations"] = Presenter.prototype.listPresentations; -*/ diff --git a/src/browser/ui/control/compass.js b/src/browser/ui/control/compass.js index a71898bc..2d62b0eb 100755 --- a/src/browser/ui/control/compass.js +++ b/src/browser/ui/control/compass.js @@ -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; @@ -68,8 +68,8 @@ UIControlCompass.prototype.onDrag = function(event) { var controller = this.browser.controlMode.getCurrentController(); if (controller.orientationDeltas) { - controller.orientationDeltas.push([-delta[0] * sensitivity, - -delta[1] * sensitivity, 0]); + controller.orientationDeltas.push([delta[0] * sensitivity, + -delta[1] * sensitivity, 0]); } }; diff --git a/src/browser/ui/control/search.js b/src/browser/ui/control/search.js index 1da8bfcc..8b1f1d87 100755 --- a/src/browser/ui/control/search.js +++ b/src/browser/ui/control/search.js @@ -44,7 +44,7 @@ var UIControlSearch = function(ui, visible) { this.ignoreDrag = false; - this.urlTemplate = "https://www.windytv.com/search/get/v1.0/{value}?lang=en-US&hash=b0f07fGWSGdsx-l"; + this.urlTemplate = "https://www.windy.com/search/get/v1.0/{value}?lang=en-US&hash=b0f07fGWSGdsx-l"; this.data = []; this.lastSearch = ""; this.itemIndex = -1; diff --git a/src/browser/ui/element/element.js b/src/browser/ui/element/element.js index fe9731f3..12877165 100755 --- a/src/browser/ui/element/element.js +++ b/src/browser/ui/element/element.js @@ -553,33 +553,3 @@ UIElement.prototype.setDraggableState = function(state) { export default UIElement; - -//prevent minification -/* -UIElement.prototype["setHtml"] = UIElement.prototype.setHtml; -UIElement.prototype["getHtml"] = UIElement.prototype.getHtml; -UIElement.prototype["getElement"] = UIElement.prototype.getElement; -UIElement.prototype["setClass"] = UIElement.prototype.setClass; -UIElement.prototype["getClass"] = UIElement.prototype.getClass; -UIElement.prototype["setStyle"] = UIElement.prototype.setStyle; -UIElement.prototype["getStyle"] = UIElement.prototype.getStyle; -UIElement.prototype["addClass"] = UIElement.prototype.addClass; -UIElement.prototype["hasClass"] = UIElement.prototype.hasClass; -UIElement.prototype["getRect"] = UIElement.prototype.getRect; -UIElement.prototype["removeClass"] = UIElement.prototype.removeClass; -*/ - -//prevent minification -/* -UIElement.prototype["on"] = UIElement.prototype.on; -UIElement.prototype["once"] = UIElement.prototype.once; -UIElement.prototype["off"] = UIElement.prototype.off; -UIElement.prototype["fire"] = UIElement.prototype.fire; -*/ - -//prevent minification -/* -UIElement.prototype["setDraggableState"] = UIElement.prototype.setDraggableState; -UIElement.prototype["getDraggableState"] = UIElement.prototype.getDraggableState; -UIElement.prototype["getDraggingState"] = UIElement.prototype.getDraggingState; -*/ diff --git a/src/browser/ui/element/event.js b/src/browser/ui/element/event.js index 33a82f39..05d2ec9a 100755 --- a/src/browser/ui/element/event.js +++ b/src/browser/ui/element/event.js @@ -281,19 +281,4 @@ UIEvent.prototype.getType = function() { export default UIEvent; -//prevent minification -/* -UIEvent.prototype["getMouseButton"] = UIEvent.prototype.getMouseButton; -UIEvent.prototype["getMouseCoords"] = UIEvent.prototype.getMouseCoords; -UIEvent.prototype["getDragDelta"] = UIEvent.prototype.getDragDelta; -UIEvent.prototype["getModifierKey"] = UIEvent.prototype.getModifierKey; -UIEvent.prototype["getKeyCode"] = UIEvent.prototype.getKeyCode; -UIEvent.prototype["getDragButton"] = UIEvent.prototype.getDragButton; -UIEvent.prototype["getWheelDelta"] = UIEvent.prototype.getWheelDelta; -UIEvent.prototype["getDragZoom"] = UIEvent.prototype.getDragZoom; -UIEvent.prototype["getDragTuches"] = UIEvent.prototype.getDragTuches; -UIEvent.prototype["getTouchesCount"] = UIEvent.prototype.getTouchesCount; -UIEvent.prototype["getTouchCoords"] = UIEvent.prototype.getTouchCoords; -UIEvent.prototype["getType"] = UIEvent.prototype.getType; -*/ diff --git a/src/browser/ui/ui.js b/src/browser/ui/ui.js index 8db3b773..31684022 100755 --- a/src/browser/ui/ui.js +++ b/src/browser/ui/ui.js @@ -176,12 +176,4 @@ UI.prototype.tick = function(dirty) { export default UI; -/* -UI.prototype["addControl"] = UI.prototype.addControl; -UI.prototype["removeControl"] = UI.prototype.removeControl; -UI.prototype["setControlHtml"] = UI.prototype.setControlHtml; -UI.prototype["setControlVisible"] = UI.prototype.setControlVisible; -UI.prototype["getControlVisible"] = UI.prototype.getControlVisible; -UI.prototype["getMapElement"] = UI.prototype.getMapElement; -UI.prototype["getControl"] = UI.prototype.getControl; -*/ + diff --git a/src/core/core.js b/src/core/core.js index c823c64a..bf9974ad 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -465,7 +465,7 @@ string getCoreVersion() */ function getCoreVersion(full) { - return (full ? "Core: " : "") + "2.0.3"; + return (full ? "Core: " : "") + "2.1.2"; }; diff --git a/src/core/inspector/inspector.js b/src/core/inspector/inspector.js index 567f9141..ba2096cf 100755 --- a/src/core/inspector/inspector.js +++ b/src/core/inspector/inspector.js @@ -116,7 +116,7 @@ Inspector.prototype.onMapUpdate = function(string) { "points" : slines, "size" : 2.0, "color" : [0,128,255,255], - "depth-test" : false, + "depthTest" : false, "blend" : false }); @@ -131,7 +131,7 @@ Inspector.prototype.onMapUpdate = function(string) { "points" : slines, "size" : 2.0, "color" : [0,255,128,255], - "depth-test" : false, + "depthTest" : false, "blend" : false }); } @@ -147,7 +147,7 @@ Inspector.prototype.onMapUpdate = function(string) { "points" : slines, "size" : 2.0, "color" : [0,255,255,255], - "depth-test" : false, + "depthTest" : false, "blend" : false }); } @@ -259,7 +259,7 @@ Inspector.prototype.onMapUpdate = function(string) { "points" : lbuffer, "size" : 2.0, "color" : [0,255,255,255], - "depth-test" : false, + "depthTest" : false, "blend" : false }); } @@ -274,7 +274,7 @@ Inspector.prototype.onMapUpdate = function(string) { "points" : lbuffer, "size" : 2.0, "color" : [0,255,255,255], - "depth-test" : false, + "depthTest" : false, "blend" : false }); } @@ -286,7 +286,7 @@ Inspector.prototype.onMapUpdate = function(string) { "texture" : this.circleTexture, "color" : [255,0,255,255], "depth" : p[2], - "depth-test" : false, + "depthTest" : false, "blend" : true }); } diff --git a/src/core/interface.js b/src/core/interface.js index 2cc86f4c..6c21d134 100755 --- a/src/core/interface.js +++ b/src/core/interface.js @@ -83,17 +83,3 @@ CoreInterface.prototype.callListener = function(name, event) { export {CoreInterface}; - -/* -Mel["MapCore"] = Mel.MapCore; -Mel["mapCore"] = Mel.MapCore; -CoreInterface.prototype["destroy"] = CoreInterface.prototype.destroy; -CoreInterface.prototype["loadMap"] = CoreInterface.prototype.loadMap; -CoreInterface.prototype["destroyMap"] = CoreInterface.prototype.destroyMap; -CoreInterface.prototype["getMap"] = CoreInterface.prototype.getMap; -CoreInterface.prototype["getRenderer"] = CoreInterface.prototype.getRenderer; -CoreInterface.prototype["on"] = CoreInterface.prototype.on; -CoreInterface.prototype["callListener"] = CoreInterface.prototype.callListener; -Mel["getCoreVersion"] = Mel.getCoreVersion; -Mel["checkSupport"] = Mel.checkSupport; -*/ diff --git a/src/core/map/convert.js b/src/core/map/convert.js index a098feb3..169e2efc 100755 --- a/src/core/map/convert.js +++ b/src/core/map/convert.js @@ -48,7 +48,7 @@ MapConvert.prototype.movePositionCoordsTo = function(position, azimuth, distance //console.log("corerction: " + (r.azi1 - r.azi2)); - orientation[0] += (r.azi1 - r.azi2) * azimuthCorrectionFactor; + orientation[0] -= (r.azi1 - r.azi2) * azimuthCorrectionFactor; //orientation[0] -= (r.azi1 - r.azi2); //if (!skipOrientation) { @@ -147,7 +147,7 @@ MapConvert.prototype.convertPositionHeightMode = function(position, mode, noPrec MapConvert.prototype.getPositionCameraCoords = function(position, heightMode) { var orientation = position.getOrientation(); var rotMatrix = mat4.create(); - mat4.multiply(math.rotationMatrix(2, math.radians(orientation[0])), math.rotationMatrix(0, math.radians(orientation[1])), rotMatrix); + mat4.multiply(math.rotationMatrix(2, math.radians(-orientation[0])), math.rotationMatrix(0, math.radians(orientation[1])), rotMatrix); if (position.getViewMode() == "obj") { var coords = position.getCoords(); diff --git a/src/core/map/interface.js b/src/core/map/interface.js index 044144a5..63615b43 100755 --- a/src/core/map/interface.js +++ b/src/core/map/interface.js @@ -236,13 +236,18 @@ MapInterface.prototype.getAzimuthCorrection = function(coords, coords2) { }; +MapInterface.prototype.getNED = function(coords) { + return this.map.measure.getNewNED(coords, true); +}; + + MapInterface.prototype.getCameraInfo = function() { var camera = this.map.camera; return { - "projection-matrix" : camera.camera.projection.slice(), - "view-matrix" : camera.camera.modelview.slice(), - "view-projection-matrix" : camera.camera.mvp.slice(), - "rotation-matrix" : camera.camera.rotationview.slice(), + "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 @@ -397,67 +402,3 @@ MapInterface.prototype.hover = function(screenX, screenY, persistent, state) { export default MapInterface; - - -/* -MapInterface.prototype["setPosition"] = MapInterface.prototype.setPosition; -MapInterface.prototype["getPosition"] = MapInterface.prototype.getPosition; -MapInterface.prototype["setView"] = MapInterface.prototype.setView; -MapInterface.prototype["getView"] = MapInterface.prototype.getView; -MapInterface.prototype["getCredits"] = MapInterface.prototype.getCredits; -MapInterface.prototype["getCurrentCredits"] = MapInterface.prototype.getCurrentCredits; -MapInterface.prototype["getCreditInfo"] = MapInterface.prototype.getCreditInfo; -MapInterface.prototype["getViews"] = MapInterface.prototype.getViews; -MapInterface.prototype["getViewInfo"] = MapInterface.prototype.getViewInfo; -MapInterface.prototype["getBoundLayers"] = MapInterface.prototype.getBoundLayers; -MapInterface.prototype["getBoundLayerInfo"] = MapInterface.prototype.getBoundLayerInfo; -MapInterface.prototype["getFreeLayers"] = MapInterface.prototype.getFreeLayers; -MapInterface.prototype["getFreeLayerInfo"] = MapInterface.prototype.getFreeLayerInfo; -MapInterface.prototype["getSurfaces"] = MapInterface.prototype.getSurfaces; -MapInterface.prototype["getSurfaceInfo"] = MapInterface.prototype.getSurfaceInfo; -MapInterface.prototype["getSrses"] = MapInterface.prototype.getSrses; -MapInterface.prototype["getSrsInfo"] = MapInterface.prototype.getSrsInfo; -MapInterface.prototype["getReferenceFrame"] = MapInterface.prototype.getReferenceFrame; -MapInterface.prototype["addFreeLayer"] = MapInterface.prototype.addFreeLayer; -MapInterface.prototype["removeFreeLayer"] = MapInterface.prototype.removeFreeLayer; -//MapInterface.prototype["setFreeLayerOptions"] = MapInterface.prototype.setFreeLayerOptions; -//MapInterface.prototype["getFreeLayerOptions"] = MapInterface.prototype.getFreeLayerOptions; -MapInterface.prototype["addBoundLayer"] = MapInterface.prototype.addBoundLayer; -MapInterface.prototype["removeBoundLayer"] = MapInterface.prototype.removeBoundLayer; -//MapInterface.prototype["setBoundLayerOptions"] = MapInterface.prototype.setBoundLayerOptions; -//MapInterface.prototype["getBoundLayerOptions"] = MapInterface.prototype.getBoundLayerOptions; -MapInterface.prototype["convertPositionViewMode"] = MapInterface.prototype.convertPositionViewMode; -MapInterface.prototype["convertPositionHeightMode"] = MapInterface.prototype.convertPositionHeightMode; -MapInterface.prototype["convertCoords"] = MapInterface.prototype.convertCoords; -MapInterface.prototype["convertCoordsFromNavToCanvas"] = MapInterface.prototype.convertCoordsFromNavToCanvas; -MapInterface.prototype["convertCoordsFromPhysToCanvas"] = MapInterface.prototype.convertCoordsFromPhysToCanvas; -MapInterface.prototype["convertCoordsFromNavToCameraSpace"] = MapInterface.prototype.convertCoordsFromNavToCameraSpace; //remove? -MapInterface.prototype["convertCoordsFromPhysToCameraSpace"] = MapInterface.prototype.convertCoordsFromPhysToCameraSpace; -MapInterface.prototype["getPositionCanvasCoords"] = MapInterface.prototype.getPositionCanvasCoords; -MapInterface.prototype["getPositionCameraCoords"] = MapInterface.prototype.getPositionCameraCoords; -MapInterface.prototype["movePositionCoordsTo"] = MapInterface.prototype.movePositionCoordsTo; -MapInterface.prototype["getSurfaceHeight"] = MapInterface.prototype.getSurfaceHeight; -MapInterface.prototype["getDistance"] = MapInterface.prototype.getDistance; -MapInterface.prototype["getAzimuthCorrection"] = MapInterface.prototype.getAzimuthCorrection; -MapInterface.prototype["getCameraInfo"] = MapInterface.prototype.getCameraInfo; -MapInterface.prototype["isPointInsideCameraFrustum"] = MapInterface.prototype.isPointInsideCameraFrustum; -MapInterface.prototype["isBBoxInsideCameraFrustum"] = MapInterface.prototype.isBBoxInsideCameraFrustum; -MapInterface.prototype["generateTrajectory"] = MapInterface.prototype.generateTrajectory; -MapInterface.prototype["setConfigParam"] = MapInterface.prototype.setConfigParam; -MapInterface.prototype["getConfigParam"] = MapInterface.prototype.getConfigParam; -MapInterface.prototype["redraw"] = MapInterface.prototype.redraw; -MapInterface.prototype["addRenderSlot"] = MapInterface.prototype.addRenderSlot; -MapInterface.prototype["moveRenderSlotBefore"] = MapInterface.prototype.moveRenderSlotBefore; -MapInterface.prototype["moveRenderSlotAfter"] = MapInterface.prototype.moveRenderSlotAfter; -MapInterface.prototype["removeRenderSlot"] = MapInterface.prototype.removeRenderSlot; -MapInterface.prototype["setRenderSlotEnabled"] = MapInterface.prototype.setRenderSlotEnabled; -MapInterface.prototype["getRenderSlotEnabled"] = MapInterface.prototype.getRenderSlotEnabled; -MapInterface.prototype["setLoaderSuspended"] = MapInterface.prototype.setLoaderSuspended; -MapInterface.prototype["getLoaderSuspended"] = MapInterface.prototype.getLoaderSuspended; -MapInterface.prototype["getGpuCache"] = MapInterface.prototype.getGpuCache; -MapInterface.prototype["getHitCoords"] = MapInterface.prototype.getHitCoords; -MapInterface.prototype["getScreenRay"] = MapInterface.prototype.getScreenRay; -MapInterface.prototype["getStats"] = MapInterface.prototype.getStats; -MapInterface.prototype["click"] = MapInterface.prototype.click; -MapInterface.prototype["hover"] = MapInterface.prototype.hover; -*/ diff --git a/src/core/map/measure.js b/src/core/map/measure.js index 86345fb3..a10a4032 100755 --- a/src/core/map/measure.js +++ b/src/core/map/measure.js @@ -520,16 +520,16 @@ MapMeasure.prototype.getDistance = function(coords, coords2, includingHeight) { 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]; + return [Math.sqrt(r.s12*r.s12 + dz*dz), -r.az1]; } else { - return [r.s12, r.azi1]; + return [r.s12, -r.azi1]; } } else { - return [d, r.azi1]; + return [d, -r.azi1]; } } else { - return [d, math.degrees(Math.atan2(dy, dx))]; + return [d, math.degrees(Math.atan2(dx, dy))]; } }; @@ -558,15 +558,12 @@ MapMeasure.prototype.getAzimuthCorrection = function(coords, coords2) { }; -MapMeasure.prototype.getPositionNED = function(position) { - var pos = position.clone(); - var coords = pos.getCoords(); - coords[2] = 0; - var centerCoords = this.convert.convertCoords(coords, "navigation", "physical"); +MapMeasure.prototype.getNED = function(coords, returnMatrix) { + 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, coords[2]], "navigation", "physical"); - var rightCoords = this.convert.convertCoords([coords[0] + 100, coords[1], coords[2]], "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; @@ -574,19 +571,17 @@ MapMeasure.prototype.getPositionNED = function(position) { if (cy < 0 || cx > 180) { //if we are out of bounds things start to be complicated var geodesic = this.getGeodesic(); + //up coords var r = geodesic.Direct(coords[1], coords[0], 0, -100); - var upPos = position.clone(); - upPos.setCoords2([r.lon2, r.lat2]); - var upCoords = this.convert.convertCoords(upPos.getCoords(), "navigation", "physical"); + var upCoords = this.convert.convertCoords([r.lon2, r.lat2, 0], "navigation", "physical"); - r = geodesic["Direct"](coords[1], coords[0], 90, 100); - var rightPos = position.clone(); - rightPos.setCoords2([r.lon2, r.lat2]); - var rightCoords = this.convert.convertCoords(rightPos.getCoords(), "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"); } else { // substraction instead of addition is probably case of complicated view matrix calculation - var upCoords = this.convert.convertCoords([coords[0], coords[1] - 0.0001, coords[2]], "navigation", "physical"); - var rightCoords = this.convert.convertCoords([coords[0] + 0.0001, coords[1], coords[2]], "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"); } } @@ -603,7 +598,7 @@ MapMeasure.prototype.getPositionNED = function(position) { vec3.normalize(right); vec3.cross(up, right, dir); vec3.normalize(dir); - + return { east : right, direction : up, @@ -611,7 +606,98 @@ MapMeasure.prototype.getPositionNED = function(position) { }; }; +MapMeasure.prototype.getNewNED = function(coords, returnMatrix) { + 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"); + } else { + //get NED for latlon coordinates + //http://www.mathworks.com/help/aeroblks/directioncosinematrixeceftoned.html + /* + var coords = this.position.getCoords(); + var lon = math.radians(coords[0]); + var lat = math.radians(coords[1]); + + //NED vectors for sphere + var east = [-Math.sin(lat)*Math.cos(lon), -Math.sin(lat)*Math.sin(lon), Math.cos(lat)]; + var direction = [-Math.sin(lon), Math.cos(lon), 0]; + var north = [-Math.cos(lat)*Math.cos(lon), -Math.cos(lat)*Math.sin(lon), -Math.sin(lat)]; + + north = vec3.negate(north); + east = vec3.negate(east); + + //get elipsoid factor + var navigationSrsInfo = this.getNavigationSrs().getSrsInfo(); + var factor = navigationSrsInfo["b"] / navigationSrsInfo["a"]; + + //flaten vectors + north[2] *= factor; + east[2] *= factor; + direction[2] *= factor; + + //normalize vectors + north = vec3.normalize(north); + east = vec3.normalize(east); + direction = vec3.normalize(direction); + */ + + var cy = (coords[1] + 90) + 0.0001; + var cx = (coords[0] + 180) + 0.0001; + + if (cy < 0 || cx > 180) { //if we are out of bounds things start to be complicated + var geodesic = this.getGeodesic(); + + //up coords + var r = geodesic.Direct(coords[1], coords[0], 0, -100); + 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"); + } 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 up = [upCoords[0] - centerCoords[0], + upCoords[1] - centerCoords[1], + upCoords[2] - centerCoords[2]]; + + var right = [rightCoords[0] - centerCoords[0], + rightCoords[1] - centerCoords[1], + rightCoords[2] - centerCoords[2]]; + + var dir = [0,0,0]; + vec3.normalize(up); + vec3.normalize(right); + vec3.cross(up, right, dir); + vec3.normalize(dir); + + if (returnMatrix) { + var east = right; + var direction = up; + var north = dir; + + return [ + east[0], east[1], east[2], 0, + north[0], north[1], north[2], 0, + up[0], up[1], up[2], 0, + 0, 0, 0, 1 + ]; + } + return { + east : right, + direction : up, + north : dir + }; +}; + +//TODO: use getNewNED MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clampTilt) { //var position = [0,0,0]; var orientation = position.getOrientation(); @@ -622,7 +708,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); + mat4.multiply(math.rotationMatrix(2, math.radians(-orientation[0])), math.rotationMatrix(0, math.radians(orientation[1])), tmpMatrix); if (position.getViewMode() == "obj") { var orbitPos = [0, -distance, 0]; @@ -642,30 +728,14 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp orbitHeight : orbitPos[2] }; + var coords = position.getCoords(); + if (projected) { tmpMatrix = mat4.create(); - mat4.multiply(math.rotationMatrix(0, math.radians(-orientation[1] - 90.0)), math.rotationMatrix(2, math.radians(-orientation[0])), tmpMatrix); + mat4.multiply(math.rotationMatrix(0, math.radians(-orientation[1] - 90.0)), math.rotationMatrix(2, math.radians(orientation[0])), tmpMatrix); - /* - //get NED for latlon coordinates - //http://www.mathworks.com/help/aeroblks/directioncosinematrixeceftoned.html - var coords = this.position.getCoords(); - var lon = math.radians(0); - var lat = math.radians(89); - - //NED vectors for sphere - var east = [-Math.sin(lat)*Math.cos(lon), -Math.sin(lat)*Math.sin(lon), Math.cos(lat)]; - var direction = [-Math.sin(lon), Math.cos(lon), 0]; - var north = [-Math.cos(lat)*Math.cos(lon), -Math.cos(lat)*Math.sin(lon), -Math.sin(lat)]; - //direction = [-direction[0], -direction[1], -direction[2]]; - - north = vec3.negate(north); - east = vec3.negate(east); - //direction = vec3.negate(direction); - */ - - var ned = this.getPositionNED(position); + var ned = this.getNED(coords); var north = ned.north; var east = ned.east; var direction = ned.direction; @@ -736,37 +806,8 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp } else { //geographics - //get NED for latlon coordinates - //http://www.mathworks.com/help/aeroblks/directioncosinematrixeceftoned.html -/* - var coords = this.position.getCoords(); - var lon = math.radians(coords[0]); - var lat = math.radians(coords[1]); - - //NED vectors for sphere - var east = [-Math.sin(lat)*Math.cos(lon), -Math.sin(lat)*Math.sin(lon), Math.cos(lat)]; - var direction = [-Math.sin(lon), Math.cos(lon), 0]; - var north = [-Math.cos(lat)*Math.cos(lon), -Math.cos(lat)*Math.sin(lon), -Math.sin(lat)]; - - north = vec3.negate(north); - east = vec3.negate(east); - - //get elipsoid factor - var navigationSrsInfo = this.getNavigationSrs().getSrsInfo(); - var factor = navigationSrsInfo["b"] / navigationSrsInfo["a"]; - - //flaten vectors - north[2] *= factor; - east[2] *= factor; - direction[2] *= factor; - - //normalize vectors - north = vec3.normalize(north); - east = vec3.normalize(east); - direction = vec3.normalize(direction); -*/ - - var ned = this.getPositionNED(position); + + var ned = this.getNED(coords); north = ned.north; east = ned.east; direction = ned.direction; @@ -782,7 +823,7 @@ MapMeasure.prototype.getPositionCameraInfo = function(position, projected, clamp //spaceMatrix = mat4.inverse(spaceMatrix); var localRotMatrix = mat4.create(); - mat4.multiply(math.rotationMatrix(0, math.radians(-orientation[1] - 90.0)), math.rotationMatrix(2, math.radians(-orientation[0])), localRotMatrix); + mat4.multiply(math.rotationMatrix(0, math.radians(-orientation[1] - 90.0)), math.rotationMatrix(2, math.radians(orientation[0])), localRotMatrix); var east2 = [1,0,0]; var direction2 = [0,1,0]; diff --git a/src/core/map/trajectory.js b/src/core/map/trajectory.js index 81c30fa4..568fc1cb 100755 --- a/src/core/map/trajectory.js +++ b/src/core/map/trajectory.js @@ -80,17 +80,16 @@ var MapTrajectory = function(map, p1, p2, options) { //get distance and azimut var res = this.map.measure.getDistance(this.pp1.getCoords(), this.pp2.getCoords()); this.distance = res[0]; - this.azimuth = (res[1] - 90) % 360; + this.azimuth = (res[1] + 90) % 360; this.azimuth = (this.azimuth < 0) ? (360 + this.azimuth) : this.azimuth; if (!this.map.getNavigationSrs().isProjected()) { - var res = this.geodesic["Inverse"](this.pp1.pos[2], this.pp1.pos[1], this.pp2.pos[2], this.pp2.pos[1]); - this.geoAzimuth = res["azi1"]; - this.geoDistance = res["s12"]; + var res = this.geodesic.Inverse(this.pp1.pos[2], this.pp1.pos[1], this.pp2.pos[2], this.pp2.pos[1]); + this.geoAzimuth = res.azi1; + this.geoDistance = res.s12; this.azimuth = this.geoAzimuth % 360; this.azimuth = (this.azimuth < 0) ? (360 + this.azimuth) : this.azimuth; } - } //console.log("azim: " + Math.round(this.azimuth) + " p1: " + this.p1.pos[5] + " p2: " + this.p2.pos[5]); @@ -264,7 +263,7 @@ MapTrajectory.prototype.generate = function() { } if (coords[3] != null) { //used for correction in planet mode - this.azimuth = coords[3]; + this.azimuth = -coords[3]; } p.setOrientation(this.getFlightOrienation(time)); @@ -295,9 +294,9 @@ MapTrajectory.prototype.getInterpolatedCoords = function(factor) { var c2 = this.pp2.getCoords(); if (!this.map.getNavigationSrs().isProjected()) { - var res = this.geodesic["Direct"](c1[1], c1[0], this.geoAzimuth, this.geoDistance * factor); + var res = this.geodesic.Direct(c1[1], c1[0], this.geoAzimuth, this.geoDistance * factor); - var azimut = res["azi1"] - res["azi2"]; + var azimut = res.azi1 - res.azi2; //var azimut = (azimut - 90) % 360; azimut = (this.azimuth < 0) ? (360 + azimut) : azimut; @@ -305,7 +304,7 @@ MapTrajectory.prototype.getInterpolatedCoords = function(factor) { //azimut = this.azimuth; - return [ res["lon2"], res["lat2"], + return [ res.lon2, res.lat2, c1[2] + (c2[2] - c1[2]) * factor, azimut]; } else { diff --git a/src/core/renderer/gpu/shaders.js b/src/core/renderer/gpu/shaders.js index f26973cc..0e2b3cf7 100755 --- a/src/core/renderer/gpu/shaders.js +++ b/src/core/renderer/gpu/shaders.js @@ -805,8 +805,8 @@ GpuShaders.tileTShadedFragmentShader = "precision mediump float;\n"+ "vec3 normal = normalize(vNormal);\n"+ "vec3 eyeDir = ldir;\n"+ "vec3 refDir = reflect(-ldir, normal);\n"+ - "float specW = pow(max(dot(refDir, eyeDir), 0.0), uMaterial[3][0]);\n"+ - "float diffW = max(dot(normal, ldir), 0.0);\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"+ @@ -825,8 +825,8 @@ GpuShaders.tileShadedFragmentShader = "precision mediump float;\n"+ "vec3 normal = normalize(vNormal);\n"+ "vec3 eyeDir = ldir;\n"+ "vec3 refDir = reflect(-ldir, normal);\n"+ - "float specW = pow(max(dot(refDir, eyeDir), 0.0), uMaterial[3][0]);\n"+ - "float diffW = max(dot(normal, ldir), 0.0);\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"+ diff --git a/src/core/renderer/interface.js b/src/core/renderer/interface.js index 00d7e654..4c3c804b 100755 --- a/src/core/renderer/interface.js +++ b/src/core/renderer/interface.js @@ -104,12 +104,12 @@ RendererInterface.prototype.createMesh = function(options) { vertices : options["vertices"], uvs : options["uvs"], uvs2 : options["normals"], - vertexSize : options["vertex-size"], - uvSize : options["uv-size"], - uv2Size : options["normal-size"] || 3, - vertexAttr : options["vertex-attr"], - uvAttr : options["uv-attr"], - uv2Attr : options["normal-attr"], + vertexSize : options["vertexSize"], + uvSize : options["uvSize"], + uv2Size : options["normalSize"] || 3, + vertexAttr : options["vertexAttr"], + uvAttr : options["uvAttr"], + uv2Attr : options["normalAttr"], bbox : options["bbox"] }; @@ -130,8 +130,8 @@ RendererInterface.prototype.createShader = function(options) { return null; } - var vertexShader = options["vertex-shader"]; - var fragmentShader = options["fragment-shader"]; + var vertexShader = options["vertexShader"]; + var fragmentShader = options["fragmentShader"]; if (vertexShader != null && fragmentShader) { return new GpuProgram(this.gpu, vertexShader, fragmentShader); @@ -162,16 +162,16 @@ RendererInterface.prototype.drawMesh = function(options) { return this; } - if (!options["mesh"] == null || !options["shader-variables"]) { + if (!options["mesh"] == null || !options["shaderVariables"]) { return this; } - var shaderAttributes = options["shader-attributes"]; + var shaderAttributes = options["shaderAttributes"]; var vertexAttr = options["vertex"] || "aPosition"; var uvAttr = options["uv"] || "aTexCoord"; var uv2Attr = options["normal"] || "aNormal"; - var shaderVariables = options["shader-variables"]; + var shaderVariables = options["shaderVariables"]; var shader = options["shader"] || "textured"; @@ -289,10 +289,10 @@ RendererInterface.prototype.drawImage = function(options) { var rect = options["rect"]; var color = options["color"] || [255,255,255,255]; var depth = (options["depth"] != null) ? options["depth"] : 0; - var depthTest = (options["depth-test"] != null) ? options["depth-test"] : false; + var depthTest = (options["depthTest"] != null) ? options["depthTest"] : false; var blend = (options["blend"] != null) ? options["blend"] : false; - var writeDepth = (options["write-depth"] != null) ? options["write-depth"] : false; - var useState = (options["use-state"] != null) ? options["use-state"] : 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; @@ -314,10 +314,10 @@ RendererInterface.prototype.drawBillboard = function(options) { var mvp = options["mvp"]; var color = options["color"] || [255,255,255,255]; - var depthTest = (options["depth-test"] != null) ? options["depth-test"] : false; + var depthTest = (options["depthTest"] != null) ? options["depthTest"] : false; var blend = (options["blend"] != null) ? options["blend"] : false; - var writeDepth = (options["write-depth"] != null) ? options["write-depth"] : false; - var useState = (options["use-state"] != null) ? options["use-state"] : 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; @@ -340,10 +340,10 @@ RendererInterface.prototype.drawLineString = function(options) { var points = options["points"]; var color = options["color"] || [255,255,255,255]; var size = options["size"] || 2; - var depthTest = (options["depth-test"] != null) ? options["depth-test"] : false; + var depthTest = (options["depthTest"] != null) ? options["depthTest"] : false; var blend = (options["blend"] != null) ? options["blend"] : false; - var writeDepth = (options["write-depth"] != null) ? options["write-depth"] : false; - var useState = (options["use-state"] != null) ? options["use-state"] : 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; @@ -379,7 +379,7 @@ RendererInterface.prototype.drawDebugText = function(options) { var color = options["color"] || [255,255,255,255]; var size = options["size"] || 16; var depth = options["depth"]; - var useState = options["use-state"] || false; + var useState = options["useState"] || false; color[0] *= 1.0/255; color[1] *= 1.0/255; color[2] *= 1.0/255; @@ -390,9 +390,9 @@ RendererInterface.prototype.drawDebugText = function(options) { this.renderer.draw.drawText(coords[0] - (lx * 0.5), coords[1], size, text, color, depth, useState); /* - var depthTest = options["depth-test"] || false; + var depthTest = options["depthTest"] || false; var blend = options["blend"] || false; - var writeDepth = options["write-depth"] || false; + var writeDepth = options["writeDepth"] || false; */ return this; @@ -432,30 +432,3 @@ RendererInterface.prototype.getConfigParam = function(key) { export default RendererInterface; - -/* -RendererInterface.prototype["clear"] = RendererInterface.prototype.clear; -RendererInterface.prototype["createState"] = RendererInterface.prototype.createState; -RendererInterface.prototype["setState"] = RendererInterface.prototype.setState; -RendererInterface.prototype["createTexture"] = RendererInterface.prototype.createTexture; -RendererInterface.prototype["removeTexture"] = RendererInterface.prototype.removeTexture; -RendererInterface.prototype["createMesh"] = RendererInterface.prototype.createMesh; -RendererInterface.prototype["removeMesh"] = RendererInterface.prototype.removeMesh; -RendererInterface.prototype["createshader"] = RendererInterface.prototype.createshader; -RendererInterface.prototype["removeResource"] = RendererInterface.prototype.removeResource; -RendererInterface.prototype["addJob"] = RendererInterface.prototype.addJob; -RendererInterface.prototype["clearJobs"] = RendererInterface.prototype.clearJobs; -RendererInterface.prototype["drawMesh"] = RendererInterface.prototype.drawMesh; -RendererInterface.prototype["drawImage"] = RendererInterface.prototype.drawImage; -RendererInterface.prototype["drawBillboard"] = RendererInterface.prototype.drawBillboard; -RendererInterface.prototype["drawLineString"] = RendererInterface.prototype.drawLineString; -RendererInterface.prototype["drawJobs"] = RendererInterface.prototype.drawJobs; -RendererInterface.prototype["drawBBox"] = RendererInterface.prototype.drawBBox; -RendererInterface.prototype["drawDebugText"] = RendererInterface.prototype.drawDebugText; -RendererInterface.prototype["getCanvasCoords"] = RendererInterface.prototype.getCanvasCoords; -RendererInterface.prototype["getCanvasSize"] = RendererInterface.prototype.getCanvasSize; -RendererInterface.prototype["setConfigParams"] = RendererInterface.prototype.setConfigParams; -RendererInterface.prototype["setConfigParam"] = RendererInterface.prototype.setConfigParam; -RendererInterface.prototype["getConfigParam"] = RendererInterface.prototype.getConfigParam; -RendererInterface.prototype["saveScreenshot"] = RendererInterface.prototype.saveScreenshot; -*/ \ No newline at end of file diff --git a/src/core/utils/matrix.js b/src/core/utils/matrix.js index f36f9c99..a9a513fc 100755 --- a/src/core/utils/matrix.js +++ b/src/core/utils/matrix.js @@ -1314,23 +1314,3 @@ quat4.str = function (a) { export {vec2, vec3, vec4, mat3, mat4}; -/* -Mel["Math"] = {}; -Mel["Math"]["mat4Multiply"] = mat4.multiply; -Mel["Math"]["mat4Inverse"] = mat4.inverse; -Mel["Math"]["mat4ToMat3"] = mat4.toMat3; -Mel["Math"]["mat4ToInverseMat3"] = mat4.toInverseMat3; -Mel["Math"]["mat4Transpose"] = mat4.transpose; -Mel["Math"]["mat3Transpose"] = mat3.transpose; -Mel["Math"]["vec3Normalize"] = vec3.normalize; -Mel["Math"]["vec3Dot"] = vec3.dot; -Mel["Math"]["vec3Cross"] = vec3.cross; -Mel["Math"]["vec3Length"] = vec3.length; -*/ -/* -Mel["Math"]["vec3Scale"] = vec3.normalize; -Mel["Math"]["vec3Mul"] = vec3.normalize; -Mel["Math"]["vec3Add"] = vec3.normalize; -Mel["Math"]["vec3Sub"] = vec3.normalize; -*/ - diff --git a/src/core/utils/platform.js b/src/core/utils/platform.js index 76ef4a28..ff26f713 100755 --- a/src/core/utils/platform.js +++ b/src/core/utils/platform.js @@ -217,12 +217,3 @@ var platform = { export {platform}; -//export default platform; - -/* -Mel["getBrowser"] = platform.getBrowser; -Mel["getBrowserVersion"] = platform.getBrowserVersion; -Mel["getOS"] = platform.getOS; -Mel["isplatformMobileDevice"] = platform.isMobile; -Mel["isplatformAndroid"] = platform.isAndroid; -*/ diff --git a/src/core/utils/url.js b/src/core/utils/url.js index f1f765bc..b6ba373e 100644 --- a/src/core/utils/url.js +++ b/src/core/utils/url.js @@ -102,11 +102,3 @@ utilsUrl.getProcessUrl = function(url, originUrl) { export {utilsUrl}; - -//Mel["Url"] = utilsUrl; - -/* -Mel["Url"] = utilsUrl; -utilsUrl["getParamsFromUrl"] = utilsUrl.getParamsFromUrl; -*/ - diff --git a/src/core/utils/utils.js b/src/core/utils/utils.js index 4d118ea9..b52258a1 100755 --- a/src/core/utils/utils.js +++ b/src/core/utils/utils.js @@ -367,13 +367,3 @@ if (typeof Array.isArray === 'undefined') { return Object.prototype.toString.call(obj) === '[object Array]'; }); }*/ - -/* -Mel["isEqual"] = utils.isEqual; -Mel["clamp"] = utils.clamp; -Mel["mix"] = utils.mix; -Mel["radians"] = utils.radians; -Mel["degrees"] = utils.degrees; -Mel["loadJSON"] = utils.loadJSON; -Mel["loadBinary"] = utils.loadBinary; -*/ diff --git a/webpack.config.js b/webpack.config.js old mode 100644 new mode 100755