From 58c289c707406224544fd216d1777b671250c9b9 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Wed, 2 Aug 2017 13:37:46 +0200 Subject: [PATCH 1/3] Moved code to be linted by happiness linter. --- .eslintrc | 35 + .jshintrc | 23 - examples/clipping_volume.html | 42 +- package-lock.json | 4508 +++++++++++++++++ package.json | 16 +- src/Actions.js | 100 +- src/AnimationPath.js | 75 +- src/Annotation.js | 352 +- src/BitReader.js | 53 +- src/Features.js | 64 +- src/LRU.js | 127 +- src/PointCloud.js | 104 +- src/PointCloudGreyhoundGeometry.js | 8 +- src/PointCloudGreyhoundGeometryNode.js | 296 +- src/PointCloudOctree.js | 808 ++- src/PointCloudOctreeGeometry.js | 192 +- src/PointCloudTree.js | 397 +- src/Potree.js | 702 ++- src/ProfileRequest.js | 213 +- src/TextSprite.js | 139 +- src/Version.js | 31 +- src/WorkerPool.js | 25 +- src/arena4d/PointCloudArena4D.js | 613 ++- src/arena4d/PointCloudArena4DGeometry.js | 335 +- src/exporter/CSVExporter.js | 59 +- src/exporter/DXFExporter.js | 86 +- src/exporter/GeoJSONExporter.js | 83 +- src/exporter/LASExporter.js | 130 +- src/extensions/EventDispatcher.js | 16 +- src/extensions/PerspectiveCamera.js | 59 +- src/extensions/Ray.js | 13 +- src/loader/BinaryLoader.js | 82 +- src/loader/GreyhoundBinaryLoader.js | 139 +- src/loader/GreyhoundLoader.js | 355 +- src/loader/LasLazLoader.js | 178 +- src/loader/POCLoader.js | 126 +- src/loader/PointAttributes.js | 86 +- src/materials/BlurMaterial.js | 35 +- src/materials/EyeDomeLightingMaterial.js | 120 +- src/materials/PointCloudMaterial.js | 939 ++-- src/navigation/EarthControls.js | 246 +- src/navigation/FirstPersonControls.js | 220 +- src/navigation/GeoControls.js | 410 +- src/navigation/InputHandler.js | 606 ++- src/navigation/OrbitControls.js | 212 +- src/stuff/HoverMenu.js | 97 +- src/utils.js | 385 +- src/utils/Box3Helper.js | 21 +- src/utils/Measure.js | 483 +- src/utils/MeasuringTool.js | 195 +- src/utils/Profile.js | 289 +- src/utils/ProfileTool.js | 108 +- src/utils/TransformationTool.js | 482 +- src/utils/TranslationTool.js | 206 +- src/utils/Volume.js | 142 +- src/utils/VolumeTool.js | 135 +- src/viewer/ProgressBar.js | 105 +- src/viewer/map.js | 511 +- src/viewer/profile.js | 678 ++- src/viewer/sidebar.js | 4952 +++++++++---------- src/viewer/viewer.js | 1825 ++++--- src/webgl/GLProgram.js | 54 +- src/workers/BinaryDecoderWorker.js | 219 +- src/workers/DEMWorker.js | 37 +- src/workers/GreyhoundBinaryDecoderWorker.js | 307 +- src/workers/LASDecoderWorker.js | 183 +- src/workers/LazLoaderWorker.js | 87 +- 67 files changed, 14313 insertions(+), 10646 deletions(-) create mode 100644 .eslintrc delete mode 100644 .jshintrc create mode 100644 package-lock.json diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..70eceafd --- /dev/null +++ b/.eslintrc @@ -0,0 +1,35 @@ +{ + "extends": "happiness", + "globals": { + "THREE": false, + "TWEEN": false, + "$": false, + "XMLHttpRequest": false, + "requestAnimationFrame": false, + "Blob": false, + "i18n": false, + "URL": false, + "Stats": false, + "ProgressBar": false, + "d3": false, + "btoa": false, + "alert": false, + "ol": false, + "proj4": false, + "shapefile": false, + "Worker": false, + "Image": false, + "LASFile": false, + "LASDecoder": false, + "BinaryHeap": false, + "Potree": true, + "initSidebar": true, + "HoverMenu": true, + "HoverMenuItem": true, + "LRU": true, + "viewer": true + }, + "rules": { + "no-lone-blocks": "off" + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 4df3791d..00000000 --- a/.jshintrc +++ /dev/null @@ -1,23 +0,0 @@ -{ - "bitwise": true, - "camelcase": true, - "curly": true, - "eqeqeq": true, - "immed": true, - "indent": 4, - "latedef": true, - "newcap": true, - "noarg": true, - "nonew": true, - "undef": true, - "unused": true, - "esversion": 6, - "sub": true, - "browser": true, - "node": true, - "globals": { - "Potree": true, - "THREE": true, - "$": true - } -} \ No newline at end of file diff --git a/examples/clipping_volume.html b/examples/clipping_volume.html index bbcffa4b..52c74fd0 100644 --- a/examples/clipping_volume.html +++ b/examples/clipping_volume.html @@ -15,10 +15,10 @@ - + - + @@ -29,13 +29,13 @@ - + - + - + @@ -43,61 +43,61 @@
- + - - + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..ff161fbb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,4508 @@ +{ + "name": "potree", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "accepts": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.2.13.tgz", + "integrity": "sha1-5fHzkoxtlf2WVYw27D2dDeSm7Oo=", + "dev": true, + "requires": { + "mime-types": "2.1.16", + "negotiator": "0.5.3" + } + }, + "acorn": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.1.tgz", + "integrity": "sha512-vOk6uEMctu0vQrvuSqFdJyqj1Q0S5VTDL79qtjo+DhRr+1mmaD+tluFSCZqhvi/JUhXSzoZN2BhtstaPEeE8cw==", + "dev": true + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "dev": true, + "requires": { + "acorn": "3.3.0" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + } + } + }, + "ajv-keywords": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", + "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "dev": true + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true + }, + "ansi-regex": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", + "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", + "dev": true + }, + "ansi-styles": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.0.0.tgz", + "integrity": "sha1-yxAt8cVvUSPquLZ817mAJ6AnkXg=", + "dev": true + }, + "archy": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/archy/-/archy-0.0.2.tgz", + "integrity": "sha1-kQ9Dv2YUH8M1VkWXq8GJ30Sz014=", + "dev": true + }, + "argparse": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", + "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", + "dev": true, + "requires": { + "sprintf-js": "1.0.3" + } + }, + "array-differ": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", + "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", + "dev": true + }, + "array-find-index": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", + "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", + "dev": true + }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "1.0.3" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", + "dev": true + }, + "babel-code-frame": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", + "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base64-url": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/base64-url/-/base64-url-1.2.1.tgz", + "integrity": "sha1-GZ/WYXAqDnt9yubgaYuwicUvbXg=", + "dev": true + }, + "basic-auth": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-1.0.4.tgz", + "integrity": "sha1-Awk1sB3nyblKgksp8/zLdQ06UpA=", + "dev": true + }, + "basic-auth-connect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/basic-auth-connect/-/basic-auth-connect-1.0.0.tgz", + "integrity": "sha1-/bC0OWLKe0BFanwrtI/hc9otISI=", + "dev": true + }, + "batch": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/batch/-/batch-0.5.3.tgz", + "integrity": "sha1-PzQU84AyF0O/wQQvmoP/HVgk1GQ=", + "dev": true + }, + "beeper": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", + "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", + "dev": true + }, + "body-parser": { + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.13.3.tgz", + "integrity": "sha1-wIzzMMM1jhUQFqBXRvE/ApyX+pc=", + "dev": true, + "requires": { + "bytes": "2.1.0", + "content-type": "1.0.2", + "debug": "2.2.0", + "depd": "1.0.1", + "http-errors": "1.3.1", + "iconv-lite": "0.4.11", + "on-finished": "2.3.0", + "qs": "4.0.0", + "raw-body": "2.1.7", + "type-is": "1.6.15" + } + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, + "bytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.1.0.tgz", + "integrity": "sha1-rJPEEOL/ycx89LRks4KJBn9eR7Q=", + "dev": true + }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "dev": true, + "requires": { + "callsites": "0.2.0" + } + }, + "callsites": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "dev": true + }, + "camelcase": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", + "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", + "dev": true + }, + "camelcase-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", + "dev": true, + "requires": { + "camelcase": "2.1.1", + "map-obj": "1.0.1" + } + }, + "chalk": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz", + "integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=", + "dev": true, + "requires": { + "ansi-styles": "1.0.0", + "has-color": "0.1.7", + "strip-ansi": "0.1.1" + } + }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "dev": true + }, + "cli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", + "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", + "dev": true, + "requires": { + "exit": "0.1.2", + "glob": "7.1.2" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + } + } + }, + "cli-width": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz", + "integrity": "sha1-sjTKIJsp72b8UY2bmNWEewDt8Ao=", + "dev": true + }, + "clone": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", + "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=", + "dev": true + }, + "clone-stats": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", + "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", + "dev": true + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "color-convert": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", + "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "compressible": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.11.tgz", + "integrity": "sha1-FnGKdd4oPtjmBAQWJaIGRYZ5fYo=", + "dev": true, + "requires": { + "mime-db": "1.29.0" + } + }, + "compression": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.5.2.tgz", + "integrity": "sha1-sDuNhub4rSloPLqN+R3cb/x3s5U=", + "dev": true, + "requires": { + "accepts": "1.2.13", + "bytes": "2.1.0", + "compressible": "2.0.11", + "debug": "2.2.0", + "on-headers": "1.0.1", + "vary": "1.0.1" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, + "connect": { + "version": "2.30.2", + "resolved": "https://registry.npmjs.org/connect/-/connect-2.30.2.tgz", + "integrity": "sha1-jam8vooFTT0xjXTf7JA7XDmhtgk=", + "dev": true, + "requires": { + "basic-auth-connect": "1.0.0", + "body-parser": "1.13.3", + "bytes": "2.1.0", + "compression": "1.5.2", + "connect-timeout": "1.6.2", + "content-type": "1.0.2", + "cookie": "0.1.3", + "cookie-parser": "1.3.5", + "cookie-signature": "1.0.6", + "csurf": "1.8.3", + "debug": "2.2.0", + "depd": "1.0.1", + "errorhandler": "1.4.3", + "express-session": "1.11.3", + "finalhandler": "0.4.0", + "fresh": "0.3.0", + "http-errors": "1.3.1", + "method-override": "2.3.9", + "morgan": "1.6.1", + "multiparty": "3.3.2", + "on-headers": "1.0.1", + "parseurl": "1.3.1", + "pause": "0.1.0", + "qs": "4.0.0", + "response-time": "2.3.2", + "serve-favicon": "2.3.2", + "serve-index": "1.7.3", + "serve-static": "1.10.3", + "type-is": "1.6.15", + "utils-merge": "1.0.0", + "vhost": "3.0.2" + } + }, + "connect-livereload": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/connect-livereload/-/connect-livereload-0.5.4.tgz", + "integrity": "sha1-gBV9E3HJ83zBQDmrGJWXDRGdw7w=", + "dev": true + }, + "connect-timeout": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/connect-timeout/-/connect-timeout-1.6.2.tgz", + "integrity": "sha1-3ppexh4zoStu2qt7XwYumMWZuI4=", + "dev": true, + "requires": { + "debug": "2.2.0", + "http-errors": "1.3.1", + "ms": "0.7.1", + "on-headers": "1.0.1" + } + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "0.1.4" + } + }, + "contains-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", + "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "dev": true + }, + "content-type": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", + "integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0=", + "dev": true + }, + "cookie": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.1.3.tgz", + "integrity": "sha1-5zSlwUF/zkctWu+Cw4HKu2TRpDU=", + "dev": true + }, + "cookie-parser": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.3.5.tgz", + "integrity": "sha1-nXVVcPtdF4kHcSJ6AjFNm+fPg1Y=", + "dev": true, + "requires": { + "cookie": "0.1.3", + "cookie-signature": "1.0.6" + } + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "crc": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/crc/-/crc-3.3.0.tgz", + "integrity": "sha1-+mIuG8OIvyVzCQgta2UgDOZwkLo=", + "dev": true + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "4.1.1", + "shebang-command": "1.2.0", + "which": "1.3.0" + }, + "dependencies": { + "lru-cache": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", + "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", + "dev": true, + "requires": { + "pseudomap": "1.0.2", + "yallist": "2.1.2" + } + } + } + }, + "csrf": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/csrf/-/csrf-3.0.6.tgz", + "integrity": "sha1-thEg3c7q/JHnbtUxO7XAsmZ7cQo=", + "dev": true, + "requires": { + "rndm": "1.2.0", + "tsscmp": "1.0.5", + "uid-safe": "2.1.4" + } + }, + "csurf": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/csurf/-/csurf-1.8.3.tgz", + "integrity": "sha1-I/KhO/HY/OHQyZZYg5RELLqGpWo=", + "dev": true, + "requires": { + "cookie": "0.1.3", + "cookie-signature": "1.0.6", + "csrf": "3.0.6", + "http-errors": "1.3.1" + } + }, + "currently-unhandled": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", + "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", + "dev": true, + "requires": { + "array-find-index": "1.0.2" + } + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "dateformat": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", + "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=", + "dev": true, + "requires": { + "get-stdin": "4.0.1", + "meow": "3.7.0" + } + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true, + "requires": { + "ms": "0.7.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "deepmerge": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-0.2.10.tgz", + "integrity": "sha1-iQa/nlJaT78bIDsq/LRkAkmCEhk=", + "dev": true + }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "dev": true, + "requires": { + "globby": "5.0.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.0", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rimraf": "2.6.1" + } + }, + "depd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.0.1.tgz", + "integrity": "sha1-gK7GTJ1tl+ZcwqnKqTwKpqv3Oqo=", + "dev": true + }, + "deprecated": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", + "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=", + "dev": true + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", + "dev": true + }, + "doctrine": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", + "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", + "dev": true, + "requires": { + "esutils": "2.0.2", + "isarray": "1.0.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + } + } + }, + "dom-serializer": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", + "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", + "dev": true, + "requires": { + "domelementtype": "1.1.3", + "entities": "1.1.1" + }, + "dependencies": { + "domelementtype": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", + "dev": true + }, + "entities": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", + "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", + "dev": true + } + } + }, + "domelementtype": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", + "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", + "dev": true + }, + "domhandler": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", + "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", + "dev": true, + "requires": { + "domelementtype": "1.3.0" + } + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dev": true, + "requires": { + "dom-serializer": "0.1.0", + "domelementtype": "1.3.0" + } + }, + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "dev": true + }, + "duplexer2": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", + "dev": true, + "requires": { + "readable-stream": "1.1.14" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "dev": true + }, + "end-of-stream": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", + "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", + "dev": true, + "requires": { + "once": "1.3.3" + } + }, + "entities": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", + "dev": true + }, + "error-ex": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", + "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "dev": true, + "requires": { + "is-arrayish": "0.2.1" + } + }, + "errorhandler": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/errorhandler/-/errorhandler-1.4.3.tgz", + "integrity": "sha1-t7cO2PNZ6duICS8tIMD4MUIK2D8=", + "dev": true, + "requires": { + "accepts": "1.3.3", + "escape-html": "1.0.3" + }, + "dependencies": { + "accepts": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", + "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", + "dev": true, + "requires": { + "mime-types": "2.1.16", + "negotiator": "0.6.1" + } + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", + "dev": true + } + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "eslint": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.3.0.tgz", + "integrity": "sha1-/NfJY3a780yF7mftABKimWQrEI8=", + "dev": true, + "requires": { + "ajv": "5.2.2", + "babel-code-frame": "6.22.0", + "chalk": "1.1.3", + "concat-stream": "1.6.0", + "cross-spawn": "5.1.0", + "debug": "2.6.8", + "doctrine": "2.0.0", + "eslint-scope": "3.7.1", + "espree": "3.4.3", + "esquery": "1.0.0", + "estraverse": "4.2.0", + "esutils": "2.0.2", + "file-entry-cache": "2.0.0", + "functional-red-black-tree": "1.0.1", + "glob": "7.1.2", + "globals": "9.18.0", + "ignore": "3.3.3", + "imurmurhash": "0.1.4", + "inquirer": "3.2.1", + "is-resolvable": "1.0.0", + "js-yaml": "3.9.1", + "json-stable-stringify": "1.0.1", + "levn": "0.3.0", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "natural-compare": "1.4.0", + "optionator": "0.8.2", + "path-is-inside": "1.0.2", + "pluralize": "4.0.0", + "progress": "2.0.0", + "require-uncached": "1.0.3", + "semver": "5.4.1", + "strip-json-comments": "2.0.1", + "table": "4.0.1", + "text-table": "0.2.0" + }, + "dependencies": { + "ajv": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.2.tgz", + "integrity": "sha1-R8aNaehvXZUxA7AHSpQw3GPaXjk=", + "dev": true, + "requires": { + "co": "4.6.0", + "fast-deep-equal": "1.0.0", + "json-schema-traverse": "0.3.1", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-escapes": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-2.0.0.tgz", + "integrity": "sha1-W65SvkJIeN2Xg+iRDj/Cki6DyBs=", + "dev": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "2.0.0" + } + }, + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "inquirer": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.2.1.tgz", + "integrity": "sha512-QgW3eiPN8gpj/K5vVpHADJJgrrF0ho/dZGylikGX7iqAdRgC9FVKYKWFLx6hZDBFcOLEoSqINYrVPeFAeG/PdA==", + "dev": true, + "requires": { + "ansi-escapes": "2.0.0", + "chalk": "2.0.1", + "cli-cursor": "2.1.0", + "cli-width": "2.1.0", + "external-editor": "2.0.4", + "figures": "2.0.0", + "lodash": "4.17.4", + "mute-stream": "0.0.7", + "run-async": "2.3.0", + "rx-lite": "4.0.8", + "rx-lite-aggregates": "4.0.8", + "string-width": "2.1.1", + "strip-ansi": "4.0.0", + "through": "2.3.8" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.0" + } + }, + "chalk": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.0.1.tgz", + "integrity": "sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0g==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.2.1" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.1.tgz", + "integrity": "sha512-qxzYsob3yv6U+xMzPrv170y8AwGP7i74g+pbixCfD6rgso8BscLT2qXIuz6TpOaiJZ3mFgT5O9lyT9nMU4LfaA==", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "1.1.0" + } + }, + "pluralize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-4.0.0.tgz", + "integrity": "sha1-WbcIwcAZCi9pLxx2GMRGsFL9F2I=", + "dev": true + }, + "progress": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "2.0.1", + "signal-exit": "3.0.2" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "2.1.0" + } + }, + "rx-lite": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", + "dev": true + }, + "semver": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "table": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.1.tgz", + "integrity": "sha1-qBFsEz+sLGH0pCCrbN9cTWHw5DU=", + "dev": true, + "requires": { + "ajv": "4.11.8", + "ajv-keywords": "1.5.1", + "chalk": "1.1.3", + "lodash": "4.17.4", + "slice-ansi": "0.0.4", + "string-width": "2.1.1" + }, + "dependencies": { + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "dev": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + } + } + } + } + }, + "eslint-config-happiness": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/eslint-config-happiness/-/eslint-config-happiness-10.2.1.tgz", + "integrity": "sha1-WOPSyCBTUrmCuogmELbWAg38ouQ=", + "dev": true + }, + "eslint-import-resolver-node": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.1.tgz", + "integrity": "sha512-yUtXS15gIcij68NmXmP9Ni77AQuCN0itXbCc/jWd8C6/yKZaSNXicpC8cgvjnxVdmfsosIXrjpzFq7GcDryb6A==", + "dev": true, + "requires": { + "debug": "2.2.0", + "resolve": "0.6.3" + } + }, + "eslint-module-utils": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.1.1.tgz", + "integrity": "sha512-jDI/X5l/6D1rRD/3T43q8Qgbls2nq5km5KSqiwlyUbGo5+04fXhMKdCPhjwbqAa6HXWaMxj8Q4hQDIh7IadJQw==", + "dev": true, + "requires": { + "debug": "2.2.0", + "pkg-dir": "1.0.0" + } + }, + "eslint-plugin-import": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.7.0.tgz", + "integrity": "sha512-HGYmpU9f/zJaQiKNQOVfHUh2oLWW3STBrCgH0sHTX1xtsxYlH1zjLh8FlQGEIdZSdTbUMaV36WaZ6ImXkenGxQ==", + "dev": true, + "requires": { + "builtin-modules": "1.1.1", + "contains-path": "0.1.0", + "debug": "2.2.0", + "doctrine": "2.0.0", + "eslint-import-resolver-node": "0.3.1", + "eslint-module-utils": "2.1.1", + "has": "1.0.1", + "lodash.cond": "4.5.2", + "minimatch": "0.3.0", + "read-pkg-up": "1.0.1" + } + }, + "eslint-plugin-node": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-5.1.1.tgz", + "integrity": "sha512-3xdoEbPyyQNyGhhqttjgSO3cU/non8QDBJF8ttGaHM2h8CaY5zFIngtqW6ZbLEIvhpoFPDVwiQg61b8zanx5zQ==", + "dev": true, + "requires": { + "ignore": "3.3.3", + "minimatch": "3.0.4", + "resolve": "1.4.0", + "semver": "5.3.0" + }, + "dependencies": { + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "resolve": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", + "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", + "dev": true, + "requires": { + "path-parse": "1.0.5" + } + }, + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", + "dev": true + } + } + }, + "eslint-plugin-promise": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz", + "integrity": "sha1-ePu2/+BHIBYnVp6FpsU3OvKmj8o=", + "dev": true + }, + "eslint-plugin-standard": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz", + "integrity": "sha1-NNDJFbRe3G8BA5PH7vOCOwhWXPI=", + "dev": true + }, + "eslint-scope": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", + "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", + "dev": true, + "requires": { + "esrecurse": "4.2.0", + "estraverse": "4.2.0" + } + }, + "espree": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz", + "integrity": "sha1-KRC1zNSc6JPC//+qtP2LOjG4I3Q=", + "dev": true, + "requires": { + "acorn": "5.1.1", + "acorn-jsx": "3.0.1" + } + }, + "esprima": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", + "dev": true + }, + "esquery": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", + "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", + "dev": true, + "requires": { + "estraverse": "4.2.0" + } + }, + "esrecurse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.0.tgz", + "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=", + "dev": true, + "requires": { + "estraverse": "4.2.0", + "object-assign": "4.1.1" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "etag": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz", + "integrity": "sha1-A9MLX2fdbmMtKUXTDWZScxo01dg=", + "dev": true + }, + "event-stream": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", + "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "dev": true, + "requires": { + "duplexer": "0.1.1", + "from": "0.1.7", + "map-stream": "0.1.0", + "pause-stream": "0.0.11", + "split": "0.3.3", + "stream-combiner": "0.0.4", + "through": "2.3.8" + } + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "express-session": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.11.3.tgz", + "integrity": "sha1-XMmPP1/4Ttg1+Ry/CqvQxxB0AK8=", + "dev": true, + "requires": { + "cookie": "0.1.3", + "cookie-signature": "1.0.6", + "crc": "3.3.0", + "debug": "2.2.0", + "depd": "1.0.1", + "on-headers": "1.0.1", + "parseurl": "1.3.1", + "uid-safe": "2.0.0", + "utils-merge": "1.0.0" + }, + "dependencies": { + "uid-safe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.0.0.tgz", + "integrity": "sha1-p/PGymSh9qXQTsDvPkw9U2cxcTc=", + "dev": true, + "requires": { + "base64-url": "1.2.1" + } + } + } + }, + "extend": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz", + "integrity": "sha1-oPX9bPyDpf5J72mNYOyKYk3UV2w=", + "dev": true + }, + "external-editor": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.0.4.tgz", + "integrity": "sha1-HtkZnanL/i7y96MbL96LDRI2iXI=", + "dev": true, + "requires": { + "iconv-lite": "0.4.18", + "jschardet": "1.5.0", + "tmp": "0.0.31" + }, + "dependencies": { + "iconv-lite": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz", + "integrity": "sha512-sr1ZQph3UwHTR0XftSbK85OvBbxe/abLGzEnPENCQwmHf7sck8Oyu4ob3LgBxWWxRoM+QszeUyl7jbqapu2TqA==", + "dev": true + } + } + }, + "fancy-log": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", + "integrity": "sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "time-stamp": "1.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "fast-deep-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", + "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "faye-websocket": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz", + "integrity": "sha1-TkkvjQTftviQA1B/btvy1QHnxvQ=", + "dev": true, + "requires": { + "websocket-driver": "0.6.5" + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "dev": true, + "requires": { + "flat-cache": "1.2.2", + "object-assign": "4.1.1" + } + }, + "finalhandler": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.4.0.tgz", + "integrity": "sha1-llpS2ejQXSuFdUhUH7ibU6JJfZs=", + "dev": true, + "requires": { + "debug": "2.2.0", + "escape-html": "1.0.2", + "on-finished": "2.3.0", + "unpipe": "1.0.0" + }, + "dependencies": { + "escape-html": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.2.tgz", + "integrity": "sha1-130y+pjjjC9BroXpJ44ODmuhAiw=", + "dev": true + } + } + }, + "find-index": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz", + "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=", + "dev": true + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" + } + }, + "findup-sync": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.1.3.tgz", + "integrity": "sha1-fz56l7gjksZTvwZYm9hRkOk8NoM=", + "dev": true, + "requires": { + "glob": "3.2.11", + "lodash": "2.4.2" + } + }, + "flat-cache": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.2.2.tgz", + "integrity": "sha1-+oZxTnLCHbiGAXYezy9VXRq8a5Y=", + "dev": true, + "requires": { + "circular-json": "0.3.3", + "del": "2.2.2", + "graceful-fs": "4.1.11", + "write": "0.2.1" + } + }, + "fresh": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz", + "integrity": "sha1-ZR+DjiJCTnVm3hYdg1jKoZn4PU8=", + "dev": true + }, + "from": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", + "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "function-bind": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.0.tgz", + "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=", + "dev": true + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, + "gaze": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", + "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", + "dev": true, + "requires": { + "globule": "0.1.0" + } + }, + "get-stdin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", + "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", + "dev": true + }, + "glob": { + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "minimatch": "0.3.0" + } + }, + "glob-stream": { + "version": "3.1.18", + "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", + "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", + "dev": true, + "requires": { + "glob": "4.5.3", + "glob2base": "0.0.12", + "minimatch": "2.0.10", + "ordered-read-streams": "0.1.0", + "through2": "0.6.5", + "unique-stream": "1.0.0" + }, + "dependencies": { + "glob": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", + "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "2.0.10", + "once": "1.3.3" + } + }, + "minimatch": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", + "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "4.0.1" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "glob-watcher": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", + "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", + "dev": true, + "requires": { + "gaze": "0.5.2" + } + }, + "glob2base": { + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", + "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", + "dev": true, + "requires": { + "find-index": "0.1.1" + } + }, + "globals": { + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", + "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", + "dev": true + }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "arrify": "1.0.1", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + } + } + }, + "globule": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", + "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", + "dev": true, + "requires": { + "glob": "3.1.21", + "lodash": "1.0.2", + "minimatch": "0.2.14" + }, + "dependencies": { + "glob": { + "version": "3.1.21", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", + "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", + "dev": true, + "requires": { + "graceful-fs": "1.2.3", + "inherits": "1.0.2", + "minimatch": "0.2.14" + } + }, + "graceful-fs": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", + "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", + "dev": true + }, + "inherits": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", + "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", + "dev": true + }, + "lodash": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", + "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", + "dev": true + }, + "minimatch": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", + "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", + "dev": true, + "requires": { + "lru-cache": "2.7.3", + "sigmund": "1.0.1" + } + } + } + }, + "glogg": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz", + "integrity": "sha1-f+DxmfV6yQbPUS/urY+Q7kooT8U=", + "dev": true, + "requires": { + "sparkles": "1.0.0" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "gulp": { + "version": "3.5.6", + "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.5.6.tgz", + "integrity": "sha1-u7mstZbI2/F4PMXxguvA+CqCSJ4=", + "dev": true, + "requires": { + "archy": "0.0.2", + "chalk": "0.4.0", + "deprecated": "0.0.1", + "gulp-util": "2.2.20", + "liftoff": "0.9.8", + "orchestrator": "0.3.8", + "pretty-hrtime": "0.2.2", + "semver": "2.3.2", + "vinyl-fs": "0.1.4" + } + }, + "gulp-concat": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/gulp-concat/-/gulp-concat-2.1.7.tgz", + "integrity": "sha1-biJ9dBeDXYiwg7xEuLTUG7fkElU=", + "dev": true, + "requires": { + "gulp-util": "2.2.20", + "through": "2.3.8" + } + }, + "gulp-connect": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/gulp-connect/-/gulp-connect-2.3.1.tgz", + "integrity": "sha1-FK5xczKLaRJSsB/Bkwo5y7JPszw=", + "dev": true, + "requires": { + "connect": "2.30.2", + "connect-livereload": "0.5.4", + "event-stream": "3.3.4", + "gulp-util": "3.0.8", + "tiny-lr": "0.2.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "dateformat": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz", + "integrity": "sha1-J0Pjq7XD/CRi5SfcpEXgTp9N7hc=", + "dev": true + }, + "gulp-util": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "dev": true, + "requires": { + "array-differ": "1.0.0", + "array-uniq": "1.0.3", + "beeper": "1.1.1", + "chalk": "1.1.3", + "dateformat": "2.0.0", + "fancy-log": "1.3.0", + "gulplog": "1.0.0", + "has-gulplog": "0.1.0", + "lodash._reescape": "3.0.0", + "lodash._reevaluate": "3.0.0", + "lodash._reinterpolate": "3.0.0", + "lodash.template": "3.6.2", + "minimist": "1.2.0", + "multipipe": "0.1.2", + "object-assign": "3.0.0", + "replace-ext": "0.0.1", + "through2": "2.0.3", + "vinyl": "0.5.3" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + }, + "lodash.escape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", + "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", + "dev": true, + "requires": { + "lodash._root": "3.0.1" + } + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } + }, + "lodash.template": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", + "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "dev": true, + "requires": { + "lodash._basecopy": "3.0.1", + "lodash._basetostring": "3.0.1", + "lodash._basevalues": "3.0.0", + "lodash._isiterateecall": "3.0.9", + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0", + "lodash.keys": "3.1.2", + "lodash.restparam": "3.6.1", + "lodash.templatesettings": "3.1.1" + } + }, + "lodash.templatesettings": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", + "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", + "dev": true, + "requires": { + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "object-assign": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + }, + "vinyl": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", + "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", + "dev": true, + "requires": { + "clone": "1.0.2", + "clone-stats": "0.0.1", + "replace-ext": "0.0.1" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "gulp-jshint": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/gulp-jshint/-/gulp-jshint-2.0.4.tgz", + "integrity": "sha1-84KxhWSxBy3vDJqvdTwUba208Og=", + "dev": true, + "requires": { + "gulp-util": "3.0.8", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "rcloader": "0.2.2", + "through2": "2.0.3" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "dateformat": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz", + "integrity": "sha1-J0Pjq7XD/CRi5SfcpEXgTp9N7hc=", + "dev": true + }, + "gulp-util": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "dev": true, + "requires": { + "array-differ": "1.0.0", + "array-uniq": "1.0.3", + "beeper": "1.1.1", + "chalk": "1.1.3", + "dateformat": "2.0.0", + "fancy-log": "1.3.0", + "gulplog": "1.0.0", + "has-gulplog": "0.1.0", + "lodash._reescape": "3.0.0", + "lodash._reevaluate": "3.0.0", + "lodash._reinterpolate": "3.0.0", + "lodash.template": "3.6.2", + "minimist": "1.2.0", + "multipipe": "0.1.2", + "object-assign": "3.0.0", + "replace-ext": "0.0.1", + "through2": "2.0.3", + "vinyl": "0.5.3" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + }, + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + }, + "lodash.escape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", + "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", + "dev": true, + "requires": { + "lodash._root": "3.0.1" + } + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } + }, + "lodash.template": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", + "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "dev": true, + "requires": { + "lodash._basecopy": "3.0.1", + "lodash._basetostring": "3.0.1", + "lodash._basevalues": "3.0.0", + "lodash._isiterateecall": "3.0.9", + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0", + "lodash.keys": "3.1.2", + "lodash.restparam": "3.6.1", + "lodash.templatesettings": "3.1.1" + } + }, + "lodash.templatesettings": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", + "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", + "dev": true, + "requires": { + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "object-assign": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + }, + "vinyl": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", + "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", + "dev": true, + "requires": { + "clone": "1.0.2", + "clone-stats": "0.0.1", + "replace-ext": "0.0.1" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "gulp-rename": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.0.0.tgz", + "integrity": "sha1-VSxBIE5RAXZNenr0NqaWpcJ1pJM=", + "dev": true, + "requires": { + "map-stream": "0.1.0" + } + }, + "gulp-size": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/gulp-size/-/gulp-size-2.1.0.tgz", + "integrity": "sha1-HCtk8X+QcdWr2Z0VS3s0gfj7oSg=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "gulp-util": "3.0.8", + "gzip-size": "3.0.0", + "object-assign": "4.1.1", + "pretty-bytes": "3.0.1", + "stream-counter": "1.0.0", + "through2": "2.0.3" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "dateformat": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz", + "integrity": "sha1-J0Pjq7XD/CRi5SfcpEXgTp9N7hc=", + "dev": true + }, + "gulp-util": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "dev": true, + "requires": { + "array-differ": "1.0.0", + "array-uniq": "1.0.3", + "beeper": "1.1.1", + "chalk": "1.1.3", + "dateformat": "2.0.0", + "fancy-log": "1.3.0", + "gulplog": "1.0.0", + "has-gulplog": "0.1.0", + "lodash._reescape": "3.0.0", + "lodash._reevaluate": "3.0.0", + "lodash._reinterpolate": "3.0.0", + "lodash.template": "3.6.2", + "minimist": "1.2.0", + "multipipe": "0.1.2", + "object-assign": "3.0.0", + "replace-ext": "0.0.1", + "through2": "2.0.3", + "vinyl": "0.5.3" + }, + "dependencies": { + "object-assign": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", + "dev": true + } + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + }, + "lodash.escape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", + "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", + "dev": true, + "requires": { + "lodash._root": "3.0.1" + } + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } + }, + "lodash.template": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", + "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "dev": true, + "requires": { + "lodash._basecopy": "3.0.1", + "lodash._basetostring": "3.0.1", + "lodash._basevalues": "3.0.0", + "lodash._isiterateecall": "3.0.9", + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0", + "lodash.keys": "3.1.2", + "lodash.restparam": "3.6.1", + "lodash.templatesettings": "3.1.1" + } + }, + "lodash.templatesettings": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", + "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", + "dev": true, + "requires": { + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "stream-counter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stream-counter/-/stream-counter-1.0.0.tgz", + "integrity": "sha1-kc8lac5NxQYf6816yyY5SloRR1E=", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + }, + "vinyl": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", + "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", + "dev": true, + "requires": { + "clone": "1.0.2", + "clone-stats": "0.0.1", + "replace-ext": "0.0.1" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "gulp-uglify": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-0.2.1.tgz", + "integrity": "sha1-NPE+yxbGDYb9hOIJOCPmL/cvLs4=", + "dev": true, + "requires": { + "deepmerge": "0.2.10", + "gulp-util": "2.2.20", + "through2": "0.4.2", + "uglify-js": "2.4.24", + "vinyl": "0.2.3" + }, + "dependencies": { + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "through2": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.4.2.tgz", + "integrity": "sha1-2/WGYDEVHsg1K7bE22SiKSqEC5s=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "2.1.2" + } + }, + "xtend": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", + "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", + "dev": true, + "requires": { + "object-keys": "0.4.0" + } + } + } + }, + "gulp-util": { + "version": "2.2.20", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-2.2.20.tgz", + "integrity": "sha1-1xRuVyiRC9jwR6awseVJvCLb1kw=", + "dev": true, + "requires": { + "chalk": "0.5.1", + "dateformat": "1.0.12", + "lodash._reinterpolate": "2.4.1", + "lodash.template": "2.4.1", + "minimist": "0.2.0", + "multipipe": "0.1.2", + "through2": "0.5.1", + "vinyl": "0.2.3" + }, + "dependencies": { + "ansi-styles": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", + "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", + "dev": true + }, + "chalk": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", + "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", + "dev": true, + "requires": { + "ansi-styles": "1.1.0", + "escape-string-regexp": "1.0.5", + "has-ansi": "0.1.0", + "strip-ansi": "0.3.0", + "supports-color": "0.2.0" + } + }, + "strip-ansi": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", + "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", + "dev": true, + "requires": { + "ansi-regex": "0.2.1" + } + } + } + }, + "gulplog": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", + "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", + "dev": true, + "requires": { + "glogg": "1.0.0" + } + }, + "gzip-size": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz", + "integrity": "sha1-VGGI6b3DN/Zzdy+BZgRks4nc5SA=", + "dev": true, + "requires": { + "duplexer": "0.1.1" + } + }, + "has": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", + "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "dev": true, + "requires": { + "function-bind": "1.1.0" + } + }, + "has-ansi": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", + "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", + "dev": true, + "requires": { + "ansi-regex": "0.2.1" + } + }, + "has-color": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz", + "integrity": "sha1-ZxRKUmDDT8PMpnfQQdr1L+e3iy8=", + "dev": true + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "has-gulplog": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", + "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", + "dev": true, + "requires": { + "sparkles": "1.0.0" + } + }, + "hosted-git-info": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", + "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", + "dev": true + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", + "dev": true, + "requires": { + "domelementtype": "1.3.0", + "domhandler": "2.3.0", + "domutils": "1.5.1", + "entities": "1.0.0", + "readable-stream": "1.1.14" + } + }, + "http-errors": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.3.1.tgz", + "integrity": "sha1-GX4izevUGYWF6GlO9nhhl7ke2UI=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "statuses": "1.3.1" + } + }, + "iconv-lite": { + "version": "0.4.11", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.11.tgz", + "integrity": "sha1-LstC/SlHRJIiCaLnxATayHk9it4=", + "dev": true + }, + "ignore": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.3.tgz", + "integrity": "sha1-QyNS5XrM2HqzEQ6C0/6g5HgSFW0=", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indent-string": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", + "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", + "dev": true, + "requires": { + "repeating": "2.0.1" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "1.3.3", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-builtin-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "dev": true, + "requires": { + "builtin-modules": "1.1.1" + } + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", + "dev": true + }, + "is-path-in-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", + "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", + "dev": true, + "requires": { + "is-path-inside": "1.0.0" + } + }, + "is-path-inside": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", + "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", + "dev": true, + "requires": { + "path-is-inside": "1.0.2" + } + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, + "is-resolvable": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", + "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", + "dev": true, + "requires": { + "tryit": "1.0.3" + } + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "js-yaml": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.9.1.tgz", + "integrity": "sha512-CbcG379L1e+mWBnLvHWWeLs8GyV/EMw862uLI3c+GxVyDHWZcjZinwuBd3iW2pgxgIlksW/1vNJa4to+RvDOww==", + "dev": true, + "requires": { + "argparse": "1.0.9", + "esprima": "4.0.0" + } + }, + "jschardet": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/jschardet/-/jschardet-1.5.0.tgz", + "integrity": "sha512-+Q8JsoEQbrdE+a/gg1F9XO92gcKXgpE5UACqr0sIubjDmBEkd+OOWPGzQeMrWSLxd73r4dHxBeRW7edHu5LmJQ==", + "dev": true + }, + "jshint": { + "version": "2.9.5", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.5.tgz", + "integrity": "sha1-HnJSkVzmgbQIJ+4UJIxG006apiw=", + "dev": true, + "requires": { + "cli": "1.0.1", + "console-browserify": "1.1.0", + "exit": "0.1.2", + "htmlparser2": "3.8.3", + "lodash": "3.7.0", + "minimatch": "3.0.4", + "shelljs": "0.3.0", + "strip-json-comments": "1.0.4" + }, + "dependencies": { + "lodash": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.7.0.tgz", + "integrity": "sha1-Nni9irmVBXwHreg27S7wh9qBHUU=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + } + } + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", + "dev": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2", + "type-check": "0.3.2" + } + }, + "liftoff": { + "version": "0.9.8", + "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-0.9.8.tgz", + "integrity": "sha1-ls5aLejmA63MvSTua2uoINF9av0=", + "dev": true, + "requires": { + "extend": "1.2.1", + "findup-sync": "0.1.3", + "minimist": "0.0.10", + "resolve": "0.6.3" + }, + "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + } + } + }, + "livereload-js": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-2.2.2.tgz", + "integrity": "sha1-bIclfmSKtHW8JOoldFftzB+NC8I=", + "dev": true + }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "strip-bom": "2.0.0" + } + }, + "lodash": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", + "dev": true + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basetostring": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", + "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", + "dev": true + }, + "lodash._basevalues": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", + "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", + "dev": true + }, + "lodash._escapehtmlchar": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._escapehtmlchar/-/lodash._escapehtmlchar-2.4.1.tgz", + "integrity": "sha1-32fDu2t+jh6DGrSL+geVuSr+iZ0=", + "dev": true, + "requires": { + "lodash._htmlescapes": "2.4.1" + } + }, + "lodash._escapestringchar": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._escapestringchar/-/lodash._escapestringchar-2.4.1.tgz", + "integrity": "sha1-7P4iYYoq3lC/7qQ5N+Ud9m8O23I=", + "dev": true + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._htmlescapes": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._htmlescapes/-/lodash._htmlescapes-2.4.1.tgz", + "integrity": "sha1-MtFL8IRLbeb4tioFG09nwii2JMs=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash._isnative": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._isnative/-/lodash._isnative-2.4.1.tgz", + "integrity": "sha1-PqZAS3hKe+g2x7V1gOHN95sUgyw=", + "dev": true + }, + "lodash._objecttypes": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._objecttypes/-/lodash._objecttypes-2.4.1.tgz", + "integrity": "sha1-fAt/admKH3ZSn4kLDNsbTf7BHBE=", + "dev": true + }, + "lodash._reescape": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", + "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", + "dev": true + }, + "lodash._reevaluate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", + "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", + "dev": true + }, + "lodash._reinterpolate": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-2.4.1.tgz", + "integrity": "sha1-TxInqlqHEfxjL1sHofRgequLMiI=", + "dev": true + }, + "lodash._reunescapedhtml": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._reunescapedhtml/-/lodash._reunescapedhtml-2.4.1.tgz", + "integrity": "sha1-dHxPxAED6zu4oJduVx96JlnpO6c=", + "dev": true, + "requires": { + "lodash._htmlescapes": "2.4.1", + "lodash.keys": "2.4.1" + } + }, + "lodash._root": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", + "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", + "dev": true + }, + "lodash._shimkeys": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._shimkeys/-/lodash._shimkeys-2.4.1.tgz", + "integrity": "sha1-bpzJZm/wgfC1psl4uD4kLmlJ0gM=", + "dev": true, + "requires": { + "lodash._objecttypes": "2.4.1" + } + }, + "lodash.assign": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", + "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=", + "dev": true + }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, + "lodash.cond": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/lodash.cond/-/lodash.cond-4.5.2.tgz", + "integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU=", + "dev": true + }, + "lodash.defaults": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-2.4.1.tgz", + "integrity": "sha1-p+iIXwXmiFEUS24SqPNngCa8TFQ=", + "dev": true, + "requires": { + "lodash._objecttypes": "2.4.1", + "lodash.keys": "2.4.1" + } + }, + "lodash.escape": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-2.4.1.tgz", + "integrity": "sha1-LOEsXghNsKV92l5dHu659dF1o7Q=", + "dev": true, + "requires": { + "lodash._escapehtmlchar": "2.4.1", + "lodash._reunescapedhtml": "2.4.1", + "lodash.keys": "2.4.1" + } + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.isobject": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-2.4.1.tgz", + "integrity": "sha1-Wi5H/mmVPx7mMafrof5k0tBlWPU=", + "dev": true, + "requires": { + "lodash._objecttypes": "2.4.1" + } + }, + "lodash.keys": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz", + "integrity": "sha1-SN6kbfj/djKxDXBrissmWR4rNyc=", + "dev": true, + "requires": { + "lodash._isnative": "2.4.1", + "lodash._shimkeys": "2.4.1", + "lodash.isobject": "2.4.1" + } + }, + "lodash.merge": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.0.tgz", + "integrity": "sha1-aYhLoUSsM/5plzemCG3v+t0PicU=", + "dev": true + }, + "lodash.restparam": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", + "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", + "dev": true + }, + "lodash.template": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-2.4.1.tgz", + "integrity": "sha1-nmEQB+32KRKal0qzxIuBez4c8g0=", + "dev": true, + "requires": { + "lodash._escapestringchar": "2.4.1", + "lodash._reinterpolate": "2.4.1", + "lodash.defaults": "2.4.1", + "lodash.escape": "2.4.1", + "lodash.keys": "2.4.1", + "lodash.templatesettings": "2.4.1", + "lodash.values": "2.4.1" + } + }, + "lodash.templatesettings": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz", + "integrity": "sha1-6nbHXRHrhtTb6JqDiTu4YZKaxpk=", + "dev": true, + "requires": { + "lodash._reinterpolate": "2.4.1", + "lodash.escape": "2.4.1" + } + }, + "lodash.values": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-2.4.1.tgz", + "integrity": "sha1-q/UUQ2s8twUAFieXjLzzCxKA7qQ=", + "dev": true, + "requires": { + "lodash.keys": "2.4.1" + } + }, + "loud-rejection": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", + "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", + "dev": true, + "requires": { + "currently-unhandled": "0.4.1", + "signal-exit": "3.0.2" + } + }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "dev": true + }, + "map-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", + "dev": true + }, + "map-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", + "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "dev": true + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "dev": true + }, + "meow": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", + "dev": true, + "requires": { + "camelcase-keys": "2.1.0", + "decamelize": "1.2.0", + "loud-rejection": "1.6.0", + "map-obj": "1.0.1", + "minimist": "1.2.0", + "normalize-package-data": "2.4.0", + "object-assign": "4.1.1", + "read-pkg-up": "1.0.1", + "redent": "1.0.0", + "trim-newlines": "1.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } + }, + "method-override": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/method-override/-/method-override-2.3.9.tgz", + "integrity": "sha1-vRUfLONM8Bp2ykAKuVwBKxAtj3E=", + "dev": true, + "requires": { + "debug": "2.6.8", + "methods": "1.1.2", + "parseurl": "1.3.1", + "vary": "1.1.1" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "vary": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz", + "integrity": "sha1-Z1Neu2lMHVIldFeYRmUyP1h+jTc=", + "dev": true + } + } + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "dev": true + }, + "mime": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", + "integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM=", + "dev": true + }, + "mime-db": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.29.0.tgz", + "integrity": "sha1-SNJtI1WJZRcErFkWygYAGRQmaHg=", + "dev": true + }, + "mime-types": { + "version": "2.1.16", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.16.tgz", + "integrity": "sha1-K4WKUuXs1RbbiXrCvodIeDBpjiM=", + "dev": true, + "requires": { + "mime-db": "1.29.0" + } + }, + "mimic-fn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz", + "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=", + "dev": true + }, + "minimatch": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", + "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "dev": true, + "requires": { + "lru-cache": "2.7.3", + "sigmund": "1.0.1" + } + }, + "minimist": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.0.tgz", + "integrity": "sha1-Tf/lJdriuGTGbC4jxicdev3s784=", + "dev": true + }, + "mkdirp": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz", + "integrity": "sha1-3j5fiWHIjHh+4TaN+EmsRBPsqNc=", + "dev": true + }, + "morgan": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.6.1.tgz", + "integrity": "sha1-X9gYOYxoGcuiinzWZk8pL+HAu/I=", + "dev": true, + "requires": { + "basic-auth": "1.0.4", + "debug": "2.2.0", + "depd": "1.0.1", + "on-finished": "2.3.0", + "on-headers": "1.0.1" + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true + }, + "multiparty": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/multiparty/-/multiparty-3.3.2.tgz", + "integrity": "sha1-Nd5oBNwZZD5SSfPT473GyM4wHT8=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "stream-counter": "0.2.0" + } + }, + "multipipe": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", + "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", + "dev": true, + "requires": { + "duplexer2": "0.0.2" + } + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "negotiator": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.5.3.tgz", + "integrity": "sha1-Jp1cR2gQ7JLtvntsLygxY4T5p+g=", + "dev": true + }, + "normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "dev": true, + "requires": { + "hosted-git-info": "2.5.0", + "is-builtin-module": "1.0.0", + "semver": "2.3.2", + "validate-npm-package-license": "3.0.1" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-keys": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", + "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", + "dev": true + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dev": true, + "requires": { + "ee-first": "1.1.1" + } + }, + "on-headers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=", + "dev": true + }, + "once": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "0.1.3", + "fast-levenshtein": "2.0.6", + "levn": "0.3.0", + "prelude-ls": "1.1.2", + "type-check": "0.3.2", + "wordwrap": "1.0.0" + }, + "dependencies": { + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + } + } + }, + "orchestrator": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", + "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", + "dev": true, + "requires": { + "end-of-stream": "0.1.5", + "sequencify": "0.0.7", + "stream-consume": "0.1.0" + } + }, + "ordered-read-streams": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", + "integrity": "sha1-/VZamvjrRHO6abbtijQ1LLVS8SY=", + "dev": true + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "1.3.1" + } + }, + "parseurl": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", + "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=", + "dev": true + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "2.0.1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-parse": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", + "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "dev": true + }, + "path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + } + }, + "pause": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/pause/-/pause-0.1.0.tgz", + "integrity": "sha1-68ikqGGf8LioGsFRPDQ0/0af23Q=", + "dev": true + }, + "pause-stream": { + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "dev": true, + "requires": { + "through": "2.3.8" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "2.0.4" + } + }, + "pkg-dir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", + "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "dev": true, + "requires": { + "find-up": "1.1.2" + } + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "pretty-bytes": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-3.0.1.tgz", + "integrity": "sha1-J9AAjXeAY6C0gRuzXHnxvV1fvM8=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "pretty-hrtime": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-0.2.2.tgz", + "integrity": "sha1-1P2INR46R0H4Fzr31qS4RvmJXAA=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "qs": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-4.0.0.tgz", + "integrity": "sha1-wx2bdOwn33XlQ6hseHKO2NRiNgc=", + "dev": true + }, + "random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=", + "dev": true + }, + "range-parser": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.0.3.tgz", + "integrity": "sha1-aHKCNTXGkuLCoBA4Jq/YLC4P8XU=", + "dev": true + }, + "raw-body": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.1.7.tgz", + "integrity": "sha1-rf6s4uT7MJgFgBTQjActzFl1h3Q=", + "dev": true, + "requires": { + "bytes": "2.4.0", + "iconv-lite": "0.4.13", + "unpipe": "1.0.0" + }, + "dependencies": { + "bytes": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", + "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.13", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz", + "integrity": "sha1-H4irpKsLFQjoMSrMOTRfNumS4vI=", + "dev": true + } + } + }, + "rcfinder": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/rcfinder/-/rcfinder-0.1.9.tgz", + "integrity": "sha1-8+gPOH3fmugK4wpBADKWQuroERU=", + "dev": true, + "requires": { + "lodash.clonedeep": "4.5.0" + } + }, + "rcloader": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/rcloader/-/rcloader-0.2.2.tgz", + "integrity": "sha1-WNIpi0YtC5v9ITPSoex0+9cFxxc=", + "dev": true, + "requires": { + "lodash.assign": "4.2.0", + "lodash.isobject": "3.0.2", + "lodash.merge": "4.6.0", + "rcfinder": "0.1.9" + }, + "dependencies": { + "lodash.isobject": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-3.0.2.tgz", + "integrity": "sha1-PI+41bW/S/kK4G4U8qUwpO2TXh0=", + "dev": true + } + } + }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "dev": true, + "requires": { + "load-json-file": "1.1.0", + "normalize-package-data": "2.4.0", + "path-type": "1.1.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "dev": true, + "requires": { + "find-up": "1.1.2", + "read-pkg": "1.1.0" + } + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "redent": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", + "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", + "dev": true, + "requires": { + "indent-string": "2.1.0", + "strip-indent": "1.0.1" + } + }, + "repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "dev": true, + "requires": { + "is-finite": "1.0.2" + } + }, + "replace-ext": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", + "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", + "dev": true + }, + "require-uncached": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "dev": true, + "requires": { + "caller-path": "0.1.0", + "resolve-from": "1.0.1" + } + }, + "resolve": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-0.6.3.tgz", + "integrity": "sha1-3ZV5gufnNt699TtYpN2RdUV13UY=", + "dev": true + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "dev": true + }, + "response-time": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/response-time/-/response-time-2.3.2.tgz", + "integrity": "sha1-/6cbq5UtYvfB1Jt0NDVfvGjf/Fo=", + "dev": true, + "requires": { + "depd": "1.1.1", + "on-headers": "1.0.1" + }, + "dependencies": { + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", + "dev": true + } + } + }, + "rimraf": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", + "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", + "dev": true, + "requires": { + "glob": "7.1.2" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + } + } + }, + "rndm": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/rndm/-/rndm-1.2.0.tgz", + "integrity": "sha1-8z/pz7Urv9UgqhgyO8ZdsRCht2w=", + "dev": true + }, + "rx-lite": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", + "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", + "dev": true + }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "dev": true, + "requires": { + "rx-lite": "3.1.2" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "semver": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-2.3.2.tgz", + "integrity": "sha1-uYSPJdbPNjMwc+ye+IVtQvEjPlI=", + "dev": true + }, + "send": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.13.2.tgz", + "integrity": "sha1-dl52B8gFVFK7pvCwUllTUJhgNt4=", + "dev": true, + "requires": { + "debug": "2.2.0", + "depd": "1.1.1", + "destroy": "1.0.4", + "escape-html": "1.0.3", + "etag": "1.7.0", + "fresh": "0.3.0", + "http-errors": "1.3.1", + "mime": "1.3.4", + "ms": "0.7.1", + "on-finished": "2.3.0", + "range-parser": "1.0.3", + "statuses": "1.2.1" + }, + "dependencies": { + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", + "dev": true + }, + "statuses": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.2.1.tgz", + "integrity": "sha1-3e1FzBglbVHtQK7BQkidXGECbSg=", + "dev": true + } + } + }, + "sequencify": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", + "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", + "dev": true + }, + "serve-favicon": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/serve-favicon/-/serve-favicon-2.3.2.tgz", + "integrity": "sha1-3UGeJo3gEqtysxnTN/IQUBP5OB8=", + "dev": true, + "requires": { + "etag": "1.7.0", + "fresh": "0.3.0", + "ms": "0.7.2", + "parseurl": "1.3.1" + }, + "dependencies": { + "ms": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", + "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "dev": true + } + } + }, + "serve-index": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.7.3.tgz", + "integrity": "sha1-egV/xu4o3GP2RWbl+lexEahq7NI=", + "dev": true, + "requires": { + "accepts": "1.2.13", + "batch": "0.5.3", + "debug": "2.2.0", + "escape-html": "1.0.3", + "http-errors": "1.3.1", + "mime-types": "2.1.16", + "parseurl": "1.3.1" + } + }, + "serve-static": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.10.3.tgz", + "integrity": "sha1-zlpuzTEB/tXsCYJ9rCKpwpv7BTU=", + "dev": true, + "requires": { + "escape-html": "1.0.3", + "parseurl": "1.3.1", + "send": "0.13.2" + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "shelljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", + "dev": true + }, + "sigmund": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, + "source-map": { + "version": "0.1.34", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.34.tgz", + "integrity": "sha1-p8/omux7FoLDsZjQrPtH19CQVms=", + "dev": true, + "requires": { + "amdefine": "1.0.1" + } + }, + "sparkles": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz", + "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", + "dev": true + }, + "spdx-correct": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", + "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", + "dev": true, + "requires": { + "spdx-license-ids": "1.2.2" + } + }, + "spdx-expression-parse": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", + "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", + "dev": true + }, + "spdx-license-ids": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz", + "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", + "dev": true + }, + "split": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", + "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "dev": true, + "requires": { + "through": "2.3.8" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "dev": true + }, + "stream-combiner": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", + "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "dev": true, + "requires": { + "duplexer": "0.1.1" + } + }, + "stream-consume": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", + "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", + "dev": true + }, + "stream-counter": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/stream-counter/-/stream-counter-0.2.0.tgz", + "integrity": "sha1-3tJmVWMZyLDiIoErnPOyb6fZR94=", + "dev": true, + "requires": { + "readable-stream": "1.1.14" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "strip-ansi": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz", + "integrity": "sha1-OeipjQRNFQZgq+SmgIrPcLt7yZE=", + "dev": true + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, + "requires": { + "is-utf8": "0.2.1" + } + }, + "strip-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", + "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", + "dev": true, + "requires": { + "get-stdin": "4.0.1" + } + }, + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + }, + "supports-color": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", + "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", + "dev": true + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "through2": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", + "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "3.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + } + } + }, + "time-stamp": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", + "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", + "dev": true + }, + "tiny-lr": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tiny-lr/-/tiny-lr-0.2.1.tgz", + "integrity": "sha1-s/26gC5dVqM8L28QeUsy5Hescp0=", + "dev": true, + "requires": { + "body-parser": "1.14.2", + "debug": "2.2.0", + "faye-websocket": "0.10.0", + "livereload-js": "2.2.2", + "parseurl": "1.3.1", + "qs": "5.1.0" + }, + "dependencies": { + "body-parser": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.14.2.tgz", + "integrity": "sha1-EBXLH+LEQ4WCWVgdtTMy+NDPUPk=", + "dev": true, + "requires": { + "bytes": "2.2.0", + "content-type": "1.0.2", + "debug": "2.2.0", + "depd": "1.1.1", + "http-errors": "1.3.1", + "iconv-lite": "0.4.13", + "on-finished": "2.3.0", + "qs": "5.2.0", + "raw-body": "2.1.7", + "type-is": "1.6.15" + }, + "dependencies": { + "qs": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-5.2.0.tgz", + "integrity": "sha1-qfMRQq9GjLcrJbMBNrokVoNJFr4=", + "dev": true + } + } + }, + "bytes": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.2.0.tgz", + "integrity": "sha1-/TVGSkA/b5EXwt42Cez/nK4ABYg=", + "dev": true + }, + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.13", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz", + "integrity": "sha1-H4irpKsLFQjoMSrMOTRfNumS4vI=", + "dev": true + }, + "qs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-5.1.0.tgz", + "integrity": "sha1-TZMuXH6kEcynajEtOaYGIA/VDNk=", + "dev": true + } + } + }, + "tmp": { + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", + "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2" + } + }, + "trim-newlines": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", + "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", + "dev": true + }, + "tryit": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", + "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=", + "dev": true + }, + "tsscmp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.5.tgz", + "integrity": "sha1-fcSjOvcVgatDN9qR2FylQn69mpc=", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2" + } + }, + "type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "dev": true, + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.16" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "uglify-js": { + "version": "2.4.24", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.4.24.tgz", + "integrity": "sha1-+tV1XB4Vd2WLsG/5q25UjJW+vW4=", + "dev": true, + "requires": { + "async": "0.2.10", + "source-map": "0.1.34", + "uglify-to-browserify": "1.0.2", + "yargs": "3.5.4" + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true + }, + "uid-safe": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.4.tgz", + "integrity": "sha1-Otbzg2jG1MjHXsF2I/t5qh0HHYE=", + "dev": true, + "requires": { + "random-bytes": "1.0.0" + } + }, + "unique-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", + "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=", + "dev": true + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "utils-merge": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=", + "dev": true + }, + "validate-npm-package-license": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", + "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", + "dev": true, + "requires": { + "spdx-correct": "1.0.2", + "spdx-expression-parse": "1.0.4" + } + }, + "vary": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.0.1.tgz", + "integrity": "sha1-meSYFWaihhGN+yuBc1ffeZM3bRA=", + "dev": true + }, + "vhost": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/vhost/-/vhost-3.0.2.tgz", + "integrity": "sha1-L7HezUxGaqiLD5NBrzPcGv8keNU=", + "dev": true + }, + "vinyl": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.2.3.tgz", + "integrity": "sha1-vKk4IJWC7FpJrVOKAPofEl5RMlI=", + "dev": true, + "requires": { + "clone-stats": "0.0.1" + } + }, + "vinyl-fs": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.1.4.tgz", + "integrity": "sha1-Q294GLaIVMt0Jc0y+r118sxtMh8=", + "dev": true, + "requires": { + "glob-stream": "3.1.18", + "glob-watcher": "0.0.6", + "graceful-fs": "2.0.3", + "map-stream": "0.1.0", + "mkdirp": "0.3.5", + "vinyl": "0.2.3" + }, + "dependencies": { + "graceful-fs": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz", + "integrity": "sha1-fNLNsiiko/Nule+mzBQt59GhNtA=", + "dev": true + } + } + }, + "websocket-driver": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.6.5.tgz", + "integrity": "sha1-XLJVbOuF9Dc8bYI4qmkchFThOjY=", + "dev": true, + "requires": { + "websocket-extensions": "0.1.1" + } + }, + "websocket-extensions": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.1.tgz", + "integrity": "sha1-domUmcGEtu91Q3fC27DNbLVdKec=", + "dev": true + }, + "which": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "dev": true, + "requires": { + "isexe": "2.0.0" + } + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "dev": true, + "requires": { + "mkdirp": "0.5.1" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + } + } + }, + "xtend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", + "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=", + "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + }, + "yargs": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.5.4.tgz", + "integrity": "sha1-2K/49mXpTDS9JZvevRv68N3TU2E=", + "dev": true, + "requires": { + "camelcase": "1.2.1", + "decamelize": "1.2.0", + "window-size": "0.1.0", + "wordwrap": "0.0.2" + }, + "dependencies": { + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + } + } + } + } +} diff --git a/package.json b/package.json index bed03ce2..e12badbf 100644 --- a/package.json +++ b/package.json @@ -3,19 +3,29 @@ "private": true, "version": "0.0.1", "description": "WebGL point cloud viewer", + "scripts": { + "lint": "eslint src", + "test": "npm run lint" + }, "dependencies": {}, "author": "Markus Schütz", "license": "BSD-2-CLAUSE", "devDependencies": { + "eslint": "^4.3.0", + "eslint-config-happiness": "^10.2.1", + "eslint-plugin-import": "^2.7.0", + "eslint-plugin-node": "^5.1.1", + "eslint-plugin-promise": "^3.5.0", + "eslint-plugin-standard": "^3.0.1", "gulp": "~3.5.2", - "gulp-jshint": "^2.0.4", - "gulp-size": "^2.1.0", - "jshint": "^2.9.5" "gulp-concat": "~2.1.7", "gulp-connect": "^2.3.1", + "gulp-jshint": "^2.0.4", "gulp-rename": "~1.0.0", + "gulp-size": "^2.1.0", "gulp-uglify": "~0.2.1", "gulp-util": "~2.2.20", + "jshint": "^2.9.5", "through": "~2.3.4" } } diff --git a/src/Actions.js b/src/Actions.js index 443fb851..9af53fb5 100644 --- a/src/Actions.js +++ b/src/Actions.js @@ -1,86 +1,80 @@ -Potree.Action = class Action extends THREE.EventDispatcher{ - - constructor(args = {}){ +Potree.Action = class Action extends THREE.EventDispatcher { + constructor (args = {}) { super(); - - this.icon = args.icon || ""; + + this.icon = args.icon || ''; this.tooltip = args.tooltip; - - if(args.onclick !== undefined){ + + if (args.onclick !== undefined) { this.onclick = args.onclick; } - } - - onclick(event){ - + + onclick (event) { + } - - pairWith(object){ - + + pairWith (object) { + } - - setIcon(newIcon){ + + setIcon (newIcon) { let oldIcon = this.icon; - - if(newIcon === oldIcon){ + + if (newIcon === oldIcon) { return; } - + this.icon = newIcon; - + this.dispatchEvent({ - type: "icon_changed", + type: 'icon_changed', action: this, icon: newIcon, oldIcon: oldIcon }); } - }; Potree.Actions = {}; -Potree.Actions.ToggleAnnotationVisibility = class ToggleAnnotationVisibility extends Potree.Action{ - - constructor(args = {}){ +Potree.Actions.ToggleAnnotationVisibility = class ToggleAnnotationVisibility extends Potree.Action { + constructor (args = {}) { super(args); - - this.icon = Potree.resourcePath + "/icons/eye.svg"; - this.showIn = "sidebar"; - this.tooltip = "toggle visibility"; + + this.icon = Potree.resourcePath + '/icons/eye.svg'; + this.showIn = 'sidebar'; + this.tooltip = 'toggle visibility'; } - - pairWith(annotation){ - - if(annotation.visible){ - this.setIcon(Potree.resourcePath + "/icons/eye.svg"); - }else{ - this.setIcon(Potree.resourcePath + "/icons/eye_crossed.svg"); + + pairWith (annotation) { + if (annotation.visible) { + this.setIcon(Potree.resourcePath + '/icons/eye.svg'); + } else { + this.setIcon(Potree.resourcePath + '/icons/eye_crossed.svg'); } - - annotation.addEventListener("visibility_changed", e => { + + annotation.addEventListener('visibility_changed', e => { let annotation = e.annotation; - - if(annotation.visible){ - this.setIcon(Potree.resourcePath + "/icons/eye.svg"); - }else{ - this.setIcon(Potree.resourcePath + "/icons/eye_crossed.svg"); + + if (annotation.visible) { + this.setIcon(Potree.resourcePath + '/icons/eye.svg'); + } else { + this.setIcon(Potree.resourcePath + '/icons/eye_crossed.svg'); } }); } - - onclick(event){ + + onclick (event) { let annotation = event.annotation; - + annotation.visible = !annotation.visible; - - if(annotation.visible){ - this.setIcon(Potree.resourcePath + "/icons/eye.svg"); - }else{ - this.setIcon(Potree.resourcePath + "/icons/eye_crossed.svg"); + + if (annotation.visible) { + this.setIcon(Potree.resourcePath + '/icons/eye.svg'); + } else { + this.setIcon(Potree.resourcePath + '/icons/eye_crossed.svg'); } } -} - +}; diff --git a/src/AnimationPath.js b/src/AnimationPath.js index 8b9036d6..b622a9f5 100644 --- a/src/AnimationPath.js +++ b/src/AnimationPath.js @@ -1,29 +1,26 @@ -// -// TODO -// +// +// TODO +// // - option to look along path during animation -// - -// +// - +// - -Potree.AnimationPath = class{ - - constructor(points = []){ +Potree.AnimationPath = class { + constructor (points = []) { this.points = points; this.spline = new THREE.Spline(points); this.spline.reparametrizeByArcLength(1 / this.spline.getLength().total); this.tween = null; } - - get(t){ + + get (t) { return this.spline.getPoint(t); } - - animate(metersPerSecond = 1){ - - stop(); - + + animate (metersPerSecond = 1) { + this.stop(); + let length = this.spline.getLength().total; let animationDuration = (1000 * length) / metersPerSecond; @@ -33,52 +30,50 @@ Potree.AnimationPath = class{ this.tween.onUpdate((e) => { viewer.scene.view.position.copy(this.spline.getPoint(progress.t)); }); - + this.tween.start(); } - - stop(){ - if(this.tween){ + + stop () { + if (this.tween) { this.tween.stop(); } } - - resume(){ - if(this.tween){ + + resume () { + if (this.tween) { this.tween.start(); } } - - getGeometry(){ + + getGeometry () { let geometry = new THREE.Geometry(); - + let samples = 100; let i = 0; - for(let u = 0; u <= 1; u += 1 / samples){ + for (let u = 0; u <= 1; u += 1 / samples) { let position = this.spline.getPoint(u); - geometry.vertices[i] = new THREE.Vector3( position.x, position.y, position.z ); - + geometry.vertices[i] = new THREE.Vector3(position.x, position.y, position.z); + i++; } - + return geometry; - - //let material = new THREE.LineBasicMaterial( { color: 0xffffff, opacity: 1, linewidth: 2 } ); - //let line = new THREE.Line(geometry, material); - //viewer.scene.scene.add(line); + + // let material = new THREE.LineBasicMaterial( { color: 0xffffff, opacity: 1, linewidth: 2 } ); + // let line = new THREE.Line(geometry, material); + // viewer.scene.scene.add(line); } }; - - -//let target = new THREE.Vector3(589854.34, 231411.19, 692.77) -//let points = [ +// let target = new THREE.Vector3(589854.34, 231411.19, 692.77) +// let points = [ // new THREE.Vector3(589815.52, 231738.31, 959.48 ), // new THREE.Vector3(589604.73, 231615.00, 968.10 ), // new THREE.Vector3(589579.11, 231354.41, 1010.06), // new THREE.Vector3(589723.00, 231169.95, 1015.57), // new THREE.Vector3(589960.76, 231116.87, 978.60 ), // new THREE.Vector3(590139.29, 231268.71, 972.33 ) -//] +// ] // -//let path = new Potree.AnimationPath(points); \ No newline at end of file +// let path = new Potree.AnimationPath(points); diff --git a/src/Annotation.js b/src/Annotation.js index 8a079b15..d290cce4 100644 --- a/src/Annotation.js +++ b/src/Annotation.js @@ -1,25 +1,24 @@ -Potree.Annotation = class extends THREE.EventDispatcher{ - - constructor(args = {}){ +Potree.Annotation = class extends THREE.EventDispatcher { + constructor (args = {}) { super(); - + this.scene = null; - this.title = args.title || "No Title"; - this.description = args.description || ""; - - if(!args.position){ - //this.position = new THREE.Vector3(0, 0, 0); + this.title = args.title || 'No Title'; + this.description = args.description || ''; + + if (!args.position) { + // this.position = new THREE.Vector3(0, 0, 0); this.position = null; - }else if(args.position instanceof THREE.Vector3){ + } else if (args.position instanceof THREE.Vector3) { this.position = args.position; - }else{ + } else { this.position = new THREE.Vector3(...args.position); } - - this.cameraPosition = (args.cameraPosition instanceof Array) ? - new THREE.Vector3().fromArray(args.cameraPosition) : args.cameraPosition; - this.cameraTarget = (args.cameraTarget instanceof Array) ? - new THREE.Vector3().fromArray(args.cameraTarget) : args.cameraTarget; + + this.cameraPosition = (args.cameraPosition instanceof Array) + ? new THREE.Vector3().fromArray(args.cameraPosition) : args.cameraPosition; + this.cameraTarget = (args.cameraTarget instanceof Array) + ? new THREE.Vector3().fromArray(args.cameraTarget) : args.cameraTarget; this.radius = args.radius; this.view = args.view || null; this.keepOpen = false; @@ -32,13 +31,13 @@ Potree.Annotation = class extends THREE.EventDispatcher{ this._display = true; this._expand = false; this.collapseThreshold = [args.collapseThreshold, 100].find(e => e !== undefined); - + this.children = []; this.parent = null; this.boundingBox = new THREE.Box3(); - - let iconClose = Potree.resourcePath + "/icons/close.svg"; - + + let iconClose = Potree.resourcePath + '/icons/close.svg'; + this.domElement = $(`
@@ -52,272 +51,267 @@ Potree.Annotation = class extends THREE.EventDispatcher{
`); - - this.elTitlebar = this.domElement.find(".annotation-titlebar"); - this.elTitle = this.elTitlebar.find(".annotation-label"); - this.elDescription = this.domElement.find(".annotation-description"); - this.elDescriptionClose = this.elDescription.find(".annotation-description-close"); - //this.elDescriptionContent = this.elDescription.find(".annotation-description-content"); - + + this.elTitlebar = this.domElement.find('.annotation-titlebar'); + this.elTitle = this.elTitlebar.find('.annotation-label'); + this.elDescription = this.domElement.find('.annotation-description'); + this.elDescriptionClose = this.elDescription.find('.annotation-description-close'); + // this.elDescriptionContent = this.elDescription.find(".annotation-description-content"); + this.clickTitle = () => { - if(this.hasView()){ + if (this.hasView()) { this.moveHere(this.scene.camera); } - this.dispatchEvent({type: "click", target: this}); + this.dispatchEvent({type: 'click', target: this}); }; - + this.elTitle.click(this.clickTitle); - + this.actions = this.actions.map(a => { - if(a instanceof Potree.Action){ + if (a instanceof Potree.Action) { return a; - }else{ + } else { return new Potree.Action(a); } }); - - for(let action of this.actions){ + + for (let action of this.actions) { action.pairWith(this); } - + let actions = this.actions.filter( - a => a.showIn === undefined || a.showIn.includes("scene")); - - for(let action of actions){ - this.elTitle.css("padding", "1px 3px 0px 8px"); - + a => a.showIn === undefined || a.showIn.includes('scene')); + + for (let action of actions) { + this.elTitle.css('padding', '1px 3px 0px 8px'); + let elButton = $(``); this.elTitlebar.append(elButton); elButton.click(() => action.onclick({annotation: this})); } - + this.elDescriptionClose.hover( - e => this.elDescriptionClose.css("opacity", "1"), - e => this.elDescriptionClose.css("opacity", "0.5") + e => this.elDescriptionClose.css('opacity', '1'), + e => this.elDescriptionClose.css('opacity', '0.5') ); this.elDescriptionClose.click(e => this.setHighlighted(false)); - //this.elDescriptionContent.html(this.description); - + // this.elDescriptionContent.html(this.description); + this.domElement.mouseenter(e => this.setHighlighted(true)); this.domElement.mouseleave(e => this.setHighlighted(false)); - - this.domElement.on("touchstart", e => { + + this.domElement.on('touchstart', e => { this.setHighlighted(!this.isHighlighted); }); - + this.display = false; } - - get visible(){ + + get visible () { return this._visible; } - - set visible(value){ - if(this._visible === value){ + + set visible (value) { + if (this._visible === value) { return; } - + this._visible = value; - + this.traverse(node => { node.display = value; }); - + this.dispatchEvent({ - type: "visibility_changed", + type: 'visibility_changed', annotation: this }); } - - get display(){ + + get display () { return this._display; } - - set display(display){ - - if(this._display === display){ + + set display (display) { + if (this._display === display) { return; } - + this._display = display; - - if(display){ - //this.domElement.fadeIn(200); + + if (display) { + // this.domElement.fadeIn(200); this.domElement.show(); - }else{ - //this.domElement.fadeOut(200); + } else { + // this.domElement.fadeOut(200); this.domElement.hide(); } } - - get expand(){ + + get expand () { return this._expand; } - - set expand(expand){ - - if(this._expand === expand){ + + set expand (expand) { + if (this._expand === expand) { return; } - - if(expand){ + + if (expand) { this.display = false; - }else{ + } else { this.display = true; this.traverseDescendants(node => { node.display = false; }); } - + this._expand = expand; } - - add(annotation){ - if(!this.children.includes(annotation)){ + + add (annotation) { + if (!this.children.includes(annotation)) { this.children.push(annotation); annotation.parent = this; - + let descendants = []; - annotation.traverse(a => {descendants.push(a)}); - - for(let descendant of descendants){ + annotation.traverse(a => { descendants.push(a); }); + + for (let descendant of descendants) { let c = this; - while(c !== null){ + while (c !== null) { c.dispatchEvent({ - "type": "annotation_added", - "annotation": descendant + 'type': 'annotation_added', + 'annotation': descendant }); c = c.parent; } } - } } - - level(){ - if(this.parent === null){ + + level () { + if (this.parent === null) { return 0; - }else{ + } else { return this.parent.level() + 1; } } - - remove(annotation){ + + remove (annotation) { this.children = this.children.filter(e => e !== annotation); annotation.parent = null; } - - updateBounds(){ + + updateBounds () { let box = new THREE.Box3(); - - if(this.position){ + + if (this.position) { box.expandByPoint(this.position); } - - for(let child of this.children){ + + for (let child of this.children) { child.updateBounds(); - + box.union(child.boundingBox); } - + this.boundingBox.copy(box); } - - traverse(callback){ - let expand = callback(this); - - if(expand === undefined || expand === true){ - for(let child of this.children){ - child.traverse(callback); + + traverse (handler) { + let expand = handler(this); + + if (expand === undefined || expand === true) { + for (let child of this.children) { + child.traverse(handler); } } } - - traverseDescendants(callback){ - for(let child of this.children){ - child.traverse(callback); + + traverseDescendants (handler) { + for (let child of this.children) { + child.traverse(handler); } } - - flatten(){ + + flatten () { let annotations = []; - + this.traverse(annotation => { annotations.push(annotation); }); - + return annotations; } - - descendants(){ + + descendants () { let annotations = []; - + this.traverse(annotation => { - if(annotation !== this){ + if (annotation !== this) { annotations.push(annotation); } }); - + return annotations; } - - setHighlighted(highlighted){ - if(highlighted){ - this.domElement.css("opacity", "0.8"); - this.elTitlebar.css("box-shadow", "0 0 5px #fff"); - this.domElement.css("z-index", "1000"); - - if(this.description){ - this.descriptionVisible = true; - //this.elDescription.css("display", "block"); + + setHighlighted (highlighted) { + if (highlighted) { + this.domElement.css('opacity', '0.8'); + this.elTitlebar.css('box-shadow', '0 0 5px #fff'); + this.domElement.css('z-index', '1000'); + + if (this.description) { + this.descriptionVisible = true; + // this.elDescription.css("display", "block"); this.elDescription.fadeIn(200); - this.elDescription.css("position", "relative"); + this.elDescription.css('position', 'relative'); } - }else{ - this.domElement.css("opacity", "0.5"); - this.elTitlebar.css("box-shadow", ""); - this.domElement.css("z-index", "100"); - this.descriptionVisible = false; - this.elDescription.css("display", "none"); - //this.elDescription.fadeOut(200); + } else { + this.domElement.css('opacity', '0.5'); + this.elTitlebar.css('box-shadow', ''); + this.domElement.css('z-index', '100'); + this.descriptionVisible = false; + this.elDescription.css('display', 'none'); + // this.elDescription.fadeOut(200); } - + this.isHighlighted = highlighted; } - - hasView(){ + + hasView () { let hasPosTargetView = this.cameraTarget instanceof THREE.Vector3; hasPosTargetView = hasPosTargetView && this.cameraPosition instanceof THREE.Vector3; - + let hasRadiusView = this.radius !== undefined; - + let hasView = hasPosTargetView || hasRadiusView; - + return hasView; }; - - moveHere(camera){ - if(!this.hasView()){ + + moveHere (camera) { + if (!this.hasView()) { return; } let view = this.scene.view; - + var animationDuration = 300; var easing = TWEEN.Easing.Quartic.Out; - - + let endTarget; - if(this.cameraTarget){ + if (this.cameraTarget) { endTarget = this.cameraTarget; - }else if(this.position){ + } else if (this.position) { endTarget = this.position; - }else{ + } else { endTarget = this.boundingBox.getCenter(); } - - if(this.cameraPosition){ - + + if (this.cameraPosition) { let endPosition = this.cameraPosition; { // animate camera position @@ -325,11 +319,11 @@ Potree.Annotation = class extends THREE.EventDispatcher{ tween.easing(easing); tween.start(); } - + { // animate camera target var camTargetDistance = camera.position.distanceTo(endTarget); var target = new THREE.Vector3().addVectors( - camera.position, + camera.position, camera.getWorldDirection().clone().multiplyScalar(camTargetDistance) ); var tween = new TWEEN.Tween(target).to(endTarget, animationDuration); @@ -339,49 +333,45 @@ Potree.Annotation = class extends THREE.EventDispatcher{ }); tween.onComplete(() => { view.lookAt(target); - this.dispatchEvent({type: "focusing_finished", target: this}); + this.dispatchEvent({type: 'focusing_finished', target: this}); }); - - this.dispatchEvent({type: "focusing_started", target: this}); + + this.dispatchEvent({type: 'focusing_started', target: this}); tween.start(); } - }else if(this.radius){ + } else if (this.radius) { let direction = view.direction; let endPosition = endTarget.clone().add(direction.multiplyScalar(-this.radius)); let startRadius = view.radius; let endRadius = this.radius; - + { // animate camera position let tween = new TWEEN.Tween(view.position).to(endPosition, animationDuration); tween.easing(easing); tween.start(); } - + { // animate radius let t = {x: 0}; - + let tween = new TWEEN.Tween(t) .to({x: 1}, animationDuration) - .onUpdate(function(){ + .onUpdate(function () { view.radius = this.x * endRadius + (1 - this.x) * startRadius; }); tween.easing(easing); tween.start(); } - } }; - - dispose(){ - if(this.domElement.parentElement){ + + dispose () { + if (this.domElement.parentElement) { this.domElement.parentElement.removeChild(this.domElement); } - }; - - - - toString(){ - return "Annotation: " + this.title; + + toString () { + return 'Annotation: ' + this.title; } }; diff --git a/src/BitReader.js b/src/BitReader.js index a6c43063..eff62b6c 100644 --- a/src/BitReader.js +++ b/src/BitReader.js @@ -1,4 +1,5 @@ - +/* globals BitReader:true */ +/* exported BitReader */ /** * Reads unsigned integers encoded in a variable amount of bits from the buffer. * Bits are aligned into 32bit unsigned integers. @@ -6,44 +7,44 @@ * x: 123 encoded in 11 bits, binary: 00001111011 * y: 7945 encoded in 17 bits, binary: 00001111100001001 * z: 12 encoded in 6 bits, binary: 001100 - * - * | --- 32 bits --- || --- 32 bits --- | + * + * | --- 32 bits --- || --- 32 bits --- | * |................................||................................| * |00001111011000011111000010010011||00 * | x || y || z | * - * z does not fit fully into the first 32 bit integer. - * The first 4 bits of z are stored at the end of the first 32 bit integer + * z does not fit fully into the first 32 bit integer. + * The first 4 bits of z are stored at the end of the first 32 bit integer * and the remaining 2 bits at the next 32 bit integer. - * + * */ -BitReader = function(buf){ - +BitReader = function (buf) { var buffer = new Uint32Array(buf); var bitOffset = 0; - - this.read = function(bits){ + + this.read = function (bits) { var result; - - if((bitOffset % 32) + bits <= 32){ - var val = buffer[Math.floor(bitOffset / 32)]; - var leftGap = bitOffset % 32; - var rightGap = 32 - (leftGap + bits); - + + // TODO val & leftGap seem to be duplicate code? Move out of if-block + if ((bitOffset % 32) + bits <= 32) { + let val = buffer[Math.floor(bitOffset / 32)]; + let leftGap = bitOffset % 32; + let rightGap = 32 - (leftGap + bits); + result = (val << leftGap) >>> (leftGap + rightGap); - }else{ - var val = buffer[Math.floor(bitOffset / 32)]; - var leftGap = bitOffset % 32; - var rightGap = (leftGap + bits) - 32; - + } else { + let val = buffer[Math.floor(bitOffset / 32)]; + let leftGap = bitOffset % 32; + let rightGap = (leftGap + bits) - 32; + result = (val << leftGap) >>> (leftGap - rightGap); - - val = buffer[Math.floor(bitOffset / 32)+1]; + + val = buffer[Math.floor(bitOffset / 32) + 1]; result = result | val >>> (32 - rightGap); } - + bitOffset += bits; - + return result; }; -}; \ No newline at end of file +}; diff --git a/src/Features.js b/src/Features.js index f868d9d3..289f67b8 100644 --- a/src/Features.js +++ b/src/Features.js @@ -1,74 +1,66 @@ -Potree.Features = function(){ - - var ftCanvas = document.createElement("canvas"); - var gl = ftCanvas.getContext("webgl") || ftCanvas.getContext("experimental-webgl"); - if (gl === null) - return null; +Potree.Features = (function () { + var ftCanvas = document.createElement('canvas'); + var gl = ftCanvas.getContext('webgl') || ftCanvas.getContext('experimental-webgl'); + if (gl === null) { return null; } // -- code taken from THREE.WebGLRenderer -- - var _vertexShaderPrecisionHighpFloat = gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.HIGH_FLOAT ); - var _vertexShaderPrecisionMediumpFloat = gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ); - var _vertexShaderPrecisionLowpFloat = gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.LOW_FLOAT ); + var _vertexShaderPrecisionHighpFloat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT); + var _vertexShaderPrecisionMediumpFloat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT); + // Unused: var _vertexShaderPrecisionLowpFloat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT); - var _fragmentShaderPrecisionHighpFloat = gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ); - var _fragmentShaderPrecisionMediumpFloat = gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ); - var _fragmentShaderPrecisionLowpFloat = gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.LOW_FLOAT ); + var _fragmentShaderPrecisionHighpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); + var _fragmentShaderPrecisionMediumpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT); + // Unused: var _fragmentShaderPrecisionLowpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT); var highpAvailable = _vertexShaderPrecisionHighpFloat.precision > 0 && _fragmentShaderPrecisionHighpFloat.precision > 0; var mediumpAvailable = _vertexShaderPrecisionMediumpFloat.precision > 0 && _fragmentShaderPrecisionMediumpFloat.precision > 0; // ----------------------------------------- var precision; - if(highpAvailable){ - precision = "highp"; - }else if(mediumpAvailable){ - precision = "mediump"; - }else{ - precision = "lowp"; + if (highpAvailable) { + precision = 'highp'; + } else if (mediumpAvailable) { + precision = 'mediump'; + } else { + precision = 'lowp'; } return { SHADER_INTERPOLATION: { - isSupported: function(){ - + isSupported: function () { var supported = true; - supported = supported && gl.getExtension("EXT_frag_depth"); + supported = supported && gl.getExtension('EXT_frag_depth'); supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8; return supported; } }, SHADER_SPLATS: { - isSupported: function(){ - + isSupported: function () { var supported = true; - supported = supported && gl.getExtension("EXT_frag_depth"); - supported = supported && gl.getExtension("OES_texture_float"); + supported = supported && gl.getExtension('EXT_frag_depth'); + supported = supported && gl.getExtension('OES_texture_float'); supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8; return supported; - } }, SHADER_EDL: { - isSupported: function(){ - + isSupported: function () { var supported = true; - - supported = supported && gl.getExtension("EXT_frag_depth"); - supported = supported && gl.getExtension("OES_texture_float"); + + supported = supported && gl.getExtension('EXT_frag_depth'); + supported = supported && gl.getExtension('OES_texture_float'); supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8; - + return supported; - } - + }, precision: precision }; - -}(); +}()); diff --git a/src/LRU.js b/src/LRU.js index ed43e9f8..3b501348 100644 --- a/src/LRU.js +++ b/src/LRU.js @@ -1,21 +1,20 @@ - /** - * + * * @param node - * @class an item in the lru list. + * @class an item in the lru list. */ -function LRUItem(node){ +function LRUItem (node) { this.previous = null; this.next = null; this.node = node; } /** - * + * * @class A doubly-linked-list of the least recently used elements. */ -function LRU(){ +function LRU () { // the least recently used item this.first = null; // the most recently used item @@ -28,50 +27,50 @@ function LRU(){ /** * number of elements in the list - * + * * @returns {Number} */ -LRU.prototype.size = function(){ +LRU.prototype.size = function () { return this.elements; }; -LRU.prototype.contains = function(node){ +LRU.prototype.contains = function (node) { return this.items[node.id] == null; }; /** * makes node the most recently used item. if the list does not contain node, it will be added. - * + * * @param node */ -LRU.prototype.touch = function(node){ - if(!node.loaded){ +LRU.prototype.touch = function (node) { + if (!node.loaded) { return; } var item; - if(this.items[node.id] == null){ + if (this.items[node.id] == null) { // add to list item = new LRUItem(node); item.previous = this.last; this.last = item; - if(item.previous !== null){ + if (item.previous !== null) { item.previous.next = item; } - + this.items[node.id] = item; this.elements++; - - if(this.first === null){ + + if (this.first === null) { this.first = item; } this.numPoints += node.numPoints; - }else{ + } else { // update in list item = this.items[node.id]; - if(item.previous === null){ + if (item.previous === null) { // handle touch on first element - if(item.next !== null){ + if (item.next !== null) { this.first = item.next; this.first.previous = null; item.previous = this.last; @@ -79,9 +78,9 @@ LRU.prototype.touch = function(node){ this.last = item; item.previous.next = item; } - }else if(item.next === null){ + } else if (item.next === null) { // handle touch on last element - }else{ + } else { // handle touch on any other element item.previous.next = item.next; item.next.previous = item.previous; @@ -90,22 +89,20 @@ LRU.prototype.touch = function(node){ this.last = item; item.previous.next = item; } - - } }; -///** -// * removes the least recently used item from the list and returns it. +/// ** +// * removes the least recently used item from the list and returns it. // * if the list was empty, null will be returned. // */ -//LRU.prototype.remove = function remove(){ +// LRU.prototype.remove = function remove(){ // if(this.first === null){ // return null; // } // var lru = this.first; // -// // if the lru list contains at least 2 items, the item after the least recently used elemnt will be the new lru item. +// // if the lru list contains at least 2 items, the item after the least recently used elemnt will be the new lru item. // if(lru.next !== null){ // this.first = lru.next; // this.first.previous = null; @@ -113,100 +110,96 @@ LRU.prototype.touch = function(node){ // this.first = null; // this.last = null; // } -// +// // delete this.items[lru.node.id]; // this.elements--; // this.numPoints -= lru.node.numPoints; -// -//// Logger.info("removed node: " + lru.node.id); +// +/// / Logger.info("removed node: " + lru.node.id); // return lru.node; -//}; - -LRU.prototype.remove = function remove(node){ +// }; +LRU.prototype.remove = function remove (node) { var lruItem = this.items[node.id]; - if(lruItem){ - - if(this.elements === 1){ + if (lruItem) { + if (this.elements === 1) { this.first = null; this.last = null; - }else{ - if(!lruItem.previous){ + } else { + if (!lruItem.previous) { this.first = lruItem.next; this.first.previous = null; } - if(!lruItem.next){ + if (!lruItem.next) { this.last = lruItem.previous; this.last.next = null; } - if(lruItem.previous &&lruItem.next){ + if (lruItem.previous && lruItem.next) { lruItem.previous.next = lruItem.next; lruItem.next.previous = lruItem.previous; } } - + delete this.items[node.id]; this.elements--; this.numPoints -= node.numPoints; } - }; -LRU.prototype.getLRUItem = function(){ - if(this.first === null){ +LRU.prototype.getLRUItem = function () { + if (this.first === null) { return null; } var lru = this.first; - + return lru.node; }; -LRU.prototype.toString = function(){ - var string = "{ "; +LRU.prototype.toString = function () { + var string = '{ '; var curr = this.first; - while(curr !== null){ + while (curr !== null) { string += curr.node.id; - if(curr.next !== null){ - string += ", "; + if (curr.next !== null) { + string += ', '; } curr = curr.next; } - string += "}"; - string += "(" + this.size() + ")"; + string += '}'; + string += '(' + this.size() + ')'; return string; }; -LRU.prototype.freeMemory = function(){ - if(this.elements <= 1){ +LRU.prototype.freeMemory = function () { + if (this.elements <= 1) { return; } - while(this.numPoints > Potree.pointLoadLimit){ + while (this.numPoints > Potree.pointLoadLimit) { var element = this.first; var node = element.node; this.disposeDescendants(node); - } }; -LRU.prototype.disposeDescendants = function(node){ +LRU.prototype.disposeDescendants = function (node) { var stack = []; stack.push(node); - while(stack.length > 0){ + while (stack.length > 0) { var current = stack.pop(); - - //console.log(current); - + + // console.log(current); + current.dispose(); this.remove(current); - - for(var key in current.children){ - if(current.children.hasOwnProperty(key)){ + + for (var key in current.children) { + if (current.children.hasOwnProperty(key)) { var child = current.children[key]; - if(child.loaded){ + if (child.loaded) { stack.push(current.children[key]); } } } } -}; \ No newline at end of file +}; diff --git a/src/PointCloud.js b/src/PointCloud.js index c4cb7529..88844d22 100644 --- a/src/PointCloud.js +++ b/src/PointCloud.js @@ -1,65 +1,65 @@ // -//Potree.PointCloud = class PointCloud extends THREE.Object3D{ -// +// Potree.PointCloud = class PointCloud extends THREE.Object3D{ +// // constructor(octree){ // this.octree = octree; // } // -//}; +// }; // -//Potree.GLObject = class GLObject{ +// Potree.GLObject = class GLObject{ // constructor(tBuffer){ // this.tBuffer = tBuffer; // this.vbos = new Map(); // } -//}; +// }; // -//Potree.GLProgram = class GLProgram{ +// Potree.GLProgram = class GLProgram{ // constructor(tMaterial){ // this.tMaterial = tMaterial; // this.program = null; // this.uniforms = new Map(); // } -//}; +// }; // // // -//Potree.Renderer = class PotreeRenderer{ +// Potree.Renderer = class PotreeRenderer{ // constructor(threeRenderer){ // this.threeRenderer = threeRenderer; // this.gl = this.threeRenderer.getContext(); -// +// // this.glObjects = new Map(); // this.glPrograms = new Map(); // } -// +// // render(pointcloud){ // let gl = this.gl; // this.threeRenderer.resetGLState(); -// +// // let visibleNodes = pointcloud.visibleNodes; // let material = pointcloud.material; -// +// // let glProgram = this.glPrograms.get(material); // if(!glProgram){ // this.createProgram(material); // glProgram = this.glPrograms.get(material); // } -// +// // for(let node of visibleNodes){ // if(!(node.sceneNode && node.sceneNode instanceof THREE.Points)){ // continue; // } -// +// // let glObject = this.glObjects.get(node); // if(!glObject){ // this.createObject(node); // glObject = this.glObjects.get(node); // } -// +// // for(let attribute of Object.keys(glObject.buffers)){ // let value = glObject.buffers[attribute]; -// +// // let type = null; // if(value.threeAttribute.array instanceof Float32Array){ // type = gl.FLOAT; @@ -68,29 +68,29 @@ // }else if(value.threeAttribute.array instanceof Uint18Array){ // type = gl.BYTE; // } -// +// // let itemSize = value.threeAttribute.itemSize; -// +// // gl.bindBuffer(gl.ARRAY_BUFFER, value.vbo); // gl.vertexAttribPointer(vertexPositionAttribute, itemSize, type, false, 0, 0); // } -// +// // gl.drawArrays(gl.POINT, 0, glObject.buffers.threeAttribute.position.count); // } -// +// // gl.bindBuffer(gl.ARRAY_BUFFER, null); -// -// +// +// // this.threeRenderer.resetGLState(); // } -// +// // createShader(type, source){ // let gl = this.gl; -// +// // let shader = gl.createShader(type); // gl.shaderSource(shader, source); // gl.compileShader(shader); -// +// // let success = gl.getShaderParameter(shader, gl.COMPILE_STATUS); // if(success){ // return shader; @@ -98,83 +98,83 @@ // console.err("Shader compilation failed:"); // console.err(gl.getShaderInfoLog(shader)); // gl.deleteShader(shader); -// +// // return null; // } // } -// +// // createProgram(material){ // let gl = this.gl; -// +// // let vsSource = material.vertexShader; // let fsSource = material.fragmentShader; -// +// // let vs = this.createShader(gl.VERTEX_SHADER, vsSource); // let fs = this.createShader(gl.FRAGMENT_SHADER, fsSource); -// +// // if(vs === null || fs === null){ // return null; // } -// +// // let program = gl.createProgram(); // gl.attachShader(program, vs); // gl.attachShader(program, fs); // gl.linkProgram(program); -// +// // let success = gl.getProgramParameter(program, gl.LINK_STATUS); // if(!success){ // console.err("failed to create/link shader program"); // console.err(gl.getProgramInfoLog(program)); // gl.deleteProgram(program); -// +// // return null; // } -// +// // let glProgram = new Potree.GLProgram(); -// -// +// +// // } -// +// // createObject(renderer, node){ -// +// // let gl = renderer.getContext(); -// +// // let bufferGeometry = node.sceneNode.geometry; -// +// // let buffers = {}; -// +// // for(let attributeName of Object.keys(bufferGeometry.attributes)){ // let attribute = bufferGeometry.attributes[attributeName]; // let vbo = gl.createBuffer(); // gl.bindBuffer(gl.ARRAY_BUFFER, vbo); // gl.bufferData(gl.ARRAY_BUFFER, attribute.array, gl.STATIC_DRAW); -// +// // buffers[attributeName] = { // threeAttribute: attribute, // vbo: vbo // }; // } // gl.bindBuffer(gl.ARRAY_BUFFER, null); -// +// // let glObject = new Potree.GLObject(node); // let webgl = { // node: node, // geometry: bufferGeometry, // buffers // }; -// +// // console.log(webgl); -// +// // this.wegbl.set(node, webgl); // } -// +// // freeObject(node){ -// +// // // TODO destroy buffers -// +// // this.webgl.delete(node); -// +// // } -// -// -//}; \ No newline at end of file +// +// +// }; diff --git a/src/PointCloudGreyhoundGeometry.js b/src/PointCloudGreyhoundGeometry.js index c75422fc..6fe85312 100644 --- a/src/PointCloudGreyhoundGeometry.js +++ b/src/PointCloudGreyhoundGeometry.js @@ -1,4 +1,4 @@ -Potree.PointCloudGreyhoundGeometry = function(){ +Potree.PointCloudGreyhoundGeometry = function () { this.spacing = 0; this.boundingBox = null; this.root = null; @@ -7,7 +7,7 @@ Potree.PointCloudGreyhoundGeometry = function(){ this.pointAttributes = {}; this.hierarchyStepSize = -1; this.loader = null; - this.schema = null; + this.schema = null; this.baseDepth = null; this.offset = null; @@ -15,8 +15,8 @@ Potree.PointCloudGreyhoundGeometry = function(){ this.boundingSphere = null; - //the serverURL will contain the base URL of the greyhound server. f.e. http://dev.greyhound.io/resource/autzen/ + // the serverURL will contain the base URL of the greyhound server. f.e. http://dev.greyhound.io/resource/autzen/ this.serverURL = null; - this.normalize = { color: false, intensity: false }; + this.normalize = { color: false, intensity: false }; }; diff --git a/src/PointCloudGreyhoundGeometryNode.js b/src/PointCloudGreyhoundGeometryNode.js index 6f6bf342..a99459e5 100644 --- a/src/PointCloudGreyhoundGeometryNode.js +++ b/src/PointCloudGreyhoundGeometryNode.js @@ -1,24 +1,23 @@ -var nodesLoadTimes = {}; var baseLoaded = false; -Potree.PointCloudGreyhoundGeometryNode = function( - name, pcoGeometry, boundingBox, scale, offset) { +Potree.PointCloudGreyhoundGeometryNode = function ( + name, pcoGeometry, boundingBox, scale, offset) { this.id = Potree.PointCloudGreyhoundGeometryNode.IDCount++; this.name = name; - this.index = parseInt(name.charAt(name.length-1)); + this.index = parseInt(name.charAt(name.length - 1)); this.pcoGeometry = pcoGeometry; this.geometry = null; this.boundingBox = boundingBox; this.boundingSphere = boundingBox.getBoundingSphere(); - this.scale = scale; - this.offset = offset; + this.scale = scale; + this.offset = offset; this.children = {}; this.numPoints = 0; this.level = null; this.loaded = false; this.oneTimeDisposeHandlers = []; - let bounds = this.boundingBox.clone() + let bounds = this.boundingBox.clone(); bounds.min.sub(this.pcoGeometry.boundingBox.getCenter()); bounds.max.sub(this.pcoGeometry.boundingBox.getCenter()); @@ -27,47 +26,48 @@ Potree.PointCloudGreyhoundGeometryNode = function( bounds.max.multiplyScalar(1 / this.scale); } - // This represents the bounds for this node in the reference frame of the - // global bounds from `info`, centered around the origin, and then scaled - // by our selected scale. - this.greyhoundBounds = bounds; + // This represents the bounds for this node in the reference frame of the + // global bounds from `info`, centered around the origin, and then scaled + // by our selected scale. + this.greyhoundBounds = bounds; - // This represents the offset between the coordinate system described above - // and our pcoGeometry bounds. - this.greyhoundOffset = this.pcoGeometry.offset.clone().add( - this.pcoGeometry.boundingBox.getSize().multiplyScalar(0.5)); + // This represents the offset between the coordinate system described above + // and our pcoGeometry bounds. + this.greyhoundOffset = this.pcoGeometry.offset.clone().add( + this.pcoGeometry.boundingBox.getSize().multiplyScalar(0.5) + ); }; Potree.PointCloudGreyhoundGeometryNode.IDCount = 0; Potree.PointCloudGreyhoundGeometryNode.prototype = - Object.create(Potree.PointCloudTreeNode.prototype); + Object.create(Potree.PointCloudTreeNode.prototype); -Potree.PointCloudGreyhoundGeometryNode.prototype.isGeometryNode = function() { +Potree.PointCloudGreyhoundGeometryNode.prototype.isGeometryNode = function () { return true; }; -Potree.PointCloudGreyhoundGeometryNode.prototype.isTreeNode = function() { +Potree.PointCloudGreyhoundGeometryNode.prototype.isTreeNode = function () { return false; }; -Potree.PointCloudGreyhoundGeometryNode.prototype.isLoaded = function() { +Potree.PointCloudGreyhoundGeometryNode.prototype.isLoaded = function () { return this.loaded; }; -Potree.PointCloudGreyhoundGeometryNode.prototype.getBoundingSphere = function() { +Potree.PointCloudGreyhoundGeometryNode.prototype.getBoundingSphere = function () { return this.boundingSphere; }; -Potree.PointCloudGreyhoundGeometryNode.prototype.getBoundingBox = function() { +Potree.PointCloudGreyhoundGeometryNode.prototype.getBoundingBox = function () { return this.boundingBox; }; -Potree.PointCloudGreyhoundGeometryNode.prototype.getLevel = function(){ +Potree.PointCloudGreyhoundGeometryNode.prototype.getLevel = function () { return this.level; }; -Potree.PointCloudGreyhoundGeometryNode.prototype.getChildren = function() { +Potree.PointCloudGreyhoundGeometryNode.prototype.getChildren = function () { var children = []; for (var i = 0; i < 8; ++i) { @@ -79,50 +79,46 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.getChildren = function() { return children; }; -Potree.PointCloudGreyhoundGeometryNode.prototype.getURL = function() { - var schema = this.pcoGeometry.schema; - let bounds = this.greyhoundBounds; +Potree.PointCloudGreyhoundGeometryNode.prototype.getURL = function () { + var schema = this.pcoGeometry.schema; + let bounds = this.greyhoundBounds; - var boundsString = - bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' + - bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z; + var boundsString = + bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' + + bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z; - var url = ''+this.pcoGeometry.serverURL + - 'read?depthBegin=' + - (baseLoaded ? (this.level + this.pcoGeometry.baseDepth) : 0) + - '&depthEnd=' + (this.level + this.pcoGeometry.baseDepth + 1) + - '&bounds=[' + boundsString + ']' + - '&schema=' + JSON.stringify(schema) + - '&compress=true'; + var url = '' + this.pcoGeometry.serverURL + + 'read?depthBegin=' + + (baseLoaded ? (this.level + this.pcoGeometry.baseDepth) : 0) + + '&depthEnd=' + (this.level + this.pcoGeometry.baseDepth + 1) + + '&bounds=[' + boundsString + ']' + + '&schema=' + JSON.stringify(schema) + + '&compress=true'; - if (this.scale) { - url += '&scale=' + this.scale; - } + if (this.scale) { + url += '&scale=' + this.scale; + } - if (this.greyhoundOffset) { + if (this.greyhoundOffset) { let offset = this.greyhoundOffset; url += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']'; } - if(this.level === 1){ - let a = 1; - } + if (!baseLoaded) baseLoaded = true; - if (!baseLoaded) baseLoaded = true; - - return url; + return url; }; -Potree.PointCloudGreyhoundGeometryNode.prototype.addChild = function(child) { +Potree.PointCloudGreyhoundGeometryNode.prototype.addChild = function (child) { this.children[child.index] = child; child.parent = this; }; -Potree.PointCloudGreyhoundGeometryNode.prototype.load = function(){ +Potree.PointCloudGreyhoundGeometryNode.prototype.load = function () { if ( - this.loading === true || - this.loaded === true || - this.pcoGeometry.numNodesLoading > 3) { + this.loading === true || + this.loaded === true || + this.pcoGeometry.numNodesLoading > 3) { return; } @@ -130,108 +126,105 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.load = function(){ this.pcoGeometry.numNodesLoading++; if ( - this.level % this.pcoGeometry.hierarchyStepSize === 0 && - this.hasChildren) { + this.level % this.pcoGeometry.hierarchyStepSize === 0 && + this.hasChildren) { this.loadHierarchyThenPoints(); - } - else { + } else { this.loadPoints(); } }; -Potree.PointCloudGreyhoundGeometryNode.prototype.loadPoints = function(){ +Potree.PointCloudGreyhoundGeometryNode.prototype.loadPoints = function () { this.pcoGeometry.loader.load(this); }; - -Potree.PointCloudGreyhoundGeometryNode.prototype.loadHierarchyThenPoints = - function() { - // From Greyhound (Cartesian) ordering for the octree to Potree-default +Potree.PointCloudGreyhoundGeometryNode.prototype.loadHierarchyThenPoints = function () { + // From Greyhound (Cartesian) ordering for the octree to Potree-default var transform = [0, 2, 1, 3, 4, 6, 5, 7]; - var makeBitMask = function(node) { - var mask = 0; - Object.keys(node).forEach(function(key) { - if (key === 'swd') mask += 1 << transform[0]; - else if (key === 'nwd') mask += 1 << transform[1]; - else if (key === 'swu') mask += 1 << transform[2]; - else if (key === 'nwu') mask += 1 << transform[3]; - else if (key === 'sed') mask += 1 << transform[4]; - else if (key === 'ned') mask += 1 << transform[5]; - else if (key === 'seu') mask += 1 << transform[6]; - else if (key === 'neu') mask += 1 << transform[7]; - }); - return mask; - }; + var makeBitMask = function (node) { + var mask = 0; + Object.keys(node).forEach(function (key) { + if (key === 'swd') mask += 1 << transform[0]; + else if (key === 'nwd') mask += 1 << transform[1]; + else if (key === 'swu') mask += 1 << transform[2]; + else if (key === 'nwu') mask += 1 << transform[3]; + else if (key === 'sed') mask += 1 << transform[4]; + else if (key === 'ned') mask += 1 << transform[5]; + else if (key === 'seu') mask += 1 << transform[6]; + else if (key === 'neu') mask += 1 << transform[7]; + }); + return mask; + }; - var parseChildrenCounts = function(base, parentName, stack) { - var keys = Object.keys(base); - var child; - var childName; + var parseChildrenCounts = function (base, parentName, stack) { + var keys = Object.keys(base); + var child; + var childName; - keys.forEach(function(key) { - if (key === 'n') return; - switch (key) { - case 'swd': - child = base.swd; childName = parentName + transform[0]; - break; - case 'nwd': - child = base.nwd; childName = parentName + transform[1]; - break; - case 'swu': - child = base.swu; childName = parentName + transform[2]; - break; - case 'nwu': - child = base.nwu; childName = parentName + transform[3]; - break; - case 'sed': - child = base.sed; childName = parentName + transform[4]; - break; - case 'ned': - child = base.ned; childName = parentName + transform[5]; - break; - case 'seu': - child = base.seu; childName = parentName + transform[6]; - break; - case 'neu': - child = base.neu; childName = parentName + transform[7]; - break; - default: - break; - } + keys.forEach(function (key) { + if (key === 'n') return; + switch (key) { + case 'swd': + child = base.swd; childName = parentName + transform[0]; + break; + case 'nwd': + child = base.nwd; childName = parentName + transform[1]; + break; + case 'swu': + child = base.swu; childName = parentName + transform[2]; + break; + case 'nwu': + child = base.nwu; childName = parentName + transform[3]; + break; + case 'sed': + child = base.sed; childName = parentName + transform[4]; + break; + case 'ned': + child = base.ned; childName = parentName + transform[5]; + break; + case 'seu': + child = base.seu; childName = parentName + transform[6]; + break; + case 'neu': + child = base.neu; childName = parentName + transform[7]; + break; + default: + break; + } - stack.push({ - children: makeBitMask(child), - numPoints: child.n, - name: childName - }); + stack.push({ + children: makeBitMask(child), + numPoints: child.n, + name: childName + }); - parseChildrenCounts(child, childName, stack); - }); - }; + parseChildrenCounts(child, childName, stack); + }); + }; // Load hierarchy. - var callback = function(node, greyhoundHierarchy) { + var callback = function (node, greyhoundHierarchy) { var decoded = []; node.numPoints = greyhoundHierarchy.n; - parseChildrenCounts(greyhoundHierarchy, node.name, decoded); + parseChildrenCounts(greyhoundHierarchy, node.name, decoded); var nodes = {}; nodes[node.name] = node; var pgg = node.pcoGeometry; - for( var i = 0; i < decoded.length; i++){ + for (var i = 0; i < decoded.length; i++) { var name = decoded[i].name; var numPoints = decoded[i].numPoints; - var index = parseInt(name.charAt(name.length-1)); - var parentName = name.substring(0, name.length-1); + var index = parseInt(name.charAt(name.length - 1)); + var parentName = name.substring(0, name.length - 1); var parentNode = nodes[parentName]; - var level = name.length-1; + var level = name.length - 1; var boundingBox = Potree.GreyhoundLoader.createChildAABB( - parentNode.boundingBox, index); + parentNode.boundingBox, index); var currentNode = new Potree.PointCloudGreyhoundGeometryNode( - name, pgg, boundingBox, node.scale, node.offset); + name, pgg, boundingBox, node.scale, node.offset); currentNode.level = level; currentNode.numPoints = numPoints; @@ -245,68 +238,66 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.loadHierarchyThenPoints = }; if (this.level % this.pcoGeometry.hierarchyStepSize === 0) { - var depthBegin = this.level + this.pcoGeometry.baseDepth; - var depthEnd = depthBegin + this.pcoGeometry.hierarchyStepSize + 2; + var depthBegin = this.level + this.pcoGeometry.baseDepth; + var depthEnd = depthBegin + this.pcoGeometry.hierarchyStepSize + 2; - let bounds = this.greyhoundBounds; + let bounds = this.greyhoundBounds; - var boundsString = - bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' + - bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z; + var boundsString = + bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' + + bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z; var hurl = '' + this.pcoGeometry.serverURL + - 'hierarchy?bounds=[' + boundsString + ']' + - '&depthBegin=' + depthBegin + - '&depthEnd=' + depthEnd; + 'hierarchy?bounds=[' + boundsString + ']' + + '&depthBegin=' + depthBegin + + '&depthEnd=' + depthEnd; if (this.scale) { hurl += '&scale=' + this.scale; } - if (this.greyhoundOffset) { - let offset = this.greyhoundOffset; + if (this.greyhoundOffset) { + let offset = this.greyhoundOffset; hurl += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']'; } var xhr = new XMLHttpRequest(); xhr.open('GET', hurl, true); - var that = this; - xhr.onreadystatechange = function() { + var that = this; + xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200 || xhr.status === 0) { - var greyhoundHierarchy = JSON.parse(xhr.responseText) || { }; - callback(that, greyhoundHierarchy); + var greyhoundHierarchy = JSON.parse(xhr.responseText) || { }; + callback(that, greyhoundHierarchy); } else { - console.log( - 'Failed to load file! HTTP status:', xhr.status, - 'file:', hurl); + console.log( + 'Failed to load file! HTTP status:', xhr.status, + 'file:', hurl + ); } } }; try { xhr.send(null); - } - catch(e) { - console.log("fehler beim laden der punktwolke: " + e); + } catch (e) { + console.log('fehler beim laden der punktwolke: ' + e); } } }; - -Potree.PointCloudGreyhoundGeometryNode.prototype.getNumPoints = function(){ +Potree.PointCloudGreyhoundGeometryNode.prototype.getNumPoints = function () { return this.numPoints; }; - -Potree.PointCloudGreyhoundGeometryNode.prototype.dispose = function(){ +Potree.PointCloudGreyhoundGeometryNode.prototype.dispose = function () { if (this.geometry && this.parent != null) { this.geometry.dispose(); this.geometry = null; this.loaded = false; - //this.dispatchEvent( { type: 'dispose' } ); + // this.dispatchEvent( { type: 'dispose' } ); for (var i = 0; i < this.oneTimeDisposeHandlers.length; i++) { var handler = this.oneTimeDisposeHandlers[i]; handler(); @@ -315,7 +306,6 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.dispose = function(){ } }; -//THREE.EventDispatcher.prototype.apply( +// THREE.EventDispatcher.prototype.apply( // Potree.PointCloudGreyhoundGeometryNode.prototype); -Object.assign( Potree.PointCloudGreyhoundGeometryNode.prototype, THREE.EventDispatcher.prototype ); - +Object.assign(Potree.PointCloudGreyhoundGeometryNode.prototype, THREE.EventDispatcher.prototype); diff --git a/src/PointCloudOctree.js b/src/PointCloudOctree.js index 3fbd2874..8d484dee 100644 --- a/src/PointCloudOctree.js +++ b/src/PointCloudOctree.js @@ -1,154 +1,148 @@ - -Potree.PointCloudOctreeNode = class PointCloudOctreeNode extends Potree.PointCloudTreeNode{ - - constructor(){ +Potree.PointCloudOctreeNode = class PointCloudOctreeNode extends Potree.PointCloudTreeNode { + constructor () { super(); - + this.children = {}; this.sceneNode = null; this.octree = null; } - - getNumPoints(){ + + getNumPoints () { return this.geometryNode.numPoints; }; - - isLoaded(){ + + isLoaded () { return true; }; - - isTreeNode(){ + + isTreeNode () { return true; }; - - isGeometryNode(){ + + isGeometryNode () { return false; }; - - getLevel(){ + + getLevel () { return this.geometryNode.level; }; - - getBoundingSphere(){ + + getBoundingSphere () { return this.geometryNode.boundingSphere; }; - - getBoundingBox(){ + + getBoundingBox () { return this.geometryNode.boundingBox; }; - - getChildren(){ + + getChildren () { let children = []; - - for(let i = 0; i < 8; i++){ - if(this.children[i]){ + + for (let i = 0; i < 8; i++) { + if (this.children[i]) { children.push(this.children[i]); } } - + return children; }; - - get name(){ + + get name () { return this.geometryNode.name; } }; - -Potree.PointCloudOctree = class extends Potree.PointCloudTree{ - - constructor(geometry, material){ +Potree.PointCloudOctree = class extends Potree.PointCloudTree { + constructor (geometry, material) { super(); - + this.pcoGeometry = geometry; this.boundingBox = this.pcoGeometry.boundingBox; this.boundingSphere = this.boundingBox.getBoundingSphere(); this.material = material || new Potree.PointCloudMaterial(); - this.visiblePointsTarget = 2*1000*1000; + this.visiblePointsTarget = 2 * 1000 * 1000; this.minimumNodePixelSize = 150; this.level = 0; this.position.copy(geometry.offset); this.updateMatrix(); - + this.showBoundingBox = false; this.boundingBoxNodes = []; this.loadQueue = []; - this.visibleBounds = new THREE.Box3(); + this.visibleBounds = new THREE.Box3(); this.visibleNodes = []; this.visibleGeometry = []; this.generateDEM = false; this.profileRequests = []; - this.name = ""; - + this.name = ''; + { let box = [this.pcoGeometry.tightBoundingBox, this.getBoundingBoxWorld()] .find(v => v !== undefined); - + this.updateMatrixWorld(true); box = Potree.utils.computeTransformedBoundingBox(box, this.matrixWorld); - + let bWidth = box.max.z - box.min.z; let bMin = box.min.z - 0.2 * bWidth; let bMax = box.max.z + 0.2 * bWidth; this.material.heightMin = bMin; this.material.heightMax = bMax; } - + // TODO read projection from file instead this.projection = geometry.projection; - + this.root = this.pcoGeometry.root; } - - - setName(name){ - if(this.name !== name){ + + setName (name) { + if (this.name !== name) { this.name = name; - this.dispatchEvent({type: "name_changed", name: name, pointcloud: this}); + this.dispatchEvent({type: 'name_changed', name: name, pointcloud: this}); } } - - getName(){ - return name; + + getName () { + return this.name; } - - toTreeNode(geometryNode, parent){ + + toTreeNode (geometryNode, parent) { let node = new Potree.PointCloudOctreeNode(); - - //if(geometryNode.name === "r40206"){ + + // if(geometryNode.name === "r40206"){ // console.log("creating node for r40206"); - //} + // } let sceneNode = new THREE.Points(geometryNode.geometry, this.material); sceneNode.name = geometryNode.name; sceneNode.position.copy(geometryNode.boundingBox.min); sceneNode.frustumCulled = false; sceneNode.onBeforeRender = (_this, scene, camera, geometry, material, group) => { - - if(material.program){ + if (material.program) { _this.getContext().useProgram(material.program.program); - - if(material.program.getUniforms().map.level){ + + if (material.program.getUniforms().map.level) { let level = geometryNode.getLevel(); material.uniforms.level.value = level; material.program.getUniforms().map.level.setValue(_this.getContext(), level); } - - if(this.visibleNodeTextureOffsets && material.program.getUniforms().map.vnStart){ + + if (this.visibleNodeTextureOffsets && material.program.getUniforms().map.vnStart) { let vnStart = this.visibleNodeTextureOffsets.get(node); material.uniforms.vnStart.value = vnStart; material.program.getUniforms().map.vnStart.setValue(_this.getContext(), vnStart); } - - if(material.program.getUniforms().map.pcIndex){ + + if (material.program.getUniforms().map.pcIndex) { let i = node.pcIndex ? node.pcIndex : this.visibleNodes.indexOf(node); material.uniforms.pcIndex.value = i; material.program.getUniforms().map.pcIndex.setValue(_this.getContext(), i); } } }; - - //{ // DEBUG + + // { // DEBUG // let sg = new THREE.SphereGeometry(1, 16, 16); // let sm = new THREE.MeshNormalMaterial(); // let s = new THREE.Mesh(sg, sm); @@ -156,68 +150,68 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ // s.position.copy(geometryNode.mean) // .add(this.position) // .add(geometryNode.boundingBox.min); - // + // // viewer.scene.scene.add(s); - //} - + // } + node.geometryNode = geometryNode; node.sceneNode = sceneNode; node.pointcloud = this; node.children = {}; - for(let key in geometryNode.children){ + for (let key in geometryNode.children) { node.children[key] = geometryNode.children[key]; } - - if(!parent){ + + if (!parent) { this.root = node; this.add(sceneNode); - }else{ + } else { let childIndex = parseInt(geometryNode.name[geometryNode.name.length - 1]); parent.sceneNode.add(sceneNode); parent.children[childIndex] = node; } - - let disposeListener = function(){ + + let disposeListener = function () { let childIndex = parseInt(geometryNode.name[geometryNode.name.length - 1]); parent.sceneNode.remove(node.sceneNode); parent.children[childIndex] = geometryNode; - } + }; geometryNode.oneTimeDisposeHandlers.push(disposeListener); - + return node; } - - updateVisibleBounds(){ + + updateVisibleBounds () { let leafNodes = []; - for(let i = 0; i < this.visibleNodes.length; i++){ + for (let i = 0; i < this.visibleNodes.length; i++) { let node = this.visibleNodes[i]; let isLeaf = true; - - for(let j = 0; j < node.children.length; j++){ + + for (let j = 0; j < node.children.length; j++) { let child = node.children[j]; - if(child instanceof Potree.PointCloudOctreeNode){ + if (child instanceof Potree.PointCloudOctreeNode) { isLeaf = isLeaf && !child.sceneNode.visible; - }else if(child instanceof Potree.PointCloudOctreeGeometryNode){ + } else if (child instanceof Potree.PointCloudOctreeGeometryNode) { isLeaf = true; } } - - if(isLeaf){ + + if (isLeaf) { leafNodes.push(node); } } - - this.visibleBounds.min = new THREE.Vector3( Infinity, Infinity, Infinity ); - this.visibleBounds.max = new THREE.Vector3( - Infinity, - Infinity, - Infinity ); - for(let i = 0; i < leafNodes.length; i++){ + + this.visibleBounds.min = new THREE.Vector3(Infinity, Infinity, Infinity); + this.visibleBounds.max = new THREE.Vector3(-Infinity, -Infinity, -Infinity); + for (let i = 0; i < leafNodes.length; i++) { let node = leafNodes[i]; - + this.visibleBounds.expandByPoint(node.getBoundingBox().min); this.visibleBounds.expandByPoint(node.getBoundingBox().max); } } - - updateMaterial(material, visibleNodes, camera, renderer){ + + updateMaterial (material, visibleNodes, camera, renderer) { material.fov = camera.fov * (Math.PI / 180); material.screenWidth = renderer.domElement.clientWidth; material.screenHeight = renderer.domElement.clientHeight; @@ -225,174 +219,164 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ material.near = camera.near; material.far = camera.far; material.uniforms.octreeSize.value = this.pcoGeometry.boundingBox.getSize().x; - + // update visibility texture - if(material.pointSizeType >= 0){ - if(material.pointSizeType === Potree.PointSizeType.ADAPTIVE - || material.pointColorType === Potree.PointColorType.LOD){ - + if (material.pointSizeType >= 0) { + if (material.pointSizeType === Potree.PointSizeType.ADAPTIVE || + material.pointColorType === Potree.PointColorType.LOD) { this.updateVisibilityTexture(material, visibleNodes); } } } - - updateVisibilityTexture(material, visibleNodes){ - if(!material){ + + updateVisibilityTexture (material, visibleNodes) { + if (!material) { return; } - + let texture = material.visibleNodesTexture; let data = texture.image.data; data.fill(0); - + this.visibleNodeTextureOffsets = new Map(); - + // copy array visibleNodes = visibleNodes.slice(); - + // sort by level and index, e.g. r, r0, r3, r4, r01, r07, r30, ... - let sort = function(a, b){ + let sort = function (a, b) { let na = a.geometryNode.name; let nb = b.geometryNode.name; - if(na.length != nb.length) return na.length - nb.length; - if(na < nb) return -1; - if(na > nb) return 1; + if (na.length !== nb.length) return na.length - nb.length; + if (na < nb) return -1; + if (na > nb) return 1; return 0; }; visibleNodes.sort(sort); - - for(let i = 0; i < visibleNodes.length; i++){ + for (let i = 0; i < visibleNodes.length; i++) { let node = visibleNodes[i]; - + this.visibleNodeTextureOffsets.set(node, i); - + let children = []; - for(let j = 0; j < 8; j++){ + for (let j = 0; j < 8; j++) { let child = node.children[j]; - if(child instanceof Potree.PointCloudOctreeNode && child.sceneNode.visible && visibleNodes.indexOf(child) >= 0){ + if (child instanceof Potree.PointCloudOctreeNode && child.sceneNode.visible && visibleNodes.indexOf(child) >= 0) { children.push(child); } } - children.sort(function(a, b){ - if(a.geometryNode.name < b.geometryNode.name) return -1; - if(a.geometryNode.name > b.geometryNode.name) return 1; + children.sort(function (a, b) { + if (a.geometryNode.name < b.geometryNode.name) return -1; + if (a.geometryNode.name > b.geometryNode.name) return 1; return 0; }); - - data[i*3 + 0] = 0; - data[i*3 + 1] = 0; - data[i*3 + 2] = 0; - for(let j = 0; j < children.length; j++){ + + data[i * 3 + 0] = 0; + data[i * 3 + 1] = 0; + data[i * 3 + 2] = 0; + for (let j = 0; j < children.length; j++) { let child = children[j]; let index = parseInt(child.geometryNode.name.substr(-1)); - data[i*3 + 0] += Math.pow(2, index); - - if(j === 0){ + data[i * 3 + 0] += Math.pow(2, index); + + if (j === 0) { let vArrayIndex = visibleNodes.indexOf(child); - data[i*3 + 1] = (vArrayIndex - i) >> 8; - data[i*3 + 2] = (vArrayIndex - i) % 256; + data[i * 3 + 1] = (vArrayIndex - i) >> 8; + data[i * 3 + 2] = (vArrayIndex - i) % 256; } - } } - - + texture.needsUpdate = true; } - - nodeIntersectsProfile(node, profile){ + + nodeIntersectsProfile (node, profile) { let bbWorld = node.boundingBox.clone().applyMatrix4(this.matrixWorld); let bsWorld = bbWorld.getBoundingSphere(); - - for(let i = 0; i < profile.points.length - 1; i++){ + + for (let i = 0; i < profile.points.length - 1; i++) { let start = new THREE.Vector3(profile.points[i].x, bsWorld.center.y, profile.points[i].z); - let end = new THREE.Vector3(profile.points[i+1].x, bsWorld.center.y, profile.points[i+1].z); - + let end = new THREE.Vector3(profile.points[i + 1].x, bsWorld.center.y, profile.points[i + 1].z); + let ray1 = new THREE.Ray(start, new THREE.Vector3().subVectors(end, start).normalize()); let ray2 = new THREE.Ray(end, new THREE.Vector3().subVectors(start, end).normalize()); - - if(ray1.intersectsSphere(bsWorld) && ray2.intersectsSphere(bsWorld)){ + + if (ray1.intersectsSphere(bsWorld) && ray2.intersectsSphere(bsWorld)) { return true; } } - + return false; } - - nodesOnRay(nodes, ray){ + + nodesOnRay (nodes, ray) { let nodesOnRay = []; let _ray = ray.clone(); - for(let i = 0; i < nodes.length; i++){ + for (let i = 0; i < nodes.length; i++) { let node = nodes[i]; - //var inverseWorld = new THREE.Matrix4().getInverse(node.matrixWorld); - //let sphere = node.getBoundingSphere().clone().applyMatrix4(node.sceneNode.matrixWorld); + // var inverseWorld = new THREE.Matrix4().getInverse(node.matrixWorld); + // let sphere = node.getBoundingSphere().clone().applyMatrix4(node.sceneNode.matrixWorld); let sphere = node.getBoundingSphere().clone().applyMatrix4(this.matrixWorld); - - if(_ray.intersectsSphere(sphere)){ + + if (_ray.intersectsSphere(sphere)) { nodesOnRay.push(node); } } - + return nodesOnRay; } - - updateMatrixWorld( force ){ - if ( this.matrixAutoUpdate === true ) this.updateMatrix(); - if ( this.matrixWorldNeedsUpdate === true || force === true ) { - - if ( !this.parent ) { - - this.matrixWorld.copy( this.matrix ); + updateMatrixWorld (force) { + if (this.matrixAutoUpdate === true) this.updateMatrix(); + if (this.matrixWorldNeedsUpdate === true || force === true) { + if (!this.parent) { + this.matrixWorld.copy(this.matrix); } else { - - this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); - + this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix); } this.matrixWorldNeedsUpdate = false; force = true; - } } - - hideDescendants(object){ + + hideDescendants (object) { let stack = []; - for(let i = 0; i < object.children.length; i++){ + for (let i = 0; i < object.children.length; i++) { let child = object.children[i]; - if(child.visible){ + if (child.visible) { stack.push(child); } } - - while(stack.length > 0){ + + while (stack.length > 0) { let object = stack.shift(); - + object.visible = false; - - for(let i = 0; i < object.children.length; i++){ + + for (let i = 0; i < object.children.length; i++) { let child = object.children[i]; - if(child.visible){ + if (child.visible) { stack.push(child); } } } } - - moveToOrigin(){ - this.position.set(0,0,0); + + moveToOrigin () { + this.position.set(0, 0, 0); this.updateMatrixWorld(true); let box = this.boundingBox; let transform = this.matrixWorld; let tBox = Potree.utils.computeTransformedBoundingBox(box, transform); - this.position.set(0,0,0).sub(tBox.getCenter()); + this.position.set(0, 0, 0).sub(tBox.getCenter()); }; - moveToGroundPlane(){ + moveToGroundPlane () { this.updateMatrixWorld(true); let box = this.boundingBox; let transform = this.matrixWorld; @@ -400,15 +384,15 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ this.position.y += -tBox.min.y; }; - getBoundingBoxWorld(){ + getBoundingBoxWorld () { this.updateMatrixWorld(true); let box = this.boundingBox; let transform = this.matrixWorld; let tBox = Potree.utils.computeTransformedBoundingBox(box, transform); - + return tBox; }; - + /** * returns points inside the profile points * @@ -428,12 +412,11 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ * * */ - getPointsInProfile(profile, maxDepth, callback){ - - if(callback){ + getPointsInProfile (profile, maxDepth, callback) { + if (callback) { let request = new Potree.ProfileRequest(this, profile, maxDepth, callback); this.profileRequests.push(request); - + return request; } @@ -442,51 +425,49 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ boundingBox: new THREE.Box3(), projectedBoundingBox: new THREE.Box2() }; - + // evaluate segments - for(let i = 0; i < profile.points.length - 1; i++){ + for (let i = 0; i < profile.points.length - 1; i++) { let start = profile.points[i]; - let end = profile.points[i+1]; + let end = profile.points[i + 1]; let ps = this.getProfile(start, end, profile.width, maxDepth); - + let segment = { start: start, end: end, points: ps, project: null }; - + points.segments.push(segment); - + points.boundingBox.expandByPoint(ps.boundingBox.min); points.boundingBox.expandByPoint(ps.boundingBox.max); } - + // add projection functions to the segments let mileage = new THREE.Vector3(); - for(let i = 0; i < points.segments.length; i++){ + for (let i = 0; i < points.segments.length; i++) { let segment = points.segments[i]; let start = segment.start; let end = segment.end; - - let project = function(_start, _end, _mileage, _boundingBox){ + + let project = (function (_start, _end, _mileage, _boundingBox) { let start = _start; let end = _end; let mileage = _mileage; let boundingBox = _boundingBox; - - let xAxis = new THREE.Vector3(1,0,0); + + let xAxis = new THREE.Vector3(1, 0, 0); let dir = new THREE.Vector3().subVectors(end, start); dir.y = 0; dir.normalize(); let alpha = Math.acos(xAxis.dot(dir)); - if(dir.z > 0){ + if (dir.z > 0) { alpha = -alpha; } - - - return function(position){ - + + return function (position) { let toOrigin = new THREE.Matrix4().makeTranslation(-start.x, -boundingBox.min.y, -start.z); let alignWithX = new THREE.Matrix4().makeRotationY(-alpha); let applyMileage = new THREE.Matrix4().makeTranslation(mileage.x, 0, 0); @@ -495,45 +476,44 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ pos.applyMatrix4(toOrigin); pos.applyMatrix4(alignWithX); pos.applyMatrix4(applyMileage); - + return pos; }; - - }(start, end, mileage.clone(), points.boundingBox.clone()); - + }(start, end, mileage.clone(), points.boundingBox.clone())); + segment.project = project; - + mileage.x += new THREE.Vector3(start.x, 0, start.z).distanceTo(new THREE.Vector3(end.x, 0, end.z)); mileage.y += end.y - start.y; } - + points.projectedBoundingBox.min.x = 0; points.projectedBoundingBox.min.y = points.boundingBox.min.y; points.projectedBoundingBox.max.x = mileage.x; points.projectedBoundingBox.max.y = points.boundingBox.max.y; - + return points; } - + /** * returns points inside the given profile bounds. * - * start: - * end: - * width: + * start: + * end: + * width: * depth: search points up to the given octree depth * callback: if specified, points are loaded before searching - * + * * */ - getProfile(start, end, width, depth, callback){ - if(callback !== undefined){ + getProfile (start, end, width, depth, callback) { + if (callback !== undefined) { let request = new Potree.ProfileRequest(start, end, width, depth, callback); this.profileRequests.push(request); - }else{ + } else { let stack = []; stack.push(this); - + let center = new THREE.Vector3().addVectors(end, start).multiplyScalar(0.5); let length = new THREE.Vector3().subVectors(end, start).length(); let side = new THREE.Vector3().subVectors(end, start).normalize(); @@ -542,218 +522,203 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ let N = forward; let cutPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(N, start); let halfPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(side, center); - + let inside = null; - + let boundingBox = new THREE.Box3(); - - - while(stack.length > 0){ + + while (stack.length > 0) { let object = stack.shift(); - - - let pointsFound = 0; - - if(object instanceof THREE.Points){ + + if (object instanceof THREE.Points) { let geometry = object.geometry; let positions = geometry.attributes.position; let p = positions.array; let numPoints = object.numPoints; - - if(!inside){ + + if (!inside) { inside = {}; - + for (let property in geometry.attributes) { if (geometry.attributes.hasOwnProperty(property)) { - if(property === "indices"){ - - }else{ + if (property === 'indices') { + + } else { inside[property] = []; } } } } - - for(let i = 0; i < numPoints; i++){ - let pos = new THREE.Vector3(p[3*i], p[3*i+1], p[3*i+2]); + + for (let i = 0; i < numPoints; i++) { + let pos = new THREE.Vector3(p[3 * i], p[3 * i + 1], p[3 * i + 2]); pos.applyMatrix4(this.matrixWorld); let distance = Math.abs(cutPlane.distanceToPoint(pos)); let centerDistance = Math.abs(halfPlane.distanceToPoint(pos)); - - if(distance < width / 2 && centerDistance < length / 2){ + + if (distance < width / 2 && centerDistance < length / 2) { boundingBox.expandByPoint(pos); - + for (let property in geometry.attributes) { if (geometry.attributes.hasOwnProperty(property)) { - - if(property === "position"){ + if (property === 'position') { inside[property].push(pos); - }else if(property === "indices"){ + } else if (property === 'indices') { // skip indices - }else{ + } else { let values = geometry.attributes[property]; - if(values.itemSize === 1){ + if (values.itemSize === 1) { inside[property].push(values.array[i + j]); - }else{ + } else { let value = []; - for(let j = 0; j < values.itemSize; j++){ - value.push(values.array[i*values.itemSize + j]); + for (let j = 0; j < values.itemSize; j++) { + value.push(values.array[i * values.itemSize + j]); } inside[property].push(value); } } - } } - - - pointsFound++; } } } - - //console.log("traversing: " + object.name + ", #points found: " + pointsFound); - - if(object == this || object.level < depth){ - for(let i = 0; i < object.children.length; i++){ + + // console.log("traversing: " + object.name + ", #points found: " + pointsFound); + + if (object === this || object.level < depth) { + for (let i = 0; i < object.children.length; i++) { let child = object.children[i]; - if(child instanceof THREE.Points){ + if (child instanceof THREE.Points) { let sphere = child.boundingSphere.clone().applyMatrix4(child.matrixWorld); - if(cutPlane.distanceToSphere(sphere) < sphere.radius){ - stack.push(child); - } + if (cutPlane.distanceToSphere(sphere) < sphere.radius) { + stack.push(child); + } } } } } - + inside.numPoints = inside.position.length; - - let project = function(_start, _end){ + + let project = (function (_start, _end) { let start = _start; let end = _end; - - let xAxis = new THREE.Vector3(1,0,0); + + let xAxis = new THREE.Vector3(1, 0, 0); let dir = new THREE.Vector3().subVectors(end, start); dir.y = 0; dir.normalize(); let alpha = Math.acos(xAxis.dot(dir)); - if(dir.z > 0){ + if (dir.z > 0) { alpha = -alpha; } - - - return function(position){ - + + return function (position) { let toOrigin = new THREE.Matrix4().makeTranslation(-start.x, -start.y, -start.z); let alignWithX = new THREE.Matrix4().makeRotationY(-alpha); let pos = position.clone(); pos.applyMatrix4(toOrigin); pos.applyMatrix4(alignWithX); - + return pos; }; - - }(start, end); - + }(start, end)); + inside.project = project; inside.boundingBox = boundingBox; - + return inside; } }; - getVisibleExtent(){ + getVisibleExtent () { return this.visibleBounds.applyMatrix4(this.matrixWorld); }; - /** * * * * params.pickWindowSize: Look for points inside a pixel window of this size. * Use odd values: 1, 3, 5, ... - * - * - * TODO: only draw pixels that are actually read with readPixels(). - * + * + * + * TODO: only draw pixels that are actually read with readPixels(). + * */ - pick(renderer, camera, ray, params = {}){ - - //let start = new Date().getTime(); - + pick (renderer, camera, ray, params = {}) { + // let start = new Date().getTime(); + let pickWindowSize = params.pickWindowSize || 17; let pickOutsideClipRegion = params.pickOutsideClipRegion || false; let width = Math.ceil(renderer.domElement.clientWidth); let height = Math.ceil(renderer.domElement.clientHeight); - + let nodes = this.nodesOnRay(this.visibleNodes, ray); - - if(nodes.length === 0){ + + if (nodes.length === 0) { return null; } - - if(!this.pickState){ - + + if (!this.pickState) { let scene = new THREE.Scene(); - + let material = new Potree.PointCloudMaterial(); - material.pointColorType = Potree.PointColorType.POINT_INDEX; - - let renderTarget = new THREE.WebGLRenderTarget( - 1, 1, - { minFilter: THREE.LinearFilter, - magFilter: THREE.NearestFilter, - format: THREE.RGBAFormat } + material.pointColorType = Potree.PointColorType.POINT_INDEX; + + let renderTarget = new THREE.WebGLRenderTarget( + 1, 1, + { minFilter: THREE.LinearFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat } ); - + this.pickState = { renderTarget: renderTarget, material: material, scene: scene }; }; - + let pickState = this.pickState; let pickMaterial = pickState.material; - + { // update pick material pickMaterial.pointSizeType = this.material.pointSizeType; pickMaterial.shape = this.material.shape; - + pickMaterial.size = this.material.size; pickMaterial.minSize = this.material.minSize; pickMaterial.maxSize = this.material.maxSize; pickMaterial.classification = this.material.classification; - - if(pickOutsideClipRegion){ + + if (pickOutsideClipRegion) { pickMaterial.clipMode = Potree.ClipMode.DISABLED; - }else{ + } else { pickMaterial.clipMode = this.material.clipMode; - if(this.material.clipMode === Potree.ClipMode.CLIP_OUTSIDE){ + if (this.material.clipMode === Potree.ClipMode.CLIP_OUTSIDE) { pickMaterial.setClipBoxes(this.material.clipBoxes); - }else{ + } else { pickMaterial.setClipBoxes([]); } } - + this.updateMaterial(pickMaterial, nodes, camera, renderer); } - - if(pickState.renderTarget.width != width || pickState.renderTarget.height != height){ + + if (pickState.renderTarget.width !== width || pickState.renderTarget.height !== height) { pickState.renderTarget.dispose(); - pickState.renderTarget = new THREE.WebGLRenderTarget( - 1, 1, - { minFilter: THREE.LinearFilter, - magFilter: THREE.NearestFilter, - format: THREE.RGBAFormat } + pickState.renderTarget = new THREE.WebGLRenderTarget( + 1, 1, + { minFilter: THREE.LinearFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat } ); } pickState.renderTarget.setSize(width, height); - renderer.setRenderTarget( pickState.renderTarget ); - + renderer.setRenderTarget(pickState.renderTarget); + let pixelPos = new THREE.Vector3() .addVectors(camera.position, ray.direction) .project(camera) @@ -761,194 +726,189 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ .multiplyScalar(0.5); pixelPos.x *= width; pixelPos.y *= height; - + renderer.setScissor( - parseInt(pixelPos.x - (pickWindowSize - 1) / 2), + parseInt(pixelPos.x - (pickWindowSize - 1) / 2), parseInt(pixelPos.y - (pickWindowSize - 1) / 2), parseInt(pickWindowSize), parseInt(pickWindowSize)); renderer.setScissorTest(true); - + renderer.state.buffers.depth.setTest(pickMaterial.depthTest); renderer.state.buffers.depth.setMask(pickMaterial.depthWrite); renderer.state.setBlending(THREE.NoBlending); - - renderer.clearTarget( pickState.renderTarget, true, true, true ); - - //pickState.scene.children = nodes.map(n => n.sceneNode); - - //let childStates = []; + + renderer.clearTarget(pickState.renderTarget, true, true, true); + + // pickState.scene.children = nodes.map(n => n.sceneNode); + + // let childStates = []; let tempNodes = []; - for(let i = 0; i < nodes.length; i++){ + for (let i = 0; i < nodes.length; i++) { let node = nodes[i]; - node.pcIndex = i+1; + node.pcIndex = i + 1; let sceneNode = node.sceneNode; - + let tempNode = new THREE.Points(sceneNode.geometry, pickMaterial); tempNode.matrix = sceneNode.matrix; tempNode.matrixWorld = sceneNode.matrixWorld; tempNode.matrixAutoUpdate = false; tempNode.frustumCulled = false; - tempNode.pcIndex = i+1; - + tempNode.pcIndex = i + 1; + let geometryNode = node.geometryNode; - let material = pickMaterial; tempNode.onBeforeRender = (_this, scene, camera, geometry, material, group) => { - - if(material.program){ + if (material.program) { _this.getContext().useProgram(material.program.program); - - if(material.program.getUniforms().map.level){ + + if (material.program.getUniforms().map.level) { let level = geometryNode.getLevel(); material.uniforms.level.value = level; material.program.getUniforms().map.level.setValue(_this.getContext(), level); } - - if(this.visibleNodeTextureOffsets && material.program.getUniforms().map.vnStart){ + + if (this.visibleNodeTextureOffsets && material.program.getUniforms().map.vnStart) { let vnStart = this.visibleNodeTextureOffsets.get(node); material.uniforms.vnStart.value = vnStart; material.program.getUniforms().map.vnStart.setValue(_this.getContext(), vnStart); } - - if(material.program.getUniforms().map.pcIndex){ + + if (material.program.getUniforms().map.pcIndex) { material.uniforms.pcIndex.value = node.pcIndex; material.program.getUniforms().map.pcIndex.setValue(_this.getContext(), node.pcIndex); } } - }; tempNodes.push(tempNode); - - //for(let child of nodes[i].sceneNode.children){ + + // for(let child of nodes[i].sceneNode.children){ // childStates.push({child: child, visible: child.visible}); // child.visible = false; - //} + // } } pickState.scene.autoUpdate = false; pickState.scene.children = tempNodes; - //pickState.scene.overrideMaterial = pickMaterial; - + // pickState.scene.overrideMaterial = pickMaterial; + renderer.state.setBlending(THREE.NoBlending); - + // RENDER renderer.render(pickState.scene, camera, pickState.renderTarget); - - //for(let childState of childStates){ + + // for(let childState of childStates){ // childState.child = childState.visible; - //} - - //pickState.scene.overrideMaterial = null; - - //renderer.context.readPixels( - // pixelPos.x - (pickWindowSize-1) / 2, pixelPos.y - (pickWindowSize-1) / 2, - // pickWindowSize, pickWindowSize, + // } + + // pickState.scene.overrideMaterial = null; + + // renderer.context.readPixels( + // pixelPos.x - (pickWindowSize-1) / 2, pixelPos.y - (pickWindowSize-1) / 2, + // pickWindowSize, pickWindowSize, // renderer.context.RGBA, renderer.context.UNSIGNED_BYTE, pixels); - + let clamp = (number, min, max) => Math.min(Math.max(min, number), max); - - let x = parseInt(clamp(pixelPos.x - (pickWindowSize-1) / 2, 0, width)); - let y = parseInt(clamp(pixelPos.y - (pickWindowSize-1) / 2, 0, height)); + + let x = parseInt(clamp(pixelPos.x - (pickWindowSize - 1) / 2, 0, width)); + let y = parseInt(clamp(pixelPos.y - (pickWindowSize - 1) / 2, 0, height)); let w = parseInt(Math.min(x + pickWindowSize, width) - x); let h = parseInt(Math.min(y + pickWindowSize, height) - y); - + let pixelCount = w * h; let buffer = new Uint8Array(4 * pixelCount); - renderer.readRenderTargetPixels(pickState.renderTarget, - x, y, w, h, + renderer.readRenderTargetPixels(pickState.renderTarget, + x, y, w, h, buffer); - + renderer.setScissorTest(false); - + renderer.setRenderTarget(null); - + let pixels = buffer; let ibuffer = new Uint32Array(buffer.buffer); - + // find closest hit inside pixelWindow boundaries let min = Number.MAX_VALUE; let hit = null; - for(let u = 0; u < pickWindowSize; u++){ - for(let v = 0; v < pickWindowSize; v++){ - let offset = (u + v*pickWindowSize); - let distance = Math.pow(u - (pickWindowSize-1) / 2, 2) + Math.pow(v - (pickWindowSize-1) / 2, 2); - - let pcIndex = pixels[4*offset + 3]; - pixels[4*offset + 3] = 0; + for (let u = 0; u < pickWindowSize; u++) { + for (let v = 0; v < pickWindowSize; v++) { + let offset = (u + v * pickWindowSize); + let distance = Math.pow(u - (pickWindowSize - 1) / 2, 2) + Math.pow(v - (pickWindowSize - 1) / 2, 2); + + let pcIndex = pixels[4 * offset + 3]; + pixels[4 * offset + 3] = 0; let pIndex = ibuffer[offset]; - - //if((pIndex !== 0 || pcIndex !== 0) && distance < min){ - if(pcIndex > 0 && distance < min){ - - + + // if((pIndex !== 0 || pcIndex !== 0) && distance < min){ + if (pcIndex > 0 && distance < min) { hit = { pIndex: pIndex, pcIndex: pcIndex - 1 }; min = distance; - - //console.log(hit); + + // console.log(hit); } } } - //console.log(pixels); - - //{ // open window with image + // console.log(pixels); + + // { // open window with image // let img = Potree.utils.pixelsArrayToImage(buffer, w, h); // let screenshot = img.src; - // + // // if(!this.debugDIV){ // this.debugDIV = $(` - //
`); // $(document.body).append(this.debugDIV); // } - // + // // this.debugDIV.empty(); // this.debugDIV.append($(``)); // //$(this.debugWindow.document).append($(``)); // //this.debugWindow.document.write(''); - //} - - //return; - + // } + + // return; + let point = null; - - if(hit){ + + if (hit) { point = {}; - - if(!nodes[hit.pcIndex]){ + + if (!nodes[hit.pcIndex]) { return null; } - + let pc = nodes[hit.pcIndex].sceneNode; let attributes = pc.geometry.attributes; - - for(let property in attributes) { + + for (let property in attributes) { if (attributes.hasOwnProperty(property)) { let values = pc.geometry.attributes[property]; - - if(property === "position"){ + + if (property === 'position') { let positionArray = values.array; - let x = positionArray[3*hit.pIndex+0]; - let y = positionArray[3*hit.pIndex+1]; - let z = positionArray[3*hit.pIndex+2]; + let x = positionArray[3 * hit.pIndex + 0]; + let y = positionArray[3 * hit.pIndex + 1]; + let z = positionArray[3 * hit.pIndex + 2]; let position = new THREE.Vector3(x, y, z); position.applyMatrix4(pc.matrixWorld); - + point[property] = position; - }else if(property === "indices"){ - - }else{ - if(values.itemSize === 1){ + } else if (property === 'indices') { + + } else { + if (values.itemSize === 1) { point[property] = values.array[hit.pIndex]; - }else{ + } else { let value = []; - for(let j = 0; j < values.itemSize; j++){ - value.push(values.array[values.itemSize*hit.pIndex + j]); + for (let j = 0; j < values.itemSize; j++) { + value.push(values.array[values.itemSize * hit.pIndex + j]); } point[property] = value; } @@ -956,31 +916,15 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ } } } - - //let end = new Date().getTime(); - //let duration = end - start; - //console.log(`pick duration: ${duration}ms`); - + + // let end = new Date().getTime(); + // let duration = end - start; + // console.log(`pick duration: ${duration}ms`); + return point; - - }; - - get progress(){ + + get progress () { return this.visibleNodes.length / this.visibleGeometry.length; } }; - - - - - - - - - - - - - - diff --git a/src/PointCloudOctreeGeometry.js b/src/PointCloudOctreeGeometry.js index b6199237..73e0fa6d 100644 --- a/src/PointCloudOctreeGeometry.js +++ b/src/PointCloudOctreeGeometry.js @@ -1,7 +1,5 @@ -var nodesLoadTimes = {}; - -Potree.PointCloudOctreeGeometry = function(){ +Potree.PointCloudOctreeGeometry = function () { this.url = null; this.octreeDir = null; this.spacing = 0; @@ -14,10 +12,10 @@ Potree.PointCloudOctreeGeometry = function(){ this.loader = null; }; -Potree.PointCloudOctreeGeometryNode = function(name, pcoGeometry, boundingBox){ +Potree.PointCloudOctreeGeometryNode = function (name, pcoGeometry, boundingBox) { this.id = Potree.PointCloudOctreeGeometryNode.IDCount++; this.name = name; - this.index = parseInt(name.charAt(name.length-1)); + this.index = parseInt(name.charAt(name.length - 1)); this.pcoGeometry = pcoGeometry; this.geometry = null; this.boundingBox = boundingBox; @@ -33,226 +31,212 @@ Potree.PointCloudOctreeGeometryNode.IDCount = 0; Potree.PointCloudOctreeGeometryNode.prototype = Object.create(Potree.PointCloudTreeNode.prototype); -Potree.PointCloudOctreeGeometryNode.prototype.isGeometryNode = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.isGeometryNode = function () { return true; }; -Potree.PointCloudOctreeGeometryNode.prototype.getLevel = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.getLevel = function () { return this.level; }; -Potree.PointCloudOctreeGeometryNode.prototype.isTreeNode = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.isTreeNode = function () { return false; }; -Potree.PointCloudOctreeGeometryNode.prototype.isLoaded = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.isLoaded = function () { return this.loaded; }; -Potree.PointCloudOctreeGeometryNode.prototype.getBoundingSphere = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.getBoundingSphere = function () { return this.boundingSphere; }; -Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function () { return this.boundingBox; }; -Potree.PointCloudOctreeGeometryNode.prototype.getChildren = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.getChildren = function () { var children = []; - - for(var i = 0; i < 8; i++){ - if(this.children[i]){ + + for (var i = 0; i < 8; i++) { + if (this.children[i]) { children.push(this.children[i]); } } - + return children; }; -Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function () { return this.boundingBox; }; -Potree.PointCloudOctreeGeometryNode.prototype.getURL = function(){ - var url = ""; - +Potree.PointCloudOctreeGeometryNode.prototype.getURL = function () { + var url = ''; + var version = this.pcoGeometry.loader.version; - - if(version.equalOrHigher("1.5")){ - url = this.pcoGeometry.octreeDir + "/" + this.getHierarchyPath() + "/" + this.name; - }else if(version.equalOrHigher("1.4")){ - url = this.pcoGeometry.octreeDir + "/" + this.name; - }else if(version.upTo("1.3")){ - url = this.pcoGeometry.octreeDir + "/" + this.name; + + if (version.equalOrHigher('1.5')) { + url = this.pcoGeometry.octreeDir + '/' + this.getHierarchyPath() + '/' + this.name; + } else if (version.equalOrHigher('1.4')) { + url = this.pcoGeometry.octreeDir + '/' + this.name; + } else if (version.upTo('1.3')) { + url = this.pcoGeometry.octreeDir + '/' + this.name; } - + return url; }; -Potree.PointCloudOctreeGeometryNode.prototype.getHierarchyPath = function(){ - var path = "r/"; +Potree.PointCloudOctreeGeometryNode.prototype.getHierarchyPath = function () { + var path = 'r/'; var hierarchyStepSize = this.pcoGeometry.hierarchyStepSize; var indices = this.name.substr(1); - + var numParts = Math.floor(indices.length / hierarchyStepSize); - for(var i = 0; i < numParts; i++){ - path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + "/"; + for (var i = 0; i < numParts; i++) { + path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + '/'; } - - path = path.slice(0,-1); + + path = path.slice(0, -1); return path; }; -Potree.PointCloudOctreeGeometryNode.prototype.addChild = function(child){ +Potree.PointCloudOctreeGeometryNode.prototype.addChild = function (child) { this.children[child.index] = child; child.parent = this; }; -Potree.PointCloudOctreeGeometryNode.prototype.load = function(){ - if(this.loading === true || this.loaded === true ||this.pcoGeometry.numNodesLoading > 3){ +Potree.PointCloudOctreeGeometryNode.prototype.load = function () { + if (this.loading === true || this.loaded === true || this.pcoGeometry.numNodesLoading > 3) { return; } - + this.loading = true; - + this.pcoGeometry.numNodesLoading++; - - - if(this.pcoGeometry.loader.version.equalOrHigher("1.5")){ - if((this.level % this.pcoGeometry.hierarchyStepSize) === 0 && this.hasChildren){ + + if (this.pcoGeometry.loader.version.equalOrHigher('1.5')) { + if ((this.level % this.pcoGeometry.hierarchyStepSize) === 0 && this.hasChildren) { this.loadHierachyThenPoints(); - }else{ + } else { this.loadPoints(); } - }else{ + } else { this.loadPoints(); } - - }; -Potree.PointCloudOctreeGeometryNode.prototype.loadPoints = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.loadPoints = function () { this.pcoGeometry.loader.load(this); }; - -Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function(){ - +Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function () { var node = this; // load hierarchy - var callback = function(node, hbuffer){ - var count = hbuffer.byteLength / 5; + var callback = function (node, hbuffer) { var view = new DataView(hbuffer); - + var stack = []; var children = view.getUint8(0); var numPoints = view.getUint32(1, true); node.numPoints = numPoints; stack.push({children: children, numPoints: numPoints, name: node.name}); - + var decoded = []; - + var offset = 5; - while(stack.length > 0){ - + while (stack.length > 0) { var snode = stack.shift(); var mask = 1; - for(var i = 0; i < 8; i++){ - if((snode.children & mask) !== 0){ - var childIndex = i; + for (let i = 0; i < 8; i++) { + if ((snode.children & mask) !== 0) { var childName = snode.name + i; - + var childChildren = view.getUint8(offset); var childNumPoints = view.getUint32(offset + 1, true); - + stack.push({children: childChildren, numPoints: childNumPoints, name: childName}); - + decoded.push({children: childChildren, numPoints: childNumPoints, name: childName}); - + offset += 5; } - + mask = mask * 2; } - - if(offset === hbuffer.byteLength){ + + if (offset === hbuffer.byteLength) { break; } - } - - //console.log(decoded); - + + // console.log(decoded); + var nodes = {}; nodes[node.name] = node; var pco = node.pcoGeometry; - - - for( var i = 0; i < decoded.length; i++){ + + for (let i = 0; i < decoded.length; i++) { var name = decoded[i].name; - var numPoints = decoded[i].numPoints; - var index = parseInt(name.charAt(name.length-1)); - var parentName = name.substring(0, name.length-1); + var decodedNumPoints = decoded[i].numPoints; + var index = parseInt(name.charAt(name.length - 1)); + var parentName = name.substring(0, name.length - 1); var parentNode = nodes[parentName]; - var level = name.length-1; + var level = name.length - 1; var boundingBox = Potree.POCLoader.createChildAABB(parentNode.boundingBox, index); - + var currentNode = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox); currentNode.level = level; - currentNode.numPoints = numPoints; + currentNode.numPoints = decodedNumPoints; currentNode.hasChildren = decoded[i].children > 0; currentNode.spacing = pco.spacing / Math.pow(2, level); parentNode.addChild(currentNode); nodes[name] = currentNode; } - + node.loadPoints(); - }; - if((node.level % node.pcoGeometry.hierarchyStepSize) === 0){ - //var hurl = node.pcoGeometry.octreeDir + "/../hierarchy/" + node.name + ".hrc"; - var hurl = node.pcoGeometry.octreeDir + "/" + node.getHierarchyPath() + "/" + node.name + ".hrc"; - + if ((node.level % node.pcoGeometry.hierarchyStepSize) === 0) { + // var hurl = node.pcoGeometry.octreeDir + "/../hierarchy/" + node.name + ".hrc"; + var hurl = node.pcoGeometry.octreeDir + '/' + node.getHierarchyPath() + '/' + node.name + '.hrc'; + var xhr = new XMLHttpRequest(); xhr.open('GET', hurl, true); xhr.responseType = 'arraybuffer'; xhr.overrideMimeType('text/plain; charset=x-user-defined'); - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200 || xhr.status === 0) { var hbuffer = xhr.response; callback(node, hbuffer); } else { - console.log('Failed to load file! HTTP status: ' + xhr.status + ", file: " + url); + console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + hurl); } } }; - try{ + try { xhr.send(null); - }catch(e){ - console.log("fehler beim laden der punktwolke: " + e); + } catch (e) { + console.log('fehler beim laden der punktwolke: ' + e); } } - }; - -Potree.PointCloudOctreeGeometryNode.prototype.getNumPoints = function(){ +Potree.PointCloudOctreeGeometryNode.prototype.getNumPoints = function () { return this.numPoints; }; - -Potree.PointCloudOctreeGeometryNode.prototype.dispose = function(){ - if(this.geometry && this.parent != null){ +Potree.PointCloudOctreeGeometryNode.prototype.dispose = function () { + if (this.geometry && this.parent != null) { this.geometry.dispose(); this.geometry = null; this.loaded = false; - - //this.dispatchEvent( { type: 'dispose' } ); - for(var i = 0; i < this.oneTimeDisposeHandlers.length; i++){ + + // this.dispatchEvent( { type: 'dispose' } ); + for (var i = 0; i < this.oneTimeDisposeHandlers.length; i++) { var handler = this.oneTimeDisposeHandlers[i]; handler(); } @@ -260,5 +244,5 @@ Potree.PointCloudOctreeGeometryNode.prototype.dispose = function(){ } }; -//THREE.EventDispatcher.prototype.apply( Potree.PointCloudOctreeGeometryNode.prototype ); -Object.assign( Potree.PointCloudOctreeGeometryNode.prototype, THREE.EventDispatcher.prototype ); \ No newline at end of file +// THREE.EventDispatcher.prototype.apply( Potree.PointCloudOctreeGeometryNode.prototype ); +Object.assign(Potree.PointCloudOctreeGeometryNode.prototype, THREE.EventDispatcher.prototype); diff --git a/src/PointCloudTree.js b/src/PointCloudTree.js index 79e88e91..7b56331c 100644 --- a/src/PointCloudTree.js +++ b/src/PointCloudTree.js @@ -1,10 +1,10 @@ -// -// index is in order xyzxyzxyz +// +// index is in order xyzxyzxyz // -Potree.DEMNode = class DEMNode{ - constructor(name, box, tileSize){ +Potree.DEMNode = class DEMNode { + constructor (name, box, tileSize) { this.name = name; this.box = box; this.tileSize = tileSize; @@ -12,159 +12,154 @@ Potree.DEMNode = class DEMNode{ this.data = new Float32Array(tileSize * tileSize); this.data.fill(-Infinity); this.children = []; - + this.mipMap = [this.data]; this.mipMapNeedsUpdate = true; } - - createMipMap(){ + + createMipMap () { this.mipMap = [this.data]; - + let sourceSize = this.tileSize; let mipSize = parseInt(sourceSize / 2); let mipSource = this.data; - while(mipSize > 1){ + while (mipSize > 1) { let mipData = new Float32Array(mipSize * mipSize); - - for(let i = 0; i < mipSize; i++){ - for(let j = 0; j < mipSize; j++){ - let h00 = mipSource[2*i+0 + 2*j*sourceSize]; - let h01 = mipSource[2*i+0 + 2*j*sourceSize + sourceSize]; - let h10 = mipSource[2*i+1 + 2*j*sourceSize]; - let h11 = mipSource[2*i+1 + 2*j*sourceSize + sourceSize]; - + + for (let i = 0; i < mipSize; i++) { + for (let j = 0; j < mipSize; j++) { + let h00 = mipSource[2 * i + 0 + 2 * j * sourceSize]; + let h01 = mipSource[2 * i + 0 + 2 * j * sourceSize + sourceSize]; + let h10 = mipSource[2 * i + 1 + 2 * j * sourceSize]; + let h11 = mipSource[2 * i + 1 + 2 * j * sourceSize + sourceSize]; + let [height, weight] = [0, 0]; - - if(isFinite(h00)){height += h00; weight += 1}; - if(isFinite(h01)){height += h01; weight += 1}; - if(isFinite(h10)){height += h10; weight += 1}; - if(isFinite(h11)){height += h11; weight += 1}; - + + if (isFinite(h00)) { height += h00; weight += 1; }; + if (isFinite(h01)) { height += h01; weight += 1; }; + if (isFinite(h10)) { height += h10; weight += 1; }; + if (isFinite(h11)) { height += h11; weight += 1; }; + height = height / weight; - - //let hs = [h00, h01, h10, h11].filter(h => isFinite(h)); - //let height = hs.reduce( (a, v, i) => a + v, 0) / hs.length; - + + // let hs = [h00, h01, h10, h11].filter(h => isFinite(h)); + // let height = hs.reduce( (a, v, i) => a + v, 0) / hs.length; + mipData[i + j * mipSize] = height; } } - + this.mipMap.push(mipData); - + mipSource = mipData; sourceSize = mipSize; mipSize = parseInt(mipSize / 2); } - + this.mipMapNeedsUpdate = false; } - - uv(position){ + + uv (position) { let boxSize = this.box.getSize(); - + let u = (position.x - this.box.min.x) / boxSize.x; let v = (position.y - this.box.min.y) / boxSize.y; - + return [u, v]; } - - heightAtMipMapLevel(position, mipMapLevel){ + + heightAtMipMapLevel (position, mipMapLevel) { let uv = this.uv(position); - + let tileSize = parseInt(this.tileSize / parseInt(2 ** mipMapLevel)); let data = this.mipMap[mipMapLevel]; - + let i = Math.min(uv[0] * tileSize, tileSize - 1); let j = Math.min(uv[1] * tileSize, tileSize - 1); - + let a = i % 1; let b = j % 1; - + let [i0, i1] = [Math.floor(i), Math.ceil(i)]; let [j0, j1] = [Math.floor(j), Math.ceil(j)]; - + let h00 = data[i0 + tileSize * j0]; let h01 = data[i0 + tileSize * j1]; let h10 = data[i1 + tileSize * j0]; let h11 = data[i1 + tileSize * j1]; - + let wh00 = isFinite(h00) ? (1 - a) * (1 - b) : 0; let wh01 = isFinite(h01) ? (1 - a) * b : 0; let wh10 = isFinite(h10) ? a * (1 - b) : 0; let wh11 = isFinite(h11) ? a * b : 0; - + let wsum = wh00 + wh01 + wh10 + wh11; wh00 = wh00 / wsum; wh01 = wh01 / wsum; wh10 = wh10 / wsum; wh11 = wh11 / wsum; - - if(wsum === 0){ + + if (wsum === 0) { return null; } - + let h = 0; - - if(isFinite(h00)) h += h00 * wh00; - if(isFinite(h01)) h += h01 * wh01; - if(isFinite(h10)) h += h10 * wh10; - if(isFinite(h11)) h += h11 * wh11; - + + if (isFinite(h00)) h += h00 * wh00; + if (isFinite(h01)) h += h01 * wh01; + if (isFinite(h10)) h += h10 * wh10; + if (isFinite(h11)) h += h11 * wh11; + return h; } - - height(position){ - + + height (position) { let h = null; - - for(let i = 0; i < this.mipMap.length; i++){ + + for (let i = 0; i < this.mipMap.length; i++) { h = this.heightAtMipMapLevel(position, i); - - if(h !== null){ + + if (h !== null) { return h; } } - + return h; } - - traverse(callback, level = 0){ - callback(this, level); - - for(let child of this.children.filter(c => c !== undefined)){ - child.traverse(callback, level + 1); + + traverse (handler, level = 0) { + handler(this, level); + + for (let child of this.children.filter(c => c !== undefined)) { + child.traverse(handler, level + 1); } } -} +}; -Potree.DEM = class DEM{ - constructor(pointcloud){ - +Potree.DEM = class DEM { + constructor (pointcloud) { this.pointcloud = pointcloud; this.matrix = null; this.boundingBox = null; this.tileSize = 64; this.root = null; this.version = 0; - } - + // expands the tree to all nodes that intersect at // returns the intersecting nodes at - expandAndFindByBox(box, level){ - - if(level === 0){ + expandAndFindByBox (box, level) { + if (level === 0) { return [this.root]; } - + let result = []; let stack = [this.root]; - - while(stack.length > 0){ - + + while (stack.length > 0) { let node = stack.pop(); let nodeBoxSize = node.box.getSize(); - + // check which children intersect by transforming min/max to quadrants let min = { x: (box.min.x - node.box.min.x) / nodeBoxSize.x, @@ -172,196 +167,184 @@ Potree.DEM = class DEM{ let max = { x: (box.max.x - node.box.max.x) / nodeBoxSize.x, y: (box.max.y - node.box.max.y) / nodeBoxSize.y}; - + min.x = min.x < 0.5 ? 0 : 1; min.y = min.y < 0.5 ? 0 : 1; max.x = max.x < 0.5 ? 0 : 1; max.y = max.y < 0.5 ? 0 : 1; - + let childIndices; - if(min.x === 0 && min.y === 0 && max.x === 1 && max.y === 1){ + if (min.x === 0 && min.y === 0 && max.x === 1 && max.y === 1) { childIndices = [0, 1, 2, 3]; - }else if(min.x === max.x && min.y == max.y){ + } else if (min.x === max.x && min.y === max.y) { childIndices = [(min.x << 1) | min.y]; - }else{ + } else { childIndices = [(min.x << 1) | min.y, (max.x << 1) | max.y]; } - - for(let index of childIndices){ - if(node.children[index] === undefined){ + + for (let index of childIndices) { + if (node.children[index] === undefined) { let childBox = node.box.clone(); - - if((index & 2) > 0){ + + if ((index & 2) > 0) { childBox.min.x += nodeBoxSize.x / 2.0; - }else{ + } else { childBox.max.x -= nodeBoxSize.x / 2.0; } - - if((index & 1) > 0){ + + if ((index & 1) > 0) { childBox.min.y += nodeBoxSize.y / 2.0; - }else{ + } else { childBox.max.y -= nodeBoxSize.y / 2.0; } - + let child = new Potree.DEMNode(node.name + index, childBox, this.tileSize); node.children[index] = child; } - + let child = node.children[index]; - - if(child.level < level){ + + if (child.level < level) { stack.push(child); - }else{ + } else { result.push(child); } } } - + return result; } - - childIndex(uv){ + + childIndex (uv) { let [x, y] = uv.map(n => n < 0.5 ? 0 : 1); - + let index = (x << 1) | y; - + return index; } - - height(position){ - - //return this.root.height(position); - - if(!this.root){ + + height (position) { + // return this.root.height(position); + + if (!this.root) { return 0; } - + let height = null; let list = [this.root]; - while(true){ + while (true) { let node = list[list.length - 1]; - + let currentHeight = node.height(position); - - if(currentHeight !== null){ + + if (currentHeight !== null) { height = currentHeight; } - + let uv = node.uv(position); let childIndex = this.childIndex(uv); - - if(node.children[childIndex]){ + + if (node.children[childIndex]) { list.push(node.children[childIndex]); - }else{ + } else { break; } } - + return height + this.pointcloud.position.z; } - - update(visibleNodes){ - - if(Potree.getDEMWorkerInstance().working){ + + update (visibleNodes) { + if (Potree.getDEMWorkerInstance().working) { return; } - + // check if point cloud transformation changed - if(this.matrix === null || !this.matrix.equals(this.pointcloud.matrixWorld)){ + if (this.matrix === null || !this.matrix.equals(this.pointcloud.matrixWorld)) { this.matrix = this.pointcloud.matrixWorld.clone(); this.boundingBox = this.pointcloud.boundingBox.clone().applyMatrix4(this.matrix); - this.root = new Potree.DEMNode("r", this.boundingBox, this.tileSize); + this.root = new Potree.DEMNode('r', this.boundingBox, this.tileSize); this.version++; } - + // find node to update let node = null; - for(let vn of visibleNodes){ - if(vn.demVersion === undefined || vn.demVersion < this.version){ + for (let vn of visibleNodes) { + if (vn.demVersion === undefined || vn.demVersion < this.version) { node = vn; break; } } - if(node === null){ + if (node === null) { return; } - - + // update node let projectedBox = node.getBoundingBox().clone().applyMatrix4(this.matrix); let projectedBoxSize = projectedBox.getSize(); - + let targetNodes = this.expandAndFindByBox(projectedBox, node.getLevel()); node.demVersion = this.version; - + Potree.getDEMWorkerInstance().onmessage = (e) => { - let data = new Float32Array(e.data.dem.data); - - for(let demNode of targetNodes){ - + + for (let demNode of targetNodes) { let boxSize = demNode.box.getSize(); - - for(let i = 0; i < this.tileSize; i++){ - for(let j = 0; j < this.tileSize; j++){ - + + for (let i = 0; i < this.tileSize; i++) { + for (let j = 0; j < this.tileSize; j++) { let u = (i / (this.tileSize - 1)); let v = (j / (this.tileSize - 1)); - + let x = demNode.box.min.x + u * boxSize.x; let y = demNode.box.min.y + v * boxSize.y; - + let ix = this.tileSize * (x - projectedBox.min.x) / projectedBoxSize.x; let iy = this.tileSize * (y - projectedBox.min.y) / projectedBoxSize.y; - - if(ix < 0 || ix > this.tileSize){ + + if (ix < 0 || ix > this.tileSize) { continue; } - - if(iy < 0 || iy > this.tileSize){ + + if (iy < 0 || iy > this.tileSize) { continue; } - + ix = Math.min(Math.floor(ix), this.tileSize - 1); iy = Math.min(Math.floor(iy), this.tileSize - 1); - + demNode.data[i + this.tileSize * j] = data[ix + this.tileSize * iy]; - } } - + demNode.createMipMap(); demNode.mipMapNeedsUpdate = true; - + Potree.getDEMWorkerInstance().working = false; - - - } - - - - // TODO only works somewhat if there is no rotation to the point cloud - - //let target = targetNodes[0]; - //target.data = new Float32Array(data); + + // TODO only works somewhat if there is no rotation to the point cloud + + // let target = targetNodes[0]; + // target.data = new Float32Array(data); // // - ////node.dem = e.data.dem; - // - //Potree.getDEMWorkerInstance().working = false; + /// /node.dem = e.data.dem; // - //{ // create scene objects for debugging + // Potree.getDEMWorkerInstance().working = false; + // + // { // create scene objects for debugging // //for(let demNode of targetNodes){ // var bb = new Potree.Box3Helper(box); // viewer.scene.scene.add(bb); - // + // // createDEMMesh(this, target); // //} - // - //} + // + // } }; - + let position = node.geometryNode.geometry.attributes.position.array; let message = { boundingBox: { @@ -373,61 +356,47 @@ Potree.DEM = class DEM{ let transferables = [message.position]; Potree.getDEMWorkerInstance().working = true; Potree.getDEMWorkerInstance().postMessage(message, transferables); - - } - }; -Potree.PointCloudTreeNode = class{ - - constructor(){ - - } - - getChildren(){ - throw "override function"; - } - - getBoundingBox(){ - throw "override function"; +Potree.PointCloudTreeNode = class { + getChildren () { + throw new Error('override function'); } - isLoaded(){ - throw "override function"; - } - - isGeometryNode(){ - throw "override function"; - } - - isTreeNode(){ - throw "override function"; - } - - getLevel(){ - throw "override function"; + getBoundingBox () { + throw new Error('override function'); } - getBoundingSphere(){ - throw "override function"; + isLoaded () { + throw new Error('override function'); + } + + isGeometryNode () { + throw new Error('override function'); + } + + isTreeNode () { + throw new Error('override function'); + } + + getLevel () { + throw new Error('override function'); + } + + getBoundingSphere () { + throw new Error('override function'); } - }; - -Potree.PointCloudTree = class PointCloudTree extends THREE.Object3D{ - - constructor(){ +Potree.PointCloudTree = class PointCloudTree extends THREE.Object3D { + constructor () { super(); - + this.dem = new Potree.DEM(this); } - - initialized(){ + + initialized () { return this.root !== null; } - - }; - diff --git a/src/Potree.js b/src/Potree.js index df411272..5a1b2bc6 100644 --- a/src/Potree.js +++ b/src/Potree.js @@ -1,23 +1,21 @@ - - -function Potree(){ +function Potree () { } Potree.version = { major: 1, minor: 5, - suffix: "RC" + suffix: 'RC' }; -console.log("Potree " + Potree.version.major + "." + Potree.version.minor + Potree.version.suffix); +console.log('Potree ' + Potree.version.major + '.' + Potree.version.minor + Potree.version.suffix); -Potree.pointBudget = 1*1000*1000; +Potree.pointBudget = 1 * 1000 * 1000; Potree.framenumber = 0; // contains WebWorkers with base64 encoded code -//Potree.workers = {}; +// Potree.workers = {}; Potree.Shaders = {}; @@ -28,207 +26,192 @@ Potree.webgl = { }; Potree.scriptPath = null; -if(document.currentScript.src){ - Potree.scriptPath = new URL(document.currentScript.src + "/..").href; - if (Potree.scriptPath.slice(-1) === '/') { - Potree.scriptPath = Potree.scriptPath.slice(0, -1); - } -}else{ - console.error("Potree was unable to find its script path using document.currentScript. Is Potree included with a script tag? Does your browser support this function?"); +if (document.currentScript.src) { + Potree.scriptPath = new URL(document.currentScript.src + '/..').href; + if (Potree.scriptPath.slice(-1) === '/') { + Potree.scriptPath = Potree.scriptPath.slice(0, -1); + } +} else { + console.error('Potree was unable to find its script path using document.currentScript. Is Potree included with a script tag? Does your browser support this function?'); } -Potree.resourcePath = Potree.scriptPath + "/resources"; - +Potree.resourcePath = Potree.scriptPath + '/resources'; Potree.timerQueries = {}; Potree.timerQueriesEnabled = false; -Potree.startQuery = function(name, gl){ - if(!Potree.timerQueriesEnabled){ +Potree.startQuery = function (name, gl) { + if (!Potree.timerQueriesEnabled) { return null; } - - if(Potree.timerQueries[name] === undefined){ + + if (Potree.timerQueries[name] === undefined) { Potree.timerQueries[name] = []; } - - let ext = gl.getExtension("EXT_disjoint_timer_query"); + + let ext = gl.getExtension('EXT_disjoint_timer_query'); let query = ext.createQueryEXT(); ext.beginQueryEXT(ext.TIME_ELAPSED_EXT, query); - + Potree.timerQueries[name].push(query); - + return query; }; -Potree.endQuery = function(query, gl){ - if(!Potree.timerQueriesEnabled){ +Potree.endQuery = function (query, gl) { + if (!Potree.timerQueriesEnabled) { return; } - - let ext = gl.getExtension("EXT_disjoint_timer_query"); + + let ext = gl.getExtension('EXT_disjoint_timer_query'); ext.endQueryEXT(ext.TIME_ELAPSED_EXT); }; -Potree.resolveQueries = function(gl){ - if(!Potree.timerQueriesEnabled){ +Potree.resolveQueries = function (gl) { + if (!Potree.timerQueriesEnabled) { return; } - - let ext = gl.getExtension("EXT_disjoint_timer_query"); - - for(let name in Potree.timerQueries){ + + let ext = gl.getExtension('EXT_disjoint_timer_query'); + + for (let name in Potree.timerQueries) { let queries = Potree.timerQueries[name]; - - if(queries.length > 0){ + + if (queries.length > 0) { let query = queries[0]; - + let available = ext.getQueryObjectEXT(query, ext.QUERY_RESULT_AVAILABLE_EXT); let disjoint = viewer.renderer.getContext().getParameter(ext.GPU_DISJOINT_EXT); - + if (available && !disjoint) { // See how much time the rendering of the object took in nanoseconds. let timeElapsed = ext.getQueryObjectEXT(query, ext.QUERY_RESULT_EXT); let miliseconds = timeElapsed / (1000 * 1000); - - console.log(name + ": " + miliseconds + "ms"); + + console.log(name + ': ' + miliseconds + 'ms'); queries.shift(); } } - - if(queries.length === 0){ + + if (queries.length === 0) { delete Potree.timerQueries[name]; } } }; - Potree.MOUSE = { - LEFT: 0b0001, - RIGHT: 0b0010, + LEFT: 0b0001, + RIGHT: 0b0010, MIDDLE: 0b0100 }; -Potree.Points = class Points{ - - constructor(){ - +Potree.Points = class Points { + constructor () { this.boundingBox = new THREE.Box3(); this.numPoints = 0; this.data = {}; - } - - add(points){ - + + add (points) { let currentSize = this.numPoints; let additionalSize = points.numPoints; let newSize = currentSize + additionalSize; - + let thisAttributes = Object.keys(this.data); let otherAttributes = Object.keys(points.data); let attributes = new Set([...thisAttributes, ...otherAttributes]); - - for(let attribute of attributes){ - if(thisAttributes.includes(attribute) && otherAttributes.includes(attribute)){ - + + for (let attribute of attributes) { + if (thisAttributes.includes(attribute) && otherAttributes.includes(attribute)) { // attribute in both, merge - let type = this.data[attribute].constructor; - let merged = new type(this.data[attribute].length + points.data[attribute].length); + let Type = this.data[attribute].constructor; + let merged = new Type(this.data[attribute].length + points.data[attribute].length); merged.set(this.data[attribute], 0); merged.set(points.data[attribute], this.data[attribute].length); this.data[attribute] = merged; - - }else if(thisAttributes.includes(attribute) && !otherAttributes.includes(attribute)){ - + } else if (thisAttributes.includes(attribute) && !otherAttributes.includes(attribute)) { // attribute only in this; take over this and expand to new size let elementsPerPoint = this.data[attribute].length / this.numPoints; - let type = this.data[attribute].constructor; - let expanded = new type(elementsPerPoint * newSize); + let Type = this.data[attribute].constructor; + let expanded = new Type(elementsPerPoint * newSize); expanded.set(this.data[attribute], 0); this.data[attribute] = expanded; - - }else if(!thisAttributes.includes(attribute) && otherAttributes.includes(attribute)){ - + } else if (!thisAttributes.includes(attribute) && otherAttributes.includes(attribute)) { // attribute only in points to be added; take over new points and expand to new size let elementsPerPoint = points.data[attribute].length / points.numPoints; - let type = points.data[attribute].constructor; - let expanded = new type(elementsPerPoint * newSize); + let Type = points.data[attribute].constructor; + let expanded = new Type(elementsPerPoint * newSize); expanded.set(points.data[attribute], elementsPerPoint * currentSize); this.data[attribute] = expanded; - } } - + this.numPoints = newSize; - + this.boundingBox.union(points.boundingBox); } - }; - -Potree.loadPointCloud = function(path, name, callback){ - - let loaded = function(pointcloud){ +/* eslint-disable standard/no-callback-literal */ +Potree.loadPointCloud = function (path, name, callback) { + let loaded = function (pointcloud) { pointcloud.name = name; - - callback({type: "pointcloud_loaded", pointcloud: pointcloud}); + callback({type: 'pointcloud_loaded', pointcloud: pointcloud}); }; - + // load pointcloud - if(!path){ - - }else if(path.indexOf("greyhound://") === 0){ + if (!path) { + // TODO: callback? comment? Hello? Bueller? Anyone? + } else if (path.indexOf('greyhound://') === 0) { // We check if the path string starts with 'greyhound:', if so we assume it's a greyhound server URL. - Potree.GreyhoundLoader.load(path, function(geometry) { - if(!geometry){ - callback({type: "loading_failed"}); - }else{ + Potree.GreyhoundLoader.load(path, function (geometry) { + if (!geometry) { + callback({type: 'loading_failed'}); + } else { let pointcloud = new Potree.PointCloudOctree(geometry); loaded(pointcloud); } }); - }else if(path.indexOf("cloud.js") > 0){ - Potree.POCLoader.load(path, function(geometry){ - if(!geometry){ - callback({type: "loading_failed"}); - }else{ + } else if (path.indexOf('cloud.js') > 0) { + Potree.POCLoader.load(path, function (geometry) { + if (!geometry) { + callback({type: 'loading_failed'}); + } else { let pointcloud = new Potree.PointCloudOctree(geometry); loaded(pointcloud); } - }.bind(this)); - }else if(path.indexOf(".vpc") > 0){ - Potree.PointCloudArena4DGeometry.load(path, function(geometry){ - if(!geometry){ - callback({type: "loading_failed"}); - }else{ + }); + } else if (path.indexOf('.vpc') > 0) { + Potree.PointCloudArena4DGeometry.load(path, function (geometry) { + if (!geometry) { + callback({type: 'loading_failed'}); + } else { let pointcloud = new Potree.PointCloudArena4D(geometry); loaded(pointcloud); } }); - }else{ - callback({"type": "loading_failed"}); + } else { + callback({'type': 'loading_failed'}); } }; +/* eslint-enable standard/no-callback-literal */ -Potree.updatePointClouds = function(pointclouds, camera, renderer){ - - if(!Potree.lru){ +Potree.updatePointClouds = function (pointclouds, camera, renderer) { + if (!Potree.lru) { Potree.lru = new LRU(); } - for(let i = 0; i < pointclouds.length; i++){ + for (let i = 0; i < pointclouds.length; i++) { let pointcloud = pointclouds[i]; - for(let j = 0; j < pointcloud.profileRequests.length; j++){ + for (let j = 0; j < pointcloud.profileRequests.length; j++) { pointcloud.profileRequests[j].update(); } } - + let result = Potree.updateVisibility(pointclouds, camera, renderer); - - for(let i = 0; i < pointclouds.length; i++){ + + for (let i = 0; i < pointclouds.length; i++) { let pointcloud = pointclouds[i]; pointcloud.updateMaterial(pointcloud.material, pointcloud.visibleNodes, camera, renderer); pointcloud.updateVisibleBounds(); @@ -239,24 +222,23 @@ Potree.updatePointClouds = function(pointclouds, camera, renderer){ return result; }; -Potree.getLRU = function(){ - if(!Potree.lru){ +Potree.getLRU = function () { + if (!Potree.lru) { Potree.lru = new LRU(); } return Potree.lru; }; - -function updateVisibilityStructures(pointclouds, camera, renderer){ +function updateVisibilityStructures (pointclouds, camera, renderer) { let frustums = []; let camObjPositions = []; - let priorityQueue = new BinaryHeap(function(x){return 1 / x.weight;}); - - for(let i = 0; i < pointclouds.length; i++){ + let priorityQueue = new BinaryHeap(function (x) { return 1 / x.weight; }); + + for (let i = 0; i < pointclouds.length; i++) { let pointcloud = pointclouds[i]; - - if(!pointcloud.initialized()){ + + if (!pointcloud.initialized()) { continue; } @@ -273,289 +255,290 @@ function updateVisibilityStructures(pointclouds, camera, renderer){ let world = pointcloud.matrixWorld; let proj = camera.projectionMatrix; let fm = new THREE.Matrix4().multiply(proj).multiply(viewI).multiply(world); - frustum.setFromMatrix( fm ); + frustum.setFromMatrix(fm); frustums.push(frustum); // camera position in object space let view = camera.matrixWorld; let worldI = new THREE.Matrix4().getInverse(world); let camMatrixObject = new THREE.Matrix4().multiply(worldI).multiply(view); - let camObjPos = new THREE.Vector3().setFromMatrixPosition( camMatrixObject ); + let camObjPos = new THREE.Vector3().setFromMatrixPosition(camMatrixObject); camObjPositions.push(camObjPos); - if(pointcloud.visible && pointcloud.root !== null){ + if (pointcloud.visible && pointcloud.root !== null) { priorityQueue.push({pointcloud: i, node: pointcloud.root, weight: Number.MAX_VALUE}); } // hide all previously visible nodes - //if(pointcloud.root instanceof Potree.PointCloudOctreeNode){ + // if(pointcloud.root instanceof Potree.PointCloudOctreeNode){ // pointcloud.hideDescendants(pointcloud.root.sceneNode); - //} - if(pointcloud.root.isTreeNode()){ + // } + if (pointcloud.root.isTreeNode()) { pointcloud.hideDescendants(pointcloud.root.sceneNode); } - - for(let j = 0; j < pointcloud.boundingBoxNodes.length; j++){ + + for (let j = 0; j < pointcloud.boundingBoxNodes.length; j++) { pointcloud.boundingBoxNodes[j].visible = false; } } - + return { - "frustums": frustums, - "camObjPositions" : camObjPositions, - "priorityQueue": priorityQueue + 'frustums': frustums, + 'camObjPositions': camObjPositions, + 'priorityQueue': priorityQueue }; } -Potree.getDEMWorkerInstance = function(){ - if(!Potree.DEMWorkerInstance){ - let workerPath = Potree.scriptPath + "/workers/DEMWorker.js"; +Potree.getDEMWorkerInstance = function () { + if (!Potree.DEMWorkerInstance) { + let workerPath = Potree.scriptPath + '/workers/DEMWorker.js'; Potree.DEMWorkerInstance = Potree.workerPool.getWorker(workerPath); } - - return Potree.DEMWorkerInstance; -} -function createDEMMesh(dem){ - + return Potree.DEMWorkerInstance; +}; + +/* +function createDEMMesh (dem) { let box = dem.boundingBox; let steps = 256; - let triangles = []; - for(let i = 0; i < steps; i++){ - for(let j = 0; j < steps; j++){ + let triangles = []; + for (let i = 0; i < steps; i++) { + for (let j = 0; j < steps; j++) { let u0 = i / steps; - let u1 = (i+1) / steps; + let u1 = (i + 1) / steps; let v0 = j / steps; - let v1 = (j+1) / steps; - - //let x0 = box.min.x + u0 * box.getSize().x; - //let x1 = box.min.x + u1 * box.getSize().x; - //let y0 = box.min.y + v0 * box.getSize().y; - //let y1 = box.min.y + v1 * box.getSize().y; + let v1 = (j + 1) / steps; + + // let x0 = box.min.x + u0 * box.getSize().x; + // let x1 = box.min.x + u1 * box.getSize().x; + // let y0 = box.min.y + v0 * box.getSize().y; + // let y1 = box.min.y + v1 * box.getSize().y; // - //let h00 = dem.height(new THREE.Vector3(x0, y0, 0)); - //let h10 = dem.height(new THREE.Vector3(x1, y0, 0)); - //let h01 = dem.height(new THREE.Vector3(x0, y1, 0)); - //let h11 = dem.height(new THREE.Vector3(x1, y1, 0)); - + // let h00 = dem.height(new THREE.Vector3(x0, y0, 0)); + // let h10 = dem.height(new THREE.Vector3(x1, y0, 0)); + // let h01 = dem.height(new THREE.Vector3(x0, y1, 0)); + // let h11 = dem.height(new THREE.Vector3(x1, y1, 0)); + let x0 = u0 * box.getSize().x; let x1 = u1 * box.getSize().x; let y0 = v0 * box.getSize().y; let y1 = v1 * box.getSize().y; - - //let h00 = demNode.data[(i+0) + tileSize * (j+0)]; - //let h10 = demNode.data[(i+1) + tileSize * (j+0)]; - //let h01 = demNode.data[(i+0) + tileSize * (j+1)]; - //let h11 = demNode.data[(i+1) + tileSize * (j+1)]; - + + // let h00 = demNode.data[(i+0) + tileSize * (j+0)]; + // let h10 = demNode.data[(i+1) + tileSize * (j+0)]; + // let h01 = demNode.data[(i+0) + tileSize * (j+1)]; + // let h11 = demNode.data[(i+1) + tileSize * (j+1)]; + let h00 = dem.height(new THREE.Vector3(box.min.x + x0, box.min.y + y0)); let h10 = dem.height(new THREE.Vector3(box.min.x + x1, box.min.y + y0)); let h01 = dem.height(new THREE.Vector3(box.min.x + x0, box.min.y + y1)); let h11 = dem.height(new THREE.Vector3(box.min.x + x1, box.min.y + y1)); - - if(![h00, h10, h01, h11].every(n => isFinite(n))){ + + if (![h00, h10, h01, h11].every(n => isFinite(n))) { continue; } - + triangles.push(x0, y0, h00); triangles.push(x0, y1, h01); triangles.push(x1, y0, h10); - + triangles.push(x0, y1, h01); triangles.push(x1, y1, h11); triangles.push(x1, y0, h10); } } - + let geometry = new THREE.BufferGeometry(); let positions = new Float32Array(triangles); - geometry.addAttribute( 'position', new THREE.BufferAttribute(positions, 3)); + geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3)); geometry.computeBoundingSphere(); geometry.computeVertexNormals(); let material = new THREE.MeshNormalMaterial({side: THREE.DoubleSide}); let mesh = new THREE.Mesh(geometry, material); mesh.position.copy(box.min); - //mesh.position.copy(pointcloud.position); + // mesh.position.copy(pointcloud.position); viewer.scene.scene.add(mesh); } +*/ -function createDEMMeshNode(dem, demNode){ - +/* +function createDEMMeshNode (dem, demNode) { let box = demNode.box; let tileSize = dem.tileSize * 1; - - let triangles = []; - for(let i = 0; i < tileSize; i++){ - //for(let j = 0; j < 1; j++){ - for(let j = 0; j < tileSize; j++){ + + let triangles = []; + for (let i = 0; i < tileSize; i++) { + // for(let j = 0; j < 1; j++){ + for (let j = 0; j < tileSize; j++) { let u0 = i / tileSize; - let u1 = (i+1) / tileSize; + let u1 = (i + 1) / tileSize; let v0 = j / tileSize; - let v1 = (j+1) / tileSize; - + let v1 = (j + 1) / tileSize; + let x0 = u0 * box.getSize().x; let x1 = u1 * box.getSize().x; let y0 = v0 * box.getSize().y; let y1 = v1 * box.getSize().y; - - //let h00 = demNode.data[(i+0) + tileSize * (j+0)]; - //let h10 = demNode.data[(i+1) + tileSize * (j+0)]; - //let h01 = demNode.data[(i+0) + tileSize * (j+1)]; - //let h11 = demNode.data[(i+1) + tileSize * (j+1)]; - + + // let h00 = demNode.data[(i+0) + tileSize * (j+0)]; + // let h10 = demNode.data[(i+1) + tileSize * (j+0)]; + // let h01 = demNode.data[(i+0) + tileSize * (j+1)]; + // let h11 = demNode.data[(i+1) + tileSize * (j+1)]; + let h00 = demNode.height(new THREE.Vector3(box.min.x + x0, box.min.y + y0)); let h10 = demNode.height(new THREE.Vector3(box.min.x + x1, box.min.y + y0)); let h01 = demNode.height(new THREE.Vector3(box.min.x + x0, box.min.y + y1)); let h11 = demNode.height(new THREE.Vector3(box.min.x + x1, box.min.y + y1)); - - if(![h00, h10, h01, h11].every(n => isFinite(n))){ + + if (![h00, h10, h01, h11].every(n => isFinite(n))) { continue; } - + triangles.push(x0, y0, h00); triangles.push(x0, y1, h01); triangles.push(x1, y0, h10); - + triangles.push(x0, y1, h01); triangles.push(x1, y1, h11); triangles.push(x1, y0, h10); } } - + let geometry = new THREE.BufferGeometry(); let positions = new Float32Array(triangles); - geometry.addAttribute( 'position', new THREE.BufferAttribute(positions, 3)); + geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3)); geometry.computeBoundingSphere(); geometry.computeVertexNormals(); let material = new THREE.MeshNormalMaterial({side: THREE.DoubleSide}); let mesh = new THREE.Mesh(geometry, material); mesh.position.copy(box.min); - //mesh.position.copy(pointcloud.position); + // mesh.position.copy(pointcloud.position); viewer.scene.scene.add(mesh); - + { // DEBUG code - //let data = demNode.data; - + // let data = demNode.data; + let steps = 64; let data = new Float32Array(steps * steps); let imgData = new Uint8Array(data.length * 4); let box = demNode.box; let boxSize = box.getSize(); - for(let i = 0; i < steps; i++){ - for(let j = 0; j < steps; j++){ + for (let i = 0; i < steps; i++) { + for (let j = 0; j < steps; j++) { let [u, v] = [i / (steps - 1), j / (steps - 1)]; let pos = new THREE.Vector3( u * boxSize.x + box.min.x, v * boxSize.y + box.min.y, 0 ); - + let height = demNode.height(pos); - + let index = i + steps * j; - data[index] = height - - //let index = i + steps * j; - //imgData[4*index + 0] = 255 * (height - min) / (max - min); - //imgData[4*index + 1] = 100; - //imgData[4*index + 2] = 0; - //imgData[4*index + 3] = 255; + data[index] = height; + + // let index = i + steps * j; + // imgData[4*index + 0] = 255 * (height - min) / (max - min); + // imgData[4*index + 1] = 100; + // imgData[4*index + 2] = 0; + // imgData[4*index + 3] = 255; } } - + let [min, max] = [Infinity, -Infinity]; - for(let height of data){ - if(!isFinite(height)){ + for (let height of data) { + if (!isFinite(height)) { continue; } - + min = Math.min(min, height); max = Math.max(max, height); } - - for(let i = 0; i < data.length; i++){ - imgData[4*i + 0] = 255 * (data[i] - min) / (max - min); - imgData[4*i + 1] = 100; - imgData[4*i + 2] = 0; - imgData[4*i + 3] = 255; + + for (let i = 0; i < data.length; i++) { + imgData[4 * i + 0] = 255 * (data[i] - min) / (max - min); + imgData[4 * i + 1] = 100; + imgData[4 * i + 2] = 0; + imgData[4 * i + 3] = 255; } - + let img = Potree.utils.pixelsArrayToImage(imgData, steps, steps); - + let screenshot = img.src; - - if(!this.debugDIV){ + + if (!this.debugDIV) { this.debugDIV = $(` -
`); $(document.body).append(this.debugDIV); } - + this.debugDIV.empty(); this.debugDIV.append($(``)); - } } +*/ -Potree.updateVisibility = function(pointclouds, camera, renderer){ - let numVisibleNodes = 0; +Potree.updateVisibility = function (pointclouds, camera, renderer) { + // let numVisibleNodes = 0; let numVisiblePoints = 0; - + let visibleNodes = []; let visibleGeometry = []; let unloadedGeometry = []; - + let lowestSpacing = Infinity; - + // calculate object space frustum and cam pos and setup priority queue let s = updateVisibilityStructures(pointclouds, camera, renderer); let frustums = s.frustums; let camObjPositions = s.camObjPositions; let priorityQueue = s.priorityQueue; - + let loadedToGPUThisFrame = 0; - - while(priorityQueue.size() > 0){ + + while (priorityQueue.size() > 0) { let element = priorityQueue.pop(); let node = element.node; let parent = element.parent; let pointcloud = pointclouds[element.pointcloud]; - - //{ // restrict to certain nodes for debugging + + // { // restrict to certain nodes for debugging // let allowedNodes = ["r", "r0", "r4"]; // if(!allowedNodes.includes(node.name)){ // continue; // } - //} - + // } + let box = node.getBoundingBox(); let frustum = frustums[element.pointcloud]; let camObjPos = camObjPositions[element.pointcloud]; - + let insideFrustum = frustum.intersectsBox(box); let maxLevel = pointcloud.maxLevel || Infinity; let level = node.getLevel(); let visible = insideFrustum; visible = visible && !(numVisiblePoints + node.getNumPoints() > Potree.pointBudget); visible = visible && level < maxLevel; - - if (pointcloud.material.numClipBoxes > 0 && visible && pointcloud.material.clipMode == Potree.ClipMode.CLIP_OUTSIDE) { - let box2 = box.clone(); + + if (pointcloud.material.numClipBoxes > 0 && visible && pointcloud.material.clipMode === Potree.ClipMode.CLIP_OUTSIDE) { + let box2 = box.clone(); pointcloud.updateMatrixWorld(true); box2.applyMatrix4(pointcloud.matrixWorld); let intersectsClipBoxes = false; - for(let clipBox of pointcloud.material.clipBoxes) { + for (let clipBox of pointcloud.material.clipBoxes) { let clipMatrixWorld = clipBox.matrix; let clipBoxWorld = new THREE.Box3( - new THREE.Vector3(-0.5, -0.5, -0.5), - new THREE.Vector3(0.5, 0.5, 0.5)) - .applyMatrix4(clipMatrixWorld); + new THREE.Vector3(-0.5, -0.5, -0.5), + new THREE.Vector3(0.5, 0.5, 0.5) + ).applyMatrix4(clipMatrixWorld); if (box2.intersectsBox(clipBoxWorld)) { intersectsClipBoxes = true; break; @@ -563,42 +546,42 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ } visible = visible && intersectsClipBoxes; } - - //visible = ["r", "r0", "r06", "r060"].includes(node.name); - //visible = ["r"].includes(node.name); - - if(node.spacing){ + + // visible = ["r", "r0", "r06", "r060"].includes(node.name); + // visible = ["r"].includes(node.name); + + if (node.spacing) { lowestSpacing = Math.min(lowestSpacing, node.spacing); - }else if(node.geometryNode && node.geometryNode.spacing){ + } else if (node.geometryNode && node.geometryNode.spacing) { lowestSpacing = Math.min(lowestSpacing, node.geometryNode.spacing); } - - if(numVisiblePoints + node.getNumPoints() > Potree.pointBudget){ + + if (numVisiblePoints + node.getNumPoints() > Potree.pointBudget) { break; } - - - if(!visible){ + + if (!visible) { continue; } - numVisibleNodes++; + // TODO: not used, same as the declaration? + // numVisibleNodes++; numVisiblePoints += node.getNumPoints(); pointcloud.numVisibleNodes++; pointcloud.numVisiblePoints += node.getNumPoints(); - if(node.isGeometryNode() && (!parent || parent.isTreeNode())){ - if(node.isLoaded() && loadedToGPUThisFrame < 2){ + if (node.isGeometryNode() && (!parent || parent.isTreeNode())) { + if (node.isLoaded() && loadedToGPUThisFrame < 2) { node = pointcloud.toTreeNode(node, parent); loadedToGPUThisFrame++; - }else{ + } else { unloadedGeometry.push(node); visibleGeometry.push(node); } } - if(node.isTreeNode()){ + if (node.isTreeNode()) { Potree.getLRU().touch(node.geometryNode); node.sceneNode.visible = true; node.sceneNode.material = pointcloud.material; @@ -607,89 +590,83 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ pointcloud.visibleNodes.push(node); node.sceneNode.updateMatrix(); - node.sceneNode.matrixWorld.multiplyMatrices( pointcloud.matrixWorld, node.sceneNode.matrix ); + node.sceneNode.matrixWorld.multiplyMatrices(pointcloud.matrixWorld, node.sceneNode.matrix); - if(pointcloud.showBoundingBox && !node.boundingBoxNode && node.getBoundingBox){ + if (pointcloud.showBoundingBox && !node.boundingBoxNode && node.getBoundingBox) { let boxHelper = new Potree.Box3Helper(node.getBoundingBox()); - //let boxHelper = new THREE.BoxHelper(node.sceneNode); + // let boxHelper = new THREE.BoxHelper(node.sceneNode); pointcloud.add(boxHelper); pointcloud.boundingBoxNodes.push(boxHelper); node.boundingBoxNode = boxHelper; node.boundingBoxNode.matrixWorld.copy(pointcloud.matrixWorld); - }else if(pointcloud.showBoundingBox){ + } else if (pointcloud.showBoundingBox) { node.boundingBoxNode.visible = true; node.boundingBoxNode.matrixWorld.copy(pointcloud.matrixWorld); - }else if(!pointcloud.showBoundingBox && node.boundingBoxNode){ + } else if (!pointcloud.showBoundingBox && node.boundingBoxNode) { node.boundingBoxNode.visible = false; } - } // add child nodes to priorityQueue let children = node.getChildren(); - for(let i = 0; i < children.length; i++){ + for (let i = 0; i < children.length; i++) { let child = children[i]; - + let sphere = child.getBoundingSphere(); let distance = sphere.center.distanceTo(camObjPos); let radius = sphere.radius; - + let fov = (camera.fov * Math.PI) / 180; let slope = Math.tan(fov / 2); let projFactor = (0.5 * renderer.domElement.clientHeight) / (slope * distance); let screenPixelRadius = radius * projFactor; - - if(screenPixelRadius < pointcloud.minimumNodePixelSize){ + + if (screenPixelRadius < pointcloud.minimumNodePixelSize) { continue; } - + let weight = screenPixelRadius; - if(distance - radius < 0){ + if (distance - radius < 0) { weight = Number.MAX_VALUE; } priorityQueue.push({pointcloud: element.pointcloud, node: child, parent: node, weight: weight}); } - - }// end priority queue loop - + { // update DEM let maxDEMLevel = 4; let candidates = pointclouds .filter(p => (p.generateDEM && p.dem instanceof Potree.DEM)); - for(let pointcloud of candidates){ + for (let pointcloud of candidates) { let updatingNodes = pointcloud.visibleNodes.filter(n => n.getLevel() <= maxDEMLevel); pointcloud.dem.update(updatingNodes); } } - - for(let i = 0; i < Math.min(5, unloadedGeometry.length); i++){ + + for (let i = 0; i < Math.min(5, unloadedGeometry.length); i++) { unloadedGeometry[i].load(); } - - //for(let node of visibleNodes){ + + // for(let node of visibleNodes){ // let allowedNodes = ["r", "r0", "r4"]; // node.sceneNode.visible = allowedNodes.includes(node.geometryNode.name); - // + // // if(node.boundingBoxNode){ // node.boundingBoxNode.visible = node.boundingBoxNode.visible && node.sceneNode.visible; // } - //} - - - //Potree.updateDEMs(renderer, visibleNodes); + // } + + // Potree.updateDEMs(renderer, visibleNodes); return { - visibleNodes: visibleNodes, + visibleNodes: visibleNodes, numVisiblePoints: numVisiblePoints, lowestSpacing: lowestSpacing }; }; - - /* // // WAY TOO SLOW WITH SYNCHRONOUS READ PIXEL @@ -697,144 +674,143 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ Potree.DEMRenderer = class{ constructor(renderer){ this.renderer = renderer; - + this.tileWidth = 64; this.tileHeight = 64; - - //this.target = new THREE.WebGLRenderTarget( 64, 64, { - // minFilter: THREE.NearestFilter, - // magFilter: THREE.NearestFilter, - // format: THREE.RGBAFormat, + + //this.target = new THREE.WebGLRenderTarget( 64, 64, { + // minFilter: THREE.NearestFilter, + // magFilter: THREE.NearestFilter, + // format: THREE.RGBAFormat, // type: THREE.FloatType //} ); //this.target.depthTexture = new THREE.DepthTexture(); //this.target.depthTexture.type = THREE.UnsignedIntType; - - this.targetElevation = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { - minFilter: THREE.NearestFilter, - magFilter: THREE.NearestFilter, + + this.targetElevation = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, format: THREE.RGBAFormat, //type: THREE.FloatType }); - - this.targetMedian = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { - minFilter: THREE.NearestFilter, - magFilter: THREE.NearestFilter, + + this.targetMedian = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, format: THREE.RGBAFormat, //type: THREE.FloatType }); - + this.vsElevation = ` precision mediump float; precision mediump int; - + attribute vec3 position; - + uniform mat4 modelMatrix; uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; - + varying float vElevation; - + void main(){ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); gl_Position = projectionMatrix * mvPosition; gl_PointSize = 1.0; - + vElevation = position.z; } `; - + this.fsElevation = ` precision mediump float; precision mediump int; - + varying float vElevation; - + void main(){ gl_FragColor = vec4(vElevation, 0.0, 0.0, 1.0); } `; - + this.vsMedian = ` precision mediump float; precision mediump int; - + attribute vec3 position; attribute vec2 uv; - + uniform mat4 modelMatrix; uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; - + varying vec2 vUV; void main() { vUV = uv; - + vec4 mvPosition = modelViewMatrix * vec4(position,1.0); gl_Position = projectionMatrix * mvPosition; } `; - + this.fsMedian = ` - + precision mediump float; precision mediump int; - + uniform float uWidth; - uniform float uHeight; + uniform float uHeight; uniform sampler2D uTexture; varying vec2 vUV; - + void main(){ - vec2 uv = gl_FragCoord.xy / vec2(uWidth, uHeight); - + vec2 uv = gl_FragCoord.xy / vec2(uWidth, uHeight); + vec4 color = texture2D(uTexture, uv); gl_FragColor = color; if(color.a == 0.0){ - + vec4 sum; - + float minVal = 1.0 / 0.0; - + float sumA = 0.0; for(int i = -1; i <= 1; i++){ for(int j = -1; j <= 1; j++){ vec2 n = gl_FragCoord.xy + vec2(i, j); - vec2 uv = n / vec2(uWidth, uHeight); + vec2 uv = n / vec2(uWidth, uHeight); vec4 c = texture2D(uTexture, uv); - + if(c.a == 1.0){ minVal = min(c.r, minVal); } - + sumA += c.a; } } - + if(sumA > 0.0){ gl_FragColor = vec4(minVal, 0.0, 0.0, 1.0); }else{ - discard; + discard; } }else{ //gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); gl_FragColor = vec4(color.rgb, 1.0); } - - + } - + `; - + this.elevationMaterial = new THREE.RawShaderMaterial( { vertexShader: this.vsElevation, fragmentShader: this.fsElevation, } ); - + this.medianFilterMaterial = new THREE.RawShaderMaterial( { uniforms: { uWidth: {value: 1.0}, @@ -844,28 +820,27 @@ Potree.DEMRenderer = class{ vertexShader: this.vsMedian, fragmentShader: this.fsMedian, }); - + this.camera = new THREE.OrthographicCamera(0, 1, 1, 0, 0, 1); - - + } - + render(pointcloud, node){ if(!node.geometryNode){ return; } - + Potree.timerQueriesEnabled = true; let start = new Date().getTime(); let queryAll = Potree.startQuery("All", this.renderer.getContext()); - + this.renderer.setClearColor(0x0000FF, 0); this.renderer.clearTarget( this.target, true, true, true ); this.renderer.clearTarget(this.targetElevation, true, true, false ); this.renderer.clearTarget(this.targetMedian, true, true, false ); - + let box = node.geometryNode.boundingBox; - + this.camera.up.set(0, 0, 1); //this.camera.rotation.x = Math.PI / 2; this.camera.left = box.min.x; @@ -875,53 +850,52 @@ Potree.DEMRenderer = class{ this.camera.near = -1000; this.camera.far = 1000; this.camera.updateProjectionMatrix(); - + let scene = new THREE.Scene(); //let material = new THREE.PointsMaterial({color: 0x00ff00, size: 0.0001}); let material = this.elevationMaterial; let points = new THREE.Points(node.geometryNode.geometry, material); scene.add(points); - + this.renderer.render(points, this.camera, this.targetElevation); - + this.medianFilterMaterial.uniforms.uWidth.value = this.targetMedian.width; this.medianFilterMaterial.uniforms.uHeight.value = this.targetMedian.height; this.medianFilterMaterial.uniforms.uTexture.value = this.targetElevation.texture; - + Potree.utils.screenPass.render(this.renderer, this.medianFilterMaterial, this.targetMedian); - + Potree.endQuery(queryAll, this.renderer.getContext()); Potree.resolveQueries(this.renderer.getContext()); Potree.timerQueriesEnabled = false; - - + setTimeout( () => { let start = new Date().getTime(); - + let pixelCount = this.tileWidth * this.tileHeight; let buffer = new Uint8Array(4 * pixelCount); - this.renderer.readRenderTargetPixels(this.targetMedian, - 0, 0, this.tileWidth, this.tileHeight, + this.renderer.readRenderTargetPixels(this.targetMedian, + 0, 0, this.tileWidth, this.tileHeight, buffer); - + let end = new Date().getTime(); let duration = end - start; console.log(`read duration: ${duration}ms`); }, 3000); - + let end = new Date().getTime(); let duration = end - start; - + console.log(`duration: ${duration}ms`); - + //{ // open window with image // // let pixelCount = this.tileWidth * this.tileHeight; // let buffer = new Float32Array(4 * pixelCount); - // this.renderer.readRenderTargetPixels(this.targetMedian, - // 0, 0, this.tileWidth, this.tileHeight, + // this.renderer.readRenderTargetPixels(this.targetMedian, + // 0, 0, this.tileWidth, this.tileHeight, // buffer); - // + // // let uiBuffer = new Uint8Array(4 * pixelCount); // for(let i = 0; i < pixelCount; i++){ // uiBuffer[i] = buffer[i] / 1.0; @@ -929,18 +903,18 @@ Potree.DEMRenderer = class{ // // let img = Potree.utils.pixelsArrayToImage(uiBuffer, this.tileWidth, this.tileHeight); // let screenshot = img.src; - // + // // if(!this.debugDIV){ // this.debugDIV = $(` - //
`); // $(document.body).append(this.debugDIV); // } - // + // // this.debugDIV.empty(); // this.debugDIV.append($(``)); @@ -949,4 +923,4 @@ Potree.DEMRenderer = class{ //} } }; -*/ \ No newline at end of file +*/ diff --git a/src/ProfileRequest.js b/src/ProfileRequest.js index d1097c6f..5879a190 100644 --- a/src/ProfileRequest.js +++ b/src/ProfileRequest.js @@ -1,21 +1,18 @@ - - -Potree.ProfileData = class ProfileData{ - - constructor(profile){ +Potree.ProfileData = class ProfileData { + constructor (profile) { this.profile = profile; - + this.segments = []; this.boundingBox = new THREE.Box3(); - - for(let i = 0; i < profile.points.length - 1; i++){ + + for (let i = 0; i < profile.points.length - 1; i++) { let start = profile.points[i]; - let end = profile.points[i+1]; - + let end = profile.points[i + 1]; + let startGround = new THREE.Vector3(start.x, start.y, 0); let endGround = new THREE.Vector3(end.x, end.y, 0); - + let center = new THREE.Vector3().addVectors(endGround, startGround).multiplyScalar(0.5); let length = startGround.distanceTo(endGround); let side = new THREE.Vector3().subVectors(endGround, startGround).normalize(); @@ -24,7 +21,7 @@ Potree.ProfileData = class ProfileData{ let N = forward; let cutPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(N, startGround); let halfPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(side, center); - + let segment = { start: start, end: end, @@ -33,26 +30,23 @@ Potree.ProfileData = class ProfileData{ length: length, points: new Potree.Points() }; - + this.segments.push(segment); } } - - size(){ - + + size () { let size = 0; - for(let segment of this.segments){ + for (let segment of this.segments) { size += segment.points.numPoints; } - + return size; } - }; -Potree.ProfileRequest = class ProfileRequest{ - - constructor(pointcloud, profile, maxDepth, callback){ +Potree.ProfileRequest = class ProfileRequest { + constructor (pointcloud, profile, maxDepth, callback) { this.pointcloud = pointcloud; this.profile = profile; this.maxDepth = maxDepth || Number.MAX_VALUE; @@ -61,214 +55,199 @@ Potree.ProfileRequest = class ProfileRequest{ this.pointsServed = 0; this.highestLevelServed = 0; - this.priorityQueue = new BinaryHeap(function(x){return 1 / x.weight;}); - + this.priorityQueue = new BinaryHeap(function (x) { return 1 / x.weight; }); + this.initialize(); } - initialize(){ + initialize () { this.priorityQueue.push({node: this.pointcloud.pcoGeometry.root, weight: 1}); this.traverse(this.pointcloud.pcoGeometry.root); }; - + // traverse the node and add intersecting descendants to queue - traverse(node){ - + traverse (node) { let stack = []; - for(let i = 0; i < 8; i++){ + for (let i = 0; i < 8; i++) { let child = node.children[i]; - if(child && this.pointcloud.nodeIntersectsProfile(child, this.profile)){ + if (child && this.pointcloud.nodeIntersectsProfile(child, this.profile)) { stack.push(child); } } - - while(stack.length > 0){ + + while (stack.length > 0) { let node = stack.pop(); let weight = node.boundingSphere.radius; - + this.priorityQueue.push({node: node, weight: weight}); - + // add children that intersect the cutting plane - if(node.level < this.maxDepth){ - for(let i = 0; i < 8; i++){ + if (node.level < this.maxDepth) { + for (let i = 0; i < 8; i++) { let child = node.children[i]; - if(child && this.pointcloud.nodeIntersectsProfile(child, this.profile)){ + if (child && this.pointcloud.nodeIntersectsProfile(child, this.profile)) { stack.push(child); } } } } } - - update(){ - + + update () { // load nodes in queue // if hierarchy expands, also load nodes from expanded hierarchy // once loaded, add data to this.points and remove node from queue // only evaluate 1-50 nodes per frame to maintain responsiveness - + let maxNodesPerUpdate = 1; let intersectedNodes = []; - - for(let i = 0; i < Math.min(maxNodesPerUpdate, this.priorityQueue.size()); i++){ + + for (let i = 0; i < Math.min(maxNodesPerUpdate, this.priorityQueue.size()); i++) { let element = this.priorityQueue.pop(); let node = element.node; - - - if(node.loaded){ + + if (node.loaded) { // add points to result intersectedNodes.push(node); Potree.getLRU().touch(node); this.highestLevelServed = node.getLevel(); - - if((node.level % node.pcoGeometry.hierarchyStepSize) === 0 && node.hasChildren){ + + if ((node.level % node.pcoGeometry.hierarchyStepSize) === 0 && node.hasChildren) { this.traverse(node); } - }else{ + } else { node.load(); this.priorityQueue.push(element); } } - - if(intersectedNodes.length > 0){ + + if (intersectedNodes.length > 0) { this.getPointsInsideProfile(intersectedNodes, this.temporaryResult); - if(this.temporaryResult.size() > 100){ + if (this.temporaryResult.size() > 100) { this.pointsServed += this.temporaryResult.size(); this.callback.onProgress({request: this, points: this.temporaryResult}); this.temporaryResult = new Potree.ProfileData(this.profile); } } - - if(this.priorityQueue.size() === 0){ + + if (this.priorityQueue.size() === 0) { // we're done! inform callback and remove from pending requests - if(this.temporaryResult.size() > 0){ + if (this.temporaryResult.size() > 0) { this.pointsServed += this.temporaryResult.size(); this.callback.onProgress({request: this, points: this.temporaryResult}); this.temporaryResult = new Potree.ProfileData(this.profile); } - + this.callback.onFinish({request: this}); - + let index = this.pointcloud.profileRequests.indexOf(this); - if(index >= 0){ + if (index >= 0) { this.pointcloud.profileRequests.splice(index, 1); } } }; - - getPointsInsideProfile(nodes, target){ - + + getPointsInsideProfile (nodes, target) { let totalMileage = 0; - - - for(let segment of target.segments){ - - for(let node of nodes){ + + for (let segment of target.segments) { + for (let node of nodes) { let geometry = node.geometry; let positions = geometry.attributes.position; let p = positions.array; let numPoints = node.numPoints; - + let sv = new THREE.Vector3().subVectors(segment.end, segment.start).setZ(0); let segmentDir = sv.clone().normalize(); - + let accepted = []; let mileage = []; let acceptedPositions = []; let points = new Potree.Points(); - + let nodeMatrix = new THREE.Matrix4().makeTranslation(...node.boundingBox.min.toArray()); - + let matrix = new THREE.Matrix4().multiplyMatrices( this.pointcloud.matrixWorld, nodeMatrix); - - for(let i = 0; i < numPoints; i++){ - let pos = new THREE.Vector3(p[3*i], p[3*i+1], p[3*i+2]); + + for (let i = 0; i < numPoints; i++) { + let pos = new THREE.Vector3(p[3 * i], p[3 * i + 1], p[3 * i + 2]); pos.applyMatrix4(matrix); let distance = Math.abs(segment.cutPlane.distanceToPoint(pos)); let centerDistance = Math.abs(segment.halfPlane.distanceToPoint(pos)); - - if(distance < this.profile.width / 2 && centerDistance < segment.length / 2){ - + + if (distance < this.profile.width / 2 && centerDistance < segment.length / 2) { let svp = new THREE.Vector3().subVectors(pos, segment.start); let localMileage = segmentDir.dot(svp); - + accepted.push(i); mileage.push(localMileage + totalMileage); points.boundingBox.expandByPoint(pos); - + acceptedPositions.push(pos.x); acceptedPositions.push(pos.y); acceptedPositions.push(pos.z); } } - - for(let attribute of Object.keys(geometry.attributes).filter(a => a !== "indices")) { + for (let attribute of Object.keys(geometry.attributes).filter(a => a !== 'indices')) { let bufferedAttribute = geometry.attributes[attribute]; - let type = bufferedAttribute.array.constructor; - + let Type = bufferedAttribute.array.constructor; + let filteredBuffer = null; - - if(attribute === "position"){ - filteredBuffer = new type(acceptedPositions); - }else{ - filteredBuffer = new type(accepted.length * bufferedAttribute.itemSize); - - for(let i = 0; i < accepted.length; i++){ + + if (attribute === 'position') { + filteredBuffer = new Type(acceptedPositions); + } else { + filteredBuffer = new Type(accepted.length * bufferedAttribute.itemSize); + + for (let i = 0; i < accepted.length; i++) { let index = accepted[i]; - + filteredBuffer.set( bufferedAttribute.array.subarray( - bufferedAttribute.itemSize * index, + bufferedAttribute.itemSize * index, bufferedAttribute.itemSize * index + bufferedAttribute.itemSize), - bufferedAttribute.itemSize * i) + bufferedAttribute.itemSize * i); } } points.data[attribute] = filteredBuffer; - - } - - points.data["mileage"] = new Float64Array(mileage); + + points.data['mileage'] = new Float64Array(mileage); points.numPoints = accepted.length; - + segment.points.add(points); - } - + totalMileage += segment.length; } - - for(let segment of target.segments){ + + for (let segment of target.segments) { target.boundingBox.union(segment.points.boundingBox); } - - - }; - - finishLevelThenCancel(){ - if(this.cancelRequested){ + + finishLevelThenCancel () { + if (this.cancelRequested) { return; } - + this.maxDepth = this.highestLevelServed + 1; this.cancelRequested = true; - + console.log(`maxDepth: ${this.maxDepth}`); }; - - cancel(){ + + cancel () { this.callback.onCancel(); - - this.priorityQueue = new BinaryHeap(function(x){return 1 / x.weight;}); - + + this.priorityQueue = new BinaryHeap(function (x) { return 1 / x.weight; }); + let index = this.pointcloud.profileRequests.indexOf(this); - if(index >= 0){ + if (index >= 0) { this.pointcloud.profileRequests.splice(index, 1); } }; - -}; \ No newline at end of file +}; diff --git a/src/TextSprite.js b/src/TextSprite.js index ab828302..2d09393b 100644 --- a/src/TextSprite.js +++ b/src/TextSprite.js @@ -2,131 +2,124 @@ * adapted from http://stemkoski.github.io/Three.js/Sprite-Text-Labels.html */ -Potree.TextSprite = function(text){ - +Potree.TextSprite = function (text) { THREE.Object3D.call(this); - - var scope = this; var texture = new THREE.Texture(); texture.minFilter = THREE.LinearFilter; texture.magFilter = THREE.LinearFilter; - var spriteMaterial = new THREE.SpriteMaterial( { - map: texture, - //useScreenCoordinates: false, + var spriteMaterial = new THREE.SpriteMaterial({ + map: texture, + // useScreenCoordinates: false, depthTest: false, - depthWrite: false} ); - + depthWrite: false}); + this.material = spriteMaterial; this.sprite = new THREE.Sprite(spriteMaterial); this.add(this.sprite); - - //THREE.Sprite.call(this, spriteMaterial); - + + // THREE.Sprite.call(this, spriteMaterial); + this.borderThickness = 4; - this.fontface = "Arial"; + this.fontface = 'Arial'; this.fontsize = 28; - this.borderColor = { r:0, g:0, b:0, a:1.0 }; - this.backgroundColor = { r:255, g:255, b:255, a:1.0 }; + this.borderColor = { r: 0, g: 0, b: 0, a: 1.0 }; + this.backgroundColor = { r: 255, g: 255, b: 255, a: 1.0 }; this.textColor = {r: 255, g: 255, b: 255, a: 1.0}; - this.text = ""; - + this.text = ''; + this.setText(text); }; Potree.TextSprite.prototype = new THREE.Object3D(); -Potree.TextSprite.prototype.setText = function(text){ - if(this.text !== text){ +Potree.TextSprite.prototype.setText = function (text) { + if (this.text !== text) { this.text = text; - + this.update(); } }; -Potree.TextSprite.prototype.setTextColor = function(color){ +Potree.TextSprite.prototype.setTextColor = function (color) { this.textColor = color; - + this.update(); }; -Potree.TextSprite.prototype.setBorderColor = function(color){ +Potree.TextSprite.prototype.setBorderColor = function (color) { this.borderColor = color; - + this.update(); }; -Potree.TextSprite.prototype.setBackgroundColor = function(color){ +Potree.TextSprite.prototype.setBackgroundColor = function (color) { this.backgroundColor = color; - + this.update(); }; -Potree.TextSprite.prototype.update = function(){ - +Potree.TextSprite.prototype.update = function () { var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); - context.font = "Bold " + this.fontsize + "px " + this.fontface; - + context.font = 'Bold ' + this.fontsize + 'px ' + this.fontface; + // get size data (height depends only on font size) - var metrics = context.measureText( this.text ); + var metrics = context.measureText(this.text); var textWidth = metrics.width; var margin = 5; - var spriteWidth = 2*margin + textWidth + 2 * this.borderThickness; + var spriteWidth = 2 * margin + textWidth + 2 * this.borderThickness; var spriteHeight = this.fontsize * 1.4 + 2 * this.borderThickness; - - var canvas = document.createElement('canvas'); - var context = canvas.getContext('2d'); + context.canvas.width = spriteWidth; context.canvas.height = spriteHeight; - context.font = "Bold " + this.fontsize + "px " + this.fontface; - + context.font = 'Bold ' + this.fontsize + 'px ' + this.fontface; + // background color - context.fillStyle = "rgba(" + this.backgroundColor.r + "," + this.backgroundColor.g + "," - + this.backgroundColor.b + "," + this.backgroundColor.a + ")"; + context.fillStyle = 'rgba(' + this.backgroundColor.r + ',' + this.backgroundColor.g + ',' + + this.backgroundColor.b + ',' + this.backgroundColor.a + ')'; // border color - context.strokeStyle = "rgba(" + this.borderColor.r + "," + this.borderColor.g + "," - + this.borderColor.b + "," + this.borderColor.a + ")"; - + context.strokeStyle = 'rgba(' + this.borderColor.r + ',' + this.borderColor.g + ',' + + this.borderColor.b + ',' + this.borderColor.a + ')'; + context.lineWidth = this.borderThickness; - this.roundRect(context, this.borderThickness/2, this.borderThickness/2, - textWidth + this.borderThickness + 2*margin, this.fontsize * 1.4 + this.borderThickness, 6); - + this.roundRect(context, this.borderThickness / 2, this.borderThickness / 2, + textWidth + this.borderThickness + 2 * margin, this.fontsize * 1.4 + this.borderThickness, 6); + // text color - context.strokeStyle = "rgba(0, 0, 0, 1.0)"; - context.strokeText( this.text, this.borderThickness + margin, this.fontsize + this.borderThickness); - - context.fillStyle = "rgba(" + this.textColor.r + "," + this.textColor.g + "," - + this.textColor.b + "," + this.textColor.a + ")"; - context.fillText( this.text, this.borderThickness + margin, this.fontsize + this.borderThickness); - - - var texture = new THREE.Texture(canvas); + context.strokeStyle = 'rgba(0, 0, 0, 1.0)'; + context.strokeText(this.text, this.borderThickness + margin, this.fontsize + this.borderThickness); + + context.fillStyle = 'rgba(' + this.textColor.r + ',' + this.textColor.g + ',' + + this.textColor.b + ',' + this.textColor.a + ')'; + context.fillText(this.text, this.borderThickness + margin, this.fontsize + this.borderThickness); + + var texture = new THREE.Texture(canvas); texture.minFilter = THREE.LinearFilter; texture.magFilter = THREE.LinearFilter; - texture.needsUpdate = true; - - //var spriteMaterial = new THREE.SpriteMaterial( + texture.needsUpdate = true; + + // var spriteMaterial = new THREE.SpriteMaterial( // { map: texture, useScreenCoordinates: false } ); this.sprite.material.map = texture; - - this.sprite.scale.set(spriteWidth*0.01,spriteHeight*0.01,1.0); - - //this.material = spriteMaterial; + + this.sprite.scale.set(spriteWidth * 0.01, spriteHeight * 0.01, 1.0); + + // this.material = spriteMaterial; }; -Potree.TextSprite.prototype.roundRect = function(ctx, x, y, w, h, r) { +Potree.TextSprite.prototype.roundRect = function (ctx, x, y, w, h, r) { ctx.beginPath(); - ctx.moveTo(x+r, y); - ctx.lineTo(x+w-r, y); - ctx.quadraticCurveTo(x+w, y, x+w, y+r); - ctx.lineTo(x+w, y+h-r); - ctx.quadraticCurveTo(x+w, y+h, x+w-r, y+h); - ctx.lineTo(x+r, y+h); - ctx.quadraticCurveTo(x, y+h, x, y+h-r); - ctx.lineTo(x, y+r); - ctx.quadraticCurveTo(x, y, x+r, y); + ctx.moveTo(x + r, y); + ctx.lineTo(x + w - r, y); + ctx.quadraticCurveTo(x + w, y, x + w, y + r); + ctx.lineTo(x + w, y + h - r); + ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h); + ctx.lineTo(x + r, y + h); + ctx.quadraticCurveTo(x, y + h, x, y + h - r); + ctx.lineTo(x, y + r); + ctx.quadraticCurveTo(x, y, x + r, y); ctx.closePath(); ctx.fill(); - ctx.stroke(); -}; \ No newline at end of file + ctx.stroke(); +}; diff --git a/src/Version.js b/src/Version.js index 4fb42efb..12537d40 100644 --- a/src/Version.js +++ b/src/Version.js @@ -1,39 +1,38 @@ -Potree.Version = function(version){ +Potree.Version = function (version) { this.version = version; - var vmLength = (version.indexOf(".") === -1) ? version.length : version.indexOf("."); + var vmLength = (version.indexOf('.') === -1) ? version.length : version.indexOf('.'); this.versionMajor = parseInt(version.substr(0, vmLength)); this.versionMinor = parseInt(version.substr(vmLength + 1)); - if(this.versionMinor.length === 0){ + if (this.versionMinor.length === 0) { this.versionMinor = 0; } - }; -Potree.Version.prototype.newerThan = function(version){ +Potree.Version.prototype.newerThan = function (version) { var v = new Potree.Version(version); - - if( this.versionMajor > v.versionMajor){ + + if (this.versionMajor > v.versionMajor) { return true; - }else if( this.versionMajor === v.versionMajor && this.versionMinor > v.versionMinor){ + } else if (this.versionMajor === v.versionMajor && this.versionMinor > v.versionMinor) { return true; - }else{ + } else { return false; } }; -Potree.Version.prototype.equalOrHigher = function(version){ +Potree.Version.prototype.equalOrHigher = function (version) { var v = new Potree.Version(version); - - if( this.versionMajor > v.versionMajor){ + + if (this.versionMajor > v.versionMajor) { return true; - }else if( this.versionMajor === v.versionMajor && this.versionMinor >= v.versionMinor){ + } else if (this.versionMajor === v.versionMajor && this.versionMinor >= v.versionMinor) { return true; - }else{ + } else { return false; } }; -Potree.Version.prototype.upTo = function(version){ +Potree.Version.prototype.upTo = function (version) { return !this.newerThan(version); -}; \ No newline at end of file +}; diff --git a/src/WorkerPool.js b/src/WorkerPool.js index 0058935f..8615f870 100644 --- a/src/WorkerPool.js +++ b/src/WorkerPool.js @@ -1,32 +1,27 @@ -Potree.WorkerPool = class WorkerPool{ - - constructor(){ +Potree.WorkerPool = class WorkerPool { + constructor () { this.workers = {}; } - - getWorker(url){ - - if(!this.workers[url]){ + + getWorker (url) { + if (!this.workers[url]) { this.workers[url] = []; } - if(this.workers[url].length === 0){ + if (this.workers[url].length === 0) { let worker = new Worker(url); this.workers[url].push(worker); } - + let worker = this.workers[url].pop(); - + return worker; } - - returnWorker(url, worker){ + + returnWorker (url, worker) { this.workers[url].push(worker); } - }; Potree.workerPool = new Potree.WorkerPool(); - - diff --git a/src/arena4d/PointCloudArena4D.js b/src/arena4d/PointCloudArena4D.js index 8744f1cb..39170213 100644 --- a/src/arena4d/PointCloudArena4D.js +++ b/src/arena4d/PointCloudArena4D.js @@ -1,60 +1,59 @@ -Potree.PointCloudArena4DNode = class PointCloudArena4DNode extends Potree.PointCloudTreeNode{ - - constructor(){ - super(); - +Potree.PointCloudArena4DNode = class PointCloudArena4DNode extends Potree.PointCloudTreeNode { + constructor () { + super(); + this.left = null; this.right = null; this.sceneNode = null; this.kdtree = null; } - - getNumPoints(){ + + getNumPoints () { return this.geometryNode.numPoints; } - - isLoaded(){ + + isLoaded () { return true; } - - isTreeNode(){ + + isTreeNode () { return true; } - - isGeometryNode(){ + + isGeometryNode () { return false; } - - getLevel(){ + + getLevel () { return this.geometryNode.level; } - - getBoundingSphere(){ + + getBoundingSphere () { return this.geometryNode.boundingSphere; } - - getBoundingBox(){ + + getBoundingBox () { return this.geometryNode.boundingBox; } - - toTreeNode(child){ + + toTreeNode (child) { var geometryNode = null; - - if(this.left === child){ + + if (this.left === child) { geometryNode = this.left; - }else if(this.right === child){ + } else if (this.right === child) { geometryNode = this.right; } - - if(!geometryNode.loaded){ + + if (!geometryNode.loaded) { return; } - + var node = new Potree.PointCloudArena4DNode(); var sceneNode = THREE.PointCloud(geometryNode.geometry, this.kdtree.material); sceneNode.visible = false; - + node.kdtree = this.kdtree; node.geometryNode = geometryNode; node.sceneNode = sceneNode; @@ -62,53 +61,50 @@ Potree.PointCloudArena4DNode = class PointCloudArena4DNode extends Potree.PointC node.left = this.geometryNode.left; node.right = this.geometryNode.right; } - - getChildren(){ + + getChildren () { var children = []; - - if(this.left){ + + if (this.left) { children.push(this.left); - } - - if(this.right){ + } + + if (this.right) { children.push(this.right); } - + return children; } }; Potree.PointCloudOctreeNode.prototype = Object.create(Potree.PointCloudTreeNode.prototype); +Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree { + constructor (geometry) { + super(); - -Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree{ - - constructor(geometry){ - super() - this.root = null; - if(geometry.root){ + if (geometry.root) { this.root = geometry.root; - }else{ - geometry.addEventListener("hierarchy_loaded", () => { + } else { + geometry.addEventListener('hierarchy_loaded', () => { this.root = geometry.root; }); } - - this.visiblePointsTarget = 2*1000*1000; + + this.visiblePointsTarget = 2 * 1000 * 1000; this.minimumNodePixelSize = 150; - + this.position.sub(geometry.offset); this.updateMatrix(); - + this.numVisibleNodes = 0; this.numVisiblePoints = 0; - + this.boundingBoxNodes = []; this.loadQueue = []; this.visibleNodes = []; - + this.pcoGeometry = geometry; this.boundingBox = this.pcoGeometry.boundingBox; this.boundingSphere = this.pcoGeometry.boundingSphere; @@ -116,264 +112,254 @@ Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree this.material.sizeType = Potree.PointSizeType.ATTENUATED; this.material.size = 0.05; this.profileRequests = []; - this.name = ""; + this.name = ''; } - - setName(name){ - if(this.name !== name){ + + setName (name) { + if (this.name !== name) { this.name = name; - this.dispatchEvent({type: "name_changed", name: name, pointcloud: this}); + this.dispatchEvent({type: 'name_changed', name: name, pointcloud: this}); } } - - getName(){ + + getName () { return this.name; } - - getLevel(){ + + getLevel () { return this.level; } - - toTreeNode(geometryNode, parent){ + + toTreeNode (geometryNode, parent) { var node = new Potree.PointCloudArena4DNode(); var sceneNode = new THREE.Points(geometryNode.geometry, this.material); - + sceneNode.frustumCulled = false; sceneNode.onBeforeRender = (_this, scene, camera, geometry, material, group) => { - - if(material.program){ + if (material.program) { _this.getContext().useProgram(material.program.program); - - if(material.program.getUniforms().map.level){ + + if (material.program.getUniforms().map.level) { let level = geometryNode.getLevel(); material.uniforms.level.value = level; material.program.getUniforms().map.level.setValue(_this.getContext(), level); } - - if(this.visibleNodeTextureOffsets && material.program.getUniforms().map.vnStart){ + + if (this.visibleNodeTextureOffsets && material.program.getUniforms().map.vnStart) { let vnStart = this.visibleNodeTextureOffsets.get(node); material.uniforms.vnStart.value = vnStart; material.program.getUniforms().map.vnStart.setValue(_this.getContext(), vnStart); } - - if(material.program.getUniforms().map.pcIndex){ + + if (material.program.getUniforms().map.pcIndex) { let i = node.pcIndex ? node.pcIndex : this.visibleNodes.indexOf(node); material.uniforms.pcIndex.value = i; material.program.getUniforms().map.pcIndex.setValue(_this.getContext(), i); } } }; - + node.geometryNode = geometryNode; node.sceneNode = sceneNode; node.pointcloud = this; node.left = geometryNode.left; node.right = geometryNode.right; - - if(!parent){ + + if (!parent) { this.root = node; this.add(sceneNode); - }else{ + } else { parent.sceneNode.add(sceneNode); - - if(parent.left === geometryNode){ + + if (parent.left === geometryNode) { parent.left = node; - }else if(parent.right === geometryNode){ + } else if (parent.right === geometryNode) { parent.right = node; } } - - var disposeListener = function(){ + + var disposeListener = function () { parent.sceneNode.remove(node.sceneNode); - - if(parent.left === node){ + + if (parent.left === node) { parent.left = geometryNode; - }else if(parent.right === node){ + } else if (parent.right === node) { parent.right = geometryNode; } - } + }; geometryNode.oneTimeDisposeHandlers.push(disposeListener); - + return node; } - - updateMaterial(material, visibleNodes, camera, renderer){ + + updateMaterial (material, visibleNodes, camera, renderer) { material.fov = camera.fov * (Math.PI / 180); material.screenWidth = renderer.domElement.clientWidth; material.screenHeight = renderer.domElement.clientHeight; material.spacing = this.pcoGeometry.spacing; material.near = camera.near; material.far = camera.far; - + // reduce shader source updates by setting maxLevel slightly higher than actually necessary - if(this.maxLevel > material.levels){ + if (this.maxLevel > material.levels) { material.levels = this.maxLevel + 2; } - - //material.minSize = 3; - - //material.uniforms.octreeSize.value = this.boundingBox.size().x; + + // material.minSize = 3; + + // material.uniforms.octreeSize.value = this.boundingBox.size().x; var bbSize = this.boundingBox.getSize(); material.bbSize = [bbSize.x, bbSize.y, bbSize.z]; - + // update visibility texture - if(material.pointSizeType){ - if(material.pointSizeType === Potree.PointSizeType.ADAPTIVE - || material.pointColorType === Potree.PointColorType.LOD){ - + if (material.pointSizeType) { + if (material.pointSizeType === Potree.PointSizeType.ADAPTIVE || + material.pointColorType === Potree.PointColorType.LOD) { this.updateVisibilityTexture(material, visibleNodes); } } } - - updateVisibleBounds(){ - + + updateVisibleBounds () { + } - - hideDescendants(object){ + + hideDescendants (object) { var stack = []; - for(var i = 0; i < object.children.length; i++){ - var child = object.children[i]; - if(child.visible){ + for (let i = 0; i < object.children.length; i++) { + let child = object.children[i]; + if (child.visible) { stack.push(child); } } - - while(stack.length > 0){ - var object = stack.shift(); - - object.visible = false; - if(object.boundingBoxNode){ - object.boundingBoxNode.visible = false; + + while (stack.length > 0) { + let child = stack.shift(); + + child.visible = false; + if (child.boundingBoxNode) { + child.boundingBoxNode.visible = false; } - - for(var i = 0; i < object.children.length; i++){ - var child = object.children[i]; - if(child.visible){ - stack.push(child); + + for (let i = 0; i < child.children.length; i++) { + let childOfChild = child.children[i]; + if (childOfChild.visible) { + stack.push(childOfChild); } } } } - - updateMatrixWorld( force ){ - //node.matrixWorld.multiplyMatrices( node.parent.matrixWorld, node.matrix ); - - if ( this.matrixAutoUpdate === true ) this.updateMatrix(); - if ( this.matrixWorldNeedsUpdate === true || force === true ) { + updateMatrixWorld (force) { + // node.matrixWorld.multiplyMatrices( node.parent.matrixWorld, node.matrix ); - if ( this.parent === undefined ) { - - this.matrixWorld.copy( this.matrix ); + if (this.matrixAutoUpdate === true) this.updateMatrix(); + if (this.matrixWorldNeedsUpdate === true || force === true) { + if (this.parent === undefined) { + this.matrixWorld.copy(this.matrix); } else { - - this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); - + this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix); } this.matrixWorldNeedsUpdate = false; force = true; - } } - - nodesOnRay(nodes, ray){ + + nodesOnRay (nodes, ray) { var nodesOnRay = []; var _ray = ray.clone(); - for(var i = 0; i < nodes.length; i++){ + for (var i = 0; i < nodes.length; i++) { var node = nodes[i]; var sphere = node.getBoundingSphere().clone().applyMatrix4(node.sceneNode.matrixWorld); - var box = node.getBoundingBox().clone().applyMatrix4(node.sceneNode.matrixWorld); - - if(_ray.intersectsSphere(sphere)){ + // TODO Unused: var box = node.getBoundingBox().clone().applyMatrix4(node.sceneNode.matrixWorld); + + if (_ray.intersectsSphere(sphere)) { nodesOnRay.push(node); } - //if(_ray.isIntersectionBox(box)){ + // if(_ray.isIntersectionBox(box)){ // nodesOnRay.push(node); - //} + // } } - + return nodesOnRay; } - - pick(renderer, camera, ray, params = {}){ - - //let start = new Date().getTime(); - + + pick (renderer, camera, ray, params = {}) { + // let start = new Date().getTime(); + let pickWindowSize = params.pickWindowSize || 17; let pickOutsideClipRegion = params.pickOutsideClipRegion || false; let width = Math.ceil(renderer.domElement.clientWidth); let height = Math.ceil(renderer.domElement.clientHeight); - + let nodes = this.nodesOnRay(this.visibleNodes, ray); - - if(nodes.length === 0){ + + if (nodes.length === 0) { return null; } - - if(!this.pickState){ - + + if (!this.pickState) { let scene = new THREE.Scene(); - + let material = new Potree.PointCloudMaterial(); - material.pointColorType = Potree.PointColorType.POINT_INDEX; - - let renderTarget = new THREE.WebGLRenderTarget( - 1, 1, - { minFilter: THREE.LinearFilter, - magFilter: THREE.NearestFilter, - format: THREE.RGBAFormat } + material.pointColorType = Potree.PointColorType.POINT_INDEX; + + let renderTarget = new THREE.WebGLRenderTarget( + 1, 1, + { minFilter: THREE.LinearFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat } ); - + this.pickState = { renderTarget: renderTarget, material: material, scene: scene }; }; - + let pickState = this.pickState; let pickMaterial = pickState.material; - + { // update pick material pickMaterial.pointSizeType = this.material.pointSizeType; pickMaterial.shape = this.material.shape; - + pickMaterial.size = this.material.size; pickMaterial.minSize = this.material.minSize; pickMaterial.maxSize = this.material.maxSize; pickMaterial.classification = this.material.classification; - - if(pickOutsideClipRegion){ + + if (pickOutsideClipRegion) { pickMaterial.clipMode = Potree.ClipMode.DISABLED; - }else{ + } else { pickMaterial.clipMode = this.material.clipMode; - if(this.material.clipMode === Potree.ClipMode.CLIP_OUTSIDE){ + if (this.material.clipMode === Potree.ClipMode.CLIP_OUTSIDE) { pickMaterial.setClipBoxes(this.material.clipBoxes); - }else{ + } else { pickMaterial.setClipBoxes([]); } } - + this.updateMaterial(pickMaterial, nodes, camera, renderer); } - - if(pickState.renderTarget.width != width || pickState.renderTarget.height != height){ + + if (pickState.renderTarget.width !== width || pickState.renderTarget.height !== height) { pickState.renderTarget.dispose(); - pickState.renderTarget = new THREE.WebGLRenderTarget( - 1, 1, - { minFilter: THREE.LinearFilter, - magFilter: THREE.NearestFilter, - format: THREE.RGBAFormat } + pickState.renderTarget = new THREE.WebGLRenderTarget( + 1, 1, + { minFilter: THREE.LinearFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat } ); } pickState.renderTarget.setSize(width, height); - renderer.setRenderTarget( pickState.renderTarget ); - + renderer.setRenderTarget(pickState.renderTarget); + let pixelPos = new THREE.Vector3() .addVectors(camera.position, ray.direction) .project(camera) @@ -381,194 +367,190 @@ Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree .multiplyScalar(0.5); pixelPos.x *= width; pixelPos.y *= height; - + renderer.setScissor( - parseInt(pixelPos.x - (pickWindowSize - 1) / 2), + parseInt(pixelPos.x - (pickWindowSize - 1) / 2), parseInt(pixelPos.y - (pickWindowSize - 1) / 2), parseInt(pickWindowSize), parseInt(pickWindowSize)); renderer.setScissorTest(true); - + renderer.state.buffers.depth.setTest(pickMaterial.depthTest); renderer.state.buffers.depth.setMask(pickMaterial.depthWrite); renderer.state.setBlending(THREE.NoBlending); - - renderer.clearTarget( pickState.renderTarget, true, true, true ); - - //pickState.scene.children = nodes.map(n => n.sceneNode); - - //let childStates = []; + + renderer.clearTarget(pickState.renderTarget, true, true, true); + + // pickState.scene.children = nodes.map(n => n.sceneNode); + + // let childStates = []; let tempNodes = []; - for(let i = 0; i < nodes.length; i++){ + for (let i = 0; i < nodes.length; i++) { let node = nodes[i]; - node.pcIndex = i+1; + node.pcIndex = i + 1; let sceneNode = node.sceneNode; - + let tempNode = new THREE.Points(sceneNode.geometry, pickMaterial); tempNode.matrix = sceneNode.matrix; tempNode.matrixWorld = sceneNode.matrixWorld; tempNode.matrixAutoUpdate = false; tempNode.frustumCulled = false; - tempNode.pcIndex = i+1; - + tempNode.pcIndex = i + 1; + let geometryNode = node.geometryNode; - let material = pickMaterial; + // TODO Unused: let material = pickMaterial; tempNode.onBeforeRender = (_this, scene, camera, geometry, material, group) => { - - if(material.program){ + if (material.program) { _this.getContext().useProgram(material.program.program); - - if(material.program.getUniforms().map.level){ + + if (material.program.getUniforms().map.level) { let level = geometryNode.getLevel(); material.uniforms.level.value = level; material.program.getUniforms().map.level.setValue(_this.getContext(), level); } - - if(this.visibleNodeTextureOffsets && material.program.getUniforms().map.vnStart){ + + if (this.visibleNodeTextureOffsets && material.program.getUniforms().map.vnStart) { let vnStart = this.visibleNodeTextureOffsets.get(node); material.uniforms.vnStart.value = vnStart; material.program.getUniforms().map.vnStart.setValue(_this.getContext(), vnStart); } - - if(material.program.getUniforms().map.pcIndex){ + + if (material.program.getUniforms().map.pcIndex) { material.uniforms.pcIndex.value = node.pcIndex; material.program.getUniforms().map.pcIndex.setValue(_this.getContext(), node.pcIndex); } } - }; tempNodes.push(tempNode); - - //for(let child of nodes[i].sceneNode.children){ + + // for(let child of nodes[i].sceneNode.children){ // childStates.push({child: child, visible: child.visible}); // child.visible = false; - //} + // } } pickState.scene.autoUpdate = false; pickState.scene.children = tempNodes; - //pickState.scene.overrideMaterial = pickMaterial; - + // pickState.scene.overrideMaterial = pickMaterial; + renderer.state.setBlending(THREE.NoBlending); - + // RENDER renderer.render(pickState.scene, camera, pickState.renderTarget); - - //for(let childState of childStates){ + + // for(let childState of childStates){ // childState.child = childState.visible; - //} - - //pickState.scene.overrideMaterial = null; - - //renderer.context.readPixels( - // pixelPos.x - (pickWindowSize-1) / 2, pixelPos.y - (pickWindowSize-1) / 2, - // pickWindowSize, pickWindowSize, + // } + + // pickState.scene.overrideMaterial = null; + + // renderer.context.readPixels( + // pixelPos.x - (pickWindowSize-1) / 2, pixelPos.y - (pickWindowSize-1) / 2, + // pickWindowSize, pickWindowSize, // renderer.context.RGBA, renderer.context.UNSIGNED_BYTE, pixels); - + let clamp = (number, min, max) => Math.min(Math.max(min, number), max); - - let x = parseInt(clamp(pixelPos.x - (pickWindowSize-1) / 2, 0, width)); - let y = parseInt(clamp(pixelPos.y - (pickWindowSize-1) / 2, 0, height)); + + let x = parseInt(clamp(pixelPos.x - (pickWindowSize - 1) / 2, 0, width)); + let y = parseInt(clamp(pixelPos.y - (pickWindowSize - 1) / 2, 0, height)); let w = parseInt(Math.min(x + pickWindowSize, width) - x); let h = parseInt(Math.min(y + pickWindowSize, height) - y); - + let pixelCount = w * h; let buffer = new Uint8Array(4 * pixelCount); - renderer.readRenderTargetPixels(pickState.renderTarget, - x, y, w, h, + renderer.readRenderTargetPixels(pickState.renderTarget, + x, y, w, h, buffer); - + renderer.setScissorTest(false); - + renderer.setRenderTarget(null); - + let pixels = buffer; let ibuffer = new Uint32Array(buffer.buffer); - + // find closest hit inside pixelWindow boundaries let min = Number.MAX_VALUE; let hit = null; - for(let u = 0; u < pickWindowSize; u++){ - for(let v = 0; v < pickWindowSize; v++){ - let offset = (u + v*pickWindowSize); - let distance = Math.pow(u - (pickWindowSize-1) / 2, 2) + Math.pow(v - (pickWindowSize-1) / 2, 2); - - let pcIndex = pixels[4*offset + 3]; - pixels[4*offset + 3] = 0; + for (let u = 0; u < pickWindowSize; u++) { + for (let v = 0; v < pickWindowSize; v++) { + let offset = (u + v * pickWindowSize); + let distance = Math.pow(u - (pickWindowSize - 1) / 2, 2) + Math.pow(v - (pickWindowSize - 1) / 2, 2); + + let pcIndex = pixels[4 * offset + 3]; + pixels[4 * offset + 3] = 0; let pIndex = ibuffer[offset]; - - //if((pIndex !== 0 || pcIndex !== 0) && distance < min){ - if(pcIndex > 0 && distance < min){ - - + + // if((pIndex !== 0 || pcIndex !== 0) && distance < min){ + if (pcIndex > 0 && distance < min) { hit = { pIndex: pIndex, pcIndex: pcIndex - 1 }; min = distance; - - //console.log(hit); + + // console.log(hit); } } } - //console.log(pixels); - - //{ // open window with image + // console.log(pixels); + + // { // open window with image // let img = Potree.utils.pixelsArrayToImage(buffer, w, h); // let screenshot = img.src; - // + // // if(!this.debugDIV){ // this.debugDIV = $(` - //
`); // $(document.body).append(this.debugDIV); // } - // + // // this.debugDIV.empty(); // this.debugDIV.append($(``)); // //$(this.debugWindow.document).append($(``)); // //this.debugWindow.document.write(''); - //} - - //return; - + // } + + // return; + let point = null; - - if(hit){ + + if (hit) { point = {}; - - if(!nodes[hit.pcIndex]){ + + if (!nodes[hit.pcIndex]) { return null; } - + let pc = nodes[hit.pcIndex].sceneNode; let attributes = pc.geometry.attributes; - - for(let property in attributes) { + + for (let property in attributes) { if (attributes.hasOwnProperty(property)) { let values = pc.geometry.attributes[property]; - - if(property === "position"){ + + if (property === 'position') { let positionArray = values.array; - let x = positionArray[3*hit.pIndex+0]; - let y = positionArray[3*hit.pIndex+1]; - let z = positionArray[3*hit.pIndex+2]; + let x = positionArray[3 * hit.pIndex + 0]; + let y = positionArray[3 * hit.pIndex + 1]; + let z = positionArray[3 * hit.pIndex + 2]; let position = new THREE.Vector3(x, y, z); position.applyMatrix4(pc.matrixWorld); - + point[property] = position; - }else if(property === "indices"){ - - }else{ - if(values.itemSize === 1){ + } else if (property === 'indices') { + + } else { + if (values.itemSize === 1) { point[property] = values.array[hit.pIndex]; - }else{ + } else { let value = []; - for(let j = 0; j < values.itemSize; j++){ - value.push(values.array[values.itemSize*hit.pIndex + j]); + for (let j = 0; j < values.itemSize; j++) { + value.push(values.array[values.itemSize * hit.pIndex + j]); } point[property] = value; } @@ -576,86 +558,81 @@ Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree } } } - - //let end = new Date().getTime(); - //let duration = end - start; - //console.log(`pick duration: ${duration}ms`); - - return point; - - - } - - updateVisibilityTexture(material, visibleNodes){ - if(!material){ + // let end = new Date().getTime(); + // let duration = end - start; + // console.log(`pick duration: ${duration}ms`); + + return point; + } + + updateVisibilityTexture (material, visibleNodes) { + if (!material) { return; } - + var texture = material.visibleNodesTexture; var data = texture.image.data; - + // copy array visibleNodes = visibleNodes.slice(); - + // sort by level and number - var sort = function(a, b){ + var sort = function (a, b) { var la = a.geometryNode.level; var lb = b.geometryNode.level; var na = a.geometryNode.number; var nb = b.geometryNode.number; - if(la != lb) return la - lb; - if(na < nb) return -1; - if(na > nb) return 1; + if (la !== lb) return la - lb; + if (na < nb) return -1; + if (na > nb) return 1; return 0; }; visibleNodes.sort(sort); - + var visibleNodeNames = []; - for(var i = 0; i < visibleNodes.length; i++){ - //visibleNodeNames[visibleNodes[i].pcoGeometry.number] = true; + for (let i = 0; i < visibleNodes.length; i++) { + // visibleNodeNames[visibleNodes[i].pcoGeometry.number] = true; visibleNodeNames.push(visibleNodes[i].geometryNode.number); } - - for(var i = 0; i < visibleNodes.length; i++){ + + for (let i = 0; i < visibleNodes.length; i++) { var node = visibleNodes[i]; - + var b1 = 0; // children var b2 = 0; // offset to first child - var b3 = 0; // split - - if(node.geometryNode.left && visibleNodeNames.indexOf(node.geometryNode.left.number) > 0){ + var b3 = 0; // split + + if (node.geometryNode.left && visibleNodeNames.indexOf(node.geometryNode.left.number) > 0) { b1 += 1; b2 = visibleNodeNames.indexOf(node.geometryNode.left.number) - i; } - if(node.geometryNode.right && visibleNodeNames.indexOf(node.geometryNode.right.number) > 0){ + if (node.geometryNode.right && visibleNodeNames.indexOf(node.geometryNode.right.number) > 0) { b1 += 2; b2 = (b2 === 0) ? visibleNodeNames.indexOf(node.geometryNode.right.number) - i : b2; } - - if(node.geometryNode.split === "X"){ + + if (node.geometryNode.split === 'X') { b3 = 1; - }else if(node.geometryNode.split === "Y"){ + } else if (node.geometryNode.split === 'Y') { b3 = 2; - }else if(node.geometryNode.split === "Z"){ + } else if (node.geometryNode.split === 'Z') { b3 = 4; } - - - data[i*3+0] = b1; - data[i*3+1] = b2; - data[i*3+2] = b3; + + data[i * 3 + 0] = b1; + data[i * 3 + 1] = b2; + data[i * 3 + 2] = b3; } - - + texture.needsUpdate = true; } - - get progress(){ - if(this.pcoGeometry.root){ + + get progress () { + if (this.pcoGeometry.root) { return Potree.PointCloudArena4DGeometryNode.nodesLoading > 0 ? 0 : 1; - }else{ + } else { return 0; } } -} +}; diff --git a/src/arena4d/PointCloudArena4DGeometry.js b/src/arena4d/PointCloudArena4DGeometry.js index 37bc769c..73ec2f53 100644 --- a/src/arena4d/PointCloudArena4DGeometry.js +++ b/src/arena4d/PointCloudArena4DGeometry.js @@ -1,8 +1,5 @@ - -Potree.PointCloudArena4DGeometryNode = function(){ - var scope = this; - +Potree.PointCloudArena4DGeometryNode = function () { this.left = null; this.right = null; this.boundingBox = null; @@ -17,135 +14,133 @@ Potree.PointCloudArena4DGeometryNode = function(){ Potree.PointCloudArena4DGeometryNode.nodesLoading = 0; -Potree.PointCloudArena4DGeometryNode.prototype.isGeometryNode = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.isGeometryNode = function () { return true; }; -Potree.PointCloudArena4DGeometryNode.prototype.isTreeNode = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.isTreeNode = function () { return false; }; -Potree.PointCloudArena4DGeometryNode.prototype.isLoaded = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.isLoaded = function () { return this.loaded; }; -Potree.PointCloudArena4DGeometryNode.prototype.getBoundingSphere = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.getBoundingSphere = function () { return this.boundingSphere; }; -Potree.PointCloudArena4DGeometryNode.prototype.getBoundingBox = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.getBoundingBox = function () { return this.boundingBox; }; -Potree.PointCloudArena4DGeometryNode.prototype.getChildren = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.getChildren = function () { var children = []; - - if(this.left){ + + if (this.left) { children.push(this.left); - } - - if(this.right){ + } + + if (this.right) { children.push(this.right); } - + return children; }; -Potree.PointCloudArena4DGeometryNode.prototype.getBoundingBox = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.getBoundingBox = function () { return this.boundingBox; }; -Potree.PointCloudArena4DGeometryNode.prototype.getLevel = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.getLevel = function () { return this.level; }; -Potree.PointCloudArena4DGeometryNode.prototype.load = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.load = function () { + if (this.loaded || this.loading) { + return; + } - if(this.loaded || this.loading){ + if (Potree.PointCloudArena4DGeometryNode.nodesLoading >= 5) { return; } - - if(Potree.PointCloudArena4DGeometryNode.nodesLoading >= 5){ - return; - } - + this.loading = true; - + Potree.PointCloudArena4DGeometryNode.nodesLoading++; - - var url = this.pcoGeometry.url + "?node=" + this.number; + + var url = this.pcoGeometry.url + '?node=' + this.number; var xhr = new XMLHttpRequest(); - xhr.open("GET", url, true); - xhr.responseType = "arraybuffer"; - + xhr.open('GET', url, true); + xhr.responseType = 'arraybuffer'; + var scope = this; - - xhr.onreadystatechange = function(){ - if(!(xhr.readyState === 4 && xhr.status === 200)){ + + xhr.onreadystatechange = function () { + if (!(xhr.readyState === 4 && xhr.status === 200)) { return; } - + var buffer = xhr.response; var view = new DataView(buffer); var numPoints = buffer.byteLength / 17; - - var positions = new Float32Array(numPoints*3); - var colors = new Uint8Array(numPoints*3); - var indices = new ArrayBuffer(numPoints*4); + + var positions = new Float32Array(numPoints * 3); + var colors = new Uint8Array(numPoints * 3); + var indices = new ArrayBuffer(numPoints * 4); var iIndices = new Uint32Array(indices); - - for(var i = 0; i < numPoints; i++){ - var x = view.getFloat32(i*17 + 0, true) + scope.boundingBox.min.x; - var y = view.getFloat32(i*17 + 4, true) + scope.boundingBox.min.y; - var z = view.getFloat32(i*17 + 8, true) + scope.boundingBox.min.z; - var r = view.getUint8(i*17 + 12, true); - var g = view.getUint8(i*17 + 13, true); - var b = view.getUint8(i*17 + 14, true); - - positions[i*3+0] = x; - positions[i*3+1] = y; - positions[i*3+2] = z; - - colors[i*3+0] = r; - colors[i*3+1] = g; - colors[i*3+2] = b; - + + for (var i = 0; i < numPoints; i++) { + var x = view.getFloat32(i * 17 + 0, true) + scope.boundingBox.min.x; + var y = view.getFloat32(i * 17 + 4, true) + scope.boundingBox.min.y; + var z = view.getFloat32(i * 17 + 8, true) + scope.boundingBox.min.z; + var r = view.getUint8(i * 17 + 12, true); + var g = view.getUint8(i * 17 + 13, true); + var b = view.getUint8(i * 17 + 14, true); + + positions[i * 3 + 0] = x; + positions[i * 3 + 1] = y; + positions[i * 3 + 2] = z; + + colors[i * 3 + 0] = r; + colors[i * 3 + 1] = g; + colors[i * 3 + 2] = b; + iIndices[i] = i; } - - + var geometry = new THREE.BufferGeometry(); - geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); - geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3, true)); - geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3)); - + geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3)); + geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true)); + geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(numPoints * 3), 3)); + let indicesAttribute = new THREE.Uint8BufferAttribute(indices, 4); indicesAttribute.normalized = true; - geometry.addAttribute("indices", indicesAttribute); - + geometry.addAttribute('indices', indicesAttribute); + scope.geometry = geometry; scope.loaded = true; Potree.PointCloudArena4DGeometryNode.nodesLoading--; - + geometry.boundingBox = scope.boundingBox; geometry.boundingSphere = scope.boundingSphere; - + scope.numPoints = numPoints; scope.loading = false; }; - + xhr.send(null); }; -Potree.PointCloudArena4DGeometryNode.prototype.dispose = function(){ - if(this.geometry && this.parent != null){ +Potree.PointCloudArena4DGeometryNode.prototype.dispose = function () { + if (this.geometry && this.parent != null) { this.geometry.dispose(); this.geometry = null; this.loaded = false; - - //this.dispatchEvent( { type: 'dispose' } ); - for(var i = 0; i < this.oneTimeDisposeHandlers.length; i++){ + + // this.dispatchEvent( { type: 'dispose' } ); + for (var i = 0; i < this.oneTimeDisposeHandlers.length; i++) { var handler = this.oneTimeDisposeHandlers[i]; handler(); } @@ -153,14 +148,11 @@ Potree.PointCloudArena4DGeometryNode.prototype.dispose = function(){ } }; -Potree.PointCloudArena4DGeometryNode.prototype.getNumPoints = function(){ +Potree.PointCloudArena4DGeometryNode.prototype.getNumPoints = function () { return this.numPoints; }; - -Potree.PointCloudArena4DGeometry = function(){ - var scope = this; - +Potree.PointCloudArena4DGeometry = function () { this.numPoints = 0; this.version = 0; this.boundingBox = null; @@ -172,23 +164,22 @@ Potree.PointCloudArena4DGeometry = function(){ this.levels = 0; this._spacing = null; this.pointAttributes = new Potree.PointAttributes([ - "POSITION_CARTESIAN", - "COLOR_PACKED" + 'POSITION_CARTESIAN', + 'COLOR_PACKED' ]); }; -Potree.PointCloudArena4DGeometry.prototype = Object.create( THREE.EventDispatcher.prototype ); - -Potree.PointCloudArena4DGeometry.load = function(url, callback){ +Potree.PointCloudArena4DGeometry.prototype = Object.create(THREE.EventDispatcher.prototype); +Potree.PointCloudArena4DGeometry.load = function (url, callback) { var xhr = new XMLHttpRequest(); - xhr.open('GET', url + "?info", true); - - xhr.onreadystatechange = function(){ - try{ - if(xhr.readyState === 4 && xhr.status === 200){ + xhr.open('GET', url + '?info', true); + + xhr.onreadystatechange = function () { + try { + if (xhr.readyState === 4 && xhr.status === 200) { var response = JSON.parse(xhr.responseText); - + var geometry = new Potree.PointCloudArena4DGeometry(); geometry.url = url; geometry.name = response.Name; @@ -197,82 +188,79 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){ geometry.numPoints = response.Points; geometry.version = response.Version; geometry.boundingBox = new THREE.Box3( - new THREE.Vector3().fromArray(response.BoundingBox.slice(0,3)), - new THREE.Vector3().fromArray(response.BoundingBox.slice(3,6)) + new THREE.Vector3().fromArray(response.BoundingBox.slice(0, 3)), + new THREE.Vector3().fromArray(response.BoundingBox.slice(3, 6)) ); - if(response.Spacing){ + if (response.Spacing) { geometry.spacing = response.Spacing; } - + var offset = geometry.boundingBox.min.clone().multiplyScalar(-1); - + geometry.boundingBox.min.add(offset); geometry.boundingBox.max.add(offset); geometry.offset = offset; - + var center = geometry.boundingBox.getCenter(); var radius = geometry.boundingBox.getSize().length() / 2; geometry.boundingSphere = new THREE.Sphere(center, radius); - + geometry.loadHierarchy(); - + callback(geometry); - }else if(xhr.readyState === 4){ + } else if (xhr.readyState === 4) { callback(null); } - }catch(e){ + } catch (e) { console.error(e.message); callback(null); } }; - - xhr.send(null); + xhr.send(null); }; -Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ - var url = this.url + "?tree"; +Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function () { + var url = this.url + '?tree'; var xhr = new XMLHttpRequest(); - xhr.open("GET", url, true); - xhr.responseType = "arraybuffer"; - + xhr.open('GET', url, true); + xhr.responseType = 'arraybuffer'; + var scope = this; - - xhr.onreadystatechange = function(){ - if(!(xhr.readyState === 4 && xhr.status === 200)){ + + xhr.onreadystatechange = function () { + if (!(xhr.readyState === 4 && xhr.status === 200)) { return; } - + var buffer = xhr.response; var numNodes = buffer.byteLength / 3; var view = new DataView(buffer); var stack = []; var root = null; - + var levels = 0; - - var start = new Date().getTime(); + + // TODO Debug: var start = new Date().getTime(); // read hierarchy - for(var i = 0; i < numNodes; i++){ - var mask = view.getUint8(i*3+0, true); - var numPoints = view.getUint16(i*3+1, true); - - + for (var i = 0; i < numNodes; i++) { + var mask = view.getUint8(i * 3 + 0, true); + // TODO Unused: var numPoints = view.getUint16(i * 3 + 1, true); + var hasLeft = (mask & 1) > 0; var hasRight = (mask & 2) > 0; var splitX = (mask & 4) > 0; var splitY = (mask & 8) > 0; var splitZ = (mask & 16) > 0; var split = null; - if(splitX){ - split = "X"; - }else if(splitY){ - split = "Y"; - }if(splitZ){ - split = "Z"; + if (splitX) { + split = 'X'; + } else if (splitY) { + split = 'Y'; + } if (splitZ) { + split = 'Z'; } - - + var node = new Potree.PointCloudArena4DGeometryNode(); node.hasLeft = hasLeft; node.hasRight = hasRight; @@ -284,99 +272,94 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ node.pcoGeometry = scope; node.level = stack.length; levels = Math.max(levels, node.level); - - if(stack.length > 0){ - var parent = stack[stack.length-1]; + + if (stack.length > 0) { + var parent = stack[stack.length - 1]; node.boundingBox = parent.boundingBox.clone(); var parentBBSize = parent.boundingBox.getSize(); - - if(parent.hasLeft && !parent.left){ + + if (parent.hasLeft && !parent.left) { parent.left = node; parent.children.push(node); - - if(parent.split === "X"){ + + if (parent.split === 'X') { node.boundingBox.max.x = node.boundingBox.min.x + parentBBSize.x / 2; - }else if(parent.split === "Y"){ + } else if (parent.split === 'Y') { node.boundingBox.max.y = node.boundingBox.min.y + parentBBSize.y / 2; - }else if(parent.split === "Z"){ + } else if (parent.split === 'Z') { node.boundingBox.max.z = node.boundingBox.min.z + parentBBSize.z / 2; } - - var center = node.boundingBox.getCenter(); - var radius = node.boundingBox.getSize().length() / 2; + + let center = node.boundingBox.getCenter(); + let radius = node.boundingBox.getSize().length() / 2; node.boundingSphere = new THREE.Sphere(center, radius); - - }else{ + } else { parent.right = node; parent.children.push(node); - - if(parent.split === "X"){ + + if (parent.split === 'X') { node.boundingBox.min.x = node.boundingBox.min.x + parentBBSize.x / 2; - }else if(parent.split === "Y"){ + } else if (parent.split === 'Y') { node.boundingBox.min.y = node.boundingBox.min.y + parentBBSize.y / 2; - }else if(parent.split === "Z"){ + } else if (parent.split === 'Z') { node.boundingBox.min.z = node.boundingBox.min.z + parentBBSize.z / 2; } - - var center = node.boundingBox.getCenter(); - var radius = node.boundingBox.getSize().length() / 2; + + let center = node.boundingBox.getCenter(); + let radius = node.boundingBox.getSize().length() / 2; node.boundingSphere = new THREE.Sphere(center, radius); } - }else{ + } else { root = node; root.boundingBox = scope.boundingBox.clone(); var center = root.boundingBox.getCenter(); var radius = root.boundingBox.getSize().length() / 2; root.boundingSphere = new THREE.Sphere(center, radius); } - + var bbSize = node.boundingBox.getSize(); node.spacing = ((bbSize.x + bbSize.y + bbSize.z) / 3) / 75; - + stack.push(node); - - if(node.isLeaf){ + + if (node.isLeaf) { var done = false; - while(!done && stack.length > 0){ + while (!done && stack.length > 0) { stack.pop(); - - var top = stack[stack.length-1]; - + + var top = stack[stack.length - 1]; + done = stack.length > 0 && top.hasRight && top.right == null; } } } - var end = new Date().getTime(); - var parseDuration = end - start; - var msg = parseDuration; - //document.getElementById("lblDebug").innerHTML = msg; - + // TODO Debug: + // var end = new Date().getTime(); + // var parseDuration = end - start; + // var msg = parseDuration; + // document.getElementById("lblDebug").innerHTML = msg; + scope.root = root; scope.levels = levels; - //console.log(this.root); - - scope.dispatchEvent({type: "hierarchy_loaded"}); - + // console.log(this.root); + + scope.dispatchEvent({type: 'hierarchy_loaded'}); }; - + xhr.send(null); - - }; -Object.defineProperty(Potree.PointCloudArena4DGeometry.prototype, "spacing", { - get: function(){ - if(this._spacing){ +Object.defineProperty(Potree.PointCloudArena4DGeometry.prototype, 'spacing', { + get: function () { + if (this._spacing) { return this._spacing; - }else if(this.root){ + } else if (this.root) { return this.root.spacing; - }else{ - null; + } else { + // TODO ???: null; } }, - set: function(value){ + set: function (value) { this._spacing = value; } }); - - diff --git a/src/exporter/CSVExporter.js b/src/exporter/CSVExporter.js index 7084603a..59db7224 100644 --- a/src/exporter/CSVExporter.js +++ b/src/exporter/CSVExporter.js @@ -1,52 +1,49 @@ -Potree.CSVExporter = class CSVExporter{ - - static toString(points){ - let string = ""; - +Potree.CSVExporter = class CSVExporter { + static toString (points) { + let string = ''; + let attributes = Object.keys(points.data) - .filter(a => a !== "normal") + .filter(a => a !== 'normal') .sort((a, b) => { - if(a === "position") return -1; - if(b === "position") return 1; - if(a === "color") return -1; - if(b === "color") return 1; + if (a === 'position') return -1; + if (b === 'position') return 1; + if (a === 'color') return -1; + if (b === 'color') return 1; }); - + let headerValues = []; - for(let attribute of attributes){ + for (let attribute of attributes) { let itemSize = points.data[attribute].length / points.numPoints; - - if(attribute === "position"){ - headerValues = headerValues.concat(["x", "y", "z"]); - }else if(attribute === "color"){ - headerValues = headerValues.concat(["r", "g", "b"]); - }else if(itemSize > 1){ - for(let i = 0; i < itemSize; i++){ + + if (attribute === 'position') { + headerValues = headerValues.concat(['x', 'y', 'z']); + } else if (attribute === 'color') { + headerValues = headerValues.concat(['r', 'g', 'b']); + } else if (itemSize > 1) { + for (let i = 0; i < itemSize; i++) { headerValues.push(`${attribute}_${i}`); } - }else{ + } else { headerValues.push(attribute); } } - string = headerValues.join(", ") + "\n"; + string = headerValues.join(', ') + '\n'; - for(let i = 0; i < points.numPoints; i++){ - + for (let i = 0; i < points.numPoints; i++) { let values = []; - - for(let attribute of attributes){ + + for (let attribute of attributes) { let itemSize = points.data[attribute].length / points.numPoints; let value = points.data[attribute] .subarray(itemSize * i, itemSize * i + itemSize) - .join(", "); + .join(', '); values.push(value); } - - string += values.join(", ") + "\n"; + + string += values.join(', ') + '\n'; } - + return string; } - -}; \ No newline at end of file +}; diff --git a/src/exporter/DXFExporter.js b/src/exporter/DXFExporter.js index 77b6b4e2..1418babe 100644 --- a/src/exporter/DXFExporter.js +++ b/src/exporter/DXFExporter.js @@ -1,21 +1,19 @@ /** * * @author sigeom sa / http://sigeom.ch - * @author Ioda-Net Sàrl / https://www.ioda-net.ch/ - * @author Markus Schütz / http://potree.org + * @author Ioda-Net S�rl / https://www.ioda-net.ch/ + * @author Markus Sch�tz / http://potree.org * */ -Potree.DXFExporter = class DXFExporter{ - - static measurementPointSection(measurement){ - +Potree.DXFExporter = class DXFExporter { + static measurementPointSection (measurement) { let position = measurement.points[0].position; - - if(!position){ - return ""; + + if (!position) { + return ''; } - + let dxfSection = `0 CIRCLE 8 @@ -32,15 +30,15 @@ ${position.z} return dxfSection; } - - static measurementPolylineSection(measurement){ - // bit code for polygons/polylines: + + static measurementPolylineSection (measurement) { + // bit code for polygons/polylines: // https://www.autodesk.com/techpubs/autocad/acad2000/dxf/polyline_dxf_06.htm - let geomCode = 8; - if(measurement.closed){ + let geomCode = 8; + if (measurement.closed) { geomCode += 1; } - + let dxfSection = `0 POLYLINE 8 @@ -62,12 +60,12 @@ ${geomCode} let xMax = 0.0; let yMax = 0.0; let zMax = 0.0; - for(let point of measurement.points){ + for (let point of measurement.points) { point = point.position; xMax = Math.max(xMax, point.x); yMax = Math.max(yMax, point.y); zMax = Math.max(zMax, point.z); - + dxfSection += `0 VERTEX 8 @@ -81,52 +79,46 @@ ${point.z} 70 32 `; - } - dxfSection += `0 + dxfSection += `0 SEQEND `; return dxfSection; } - - static measurementSection(measurement){ - - //if(measurement.points.length <= 1){ + + static measurementSection (measurement) { + // if(measurement.points.length <= 1){ // return ""; - //} - - if(measurement.points.length === 0){ - return ""; - }else if(measurement.points.length === 1){ + // } + + if (measurement.points.length === 0) { + return ''; + } else if (measurement.points.length === 1) { return Potree.DXFExporter.measurementPointSection(measurement); - }else if(measurement.points.length >= 2){ + } else if (measurement.points.length >= 2) { return Potree.DXFExporter.measurementPolylineSection(measurement); } } - - - static toString(measurements){ - - if(!(measurements instanceof Array)){ + + static toString (measurements) { + if (!(measurements instanceof Array)) { measurements = [measurements]; } measurements = measurements.filter(m => m instanceof Potree.Measure); - + let points = measurements.filter(m => (m instanceof Potree.Measure)) .map(m => m.points) .reduce((a, v) => a.concat(v)) .map(p => p.position); - + let min = new THREE.Vector3(Infinity, Infinity, Infinity); let max = new THREE.Vector3(-Infinity, -Infinity, -Infinity); - for(let point of points){ + for (let point of points) { min.min(point); max.max(point); } - - - + let dxfHeader = `999 DXF created from potree 0 @@ -170,19 +162,17 @@ SECTION 2 ENTITIES `; - - for(let measurement of measurements){ + + for (let measurement of measurements) { dxfBody += Potree.DXFExporter.measurementSection(measurement); } - + dxfBody += `0 ENDSEC `; let dxf = dxfHeader + dxfBody + '0\nEOF'; - + return dxf; } - - -} \ No newline at end of file +}; diff --git a/src/exporter/GeoJSONExporter.js b/src/exporter/GeoJSONExporter.js index 5cb3633f..0ebff1f9 100644 --- a/src/exporter/GeoJSONExporter.js +++ b/src/exporter/GeoJSONExporter.js @@ -6,61 +6,58 @@ * */ -Potree.GeoJSONExporter = class GeoJSONExporter{ - - static measurementToFeatures(measurement){ - +Potree.GeoJSONExporter = class GeoJSONExporter { + static measurementToFeatures (measurement) { let coords = measurement.points.map(e => e.position.toArray()); - + let features = []; - - if(coords.length === 1){ + + if (coords.length === 1) { let feature = { type: 'Feature', geometry: { type: 'Point', - coordinates: coords[0], + coordinates: coords[0] }, properties: { name: measurement.name } }; features.push(feature); - }else if(coords.length > 1 && !measurement.closed){ + } else if (coords.length > 1 && !measurement.closed) { let object = { - "type": "Feature", - "geometry": { - "type": "LineString", - "coordinates": coords + 'type': 'Feature', + 'geometry': { + 'type': 'LineString', + 'coordinates': coords }, - "properties": { + 'properties': { name: measurement.name } }; - - features.push(object); - }else if(coords.length > 1 && measurement.closed){ + features.push(object); + } else if (coords.length > 1 && measurement.closed) { let object = { - "type": "Feature", - "geometry": { - "type": "Polygon", - "coordinates": [[...coords, coords[0]]] + 'type': 'Feature', + 'geometry': { + 'type': 'Polygon', + 'coordinates': [[...coords, coords[0]]] }, - "properties": { + 'properties': { name: measurement.name } }; features.push(object); } - if(measurement.showDistances){ + if (measurement.showDistances) { measurement.edgeLabels.forEach((label) => { let labelPoint = { type: 'Feature', geometry: { type: 'Point', - coordinates: label.position.toArray(), + coordinates: label.position.toArray() }, properties: { distance: label.text @@ -69,14 +66,14 @@ Potree.GeoJSONExporter = class GeoJSONExporter{ features.push(labelPoint); }); } - - if(measurement.showArea){ + + if (measurement.showArea) { var point = measurement.areaLabel.position; var labelArea = { type: 'Feature', geometry: { type: 'Point', - coordinates: point.toArray(), + coordinates: point.toArray() }, properties: { area: measurement.areaLabel.text @@ -84,33 +81,29 @@ Potree.GeoJSONExporter = class GeoJSONExporter{ }; features.push(labelArea); } - + return features; } - - static toString(measurements){ - - if(!(measurements instanceof Array)){ + + static toString (measurements) { + if (!(measurements instanceof Array)) { measurements = [measurements]; } - + measurements = measurements.filter(m => m instanceof Potree.Measure); - + let features = []; - for(let measure of measurements){ + for (let measure of measurements) { let f = Potree.GeoJSONExporter.measurementToFeatures(measure); - + features = features.concat(f); } - + let geojson = { - "type": "FeatureCollection", - "features": features + 'type': 'FeatureCollection', + 'features': features }; - - return JSON.stringify(geojson, null, "\t"); + + return JSON.stringify(geojson, null, '\t'); } - -} - - +}; diff --git a/src/exporter/LASExporter.js b/src/exporter/LASExporter.js index f3565ebb..397fc393 100644 --- a/src/exporter/LASExporter.js +++ b/src/exporter/LASExporter.js @@ -1,150 +1,148 @@ -Potree.LASExporter = class LASExporter{ - - static toLAS(points){ - let string = ""; - +Potree.LASExporter = class LASExporter { + static toLAS (points) { + // TODO Unused: let string = ''; + let boundingBox = points.boundingBox; let offset = boundingBox.min.clone(); let diagonal = boundingBox.min.distanceTo(boundingBox.max); let scale = new THREE.Vector3(0.001, 0.001, 0.001); - if(diagonal > 1000*1000){ + if (diagonal > 1000 * 1000) { scale = new THREE.Vector3(0.01, 0.01, 0.01); - }else{ + } else { scale = new THREE.Vector3(0.001, 0.001, 0.001); } - - let setString = function(string, offset, buffer){ + + let setString = function (string, offset, buffer) { let view = new Uint8Array(buffer); - - for(let i = 0; i < string.length; i++){ + + for (let i = 0; i < string.length; i++) { let charCode = string.charCodeAt(i); view[offset + i] = charCode; } - } - + }; + let buffer = new ArrayBuffer(227 + 28 * points.numPoints); let view = new DataView(buffer); let u8View = new Uint8Array(buffer); - //let u16View = new Uint16Array(buffer); - - setString("LASF", 0, buffer); + // let u16View = new Uint16Array(buffer); + + setString('LASF', 0, buffer); u8View[24] = 1; u8View[25] = 2; - + // system identifier o:26 l:32 - + // generating software o:58 l:32 - setString("Potree 1.5", 58, buffer); - + setString('Potree 1.5', 58, buffer); + // file creation day of year o:90 l:2 // file creation year o:92 l:2 - + // header size o:94 l:2 view.setUint16(94, 227, true); - + // offset to point data o:96 l:4 view.setUint32(96, 227, true); - + // number of letiable length records o:100 l:4 - + // point data record format 104 1 u8View[104] = 2; - + // point data record length 105 2 view.setUint16(105, 28, true); - - // number of point records 107 4 + + // number of point records 107 4 view.setUint32(107, points.numPoints, true); - + // number of points by return 111 20 - + // x scale factor 131 8 view.setFloat64(131, scale.x, true); - + // y scale factor 139 8 view.setFloat64(139, scale.y, true); - + // z scale factor 147 8 view.setFloat64(147, scale.z, true); - + // x offset 155 8 view.setFloat64(155, offset.x, true); - + // y offset 163 8 view.setFloat64(163, offset.y, true); - + // z offset 171 8 view.setFloat64(171, offset.z, true); - + // max x 179 8 view.setFloat64(179, boundingBox.max.x, true); - + // min x 187 8 view.setFloat64(187, boundingBox.min.x, true); - + // max y 195 8 view.setFloat64(195, boundingBox.max.y, true); - + // min y 203 8 view.setFloat64(203, boundingBox.min.y, true); - + // max z 211 8 view.setFloat64(211, boundingBox.max.z, true); - + // min z 219 8 view.setFloat64(219, boundingBox.min.z, true); - + let boffset = 227; - for(let i = 0; i < points.numPoints; i++){ - //let point = points[i]; - //let position = new THREE.Vector3(point.x, point.y, point.z); - - let px = points.data.position[3*i + 0]; - let py = points.data.position[3*i + 1]; - let pz = points.data.position[3*i + 2]; - + for (let i = 0; i < points.numPoints; i++) { + // let point = points[i]; + // let position = new THREE.Vector3(point.x, point.y, point.z); + + let px = points.data.position[3 * i + 0]; + let py = points.data.position[3 * i + 1]; + let pz = points.data.position[3 * i + 2]; + let ux = parseInt((px - offset.x) / scale.x); let uy = parseInt((py - offset.y) / scale.y); let uz = parseInt((pz - offset.z) / scale.z); - + view.setUint32(boffset + 0, ux, true); view.setUint32(boffset + 4, uy, true); view.setUint32(boffset + 8, uz, true); - - if(points.data.intensity){ + + if (points.data.intensity) { view.setUint16(boffset + 12, (points.data.intensity[i]), true); } - + let rt = 0; - if(points.data.returnNumber){ + if (points.data.returnNumber) { rt += points.data.returnNumber[i]; } - if(points.data.numberOfReturns){ + if (points.data.numberOfReturns) { rt += (points.data.numberOfReturns[i] << 3); } view.setUint8(boffset + 14, rt); - - if(points.data.classification){ + + if (points.data.classification) { view.setUint8(boffset + 15, points.data.classification[i]); } // scan angle rank // user data // point source id - if(points.data.pointSourceID){ + if (points.data.pointSourceID) { view.setUint16(boffset + 18, points.data.pointSourceID[i]); } - - if(points.data.color){ - view.setUint16(boffset + 20, (points.data.color[3*i + 0] * 255), true); - view.setUint16(boffset + 22, (points.data.color[3*i + 1] * 255), true); - view.setUint16(boffset + 24, (points.data.color[3*i + 2] * 255), true); + + if (points.data.color) { + view.setUint16(boffset + 20, (points.data.color[3 * i + 0] * 255), true); + view.setUint16(boffset + 22, (points.data.color[3 * i + 1] * 255), true); + view.setUint16(boffset + 24, (points.data.color[3 * i + 2] * 255), true); } - + boffset += 28; } return buffer; } - -}; \ No newline at end of file +}; diff --git a/src/extensions/EventDispatcher.js b/src/extensions/EventDispatcher.js index e64788bd..ea06d1f8 100644 --- a/src/extensions/EventDispatcher.js +++ b/src/extensions/EventDispatcher.js @@ -1,16 +1,10 @@ -THREE.EventDispatcher.prototype.removeEventListeners = function(type){ - - if ( this._listeners === undefined ) { - +THREE.EventDispatcher.prototype.removeEventListeners = function (type) { + if (this._listeners === undefined) { return; - } - - if ( this._listeners[ type ] ) { - + + if (this._listeners[ type ]) { delete this._listeners[ type ]; - } - -}; \ No newline at end of file +}; diff --git a/src/extensions/PerspectiveCamera.js b/src/extensions/PerspectiveCamera.js index 588cbe7f..829f6a8d 100644 --- a/src/extensions/PerspectiveCamera.js +++ b/src/extensions/PerspectiveCamera.js @@ -1,47 +1,42 @@ - -THREE.PerspectiveCamera.prototype.zoomTo = function( node, factor ){ - - if ( !node.geometry && !node.boundingSphere && !node.boundingBox) { +THREE.PerspectiveCamera.prototype.zoomTo = function (node, factor) { + if (!node.geometry && !node.boundingSphere && !node.boundingBox) { return; } - - if ( node.geometry && node.geometry.boundingSphere === null ) { + + if (node.geometry && node.geometry.boundingSphere === null) { node.geometry.computeBoundingSphere(); } - + node.updateMatrixWorld(); - + var bs; - - if(node.boundingSphere){ + + if (node.boundingSphere) { bs = node.boundingSphere; - }else if(node.geometry && node.geometry.boundingSphere){ + } else if (node.geometry && node.geometry.boundingSphere) { bs = node.geometry.boundingSphere; - }else{ + } else { bs = node.boundingBox.getBoundingSphere(); } var _factor = factor || 1; - - bs = bs.clone().applyMatrix4(node.matrixWorld); + + bs = bs.clone().applyMatrix4(node.matrixWorld); var radius = bs.radius; var fovr = this.fov * Math.PI / 180; - - if( this.aspect < 1 ){ + + if (this.aspect < 1) { fovr = fovr * this.aspect; } - - var distanceFactor = Math.abs( radius / Math.sin( fovr / 2 ) ) * _factor ; - - var offset = this.getWorldDirection().multiplyScalar( -distanceFactor ); - this.position.copy(bs.center.clone().add( offset )); - + + var distanceFactor = Math.abs(radius / Math.sin(fovr / 2)) * _factor; + + var offset = this.getWorldDirection().multiplyScalar(-distanceFactor); + this.position.copy(bs.center.clone().add(offset)); }; - - -//THREE.PerspectiveCamera.prototype.zoomTo = function(node, factor){ +// THREE.PerspectiveCamera.prototype.zoomTo = function(node, factor){ // if(factor === undefined){ // factor = 1; // } @@ -49,11 +44,11 @@ THREE.PerspectiveCamera.prototype.zoomTo = function( node, factor ){ // node.updateMatrixWorld(); // this.updateMatrix(); // this.updateMatrixWorld(); -// +// // var box = Potree.utils.computeTransformedBoundingBox(node.boundingBox, node.matrixWorld); // var dir = new THREE.Vector3(0, 0, -1).applyQuaternion(this.quaternion); // var pos = box.center().sub(dir); -// +// // var ps = [ // new THREE.Vector3(box.min.x, box.min.y, box.min.z), // new THREE.Vector3(box.min.x, box.min.y, box.min.z), @@ -65,14 +60,14 @@ THREE.PerspectiveCamera.prototype.zoomTo = function( node, factor ){ // new THREE.Vector3(box.max.x, box.min.y, box.max.z), // new THREE.Vector3(box.max.x, box.max.y, box.max.z) // ]; -// +// // var frustum = new THREE.Frustum(); // frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(this.projectionMatrix, this.matrixWorldInverse)); -// +// // var max = Number.MIN_VALUE; // for(var i = 0; i < ps.length; i++){ // var p = ps[i]; -// +// // var distance = Number.MIN_VALUE; // // iterate through left, right, top and bottom planes // for(var j = 0; j < frustum.planes.length-2; j++){ @@ -87,5 +82,5 @@ THREE.PerspectiveCamera.prototype.zoomTo = function( node, factor ){ // offset.multiplyScalar(factor); // pos.add(offset); // this.position.copy(pos); -// -//} \ No newline at end of file +// +// } diff --git a/src/extensions/Ray.js b/src/extensions/Ray.js index 82a0a782..4b4ceec1 100644 --- a/src/extensions/Ray.js +++ b/src/extensions/Ray.js @@ -1,16 +1,15 @@ -THREE.Ray.prototype.distanceToPlaneWithNegative = function ( plane ) { - var denominator = plane.normal.dot( this.direction ); - if ( denominator === 0 ) { - +THREE.Ray.prototype.distanceToPlaneWithNegative = function (plane) { + var denominator = plane.normal.dot(this.direction); + if (denominator === 0) { // line is coplanar, return origin - if( plane.distanceToPoint( this.origin ) === 0 ) { + if (plane.distanceToPoint(this.origin) === 0) { return 0; } // Null is preferable to undefined since undefined means.... it is undefined return null; } - var t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator; + var t = -(this.origin.dot(plane.normal) + plane.constant) / denominator; return t; -}; \ No newline at end of file +}; diff --git a/src/loader/BinaryLoader.js b/src/loader/BinaryLoader.js index 82925874..57bb9483 100644 --- a/src/loader/BinaryLoader.js +++ b/src/loader/BinaryLoader.js @@ -1,8 +1,8 @@ -Potree.BinaryLoader = function(version, boundingBox, scale){ - if(typeof(version) === "string"){ +Potree.BinaryLoader = function (version, boundingBox, scale) { + if (typeof (version) === 'string') { this.version = new Potree.Version(version); - }else{ + } else { this.version = version; } @@ -10,8 +10,8 @@ Potree.BinaryLoader = function(version, boundingBox, scale){ this.scale = scale; }; -Potree.BinaryLoader.prototype.load = function(node){ - if(node.loaded){ +Potree.BinaryLoader.prototype.load = function (node) { + if (node.loaded) { return; } @@ -19,44 +19,43 @@ Potree.BinaryLoader.prototype.load = function(node){ let url = node.getURL(); - if(this.version.equalOrHigher("1.4")){ - url += ".bin"; + if (this.version.equalOrHigher('1.4')) { + url += '.bin'; } let xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.overrideMimeType('text/plain; charset=x-user-defined'); - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200 || xhr.status === 0) { let buffer = xhr.response; scope.parse(node, buffer); } else { - console.log('Failed to load file! HTTP status: ' + xhr.status + ", file: " + url); + console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + url); } } }; - try{ + try { xhr.send(null); - }catch(e){ - console.log("fehler beim laden der punktwolke: " + e); + } catch (e) { + console.log('fehler beim laden der punktwolke: ' + e); } }; -Potree.BinaryLoader.prototype.parse = function(node, buffer){ - +Potree.BinaryLoader.prototype.parse = function (node, buffer) { let numPoints = buffer.byteLength / node.pcoGeometry.pointAttributes.byteSize; let pointAttributes = node.pcoGeometry.pointAttributes; - if(this.version.upTo("1.5")){ + if (this.version.upTo('1.5')) { node.numPoints = numPoints; } - let workerPath = Potree.scriptPath + "/workers/BinaryDecoderWorker.js"; + let workerPath = Potree.scriptPath + '/workers/BinaryDecoderWorker.js'; let worker = Potree.workerPool.getWorker(workerPath); - - worker.onmessage = function(e){ + + worker.onmessage = function (e) { let data = e.data; let buffers = data.attributeBuffers; let tightBoundingBox = new THREE.Box3( @@ -68,38 +67,38 @@ Potree.BinaryLoader.prototype.parse = function(node, buffer){ let geometry = new THREE.BufferGeometry(); - for(let property in buffers){ - if(buffers.hasOwnProperty(property)){ + for (let property in buffers) { + if (buffers.hasOwnProperty(property)) { let buffer = buffers[property].buffer; - let attribute = buffers[property].attribute; - let numElements = attribute.numElements; + // TODO Unused: let attribute = buffers[property].attribute; + // TODO Unused: let numElements = attribute.numElements; - if(parseInt(property) === Potree.PointAttributeNames.POSITION_CARTESIAN){ - geometry.addAttribute("position", new THREE.BufferAttribute(new Float32Array(buffer), 3)); - }else if(parseInt(property) === Potree.PointAttributeNames.COLOR_PACKED){ - geometry.addAttribute("color", new THREE.BufferAttribute(new Uint8Array(buffer), 3, true)); - }else if(parseInt(property) === Potree.PointAttributeNames.INTENSITY){ - geometry.addAttribute("intensity", new THREE.BufferAttribute(new Float32Array(buffer), 1)); - }else if(parseInt(property) === Potree.PointAttributeNames.CLASSIFICATION){ - geometry.addAttribute("classification", new THREE.BufferAttribute(new Uint8Array(buffer), 1)); - }else if(parseInt(property) === Potree.PointAttributeNames.NORMAL_SPHEREMAPPED){ - geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3)); - }else if(parseInt(property) === Potree.PointAttributeNames.NORMAL_OCT16){ - geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3)); - }else if(parseInt(property) === Potree.PointAttributeNames.NORMAL){ - geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3)); + if (parseInt(property) === Potree.PointAttributeNames.POSITION_CARTESIAN) { + geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3)); + } else if (parseInt(property) === Potree.PointAttributeNames.COLOR_PACKED) { + geometry.addAttribute('color', new THREE.BufferAttribute(new Uint8Array(buffer), 3, true)); + } else if (parseInt(property) === Potree.PointAttributeNames.INTENSITY) { + geometry.addAttribute('intensity', new THREE.BufferAttribute(new Float32Array(buffer), 1)); + } else if (parseInt(property) === Potree.PointAttributeNames.CLASSIFICATION) { + geometry.addAttribute('classification', new THREE.BufferAttribute(new Uint8Array(buffer), 1)); + } else if (parseInt(property) === Potree.PointAttributeNames.NORMAL_SPHEREMAPPED) { + geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3)); + } else if (parseInt(property) === Potree.PointAttributeNames.NORMAL_OCT16) { + geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3)); + } else if (parseInt(property) === Potree.PointAttributeNames.NORMAL) { + geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3)); } } } let indicesAttribute = new THREE.Uint8BufferAttribute(data.indices, 4); indicesAttribute.normalized = true; - geometry.addAttribute("indices", indicesAttribute); + geometry.addAttribute('indices', indicesAttribute); - if(!geometry.attributes.normal){ - let buffer = new Float32Array(numPoints*3); - geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3)); + if (!geometry.attributes.normal) { + let buffer = new Float32Array(numPoints * 3); + geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3)); } - + tightBoundingBox.max.sub(tightBoundingBox.min); tightBoundingBox.min.set(0, 0, 0); @@ -121,5 +120,4 @@ Potree.BinaryLoader.prototype.parse = function(node, buffer){ scale: this.scale }; worker.postMessage(message, [message.buffer]); - }; diff --git a/src/loader/GreyhoundBinaryLoader.js b/src/loader/GreyhoundBinaryLoader.js index 886030e0..f58b48e4 100644 --- a/src/loader/GreyhoundBinaryLoader.js +++ b/src/loader/GreyhoundBinaryLoader.js @@ -1,15 +1,14 @@ -function networkToNative(val) { - return ((val & 0x00FF) << 24) | - ((val & 0xFF00) << 8) | - ((val >> 8) & 0xFF00) | - ((val >> 24) & 0x00FF); +function networkToNative (val) { + return ((val & 0x00FF) << 24) | + ((val & 0xFF00) << 8) | + ((val >> 8) & 0xFF00) | + ((val >> 24) & 0x00FF); } -Potree.GreyhoundBinaryLoader = function(version, boundingBox, scale){ - if (typeof(version) === "string") { +Potree.GreyhoundBinaryLoader = function (version, boundingBox, scale) { + if (typeof (version) === 'string') { this.version = new Potree.Version(version); - } - else { + } else { this.version = version; } @@ -17,10 +16,10 @@ Potree.GreyhoundBinaryLoader = function(version, boundingBox, scale){ this.scale = scale; }; -Potree.GreyhoundBinaryLoader.prototype.load = function(node){ +Potree.GreyhoundBinaryLoader.prototype.load = function (node) { if (node.loaded) return; - var scope = this; + var scope = this; var url = node.getURL(); var xhr = new XMLHttpRequest(); @@ -28,42 +27,40 @@ Potree.GreyhoundBinaryLoader.prototype.load = function(node){ xhr.responseType = 'arraybuffer'; xhr.overrideMimeType('text/plain; charset=x-user-defined'); - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200 || xhr.status === 0) { var buffer = xhr.response; scope.parse(node, buffer); - } - else { + } else { console.log( - 'Failed to load file! HTTP status:', xhr.status, - 'file:', url); + 'Failed to load file! HTTP status:', xhr.status, + 'file:', url); } } }; try { xhr.send(null); - } - catch(e) { - console.log("error loading point cloud: " + e); + } catch (e) { + console.log('error loading point cloud: ' + e); } }; -Potree.GreyhoundBinaryLoader.prototype.parse = function(node, buffer){ +Potree.GreyhoundBinaryLoader.prototype.parse = function (node, buffer) { var NUM_POINTS_BYTES = 4; - var view = new DataView( - buffer, buffer.byteLength - NUM_POINTS_BYTES, NUM_POINTS_BYTES); - var numPoints = networkToNative(view.getUint32(0)); + var view = new DataView( + buffer, buffer.byteLength - NUM_POINTS_BYTES, NUM_POINTS_BYTES); + var numPoints = networkToNative(view.getUint32(0)); var pointAttributes = node.pcoGeometry.pointAttributes; - node.numPoints = numPoints; + node.numPoints = numPoints; - let workerPath = Potree.scriptPath + "/workers/GreyhoundBinaryDecoderWorker.js"; + let workerPath = Potree.scriptPath + '/workers/GreyhoundBinaryDecoderWorker.js'; let worker = Potree.workerPool.getWorker(workerPath); - worker.onmessage = function(e){ + worker.onmessage = function (e) { var data = e.data; var buffers = data.attributeBuffers; var tightBoundingBox = new THREE.Box3( @@ -75,56 +72,56 @@ Potree.GreyhoundBinaryLoader.prototype.parse = function(node, buffer){ var geometry = new THREE.BufferGeometry(); - var addAttribute = function(name, buffer, size) { - geometry.addAttribute( - name, - new THREE.BufferAttribute(new Float32Array(buffer), size)); - }; + var addAttribute = function (name, buffer, size) { + geometry.addAttribute( + name, + new THREE.BufferAttribute(new Float32Array(buffer), size)); + }; for (var property in buffers) { if (buffers.hasOwnProperty(property)) { var buffer = buffers[property].buffer; - var attribute = buffers[property].attribute; - var numElements = attribute.numElements; + // TODO Unused: var attribute = buffers[property].attribute; + // TODO Unused: var numElements = attribute.numElements; - var pointAttributes = Potree.PointAttributeNames; + var pointAttributes = Potree.PointAttributeNames; - switch (parseInt(property)) { - case pointAttributes.POSITION_CARTESIAN: - addAttribute('position', buffer, 3); - //let fb = new Float32Array(buffer); - //console.log(fb); - break; - case pointAttributes.COLOR_PACKED: - geometry.addAttribute("color", + switch (parseInt(property)) { + case pointAttributes.POSITION_CARTESIAN: + addAttribute('position', buffer, 3); + // let fb = new Float32Array(buffer); + // console.log(fb); + break; + case pointAttributes.COLOR_PACKED: + geometry.addAttribute('color', new THREE.BufferAttribute(new Uint8Array(buffer), 3, true)); - break; - case pointAttributes.INTENSITY: - addAttribute('intensity', buffer, 1); - break; - case pointAttributes.CLASSIFICATION: - addAttribute('classification', buffer, 1); - break; - case pointAttributes.NORMAL_SPHEREMAPPED: - case pointAttributes.NORMAL_OCT16: - case pointAttributes.NORMAL: - addAttribute('normal', buffer, 3); - break; - default: - break; - } + break; + case pointAttributes.INTENSITY: + addAttribute('intensity', buffer, 1); + break; + case pointAttributes.CLASSIFICATION: + addAttribute('classification', buffer, 1); + break; + case pointAttributes.NORMAL_SPHEREMAPPED: + case pointAttributes.NORMAL_OCT16: + case pointAttributes.NORMAL: + addAttribute('normal', buffer, 3); + break; + default: + break; + } } } - //addAttribute('indices', data.indices, 1); - + // addAttribute('indices', data.indices, 1); + let indicesAttribute = new THREE.Uint8BufferAttribute(data.indices, 4); indicesAttribute.normalized = true; - geometry.addAttribute("indices", indicesAttribute); + geometry.addAttribute('indices', indicesAttribute); if (!geometry.attributes.normal) { - addAttribute('normal', new Float32Array(numPoints * 3), 3); - } + addAttribute('normal', new Float32Array(numPoints * 3), 3); + } geometry.boundingBox = node.boundingBox; node.geometry = geometry; @@ -134,27 +131,25 @@ Potree.GreyhoundBinaryLoader.prototype.parse = function(node, buffer){ --node.pcoGeometry.numNodesLoading; }; - var bb = node.boundingBox; - var pco = node.pcoGeometry; + var bb = node.boundingBox; + // TODO Unused: var pco = node.pcoGeometry; - - //let nodeOffset = node.boundingBox.getCenter(); - //let nodeOffset = new THREE.Vector3(0, 0, 0); + // let nodeOffset = node.boundingBox.getCenter(); + // let nodeOffset = new THREE.Vector3(0, 0, 0); let nodeOffset = node.pcoGeometry.boundingBox.getCenter().sub(node.boundingBox.min); - //let nodeOffset = node.pcoGeometry.boundingBox.min; + // let nodeOffset = node.pcoGeometry.boundingBox.min; var message = { buffer: buffer, pointAttributes: pointAttributes, version: this.version.version, - schema: node.pcoGeometry.schema, + schema: node.pcoGeometry.schema, min: [bb.min.x, bb.min.y, bb.min.z], max: [bb.max.x, bb.max.y, bb.max.z], offset: nodeOffset.toArray(), - scale: this.scale, - normalize: node.pcoGeometry.normalize + scale: this.scale, + normalize: node.pcoGeometry.normalize }; worker.postMessage(message, [message.buffer]); }; - diff --git a/src/loader/GreyhoundLoader.js b/src/loader/GreyhoundLoader.js index 3f397679..c4f54bfc 100644 --- a/src/loader/GreyhoundLoader.js +++ b/src/loader/GreyhoundLoader.js @@ -6,22 +6,21 @@ * @author Connor Manning */ -class GreyhoundUtils{ - - static getQueryParam(name) { - name = name.replace(/[\[\]]/g, "\\$&"); - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), - results = regex.exec(window.location.href); +class GreyhoundUtils { + static getQueryParam (name) { + name = name.replace(/[[\]]/g, '\\$&'); + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'); + var results = regex.exec(window.location.href); if (!results) return null; if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, " ")); + return decodeURIComponent(results[2].replace(/\+/g, ' ')); } - - static createSchema(attributes) { + + static createSchema (attributes) { var schema = [ - { "name": "X", "size": 4, "type": "signed" }, - { "name": "Y", "size": 4, "type": "signed" }, - { "name": "Z", "size": 4, "type": "signed" } + { 'name': 'X', 'size': 4, 'type': 'signed' }, + { 'name': 'Y', 'size': 4, 'type': 'signed' }, + { 'name': 'Z', 'size': 4, 'type': 'signed' } ]; // Once we include options in the UI to load a dynamic list of available @@ -31,31 +30,29 @@ class GreyhoundUtils{ // If we do that though, we also need to tell Potree to redraw the points // that are already loaded (with different attributes). // This is not default behaviour. - attributes.forEach(function(item) { - if(item === 'COLOR_PACKED') { - schema.push({ "name": "Red", "size": 2, "type": "unsigned" }); - schema.push({ "name": "Green", "size": 2, "type": "unsigned" }); - schema.push({ "name": "Blue", "size": 2, "type": "unsigned" }); - } else if(item === 'INTENSITY'){ - schema.push({ "name": "Intensity", "size": 2, "type": "unsigned" }); - } else if(item === 'CLASSIFICATION') { - schema.push( - { "name": "Classification", "size": 1, "type": "unsigned" }); + attributes.forEach(function (item) { + if (item === 'COLOR_PACKED') { + schema.push({ 'name': 'Red', 'size': 2, 'type': 'unsigned' }); + schema.push({ 'name': 'Green', 'size': 2, 'type': 'unsigned' }); + schema.push({ 'name': 'Blue', 'size': 2, 'type': 'unsigned' }); + } else if (item === 'INTENSITY') { + schema.push({ 'name': 'Intensity', 'size': 2, 'type': 'unsigned' }); + } else if (item === 'CLASSIFICATION') { + schema.push({ 'name': 'Classification', 'size': 1, 'type': 'unsigned' }); } }); - return schema; + return schema; } - - static fetch(url, cb) { + + static fetch (url, cb) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200 || xhr.status === 0) { cb(null, xhr.responseText); - } - else { + } else { cb(xhr.responseText); } } @@ -63,16 +60,15 @@ class GreyhoundUtils{ xhr.send(null); }; - static fetchBinary(url, cb) { + static fetchBinary (url, cb) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200 || xhr.status === 0) { cb(null, xhr.response); - } - else { + } else { cb(xhr.responseText); } } @@ -80,34 +76,34 @@ class GreyhoundUtils{ xhr.send(null); }; - static pointSizeFrom(schema) { + static pointSizeFrom (schema) { return schema.reduce((p, c) => p + c.size, 0); }; - static getNormalization(serverURL, baseDepth, cb) { + static getNormalization (serverURL, baseDepth, cb) { var s = [ - { "name": "X", "size": 4, "type": "floating" }, - { "name": "Y", "size": 4, "type": "floating" }, - { "name": "Z", "size": 4, "type": "floating" }, - { "name": "Red", "size": 2, "type": "unsigned" }, - { "name": "Green", "size": 2, "type": "unsigned" }, - { "name": "Blue", "size": 2, "type": "unsigned" }, - { "name": "Intensity", "size": 2, "type": "unsigned" } + { 'name': 'X', 'size': 4, 'type': 'floating' }, + { 'name': 'Y', 'size': 4, 'type': 'floating' }, + { 'name': 'Z', 'size': 4, 'type': 'floating' }, + { 'name': 'Red', 'size': 2, 'type': 'unsigned' }, + { 'name': 'Green', 'size': 2, 'type': 'unsigned' }, + { 'name': 'Blue', 'size': 2, 'type': 'unsigned' }, + { 'name': 'Intensity', 'size': 2, 'type': 'unsigned' } ]; var url = serverURL + 'read?depth=' + baseDepth + '&schema=' + JSON.stringify(s); - GreyhoundUtils.fetchBinary(url, function(err, buffer) { + GreyhoundUtils.fetchBinary(url, function (err, buffer) { if (err) throw new Error(err); var view = new DataView(buffer); var numBytes = buffer.byteLength - 4; - var numPoints = view.getUint32(numBytes, true); + // TODO Unused: var numPoints = view.getUint32(numBytes, true); var pointSize = GreyhoundUtils.pointSizeFrom(s); - var colorNorm = false, intensityNorm = false; - var v; + var colorNorm = false; + var intensityNorm = false; for (var offset = 0; offset < numBytes; offset += pointSize) { if (view.getUint16(offset + 12, true) > 255 || @@ -129,11 +125,10 @@ class GreyhoundUtils{ cb(null, { color: colorNorm, intensity: intensityNorm }); }); }; - }; -Potree.GreyhoundLoader = function() { }; -Potree.GreyhoundLoader.loadInfoJSON = function load(url, callback) { } +Potree.GreyhoundLoader = function () { }; +Potree.GreyhoundLoader.loadInfoJSON = function load (url, callback) { }; /** * @return a point cloud octree with the root node data loaded. @@ -143,159 +138,160 @@ Potree.GreyhoundLoader.loadInfoJSON = function load(url, callback) { } * @param loadingFinishedListener executed after loading the binary has been * finished */ -Potree.GreyhoundLoader.load = function load(url, callback) { +Potree.GreyhoundLoader.load = function load (url, callback) { var HIERARCHY_STEP_SIZE = 5; try { // We assume everything ater the string 'greyhound://' is the server url var serverURL = url.split('greyhound://')[1]; - if (serverURL.split('http://').length == 1) { - serverURL = 'http://' + serverURL; - } + if (serverURL.split('http://').length === 1) { + serverURL = 'http://' + serverURL; + } - GreyhoundUtils.fetch(serverURL + 'info', function(err, data) { - if (err) throw new Error(err); + GreyhoundUtils.fetch(serverURL + 'info', function (err, data) { + if (err) throw new Error(err); - /* We parse the result of the info query, which should be a JSON - * datastructure somewhat like: - { - "bounds": [635577, 848882, -1000, 639004, 853538, 2000], - "numPoints": 10653336, - "schema": [ - { "name": "X", "size": 8, "type": "floating" }, - { "name": "Y", "size": 8, "type": "floating" }, - { "name": "Z", "size": 8, "type": "floating" }, - { "name": "Intensity", "size": 2, "type": "unsigned" }, - { "name": "OriginId", "size": 4, "type": "unsigned" }, - { "name": "Red", "size": 2, "type": "unsigned" }, - { "name": "Green", "size": 2, "type": "unsigned" }, - { "name": "Blue", "size": 2, "type": "unsigned" } - ], - "srs": "", - "type": "octree" - } - */ - var greyhoundInfo = JSON.parse(data); - var version = new Potree.Version('1.4'); + /* We parse the result of the info query, which should be a JSON + * datastructure somewhat like: + { + "bounds": [635577, 848882, -1000, 639004, 853538, 2000], + "numPoints": 10653336, + "schema": [ + { "name": "X", "size": 8, "type": "floating" }, + { "name": "Y", "size": 8, "type": "floating" }, + { "name": "Z", "size": 8, "type": "floating" }, + { "name": "Intensity", "size": 2, "type": "unsigned" }, + { "name": "OriginId", "size": 4, "type": "unsigned" }, + { "name": "Red", "size": 2, "type": "unsigned" }, + { "name": "Green", "size": 2, "type": "unsigned" }, + { "name": "Blue", "size": 2, "type": "unsigned" } + ], + "srs": "", + "type": "octree" + } + */ + var greyhoundInfo = JSON.parse(data); + var version = new Potree.Version('1.4'); - var bounds = greyhoundInfo.bounds; - var boundsConforming = greyhoundInfo.boundsConforming; + var bounds = greyhoundInfo.bounds; + // TODO Unused: var boundsConforming = greyhoundInfo.boundsConforming; - var width = bounds[3] - bounds[0]; - var depth = bounds[4] - bounds[1]; - var height= bounds[5] - bounds[2]; - var radius = width / 2; + // TODO Unused: var width = bounds[3] - bounds[0]; + // TODO Unused: var depth = bounds[4] - bounds[1]; + // TODO Unused: var height = bounds[5] - bounds[2]; + // TODO Unused: var radius = width / 2; + var scale = greyhoundInfo.scale || 0.01; + if (Array.isArray(scale)) { + scale = Math.min(scale[0], scale[1], scale[2]); + } - var scale = greyhoundInfo.scale; - var scale = greyhoundInfo.scale || .01; - if (Array.isArray(scale)) { - scale = Math.min(scale[0], scale[1], scale[2]); - } + if (GreyhoundUtils.getQueryParam('scale')) { + scale = parseFloat(GreyhoundUtils.getQueryParam('scale')); + } - if (GreyhoundUtils.getQueryParam('scale')) { - scale = parseFloat(GreyhoundUtils.getQueryParam('scale')); - } + var baseDepth = Math.max(8, greyhoundInfo.baseDepth); - var baseDepth = Math.max(8, greyhoundInfo.baseDepth); + // Ideally we want to change this bit completely, since + // greyhound's options are wider than the default options for + // visualizing pointclouds. If someone ever has time to build a + // custom ui element for greyhound, the schema options from + // this info request should be given to the UI, so the user can + // choose between them. The selected option can then be + // directly requested from the server in the + // PointCloudGreyhoundGeometryNode without asking for + // attributes that we are not currently visualizing. We assume + // XYZ are always available. + var attributes = ['POSITION_CARTESIAN']; - // Ideally we want to change this bit completely, since - // greyhound's options are wider than the default options for - // visualizing pointclouds. If someone ever has time to build a - // custom ui element for greyhound, the schema options from - // this info request should be given to the UI, so the user can - // choose between them. The selected option can then be - // directly requested from the server in the - // PointCloudGreyhoundGeometryNode without asking for - // attributes that we are not currently visualizing. We assume - // XYZ are always available. - var attributes = ['POSITION_CARTESIAN']; + // To be careful, we only add COLOR_PACKED as an option if all + // colors are actually found. + var red = false; + var green = false; + var blue = false; - // To be careful, we only add COLOR_PACKED as an option if all - // colors are actually found. - var red = false, green = false, blue = false; + greyhoundInfo.schema.forEach(function (entry) { + // Intensity and Classification are optional. + if (entry.name === 'Intensity') { + attributes.push('INTENSITY'); + } + if (entry.name === 'Classification') { + attributes.push('CLASSIFICATION'); + } - greyhoundInfo.schema.forEach(function(entry) { - // Intensity and Classification are optional. - if (entry.name === 'Intensity') { - attributes.push('INTENSITY'); - } - if (entry.name === 'Classification') { - attributes.push('CLASSIFICATION'); - } + if (entry.name === 'Red') red = true; + else if (entry.name === 'Green') green = true; + else if (entry.name === 'Blue') blue = true; + }); - if (entry.name === 'Red') red = true; - else if (entry.name === 'Green') green = true; - else if (entry.name === 'Blue') blue = true; - }); + if (red && green && blue) attributes.push('COLOR_PACKED'); - if (red && green && blue) attributes.push('COLOR_PACKED'); + // Fill in geometry fields. + var pgg = new Potree.PointCloudGreyhoundGeometry(); + pgg.serverURL = serverURL; + pgg.spacing = (bounds[3] - bounds[0]) / Math.pow(2, baseDepth); + pgg.baseDepth = baseDepth; + pgg.hierarchyStepSize = HIERARCHY_STEP_SIZE; - // Fill in geometry fields. - var pgg = new Potree.PointCloudGreyhoundGeometry(); - pgg.serverURL = serverURL; - pgg.spacing = (bounds[3] - bounds[0]) / Math.pow(2, baseDepth); - pgg.baseDepth = baseDepth; - pgg.hierarchyStepSize = HIERARCHY_STEP_SIZE; + pgg.schema = GreyhoundUtils.createSchema(attributes); + var pointSize = GreyhoundUtils.pointSizeFrom(pgg.schema); - pgg.schema = GreyhoundUtils.createSchema(attributes); - var pointSize = GreyhoundUtils.pointSizeFrom(pgg.schema); + pgg.pointAttributes = new Potree.PointAttributes(attributes); + pgg.pointAttributes.byteSize = pointSize; - pgg.pointAttributes = new Potree.PointAttributes(attributes); - pgg.pointAttributes.byteSize = pointSize; + var boundingBox = new THREE.Box3( + new THREE.Vector3().fromArray(bounds, 0), + new THREE.Vector3().fromArray(bounds, 3) + ); - var boundingBox = new THREE.Box3( - new THREE.Vector3().fromArray(bounds, 0), - new THREE.Vector3().fromArray(bounds, 3)); + var offset = boundingBox.min.clone(); - var offset = boundingBox.min.clone(); + boundingBox.max.sub(boundingBox.min); + boundingBox.min.set(0, 0, 0); - boundingBox.max.sub(boundingBox.min); - boundingBox.min.set(0, 0, 0); + pgg.projection = greyhoundInfo.srs; + pgg.boundingBox = boundingBox; + pgg.boundingSphere = boundingBox.getBoundingSphere(); - pgg.projection = greyhoundInfo.srs; - pgg.boundingBox = boundingBox; - pgg.boundingSphere = boundingBox.getBoundingSphere(); + pgg.scale = scale; + pgg.offset = offset; - pgg.scale = scale; - pgg.offset = offset; + console.log('Scale:', scale); + console.log('Offset:', offset); + console.log('Bounds:', boundingBox); - console.log('Scale:', scale); - console.log('Offset:', offset); - console.log('Bounds:', boundingBox); + pgg.loader = new Potree.GreyhoundBinaryLoader(version, boundingBox, pgg.scale); - pgg.loader = new Potree.GreyhoundBinaryLoader( - version, boundingBox, pgg.scale); + var nodes = {}; - var nodes = {}; + { // load root + var name = 'r'; - { // load root - var name = "r"; + var root = new Potree.PointCloudGreyhoundGeometryNode( + name, pgg, boundingBox, + scale, offset + ); - var root = new Potree.PointCloudGreyhoundGeometryNode( - name, pgg, boundingBox, - scale, offset); + root.level = 0; + root.hasChildren = true; + root.numPoints = greyhoundInfo.numPoints; + root.spacing = pgg.spacing; + pgg.root = root; + pgg.root.load(); + nodes[name] = root; + } - root.level = 0; - root.hasChildren = true; - root.numPoints = greyhoundInfo.numPoints; - root.spacing = pgg.spacing; - pgg.root = root; - pgg.root.load(); - nodes[name] = root; - } + pgg.nodes = nodes; - pgg.nodes = nodes; + GreyhoundUtils.getNormalization(serverURL, greyhoundInfo.baseDepth, + function (_, normalize) { + if (normalize.color) pgg.normalize.color = true; + if (normalize.intensity) pgg.normalize.intensity = true; - GreyhoundUtils.getNormalization(serverURL, greyhoundInfo.baseDepth, - function(err, normalize) { - if (normalize.color) pgg.normalize.color = true; - if (normalize.intensity) pgg.normalize.intensity = true; - - callback(pgg); - }); - }); - } - catch(e) { + callback(pgg); + } + ); + }); + } catch (e) { console.log("loading failed: '" + url + "'"); console.log(e); @@ -303,11 +299,11 @@ Potree.GreyhoundLoader.load = function load(url, callback) { } }; -Potree.GreyhoundLoader.loadPointAttributes = function(mno){ +Potree.GreyhoundLoader.loadPointAttributes = function (mno) { var fpa = mno.pointAttributes; var pa = new Potree.PointAttributes(); - for(var i = 0; i < fpa.length; i++){ + for (var i = 0; i < fpa.length; i++) { var pointAttribute = Potree.PointAttribute[fpa[i]]; pa.add(pointAttribute); } @@ -315,9 +311,7 @@ Potree.GreyhoundLoader.loadPointAttributes = function(mno){ return pa; }; - -Potree.GreyhoundLoader.createChildAABB = function(aabb, childIndex){ - var V3 = THREE.Vector3; +Potree.GreyhoundLoader.createChildAABB = function (aabb, childIndex) { var min = aabb.min; var max = aabb.max; var dHalfLength = new THREE.Vector3().copy(max).sub(min).multiplyScalar(0.5); @@ -328,29 +322,28 @@ Potree.GreyhoundLoader.createChildAABB = function(aabb, childIndex){ var cmin = min; var cmax = new THREE.Vector3().add(min).add(dHalfLength); - var min, max; if (childIndex === 1) { min = new THREE.Vector3().copy(cmin).add(zHalfLength); max = new THREE.Vector3().copy(cmax).add(zHalfLength); - }else if (childIndex === 3) { + } else if (childIndex === 3) { min = new THREE.Vector3().copy(cmin).add(zHalfLength).add(yHalfLength); max = new THREE.Vector3().copy(cmax).add(zHalfLength).add(yHalfLength); - }else if (childIndex === 0) { + } else if (childIndex === 0) { min = cmin; max = cmax; - }else if (childIndex === 2) { + } else if (childIndex === 2) { min = new THREE.Vector3().copy(cmin).add(yHalfLength); max = new THREE.Vector3().copy(cmax).add(yHalfLength); - }else if (childIndex === 5) { + } else if (childIndex === 5) { min = new THREE.Vector3().copy(cmin).add(zHalfLength).add(xHalfLength); max = new THREE.Vector3().copy(cmax).add(zHalfLength).add(xHalfLength); - }else if (childIndex === 7) { + } else if (childIndex === 7) { min = new THREE.Vector3().copy(cmin).add(dHalfLength); max = new THREE.Vector3().copy(cmax).add(dHalfLength); - }else if (childIndex === 4) { + } else if (childIndex === 4) { min = new THREE.Vector3().copy(cmin).add(xHalfLength); max = new THREE.Vector3().copy(cmax).add(xHalfLength); - }else if (childIndex === 6) { + } else if (childIndex === 6) { min = new THREE.Vector3().copy(cmin).add(xHalfLength).add(yHalfLength); max = new THREE.Vector3().copy(cmax).add(xHalfLength).add(yHalfLength); } diff --git a/src/loader/LasLazLoader.js b/src/loader/LasLazLoader.js index 6abc20a9..97fa1d1b 100644 --- a/src/loader/LasLazLoader.js +++ b/src/loader/LasLazLoader.js @@ -7,100 +7,97 @@ * Thanks to Uday Verma and Howard Butler * */ - -Potree.LasLazLoader = class LasLazLoader{ - - constructor(version){ - if(typeof(version) === "string"){ + +Potree.LasLazLoader = class LasLazLoader { + constructor (version) { + if (typeof (version) === 'string') { this.version = new Potree.Version(version); - }else{ + } else { this.version = version; } } - - static progressCB(){ - + + static progressCB () { } - - load(node){ - - if(node.loaded){ + + load (node) { + if (node.loaded) { return; } - + let pointAttributes = node.pcoGeometry.pointAttributes; let url = node.getURL(); - - if(this.version.equalOrHigher("1.4")){ - url += "." + pointAttributes.toLowerCase(); + + if (this.version.equalOrHigher('1.4')) { + url += '.' + pointAttributes.toLowerCase(); } - + let scope = this; - + let xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.overrideMimeType('text/plain; charset=x-user-defined'); - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { let buffer = xhr.response; scope.parse(node, buffer); } else { - console.log('Failed to load file! HTTP status: ' + xhr.status + ", file: " + url); + console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + url); } } }; - + xhr.send(null); } - - parse(node, buffer){ + + parse (node, buffer) { let lf = new LASFile(buffer); let handler = new Potree.LasLazBatcher(node); - - return Promise.resolve(lf).cancellable().then(function(lf) { - return lf.open().then(function() { - lf.isOpen = true; - return lf; - }) - .catch(Promise.CancellationError, function(e) { - // open message was sent at this point, but then handler was not called - // because the operation was cancelled, explicitly close the file - return lf.close().then(function() { - throw e; + + return Promise.resolve(lf).cancellable().then(function (lf) { + return lf.open() + .then(function () { + lf.isOpen = true; + return lf; + }) + .catch(Promise.CancellationError, function (e) { + // open message was sent at this point, but then handler was not called + // because the operation was cancelled, explicitly close the file + return lf.close().then(function () { + throw e; + }); }); - }); - }).then(function(lf) { - return lf.getHeader().then(function(h) { + }).then(function (lf) { + return lf.getHeader().then(function (h) { return [lf, h]; }); - }).then(function(v) { + }).then(function (v) { let lf = v[0]; let header = v[1]; - + let skip = 1; let totalRead = 0; let totalToRead = (skip <= 1 ? header.pointsCount : header.pointsCount / skip); - let reader = function() { + let reader = function () { let p = lf.readData(1000000, 0, skip); - return p.then(function(data) { + return p.then(function (data) { handler.push(new LASDecoder(data.buffer, - header.pointsFormatId, - header.pointsStructSize, - data.count, - header.scale, - header.offset, - header.mins, header.maxs)); + header.pointsFormatId, + header.pointsStructSize, + data.count, + header.scale, + header.offset, + header.mins, header.maxs)); totalRead += data.count; Potree.LasLazLoader.progressCB(totalRead / totalToRead); - if (data.hasMoreData) + if (data.hasMoreData) { return reader(); - else { - + } else { header.totalRead = totalRead; header.versionAsString = lf.versionAsString; header.isCompressed = lf.isCompressed; @@ -108,62 +105,63 @@ Potree.LasLazLoader = class LasLazLoader{ } }); }; - + return reader(); - }).then(function(v) { + }).then(function (v) { let lf = v[0]; // we're done loading this file // Potree.LasLazLoader.progressCB(1); // Close it - return lf.close().then(function() { + return lf.close().then(function () { lf.isOpen = false; // Delay this a bit so that the user sees 100% completion // return Promise.delay(200).cancellable(); - }).then(function() { + }).then(function () { // trim off the first element (our LASFile which we don't really want to pass to the user) // return v.slice(1); }); - }).catch(Promise.CancellationError, function(e) { + }).catch(Promise.CancellationError, function (e) { // If there was a cancellation, make sure the file is closed, if the file is open // close and then fail - if (lf.isOpen) - return lf.close().then(function() { + if (lf.isOpen) { + return lf.close().then(function () { lf.isOpen = false; throw e; }); + } throw e; }); } - - handle(node, url){ - + + handle (node, url) { + } - }; -Potree.LasLazBatcher = class LasLazBatcher{ - - constructor(node){ +Potree.LasLazBatcher = class LasLazBatcher { + constructor (node) { this.node = node; } - - push(lasBuffer){ - - let workerPath = Potree.scriptPath + "/workers/LASDecoderWorker.js"; + + push (lasBuffer) { + let workerPath = Potree.scriptPath + '/workers/LASDecoderWorker.js'; let worker = Potree.workerPool.getWorker(workerPath); - + worker.onmessage = (e) => { let geometry = new THREE.BufferGeometry(); let numPoints = lasBuffer.pointsCount; - - let endsWith = function(str, suffix) { + + /* + TODO Unused: + let endsWith = function (str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; }; - + */ + let positions = e.data.position; let colors = new Uint8Array(e.data.color); let intensities = e.data.intensity; @@ -171,16 +169,16 @@ Potree.LasLazBatcher = class LasLazBatcher{ let returnNumbers = new Uint8Array(e.data.returnNumber); let numberOfReturns = new Uint8Array(e.data.numberOfReturns); let pointSourceIDs = new Uint16Array(e.data.pointSourceID); - //let indices = new ArrayBuffer(numPoints*4); - //let iIndices = new Uint32Array(indices); - - //let box = new THREE.Box3(); + // let indices = new ArrayBuffer(numPoints*4); + // let iIndices = new Uint32Array(indices); + + // let box = new THREE.Box3(); // - //let fPositions = new Float32Array(positions); - //for(let i = 0; i < numPoints; i++){ + // let fPositions = new Float32Array(positions); + // for(let i = 0; i < numPoints; i++){ // box.expandByPoint(new THREE.Vector3(fPositions[3*i+0], fPositions[3*i+1], fPositions[3*i+2])); - //} - + // } + geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), 3)); geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true)); geometry.addAttribute('intensity', new THREE.BufferAttribute(new Float32Array(intensities), 1)); @@ -188,29 +186,29 @@ Potree.LasLazBatcher = class LasLazBatcher{ geometry.addAttribute('returnNumber', new THREE.BufferAttribute(returnNumbers, 1)); geometry.addAttribute('numberOfReturns', new THREE.BufferAttribute(numberOfReturns, 1)); geometry.addAttribute('pointSourceID', new THREE.BufferAttribute(pointSourceIDs, 1)); - geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3)); - + geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(numPoints * 3), 3)); + let indicesAttribute = new THREE.Uint8BufferAttribute(e.data.indices, 4); indicesAttribute.normalized = true; - geometry.addAttribute("indices", indicesAttribute); - + geometry.addAttribute('indices', indicesAttribute); + let tightBoundingBox = new THREE.Box3( new THREE.Vector3().fromArray(e.data.tightBoundingBox.min), new THREE.Vector3().fromArray(e.data.tightBoundingBox.max) ); - + geometry.boundingBox = this.node.boundingBox; this.node.tightBoundingBox = tightBoundingBox; - + this.node.geometry = geometry; this.node.loaded = true; this.node.loading = false; this.node.pcoGeometry.numNodesLoading--; this.node.mean = new THREE.Vector3(...e.data.mean); - + Potree.workerPool.returnWorker(workerPath, worker); }; - + let message = { buffer: lasBuffer.arrayb, numPoints: lasBuffer.pointsCount, @@ -223,4 +221,4 @@ Potree.LasLazBatcher = class LasLazBatcher{ }; worker.postMessage(message, [message.buffer]); }; -}; \ No newline at end of file +}; diff --git a/src/loader/POCLoader.js b/src/loader/POCLoader.js index a6fbe82f..7e7d1297 100644 --- a/src/loader/POCLoader.js +++ b/src/loader/POCLoader.js @@ -1,110 +1,109 @@ - /** * @class Loads mno files and returns a PointcloudOctree * for a description of the mno binary file format, read mnoFileFormat.txt - * + * * @author Markus Schuetz */ -Potree.POCLoader = function(){ - +Potree.POCLoader = function () { + }; - + /** - * @return a point cloud octree with the root node data loaded. + * @return a point cloud octree with the root node data loaded. * loading of descendants happens asynchronously when they're needed - * + * * @param url * @param loadingFinishedListener executed after loading the binary has been finished */ -Potree.POCLoader.load = function load(url, callback) { - try{ +Potree.POCLoader.load = function load (url, callback) { + try { let pco = new Potree.PointCloudOctreeGeometry(); pco.url = url; let xhr = new XMLHttpRequest(); xhr.open('GET', url, true); - - xhr.onreadystatechange = function(){ - if(xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)){ + + xhr.onreadystatechange = function () { + if (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)) { let fMno = JSON.parse(xhr.responseText); - + let version = new Potree.Version(fMno.version); - + // assume octreeDir is absolute if it starts with http - if(fMno.octreeDir.indexOf("http") === 0){ + if (fMno.octreeDir.indexOf('http') === 0) { pco.octreeDir = fMno.octreeDir; - }else{ - pco.octreeDir = url + "/../" + fMno.octreeDir; + } else { + pco.octreeDir = url + '/../' + fMno.octreeDir; } - + pco.spacing = fMno.spacing; pco.hierarchyStepSize = fMno.hierarchyStepSize; pco.pointAttributes = fMno.pointAttributes; - + let min = new THREE.Vector3(fMno.boundingBox.lx, fMno.boundingBox.ly, fMno.boundingBox.lz); let max = new THREE.Vector3(fMno.boundingBox.ux, fMno.boundingBox.uy, fMno.boundingBox.uz); let boundingBox = new THREE.Box3(min, max); let tightBoundingBox = boundingBox.clone(); - - if(fMno.tightBoundingBox){ + + if (fMno.tightBoundingBox) { tightBoundingBox.min.copy(new THREE.Vector3(fMno.tightBoundingBox.lx, fMno.tightBoundingBox.ly, fMno.tightBoundingBox.lz)); tightBoundingBox.max.copy(new THREE.Vector3(fMno.tightBoundingBox.ux, fMno.tightBoundingBox.uy, fMno.tightBoundingBox.uz)); } let offset = min.clone(); - + boundingBox.min.sub(offset); boundingBox.max.sub(offset); - + tightBoundingBox.min.sub(offset); tightBoundingBox.max.sub(offset); - + pco.projection = fMno.projection; pco.boundingBox = boundingBox; pco.tightBoundingBox = tightBoundingBox; pco.boundingSphere = boundingBox.getBoundingSphere(); pco.tightBoundingSphere = tightBoundingBox.getBoundingSphere(); pco.offset = offset; - if(fMno.pointAttributes === "LAS"){ + if (fMno.pointAttributes === 'LAS') { pco.loader = new Potree.LasLazLoader(fMno.version); - }else if(fMno.pointAttributes === "LAZ"){ + } else if (fMno.pointAttributes === 'LAZ') { pco.loader = new Potree.LasLazLoader(fMno.version); - }else{ + } else { pco.loader = new Potree.BinaryLoader(fMno.version, boundingBox, fMno.scale); pco.pointAttributes = new Potree.PointAttributes(pco.pointAttributes); } - + let nodes = {}; - + { // load root - let name = "r"; - + let name = 'r'; + let root = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox); root.level = 0; root.hasChildren = true; root.spacing = pco.spacing; - if(version.upTo("1.5")){ + if (version.upTo('1.5')) { root.numPoints = fMno.hierarchy[0][1]; - }else{ + } else { root.numPoints = 0; } pco.root = root; pco.root.load(); nodes[name] = root; } - + // load remaining hierarchy - if(version.upTo("1.4")){ - for( let i = 1; i < fMno.hierarchy.length; i++){ + if (version.upTo('1.4')) { + for (let i = 1; i < fMno.hierarchy.length; i++) { let name = fMno.hierarchy[i][0]; let numPoints = fMno.hierarchy[i][1]; - let index = parseInt(name.charAt(name.length-1)); - let parentName = name.substring(0, name.length-1); + let index = parseInt(name.charAt(name.length - 1)); + let parentName = name.substring(0, name.length - 1); let parentNode = nodes[parentName]; - let level = name.length-1; + let level = name.length - 1; let boundingBox = Potree.POCLoader.createChildAABB(parentNode.boundingBox, index); - + let node = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox); node.level = level; node.numPoints = numPoints; @@ -113,61 +112,56 @@ Potree.POCLoader.load = function load(url, callback) { nodes[name] = node; } } - + pco.nodes = nodes; - + callback(pco); } }; - + xhr.send(null); - }catch(e){ + } catch (e) { console.log("loading failed: '" + url + "'"); console.log(e); - + callback(); } }; -Potree.POCLoader.loadPointAttributes = function(mno){ - +Potree.POCLoader.loadPointAttributes = function (mno) { let fpa = mno.pointAttributes; let pa = new Potree.PointAttributes(); - - for(let i = 0; i < fpa.length; i++){ + + for (let i = 0; i < fpa.length; i++) { let pointAttribute = Potree.PointAttribute[fpa[i]]; pa.add(pointAttribute); - } - + } + return pa; }; - -Potree.POCLoader.createChildAABB = function(aabb, index){ - +Potree.POCLoader.createChildAABB = function (aabb, index) { let min = aabb.min.clone(); let max = aabb.max.clone(); let size = new THREE.Vector3().subVectors(max, min); - - if((index & 0b0001) > 0){ + + if ((index & 0b0001) > 0) { min.z += size.z / 2; - }else{ + } else { max.z -= size.z / 2; } - - if((index & 0b0010) > 0){ + + if ((index & 0b0010) > 0) { min.y += size.y / 2; - }else{ + } else { max.y -= size.y / 2; } - - if((index & 0b0100) > 0){ + + if ((index & 0b0100) > 0) { min.x += size.x / 2; - }else{ + } else { max.x -= size.x / 2; } - + return new THREE.Box3(min, max); }; - - diff --git a/src/loader/PointAttributes.js b/src/loader/PointAttributes.js index bb1c4325..bee0e4bc 100644 --- a/src/loader/PointAttributes.js +++ b/src/loader/PointAttributes.js @@ -19,20 +19,20 @@ Potree.PointAttributeNames.NORMAL = 10; * @class */ Potree.PointAttributeTypes = { - DATA_TYPE_DOUBLE : {ordinal : 0, size: 8}, - DATA_TYPE_FLOAT : {ordinal : 1, size: 4}, - DATA_TYPE_INT8 : {ordinal : 2, size: 1}, - DATA_TYPE_UINT8 : {ordinal : 3, size: 1}, - DATA_TYPE_INT16 : {ordinal : 4, size: 2}, - DATA_TYPE_UINT16 : {ordinal : 5, size: 2}, - DATA_TYPE_INT32 : {ordinal : 6, size: 4}, - DATA_TYPE_UINT32 : {ordinal : 7, size: 4}, - DATA_TYPE_INT64 : {ordinal : 8, size: 8}, - DATA_TYPE_UINT64 : {ordinal : 9, size: 8} + DATA_TYPE_DOUBLE: {ordinal: 0, size: 8}, + DATA_TYPE_FLOAT: {ordinal: 1, size: 4}, + DATA_TYPE_INT8: {ordinal: 2, size: 1}, + DATA_TYPE_UINT8: {ordinal: 3, size: 1}, + DATA_TYPE_INT16: {ordinal: 4, size: 2}, + DATA_TYPE_UINT16: {ordinal: 5, size: 2}, + DATA_TYPE_INT32: {ordinal: 6, size: 4}, + DATA_TYPE_UINT32: {ordinal: 7, size: 4}, + DATA_TYPE_INT64: {ordinal: 8, size: 8}, + DATA_TYPE_UINT64: {ordinal: 9, size: 8} }; var i = 0; -for(var obj in Potree.PointAttributeTypes){ +for (var obj in Potree.PointAttributeTypes) { Potree.PointAttributeTypes[i] = Potree.PointAttributeTypes[obj]; i++; } @@ -46,7 +46,7 @@ for(var obj in Potree.PointAttributeTypes){ * @param size * @returns */ -Potree.PointAttribute = function(name, type, numElements){ +Potree.PointAttribute = function (name, type, numElements) { this.name = name; this.type = type; this.numElements = numElements; @@ -54,46 +54,46 @@ Potree.PointAttribute = function(name, type, numElements){ }; Potree.PointAttribute.POSITION_CARTESIAN = new Potree.PointAttribute( - Potree.PointAttributeNames.POSITION_CARTESIAN, - Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3); + Potree.PointAttributeNames.POSITION_CARTESIAN, + Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3); Potree.PointAttribute.RGBA_PACKED = new Potree.PointAttribute( - Potree.PointAttributeNames.COLOR_PACKED, - Potree.PointAttributeTypes.DATA_TYPE_INT8, 4); + Potree.PointAttributeNames.COLOR_PACKED, + Potree.PointAttributeTypes.DATA_TYPE_INT8, 4); Potree.PointAttribute.COLOR_PACKED = Potree.PointAttribute.RGBA_PACKED; Potree.PointAttribute.RGB_PACKED = new Potree.PointAttribute( - Potree.PointAttributeNames.COLOR_PACKED, - Potree.PointAttributeTypes.DATA_TYPE_INT8, 3); + Potree.PointAttributeNames.COLOR_PACKED, + Potree.PointAttributeTypes.DATA_TYPE_INT8, 3); Potree.PointAttribute.NORMAL_FLOATS = new Potree.PointAttribute( - Potree.PointAttributeNames.NORMAL_FLOATS, - Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3); + Potree.PointAttributeNames.NORMAL_FLOATS, + Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3); Potree.PointAttribute.FILLER_1B = new Potree.PointAttribute( - Potree.PointAttributeNames.FILLER, - Potree.PointAttributeTypes.DATA_TYPE_UINT8, 1); + Potree.PointAttributeNames.FILLER, + Potree.PointAttributeTypes.DATA_TYPE_UINT8, 1); Potree.PointAttribute.INTENSITY = new Potree.PointAttribute( - Potree.PointAttributeNames.INTENSITY, - Potree.PointAttributeTypes.DATA_TYPE_UINT16, 1); + Potree.PointAttributeNames.INTENSITY, + Potree.PointAttributeTypes.DATA_TYPE_UINT16, 1); Potree.PointAttribute.CLASSIFICATION = new Potree.PointAttribute( - Potree.PointAttributeNames.CLASSIFICATION, - Potree.PointAttributeTypes.DATA_TYPE_UINT8, 1); + Potree.PointAttributeNames.CLASSIFICATION, + Potree.PointAttributeTypes.DATA_TYPE_UINT8, 1); Potree.PointAttribute.NORMAL_SPHEREMAPPED = new Potree.PointAttribute( - Potree.PointAttributeNames.NORMAL_SPHEREMAPPED, - Potree.PointAttributeTypes.DATA_TYPE_UINT8, 2); + Potree.PointAttributeNames.NORMAL_SPHEREMAPPED, + Potree.PointAttributeTypes.DATA_TYPE_UINT8, 2); Potree.PointAttribute.NORMAL_OCT16 = new Potree.PointAttribute( - Potree.PointAttributeNames.NORMAL_OCT16, - Potree.PointAttributeTypes.DATA_TYPE_UINT8, 2); + Potree.PointAttributeNames.NORMAL_OCT16, + Potree.PointAttributeTypes.DATA_TYPE_UINT8, 2); Potree.PointAttribute.NORMAL = new Potree.PointAttribute( - Potree.PointAttributeNames.NORMAL, - Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3); + Potree.PointAttributeNames.NORMAL, + Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3); /** * Ordered list of PointAttributes used to identify how points are aligned in a buffer. @@ -101,13 +101,13 @@ Potree.PointAttribute.NORMAL = new Potree.PointAttribute( * @class * */ -Potree.PointAttributes = function(pointAttributes){ +Potree.PointAttributes = function (pointAttributes) { this.attributes = []; this.byteSize = 0; this.size = 0; - if(pointAttributes != null){ - for(var i = 0; i < pointAttributes.length; i++){ + if (pointAttributes != null) { + for (var i = 0; i < pointAttributes.length; i++) { var pointAttributeName = pointAttributes[i]; var pointAttribute = Potree.PointAttribute[pointAttributeName]; this.attributes.push(pointAttribute); @@ -117,16 +117,16 @@ Potree.PointAttributes = function(pointAttributes){ } }; -Potree.PointAttributes.prototype.add = function(pointAttribute){ +Potree.PointAttributes.prototype.add = function (pointAttribute) { this.attributes.push(pointAttribute); this.byteSize += pointAttribute.byteSize; this.size++; }; -Potree.PointAttributes.prototype.hasColors = function(){ - for(var name in this.attributes){ +Potree.PointAttributes.prototype.hasColors = function () { + for (var name in this.attributes) { var pointAttribute = this.attributes[name]; - if(pointAttribute.name === Potree.PointAttributeNames.COLOR_PACKED){ + if (pointAttribute.name === Potree.PointAttributeNames.COLOR_PACKED) { return true; } } @@ -134,14 +134,14 @@ Potree.PointAttributes.prototype.hasColors = function(){ return false; }; -Potree.PointAttributes.prototype.hasNormals = function(){ - for(var name in this.attributes){ +Potree.PointAttributes.prototype.hasNormals = function () { + for (var name in this.attributes) { var pointAttribute = this.attributes[name]; - if( + if ( pointAttribute === Potree.PointAttribute.NORMAL_SPHEREMAPPED || pointAttribute === Potree.PointAttribute.NORMAL_FLOATS || pointAttribute === Potree.PointAttribute.NORMAL || - pointAttribute === Potree.PointAttribute.NORMAL_OCT16){ + pointAttribute === Potree.PointAttribute.NORMAL_OCT16) { return true; } } diff --git a/src/materials/BlurMaterial.js b/src/materials/BlurMaterial.js index fe734a46..307e2940 100644 --- a/src/materials/BlurMaterial.js +++ b/src/materials/BlurMaterial.js @@ -1,37 +1,24 @@ // see http://john-chapman-graphics.blogspot.co.at/2013/01/ssao-tutorial.html - - -Potree.BlurMaterial = function(parameters){ - THREE.Material.call( this ); +Potree.BlurMaterial = function (parameters) { + THREE.Material.call(this); parameters = parameters || {}; - + var uniforms = { - near: { type: "f", value: 0 }, - far: { type: "f", value: 0 }, - screenWidth: { type: "f", value: 0 }, - screenHeight: { type: "f", value: 0 }, - map: { type: "t", value: null } + near: { type: 'f', value: 0 }, + far: { type: 'f', value: 0 }, + screenWidth: { type: 'f', value: 0 }, + screenHeight: { type: 'f', value: 0 }, + map: { type: 't', value: null } }; - + this.setValues({ uniforms: uniforms, - vertexShader: Potree.Shaders["blur.vs"], - fragmentShader: Potree.Shaders["blur.fs"], + vertexShader: Potree.Shaders['blur.vs'], + fragmentShader: Potree.Shaders['blur.fs'] }); - }; - Potree.BlurMaterial.prototype = new THREE.ShaderMaterial(); - - - - - - - - - diff --git a/src/materials/EyeDomeLightingMaterial.js b/src/materials/EyeDomeLightingMaterial.js index 82009c5a..d6c8207f 100644 --- a/src/materials/EyeDomeLightingMaterial.js +++ b/src/materials/EyeDomeLightingMaterial.js @@ -8,109 +8,95 @@ // http://www.kitware.com/source/home/post/9 // https://tel.archives-ouvertes.fr/tel-00438464/document p. 115+ (french) - - - -Potree.EyeDomeLightingMaterial = function(parameters){ - THREE.Material.call( this ); +Potree.EyeDomeLightingMaterial = function (parameters) { + THREE.Material.call(this); parameters = parameters || {}; - + this._neighbourCount = 4; - this.neighbours = new Float32Array(this.neighbourCount*2); - for(var c = 0; c < this.neighbourCount; c++){ - this.neighbours[2*c+0] = Math.cos(2 * c * Math.PI / this.neighbourCount); - this.neighbours[2*c+1] = Math.sin(2 * c * Math.PI / this.neighbourCount); + this.neighbours = new Float32Array(this.neighbourCount * 2); + for (var c = 0; c < this.neighbourCount; c++) { + this.neighbours[2 * c + 0] = Math.cos(2 * c * Math.PI / this.neighbourCount); + this.neighbours[2 * c + 1] = Math.sin(2 * c * Math.PI / this.neighbourCount); } - - //var lightDir = new THREE.Vector3(0.0, 0.0, 1.0).normalize(); - + + // var lightDir = new THREE.Vector3(0.0, 0.0, 1.0).normalize(); + var uniforms = { - screenWidth: { type: "f", value: 0 }, - screenHeight: { type: "f", value: 0 }, - edlStrength: { type: "f", value: 1.0 }, - radius: { type: "f", value: 1.0 }, - neighbours: { type: "2fv", value: this.neighbours }, - depthMap: { type: "t", value: null }, - colorMap: { type: "t", value: null }, - opacity: { type: "f", value: 1.0} + screenWidth: { type: 'f', value: 0 }, + screenHeight: { type: 'f', value: 0 }, + edlStrength: { type: 'f', value: 1.0 }, + radius: { type: 'f', value: 1.0 }, + neighbours: { type: '2fv', value: this.neighbours }, + depthMap: { type: 't', value: null }, + colorMap: { type: 't', value: null }, + opacity: { type: 'f', value: 1.0 } }; - + this.setValues({ uniforms: uniforms, - vertexShader: this.getDefines() + Potree.Shaders["edl.vs"], - fragmentShader: this.getDefines() + Potree.Shaders["edl.fs"], + vertexShader: this.getDefines() + Potree.Shaders['edl.vs'], + fragmentShader: this.getDefines() + Potree.Shaders['edl.fs'], lights: false }); - }; - Potree.EyeDomeLightingMaterial.prototype = new THREE.ShaderMaterial(); +Potree.EyeDomeLightingMaterial.prototype.getDefines = function () { + var defines = ''; -Potree.EyeDomeLightingMaterial.prototype.getDefines = function(){ - var defines = ""; - - defines += "#define NEIGHBOUR_COUNT " + this.neighbourCount + "\n"; + defines += '#define NEIGHBOUR_COUNT ' + this.neighbourCount + '\n'; return defines; }; -Potree.EyeDomeLightingMaterial.prototype.updateShaderSource = function(){ +Potree.EyeDomeLightingMaterial.prototype.updateShaderSource = function () { var attributes = {}; - + let PC = Potree.PointColorType; - - if([PC.INTENSITY, PC.INTENSITY_GRADIENT].includes(this.pointColorType)){ - attributes.intensity = { type: "f", value: [] }; - }else if(this.pointColorType === PC.CLASSIFICATION){ - //attributes.classification = { type: "f", value: [] }; - }else if(this.pointColorType === PC.RETURN_NUMBER){ - attributes.returnNumber = { type: "f", value: [] }; - attributes.numberOfReturns = { type: "f", value: [] }; - }else if(this.pointColorType === PC.SOURCE){ - attributes.pointSourceID = { type: "f", value: [] }; - }else if(this.pointColorType === PC.NORMAL || this.pointColorType === Potree.PointColorType.PHONG){ - attributes.normal = { type: "f", value: [] }; + + if ([PC.INTENSITY, PC.INTENSITY_GRADIENT].includes(this.pointColorType)) { + attributes.intensity = { type: 'f', value: [] }; + } else if (this.pointColorType === PC.CLASSIFICATION) { + // attributes.classification = { type: "f", value: [] }; + } else if (this.pointColorType === PC.RETURN_NUMBER) { + attributes.returnNumber = { type: 'f', value: [] }; + attributes.numberOfReturns = { type: 'f', value: [] }; + } else if (this.pointColorType === PC.SOURCE) { + attributes.pointSourceID = { type: 'f', value: [] }; + } else if (this.pointColorType === PC.NORMAL || this.pointColorType === Potree.PointColorType.PHONG) { + attributes.normal = { type: 'f', value: [] }; } - attributes.classification = { type: "f", value: 0 }; - - var vs = this.getDefines() + Potree.Shaders["edl.vs"]; - var fs = this.getDefines() + Potree.Shaders["edl.fs"]; + attributes.classification = { type: 'f', value: 0 }; + + var vs = this.getDefines() + Potree.Shaders['edl.vs']; + var fs = this.getDefines() + Potree.Shaders['edl.fs']; this.setValues({ vertexShader: vs, fragmentShader: fs }); - + this.uniforms.neighbours.value = this.neighbours; - + this.needsUpdate = true; }; -Object.defineProperty(Potree.EyeDomeLightingMaterial.prototype, "neighbourCount", { - get: function(){ +Object.defineProperty(Potree.EyeDomeLightingMaterial.prototype, 'neighbourCount', { + get: function () { return this._neighbourCount; }, - set: function(value){ - if(this._neighbourCount !== value){ + set: function (value) { + if (this._neighbourCount !== value) { this._neighbourCount = value; - this.neighbours = new Float32Array(this._neighbourCount*2); - for(var c = 0; c < this._neighbourCount; c++){ - this.neighbours[2*c+0] = Math.cos(2 * c * Math.PI / this._neighbourCount); - this.neighbours[2*c+1] = Math.sin(2 * c * Math.PI / this._neighbourCount); + this.neighbours = new Float32Array(this._neighbourCount * 2); + for (var c = 0; c < this._neighbourCount; c++) { + this.neighbours[2 * c + 0] = Math.cos(2 * c * Math.PI / this._neighbourCount); + this.neighbours[2 * c + 1] = Math.sin(2 * c * Math.PI / this._neighbourCount); } - + this.updateShaderSource(); } } }); - - - - - - - - diff --git a/src/materials/PointCloudMaterial.js b/src/materials/PointCloudMaterial.js index 00b08b5e..3ecd7e09 100644 --- a/src/materials/PointCloudMaterial.js +++ b/src/materials/PointCloudMaterial.js @@ -1,5 +1,4 @@ - // // // @@ -12,8 +11,8 @@ // to get a ready to use gradient array from a chroma.js gradient: // http://gka.github.io/chroma.js/ // -//var stops = []; -//for(let i = 0; i <= 10; i++){ +// var stops = []; +// for(let i = 0; i <= 10; i++){ // let range = chroma.scale(['yellow', 'navy']).mode('lch').domain([10,0])(i)._rgb // .slice(0, 3) // .map(v => (v / 255).toFixed(4)) @@ -22,18 +21,17 @@ // let line = `[${i / 10}, new THREE.Color(${range})],`; // // stops.push(line); -//} -//stops.join("\n"); - +// } +// stops.join("\n"); // to get a ready to use gradient array from matplotlib: -//import matplotlib.pyplot as plt -//import matplotlib.colors as colors +// import matplotlib.pyplot as plt +// import matplotlib.colors as colors // -//norm = colors.Normalize(vmin=0,vmax=1) -//cmap = plt.cm.viridis +// norm = colors.Normalize(vmin=0,vmax=1) +// cmap = plt.cm.viridis // -//for i in range(0,11): +// for i in range(0,11): // u = i / 10 // rgb = cmap(norm(u))[0:3] // rgb = ["{0:.3f}".format(v) for v in rgb] @@ -43,11 +41,11 @@ Potree.Gradients = { RAINBOW: [ [0, new THREE.Color(0.278, 0, 0.714)], - [1/6, new THREE.Color(0, 0, 1)], - [2/6, new THREE.Color(0, 1, 1)], - [3/6, new THREE.Color(0, 1, 0)], - [4/6, new THREE.Color(1, 1, 0)], - [5/6, new THREE.Color(1, 0.64, 0)], + [1 / 6, new THREE.Color(0, 0, 1)], + [2 / 6, new THREE.Color(0, 1, 1)], + [3 / 6, new THREE.Color(0, 1, 0)], + [4 / 6, new THREE.Color(1, 1, 0)], + [5 / 6, new THREE.Color(1, 0.64, 0)], [1, new THREE.Color(1, 0, 0)] ], // From chroma spectral http://gka.github.io/chroma.js/ @@ -62,7 +60,7 @@ Potree.Gradients = { [0.7, new THREE.Color(0.9922, 0.6824, 0.3804)], [0.8, new THREE.Color(0.9569, 0.4275, 0.2627)], [0.9, new THREE.Color(0.8353, 0.2431, 0.3098)], - [1, new THREE.Color(0.6196, 0.0039, 0.2588)], + [1, new THREE.Color(0.6196, 0.0039, 0.2588)] ], PLASMA: [ [0.0, new THREE.Color(0.241, 0.015, 0.610)], @@ -75,7 +73,7 @@ Potree.Gradients = { [0.7, new THREE.Color(0.963, 0.554, 0.272)], [0.8, new THREE.Color(0.992, 0.681, 0.195)], [0.9, new THREE.Color(0.987, 0.822, 0.144)], - [1.0, new THREE.Color(0.940, 0.975, 0.131)], + [1.0, new THREE.Color(0.940, 0.975, 0.131)] ], YELLOW_GREEN: [ [0, new THREE.Color(0.1647, 0.2824, 0.3451)], @@ -88,7 +86,7 @@ Potree.Gradients = { [0.7, new THREE.Color(0.4453, 0.8099, 0.5201)], [0.8, new THREE.Color(0.6102, 0.8748, 0.4850)], [0.9, new THREE.Color(0.7883, 0.9323, 0.4514)], - [1, new THREE.Color(0.9804, 0.9804, 0.4314)], + [1, new THREE.Color(0.9804, 0.9804, 0.4314)] ], VIRIDIS: [ [0.0, new THREE.Color(0.267, 0.005, 0.329)], @@ -101,7 +99,7 @@ Potree.Gradients = { [0.7, new THREE.Color(0.267, 0.749, 0.441)], [0.8, new THREE.Color(0.478, 0.821, 0.318)], [0.9, new THREE.Color(0.741, 0.873, 0.150)], - [1.0, new THREE.Color(0.993, 0.906, 0.144)], + [1.0, new THREE.Color(0.993, 0.906, 0.144)] ], INFERNO: [ [0.0, new THREE.Color(0.077, 0.042, 0.206)], @@ -114,37 +112,35 @@ Potree.Gradients = { [0.7, new THREE.Color(0.969, 0.516, 0.063)], [0.8, new THREE.Color(0.988, 0.683, 0.072)], [0.9, new THREE.Color(0.961, 0.859, 0.298)], - [1.0, new THREE.Color(0.988, 0.998, 0.645)], + [1.0, new THREE.Color(0.988, 0.998, 0.645)] ], GRAYSCALE: [ - [0, new THREE.Color(0,0,0)], - [1, new THREE.Color(1,1,1)] + [0, new THREE.Color(0, 0, 0)], + [1, new THREE.Color(1, 1, 1)] ] }; Potree.Classification = { - "DEFAULT": { - 0: new THREE.Vector4(0.5, 0.5,0.5, 1.0), - 1: new THREE.Vector4(0.5, 0.5,0.5, 1.0), - 2: new THREE.Vector4(0.63, 0.32, 0.18, 1.0), - 3: new THREE.Vector4(0.0, 1.0, 0.0, 1.0), - 4: new THREE.Vector4(0.0, 0.8, 0.0, 1.0), - 5: new THREE.Vector4(0.0, 0.6, 0.0, 1.0), - 6: new THREE.Vector4(1.0, 0.66, 0.0, 1.0), - 7: new THREE.Vector4(1.0, 0, 1.0, 1.0), - 8: new THREE.Vector4(1.0, 0, 0.0, 1.0), - 9: new THREE.Vector4(0.0, 0.0, 1.0, 1.0), - 12: new THREE.Vector4(1.0, 1.0, 0.0, 1.0), - "DEFAULT": new THREE.Vector4(0.3, 0.6, 0.6, 0.5) + 'DEFAULT': { + 0: new THREE.Vector4(0.5, 0.5, 0.5, 1.0), + 1: new THREE.Vector4(0.5, 0.5, 0.5, 1.0), + 2: new THREE.Vector4(0.63, 0.32, 0.18, 1.0), + 3: new THREE.Vector4(0.0, 1.0, 0.0, 1.0), + 4: new THREE.Vector4(0.0, 0.8, 0.0, 1.0), + 5: new THREE.Vector4(0.0, 0.6, 0.0, 1.0), + 6: new THREE.Vector4(1.0, 0.66, 0.0, 1.0), + 7: new THREE.Vector4(1.0, 0, 1.0, 1.0), + 8: new THREE.Vector4(1.0, 0, 0.0, 1.0), + 9: new THREE.Vector4(0.0, 0.0, 1.0, 1.0), + 12: new THREE.Vector4(1.0, 1.0, 0.0, 1.0), + 'DEFAULT': new THREE.Vector4(0.3, 0.6, 0.6, 0.5) } }; - - Potree.PointSizeType = { - FIXED: 0, + FIXED: 0, ATTENUATED: 1, - ADAPTIVE: 2 + ADAPTIVE: 2 }; Potree.PointShape = { @@ -154,51 +150,49 @@ Potree.PointShape = { }; Potree.PointColorType = { - RGB: 0, - COLOR: 1, - DEPTH: 2, - HEIGHT: 3, - ELEVATION: 3, - INTENSITY: 4, + RGB: 0, + COLOR: 1, + DEPTH: 2, + HEIGHT: 3, + ELEVATION: 3, + INTENSITY: 4, INTENSITY_GRADIENT: 5, - LOD: 6, - LEVEL_OF_DETAIL: 6, - POINT_INDEX: 7, - CLASSIFICATION: 8, - RETURN_NUMBER: 9, - SOURCE: 10, - NORMAL: 11, - PHONG: 12, - RGB_HEIGHT: 13, - COMPOSITE: 50 + LOD: 6, + LEVEL_OF_DETAIL: 6, + POINT_INDEX: 7, + CLASSIFICATION: 8, + RETURN_NUMBER: 9, + SOURCE: 10, + NORMAL: 11, + PHONG: 12, + RGB_HEIGHT: 13, + COMPOSITE: 50 }; Potree.ClipMode = { - DISABLED: 0, - CLIP_OUTSIDE: 1, + DISABLED: 0, + CLIP_OUTSIDE: 1, HIGHLIGHT_INSIDE: 2 }; Potree.TreeType = { - OCTREE: 0, - KDTREE: 1 + OCTREE: 0, + KDTREE: 1 }; - -Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMaterial{ - - constructor(parameters = {}){ +Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMaterial { + constructor (parameters = {}) { super(); - - this.visibleNodesTexture = Potree.utils.generateDataTexture( 2048, 1, new THREE.Color( 0xffffff ) ); + + this.visibleNodesTexture = Potree.utils.generateDataTexture(2048, 1, new THREE.Color(0xffffff)); this.visibleNodesTexture.minFilter = THREE.NearestFilter; this.visibleNodesTexture.magFilter = THREE.NearestFilter; - + let pointSize = parameters.size || 1.0; let minSize = parameters.minSize || 1.0; let maxSize = parameters.maxSize || 50.0; let treeType = parameters.treeType || Potree.TreeType.OCTREE; - + this._pointSizeType = Potree.PointSizeType.FIXED; this._shape = Potree.PointShape.SQUARE; this._pointColorType = Potree.PointColorType.RGB; @@ -215,194 +209,193 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate this.fog = false; this._treeType = treeType; this._useEDL = false; - + this._defaultIntensityRangeChanged = false; this._defaultElevationRangeChanged = false; - + this.attributes = { - position: { type: "fv", value: [] }, - color: { type: "fv", value: [] }, - normal: { type: "fv", value: [] }, - intensity: { type: "f", value: [] }, - classification: { type: "f", value: [] }, - returnNumber: { type: "f", value: [] }, - numberOfReturns: { type: "f", value: [] }, - pointSourceID: { type: "f", value: [] }, - indices: { type: "fv", value: [] } + position: { type: 'fv', value: [] }, + color: { type: 'fv', value: [] }, + normal: { type: 'fv', value: [] }, + intensity: { type: 'f', value: [] }, + classification: { type: 'f', value: [] }, + returnNumber: { type: 'f', value: [] }, + numberOfReturns: { type: 'f', value: [] }, + pointSourceID: { type: 'f', value: [] }, + indices: { type: 'fv', value: [] } }; - + this.uniforms = { - level: { type: "f", value: 0.0 }, - vnStart: { type: "f", value: 0.0 }, - spacing: { type: "f", value: 1.0 }, - blendHardness: { type: "f", value: 2.0 }, - blendDepthSupplement: { type: "f", value: 0.0 }, - fov: { type: "f", value: 1.0 }, - screenWidth: { type: "f", value: 1.0 }, - screenHeight: { type: "f", value: 1.0 }, - near: { type: "f", value: 0.1 }, - far: { type: "f", value: 1.0 }, - uColor: { type: "c", value: new THREE.Color( 0xffffff ) }, - opacity: { type: "f", value: 1.0 }, - size: { type: "f", value: pointSize }, - minSize: { type: "f", value: minSize }, - maxSize: { type: "f", value: maxSize }, - octreeSize: { type: "f", value: 0 }, - bbSize: { type: "fv", value: [0,0,0] }, - heightMin: { type: "f", value: 0.0 }, - heightMax: { type: "f", value: 1.0 }, - clipBoxCount: { type: "f", value: 0 }, - visibleNodes: { type: "t", value: this.visibleNodesTexture }, - pcIndex: { type: "f", value: 0 }, - gradient: { type: "t", value: this.gradientTexture }, - classificationLUT: { type: "t", value: this.classificationTexture }, - clipBoxes: { type: "Matrix4fv", value: [] }, - toModel: { type: "Matrix4f", value: [] }, - depthMap: { type: "t", value: null }, - diffuse: { type: "fv", value: [1,1,1]}, - transition: { type: "f", value: 0.5 }, - intensityRange: { type: "fv", value: [0, 65000] }, - intensityGamma: { type: "f", value: 1 }, - intensityContrast: { type: "f", value: 0 }, - intensityBrightness:{ type: "f", value: 0 }, - rgbGamma: { type: "f", value: 1 }, - rgbContrast: { type: "f", value: 0 }, - rgbBrightness: { type: "f", value: 0 }, - wRGB: { type: "f", value: 1 }, - wIntensity: { type: "f", value: 0 }, - wElevation: { type: "f", value: 0 }, - wClassification: { type: "f", value: 0 }, - wReturnNumber: { type: "f", value: 0 }, - wSourceID: { type: "f", value: 0 }, + level: { type: 'f', value: 0.0 }, + vnStart: { type: 'f', value: 0.0 }, + spacing: { type: 'f', value: 1.0 }, + blendHardness: { type: 'f', value: 2.0 }, + blendDepthSupplement: { type: 'f', value: 0.0 }, + fov: { type: 'f', value: 1.0 }, + screenWidth: { type: 'f', value: 1.0 }, + screenHeight: { type: 'f', value: 1.0 }, + near: { type: 'f', value: 0.1 }, + far: { type: 'f', value: 1.0 }, + uColor: { type: 'c', value: new THREE.Color(0xffffff) }, + opacity: { type: 'f', value: 1.0 }, + size: { type: 'f', value: pointSize }, + minSize: { type: 'f', value: minSize }, + maxSize: { type: 'f', value: maxSize }, + octreeSize: { type: 'f', value: 0 }, + bbSize: { type: 'fv', value: [0, 0, 0] }, + heightMin: { type: 'f', value: 0.0 }, + heightMax: { type: 'f', value: 1.0 }, + clipBoxCount: { type: 'f', value: 0 }, + visibleNodes: { type: 't', value: this.visibleNodesTexture }, + pcIndex: { type: 'f', value: 0 }, + gradient: { type: 't', value: this.gradientTexture }, + classificationLUT: { type: 't', value: this.classificationTexture }, + clipBoxes: { type: 'Matrix4fv', value: [] }, + toModel: { type: 'Matrix4f', value: [] }, + depthMap: { type: 't', value: null }, + diffuse: { type: 'fv', value: [1, 1, 1] }, + transition: { type: 'f', value: 0.5 }, + intensityRange: { type: 'fv', value: [0, 65000] }, + intensityGamma: { type: 'f', value: 1 }, + intensityContrast: { type: 'f', value: 0 }, + intensityBrightness: { type: 'f', value: 0 }, + rgbGamma: { type: 'f', value: 1 }, + rgbContrast: { type: 'f', value: 0 }, + rgbBrightness: { type: 'f', value: 0 }, + wRGB: { type: 'f', value: 1 }, + wIntensity: { type: 'f', value: 0 }, + wElevation: { type: 'f', value: 0 }, + wClassification: { type: 'f', value: 0 }, + wReturnNumber: { type: 'f', value: 0 }, + wSourceID: { type: 'f', value: 0 } }; - - this.defaultAttributeValues.normal = [0,0,0]; - this.defaultAttributeValues.classification = [0,0,0]; - this.defaultAttributeValues.indices = [0,0,0,0]; - - this.vertexShader = this.getDefines() + Potree.Shaders["pointcloud.vs"]; - this.fragmentShader = this.getDefines() + Potree.Shaders["pointcloud.fs"]; + + this.defaultAttributeValues.normal = [0, 0, 0]; + this.defaultAttributeValues.classification = [0, 0, 0]; + this.defaultAttributeValues.indices = [0, 0, 0, 0]; + + this.vertexShader = this.getDefines() + Potree.Shaders['pointcloud.vs']; + this.fragmentShader = this.getDefines() + Potree.Shaders['pointcloud.fs']; this.vertexColors = THREE.VertexColors; } - - updateShaderSource(){ - this.vertexShader = this.getDefines() + Potree.Shaders["pointcloud.vs"]; - this.fragmentShader = this.getDefines() + Potree.Shaders["pointcloud.fs"]; - - if(this.depthMap){ + + updateShaderSource () { + this.vertexShader = this.getDefines() + Potree.Shaders['pointcloud.vs']; + this.fragmentShader = this.getDefines() + Potree.Shaders['pointcloud.fs']; + + if (this.depthMap) { this.uniforms.depthMap.value = this.depthMap; - //this.depthMap = depthMap; - //this.setValues({ + // this.depthMap = depthMap; + // this.setValues({ // depthMap: this.depthMap, - //}); + // }); } - - if(this.opacity === 1.0){ + + if (this.opacity === 1.0) { this.blending = THREE.NoBlending; this.transparent = false; this.depthTest = true; this.depthWrite = true; - }else if(this.opacity < 1.0 && !this.useEDL){ + } else if (this.opacity < 1.0 && !this.useEDL) { this.blending = THREE.AdditiveBlending; this.transparent = true; this.depthTest = false; this.depthWrite = true; this.depthFunc = THREE.AlwaysDepth; } - - if(this.weighted){ + + if (this.weighted) { this.blending = THREE.AdditiveBlending; this.transparent = true; this.depthTest = true; - this.depthWrite = false; + this.depthWrite = false; } - + this.needsUpdate = true; } - - getDefines(){ - let defines = ""; - - if(this.pointSizeType === Potree.PointSizeType.FIXED){ - defines += "#define fixed_point_size\n"; - }else if(this.pointSizeType === Potree.PointSizeType.ATTENUATED){ - defines += "#define attenuated_point_size\n"; - }else if(this.pointSizeType === Potree.PointSizeType.ADAPTIVE){ - defines += "#define adaptive_point_size\n"; + + getDefines () { + let defines = ''; + + if (this.pointSizeType === Potree.PointSizeType.FIXED) { + defines += '#define fixed_point_size\n'; + } else if (this.pointSizeType === Potree.PointSizeType.ATTENUATED) { + defines += '#define attenuated_point_size\n'; + } else if (this.pointSizeType === Potree.PointSizeType.ADAPTIVE) { + defines += '#define adaptive_point_size\n'; } - - if(this.shape === Potree.PointShape.SQUARE){ - defines += "#define square_point_shape\n"; - }else if(this.shape === Potree.PointShape.CIRCLE){ - defines += "#define circle_point_shape\n"; - }else if(this.shape === Potree.PointShape.PARABOLOID){ - defines += "#define paraboloid_point_shape\n"; + + if (this.shape === Potree.PointShape.SQUARE) { + defines += '#define square_point_shape\n'; + } else if (this.shape === Potree.PointShape.CIRCLE) { + defines += '#define circle_point_shape\n'; + } else if (this.shape === Potree.PointShape.PARABOLOID) { + defines += '#define paraboloid_point_shape\n'; } - - if(this._useEDL){ - defines += "#define use_edl\n"; + + if (this._useEDL) { + defines += '#define use_edl\n'; } - - if(this._pointColorType === Potree.PointColorType.RGB){ - defines += "#define color_type_rgb\n"; - }else if(this._pointColorType === Potree.PointColorType.COLOR){ - defines += "#define color_type_color\n"; - }else if(this._pointColorType === Potree.PointColorType.DEPTH){ - defines += "#define color_type_depth\n"; - }else if(this._pointColorType === Potree.PointColorType.HEIGHT){ - defines += "#define color_type_height\n"; - }else if(this._pointColorType === Potree.PointColorType.INTENSITY){ - defines += "#define color_type_intensity\n"; - }else if(this._pointColorType === Potree.PointColorType.INTENSITY_GRADIENT){ - defines += "#define color_type_intensity_gradient\n"; - }else if(this._pointColorType === Potree.PointColorType.LOD){ - defines += "#define color_type_lod\n"; - }else if(this._pointColorType === Potree.PointColorType.POINT_INDEX){ - defines += "#define color_type_point_index\n"; - }else if(this._pointColorType === Potree.PointColorType.CLASSIFICATION){ - defines += "#define color_type_classification\n"; - }else if(this._pointColorType === Potree.PointColorType.RETURN_NUMBER){ - defines += "#define color_type_return_number\n"; - }else if(this._pointColorType === Potree.PointColorType.SOURCE){ - defines += "#define color_type_source\n"; - }else if(this._pointColorType === Potree.PointColorType.NORMAL){ - defines += "#define color_type_normal\n"; - }else if(this._pointColorType === Potree.PointColorType.PHONG){ - defines += "#define color_type_phong\n"; - }else if(this._pointColorType === Potree.PointColorType.RGB_HEIGHT){ - defines += "#define color_type_rgb_height\n"; - }else if(this._pointColorType === Potree.PointColorType.COMPOSITE){ - defines += "#define color_type_composite\n"; + + if (this._pointColorType === Potree.PointColorType.RGB) { + defines += '#define color_type_rgb\n'; + } else if (this._pointColorType === Potree.PointColorType.COLOR) { + defines += '#define color_type_color\n'; + } else if (this._pointColorType === Potree.PointColorType.DEPTH) { + defines += '#define color_type_depth\n'; + } else if (this._pointColorType === Potree.PointColorType.HEIGHT) { + defines += '#define color_type_height\n'; + } else if (this._pointColorType === Potree.PointColorType.INTENSITY) { + defines += '#define color_type_intensity\n'; + } else if (this._pointColorType === Potree.PointColorType.INTENSITY_GRADIENT) { + defines += '#define color_type_intensity_gradient\n'; + } else if (this._pointColorType === Potree.PointColorType.LOD) { + defines += '#define color_type_lod\n'; + } else if (this._pointColorType === Potree.PointColorType.POINT_INDEX) { + defines += '#define color_type_point_index\n'; + } else if (this._pointColorType === Potree.PointColorType.CLASSIFICATION) { + defines += '#define color_type_classification\n'; + } else if (this._pointColorType === Potree.PointColorType.RETURN_NUMBER) { + defines += '#define color_type_return_number\n'; + } else if (this._pointColorType === Potree.PointColorType.SOURCE) { + defines += '#define color_type_source\n'; + } else if (this._pointColorType === Potree.PointColorType.NORMAL) { + defines += '#define color_type_normal\n'; + } else if (this._pointColorType === Potree.PointColorType.PHONG) { + defines += '#define color_type_phong\n'; + } else if (this._pointColorType === Potree.PointColorType.RGB_HEIGHT) { + defines += '#define color_type_rgb_height\n'; + } else if (this._pointColorType === Potree.PointColorType.COMPOSITE) { + defines += '#define color_type_composite\n'; } - - if(this.clipMode === Potree.ClipMode.DISABLED){ - defines += "#define clip_disabled\n"; - }else if(this.clipMode === Potree.ClipMode.CLIP_OUTSIDE){ - defines += "#define clip_outside\n"; - }else if(this.clipMode === Potree.ClipMode.HIGHLIGHT_INSIDE){ - defines += "#define clip_highlight_inside\n"; + + if (this.clipMode === Potree.ClipMode.DISABLED) { + defines += '#define clip_disabled\n'; + } else if (this.clipMode === Potree.ClipMode.CLIP_OUTSIDE) { + defines += '#define clip_outside\n'; + } else if (this.clipMode === Potree.ClipMode.HIGHLIGHT_INSIDE) { + defines += '#define clip_highlight_inside\n'; } - - if(this._treeType === Potree.TreeType.OCTREE){ - defines += "#define tree_type_octree\n"; - }else if(this._treeType === Potree.TreeType.KDTREE){ - defines += "#define tree_type_kdtree\n"; + + if (this._treeType === Potree.TreeType.OCTREE) { + defines += '#define tree_type_octree\n'; + } else if (this._treeType === Potree.TreeType.KDTREE) { + defines += '#define tree_type_kdtree\n'; } - - if(this.weighted){ - defines += "#define weighted_splats\n"; + + if (this.weighted) { + defines += '#define weighted_splats\n'; } - - if(this.numClipBoxes > 0){ - defines += "#define use_clip_box\n"; + + if (this.numClipBoxes > 0) { + defines += '#define use_clip_box\n'; } return defines; } - - setClipBoxes(clipBoxes){ - if(!clipBoxes){ + setClipBoxes (clipBoxes) { + if (!clipBoxes) { return; } @@ -411,628 +404,584 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate this.numClipBoxes = clipBoxes.length; this.uniforms.clipBoxCount.value = this.numClipBoxes; - - if(doUpdate){ + + if (doUpdate) { this.updateShaderSource(); } - + this.uniforms.clipBoxes.value = new Float32Array(this.numClipBoxes * 16); - - for(let i = 0; i < this.numClipBoxes; i++){ + + for (let i = 0; i < this.numClipBoxes; i++) { let box = clipBoxes[i]; - - this.uniforms.clipBoxes.value.set(box.inverse.elements, 16*i); + + this.uniforms.clipBoxes.value.set(box.inverse.elements, 16 * i); } - - for(let i = 0; i < this.uniforms.clipBoxes.value.length; i++){ - if(Number.isNaN(this.uniforms.clipBoxes.value[i])){ + + for (let i = 0; i < this.uniforms.clipBoxes.value.length; i++) { + if (Number.isNaN(this.uniforms.clipBoxes.value[i])) { this.uniforms.clipBoxes.value[i] = Infinity; } } } - - get gradient(){ + + get gradient () { return this._gradient; } - - set gradient(value){ - if(this._gradient !== value){ + + set gradient (value) { + if (this._gradient !== value) { this._gradient = value; this.gradientTexture = Potree.PointCloudMaterial.generateGradientTexture(this._gradient); this.uniforms.gradient.value = this.gradientTexture; } } - - - get classification(){ + get classification () { return this._classification; } - - set classification(value){ - + + set classification (value) { let isEqual = Object.keys(value).length === Object.keys(this._classification).length; - - for(let key of Object.keys(value)){ + + for (let key of Object.keys(value)) { isEqual = isEqual && this._classification[key] !== undefined; isEqual = isEqual && value[key].equals(this._classification[key]); } - - - if(!isEqual){ - recomputeClassification(); + + if (!isEqual) { + this.recomputeClassification(); } } - - recomputeClassification(){ + + recomputeClassification () { this.classificationTexture = Potree.PointCloudMaterial.generateClassificationTexture(this._classification); this.uniforms.classificationLUT.value = this.classificationTexture; - + this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } - get spacing(){ + get spacing () { return this.uniforms.spacing.value; } - - set spacing(value){ - if(this.uniforms.spacing.value !== value){ + + set spacing (value) { + if (this.uniforms.spacing.value !== value) { this.uniforms.spacing.value = value; } } - - - get useClipBox(){ + get useClipBox () { return this._useClipBox; } - - set useClipBox(value){ - if(this._useClipBox !== value){ + + set useClipBox (value) { + if (this._useClipBox !== value) { this._useClipBox = value; this.updateShaderSource(); } } - - get weighted(){ + get weighted () { return this._weighted; } - - set weighted(value){ - if(this._weighted !== value){ + + set weighted (value) { + if (this._weighted !== value) { this._weighted = value; this.updateShaderSource(); } } - - get fov(){ + get fov () { return this.uniforms.fov.value; } - - set fov(value){ - if(this.uniforms.fov.value !== value){ + + set fov (value) { + if (this.uniforms.fov.value !== value) { this.uniforms.fov.value = value; - //this.updateShaderSource(); + // this.updateShaderSource(); } } - get screenWidth(){ + get screenWidth () { return this.uniforms.screenWidth.value; } - - set screenWidth(value){ - if(this.uniforms.screenWidth.value !== value){ + + set screenWidth (value) { + if (this.uniforms.screenWidth.value !== value) { this.uniforms.screenWidth.value = value; - //this.updateShaderSource(); + // this.updateShaderSource(); } } - - get screenHeight(){ + get screenHeight () { return this.uniforms.screenHeight.value; } - - set screenHeight(value){ - if(this.uniforms.screenHeight.value !== value){ + + set screenHeight (value) { + if (this.uniforms.screenHeight.value !== value) { this.uniforms.screenHeight.value = value; - //this.updateShaderSource(); + // this.updateShaderSource(); } } - - get near(){ + get near () { return this.uniforms.near.value; } - - set near(value){ - if(this.uniforms.near.value !== value){ + + set near (value) { + if (this.uniforms.near.value !== value) { this.uniforms.near.value = value; } } - - get far(){ + get far () { return this.uniforms.far.value; } - - set far(value){ - if(this.uniforms.far.value !== value){ + + set far (value) { + if (this.uniforms.far.value !== value) { this.uniforms.far.value = value; } } - - get opacity(){ + get opacity () { return this.uniforms.opacity.value; } - - set opacity(value){ - if(this.uniforms && this.uniforms.opacity){ - if(this.uniforms.opacity.value !== value){ + + set opacity (value) { + if (this.uniforms && this.uniforms.opacity) { + if (this.uniforms.opacity.value !== value) { this.uniforms.opacity.value = value; this.updateShaderSource(); this.dispatchEvent({ - type: "opacity_changed", + type: 'opacity_changed', target: this }); this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } } - - get pointColorType(){ + get pointColorType () { return this._pointColorType; } - - set pointColorType(value){ - if(this._pointColorType !== value){ + + set pointColorType (value) { + if (this._pointColorType !== value) { this._pointColorType = value; this.updateShaderSource(); this.dispatchEvent({ - type: "point_color_type_changed", + type: 'point_color_type_changed', target: this }); this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get depthMap(){ + get depthMap () { return this._depthMap; } - - set depthMap(value){ - if(this._depthMap !== value){ + + set depthMap (value) { + if (this._depthMap !== value) { this._depthMap = value; this.updateShaderSource(); } } - - get pointSizeType(){ + get pointSizeType () { return this._pointSizeType; } - - set pointSizeType(value){ - if(this._pointSizeType !== value){ + + set pointSizeType (value) { + if (this._pointSizeType !== value) { this._pointSizeType = value; this.updateShaderSource(); this.dispatchEvent({ - type: "point_size_type_changed", + type: 'point_size_type_changed', target: this }); this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get clipMode(){ + get clipMode () { return this._clipMode; } - - set clipMode(value){ - if(this._clipMode !== value){ + + set clipMode (value) { + if (this._clipMode !== value) { this._clipMode = value; this.updateShaderSource(); } } - - get useEDL(){ + get useEDL () { return this._useEDL; } - - set useEDL(value){ - if(this._useEDL !== value){ + + set useEDL (value) { + if (this._useEDL !== value) { this._useEDL = value; this.updateShaderSource(); } } - - get color(){ + get color () { return this.uniforms.uColor.value; } - - set color(value){ - if(!this.uniforms.uColor.value.equals(value)){ + + set color (value) { + if (!this.uniforms.uColor.value.equals(value)) { this.uniforms.uColor.value.copy(value); - + this.dispatchEvent({ - type: "color_changed", + type: 'color_changed', target: this }); this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get shape(){ + get shape () { return this._shape; } - - set shape(value){ - if(this._shape !== value){ + + set shape (value) { + if (this._shape !== value) { this._shape = value; this.updateShaderSource(); - this.dispatchEvent({type: "point_shape_changed", target: this}); + this.dispatchEvent({type: 'point_shape_changed', target: this}); this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - - get treeType(){ + get treeType () { return this._treeType; } - - set treeType(value){ - if(this._treeType !== value){ + + set treeType (value) { + if (this._treeType !== value) { this._treeType = value; this.updateShaderSource(); } } - - get bbSize(){ + get bbSize () { return this.uniforms.bbSize.value; } - - set bbSize(value){ + + set bbSize (value) { this.uniforms.bbSize.value = value; } - - get size(){ + get size () { return this.uniforms.size.value; } - - set size(value){ - if(this.uniforms.size.value !== value){ + + set size (value) { + if (this.uniforms.size.value !== value) { this.uniforms.size.value = value; - + this.dispatchEvent({ - type: "point_size_changed", + type: 'point_size_changed', target: this }); this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get elevationRange(){ + + get elevationRange () { return [this.heightMin, this.heightMax]; } - - set elevationRange(value){ + + set elevationRange (value) { this.heightMin = value[0]; this.heightMax = value[1]; } - get heightMin(){ + get heightMin () { return this.uniforms.heightMin.value; } - - set heightMin(value){ - if(this.uniforms.heightMin.value !== value){ + + set heightMin (value) { + if (this.uniforms.heightMin.value !== value) { this.uniforms.heightMin.value = value; - + this._defaultElevationRangeChanged = true; - + this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get heightMax(){ + get heightMax () { return this.uniforms.heightMax.value; } - - set heightMax(value){ - if(this.uniforms.heightMax.value !== value){ + + set heightMax (value) { + if (this.uniforms.heightMax.value !== value) { this.uniforms.heightMax.value = value; - + this._defaultElevationRangeChanged = true; - + this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get transition(){ + get transition () { return this.uniforms.transition.value; } - - set transition(value){ + + set transition (value) { this.uniforms.transition.value = value; } - - get intensityRange(){ + get intensityRange () { return this.uniforms.intensityRange.value; } - - set intensityRange(value){ - - if(!(value instanceof Array && value.length === 2)){ + + set intensityRange (value) { + if (!(value instanceof Array && value.length === 2)) { return; } - - if(value[0] === this.uniforms.intensityRange.value[0] && - value[1] === this.uniforms.intensityRange.value[1]){ - + + if (value[0] === this.uniforms.intensityRange.value[0] && + value[1] === this.uniforms.intensityRange.value[1]) { return; } - + this.uniforms.intensityRange.value = value; - + this._defaultIntensityRangeChanged = true; - + this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } - - get intensityGamma(){ + get intensityGamma () { return this.uniforms.intensityGamma.value; } - - set intensityGamma(value){ - if(this.uniforms.intensityGamma.value !== value){ + + set intensityGamma (value) { + if (this.uniforms.intensityGamma.value !== value) { this.uniforms.intensityGamma.value = value; this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get intensityContrast(){ + get intensityContrast () { return this.uniforms.intensityContrast.value; } - - set intensityContrast(value){ - if(this.uniforms.intensityContrast.value !== value){ + + set intensityContrast (value) { + if (this.uniforms.intensityContrast.value !== value) { this.uniforms.intensityContrast.value = value; this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get intensityBrightness(){ + get intensityBrightness () { return this.uniforms.intensityBrightness.value; } - - set intensityBrightness(value){ - if(this.uniforms.intensityBrightness.value !== value){ + + set intensityBrightness (value) { + if (this.uniforms.intensityBrightness.value !== value) { this.uniforms.intensityBrightness.value = value; this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get rgbGamma(){ + get rgbGamma () { return this.uniforms.rgbGamma.value; } - - set rgbGamma(value){ - if(this.uniforms.rgbGamma.value !== value){ + + set rgbGamma (value) { + if (this.uniforms.rgbGamma.value !== value) { this.uniforms.rgbGamma.value = value; this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get rgbContrast(){ + get rgbContrast () { return this.uniforms.rgbContrast.value; } - - set rgbContrast(value){ - if(this.uniforms.rgbContrast.value !== value){ + + set rgbContrast (value) { + if (this.uniforms.rgbContrast.value !== value) { this.uniforms.rgbContrast.value = value; this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get rgbBrightness(){ + get rgbBrightness () { return this.uniforms.rgbBrightness.value; } - - set rgbBrightness(value){ - if(this.uniforms.rgbBrightness.value !== value){ + + set rgbBrightness (value) { + if (this.uniforms.rgbBrightness.value !== value) { this.uniforms.rgbBrightness.value = value; this.dispatchEvent({ - type: "material_property_changed", + type: 'material_property_changed', target: this }); } } - - get weightRGB(){ + get weightRGB () { return this.uniforms.wRGB.value; } - - set weightRGB(value){ + + set weightRGB (value) { this.uniforms.wRGB.value = value; } - - get weightIntensity(){ + get weightIntensity () { return this.uniforms.wIntensity.value; } - - set weightIntensity(value){ + + set weightIntensity (value) { this.uniforms.wIntensity.value = value; } - - get weightElevation(){ + get weightElevation () { return this.uniforms.wElevation.value; } - - set weightElevation(value){ + + set weightElevation (value) { this.uniforms.wElevation.value = value; } - - get weightClassification(){ + get weightClassification () { return this.uniforms.wClassification.value; } - - set weightClassification(value){ + + set weightClassification (value) { this.uniforms.wClassification.value = value; } - - get weightReturnNumber(){ + get weightReturnNumber () { return this.uniforms.wReturnNumber.value; } - - set weightReturnNumber(value){ + + set weightReturnNumber (value) { this.uniforms.wReturnNumber.value = value; } - - get weightSourceID(){ + get weightSourceID () { return this.uniforms.wSourceID.value; } - - set weightSourceID(value){ + + set weightSourceID (value) { this.uniforms.wSourceID.value = value; } - - - static generateGradientTexture(gradient){ + static generateGradientTexture (gradient) { let size = 64; // create canvas - let canvas = document.createElement( 'canvas' ); + let canvas = document.createElement('canvas'); canvas.width = size; canvas.height = size; // get context - let context = canvas.getContext( '2d' ); + let context = canvas.getContext('2d'); // draw gradient - context.rect( 0, 0, size, size ); - let ctxGradient = context.createLinearGradient( 0, 0, size, size ); - - for(let i = 0;i < gradient.length; i++){ + context.rect(0, 0, size, size); + let ctxGradient = context.createLinearGradient(0, 0, size, size); + + for (let i = 0; i < gradient.length; i++) { let step = gradient[i]; - - ctxGradient.addColorStop(step[0], "#" + step[1].getHexString()); - } - + + ctxGradient.addColorStop(step[0], '#' + step[1].getHexString()); + } + context.fillStyle = ctxGradient; context.fill(); - - let texture = new THREE.Texture( canvas ); + + let texture = new THREE.Texture(canvas); texture.needsUpdate = true; - //textureImage = texture.image; + // textureImage = texture.image; return texture; } - - static generateClassificationTexture(classification){ + + static generateClassificationTexture (classification) { let width = 256; let height = 256; - let size = width*height; - - let data = new Uint8Array(4*size); - - for(let x = 0; x < width; x++){ - for(let y = 0; y < height; y++){ - - let i = x + width*y; - + let size = width * height; + + let data = new Uint8Array(4 * size); + + for (let x = 0; x < width; x++) { + for (let y = 0; y < height; y++) { + let i = x + width * y; + let color; - if(classification[x]){ + if (classification[x]) { color = classification[x]; - }else if(classification[x % 32]){ + } else if (classification[x % 32]) { color = classification[x % 32]; - }else{ + } else { color = classification.DEFAULT; } - - - data[4*i+0] = 255 * color.x; - data[4*i+1] = 255 * color.y; - data[4*i+2] = 255 * color.z; - data[4*i+3] = 255 * color.w; + + data[4 * i + 0] = 255 * color.x; + data[4 * i + 1] = 255 * color.y; + data[4 * i + 2] = 255 * color.z; + data[4 * i + 3] = 255 * color.w; } } - + let texture = new THREE.DataTexture(data, width, height, THREE.RGBAFormat); texture.magFilter = THREE.NearestFilter; texture.needsUpdate = true; - + return texture; } }; diff --git a/src/navigation/EarthControls.js b/src/navigation/EarthControls.js index ea61916a..bed94434 100644 --- a/src/navigation/EarthControls.js +++ b/src/navigation/EarthControls.js @@ -1,27 +1,23 @@ - -Potree.EarthControls = class EarthControls extends THREE.EventDispatcher{ - - constructor(viewer){ +Potree.EarthControls = class EarthControls extends THREE.EventDispatcher { + constructor (viewer) { super(viewer); - + this.viewer = viewer; this.renderer = viewer.renderer; - + this.scene = null; this.sceneControls = new THREE.Scene(); - + this.rotationSpeed = 10; - + this.fadeFactor = 20; this.wheelDelta = 0; this.zoomDelta = new THREE.Vector3(); this.camStart = null; - + this.tweens = []; - - this.pivotIndicator; { let sg = new THREE.SphereGeometry(1, 16, 16); let sm = new THREE.MeshNormalMaterial(); @@ -29,59 +25,58 @@ Potree.EarthControls = class EarthControls extends THREE.EventDispatcher{ this.pivotIndicator.visible = false; this.sceneControls.add(this.pivotIndicator); } - + let drag = (e) => { - if(e.drag.object !== null){ + if (e.drag.object !== null) { return; } - - if(!this.pivot){ + + if (!this.pivot) { return; } - - if(e.drag.startHandled === undefined){ + + if (e.drag.startHandled === undefined) { e.drag.startHandled = true; - - this.dispatchEvent({type: "start"}); + + this.dispatchEvent({type: 'start'}); } - + let camStart = this.camStart; let view = this.viewer.scene.view; - - //let camera = this.viewer.scene.camera; + + // let camera = this.viewer.scene.camera; let mouse = e.drag.end; let domElement = this.viewer.renderer.domElement; - - if(e.drag.mouse === Potree.MOUSE.LEFT){ - let nmouse = { - x: (mouse.x / domElement.clientWidth ) * 2 - 1, - y: - (mouse.y / domElement.clientHeight ) * 2 + 1 + + if (e.drag.mouse === Potree.MOUSE.LEFT) { + let nmouse = { + x: (mouse.x / domElement.clientWidth) * 2 - 1, + y: -(mouse.y / domElement.clientHeight) * 2 + 1 }; - - let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + + let vector = new THREE.Vector3(nmouse.x, nmouse.y, 0.5); vector.unproject(camStart); - - let dir = vector.sub( camStart.position).normalize(); + + let dir = vector.sub(camStart.position).normalize(); let ray = new THREE.Ray(camStart.position, dir); let plane = new THREE.Plane().setFromNormalAndCoplanarPoint( - new THREE.Vector3(0, 0, 1), + new THREE.Vector3(0, 0, 1), this.pivot); - - + let distanceToPlane = ray.distanceToPlane(plane); - if(distanceToPlane > 0){ + if (distanceToPlane > 0) { let I = new THREE.Vector3().addVectors( - camStart.position, + camStart.position, dir.clone().multiplyScalar(distanceToPlane)); - + let movedBy = new THREE.Vector3().subVectors( I, this.pivot); - + let newCamPos = camStart.position.clone().sub(movedBy); - + view.position.copy(newCamPos); - + { let distance = newCamPos.distanceTo(this.pivot); view.radius = distance; @@ -89,184 +84,179 @@ Potree.EarthControls = class EarthControls extends THREE.EventDispatcher{ this.viewer.setMoveSpeed(speed); } } - - }else if(e.drag.mouse === Potree.MOUSE.RIGHT){ + } else if (e.drag.mouse === Potree.MOUSE.RIGHT) { let ndrag = { x: e.drag.lastDrag.x / this.renderer.domElement.clientWidth, y: e.drag.lastDrag.y / this.renderer.domElement.clientHeight }; - + let yawDelta = -ndrag.x * this.rotationSpeed * 0.5; let pitchDelta = -ndrag.y * this.rotationSpeed * 0.2; - + let originalPitch = view.pitch; let tmpView = view.clone(); tmpView.pitch = tmpView.pitch + pitchDelta; pitchDelta = tmpView.pitch - originalPitch; - - + let pivotToCam = new THREE.Vector3().subVectors(view.position, this.pivot); let pivotToCamTarget = new THREE.Vector3().subVectors(view.getPivot(), this.pivot); let side = view.getSide(); - + pivotToCam.applyAxisAngle(side, pitchDelta); pivotToCamTarget.applyAxisAngle(side, pitchDelta); - + pivotToCam.applyAxisAngle(new THREE.Vector3(0, 0, 1), yawDelta); pivotToCamTarget.applyAxisAngle(new THREE.Vector3(0, 0, 1), yawDelta); - + let newCam = new THREE.Vector3().addVectors(this.pivot, pivotToCam); - let newCamTarget = new THREE.Vector3().addVectors(this.pivot, pivotToCamTarget); - + // TODO: Unused: let newCamTarget = new THREE.Vector3().addVectors(this.pivot, pivotToCamTarget); + view.position.copy(newCam); view.yaw += yawDelta; view.pitch += pitchDelta; - } - }; - + let onMouseDown = e => { let I = Potree.utils.getMousePointCloudIntersection( - e.mouse, - this.scene.camera, - this.renderer, + e.mouse, + this.scene.camera, + this.renderer, this.scene.pointclouds); - - if(I){ + + if (I) { this.pivot = I.location; this.camStart = this.scene.camera.clone(); this.pivotIndicator.visible = true; this.pivotIndicator.position.copy(I.location); } }; - + let drop = e => { - this.dispatchEvent({type: "end"}); + this.dispatchEvent({type: 'end'}); }; - + let onMouseUp = e => { this.camStart = null; this.pivot = null; this.pivotIndicator.visible = false; }; - + let scroll = (e) => { - this.wheelDelta += e.delta + this.wheelDelta += e.delta; }; - + let dblclick = (e) => { this.zoomToLocation(e.mouse); }; - - this.addEventListener("drag", drag); - this.addEventListener("drop", drop); - this.addEventListener("mousewheel", scroll); - this.addEventListener("mousedown", onMouseDown); - this.addEventListener("mouseup", onMouseUp); - this.addEventListener("dblclick", dblclick); + + this.addEventListener('drag', drag); + this.addEventListener('drop', drop); + this.addEventListener('mousewheel', scroll); + this.addEventListener('mousedown', onMouseDown); + this.addEventListener('mouseup', onMouseUp); + this.addEventListener('dblclick', dblclick); } - - setScene(scene){ + + setScene (scene) { this.scene = scene; } - - zoomToLocation(mouse){ + + zoomToLocation (mouse) { let camera = this.scene.camera; - + let I = Potree.utils.getMousePointCloudIntersection( - mouse, - camera, - this.renderer, + mouse, + camera, + this.renderer, this.scene.pointclouds); - - if(I === null){ + + if (I === null) { return; } - - let nmouse = { - x: +( mouse.x / this.renderer.domElement.clientWidth ) * 2 - 1, - y: -( mouse.y / this.renderer.domElement.clientHeight ) * 2 + 1 + + let nmouse = { + x: +(mouse.x / this.renderer.domElement.clientWidth) * 2 - 1, + y: -(mouse.y / this.renderer.domElement.clientHeight) * 2 + 1 }; - + let targetRadius = 0; { let minimumJumpDistance = 0.2; - - let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + + let vector = new THREE.Vector3(nmouse.x, nmouse.y, 0.5); vector.unproject(camera); - + let direction = vector.sub(camera.position).normalize(); let ray = new THREE.Ray(camera.position, direction); - + let nodes = I.pointcloud.nodesOnRay(I.pointcloud.visibleNodes, ray); let lastNode = nodes[nodes.length - 1]; let radius = lastNode.getBoundingSphere().radius; targetRadius = Math.min(this.scene.view.radius, radius); targetRadius = Math.max(minimumJumpDistance, targetRadius); } - + let d = this.scene.view.direction.multiplyScalar(-1); let cameraTargetPosition = new THREE.Vector3().addVectors(I.location, d.multiplyScalar(targetRadius)); - let controlsTargetPosition = I.location; - + // TODO Unused: let controlsTargetPosition = I.location; + var animationDuration = 600; var easing = TWEEN.Easing.Quartic.Out; - - { // animate - + + { // animate let value = {x: 0}; let tween = new TWEEN.Tween(value).to({x: 1}, animationDuration); tween.easing(easing); this.tweens.push(tween); - + let startPos = this.scene.view.position.clone(); let targetPos = cameraTargetPosition.clone(); let startRadius = this.scene.view.radius; let targetRadius = cameraTargetPosition.distanceTo(I.location); - - tween.onUpdate( () => { + + tween.onUpdate(() => { let t = value.x; this.scene.view.position.x = (1 - t) * startPos.x + t * targetPos.x; this.scene.view.position.y = (1 - t) * startPos.y + t * targetPos.y; this.scene.view.position.z = (1 - t) * startPos.z + t * targetPos.z; - + this.scene.view.radius = (1 - t) * startRadius + t * targetRadius; this.viewer.setMoveSpeed(this.scene.view.radius / 2.5); }); - - tween.onComplete( () => { - this.tweens = this.tweens.filter( e => e !== tween); + + tween.onComplete(() => { + this.tweens = this.tweens.filter(e => e !== tween); }); - + tween.start(); } } - - update(delta){ + + update (delta) { let view = this.scene.view; let fade = Math.pow(0.5, this.fadeFactor * delta); let progression = 1 - fade; let camera = this.scene.camera; - + // compute zoom - if(this.wheelDelta !== 0){ + if (this.wheelDelta !== 0) { let I = Potree.utils.getMousePointCloudIntersection( - this.viewer.inputHandler.mouse, - this.scene.camera, - this.renderer, + this.viewer.inputHandler.mouse, + this.scene.camera, + this.renderer, this.scene.pointclouds); - - if(I){ + + if (I) { let resolvedPos = new THREE.Vector3().addVectors(view.position, this.zoomDelta); let distance = I.location.distanceTo(resolvedPos); let jumpDistance = distance * 0.2 * this.wheelDelta; let targetDir = new THREE.Vector3().subVectors(I.location, view.position); targetDir.normalize(); - + resolvedPos.add(targetDir.multiplyScalar(jumpDistance)); this.zoomDelta.subVectors(resolvedPos, view.position); - + { let distance = resolvedPos.distanceTo(I.location); view.radius = distance; @@ -275,37 +265,27 @@ Potree.EarthControls = class EarthControls extends THREE.EventDispatcher{ } } } - + // apply zoom - if(this.zoomDelta.length() !== 0){ + if (this.zoomDelta.length() !== 0) { let p = this.zoomDelta.clone().multiplyScalar(progression); - + let newPos = new THREE.Vector3().addVectors(view.position, p); view.position.copy(newPos); } - - if(this.pivotIndicator.visible){ + + if (this.pivotIndicator.visible) { let distance = this.pivotIndicator.position.distanceTo(view.position); let pixelHeight = this.renderer.domElement.clientHeight; let pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, pixelHeight); let scale = (10 / pr); this.pivotIndicator.scale.set(scale, scale, scale); } - + // decelerate over time { this.zoomDelta.multiplyScalar(fade); this.wheelDelta = 0; } - } - -} - - - - - - - - +}; diff --git a/src/navigation/FirstPersonControls.js b/src/navigation/FirstPersonControls.js index 5bbc9544..ec88ac8f 100644 --- a/src/navigation/FirstPersonControls.js +++ b/src/navigation/FirstPersonControls.js @@ -1,7 +1,7 @@ /** * @author mschuetz / http://mschuetz.at * - * adapted from THREE.OrbitControls by + * adapted from THREE.OrbitControls by * * @author qiao / https://github.com/qiao * @author mrdoob / http://mrdoob.com @@ -12,264 +12,252 @@ * * */ - -Potree.FirstPersonControls = class FirstPersonControls extends THREE.EventDispatcher{ - - constructor(viewer){ + +Potree.FirstPersonControls = class FirstPersonControls extends THREE.EventDispatcher { + constructor (viewer) { super(); - + this.viewer = viewer; this.renderer = viewer.renderer; - + this.scene = null; this.sceneControls = new THREE.Scene(); - + this.rotationSpeed = 200; this.moveSpeed = 10; - + this.keys = { - FORWARD: ['W'.charCodeAt(0), 38], - BACKWARD: ['S'.charCodeAt(0), 40], - LEFT: ['A'.charCodeAt(0), 37], - RIGHT: ['D'.charCodeAt(0), 39], - UP: ['R'.charCodeAt(0), 33], - DOWN: ['F'.charCodeAt(0), 34] + FORWARD: ['W'.charCodeAt(0), 38], + BACKWARD: ['S'.charCodeAt(0), 40], + LEFT: ['A'.charCodeAt(0), 37], + RIGHT: ['D'.charCodeAt(0), 39], + UP: ['R'.charCodeAt(0), 33], + DOWN: ['F'.charCodeAt(0), 34] }; - + this.fadeFactor = 50; this.yawDelta = 0; this.pitchDelta = 0; this.translationDelta = new THREE.Vector3(0, 0, 0); this.translationWorldDelta = new THREE.Vector3(0, 0, 0); - + this.tweens = []; - + let drag = (e) => { - if(e.drag.object !== null){ + if (e.drag.object !== null) { return; } - - if(e.drag.startHandled === undefined){ + + if (e.drag.startHandled === undefined) { e.drag.startHandled = true; - - this.dispatchEvent({type: "start"}); + + this.dispatchEvent({type: 'start'}); } - + let moveSpeed = this.viewer.getMoveSpeed(); - + let ndrag = { x: e.drag.lastDrag.x / this.renderer.domElement.clientWidth, y: e.drag.lastDrag.y / this.renderer.domElement.clientHeight }; - - if(e.drag.mouse === Potree.MOUSE.LEFT){ + + if (e.drag.mouse === Potree.MOUSE.LEFT) { this.yawDelta += ndrag.x * this.rotationSpeed; this.pitchDelta += ndrag.y * this.rotationSpeed; - }else if(e.drag.mouse === Potree.MOUSE.RIGHT){ + } else if (e.drag.mouse === Potree.MOUSE.RIGHT) { this.translationDelta.x -= ndrag.x * moveSpeed * 100; this.translationDelta.z += ndrag.y * moveSpeed * 100; } }; - + let drop = e => { - this.dispatchEvent({type: "end"}); + this.dispatchEvent({type: 'end'}); }; - + let scroll = (e) => { let speed = this.viewer.getMoveSpeed(); - - if(e.delta < 0){ + + if (e.delta < 0) { speed = speed * 0.9; - }else if(e.delta > 0){ + } else if (e.delta > 0) { speed = speed / 0.9; } - + speed = Math.max(speed, 0.1); - + this.viewer.setMoveSpeed(speed); }; - + let dblclick = (e) => { this.zoomToLocation(e.mouse); }; - - this.addEventListener("drag", drag); - this.addEventListener("drop", drop); - this.addEventListener("mousewheel", scroll); - this.addEventListener("dblclick", dblclick); + + this.addEventListener('drag', drag); + this.addEventListener('drop', drop); + this.addEventListener('mousewheel', scroll); + this.addEventListener('dblclick', dblclick); } - - setScene(scene){ + + setScene (scene) { this.scene = scene; } - - zoomToLocation(mouse){ + + zoomToLocation (mouse) { let camera = this.scene.camera; - + let I = Potree.utils.getMousePointCloudIntersection( - mouse, - camera, - this.renderer, + mouse, + camera, + this.renderer, this.scene.pointclouds); - - if(I === null){ + + if (I === null) { return; } - - let nmouse = { - x: +( mouse.x / this.renderer.domElement.clientWidth ) * 2 - 1, - y: -( mouse.y / this.renderer.domElement.clientHeight ) * 2 + 1 + + let nmouse = { + x: +(mouse.x / this.renderer.domElement.clientWidth) * 2 - 1, + y: -(mouse.y / this.renderer.domElement.clientHeight) * 2 + 1 }; - + let targetRadius = 0; { let minimumJumpDistance = 0.2; - - let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + + let vector = new THREE.Vector3(nmouse.x, nmouse.y, 0.5); vector.unproject(camera); - + let direction = vector.sub(camera.position).normalize(); let ray = new THREE.Ray(camera.position, direction); - + let nodes = I.pointcloud.nodesOnRay(I.pointcloud.visibleNodes, ray); let lastNode = nodes[nodes.length - 1]; let radius = lastNode.getBoundingSphere().radius; targetRadius = Math.min(this.scene.view.radius, radius); targetRadius = Math.max(minimumJumpDistance, targetRadius); } - + let d = this.scene.view.direction.multiplyScalar(-1); let cameraTargetPosition = new THREE.Vector3().addVectors(I.location, d.multiplyScalar(targetRadius)); - let controlsTargetPosition = I.location; - + // TODO Unused: let controlsTargetPosition = I.location; + var animationDuration = 600; var easing = TWEEN.Easing.Quartic.Out; - - { // animate - + + { // animate let value = {x: 0}; let tween = new TWEEN.Tween(value).to({x: 1}, animationDuration); tween.easing(easing); this.tweens.push(tween); - + let startPos = this.scene.view.position.clone(); let targetPos = cameraTargetPosition.clone(); let startRadius = this.scene.view.radius; let targetRadius = cameraTargetPosition.distanceTo(I.location); - - tween.onUpdate( () => { + + tween.onUpdate(() => { let t = value.x; this.scene.view.position.x = (1 - t) * startPos.x + t * targetPos.x; this.scene.view.position.y = (1 - t) * startPos.y + t * targetPos.y; this.scene.view.position.z = (1 - t) * startPos.z + t * targetPos.z; - + this.scene.view.radius = (1 - t) * startRadius + t * targetRadius; this.viewer.setMoveSpeed(this.scene.view.radius / 2.5); }); - - tween.onComplete( () => { - this.tweens = this.tweens.filter( e => e !== tween); + + tween.onComplete(() => { + this.tweens = this.tweens.filter(e => e !== tween); }); - + tween.start(); } - } - - update(delta){ + + update (delta) { let view = this.scene.view; - + { // cancel move animations on user input - let changes = [ this.yawDelta, - this.pitchDelta, + let changes = [ this.yawDelta, + this.pitchDelta, this.translationDelta.length(), this.translationWorldDelta.length() ]; - let changeHappens = changes.some( e => Math.abs(e) > 0.001); - if(changeHappens && this.tweens.length > 0){ - this.tweens.forEach( e => e.stop() ); + let changeHappens = changes.some(e => Math.abs(e) > 0.001); + if (changeHappens && this.tweens.length > 0) { + this.tweens.forEach(e => e.stop()); this.tweens = []; - } + } } - + { // accelerate while input is given let ih = this.viewer.inputHandler; - + let moveForward = this.keys.FORWARD.some(e => ih.pressedKeys[e]); let moveBackward = this.keys.BACKWARD.some(e => ih.pressedKeys[e]); let moveLeft = this.keys.LEFT.some(e => ih.pressedKeys[e]); let moveRight = this.keys.RIGHT.some(e => ih.pressedKeys[e]); let moveUp = this.keys.UP.some(e => ih.pressedKeys[e]); let moveDown = this.keys.DOWN.some(e => ih.pressedKeys[e]); - - if(moveForward && moveBackward){ + + if (moveForward && moveBackward) { this.translationDelta.y = 0; - }else if(moveForward){ + } else if (moveForward) { this.translationDelta.y = this.viewer.getMoveSpeed(); - }else if(moveBackward){ + } else if (moveBackward) { this.translationDelta.y = -this.viewer.getMoveSpeed(); } - - if(moveLeft && moveRight){ + + if (moveLeft && moveRight) { this.translationDelta.x = 0; - }else if(moveLeft){ + } else if (moveLeft) { this.translationDelta.x = -this.viewer.getMoveSpeed(); - }else if(moveRight){ + } else if (moveRight) { this.translationDelta.x = this.viewer.getMoveSpeed(); } - - if(moveUp && moveDown){ + + if (moveUp && moveDown) { this.translationWorldDelta.z = 0; - }else if(moveUp){ + } else if (moveUp) { this.translationWorldDelta.z = this.viewer.getMoveSpeed(); - }else if(moveDown){ + } else if (moveDown) { this.translationWorldDelta.z = -this.viewer.getMoveSpeed(); } - } - + { // apply rotation let yaw = view.yaw; let pitch = view.pitch; - + yaw -= this.yawDelta * delta; pitch -= this.pitchDelta * delta; - + view.yaw = yaw; view.pitch = pitch; } - + { // apply translation view.translate( this.translationDelta.x * delta, this.translationDelta.y * delta, this.translationDelta.z * delta ); - + view.translateWorld( this.translationWorldDelta.x * delta, this.translationWorldDelta.y * delta, this.translationWorldDelta.z * delta ); } - + { // set view target according to speed view.radius = 3 * this.viewer.getMoveSpeed(); } - - {// decelerate over time + + { // decelerate over time let attenuation = Math.max(0, 1 - this.fadeFactor * delta); this.yawDelta *= attenuation; this.pitchDelta *= attenuation; this.translationDelta.multiplyScalar(attenuation); this.translationWorldDelta.multiplyScalar(attenuation); } - } - - - }; - - - - diff --git a/src/navigation/GeoControls.js b/src/navigation/GeoControls.js index c04ac4cf..9ecab055 100644 --- a/src/navigation/GeoControls.js +++ b/src/navigation/GeoControls.js @@ -1,9 +1,8 @@ - /** * @author mschuetz / http://mschuetz.at * - * adapted from THREE.OrbitControls by + * adapted from THREE.OrbitControls by * * @author qiao / https://github.com/qiao * @author mrdoob / http://mrdoob.com @@ -22,12 +21,10 @@ * */ - - -Potree.GeoControls = function ( object, domElement ) { +Potree.GeoControls = function (object, domElement) { this.object = object; - this.domElement = ( domElement !== undefined ) ? domElement : document; - + this.domElement = (domElement !== undefined) ? domElement : document; + // Set to false to disable this control this.enabled = true; @@ -35,14 +32,14 @@ Potree.GeoControls = function ( object, domElement ) { this.track = null; // position on track in intervall [0,1] this.trackPos = 0; - + this.rotateSpeed = 1.0; this.moveSpeed = 10.0; - this.keys = { - LEFT: 37, - UP: 38, - RIGHT: 39, + this.keys = { + LEFT: 37, + UP: 38, + RIGHT: 39, BOTTOM: 40, A: 'A'.charCodeAt(0), S: 'S'.charCodeAt(0), @@ -65,18 +62,17 @@ Potree.GeoControls = function ( object, domElement ) { var panDelta = new THREE.Vector2(); var panOffset = new THREE.Vector3(); - var offset = new THREE.Vector3(); + // TODO Unused: var offset = new THREE.Vector3(); var phiDelta = 0; var thetaDelta = 0; - var scale = 1; var pan = new THREE.Vector3(); - + this.shiftDown = false; var lastPosition = new THREE.Vector3(); - var STATE = { NONE : -1, ROTATE : 0, SPEEDCHANGE : 1, PAN : 2 }; + var STATE = { NONE: -1, ROTATE: 0, SPEEDCHANGE: 1, PAN: 2 }; var state = STATE.NONE; @@ -86,38 +82,38 @@ Potree.GeoControls = function ( object, domElement ) { // events var changeEvent = { type: 'change' }; - var startEvent = { type: 'start'}; - var endEvent = { type: 'end'}; - - this.setTrack = function(track){ - if(this.track !== track){ + var startEvent = { type: 'start' }; + var endEvent = { type: 'end' }; + + this.setTrack = function (track) { + if (this.track !== track) { this.track = track; this.trackPos = null; } }; - - this.setTrackPos = function(trackPos, _preserveRelativeRotation){ - var preserveRelativeRotation = _preserveRelativeRotation || false; - + + this.setTrackPos = function (trackPos, _preserveRelativeRotation) { + // TODO Unused: var preserveRelativeRotation = _preserveRelativeRotation || false; + var newTrackPos = Math.max(0, Math.min(1, trackPos)); var oldTrackPos = this.trackPos || newTrackPos; - + var newTangent = this.track.getTangentAt(newTrackPos); var oldTangent = this.track.getTangentAt(oldTrackPos); - - if(newTangent.equals(oldTangent)){ + + if (newTangent.equals(oldTangent)) { // no change in direction - }else{ + } else { var tangentDiffNormal = new THREE.Vector3().crossVectors(oldTangent, newTangent).normalize(); var angle = oldTangent.angleTo(newTangent); var rot = new THREE.Matrix4().makeRotationAxis(tangentDiffNormal, angle); var dir = this.object.getWorldDirection().clone(); dir = dir.applyMatrix4(rot); - var target = new THREE.Vector3().addVectors(this.object.position, dir); + let target = new THREE.Vector3().addVectors(this.object.position, dir); this.object.lookAt(target); this.object.updateMatrixWorld(); - - var event = { + + let event = { type: 'path_relative_rotation', angle: angle, axis: tangentDiffNormal, @@ -125,341 +121,325 @@ Potree.GeoControls = function ( object, domElement ) { }; this.dispatchEvent(event); } - - if(this.trackPos === null){ - var target = new THREE.Vector3().addVectors(this.object.position, newTangent); + + if (this.trackPos === null) { + let target = new THREE.Vector3().addVectors(this.object.position, newTangent); this.object.lookAt(target); } - - + this.trackPos = newTrackPos; - - //var pStart = this.track.getPointAt(oldTrackPos); - //var pEnd = this.track.getPointAt(newTrackPos); - //var pDiff = pEnd.sub(pStart); - - - if(newTrackPos !== oldTrackPos){ - var event = { + + // var pStart = this.track.getPointAt(oldTrackPos); + // var pEnd = this.track.getPointAt(newTrackPos); + // var pDiff = pEnd.sub(pStart); + + if (newTrackPos !== oldTrackPos) { + let event = { type: 'move', translation: pan.clone() }; this.dispatchEvent(event); } - } - - this.getTrackPos = function(){ + }; + + this.getTrackPos = function () { return this.trackPos; }; - this.rotateLeft = function ( angle ) { + this.rotateLeft = function (angle) { thetaDelta -= angle; }; - this.rotateUp = function ( angle ) { + this.rotateUp = function (angle) { phiDelta -= angle; }; // pass in distance in world space to move left - this.panLeft = function ( distance ) { - + this.panLeft = function (distance) { var te = this.object.matrix.elements; // get X column of matrix - panOffset.set( te[ 0 ], te[ 1 ], te[ 2 ] ); - panOffset.multiplyScalar( - distance ); - - pan.add( panOffset ); + panOffset.set(te[ 0 ], te[ 1 ], te[ 2 ]); + panOffset.multiplyScalar(-distance); + pan.add(panOffset); }; // pass in distance in world space to move up - this.panUp = function ( distance ) { - + this.panUp = function (distance) { var te = this.object.matrix.elements; // get Y column of matrix - panOffset.set( te[ 4 ], te[ 5 ], te[ 6 ] ); - panOffset.multiplyScalar( distance ); - - pan.add( panOffset ); + panOffset.set(te[ 4 ], te[ 5 ], te[ 6 ]); + panOffset.multiplyScalar(distance); + pan.add(panOffset); }; - - // pass in distance in world space to move forward - this.panForward = function ( distance ) { - if(this.track){ - this.setTrackPos( this.getTrackPos() - distance / this.track.getLength()); - }else{ + // pass in distance in world space to move forward + this.panForward = function (distance) { + if (this.track) { + this.setTrackPos(this.getTrackPos() - distance / this.track.getLength()); + } else { var te = this.object.matrix.elements; // get Y column of matrix - panOffset.set( te[ 8 ], te[ 9 ], te[ 10 ] ); - //panOffset.set( te[ 8 ], 0, te[ 10 ] ); - panOffset.multiplyScalar( distance ); - - pan.add( panOffset ); + panOffset.set(te[ 8 ], te[ 9 ], te[ 10 ]); + // panOffset.set( te[ 8 ], 0, te[ 10 ] ); + panOffset.multiplyScalar(distance); + + pan.add(panOffset); } }; - - this.pan = function ( deltaX, deltaY ) { + this.pan = function (deltaX, deltaY) { var element = scope.domElement === document ? scope.domElement.body : scope.domElement; - if ( scope.object.fov !== undefined ) { + if (scope.object.fov !== undefined) { // perspective var position = scope.object.position; var offset = position.clone(); var targetDistance = offset.length(); // half of the fov is center to top of screen - targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 ); + targetDistance *= Math.tan((scope.object.fov / 2) * Math.PI / 180.0); // we actually don't use screenWidth, since perspective camera is fixed to screen height - scope.panLeft( 2 * deltaX * targetDistance / element.clientHeight ); - scope.panUp( 2 * deltaY * targetDistance / element.clientHeight ); - } else if ( scope.object.top !== undefined ) { - + scope.panLeft(2 * deltaX * targetDistance / element.clientHeight); + scope.panUp(2 * deltaY * targetDistance / element.clientHeight); + } else if (scope.object.top !== undefined) { // orthographic - scope.panLeft( deltaX * (scope.object.right - scope.object.left) / element.clientWidth ); - scope.panUp( deltaY * (scope.object.top - scope.object.bottom) / element.clientHeight ); + scope.panLeft(deltaX * (scope.object.right - scope.object.left) / element.clientWidth); + scope.panUp(deltaY * (scope.object.top - scope.object.bottom) / element.clientHeight); } else { - // camera neither orthographic or perspective - console.warn( 'WARNING: GeoControls.js encountered an unknown camera type - pan disabled.' ); + console.warn('WARNING: GeoControls.js encountered an unknown camera type - pan disabled.'); } }; this.update = function (delta) { this.object.rotation.order = 'ZYX'; - + var object = this.object; - + this.object = new THREE.Object3D(); this.object.position.copy(object.position); this.object.rotation.copy(object.rotation); this.object.updateMatrix(); this.object.updateMatrixWorld(); - + var position = this.object.position; - - if(delta !== undefined){ - + + if (delta !== undefined) { var multiplier = scope.shiftDown ? 4 : 1; - if(this.moveRight){ + if (this.moveRight) { this.panLeft(-delta * this.moveSpeed * multiplier); } - if(this.moveLeft){ + if (this.moveLeft) { this.panLeft(delta * this.moveSpeed * multiplier); } - if(this.moveForward || this.moveForwardMouse){ + if (this.moveForward || this.moveForwardMouse) { this.panForward(-delta * this.moveSpeed * multiplier); } - if(this.moveBackward){ + if (this.moveBackward) { this.panForward(delta * this.moveSpeed * multiplier); } - if(this.rotLeft){ - scope.rotateLeft( -0.5 * Math.PI * delta / scope.rotateSpeed ); + if (this.rotLeft) { + scope.rotateLeft(-0.5 * Math.PI * delta / scope.rotateSpeed); } - if(this.rotRight){ - scope.rotateLeft( 0.5 * Math.PI * delta / scope.rotateSpeed ); + if (this.rotRight) { + scope.rotateLeft(0.5 * Math.PI * delta / scope.rotateSpeed); } - if(this.raiseCamera){ - //scope.rotateUp( -0.5 * Math.PI * delta / scope.rotateSpeed ); - scope.panUp( delta * this.moveSpeed * multiplier ); + if (this.raiseCamera) { + // scope.rotateUp( -0.5 * Math.PI * delta / scope.rotateSpeed ); + scope.panUp(delta * this.moveSpeed * multiplier); } - if(this.lowerCamera){ - //scope.rotateUp( 0.5 * Math.PI * delta / scope.rotateSpeed ); - scope.panUp( -delta * this.moveSpeed * multiplier ); + if (this.lowerCamera) { + // scope.rotateUp( 0.5 * Math.PI * delta / scope.rotateSpeed ); + scope.panUp(-delta * this.moveSpeed * multiplier); } - } - - if(!pan.equals(new THREE.Vector3(0,0,0))){ - var event = { + + if (!pan.equals(new THREE.Vector3(0, 0, 0))) { + let event = { type: 'move', translation: pan.clone() }; this.dispatchEvent(event); } - + position.add(pan); - - if(!(thetaDelta === 0.0 && phiDelta === 0.0)) { - var event = { + + if (!(thetaDelta === 0.0 && phiDelta === 0.0)) { + let event = { type: 'rotate', thetaDelta: thetaDelta, phiDelta: phiDelta }; this.dispatchEvent(event); } - + this.object.updateMatrix(); var rot = new THREE.Matrix4().makeRotationY(thetaDelta); var res = new THREE.Matrix4().multiplyMatrices(rot, this.object.matrix); this.object.quaternion.setFromRotationMatrix(res); - + this.object.rotation.x += phiDelta; this.object.updateMatrixWorld(); - + // send transformation proposal to listeners var proposeTransformEvent = { - type: "proposeTransform", + type: 'proposeTransform', oldPosition: object.position, newPosition: this.object.position, objections: 0, counterProposals: [] }; this.dispatchEvent(proposeTransformEvent); - + // check some counter proposals if transformation wasn't accepted - if(proposeTransformEvent.objections > 0 ){ - if(proposeTransformEvent.counterProposals.length > 0){ + if (proposeTransformEvent.objections > 0) { + if (proposeTransformEvent.counterProposals.length > 0) { var cp = proposeTransformEvent.counterProposals; this.object.position.copy(cp[0]); - + proposeTransformEvent.objections = 0; proposeTransformEvent.counterProposals = []; } } - + // apply transformation, if accepted - if(proposeTransformEvent.objections > 0){ - - }else{ + if (proposeTransformEvent.objections > 0) { + + } else { object.position.copy(this.object.position); } - + object.rotation.copy(this.object.rotation); - + this.object = object; thetaDelta = 0; phiDelta = 0; - scale = 1; - pan.set( 0, 0, 0 ); + pan.set(0, 0, 0); - if ( lastPosition.distanceTo( this.object.position ) > 0 ) { - this.dispatchEvent( changeEvent ); + if (lastPosition.distanceTo(this.object.position) > 0) { + this.dispatchEvent(changeEvent); - lastPosition.copy( this.object.position ); + lastPosition.copy(this.object.position); } - - if(this.track){ + + if (this.track) { var pos = this.track.getPointAt(this.trackPos); object.position.copy(pos); } }; - this.reset = function () { state = STATE.NONE; - this.object.position.copy( this.position0 ); + this.object.position.copy(this.position0); }; - function onMouseDown( event ) { - if ( scope.enabled === false ) return; + function onMouseDown (event) { + if (scope.enabled === false) return; event.preventDefault(); - if ( event.button === 0 ) { + if (event.button === 0) { state = STATE.ROTATE; - rotateStart.set( event.clientX, event.clientY ); - } else if ( event.button === 1 ) { + rotateStart.set(event.clientX, event.clientY); + } else if (event.button === 1) { state = STATE.PAN; - - panStart.set( event.clientX, event.clientY ); - } else if ( event.button === 2 ) { - //state = STATE.PAN; - // - //panStart.set( event.clientX, event.clientY ); + + panStart.set(event.clientX, event.clientY); + } else if (event.button === 2) { + // state = STATE.PAN; + // panStart.set( event.clientX, event.clientY ); scope.moveForwardMouse = true; } - //scope.domElement.addEventListener( 'mousemove', onMouseMove, false ); - //scope.domElement.addEventListener( 'mouseup', onMouseUp, false ); - scope.dispatchEvent( startEvent ); + // scope.domElement.addEventListener( 'mousemove', onMouseMove, false ); + // scope.domElement.addEventListener( 'mouseup', onMouseUp, false ); + scope.dispatchEvent(startEvent); } - function onMouseMove( event ) { - if ( scope.enabled === false ) return; + function onMouseMove (event) { + if (scope.enabled === false) return; event.preventDefault(); var element = scope.domElement === document ? scope.domElement.body : scope.domElement; - if ( state === STATE.ROTATE ) { - rotateEnd.set( event.clientX, event.clientY ); - rotateDelta.subVectors( rotateEnd, rotateStart ); + if (state === STATE.ROTATE) { + rotateEnd.set(event.clientX, event.clientY); + rotateDelta.subVectors(rotateEnd, rotateStart); // rotating across whole screen goes 360 degrees around - scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed ); + scope.rotateLeft(2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed); // rotating up and down along whole screen attempts to go 360, but limited to 180 - scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed ); + scope.rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed); - rotateStart.copy( rotateEnd ); - - } else if ( state === STATE.PAN ) { - panEnd.set( event.clientX, event.clientY ); - panDelta.subVectors( panEnd, panStart ); - //panDelta.multiplyScalar(this.moveSpeed).multiplyScalar(0.0001); + rotateStart.copy(rotateEnd); + } else if (state === STATE.PAN) { + panEnd.set(event.clientX, event.clientY); + panDelta.subVectors(panEnd, panStart); + // panDelta.multiplyScalar(this.moveSpeed).multiplyScalar(0.0001); panDelta.multiplyScalar(0.002).multiplyScalar(scope.moveSpeed); - - scope.pan( panDelta.x, panDelta.y ); - panStart.copy( panEnd ); + scope.pan(panDelta.x, panDelta.y); + + panStart.copy(panEnd); } } - function onMouseUp(event) { - if ( scope.enabled === false ) return; - - //console.log(event.which); - - if(event.button === 2){ + function onMouseUp (event) { + if (scope.enabled === false) return; + + // console.log(event.which); + + if (event.button === 2) { scope.moveForwardMouse = false; - }else{ - //scope.domElement.removeEventListener( 'mousemove', onMouseMove, false ); - //scope.domElement.removeEventListener( 'mouseup', onMouseUp, false ); - scope.dispatchEvent( endEvent ); + } else { + // scope.domElement.removeEventListener( 'mousemove', onMouseMove, false ); + // scope.domElement.removeEventListener( 'mouseup', onMouseUp, false ); + scope.dispatchEvent(endEvent); state = STATE.NONE; } } - function onMouseWheel(event) { - if ( scope.enabled === false || scope.noZoom === true ) return; + function onMouseWheel (event) { + if (scope.enabled === false || scope.noZoom === true) return; event.preventDefault(); - var direction = (event.detail<0 || event.wheelDelta>0) ? 1 : -1; + var direction = (event.detail < 0 || event.wheelDelta > 0) ? 1 : -1; var moveSpeed = scope.moveSpeed + scope.moveSpeed * 0.1 * direction; moveSpeed = Math.max(0.1, moveSpeed); scope.setMoveSpeed(moveSpeed); - scope.dispatchEvent( startEvent ); - scope.dispatchEvent( endEvent ); + scope.dispatchEvent(startEvent); + scope.dispatchEvent(endEvent); } - - this.setMoveSpeed = function(value){ - if(scope.moveSpeed !== value){ + + this.setMoveSpeed = function (value) { + if (scope.moveSpeed !== value) { scope.moveSpeed = value; - scope.dispatchEvent( { - type: "move_speed_changed", + scope.dispatchEvent({ + type: 'move_speed_changed', controls: scope }); } }; - function onKeyDown( event ) { - if ( scope.enabled === false) return; - + function onKeyDown (event) { + if (scope.enabled === false) return; + scope.shiftDown = event.shiftKey; - - switch ( event.keyCode ) { + + switch (event.keyCode) { case scope.keys.UP: scope.moveForward = true; break; case scope.keys.BOTTOM: scope.moveBackward = true; break; case scope.keys.LEFT: scope.moveLeft = true; break; @@ -467,19 +447,18 @@ Potree.GeoControls = function ( object, domElement ) { case scope.keys.W: scope.moveForward = true; break; case scope.keys.S: scope.moveBackward = true; break; case scope.keys.A: scope.moveLeft = true; break; - case scope.keys.D: scope.moveRight = true; break; - case scope.keys.Q: scope.rotLeft = true; break; - case scope.keys.E: scope.rotRight = true; break; - case scope.keys.R: scope.raiseCamera = true; break; - case scope.keys.F: scope.lowerCamera = true; break; + case scope.keys.D: scope.moveRight = true; break; + case scope.keys.Q: scope.rotLeft = true; break; + case scope.keys.E: scope.rotRight = true; break; + case scope.keys.R: scope.raiseCamera = true; break; + case scope.keys.F: scope.lowerCamera = true; break; } } - - function onKeyUp( event ) { - + + function onKeyUp (event) { scope.shiftDown = event.shiftKey; - - switch ( event.keyCode ) { + + switch (event.keyCode) { case scope.keys.W: scope.moveForward = false; break; case scope.keys.S: scope.moveBackward = false; break; case scope.keys.A: scope.moveLeft = false; break; @@ -488,27 +467,26 @@ Potree.GeoControls = function ( object, domElement ) { case scope.keys.BOTTOM: scope.moveBackward = false; break; case scope.keys.LEFT: scope.moveLeft = false; break; case scope.keys.RIGHT: scope.moveRight = false; break; - case scope.keys.Q: scope.rotLeft = false; break; + case scope.keys.Q: scope.rotLeft = false; break; case scope.keys.E: scope.rotRight = false; break; - case scope.keys.R: scope.raiseCamera = false; break; - case scope.keys.F: scope.lowerCamera = false; break; + case scope.keys.R: scope.raiseCamera = false; break; + case scope.keys.F: scope.lowerCamera = false; break; } } - this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); - this.domElement.addEventListener( 'mousedown', onMouseDown, false ); - this.domElement.addEventListener( 'mousewheel', onMouseWheel, false ); - this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox - - scope.domElement.addEventListener( 'mousemove', onMouseMove, false ); - scope.domElement.addEventListener( 'mouseup', onMouseUp, false ); + this.domElement.addEventListener('contextmenu', function (event) { event.preventDefault(); }, false); + this.domElement.addEventListener('mousedown', onMouseDown, false); + this.domElement.addEventListener('mousewheel', onMouseWheel, false); + this.domElement.addEventListener('DOMMouseScroll', onMouseWheel, false); // firefox - if(this.domElement.tabIndex === -1){ + scope.domElement.addEventListener('mousemove', onMouseMove, false); + scope.domElement.addEventListener('mouseup', onMouseUp, false); + + if (this.domElement.tabIndex === -1) { this.domElement.tabIndex = 2222; } - scope.domElement.addEventListener( 'keydown', onKeyDown, false ); - scope.domElement.addEventListener( 'keyup', onKeyUp, false ); - + scope.domElement.addEventListener('keydown', onKeyDown, false); + scope.domElement.addEventListener('keyup', onKeyUp, false); }; -Potree.GeoControls.prototype = Object.create( THREE.EventDispatcher.prototype ); \ No newline at end of file +Potree.GeoControls.prototype = Object.create(THREE.EventDispatcher.prototype); diff --git a/src/navigation/InputHandler.js b/src/navigation/InputHandler.js index e9ca2ec1..43be3412 100644 --- a/src/navigation/InputHandler.js +++ b/src/navigation/InputHandler.js @@ -2,76 +2,75 @@ * @author mschuetz / http://mschuetz.at * * - */ -Potree.InputHandler = class InputHandler extends THREE.EventDispatcher{ - - constructor(viewer){ + */ +Potree.InputHandler = class InputHandler extends THREE.EventDispatcher { + constructor (viewer) { super(); - + this.viewer = viewer; this.renderer = viewer.renderer; this.domElement = this.renderer.domElement; - + this.scene = null; this.interactiveScenes = []; this.inputListeners = []; - + this.drag = null; this.mouse = new THREE.Vector2(0, 0); - + this.selection = []; - + this.hoveredElements = []; this.pressedKeys = {}; - + this.wheelDelta = 0; - + this.speed = 1; - + this.logMessages = false; - - if(this.domElement.tabIndex === -1){ + + if (this.domElement.tabIndex === -1) { this.domElement.tabIndex = 2222; } - - this.domElement.addEventListener("contextmenu", (event) => { event.preventDefault(); }, false ); - this.domElement.addEventListener("click", this.onMouseClick.bind(this), false); - this.domElement.addEventListener("mousedown", this.onMouseDown.bind(this), false); - this.domElement.addEventListener("mouseup", this.onMouseUp.bind(this), false); - this.domElement.addEventListener("mousemove", this.onMouseMove.bind(this), false); - this.domElement.addEventListener("mousewheel", this.onMouseWheel.bind(this), false ); - this.domElement.addEventListener("DOMMouseScroll", this.onMouseWheel.bind(this), false ); // Firefox - this.domElement.addEventListener("dblclick", this.onDoubleClick.bind(this)); - this.domElement.addEventListener("keydown", this.onKeyDown.bind(this)); - this.domElement.addEventListener("keyup", this.onKeyUp.bind(this)); - this.domElement.addEventListener("touchstart", this.onTouchStart.bind(this)); - this.domElement.addEventListener("touchend", this.onTouchEnd.bind(this)); - this.domElement.addEventListener("touchmove", this.onTouchMove.bind(this)); + + this.domElement.addEventListener('contextmenu', (event) => { event.preventDefault(); }, false); + this.domElement.addEventListener('click', this.onMouseClick.bind(this), false); + this.domElement.addEventListener('mousedown', this.onMouseDown.bind(this), false); + this.domElement.addEventListener('mouseup', this.onMouseUp.bind(this), false); + this.domElement.addEventListener('mousemove', this.onMouseMove.bind(this), false); + this.domElement.addEventListener('mousewheel', this.onMouseWheel.bind(this), false); + this.domElement.addEventListener('DOMMouseScroll', this.onMouseWheel.bind(this), false); // Firefox + this.domElement.addEventListener('dblclick', this.onDoubleClick.bind(this)); + this.domElement.addEventListener('keydown', this.onKeyDown.bind(this)); + this.domElement.addEventListener('keyup', this.onKeyUp.bind(this)); + this.domElement.addEventListener('touchstart', this.onTouchStart.bind(this)); + this.domElement.addEventListener('touchend', this.onTouchEnd.bind(this)); + this.domElement.addEventListener('touchmove', this.onTouchMove.bind(this)); } - - addInputListener(listener){ + + addInputListener (listener) { this.inputListeners.push(listener); } - - removeInputListener(listener){ + + removeInputListener (listener) { this.inputListeners = this.inputListeners.filter(e => e !== listener); } - - onTouchStart(e){ - if(this.logMessages) console.log(this.constructor.name + ": onTouchStart"); - + + onTouchStart (e) { + if (this.logMessages) console.log(this.constructor.name + ': onTouchStart'); + e.preventDefault(); - if(e.touches.length === 1){ + if (e.touches.length === 1) { let rect = this.domElement.getBoundingClientRect(); let x = e.touches[0].pageX - rect.left; let y = e.touches[0].pageY - rect.top; this.mouse.set(x, y); - + this.startDragging(null); } - - for(let inputListener of this.inputListeners){ + + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ type: e.type, touches: e.touches, @@ -79,23 +78,23 @@ Potree.InputHandler = class InputHandler extends THREE.EventDispatcher{ }); } } - - onTouchEnd(e){ - if(this.logMessages) console.log(this.constructor.name + ": onTouchEnd"); - + + onTouchEnd (e) { + if (this.logMessages) console.log(this.constructor.name + ': onTouchEnd'); + e.preventDefault(); - - for(let inputListener of this.inputListeners){ + + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ - type: "drop", + type: 'drop', drag: this.drag, viewer: this.viewer }); } - + this.drag = null; - - for(let inputListener of this.inputListeners){ + + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ type: e.type, touches: e.touches, @@ -103,107 +102,106 @@ Potree.InputHandler = class InputHandler extends THREE.EventDispatcher{ }); } } - - onTouchMove(e){ - if(this.logMessages) console.log(this.constructor.name + ": onTouchMove"); - + + onTouchMove (e) { + if (this.logMessages) console.log(this.constructor.name + ': onTouchMove'); + e.preventDefault(); - - if(e.touches.length === 1){ + + if (e.touches.length === 1) { let rect = this.domElement.getBoundingClientRect(); let x = e.touches[0].pageX - rect.left; let y = e.touches[0].pageY - rect.top; this.mouse.set(x, y); - - if(this.drag){ + + if (this.drag) { this.drag.mouse = 1; - + this.drag.lastDrag.x = x - this.drag.end.x; this.drag.lastDrag.y = y - this.drag.end.y; - + this.drag.end.set(x, y); - - if(this.logMessages) console.log(this.constructor.name + ": drag: "); - for(let inputListener of this.inputListeners){ + + if (this.logMessages) console.log(this.constructor.name + ': drag: '); + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ - type: "drag", + type: 'drag', drag: this.drag, viewer: this.viewer }); } } } - - for(let inputListener of this.inputListeners){ + + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ type: e.type, touches: e.touches, changedTouches: e.changedTouches }); } - + // DEBUG CODE - //let debugTouches = [...e.touches, { - // pageX: this.domElement.clientWidth / 2, + // let debugTouches = [...e.touches, { + // pageX: this.domElement.clientWidth / 2, // pageY: this.domElement.clientHeight / 2}]; - //for(let inputListener of this.inputListeners){ + // for(let inputListener of this.inputListeners){ // inputListener.dispatchEvent({ // type: e.type, // touches: debugTouches, // changedTouches: e.changedTouches // }); - //} + // } } - - onKeyDown(e){ - if(this.logMessages) console.log(this.constructor.name + ": onKeyDown"); - - if(e.keyCode === 46 && this.selection.length > 0){ + + onKeyDown (e) { + if (this.logMessages) console.log(this.constructor.name + ': onKeyDown'); + + if (e.keyCode === 46 && this.selection.length > 0) { // DELETE this.dispatchEvent({ - type: "delete", + type: 'delete', selection: this.selection }); - + this.deselectAll(); } - + this.dispatchEvent({ - type: "keydown", + type: 'keydown', keyCode: e.keyCode, event: e }); - - //for(let l of this.inputListeners){ + + // for(let l of this.inputListeners){ // l.dispatchEvent({ // type: "keydown", // keyCode: e.keyCode, // event: e // }); - //} - + // } + this.pressedKeys[e.keyCode] = true; - - //e.preventDefault(); + + // e.preventDefault(); } - - onKeyUp(e){ - if(this.logMessages) console.log(this.constructor.name + ": onKeyUp"); - + + onKeyUp (e) { + if (this.logMessages) console.log(this.constructor.name + ': onKeyUp'); + delete this.pressedKeys[e.keyCode]; - + e.preventDefault(); } - - onDoubleClick(e){ - if(this.logMessages) console.log(this.constructor.name + ": onDoubleClick"); - - + + onDoubleClick (e) { + if (this.logMessages) console.log(this.constructor.name + ': onDoubleClick'); + let consumed = false; - for(let hovered of this.hoveredElements){ - if(hovered._listeners && hovered._listeners["dblclick"]){ + for (let hovered of this.hoveredElements) { + if (hovered._listeners && hovered._listeners['dblclick']) { hovered.object.dispatchEvent({ - type: "dblclick", + type: 'dblclick', mouse: this.mouse, object: hovered.object }); @@ -211,248 +209,245 @@ Potree.InputHandler = class InputHandler extends THREE.EventDispatcher{ break; } } - - if(!consumed){ - for(let inputListener of this.inputListeners){ + + if (!consumed) { + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ - type: "dblclick", + type: 'dblclick', mouse: this.mouse, object: null }); } } - + e.preventDefault(); } - - onMouseClick(e){ - if(this.logMessages) console.log(this.constructor.name + ": onMouseClick"); - + + onMouseClick (e) { + if (this.logMessages) console.log(this.constructor.name + ': onMouseClick'); + e.preventDefault(); } - - onMouseDown(e){ - if(this.logMessages) console.log(this.constructor.name + ": onMouseDown"); - + + onMouseDown (e) { + if (this.logMessages) console.log(this.constructor.name + ': onMouseDown'); + e.preventDefault(); - - if(this.hoveredElements.length === 0){ - for(let inputListener of this.inputListeners){ + + if (this.hoveredElements.length === 0) { + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ - type: "mousedown", + type: 'mousedown', viewer: this.viewer, mouse: this.mouse }); } } - - if(!this.drag){ + + if (!this.drag) { let target = this.hoveredElements .find(el => ( - el.object._listeners - && el.object._listeners["drag"] - && el.object._listeners["drag"].length > 0)); - - if(target){ + el.object._listeners && + el.object._listeners['drag'] && + el.object._listeners['drag'].length > 0)); + + if (target) { this.startDragging(target.object, {location: target.point}); - }else{ + } else { this.startDragging(null); } } - - if(this.scene){ + + if (this.scene) { this.viewStart = this.scene.view.clone(); } } - - onMouseUp(e){ - if(this.logMessages) console.log(this.constructor.name + ": onMouseUp"); - + + onMouseUp (e) { + if (this.logMessages) console.log(this.constructor.name + ': onMouseUp'); + e.preventDefault(); - - let noMovement = this.getNormalizedDrag().length() === 0; - - if(e.button === THREE.MOUSE.LEFT){ - if(noMovement){ - + + let noMovement = this.getNormalizedDrag().length() === 0; + + if (e.button === THREE.MOUSE.LEFT) { + if (noMovement) { let selectable = this.hoveredElements - .find(el => el.object._listeners && el.object._listeners["select"]); - - if(selectable){ + .find(el => el.object._listeners && el.object._listeners['select']); + + if (selectable) { selectable = selectable.object; - - if(this.isSelected(selectable)){ + + if (this.isSelected(selectable)) { this.selection .filter(e => e !== selectable) .forEach(e => this.toggleSelection(e)); - }else{ + } else { this.deselectAll(); this.toggleSelection(selectable); } - }else{ + } else { this.deselectAll(); } } - }else if((e.button === THREE.MOUSE.RIGHT) && noMovement){ + } else if ((e.button === THREE.MOUSE.RIGHT) && noMovement) { this.deselectAll(); } - - if(this.hoveredElements.length === 0){ - for(let inputListener of this.inputListeners){ + + if (this.hoveredElements.length === 0) { + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ - type: "mouseup", + type: 'mouseup', viewer: this.viewer, mouse: this.mouse }); } } - - if(this.drag){ - if(this.drag.object){ + + if (this.drag) { + if (this.drag.object) { this.drag.object.dispatchEvent({ - type: "drop", + type: 'drop', drag: this.drag, viewer: this.viewer - + }); - }else{ - if(this.logMessages) console.log(this.constructor.name + ": drop: "); - for(let inputListener of this.inputListeners){ + } else { + if (this.logMessages) console.log(this.constructor.name + ': drop: '); + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ - type: "drop", + type: 'drop', drag: this.drag, viewer: this.viewer }); } } - + this.drag = null; } - } - - onMouseMove(e){ - if(this.logMessages) console.log(this.constructor.name + ": onMouseMove"); - + } + + onMouseMove (e) { + if (this.logMessages) console.log(this.constructor.name + ': onMouseMove'); + e.preventDefault(); - + let rect = this.domElement.getBoundingClientRect(); let x = e.clientX - rect.left; let y = e.clientY - rect.top; this.mouse.set(x, y); - - if(this.drag){ + + if (this.drag) { this.drag.mouse = e.buttons; - + this.drag.lastDrag.x = x - this.drag.end.x; this.drag.lastDrag.y = y - this.drag.end.y; - + this.drag.end.set(x, y); - - if(this.drag.object){ - if(this.logMessages) console.log(this.constructor.name + ": drag: " + this.drag.object.name); + + if (this.drag.object) { + if (this.logMessages) console.log(this.constructor.name + ': drag: ' + this.drag.object.name); this.drag.object.dispatchEvent({ - type: "drag", + type: 'drag', drag: this.drag, viewer: this.viewer }); - }else{ - if(this.logMessages) console.log(this.constructor.name + ": drag: "); - for(let inputListener of this.inputListeners){ + } else { + if (this.logMessages) console.log(this.constructor.name + ': drag: '); + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ - type: "drag", + type: 'drag', drag: this.drag, viewer: this.viewer }); } } } - + let hoveredElements = this.getHoveredElements(); let currentlyHoveredObjects = hoveredElements.map(e => e.object); let previouslyHoveredObjects = this.hoveredElements.map(e => e.object); - - let now = currentlyHoveredObjects.find(e => (e._listeners && e._listeners["mouseover"])); - let prev = previouslyHoveredObjects.find(e => (e._listeners && e._listeners["mouseover"])); - - if(now !== prev){ - if(now){ + + let now = currentlyHoveredObjects.find(e => (e._listeners && e._listeners['mouseover'])); + let prev = previouslyHoveredObjects.find(e => (e._listeners && e._listeners['mouseover'])); + + if (now !== prev) { + if (now) { now.dispatchEvent({ - type: "mouseover", + type: 'mouseover', object: now }); } - - if(prev){ + + if (prev) { prev.dispatchEvent({ - type: "mouseleave", + type: 'mouseleave', object: prev }); } } - - //let justHovered = currentlyHoveredObjects + + // let justHovered = currentlyHoveredObjects // .filter(e => previouslyHoveredObjects.indexOf(e) === -1); - //let justUnhovered = previouslyHoveredObjects + // let justUnhovered = previouslyHoveredObjects // .filter(e => currentlyHoveredObjects.indexOf(e) === -1); - // - //justHovered = justHovered.find(e => (e._listeners && e._listeners["mouseover"])); - //justUnhovered = justUnhovered.find(e => (e._listeners && e._listeners["mouseover"])); - - - - //let over = justHovered.find(e => (e._listeners && e._listeners["mouseover"])); - //if(over){ + // + // justHovered = justHovered.find(e => (e._listeners && e._listeners["mouseover"])); + // justUnhovered = justUnhovered.find(e => (e._listeners && e._listeners["mouseover"])); + + // let over = justHovered.find(e => (e._listeners && e._listeners["mouseover"])); + // if(over){ // over.dispatchEvent({ // type: "mouseover", // object: over // }); - //} + // } // - //let leave = justUnhovered.find(e => (e._listeners && e._listeners["mouseleave"])); - //if(leave){ + // let leave = justUnhovered.find(e => (e._listeners && e._listeners["mouseleave"])); + // if(leave){ // leave.dispatchEvent({ // type: "mouseleave", // object: leave // }); - //} - + // } + this.hoveredElements = hoveredElements; } - - onMouseWheel(e){ - if(this.logMessages) console.log(this.constructor.name + ": onMouseWheel"); - + + onMouseWheel (e) { + if (this.logMessages) console.log(this.constructor.name + ': onMouseWheel'); + e.preventDefault(); - + let delta = 0; - if( e.wheelDelta !== undefined ) { // WebKit / Opera / Explorer 9 + if (e.wheelDelta !== undefined) { // WebKit / Opera / Explorer 9 delta = e.wheelDelta; - } else if ( e.detail !== undefined ) { // Firefox + } else if (e.detail !== undefined) { // Firefox delta = -e.detail; } - + let ndelta = Math.sign(delta); - - //this.wheelDelta += Math.sign(delta); - - if(this.hoveredElement){ + + // this.wheelDelta += Math.sign(delta); + + if (this.hoveredElement) { this.hoveredElement.object.dispatchEvent({ - type: "mousewheel", + type: 'mousewheel', delta: ndelta, object: this.hoveredElement.object }); - }else{ - for(let inputListener of this.inputListeners){ + } else { + for (let inputListener of this.inputListeners) { inputListener.dispatchEvent({ - type: "mousewheel", + type: 'mousewheel', delta: ndelta, object: null }); } } } - - startDragging(object, args = null){ + + startDragging (object, args = null) { this.drag = { start: this.mouse.clone(), end: this.mouse.clone(), @@ -460,174 +455,169 @@ Potree.InputHandler = class InputHandler extends THREE.EventDispatcher{ startView: this.scene.view.clone(), object: object }; - - if(args){ - for(let key of Object.keys(args)){ + + if (args) { + for (let key of Object.keys(args)) { this.drag[key] = args[key]; } } } - - getMousePointCloudIntersection(mouse){ + + getMousePointCloudIntersection (mouse) { return Potree.utils.getMousePointCloudIntersection( - this.mouse, - this.scene.camera, - this.renderer, + this.mouse, + this.scene.camera, + this.renderer, this.scene.pointclouds); } - - toggleSelection(object){ - + + toggleSelection (object) { let oldSelection = this.selection; - + let index = this.selection.indexOf(object); - - if(index === -1){ + + if (index === -1) { this.selection.push(object); object.dispatchEvent({ - type: "select" + type: 'select' }); - }else{ + } else { this.selection.splice(index, 1); object.dispatchEvent({ - type: "deselect" + type: 'deselect' }); } - + this.dispatchEvent({ - type: "selection_changed", + type: 'selection_changed', oldSelection: oldSelection, selection: this.selection }); } - - deselectAll(){ - for(let object of this.selection){ + + deselectAll () { + for (let object of this.selection) { object.dispatchEvent({ - type: "deselect" + type: 'deselect' }); } - + let oldSelection = this.selection; - - if(this.selection.length > 0){ + + if (this.selection.length > 0) { this.selection = []; this.dispatchEvent({ - type: "selection_changed", + type: 'selection_changed', oldSelection: oldSelection, selection: this.selection }); } - - } - - isSelected(object){ + + isSelected (object) { let index = this.selection.indexOf(object); - + return index !== -1; } - - registerInteractiveScene(scene){ + + registerInteractiveScene (scene) { let index = this.interactiveScenes.indexOf(scene); - if(index === -1){ + if (index === -1) { this.interactiveScenes.push(scene); } } - - unregisterInteractiveScene(scene){ + + unregisterInteractiveScene (scene) { let index = this.interactiveScenes.indexOf(scene); if (index > -1) { this.interactiveScenes.splice(index, 1); } } - - getHoveredElement(){ + + getHoveredElement () { let hoveredElements = this.getHoveredElements(); - if(hoveredElements.length > 0){ + if (hoveredElements.length > 0) { return hoveredElements[0]; - }else{ + } else { return null; } } - - getHoveredElements(){ - + + getHoveredElements () { let scenes = this.interactiveScenes.concat(this.scene.scene); - - let interactableListeners = ["mouseover", "mouseleave", "drag", "drop", "click", "select", "deselect"]; + + let interactableListeners = ['mouseover', 'mouseleave', 'drag', 'drop', 'click', 'select', 'deselect']; let interactables = []; - for(let scene of scenes){ + for (let scene of scenes) { scene.traverseVisible(node => { - if(node._listeners && node.visible){ + if (node._listeners && node.visible) { let hasInteractableListener = interactableListeners.filter((e) => { - return node._listeners[e] !== undefined + return node._listeners[e] !== undefined; }).length > 0; - - if(hasInteractableListener){ + + if (hasInteractableListener) { interactables.push(node); } } }); } - - let nmouse = { - x: (this.mouse.x / this.domElement.clientWidth ) * 2 - 1, - y: - (this.mouse.y / this.domElement.clientHeight ) * 2 + 1 + + let nmouse = { + x: (this.mouse.x / this.domElement.clientWidth) * 2 - 1, + y: -(this.mouse.y / this.domElement.clientHeight) * 2 + 1 }; - - let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + + let vector = new THREE.Vector3(nmouse.x, nmouse.y, 0.5); vector.unproject(this.scene.camera); - + let raycaster = new THREE.Raycaster(); - raycaster.ray.set( this.scene.camera.position, vector.sub( this.scene.camera.position ).normalize() ); + raycaster.ray.set(this.scene.camera.position, vector.sub(this.scene.camera.position).normalize()); raycaster.linePrecision = 0.2; - + let intersections = raycaster.intersectObjects(interactables, false); - + return intersections; - - //if(intersections.length > 0){ + + // if(intersections.length > 0){ // return intersections[0]; - //}else{ + // }else{ // return null; - //} - } - - setScene(scene){ - this.deselectAll(); - - this.scene = scene; - } - - update(delta){ - + // } } - getNormalizedDrag(){ - if(!this.drag){ + setScene (scene) { + this.deselectAll(); + + this.scene = scene; + } + + update (delta) { + + } + + getNormalizedDrag () { + if (!this.drag) { return new THREE.Vector2(0, 0); } - + let diff = new THREE.Vector2().subVectors(this.drag.end, this.drag.start); diff.x = diff.x / this.domElement.clientWidth; diff.y = diff.y / this.domElement.clientHeight; - + return diff; } - - getNormalizedLastDrag(){ - if(!this.drag){ + + getNormalizedLastDrag () { + if (!this.drag) { return new THREE.Vector2(0, 0); } - + let lastDrag = this.drag.lastDrag.clone(); - + lastDrag.x = lastDrag.x / this.domElement.clientWidth; lastDrag.y = lastDrag.y / this.domElement.clientHeight; - + return lastDrag; } - -}; \ No newline at end of file +}; diff --git a/src/navigation/OrbitControls.js b/src/navigation/OrbitControls.js index 32b26f47..a80c7b85 100644 --- a/src/navigation/OrbitControls.js +++ b/src/navigation/OrbitControls.js @@ -1,7 +1,7 @@ /** * @author mschuetz / http://mschuetz.at * - * adapted from THREE.OrbitControls by + * adapted from THREE.OrbitControls by * * @author qiao / https://github.com/qiao * @author mrdoob / http://mrdoob.com @@ -12,100 +12,94 @@ * * */ - -Potree.OrbitControls = class OrbitControls extends THREE.EventDispatcher{ - - constructor(viewer){ - super() - + +Potree.OrbitControls = class OrbitControls extends THREE.EventDispatcher { + constructor (viewer) { + super(); + this.viewer = viewer; this.renderer = viewer.renderer; - + this.scene = null; this.sceneControls = new THREE.Scene(); - + this.rotationSpeed = 5; - + this.fadeFactor = 10; this.yawDelta = 0; this.pitchDelta = 0; this.panDelta = new THREE.Vector2(0, 0); this.radiusDelta = 0; - + this.tweens = []; - - + let drag = (e) => { - if(e.drag.object !== null){ + if (e.drag.object !== null) { return; } - - if(e.drag.startHandled === undefined){ + + if (e.drag.startHandled === undefined) { e.drag.startHandled = true; - - this.dispatchEvent({type: "start"}); + + this.dispatchEvent({type: 'start'}); } - + let ndrag = { x: e.drag.lastDrag.x / this.renderer.domElement.clientWidth, y: e.drag.lastDrag.y / this.renderer.domElement.clientHeight }; - - if(e.drag.mouse === Potree.MOUSE.LEFT){ + + if (e.drag.mouse === Potree.MOUSE.LEFT) { this.yawDelta += ndrag.x * this.rotationSpeed; this.pitchDelta += ndrag.y * this.rotationSpeed; - + this.stopTweens(); - }else if(e.drag.mouse === Potree.MOUSE.RIGHT){ + } else if (e.drag.mouse === Potree.MOUSE.RIGHT) { this.panDelta.x += ndrag.x; this.panDelta.y += ndrag.y; - + this.stopTweens(); } - - }; - + let drop = e => { - this.dispatchEvent({type: "end"}); + this.dispatchEvent({type: 'end'}); }; - + let scroll = (e) => { let resolvedRadius = this.scene.view.radius + this.radiusDelta; - + this.radiusDelta += -e.delta * resolvedRadius * 0.1; - + this.stopTweens(); }; - + let dblclick = (e) => { this.zoomToLocation(e.mouse); }; - - + let previousTouch = null; let touchStart = e => { previousTouch = e; }; - + let touchEnd = e => { previousTouch = e; }; - + let touchMove = e => { - - if(e.touches.length === 2 && previousTouch.touches.length === 2){ + if (e.touches.length === 2 && previousTouch.touches.length === 2) { let prev = previousTouch; let curr = e; - + let prevDX = prev.touches[0].pageX - prev.touches[1].pageX; let prevDY = prev.touches[0].pageY - prev.touches[1].pageY; let prevDist = Math.sqrt(prevDX * prevDX + prevDY * prevDY); - + let currDX = curr.touches[0].pageX - curr.touches[1].pageX; let currDY = curr.touches[0].pageY - curr.touches[1].pageY; let currDist = Math.sqrt(currDX * currDX + currDY * currDY); - + let delta = currDist / prevDist; let resolvedRadius = this.scene.view.radius + this.radiusDelta; let newRadius = resolvedRadius / delta; @@ -113,162 +107,158 @@ Potree.OrbitControls = class OrbitControls extends THREE.EventDispatcher{ this.stopTweens(); } - + previousTouch = e; }; - - this.addEventListener("touchstart", touchStart); - this.addEventListener("touchend", touchEnd); - this.addEventListener("touchmove", touchMove); - this.addEventListener("drag", drag); - this.addEventListener("drop", drop); - this.addEventListener("mousewheel", scroll); - this.addEventListener("dblclick", dblclick); - + + this.addEventListener('touchstart', touchStart); + this.addEventListener('touchend', touchEnd); + this.addEventListener('touchmove', touchMove); + this.addEventListener('drag', drag); + this.addEventListener('drop', drop); + this.addEventListener('mousewheel', scroll); + this.addEventListener('dblclick', dblclick); } - - setScene(scene){ + + setScene (scene) { this.scene = scene; } - - zoomToLocation(mouse){ + + zoomToLocation (mouse) { let camera = this.scene.camera; - + let I = Potree.utils.getMousePointCloudIntersection( - mouse, - camera, - this.renderer, + mouse, + camera, + this.renderer, this.scene.pointclouds); - - if(I === null){ + + if (I === null) { return; } - - let nmouse = { - x: +( mouse.x / this.renderer.domElement.clientWidth ) * 2 - 1, - y: -( mouse.y / this.renderer.domElement.clientHeight ) * 2 + 1 + + let nmouse = { + x: +(mouse.x / this.renderer.domElement.clientWidth) * 2 - 1, + y: -(mouse.y / this.renderer.domElement.clientHeight) * 2 + 1 }; - + let targetRadius = 0; { let minimumJumpDistance = 0.2; - - let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + + let vector = new THREE.Vector3(nmouse.x, nmouse.y, 0.5); vector.unproject(camera); - + let direction = vector.sub(camera.position).normalize(); let ray = new THREE.Ray(camera.position, direction); - + let nodes = I.pointcloud.nodesOnRay(I.pointcloud.visibleNodes, ray); let lastNode = nodes[nodes.length - 1]; let radius = lastNode.getBoundingSphere().radius; targetRadius = Math.min(this.scene.view.radius, radius); targetRadius = Math.max(minimumJumpDistance, targetRadius); } - + let d = this.scene.view.direction.multiplyScalar(-1); let cameraTargetPosition = new THREE.Vector3().addVectors(I.location, d.multiplyScalar(targetRadius)); - let controlsTargetPosition = I.location; - + // TODO Unused: let controlsTargetPosition = I.location; + var animationDuration = 600; var easing = TWEEN.Easing.Quartic.Out; - - { // animate - + + { // animate let value = {x: 0}; let tween = new TWEEN.Tween(value).to({x: 1}, animationDuration); tween.easing(easing); this.tweens.push(tween); - + let startPos = this.scene.view.position.clone(); let targetPos = cameraTargetPosition.clone(); let startRadius = this.scene.view.radius; let targetRadius = cameraTargetPosition.distanceTo(I.location); - - tween.onUpdate( () => { + + tween.onUpdate(() => { let t = value.x; this.scene.view.position.x = (1 - t) * startPos.x + t * targetPos.x; this.scene.view.position.y = (1 - t) * startPos.y + t * targetPos.y; this.scene.view.position.z = (1 - t) * startPos.z + t * targetPos.z; - + this.scene.view.radius = (1 - t) * startRadius + t * targetRadius; this.viewer.setMoveSpeed(this.scene.view.radius / 2.5); }); - - tween.onComplete( () => { - this.tweens = this.tweens.filter( e => e !== tween); + + tween.onComplete(() => { + this.tweens = this.tweens.filter(e => e !== tween); }); - + tween.start(); } } - - stopTweens(){ - this.tweens.forEach( e => e.stop() ); + + stopTweens () { + this.tweens.forEach(e => e.stop()); this.tweens = []; } - - update(delta){ - + + update (delta) { let view = this.scene.view; - + { // apply rotation let progression = Math.min(1, this.fadeFactor * delta); - + let yaw = view.yaw; let pitch = view.pitch; let pivot = view.getPivot(); - + yaw -= progression * this.yawDelta; pitch -= progression * this.pitchDelta; - + view.yaw = yaw; view.pitch = pitch; - + let V = this.scene.view.direction.multiplyScalar(-view.radius); let position = new THREE.Vector3().addVectors(pivot, V); - + view.position.copy(position); } - + { // apply pan let progression = Math.min(1, this.fadeFactor * delta); let panDistance = progression * view.radius * 3; - + let px = -this.panDelta.x * panDistance; let py = this.panDelta.y * panDistance; - + view.pan(px, py); } - + { // apply zoom let progression = Math.min(1, this.fadeFactor * delta); - - //let radius = view.radius + progression * this.radiusDelta * view.radius * 0.1; + + // let radius = view.radius + progression * this.radiusDelta * view.radius * 0.1; let radius = view.radius + progression * this.radiusDelta; - + let V = view.direction.multiplyScalar(-radius); let position = new THREE.Vector3().addVectors(view.getPivot(), V); view.radius = radius; - + view.position.copy(position); } - + { let speed = view.radius / 2.5; this.viewer.setMoveSpeed(speed); } - - {// decelerate over time + + { // decelerate over time let progression = Math.min(1, this.fadeFactor * delta); let attenuation = Math.max(0, 1 - this.fadeFactor * delta); - + this.yawDelta *= attenuation; this.pitchDelta *= attenuation; this.panDelta.multiplyScalar(attenuation); - //this.radiusDelta *= attenuation; - this.radiusDelta -= progression * this.radiusDelta + // this.radiusDelta *= attenuation; + this.radiusDelta -= progression * this.radiusDelta; } } - }; diff --git a/src/stuff/HoverMenu.js b/src/stuff/HoverMenu.js index 992bb4c6..07ba458a 100644 --- a/src/stuff/HoverMenu.js +++ b/src/stuff/HoverMenu.js @@ -1,91 +1,90 @@ -class HoverMenuItem{ - - constructor(icon, callback){ +/* globals HoverMenu:true HoverMenuItem:true */ +/* exported HoverMenu */ +/* exported HoverMenuItem */ +HoverMenuItem = class { + constructor (icon, callback) { this.icon = icon; this.callback = callback; - + this.element = $(` `); - - this.element.click(function(){ + + this.element.click(function () { callback(); }); } }; -class HoverMenu{ - - constructor(icon){ +HoverMenu = class { + constructor (icon) { let scope = this; - + this.items = []; - + this.x = 0; this.y = 0; this.circumference = 32; - + this.element = $(''); this.elIcon = $(` `); this.element.append(this.elIcon); - - this.element.click(function(){ - $(this).find(".hover_menu_item").fadeIn(200); - $(this).find(".hover_menu_icon").fadeOut(200); - - $(this).css("left", (scope.x - scope.circumference - $(this).width() / 2) + "px"); - $(this).css("top", (scope.y - scope.circumference - $(this).height() / 2) + "px"); - $(this).css("border", scope.circumference + "px solid transparent"); - }).mouseleave(function(){ - $(this).find(".hover_menu_item").fadeOut(200); - $(this).find(".hover_menu_icon").fadeIn(200); - - $(this).css("left", (scope.x - $(this).width() / 2) + "px"); - $(this).css("top", (scope.y - $(this).height() / 2) + "px"); - $(this).css("border", "0px solid black"); + + this.element.click(function () { + $(this).find('.hover_menu_item').fadeIn(200); + $(this).find('.hover_menu_icon').fadeOut(200); + + $(this).css('left', (scope.x - scope.circumference - $(this).width() / 2) + 'px'); + $(this).css('top', (scope.y - scope.circumference - $(this).height() / 2) + 'px'); + $(this).css('border', scope.circumference + 'px solid transparent'); + }).mouseleave(function () { + $(this).find('.hover_menu_item').fadeOut(200); + $(this).find('.hover_menu_icon').fadeIn(200); + + $(this).css('left', (scope.x - $(this).width() / 2) + 'px'); + $(this).css('top', (scope.y - $(this).height() / 2) + 'px'); + $(this).css('border', '0px solid black'); }); } - - addItem(item){ + + addItem (item) { this.items.push(item); this.element.append(item.element); item.element.hide(); - + this.arrange(); } - - removeItem(item){ + + removeItem (item) { this.items = this.items.filter(e => e !== item); this.element.remove(item.element); - + this.arrange(); } - - arrange(){ - let menuItems = this.element.find(".hover_menu_item"); - menuItems.each(function(index, value){ + + arrange () { + let menuItems = this.element.find('.hover_menu_item'); + menuItems.each(function (index, value) { let u = (index / menuItems.length) * Math.PI * 2; let radius = 22; let x = Math.cos(u) * radius;// + offset ; let y = Math.sin(u) * radius;// + offset ; - - $(this).css("left", x).css("top", y); - + + $(this).css('left', x).css('top', y); }); } - - setPosition(x, y){ + + setPosition (x, y) { this.x = x; this.y = y; - - let rect = this.element.get(0).getBoundingClientRect(); - - this.element.css("left", (this.x - rect.width / 2) + "px"); - this.element.css("top", (this.y - rect.height / 2) + "px"); - } -}; \ No newline at end of file + let rect = this.element.get(0).getBoundingClientRect(); + + this.element.css('left', (this.x - rect.width / 2) + 'px'); + this.element.css('top', (this.y - rect.height / 2) + 'px'); + } +}; diff --git a/src/utils.js b/src/utils.js index fbef3d06..791864a5 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,49 +1,47 @@ - -Potree.utils = class{ - - static loadShapefileFeatures(file, callback){ - +Potree.utils = class { + static loadShapefileFeatures (file, callback) { let features = []; - + let handleFinish = () => { callback(features); }; - + shapefile.open(file) - .then(source => {source.read() - .then(function log(result){ - if(result.done){ - handleFinish(); - return; - } - - //console.log(result.value); - - if(result.value && result.value.type === "Feature" && result.value.geometry !== undefined){ - features.push(result.value); - } - - return source.read().then(log); - }) - }); + .then(source => { + source.read() + .then(function log (result) { + if (result.done) { + handleFinish(); + return; + } + + // console.log(result.value); + + if (result.value && result.value.type === 'Feature' && result.value.geometry !== undefined) { + features.push(result.value); + } + + return source.read().then(log); + }); + }); } - - static toString(value){ - if(value instanceof THREE.Vector3){ - return value.x.toFixed(2) + ", " + value.y.toFixed(2) + ", " + value.z.toFixed(2); - }else{ - return "" + value + ""; + + static toString (value) { + if (value instanceof THREE.Vector3) { + return value.x.toFixed(2) + ', ' + value.y.toFixed(2) + ', ' + value.z.toFixed(2); + } else { + return '' + value + ''; } } - - static normalizeURL(url){ + + static normalizeURL (url) { let u = new URL(url); - - return u.protocol + "//" + u.hostname + u.pathname.replace(/\/+/g, "/"); + + return u.protocol + '//' + u.hostname + u.pathname.replace(/\/+/g, '/'); }; - static pathExists(url){ + static pathExists (url) { let req = new XMLHttpRequest(); req.open('GET', url, false); req.send(null); @@ -56,8 +54,7 @@ Potree.utils = class{ /** * adapted from mhluska at https://github.com/mrdoob/three.js/issues/1561 */ - static computeTransformedBoundingBox(box, transform){ - + static computeTransformedBoundingBox (box, transform) { let vertices = [ new THREE.Vector3(box.min.x, box.min.y, box.min.z).applyMatrix4(transform), new THREE.Vector3(box.min.x, box.min.y, box.min.z).applyMatrix4(transform), @@ -69,20 +66,20 @@ Potree.utils = class{ new THREE.Vector3(box.max.x, box.min.y, box.max.z).applyMatrix4(transform), new THREE.Vector3(box.max.x, box.max.y, box.max.z).applyMatrix4(transform) ]; - + let boundingBox = new THREE.Box3(); - boundingBox.setFromPoints( vertices ); - + boundingBox.setFromPoints(vertices); + return boundingBox; }; /** * add separators to large numbers - * + * * @param nStr * @returns */ - static addCommas(nStr){ + static addCommas (nStr) { nStr += ''; let x = nStr.split('.'); let x1 = x[0]; @@ -93,9 +90,9 @@ Potree.utils = class{ } return x1 + x2; }; - - static removeCommas(str){ - return str.replace(/,/g, ""); + + static removeCommas (str) { + return str.replace(/,/g, ''); } /** @@ -103,27 +100,27 @@ Potree.utils = class{ * * code from http://stackoverflow.com/questions/10343913/how-to-create-a-web-worker-from-a-string */ - static createWorker(code){ - let blob = new Blob([code], {type: 'application/javascript'}); - let worker = new Worker(URL.createObjectURL(blob)); - - return worker; + static createWorker (code) { + let blob = new Blob([code], {type: 'application/javascript'}); + let worker = new Worker(URL.createObjectURL(blob)); + + return worker; }; - static loadSkybox(path){ - let camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 100000 ); + static loadSkybox (path) { + let camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 100000); camera.up.set(0, 0, 1); let scene = new THREE.Scene(); - let format = ".jpg"; + let format = '.jpg'; let urls = [ path + 'px' + format, path + 'nx' + format, path + 'py' + format, path + 'ny' + format, path + 'pz' + format, path + 'nz' + format ]; - - //var materialArray = []; - //for (var i = 0; i < 6; i++){ + + // var materialArray = []; + // for (var i = 0; i < 6; i++){ // materialArray.push( new THREE.MeshBasicMaterial({ // map: THREE.ImageUtils.loadTexture( urls[i] ), // side: THREE.BackSide, @@ -131,169 +128,164 @@ Potree.utils = class{ // depthWrite: false // }) // ); - //} - + // } + let materialArray = []; { - for (let i = 0; i < 6; i++){ - + for (let i = 0; i < 6; i++) { let material = new THREE.MeshBasicMaterial({ map: null, side: THREE.BackSide, depthTest: false, depthWrite: false }); - + materialArray.push(material); - + let loader = new THREE.TextureLoader(); - loader.load( urls[i], - function loaded(texture){ + loader.load(urls[i], + function loaded (texture) { material.map = texture; material.needsUpdate = true; - },function progress(xhr){ - //console.log( (xhr.loaded / xhr.total * 100) + '% loaded' ); - },function error(xhr){ - console.log( 'An error happened', xhr ); + }, function progress (xhr) { + // console.log( (xhr.loaded / xhr.total * 100) + '% loaded' ); + }, function error (xhr) { + console.log('An error happened', xhr); } ); } - - } - - var skyGeometry = new THREE.CubeGeometry( 5000, 5000, 5000 ); - var skybox = new THREE.Mesh( skyGeometry, materialArray ); + + var skyGeometry = new THREE.CubeGeometry(5000, 5000, 5000); + var skybox = new THREE.Mesh(skyGeometry, materialArray); scene.add(skybox); - + // z up scene.rotation.x = Math.PI / 2; - - return {"camera": camera, "scene": scene}; + + return {'camera': camera, 'scene': scene}; }; - static createGrid(width, length, spacing, color){ + static createGrid (width, length, spacing, color) { let material = new THREE.LineBasicMaterial({ color: color || 0x888888 }); - + let geometry = new THREE.Geometry(); - for(let i = 0; i <= length; i++){ - geometry.vertices.push(new THREE.Vector3(-(spacing*width)/2, i*spacing-(spacing*length)/2, 0)); - geometry.vertices.push(new THREE.Vector3(+(spacing*width)/2, i*spacing-(spacing*length)/2, 0)); + for (let i = 0; i <= length; i++) { + geometry.vertices.push(new THREE.Vector3(-(spacing * width) / 2, i * spacing - (spacing * length) / 2, 0)); + geometry.vertices.push(new THREE.Vector3(+(spacing * width) / 2, i * spacing - (spacing * length) / 2, 0)); } - - for(let i = 0; i <= width; i++){ - geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, -(spacing*length)/2, 0)); - geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, +(spacing*length)/2, 0)); + + for (let i = 0; i <= width; i++) { + geometry.vertices.push(new THREE.Vector3(i * spacing - (spacing * width) / 2, -(spacing * length) / 2, 0)); + geometry.vertices.push(new THREE.Vector3(i * spacing - (spacing * width) / 2, +(spacing * length) / 2, 0)); } - + let line = new THREE.LineSegments(geometry, material, THREE.LinePieces); line.receiveShadow = true; return line; }; - - static createBackgroundTexture(width, height){ - - function gauss(x, y){ - return (1 / (2 * Math.PI)) * Math.exp( - (x*x + y*y) / 2); + static createBackgroundTexture (width, height) { + function gauss (x, y) { + return (1 / (2 * Math.PI)) * Math.exp(-(x * x + y * y) / 2); }; - //map.magFilter = THREE.NearestFilter; + // map.magFilter = THREE.NearestFilter; let size = width * height; - let data = new Uint8Array( 3 * size ); + let data = new Uint8Array(3 * size); let chroma = [1, 1.5, 1.7]; let max = gauss(0, 0); - for(let x = 0; x < width; x++){ - for(let y = 0; y < height; y++){ + for (let x = 0; x < width; x++) { + for (let y = 0; y < height; y++) { let u = 2 * (x / width) - 1; let v = 2 * (y / height) - 1; - - let i = x + width*y; - let d = gauss(2*u, 2*v) / max; + + let i = x + width * y; + let d = gauss(2 * u, 2 * v) / max; let r = (Math.random() + Math.random() + Math.random()) / 3; r = (d * 0.5 + 0.5) * r * 0.03; r = r * 0.4; - - //d = Math.pow(d, 0.6); - - data[3*i+0] = 255 * (d / 15 + 0.05 + r) * chroma[0]; - data[3*i+1] = 255 * (d / 15 + 0.05 + r) * chroma[1]; - data[3*i+2] = 255 * (d / 15 + 0.05 + r) * chroma[2]; + + // d = Math.pow(d, 0.6); + + data[3 * i + 0] = 255 * (d / 15 + 0.05 + r) * chroma[0]; + data[3 * i + 1] = 255 * (d / 15 + 0.05 + r) * chroma[1]; + data[3 * i + 2] = 255 * (d / 15 + 0.05 + r) * chroma[2]; } } - - let texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat ); + + let texture = new THREE.DataTexture(data, width, height, THREE.RGBFormat); texture.needsUpdate = true; - + return texture; }; - static getMousePointCloudIntersection(mouse, camera, renderer, pointclouds){ - let nmouse = { - x: (mouse.x / renderer.domElement.clientWidth ) * 2 - 1, - y: - (mouse.y / renderer.domElement.clientHeight ) * 2 + 1 + static getMousePointCloudIntersection (mouse, camera, renderer, pointclouds) { + let nmouse = { + x: (mouse.x / renderer.domElement.clientWidth) * 2 - 1, + y: -(mouse.y / renderer.domElement.clientHeight) * 2 + 1 }; - - //let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); - //vector.unproject(camera); - //let direction = vector.sub(camera.position).normalize(); - //let ray = new THREE.Ray(camera.position, direction); - + // let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + // vector.unproject(camera); + + // let direction = vector.sub(camera.position).normalize(); + // let ray = new THREE.Ray(camera.position, direction); + let raycaster = new THREE.Raycaster(); raycaster.setFromCamera(nmouse, camera); let ray = raycaster.ray; - + let selectedPointcloud = null; let closestDistance = Infinity; let closestIntersection = null; let closestPoint = null; - - for(let pointcloud of pointclouds){ + + for (let pointcloud of pointclouds) { let point = pointcloud.pick(renderer, camera, ray); - - if(!point){ + + if (!point) { continue; } - + let distance = camera.position.distanceTo(point.position); - - if(distance < closestDistance){ + + if (distance < closestDistance) { closestDistance = distance; selectedPointcloud = pointcloud; closestIntersection = point.position; closestPoint = point; } } - - if(selectedPointcloud){ + + if (selectedPointcloud) { return { location: closestIntersection, distance: closestDistance, pointcloud: selectedPointcloud, point: closestPoint }; - }else{ + } else { return null; } - }; - - static pixelsArrayToImage(pixels, width, height){ + }; + + static pixelsArrayToImage (pixels, width, height) { let canvas = document.createElement('canvas'); canvas.width = width; canvas.height = height; let context = canvas.getContext('2d'); - + pixels = new pixels.constructor(pixels); - - for(let i = 0; i < pixels.length; i++){ - pixels[i*4 + 3] = 255; + + for (let i = 0; i < pixels.length; i++) { + pixels[i * 4 + 3] = 255; } let imageData = context.createImageData(width, height); @@ -302,131 +294,124 @@ Potree.utils = class{ let img = new Image(); img.src = canvas.toDataURL(); - //img.style.transform = "scaleY(-1)"; - + // img.style.transform = "scaleY(-1)"; + return img; }; - static projectedRadius(radius, fov, distance, screenHeight){ - let projFactor = (1 / Math.tan(fov / 2)) / distance; + static projectedRadius (radius, fov, distance, screenHeight) { + let projFactor = (1 / Math.tan(fov / 2)) / distance; projFactor = projFactor * screenHeight / 2; - + return radius * projFactor; }; - - - static topView(camera, node){ + + static topView (camera, node) { camera.position.set(0, 1, 0); camera.rotation.set(-Math.PI / 2, 0, 0); camera.zoomTo(node, 1); }; - static frontView(camera, node){ + static frontView (camera, node) { camera.position.set(0, 0, 1); camera.rotation.set(0, 0, 0); camera.zoomTo(node, 1); }; - - static leftView(camera, node){ + static leftView (camera, node) { camera.position.set(-1, 0, 0); camera.rotation.set(0, -Math.PI / 2, 0); camera.zoomTo(node, 1); }; - static rightView(camera, node){ + static rightView (camera, node) { camera.position.set(1, 0, 0); camera.rotation.set(0, Math.PI / 2, 0); camera.zoomTo(node, 1); }; - + /** - * + * * 0: no intersection * 1: intersection * 2: fully inside */ - static frustumSphereIntersection(frustum, sphere){ + static frustumSphereIntersection (frustum, sphere) { let planes = frustum.planes; let center = sphere.center; - let negRadius = - sphere.radius; + let negRadius = -sphere.radius; let minDistance = Number.MAX_VALUE; - - for ( let i = 0; i < 6; i ++ ) { - let distance = planes[ i ].distanceToPoint( center ); - - if ( distance < negRadius ) { + for (let i = 0; i < 6; i++) { + let distance = planes[ i ].distanceToPoint(center); + if (distance < negRadius) { return 0; - } - - minDistance = Math.min(minDistance, distance); + minDistance = Math.min(minDistance, distance); } return (minDistance >= sphere.radius) ? 2 : 1; }; - + // code taken from three.js // ImageUtils - generateDataTexture() - static generateDataTexture(width, height, color){ + static generateDataTexture (width, height, color) { let size = width * height; let data = new Uint8Array(3 * width * height); - - let r = Math.floor( color.r * 255 ); - let g = Math.floor( color.g * 255 ); - let b = Math.floor( color.b * 255 ); - - for ( let i = 0; i < size; i ++ ) { - data[ i * 3 ] = r; + + let r = Math.floor(color.r * 255); + let g = Math.floor(color.g * 255); + let b = Math.floor(color.b * 255); + + for (let i = 0; i < size; i++) { + data[ i * 3 ] = r; data[ i * 3 + 1 ] = g; data[ i * 3 + 2 ] = b; } - - let texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat ); + + let texture = new THREE.DataTexture(data, width, height, THREE.RGBFormat); texture.needsUpdate = true; texture.magFilter = THREE.NearestFilter; - + return texture; }; - + // from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript - static getParameterByName(name) { - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - let regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); - return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, " ")); + static getParameterByName (name) { + name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]'); + let regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); + let results = regex.exec(document.location.search); + return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, ' ')); } - - static setParameter(name, value){ - //value = encodeURIComponent(value); - - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - let regex = new RegExp("([\\?&])(" + name + "=([^&#]*))"); - let results = regex.exec(location.search); + + static setParameter (name, value) { + // value = encodeURIComponent(value); + + name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]'); + let regex = new RegExp('([\\?&])(' + name + '=([^&#]*))'); + let results = regex.exec(document.location.search); let url = window.location.href; - if(results === null){ - if(window.location.search.length === 0){ - url = url + "?"; - }else{ - url = url + "&"; + if (results === null) { + if (window.location.search.length === 0) { + url = url + '?'; + } else { + url = url + '&'; } - url = url + name + "=" + value; - }else{ - let newValue = name + "=" + value; + url = url + name + '=' + value; + } else { + let newValue = name + '=' + value; url = url.replace(results[2], newValue); } - window.history.replaceState({}, "", url); + window.history.replaceState({}, '', url); } - }; -Potree.utils.screenPass = new function(){ - +Potree.utils.screenPass = new function () { this.screenScene = new THREE.Scene(); this.screenQuad = new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2, 0)); this.screenQuad.material.depthTest = true; @@ -434,16 +419,14 @@ Potree.utils.screenPass = new function(){ this.screenQuad.material.transparent = true; this.screenScene.add(this.screenQuad); this.camera = new THREE.Camera(); - - this.render = function(renderer, material, target){ + + this.render = function (renderer, material, target) { this.screenQuad.material = material; - - if(typeof target === "undefined"){ + + if (typeof target === 'undefined') { renderer.render(this.screenScene, this.camera); - }else{ + } else { renderer.render(this.screenScene, this.camera, target); } }; }(); - - diff --git a/src/utils/Box3Helper.js b/src/utils/Box3Helper.js index 83092659..702ad4d6 100644 --- a/src/utils/Box3Helper.js +++ b/src/utils/Box3Helper.js @@ -8,14 +8,12 @@ * @author mschuetz / http://potree.org */ -Potree.Box3Helper = class Box3Helper extends THREE.LineSegments{ - - constructor(box, color){ - - if ( color === undefined ) color = 0xffff00; +Potree.Box3Helper = class Box3Helper extends THREE.LineSegments { + constructor (box, color) { + if (color === undefined) color = 0xffff00; let indices = new Uint16Array([ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ]); - let positions = new Float32Array( [ + let positions = new Float32Array([ box.min.x, box.min.y, box.min.z, box.max.x, box.min.y, box.min.z, box.max.x, box.min.y, box.max.z, @@ -27,12 +25,11 @@ Potree.Box3Helper = class Box3Helper extends THREE.LineSegments{ ]); let geometry = new THREE.BufferGeometry(); - geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) ); - geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); + geometry.setIndex(new THREE.BufferAttribute(indices, 1)); + geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3)); + + let material = new THREE.LineBasicMaterial({ color: color }); - let material = new THREE.LineBasicMaterial( { color: color } ) ; - super(geometry, material); } - -} +}; diff --git a/src/utils/Measure.js b/src/utils/Measure.js index 656b43c7..ecb286da 100644 --- a/src/utils/Measure.js +++ b/src/utils/Measure.js @@ -1,11 +1,11 @@ -Potree.Measure = class Measure extends THREE.Object3D{ - constructor(){ +Potree.Measure = class Measure extends THREE.Object3D { + constructor () { super(); - + this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1; - - this.name = "Measure_" + this.constructor.counter; + + this.name = 'Measure_' + this.constructor.counter; this.points = []; this._showDistances = true; this._showCoordinates = false; @@ -14,410 +14,402 @@ Potree.Measure = class Measure extends THREE.Object3D{ this._showAngles = false; this._showHeight = false; this.maxMarkers = Number.MAX_SAFE_INTEGER; - - this.sphereGeometry = new THREE.SphereGeometry(0.4, 10, 10); - this.color = new THREE.Color( 0xff0000 ); - this.lengthUnit = {code: "m"}; - + this.sphereGeometry = new THREE.SphereGeometry(0.4, 10, 10); + this.color = new THREE.Color(0xff0000); + + this.lengthUnit = {code: 'm'}; + this.spheres = []; this.edges = []; this.sphereLabels = []; this.edgeLabels = []; this.angleLabels = []; this.coordinateLabels = []; - - this.heightEdge; - this.heightLabel; + + // this.heightEdge; + // this.heightLabel; { // height stuff - { // height line let lineGeometry = new THREE.Geometry(); lineGeometry.vertices.push( - new THREE.Vector3(), - new THREE.Vector3(), - new THREE.Vector3(), + new THREE.Vector3(), + new THREE.Vector3(), + new THREE.Vector3(), new THREE.Vector3()); lineGeometry.colors.push(this.color, this.color, this.color); - let lineMaterial = new THREE.LineDashedMaterial( - { color: 0xff0000, dashSize: 5, gapSize: 2 } ); - + let lineMaterial = new THREE.LineDashedMaterial( + { color: 0xff0000, dashSize: 5, gapSize: 2 }); + lineMaterial.depthTest = false; this.heightEdge = new THREE.Line(lineGeometry, lineMaterial); this.heightEdge.visible = false; - + this.add(this.heightEdge); } - + { // height label - this.heightLabel = new Potree.TextSprite(""); - this.heightLabel.setBorderColor({r:0, g:0, b:0, a:0.8}); - this.heightLabel.setBackgroundColor({r:0, g:0, b:0, a:0.3}); - this.heightLabel.setTextColor({r:180, g:220, b:180, a:1.0}); + this.heightLabel = new Potree.TextSprite(''); + this.heightLabel.setBorderColor({r: 0, g: 0, b: 0, a: 0.8}); + this.heightLabel.setBackgroundColor({r: 0, g: 0, b: 0, a: 0.3}); + this.heightLabel.setTextColor({r: 180, g: 220, b: 180, a: 1.0}); this.heightLabel.material.depthTest = false; this.heightLabel.material.opacity = 1; - this.heightLabel.visible = false;; + this.heightLabel.visible = false; ; this.add(this.heightLabel); } } - - this.areaLabel = new Potree.TextSprite(""); - this.areaLabel.setBorderColor({r:0, g:0, b:0, a:0.8}); - this.areaLabel.setBackgroundColor({r:0, g:0, b:0, a:0.3}); - this.areaLabel.setTextColor({r:180, g:220, b:180, a:1.0}); + + this.areaLabel = new Potree.TextSprite(''); + this.areaLabel.setBorderColor({r: 0, g: 0, b: 0, a: 0.8}); + this.areaLabel.setBackgroundColor({r: 0, g: 0, b: 0, a: 0.3}); + this.areaLabel.setTextColor({r: 180, g: 220, b: 180, a: 1.0}); this.areaLabel.material.depthTest = false; this.areaLabel.material.opacity = 1; - this.areaLabel.visible = false;; + this.areaLabel.visible = false; ; this.add(this.areaLabel); - - } - - createSphereMaterial(){ + + createSphereMaterial () { let sphereMaterial = new THREE.MeshLambertMaterial({ - shading: THREE.SmoothShading, - color: this.color, - depthTest: false, + shading: THREE.SmoothShading, + color: this.color, + depthTest: false, depthWrite: false} ); - + return sphereMaterial; }; - - addMarker(point){ - if(point instanceof THREE.Vector3){ + + addMarker (point) { + if (point instanceof THREE.Vector3) { point = {position: point}; } this.points.push(point); - + // sphere let sphere = new THREE.Mesh(this.sphereGeometry, this.createSphereMaterial()); - + this.add(sphere); this.spheres.push(sphere); - + { // edges let lineGeometry = new THREE.Geometry(); lineGeometry.vertices.push(new THREE.Vector3(), new THREE.Vector3()); lineGeometry.colors.push(this.color, this.color, this.color); - let lineMaterial = new THREE.LineBasicMaterial( { + let lineMaterial = new THREE.LineBasicMaterial({ linewidth: 1 }); lineMaterial.depthTest = false; let edge = new THREE.Line(lineGeometry, lineMaterial); edge.visible = true; - + this.add(edge); this.edges.push(edge); } - - + { // edge labels let edgeLabel = new Potree.TextSprite(); - edgeLabel.setBorderColor({r:0, g:0, b:0, a:0.8}); - edgeLabel.setBackgroundColor({r:0, g:0, b:0, a:0.3}); + edgeLabel.setBorderColor({r: 0, g: 0, b: 0, a: 0.8}); + edgeLabel.setBackgroundColor({r: 0, g: 0, b: 0, a: 0.3}); edgeLabel.material.depthTest = false; edgeLabel.visible = false; this.edgeLabels.push(edgeLabel); this.add(edgeLabel); } - + { // angle labels let angleLabel = new Potree.TextSprite(); - angleLabel.setBorderColor({r:0, g:0, b:0, a:0.8}); - angleLabel.setBackgroundColor({r:0, g:0, b:0, a:0.3}); - angleLabel.material.depthTest = false; - angleLabel.material.opacity = 1; + angleLabel.setBorderColor({r: 0, g: 0, b: 0, a: 0.8}); + angleLabel.setBackgroundColor({r: 0, g: 0, b: 0, a: 0.3}); + angleLabel.material.depthTest = false; + angleLabel.material.opacity = 1; angleLabel.visible = false; this.angleLabels.push(angleLabel); this.add(angleLabel); } - + { // coordinate labels let coordinateLabel = new Potree.TextSprite(); - coordinateLabel.setBorderColor({r:0, g:0, b:0, a:0.8}); - coordinateLabel.setBackgroundColor({r:0, g:0, b:0, a:0.3}); + coordinateLabel.setBorderColor({r: 0, g: 0, b: 0, a: 0.8}); + coordinateLabel.setBackgroundColor({r: 0, g: 0, b: 0, a: 0.3}); coordinateLabel.material.depthTest = false; coordinateLabel.material.opacity = 1; coordinateLabel.visible = false; this.coordinateLabels.push(coordinateLabel); this.add(coordinateLabel); } - + { // Event Listeners let drag = (e) => { let I = Potree.utils.getMousePointCloudIntersection( - e.drag.end, - e.viewer.scene.camera, - e.viewer.renderer, + e.drag.end, + e.viewer.scene.camera, + e.viewer.renderer, e.viewer.scene.pointclouds); - - if(I){ + + if (I) { let i = this.spheres.indexOf(e.drag.object); - if(i !== -1){ - + if (i !== -1) { let point = this.points[i]; - for(let key of Object.keys(I.point).filter(e => e !== "position")){ + for (let key of Object.keys(I.point).filter(e => e !== 'position')) { point[key] = I.point[key]; } - + this.setPosition(i, I.location); } } }; - + let drop = e => { let i = this.spheres.indexOf(e.drag.object); - if(i !== -1){ + if (i !== -1) { this.dispatchEvent({ - "type": "marker_dropped", - "measurement": this, - "index": i + 'type': 'marker_dropped', + 'measurement': this, + 'index': i }); } }; - + let mouseover = (e) => e.object.material.emissive.setHex(0x888888); let mouseleave = (e) => e.object.material.emissive.setHex(0x000000); - - sphere.addEventListener("drag", drag); - sphere.addEventListener("drop", drop); - sphere.addEventListener("mouseover", mouseover); - sphere.addEventListener("mouseleave", mouseleave); + + sphere.addEventListener('drag', drag); + sphere.addEventListener('drop', drop); + sphere.addEventListener('mouseover', mouseover); + sphere.addEventListener('mouseleave', mouseleave); } let event = { - type: "marker_added", + type: 'marker_added', measurement: this, sphere: sphere }; this.dispatchEvent(event); - - this.setMarker(this.points.length-1, point); + + this.setMarker(this.points.length - 1, point); }; - - removeMarker(index){ + + removeMarker (index) { this.points.splice(index, 1); - + this.remove(this.spheres[index]); - + let edgeIndex = (index === 0) ? 0 : (index - 1); this.remove(this.edges[edgeIndex]); this.edges.splice(edgeIndex, 1); - + this.remove(this.edgeLabels[edgeIndex]); this.edgeLabels.splice(edgeIndex, 1); this.coordinateLabels.splice(index, 1); - + this.spheres.splice(index, 1); - + this.update(); - - this.dispatchEvent({type: "marker_removed", measurement: this}); + + this.dispatchEvent({type: 'marker_removed', measurement: this}); }; - - setMarker(index, point){ + + setMarker (index, point) { this.points[index] = point; - + let event = { - type: 'marker_moved', + type: 'marker_moved', measure: this, - index: index, - position: point.position.clone() + index: index, + position: point.position.clone() }; this.dispatchEvent(event); - + this.update(); } - - setPosition(index, position){ - let point = this.points[index]; + + setPosition (index, position) { + let point = this.points[index]; point.position.copy(position); - + let event = { - type: 'marker_moved', + type: 'marker_moved', measure: this, - index: index, - position: position.clone() + index: index, + position: position.clone() }; this.dispatchEvent(event); - + this.update(); }; - - getArea(){ + + getArea () { let area = 0; let j = this.points.length - 1; - - for(let i = 0; i < this.points.length; i++){ + + for (let i = 0; i < this.points.length; i++) { let p1 = this.points[i].position; let p2 = this.points[j].position; area += (p2.x + p1.x) * (p1.y - p2.y); j = i; } - + return Math.abs(area / 2); }; - - getTotalDistance(){ - - if(this.points.length === 0){ + + getTotalDistance () { + if (this.points.length === 0) { return 0; } - + let distance = 0; - - for(let i = 1; i < this.points.length; i++){ - let prev = this.points[i-1].position; + + for (let i = 1; i < this.points.length; i++) { + let prev = this.points[i - 1].position; let curr = this.points[i].position; let d = prev.distanceTo(curr); - + distance += d; } - - if(this.closed && this.points.length > 1){ + + if (this.closed && this.points.length > 1) { let first = this.points[0].position; let last = this.points[this.points.length - 1].position; let d = last.distanceTo(first); - + distance += d; } - + return distance; } - - getAngleBetweenLines(cornerPoint, point1, point2) { - let v1 = new THREE.Vector3().subVectors(point1.position, cornerPoint.position); - let v2 = new THREE.Vector3().subVectors(point2.position, cornerPoint.position); - return v1.angleTo(v2); - }; - - getAngle(index){ - - if(this.points.length < 3 || index >= this.points.length){ + + getAngleBetweenLines (cornerPoint, point1, point2) { + let v1 = new THREE.Vector3().subVectors(point1.position, cornerPoint.position); + let v2 = new THREE.Vector3().subVectors(point2.position, cornerPoint.position); + return v1.angleTo(v2); + }; + + getAngle (index) { + if (this.points.length < 3 || index >= this.points.length) { return 0; } - - let previous = (index === 0) ? this.points[this.points.length-1] : this.points[index-1]; + + let previous = (index === 0) ? this.points[this.points.length - 1] : this.points[index - 1]; let point = this.points[index]; let next = this.points[(index + 1) % (this.points.length)]; - + return this.getAngleBetweenLines(point, previous, next); }; - - update(){ - - if(this.points.length === 0){ + + update () { + if (this.points.length === 0) { return; - }else if(this.points.length === 1){ + } else if (this.points.length === 1) { let point = this.points[0]; let position = point.position; this.spheres[0].position.copy(position); - - {// coordinate labels + + { // coordinate labels let coordinateLabel = this.coordinateLabels[0]; - - let labelPos = position.clone().add(new THREE.Vector3(0,1,0)); + + let labelPos = position.clone().add(new THREE.Vector3(0, 1, 0)); coordinateLabel.position.copy(labelPos); - - /*let msg = Potree.utils.addCommas(position.x.toFixed(2)) - + " / " + Potree.utils.addCommas(position.y.toFixed(2)) - + " / " + Potree.utils.addCommas(position.z.toFixed(2));*/ - let msg = Potree.utils.addCommas(position.z.toFixed(2) + " " + this.lengthUnit.code); + + /* let msg = Potree.utils.addCommas(position.x.toFixed(2)) + + " / " + Potree.utils.addCommas(position.y.toFixed(2)) + + " / " + Potree.utils.addCommas(position.z.toFixed(2)); */ + let msg = Potree.utils.addCommas(position.z.toFixed(2) + ' ' + this.lengthUnit.code); coordinateLabel.setText(msg); - + coordinateLabel.visible = this.showCoordinates; } - + return; } - + let lastIndex = this.points.length - 1; - + let centroid = new THREE.Vector3(); - for(let i = 0; i <= lastIndex; i++){ + for (let i = 0; i <= lastIndex; i++) { let point = this.points[i]; centroid.add(point.position); } centroid.divideScalar(this.points.length); - - for(let i = 0; i <= lastIndex; i++){ + + for (let i = 0; i <= lastIndex; i++) { let index = i; - let nextIndex = ( i + 1 > lastIndex ) ? 0 : i + 1; + let nextIndex = (i + 1 > lastIndex) ? 0 : i + 1; let previousIndex = (i === 0) ? lastIndex : i - 1; - + let point = this.points[index]; let nextPoint = this.points[nextIndex]; let previousPoint = this.points[previousIndex]; - + let sphere = this.spheres[index]; - + // spheres sphere.position.copy(point.position); sphere.material.color = this.color; - {// edges + { // edges let edge = this.edges[index]; - + edge.material.color = this.color; - + edge.position.copy(point.position); - + edge.geometry.vertices[0].set(0, 0, 0); edge.geometry.vertices[1].copy(nextPoint.position).sub(point.position); - + edge.geometry.verticesNeedUpdate = true; edge.geometry.computeBoundingSphere(); edge.visible = index < lastIndex || this.closed; } - - {// edge labels + + { // edge labels let edgeLabel = this.edgeLabels[i]; - + let center = new THREE.Vector3().add(point.position); center.add(nextPoint.position); center = center.multiplyScalar(0.5); let distance = point.position.distanceTo(nextPoint.position); - + edgeLabel.position.copy(center); - edgeLabel.setText(Potree.utils.addCommas(distance.toFixed(2)) + " " + this.lengthUnit.code); + edgeLabel.setText(Potree.utils.addCommas(distance.toFixed(2)) + ' ' + this.lengthUnit.code); edgeLabel.visible = this.showDistances && (index < lastIndex || this.closed) && this.points.length >= 2 && distance > 0; } - - {// angle labels + + { // angle labels let angleLabel = this.angleLabels[i]; let angle = this.getAngleBetweenLines(point, previousPoint, nextPoint); - + let dir = nextPoint.position.clone().sub(previousPoint.position); dir.multiplyScalar(0.5); dir = previousPoint.position.clone().add(dir).sub(point.position).normalize(); - + let dist = Math.min(point.position.distanceTo(previousPoint.position), point.position.distanceTo(nextPoint.position)); dist = dist / 9; - + let labelPos = point.position.clone().add(dir.multiplyScalar(dist)); angleLabel.position.copy(labelPos); - - let msg = Potree.utils.addCommas((angle*(180.0/Math.PI)).toFixed(1)) + '\u00B0'; + + let msg = Potree.utils.addCommas((angle * (180.0 / Math.PI)).toFixed(1)) + '\u00B0'; angleLabel.setText(msg); - + angleLabel.visible = this.showAngles && (index < lastIndex || this.closed) && this.points.length >= 3 && angle > 0; } - - {// coordinate labels - let coordinateLabel = this.coordinateLabels[0]; - - let labelPos = point.position.clone().add(new THREE.Vector3(0,1,0)); - coordinateLabel.position.copy(labelPos); - - /*let msg = Potree.utils.addCommas(point.position.x.toFixed(2)) - + " / " + Potree.utils.addCommas(point.position.y.toFixed(2)) - + " / " + Potree.utils.addCommas(point.position.z.toFixed(2));*/ - let msg = Potree.utils.addCommas(point.position.z.toFixed(2) + " " + this.lengthUnit.code); + { // coordinate labels + let coordinateLabel = this.coordinateLabels[0]; + + let labelPos = point.position.clone().add(new THREE.Vector3(0, 1, 0)); + coordinateLabel.position.copy(labelPos); + + /* let msg = Potree.utils.addCommas(point.position.x.toFixed(2)) + + " / " + Potree.utils.addCommas(point.position.y.toFixed(2)) + + " / " + Potree.utils.addCommas(point.position.z.toFixed(2)); */ + + let msg = Potree.utils.addCommas(point.position.z.toFixed(2) + ' ' + this.lengthUnit.code); coordinateLabel.setText(msg); - - //coordinateLabel.visible = this.showCoordinates && (index < lastIndex || this.closed); + + // coordinateLabel.visible = this.showCoordinates && (index < lastIndex || this.closed); coordinateLabel.visible = this.showCoordinates; } } @@ -426,120 +418,117 @@ Potree.Measure = class Measure extends THREE.Object3D{ let heightEdge = this.heightEdge; heightEdge.visible = this.showHeight; this.heightLabel.visible = this.showHeight; - - if(this.showHeight){ - let sorted = this.points.slice().sort( (a, b) => a.position.z - b.position.z ); + + if (this.showHeight) { + let sorted = this.points.slice().sort((a, b) => a.position.z - b.position.z); let lowPoint = sorted[0].position.clone(); let highPoint = sorted[sorted.length - 1].position.clone(); let min = lowPoint.z; let max = highPoint.z; let height = max - min; - + let start = new THREE.Vector3(highPoint.x, highPoint.y, min); let end = new THREE.Vector3(highPoint.x, highPoint.y, max); - + heightEdge.position.copy(lowPoint); - + heightEdge.geometry.vertices[0].set(0, 0, 0); heightEdge.geometry.vertices[1].copy(start).sub(lowPoint); heightEdge.geometry.vertices[2].copy(start).sub(lowPoint); heightEdge.geometry.vertices[3].copy(end).sub(lowPoint); - + heightEdge.geometry.verticesNeedUpdate = true; - //heightEdge.geometry.computeLineDistances(); - //heightEdge.geometry.lineDistancesNeedUpdate = true; + // heightEdge.geometry.computeLineDistances(); + // heightEdge.geometry.lineDistancesNeedUpdate = true; heightEdge.geometry.computeBoundingSphere(); - - //heightEdge.material.dashSize = height / 40; - //heightEdge.material.gapSize = height / 40; - - + + // heightEdge.material.dashSize = height / 40; + // heightEdge.material.gapSize = height / 40; + let heightLabelPosition = start.clone().add(end).multiplyScalar(0.5); this.heightLabel.position.copy(heightLabelPosition); - let msg = Potree.utils.addCommas(height.toFixed(2)) + " " + this.lengthUnit.code; + let msg = Potree.utils.addCommas(height.toFixed(2)) + ' ' + this.lengthUnit.code; this.heightLabel.setText(msg); } - } - + { // update area label this.areaLabel.position.copy(centroid); this.areaLabel.visible = this.showArea && this.points.length >= 3; - let msg = Potree.utils.addCommas(this.getArea().toFixed(1)) + " " + this.lengthUnit.code + "\u00B2"; + let msg = Potree.utils.addCommas(this.getArea().toFixed(1)) + ' ' + this.lengthUnit.code + '\u00B2'; this.areaLabel.setText(msg); } }; - - raycast(raycaster, intersects){ - - for(let i = 0; i < this.points.length; i++){ + + raycast (raycaster, intersects) { + for (let i = 0; i < this.points.length; i++) { let sphere = this.spheres[i]; - + sphere.raycast(raycaster, intersects); } - + // recalculate distances because they are not necessarely correct // for scaled objects. // see https://github.com/mrdoob/three.js/issues/5827 // TODO: remove this once the bug has been fixed - for(let i = 0; i < intersects.length; i++){ + for (let i = 0; i < intersects.length; i++) { let I = intersects[i]; I.distance = raycaster.ray.origin.distanceTo(I.point); } - intersects.sort( function ( a, b ) { return a.distance - b.distance;} ); + intersects.sort(function (a, b) { return a.distance - b.distance; }); }; - - get showCoordinates(){ + + get showCoordinates () { return this._showCoordinates; } - - set showCoordinates(value){ + + set showCoordinates (value) { this._showCoordinates = value; this.update(); } - - get showAngles(){ + + get showAngles () { return this._showAngles; } - - set showAngles(value){ + + set showAngles (value) { this._showAngles = value; this.update(); } - - get showHeight(){ + + get showHeight () { return this._showHeight; } - - set showHeight(value){ + + set showHeight (value) { this._showHeight = value; this.update(); } - - get showArea(){ + + get showArea () { return this._showArea; } - - set showArea(value){ + + set showArea (value) { this._showArea = value; this.update(); } - - get closed(){ + + get closed () { return this._closed; } - - set closed(value){ + + set closed (value) { this._closed = value; this.update(); } - - get showDistances(){ + + get showDistances () { return this._showDistances; } - - set showDistances(value){ + + set showDistances (value) { this._showDistances = value; this.update(); } -}; \ No newline at end of file +}; diff --git a/src/utils/MeasuringTool.js b/src/utils/MeasuringTool.js index 6890cf2d..5f07f98c 100644 --- a/src/utils/MeasuringTool.js +++ b/src/utils/MeasuringTool.js @@ -1,239 +1,218 @@ - -Potree.MeasuringTool = class MeasuringTool extends THREE.EventDispatcher{ - - constructor(viewer){ +Potree.MeasuringTool = class MeasuringTool extends THREE.EventDispatcher { + constructor (viewer) { super(); - + this.viewer = viewer; this.renderer = viewer.renderer; - - this.addEventListener("start_inserting_measurement", e => { + + this.addEventListener('start_inserting_measurement', e => { this.viewer.dispatchEvent({ - type: "cancel_insertions" + type: 'cancel_insertions' }); }); - + this.sceneMeasurement = new THREE.Scene(); - this.sceneMeasurement.name = "scene_measurement"; - this.light = new THREE.PointLight( 0xffffff, 1.0 ); + this.sceneMeasurement.name = 'scene_measurement'; + this.light = new THREE.PointLight(0xffffff, 1.0); this.sceneMeasurement.add(this.light); - + this.viewer.inputHandler.registerInteractiveScene(this.sceneMeasurement); - - this.onRemove = (e) => {this.sceneMeasurement.remove(e.measurement)}; - this.onAdd = e => {this.sceneMeasurement.add(e.measurement)}; + + this.onRemove = (e) => { this.sceneMeasurement.remove(e.measurement); }; + this.onAdd = e => { this.sceneMeasurement.add(e.measurement); }; } - - setScene(scene){ - if(this.scene === scene){ + + setScene (scene) { + if (this.scene === scene) { return; } - - if(this.scene){ - this.scene.removeEventListener("measurement_added", this.onAdd); - this.scene.removeEventListener("measurement_removed", this.onRemove); + + if (this.scene) { + this.scene.removeEventListener('measurement_added', this.onAdd); + this.scene.removeEventListener('measurement_removed', this.onRemove); } - + this.scene = scene; - - this.scene.addEventListener("measurement_added", this.onAdd); - this.scene.addEventListener("measurement_removed", this.onRemove); - + + this.scene.addEventListener('measurement_added', this.onAdd); + this.scene.addEventListener('measurement_removed', this.onRemove); } - - startInsertion(args = {}){ - + + startInsertion (args = {}) { let domElement = this.viewer.renderer.domElement; - + let measure = new Potree.Measure(); - + this.dispatchEvent({ - type: "start_inserting_measurement", + type: 'start_inserting_measurement', measure: measure }); - measure.showDistances = (args.showDistances == null) ? true : args.showDistances; + measure.showDistances = (args.showDistances == null) ? true : args.showDistances; measure.showArea = args.showArea || false; measure.showAngles = args.showAngles || false; measure.showCoordinates = args.showCoordinates || false; measure.showHeight = args.showHeight || false; measure.closed = args.closed || false; measure.maxMarkers = args.maxMarkers || Infinity; - measure.name = args.name || "Measurement"; - + measure.name = args.name || 'Measurement'; + this.sceneMeasurement.add(measure); - + let cancel = { removeLastMarker: measure.maxMarkers > 3, callback: null }; - + let insertionCallback = (e) => { - if(e.button === THREE.MOUSE.LEFT){ - + if (e.button === THREE.MOUSE.LEFT) { measure.addMarker(measure.points[measure.points.length - 1].position.clone()); - - if(measure.points.length >= measure.maxMarkers){ + + if (measure.points.length >= measure.maxMarkers) { cancel.callback(); } - + this.viewer.inputHandler.startDragging( measure.spheres[measure.spheres.length - 1]); - }else if(e.button === THREE.MOUSE.RIGHT){ + } else if (e.button === THREE.MOUSE.RIGHT) { cancel.callback(); } }; - + cancel.callback = e => { - if(cancel.removeLastMarker){ + if (cancel.removeLastMarker) { measure.removeMarker(measure.points.length - 1); } - domElement.removeEventListener("mouseup", insertionCallback, true); - this.viewer.removeEventListener("cancel_insertions", cancel.callback); + domElement.removeEventListener('mouseup', insertionCallback, true); + this.viewer.removeEventListener('cancel_insertions', cancel.callback); }; - - if(measure.maxMarkers > 1){ - this.viewer.addEventListener("cancel_insertions", cancel.callback); - domElement.addEventListener("mouseup", insertionCallback , true); + + if (measure.maxMarkers > 1) { + this.viewer.addEventListener('cancel_insertions', cancel.callback); + domElement.addEventListener('mouseup', insertionCallback, true); } - + measure.addMarker(new THREE.Vector3(0, 0, 0)); this.viewer.inputHandler.startDragging( measure.spheres[measure.spheres.length - 1]); - + this.viewer.scene.addMeasurement(measure); } - - update(){ + + update () { let camera = this.viewer.scene.camera; let domElement = this.renderer.domElement; let measurements = this.viewer.scene.measurements; - + this.light.position.copy(camera.position); - + // make size independant of distance - for(let measure of measurements){ - + for (let measure of measurements) { measure.lengthUnit = this.viewer.lengthUnit; measure.update(); // spheres - for(let sphere of measure.spheres){ + for (let sphere of measure.spheres) { let distance = camera.position.distanceTo(sphere.getWorldPosition()); let pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, domElement.clientHeight); let scale = (15 / pr); sphere.scale.set(scale, scale, scale); } - + // labels let labels = measure.edgeLabels.concat(measure.angleLabels); - for(let label of labels){ + for (let label of labels) { let distance = camera.position.distanceTo(label.getWorldPosition()); let pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, domElement.clientHeight); let scale = (70 / pr); label.scale.set(scale, scale, scale); } - + // coordinate labels - for(let j = 0; j < measure.coordinateLabels.length; j++){ - let label = measure.coordinateLabels[j] + for (let j = 0; j < measure.coordinateLabels.length; j++) { + let label = measure.coordinateLabels[j]; let sphere = measure.spheres[j]; - let point = measure.points[j]; - + // measure.points[j] + let distance = camera.position.distanceTo(sphere.getWorldPosition()); - - let screenPos = sphere.getWorldPosition().clone().project( camera ); - screenPos.x = Math.round( ( screenPos.x + 1 ) * domElement.clientWidth / 2 ), - screenPos.y = Math.round( ( - screenPos.y + 1 ) * domElement.clientHeight / 2 ); + + let screenPos = sphere.getWorldPosition().clone().project(camera); + screenPos.x = Math.round((screenPos.x + 1) * domElement.clientWidth / 2); + screenPos.y = Math.round((-screenPos.y + 1) * domElement.clientHeight / 2); screenPos.z = 0; screenPos.y -= 30; - - let labelPos = new THREE.Vector3( - (screenPos.x / domElement.clientWidth) * 2 - 1, - -(screenPos.y / domElement.clientHeight) * 2 + 1, - 0.5 ); + + let labelPos = new THREE.Vector3( + (screenPos.x / domElement.clientWidth) * 2 - 1, + -(screenPos.y / domElement.clientHeight) * 2 + 1, + 0.5); labelPos.unproject(camera); - + let direction = labelPos.sub(camera.position).normalize(); labelPos = new THREE.Vector3().addVectors( camera.position, direction.multiplyScalar(distance)); - + label.position.copy(labelPos); - + let pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, domElement.clientHeight); let scale = (70 / pr); label.scale.set(scale, scale, scale); } - + // height label - if(measure.showHeight){ + if (measure.showHeight) { let label = measure.heightLabel; - + { let distance = label.position.distanceTo(camera.position); let pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, domElement.clientHeight); let scale = (70 / pr); label.scale.set(scale, scale, scale); } - + { // height edge let edge = measure.heightEdge; let lowpoint = edge.geometry.vertices[0].clone().add(edge.position); let start = edge.geometry.vertices[2].clone().add(edge.position); let end = edge.geometry.vertices[3].clone().add(edge.position); - + let lowScreen = lowpoint.clone().project(camera); let startScreen = start.clone().project(camera); let endScreen = end.clone().project(camera); - + let toPixelCoordinates = v => { let r = v.clone().addScalar(1).divideScalar(2); r.x = r.x * domElement.clientWidth; r.y = r.y * domElement.clientHeight; r.z = 0; - + return r; }; - + let lowEL = toPixelCoordinates(lowScreen); let startEL = toPixelCoordinates(startScreen); let endEL = toPixelCoordinates(endScreen); - - let distances = [0, - lowEL.distanceTo(startEL), - startEL.distanceTo(endEL), 0]; - + let lToS = lowEL.distanceTo(startEL); let sToE = startEL.distanceTo(endEL); - + edge.geometry.lineDistances = [0, lToS, lToS, lToS + sToE]; edge.geometry.lineDistancesNeedUpdate = true; - + edge.material.dashSize = 10; edge.material.gapSize = 10; } } - - - + { // area label let label = measure.areaLabel; - + let distance = label.position.distanceTo(camera.position); let pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, domElement.clientHeight); let scale = (70 / pr); label.scale.set(scale, scale, scale); } - } - - } - }; - - - - - diff --git a/src/utils/Profile.js b/src/utils/Profile.js index bce014ab..91d824ae 100644 --- a/src/utils/Profile.js +++ b/src/utils/Profile.js @@ -1,12 +1,11 @@ -Potree.Profile = class extends THREE.Object3D{ - - constructor(){ +Potree.Profile = class extends THREE.Object3D { + constructor () { super(); - + this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1; - - this.name = "Profile_" + this.constructor.counter; + + this.name = 'Profile_' + this.constructor.counter; this.points = []; this.spheres = []; this.edges = []; @@ -14,44 +13,44 @@ Potree.Profile = class extends THREE.Object3D{ this.width = 1; this.height = 20; this._modifiable = true; - + this.sphereGeometry = new THREE.SphereGeometry(0.4, 10, 10); - this.color = new THREE.Color( 0xff0000 ); - this.lineColor = new THREE.Color( 0xff0000 ); + this.color = new THREE.Color(0xff0000); + this.lineColor = new THREE.Color(0xff0000); } - - createSphereMaterial(){ + + createSphereMaterial () { let sphereMaterial = new THREE.MeshLambertMaterial({ - shading: THREE.SmoothShading, - color: 0xff0000, - depthTest: false, + shading: THREE.SmoothShading, + color: 0xff0000, + depthTest: false, depthWrite: false} ); - + return sphereMaterial; }; - - getSegments(){ + + getSegments () { let segments = []; - - for(let i = 0; i < this.points.length - 1; i++){ + + for (let i = 0; i < this.points.length - 1; i++) { let start = this.points[i].clone(); - let end = this.points[i+1].clone(); + let end = this.points[i + 1].clone(); segments.push({start: start, end: end}); } - + return segments; } - - getSegmentMatrices(){ + + getSegmentMatrices () { let segments = this.getSegments(); let matrices = []; - - for(let segment of segments){ + + for (let segment of segments) { let {start, end} = segment; - + let box = new THREE.Object3D(); - + let length = start.clone().setZ(0).distanceTo(end.clone().setZ(0)); box.scale.set(length, 10000, this.width); box.up.set(0, 0, 1); @@ -60,222 +59,219 @@ Potree.Profile = class extends THREE.Object3D{ let diff = new THREE.Vector3().subVectors(end, start); let target = new THREE.Vector3(diff.y, -diff.x, 0); - box.position.set(0,0,0); + box.position.set(0, 0, 0); box.lookAt(target); box.position.copy(center); - + box.updateMatrixWorld(); matrices.push(box.matrixWorld); } - + return matrices; } - - addMarker(point){ + + addMarker (point) { this.points.push(point); - + let sphere = new THREE.Mesh(this.sphereGeometry, this.createSphereMaterial()); - + this.add(sphere); this.spheres.push(sphere); - + // edges & boxes - if(this.points.length > 1){ - + if (this.points.length > 1) { var lineGeometry = new THREE.Geometry(); lineGeometry.vertices.push(new THREE.Vector3(), new THREE.Vector3()); lineGeometry.colors.push(this.lineColor, this.lineColor, this.lineColor); - var lineMaterial = new THREE.LineBasicMaterial( { - vertexColors: THREE.VertexColors, - linewidth: 2, - transparent: true, - opacity: 0.4 + var lineMaterial = new THREE.LineBasicMaterial({ + vertexColors: THREE.VertexColors, + linewidth: 2, + transparent: true, + opacity: 0.4 }); lineMaterial.depthTest = false; var edge = new THREE.Line(lineGeometry, lineMaterial); edge.visible = false; - + this.add(edge); this.edges.push(edge); - - + var boxGeometry = new THREE.BoxGeometry(1, 1, 1); var boxMaterial = new THREE.MeshBasicMaterial({color: 0xff0000, transparent: true, opacity: 0.2}); var box = new THREE.Mesh(boxGeometry, boxMaterial); box.visible = false; - + this.add(box); this.boxes.push(box); } - + { // event listeners let drag = (e) => { let I = Potree.utils.getMousePointCloudIntersection( - e.drag.end, - e.viewer.scene.camera, - e.viewer.renderer, + e.drag.end, + e.viewer.scene.camera, + e.viewer.renderer, e.viewer.scene.pointclouds); - - if(I){ + + if (I) { let i = this.spheres.indexOf(e.drag.object); - if(i !== -1){ + if (i !== -1) { this.setPosition(i, I.location); this.dispatchEvent({ - "type": "marker_moved", - "profile": this, - "index": i + 'type': 'marker_moved', + 'profile': this, + 'index': i }); } } }; - + let drop = e => { let i = this.spheres.indexOf(e.drag.object); - if(i !== -1){ + if (i !== -1) { this.dispatchEvent({ - "type": "marker_dropped", - "profile": this, - "index": i + 'type': 'marker_dropped', + 'profile': this, + 'index': i }); } }; - + let mouseover = (e) => e.object.material.emissive.setHex(0x888888); let mouseleave = (e) => e.object.material.emissive.setHex(0x000000); - - sphere.addEventListener("drag", drag); - sphere.addEventListener("drop", drop); - sphere.addEventListener("mouseover", mouseover); - sphere.addEventListener("mouseleave", mouseleave); + + sphere.addEventListener('drag', drag); + sphere.addEventListener('drop', drop); + sphere.addEventListener('mouseover', mouseover); + sphere.addEventListener('mouseleave', mouseleave); } - + let event = { - type: "marker_added", + type: 'marker_added', profile: this, sphere: sphere }; this.dispatchEvent(event); - - this.setPosition(this.points.length-1, point); + + this.setPosition(this.points.length - 1, point); } - - removeMarker(index){ + + removeMarker (index) { this.points.splice(index, 1); - + this.remove(this.spheres[index]); - + var edgeIndex = (index === 0) ? 0 : (index - 1); this.remove(this.edges[edgeIndex]); this.edges.splice(edgeIndex, 1); this.remove(this.boxes[edgeIndex]); this.boxes.splice(edgeIndex, 1); - + this.spheres.splice(index, 1); - + this.update(); - + this.dispatchEvent({ - "type": "marker_removed", - "profile": this + 'type': 'marker_removed', + 'profile': this }); } - - setPosition(index, position){ - let point = this.points[index]; + + setPosition (index, position) { + let point = this.points[index]; point.copy(position); - + let event = { - type: 'marker_moved', + type: 'marker_moved', profile: this, - index: index, - position: point.clone() + index: index, + position: point.clone() }; this.dispatchEvent(event); - + this.update(); } - - setWidth(width){ + + setWidth (width) { this.width = width; - + let event = { - type: 'width_changed', + type: 'width_changed', profile: this, - width: width + width: width }; this.dispatchEvent(event); - + this.update(); } - - getWidth(){ + + getWidth () { return this.width; } - - update(){ - - if(this.points.length === 0){ + + update () { + if (this.points.length === 0) { return; - }else if(this.points.length === 1){ + } else if (this.points.length === 1) { let point = this.points[0]; this.spheres[0].position.copy(point); - + return; } - + let min = this.points[0].clone(); let max = this.points[0].clone(); let centroid = new THREE.Vector3(); let lastIndex = this.points.length - 1; - for(var i = 0; i <= lastIndex; i++){ + for (let i = 0; i <= lastIndex; i++) { let point = this.points[i]; let sphere = this.spheres[i]; let leftIndex = (i === 0) ? lastIndex : i - 1; - let rightIndex = (i === lastIndex) ? 0 : i + 1; + // let rightIndex = (i === lastIndex) ? 0 : i + 1; let leftVertex = this.points[leftIndex]; - let rightVertex = this.points[rightIndex]; + // let rightVertex = this.points[rightIndex]; let leftEdge = this.edges[leftIndex]; let rightEdge = this.edges[i]; let leftBox = this.boxes[leftIndex]; - let rightBox = this.boxes[i]; - - let leftEdgeLength = point.distanceTo(leftVertex); - let rightEdgeLength = point.distanceTo(rightVertex); - let leftEdgeCenter = new THREE.Vector3().addVectors(leftVertex, point).multiplyScalar(0.5); - let rightEdgeCenter = new THREE.Vector3().addVectors(point, rightVertex).multiplyScalar(0.5); - + // rightBox = this.boxes[i]; + + // let leftEdgeLength = point.distanceTo(leftVertex); + // let rightEdgeLength = point.distanceTo(rightVertex); + // let leftEdgeCenter = new THREE.Vector3().addVectors(leftVertex, point).multiplyScalar(0.5); + // let rightEdgeCenter = new THREE.Vector3().addVectors(point, rightVertex).multiplyScalar(0.5); + sphere.position.copy(point); - - if(this._modifiable){ + + if (this._modifiable) { sphere.visible = true; - }else{ + } else { sphere.visible = false; } - - if(leftEdge){ + + if (leftEdge) { leftEdge.geometry.vertices[1].copy(point); leftEdge.geometry.verticesNeedUpdate = true; leftEdge.geometry.computeBoundingSphere(); } - - if(rightEdge){ + + if (rightEdge) { rightEdge.geometry.vertices[0].copy(point); rightEdge.geometry.verticesNeedUpdate = true; rightEdge.geometry.computeBoundingSphere(); } - - if(leftBox){ + + if (leftBox) { var start = leftVertex; var end = point; var length = start.clone().setZ(0).distanceTo(end.clone().setZ(0)); leftBox.scale.set(length, 1000000, this.width); leftBox.up.set(0, 0, 1); - + var center = new THREE.Vector3().addVectors(start, end).multiplyScalar(0.5); var diff = new THREE.Vector3().subVectors(end, start); var target = new THREE.Vector3(diff.y, -diff.x, 0); - - leftBox.position.set(0,0,0); + + leftBox.position.set(0, 0, 0); leftBox.lookAt(target); leftBox.position.copy(center); } @@ -285,53 +281,38 @@ Potree.Profile = class extends THREE.Object3D{ max.max(point); } centroid.multiplyScalar(1 / this.points.length); - - for(var i = 0; i < this.boxes.length; i++){ + + for (let i = 0; i < this.boxes.length; i++) { var box = this.boxes[i]; - + box.position.z = min.z + (max.z - min.z) / 2; } } - - raycast(raycaster, intersects){ - - for(let i = 0; i < this.points.length; i++){ + + raycast (raycaster, intersects) { + for (let i = 0; i < this.points.length; i++) { let sphere = this.spheres[i]; - + sphere.raycast(raycaster, intersects); } - + // recalculate distances because they are not necessarely correct // for scaled objects. // see https://github.com/mrdoob/three.js/issues/5827 // TODO: remove this once the bug has been fixed - for(let i = 0; i < intersects.length; i++){ + for (let i = 0; i < intersects.length; i++) { let I = intersects[i]; I.distance = raycaster.ray.origin.distanceTo(I.point); } - intersects.sort( function ( a, b ) { return a.distance - b.distance;} ); + intersects.sort(function (a, b) { return a.distance - b.distance; }); }; - - get modifiable(){ + + get modifiable () { return this._modifiable; } - - set modifiable(value){ + + set modifiable (value) { this._modifiable = value; this.update(); } }; - - - - - - - - - - - - - - diff --git a/src/utils/ProfileTool.js b/src/utils/ProfileTool.js index 7af9a939..3297c531 100644 --- a/src/utils/ProfileTool.js +++ b/src/utils/ProfileTool.js @@ -1,110 +1,107 @@ -Potree.ProfileTool = class ProfileTool extends THREE.EventDispatcher{ - - constructor(viewer){ +Potree.ProfileTool = class ProfileTool extends THREE.EventDispatcher { + constructor (viewer) { super(); - + this.viewer = viewer; this.renderer = viewer.renderer; - - this.addEventListener("start_inserting_profile", e => { + + this.addEventListener('start_inserting_profile', e => { this.viewer.dispatchEvent({ - type: "cancel_insertions" + type: 'cancel_insertions' }); }); - + this.sceneProfile = new THREE.Scene(); - this.sceneProfile.name = "scene_profile"; - this.light = new THREE.PointLight( 0xffffff, 1.0 ); + this.sceneProfile.name = 'scene_profile'; + this.light = new THREE.PointLight(0xffffff, 1.0); this.sceneProfile.add(this.light); - + this.viewer.inputHandler.registerInteractiveScene(this.sceneProfile); this.onRemove = e => this.sceneProfile.remove(e.profile); this.onAdd = e => this.sceneProfile.add(e.profile); } - - setScene(scene){ - if(this.scene === scene){ + + setScene (scene) { + if (this.scene === scene) { return; } - - if(this.scene){ - this.scene.removeEventListeners("profile_added", this.onAdd); - this.scene.removeEventListeners("profile_removed", this.onRemove); + + if (this.scene) { + this.scene.removeEventListeners('profile_added', this.onAdd); + this.scene.removeEventListeners('profile_removed', this.onRemove); } - + this.scene = scene; - - this.scene.addEventListener("profile_added", this.onAdd); - this.scene.addEventListener("profile_removed", this.onRemove); + + this.scene.addEventListener('profile_added', this.onAdd); + this.scene.addEventListener('profile_removed', this.onRemove); } - - startInsertion(args = {}){ + + startInsertion (args = {}) { let domElement = this.viewer.renderer.domElement; - + let profile = new Potree.Profile(); - profile.name = args.name || "Profile"; - + profile.name = args.name || 'Profile'; + this.dispatchEvent({ - type: "start_inserting_profile", + type: 'start_inserting_profile', profile: profile }); - + this.sceneProfile.add(profile); - + let cancel = { callback: null }; - + let insertionCallback = (e) => { - if(e.button === THREE.MOUSE.LEFT){ - if(profile.points.length <= 1){ + if (e.button === THREE.MOUSE.LEFT) { + if (profile.points.length <= 1) { let camera = this.viewer.scene.camera; let distance = camera.position.distanceTo(profile.points[0]); let pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, domElement.clientHeight); let width = (10 / pr); - + profile.setWidth(width); } - + profile.addMarker(profile.points[profile.points.length - 1].clone()); - + this.viewer.inputHandler.startDragging( profile.spheres[profile.spheres.length - 1]); - }else if(e.button === THREE.MOUSE.RIGHT){ + } else if (e.button === THREE.MOUSE.RIGHT) { cancel.callback(); } }; - - - + cancel.callback = e => { profile.removeMarker(profile.points.length - 1); - domElement.removeEventListener("mouseup", insertionCallback, true); - this.viewer.removeEventListener("cancel_insertions", cancel.callback); + domElement.removeEventListener('mouseup', insertionCallback, true); + this.viewer.removeEventListener('cancel_insertions', cancel.callback); }; - - this.viewer.addEventListener("cancel_insertions", cancel.callback); - domElement.addEventListener("mouseup", insertionCallback , true); - + + this.viewer.addEventListener('cancel_insertions', cancel.callback); + domElement.addEventListener('mouseup', insertionCallback, true); + profile.addMarker(new THREE.Vector3(0, 0, 0)); this.viewer.inputHandler.startDragging( profile.spheres[profile.spheres.length - 1]); - + this.viewer.scene.addProfile(profile); } - - update(){ + + update () { let camera = this.viewer.scene.camera; let domElement = this.renderer.domElement; let profiles = this.viewer.scene.profiles; - + this.light.position.copy(camera.position); - + // make size independant of distance - for(let profile of profiles){ - for(let sphere of profile.spheres){ + for (let profile of profiles) { + for (let sphere of profile.spheres) { let distance = camera.position.distanceTo(sphere.getWorldPosition()); let pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, domElement.clientHeight); let scale = (15 / pr); @@ -112,9 +109,4 @@ Potree.ProfileTool = class ProfileTool extends THREE.EventDispatcher{ } } } - }; - - - - diff --git a/src/utils/TransformationTool.js b/src/utils/TransformationTool.js index 59df8312..e8ffc5a0 100644 --- a/src/utils/TransformationTool.js +++ b/src/utils/TransformationTool.js @@ -1,567 +1,545 @@ -Potree.TransformationTool = class TransformationTool{ - - constructor(viewer){ - +Potree.TransformationTool = class TransformationTool { + constructor (viewer) { this.viewer = viewer; - + this.sceneTransform = new THREE.Scene(); this.translationNode = new THREE.Object3D(); this.rotationNode = new THREE.Object3D(); this.scaleNode = new THREE.Object3D(); - + this.TRANSFORMATION_MODES = { DEFAULT: 0, TRANSLATE: 1, ROTATE: 2, SCALE: 3 }; - + this.keys = { - TRANSLATE: ['E'.charCodeAt(0)], - SCALE: ['R'.charCodeAt(0)], - ROTATE: ['T'.charCodeAt(0)] - } - + TRANSLATE: ['E'.charCodeAt(0)], + SCALE: ['R'.charCodeAt(0)], + ROTATE: ['T'.charCodeAt(0)] + }; + this.mode = this.TRANSFORMATION_MODES.DEFAULT; - - this.menu = new HoverMenu(Potree.resourcePath + "/icons/menu_icon.svg"); - + + this.menu = new HoverMenu(Potree.resourcePath + '/icons/menu_icon.svg'); + this.selection = []; - + this.viewer.inputHandler.registerInteractiveScene(this.sceneTransform); - this.viewer.inputHandler.addEventListener("selection_changed", (e) => { + this.viewer.inputHandler.addEventListener('selection_changed', (e) => { this.selection = e.selection; }); - this.viewer.inputHandler.addEventListener("keydown", (e) => { - if(this.selection.length > 0){ - if(this.keys.TRANSLATE.some(key => key === e.keyCode)){ + this.viewer.inputHandler.addEventListener('keydown', (e) => { + if (this.selection.length > 0) { + if (this.keys.TRANSLATE.some(key => key === e.keyCode)) { this.setMode(this.TRANSFORMATION_MODES.TRANSLATE); - }else if(this.keys.SCALE.some(key => key === e.keyCode)){ + } else if (this.keys.SCALE.some(key => key === e.keyCode)) { this.setMode(this.TRANSFORMATION_MODES.SCALE); - }else if(this.keys.ROTATE.some(key => key === e.keyCode)){ + } else if (this.keys.ROTATE.some(key => key === e.keyCode)) { this.setMode(this.TRANSFORMATION_MODES.ROTATE); } } - }); - + { // Menu - this.menu.addItem(new HoverMenuItem(Potree.resourcePath + "/icons/translate.svg", e => { - //console.log("translate!"); + this.menu.addItem(new HoverMenuItem(Potree.resourcePath + '/icons/translate.svg', e => { + // console.log("translate!"); this.setMode(this.TRANSFORMATION_MODES.TRANSLATE); })); - this.menu.addItem(new HoverMenuItem(Potree.resourcePath + "/icons/rotate.svg", e => { - //console.log("rotate!"); + this.menu.addItem(new HoverMenuItem(Potree.resourcePath + '/icons/rotate.svg', e => { + // console.log("rotate!"); this.setMode(this.TRANSFORMATION_MODES.ROTATE); })); - this.menu.addItem(new HoverMenuItem(Potree.resourcePath + "/icons/scale.svg", e => { - //console.log("scale!"); + this.menu.addItem(new HoverMenuItem(Potree.resourcePath + '/icons/scale.svg', e => { + // console.log("scale!"); this.setMode(this.TRANSFORMATION_MODES.SCALE); })); this.menu.setPosition(100, 100); $(this.viewer.renderArea).append(this.menu.element); this.menu.element.hide(); } - + { // translation node - let createArrow = (name, direction, color) => { let material = new THREE.MeshBasicMaterial({ - color: color, - depthTest: false, + color: color, + depthTest: false, depthWrite: false}); - + let shaftGeometry = new THREE.Geometry(); shaftGeometry.vertices.push(new THREE.Vector3(0, 0, 0)); shaftGeometry.vertices.push(new THREE.Vector3(0, 1, 0)); - + let shaftMaterial = new THREE.LineBasicMaterial({ - color: color, - depthTest: true, + color: color, + depthTest: true, depthWrite: true, transparent: true - }); + }); let shaft = new THREE.Line(shaftGeometry, shaftMaterial); - shaft.name = name + "_shaft"; - + shaft.name = name + '_shaft'; + let headGeometry = new THREE.CylinderGeometry(0, 0.04, 0.1, 10, 1, false); - let headMaterial = material; + let headMaterial = material; let head = new THREE.Mesh(headGeometry, headMaterial); - head.name = name + "_head"; + head.name = name + '_head'; head.position.y = 1; - + let arrow = new THREE.Object3D(); arrow.name = name; arrow.add(shaft); arrow.add(head); - + let mouseover = e => { let c = new THREE.Color(0xFFFF00); shaftMaterial.color = c; headMaterial.color = c; }; - + let mouseleave = e => { let c = new THREE.Color(color); shaftMaterial.color = c; headMaterial.color = c; }; - + let drag = e => { - let camera = this.viewer.scene.camera; - - if(!e.drag.intersectionStart){ + + if (!e.drag.intersectionStart) { e.drag.intersectionStart = e.drag.location; e.drag.objectStart = e.drag.object.getWorldPosition(); - + let start = this.sceneTransform.position.clone(); let end = direction.clone().applyMatrix4(this.sceneTransform.matrixWorld); - //let end = start.clone().add(direction); + // let end = start.clone().add(direction); let line = new THREE.Line3(start, end); e.drag.line = line; - + let camOnLine = line.closestPointToPoint(camera.position, false); let normal = new THREE.Vector3().subVectors( camera.position, camOnLine); let plane = new THREE.Plane() .setFromNormalAndCoplanarPoint(normal, e.drag.intersectionStart); - + e.drag.dragPlane = plane; e.drag.pivot = e.drag.intersectionStart; } - + { let mouse = e.drag.end; let domElement = viewer.renderer.domElement; - let nmouse = { - x: (mouse.x / domElement.clientWidth ) * 2 - 1, - y: - (mouse.y / domElement.clientHeight ) * 2 + 1 + let nmouse = { + x: (mouse.x / domElement.clientWidth) * 2 - 1, + y: -(mouse.y / domElement.clientHeight) * 2 + 1 }; - - let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + + let vector = new THREE.Vector3(nmouse.x, nmouse.y, 0.5); vector.unproject(camera); - - let ray = new THREE.Ray(camera.position, vector.sub( camera.position)); + + let ray = new THREE.Ray(camera.position, vector.sub(camera.position)); let I = ray.intersectPlane(e.drag.dragPlane); - - if(I){ - + + if (I) { let iOnLine = e.drag.line.closestPointToPoint(I, false); - + let diff = new THREE.Vector3().subVectors( iOnLine, e.drag.pivot); - - for(let selection of this.selection){ + + for (let selection of this.selection) { selection.position.add(diff); } - + e.drag.pivot = e.drag.pivot.add(diff); } } }; - - shaft.addEventListener("mouseover", mouseover); - shaft.addEventListener("mouseleave", mouseleave); - shaft.addEventListener("drag", drag); + + shaft.addEventListener('mouseover', mouseover); + shaft.addEventListener('mouseleave', mouseleave); + shaft.addEventListener('drag', drag); return arrow; }; - - let arrowX = createArrow("arrow_x", new THREE.Vector3(1, 0, 0), 0xFF0000); - let arrowY = createArrow("arrow_y", new THREE.Vector3(0, 1, 0), 0x00FF00); - let arrowZ = createArrow("arrow_z", new THREE.Vector3(0, 0, 1), 0x0000FF); - - arrowX.rotation.z = -Math.PI/2; - arrowZ.rotation.x = Math.PI/2; - + + let arrowX = createArrow('arrow_x', new THREE.Vector3(1, 0, 0), 0xFF0000); + let arrowY = createArrow('arrow_y', new THREE.Vector3(0, 1, 0), 0x00FF00); + let arrowZ = createArrow('arrow_z', new THREE.Vector3(0, 0, 1), 0x0000FF); + + arrowX.rotation.z = -Math.PI / 2; + arrowZ.rotation.x = Math.PI / 2; + this.translationNode.add(arrowX); this.translationNode.add(arrowY); this.translationNode.add(arrowZ); } - + { // Rotation Node let createCircle = (name, normal, color) => { let material = new THREE.LineBasicMaterial({ - color: color, - depthTest: true, + color: color, + depthTest: true, depthWrite: true, transparent: true - }); - + }); + let segments = 32; let radius = 1; let geometry = new THREE.BufferGeometry(); - let positions = new Float32Array( (segments + 1) * 3 ); - for(let i = 0; i <= segments; i++){ + let positions = new Float32Array((segments + 1) * 3); + for (let i = 0; i <= segments; i++) { let u = (i / segments) * Math.PI * 2; let x = Math.cos(u) * radius; let y = Math.sin(u) * radius; - + positions[3 * i + 0] = x; positions[3 * i + 1] = y; positions[3 * i + 2] = 0; } - geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); + geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3)); geometry.computeBoundingSphere(); - + let circle = new THREE.Line(geometry, material); - circle.name = name + "_circle"; + circle.name = name + '_circle'; circle.lookAt(normal); - + let mouseover = e => { let c = new THREE.Color(0xFFFF00); material.color = c; }; - + let mouseleave = e => { let c = new THREE.Color(color); material.color = c; }; - + let drag = e => { - let camera = this.viewer.scene.camera; let n = normal.clone().applyEuler(this.sceneTransform.rotation); - - if(!e.drag.intersectionStart){ + + if (!e.drag.intersectionStart) { e.drag.objectStart = e.drag.object.getWorldPosition(); - + let plane = new THREE.Plane() .setFromNormalAndCoplanarPoint(n, this.sceneTransform.getWorldPosition()); - + { // e.drag.location seems imprecisse, calculate real start location let mouse = e.drag.end; let domElement = viewer.renderer.domElement; - let nmouse = { - x: (mouse.x / domElement.clientWidth ) * 2 - 1, - y: - (mouse.y / domElement.clientHeight ) * 2 + 1 + let nmouse = { + x: (mouse.x / domElement.clientWidth) * 2 - 1, + y: -(mouse.y / domElement.clientHeight) * 2 + 1 }; - - let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + + let vector = new THREE.Vector3(nmouse.x, nmouse.y, 0.5); vector.unproject(camera); - - let ray = new THREE.Ray(camera.position, vector.sub( camera.position)); + + let ray = new THREE.Ray(camera.position, vector.sub(camera.position)); let I = ray.intersectPlane(plane); - + e.drag.intersectionStart = I; } - + e.drag.dragPlane = plane; e.drag.pivot = e.drag.intersectionStart; } - + let mouse = e.drag.end; let domElement = viewer.renderer.domElement; - let nmouse = { - x: (mouse.x / domElement.clientWidth ) * 2 - 1, - y: - (mouse.y / domElement.clientHeight ) * 2 + 1 + let nmouse = { + x: (mouse.x / domElement.clientWidth) * 2 - 1, + y: -(mouse.y / domElement.clientHeight) * 2 + 1 }; - - let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + + let vector = new THREE.Vector3(nmouse.x, nmouse.y, 0.5); vector.unproject(camera); - - let ray = new THREE.Ray(camera.position, vector.sub( camera.position)); + + let ray = new THREE.Ray(camera.position, vector.sub(camera.position)); let I = ray.intersectPlane(e.drag.dragPlane); - - if(I){ + + if (I) { let center = this.sceneTransform.position; let from = e.drag.pivot; let to = I; - + let v1 = from.clone().sub(center).normalize(); let v2 = to.clone().sub(center).normalize(); - + let angle = Math.acos(v1.dot(v2)); let sign = Math.sign(v1.cross(v2).dot(n)); angle = angle * sign; - if(Number.isNaN(angle)){ + if (Number.isNaN(angle)) { return; } - - for(let selection of this.selection){ + + for (let selection of this.selection) { selection.rotateOnAxis(normal, angle); } - + e.drag.pivot = I; } - }; - - circle.addEventListener("mouseover", mouseover); - circle.addEventListener("mouseleave", mouseleave); - circle.addEventListener("drag", drag); - - + + circle.addEventListener('mouseover', mouseover); + circle.addEventListener('mouseleave', mouseleave); + circle.addEventListener('drag', drag); + return circle; }; - + { // transparent ball let sg = new THREE.SphereGeometry(1, 32, 32); let sm = new THREE.MeshBasicMaterial({ - //let sm = new THREE.MeshNormalMaterial({ + // let sm = new THREE.MeshNormalMaterial({ color: 0xaaaaaa, transparent: true, depthTest: true, depthWrite: true, opacity: 0.4 }); - + let sphere = new THREE.Mesh(sg, sm); - sphere.name = name + "_sphere"; + sphere.name = name + '_sphere'; sphere.scale.set(0.9, 0.9, 0.9); this.rotationNode.add(sphere); } - - let yaw = createCircle("yaw", new THREE.Vector3(0, 0, 1), 0xff0000); - let pitch = createCircle("pitch", new THREE.Vector3(1, 0, 0), 0x00ff00); - let roll = createCircle("roll", new THREE.Vector3(0, 1, 0), 0x0000ff); - + + let yaw = createCircle('yaw', new THREE.Vector3(0, 0, 1), 0xff0000); + let pitch = createCircle('pitch', new THREE.Vector3(1, 0, 0), 0x00ff00); + let roll = createCircle('roll', new THREE.Vector3(0, 1, 0), 0x0000ff); + this.rotationNode.add(yaw); this.rotationNode.add(pitch); this.rotationNode.add(roll); } - + { // scale node - let createHandle = (name, direction, color) => { let material = new THREE.MeshBasicMaterial({ - color: color, - depthTest: false, + color: color, + depthTest: false, depthWrite: false}); - + let shaftGeometry = new THREE.Geometry(); shaftGeometry.vertices.push(new THREE.Vector3(0, 0, 0)); shaftGeometry.vertices.push(new THREE.Vector3(0, 1, 0)); - + let shaftMaterial = new THREE.LineBasicMaterial({ - color: color, - depthTest: true, + color: color, + depthTest: true, depthWrite: true, transparent: true - }); + }); let shaft = new THREE.Line(shaftGeometry, shaftMaterial); - shaft.name = name + "_shaft"; - + shaft.name = name + '_shaft'; + let headGeometry = new THREE.BoxGeometry(1, 1, 1); - let headMaterial = material; + let headMaterial = material; let head = new THREE.Mesh(headGeometry, headMaterial); - head.name = name + "_head"; + head.name = name + '_head'; head.position.y = 1; head.scale.set(0.07, 0.07, 0.07); - + let arrow = new THREE.Object3D(); arrow.add(shaft); arrow.add(head); - + let mouseover = e => { let c = new THREE.Color(0xFFFF00); shaftMaterial.color = c; headMaterial.color = c; }; - + let mouseleave = e => { let c = new THREE.Color(color); shaftMaterial.color = c; headMaterial.color = c; }; - + let drag = e => { - let camera = this.viewer.scene.camera; - - if(!e.drag.intersectionStart){ + + if (!e.drag.intersectionStart) { e.drag.intersectionStart = e.drag.location; e.drag.scaleStart = this.selection[0].scale.clone(); - + let start = this.sceneTransform.position.clone(); let end = direction.clone().applyMatrix4(this.sceneTransform.matrixWorld); - //let end = start.clone().add(direction); + // let end = start.clone().add(direction); let line = new THREE.Line3(start, end); e.drag.line = line; - + let camOnLine = line.closestPointToPoint(camera.position, false); let normal = new THREE.Vector3().subVectors( camera.position, camOnLine); let plane = new THREE.Plane() .setFromNormalAndCoplanarPoint(normal, e.drag.intersectionStart); - + e.drag.dragPlane = plane; e.drag.pivot = e.drag.intersectionStart; } - + { let mouse = e.drag.end; let domElement = viewer.renderer.domElement; - let nmouse = { - x: (mouse.x / domElement.clientWidth ) * 2 - 1, - y: - (mouse.y / domElement.clientHeight ) * 2 + 1 + let nmouse = { + x: (mouse.x / domElement.clientWidth) * 2 - 1, + y: -(mouse.y / domElement.clientHeight) * 2 + 1 }; - - let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); + + let vector = new THREE.Vector3(nmouse.x, nmouse.y, 0.5); vector.unproject(camera); - - let ray = new THREE.Ray(camera.position, vector.sub( camera.position)); + + let ray = new THREE.Ray(camera.position, vector.sub(camera.position)); let I = ray.intersectPlane(e.drag.dragPlane); - - if(I){ - - let iOnLine = e.drag.line.closestPointToPoint(I, false); - - //let diff = new THREE.Vector3().subVectors( + + if (I) { + // let iOnLine = e.drag.line.closestPointToPoint(I, false); + // let diff = new THREE.Vector3().subVectors( // iOnLine, e.drag.pivot); - + let oldDistance = this.sceneTransform.position.distanceTo(e.drag.pivot); let newDistance = this.sceneTransform.position.distanceTo(I); - + let s = newDistance / oldDistance; let scale = new THREE.Vector3( direction.x === 0 ? 1 : s * direction.x, direction.y === 0 ? 1 : s * direction.y, direction.z === 0 ? 1 : s * direction.z ); - - - for(let selection of this.selection){ - //selection.position.add(diff); - + + for (let selection of this.selection) { + // selection.position.add(diff); + selection.scale.copy(e.drag.scaleStart.clone().multiply(scale)); - - //selection.scale.copy( + + // selection.scale.copy( // e.drag.scaleStart.clone() // .multiplyScalar(scale) // .multiply(direction)); - //console.log(Potree.utils.toString(selection.scale)); + // console.log(Potree.utils.toString(selection.scale)); } - - //e.drag.pivot = e.drag.pivot.add(diff); + + // e.drag.pivot = e.drag.pivot.add(diff); } } }; - - shaft.addEventListener("mouseover", mouseover); - shaft.addEventListener("mouseleave", mouseleave); - shaft.addEventListener("drag", drag); + + shaft.addEventListener('mouseover', mouseover); + shaft.addEventListener('mouseleave', mouseleave); + shaft.addEventListener('drag', drag); return arrow; }; - - let arrowX = createHandle("arrow_x", new THREE.Vector3(1, 0, 0), 0xFF0000); - let arrowY = createHandle("arrow_y", new THREE.Vector3(0, 1, 0), 0x00FF00); - let arrowZ = createHandle("arrow_z", new THREE.Vector3(0, 0, 1), 0x0000FF); - - arrowX.rotation.z = -Math.PI/2; - arrowZ.rotation.x = Math.PI/2; - + + let arrowX = createHandle('arrow_x', new THREE.Vector3(1, 0, 0), 0xFF0000); + let arrowY = createHandle('arrow_y', new THREE.Vector3(0, 1, 0), 0x00FF00); + let arrowZ = createHandle('arrow_z', new THREE.Vector3(0, 0, 1), 0x0000FF); + + arrowX.rotation.z = -Math.PI / 2; + arrowZ.rotation.x = Math.PI / 2; + this.scaleNode.add(arrowX); this.scaleNode.add(arrowY); this.scaleNode.add(arrowZ); } - - + this.setMode(this.TRANSFORMATION_MODES.TRANSLATE); } - - getSelectionBoundingBox(){ - + + getSelectionBoundingBox () { let min = new THREE.Vector3(+Infinity, +Infinity, +Infinity); let max = new THREE.Vector3(-Infinity, -Infinity, -Infinity); - - for(let node of this.selection){ - + + for (let node of this.selection) { let box = null; - if(node.boundingBox){ + if (node.boundingBox) { box = node.boundingBox; - }else if(node.geometry && node.geometry.boundingBox){ + } else if (node.geometry && node.geometry.boundingBox) { box = node.geometry.boundingBox; } - - if(box){ - //let tbox = Potree.utils.computeTransformedBoundingBox(box, node.matrixWorld); + + if (box) { + // let tbox = Potree.utils.computeTransformedBoundingBox(box, node.matrixWorld); let tbox = box.clone().applyMatrix4(node.matrixWorld); - + min = min.min(tbox.min); max = max.max(tbox.max); - }else{ + } else { let wp = node.getWorldPosition(); min = min.min(wp); max = max.max(wp); } } - + return new THREE.Box3(min, max); - } - - setMode(mode){ - if(this.mode === mode){ + + setMode (mode) { + if (this.mode === mode) { return; } - + this.sceneTransform.remove(this.translationNode); this.sceneTransform.remove(this.rotationNode); this.sceneTransform.remove(this.scaleNode); - - if(mode === this.TRANSFORMATION_MODES.TRANSLATE){ + + if (mode === this.TRANSFORMATION_MODES.TRANSLATE) { this.sceneTransform.add(this.translationNode); - }else if(mode === this.TRANSFORMATION_MODES.ROTATE){ + } else if (mode === this.TRANSFORMATION_MODES.ROTATE) { this.sceneTransform.add(this.rotationNode); - }else if(mode === this.TRANSFORMATION_MODES.SCALE){ + } else if (mode === this.TRANSFORMATION_MODES.SCALE) { this.sceneTransform.add(this.scaleNode); } - + this.mode = mode; } - - - //setSelection(selection){ + + // setSelection(selection){ // this.selection = selection; - //} - - update(){ - - if(this.selection.length === 0){ + // } + + update () { + if (this.selection.length === 0) { this.sceneTransform.visible = false; this.menu.element.hide(); return; - }else{ + } else { this.sceneTransform.visible = true; this.menu.element.show(); } - - if(this.selection.length === 1){ + + if (this.selection.length === 1) { this.sceneTransform.rotation.copy(this.selection[0].rotation); } - + let scene = this.viewer.scene; let renderer = this.viewer.renderer; let domElement = renderer.domElement; - + let box = this.getSelectionBoundingBox(); let pivot = box.getCenter(); this.sceneTransform.position.copy(pivot); - + { // size let distance = scene.camera.position.distanceTo(pivot); let pr = Potree.utils.projectedRadius(1, scene.camera.fov * Math.PI / 180, distance, renderer.domElement.clientHeight); let scale = (120 / pr); this.sceneTransform.scale.set(scale, scale, scale); } - + { // menu let screenPos = pivot.clone().project(scene.camera); screenPos.x = domElement.clientWidth * (screenPos.x + 1) / 2; - screenPos.y = domElement.clientHeight * (1-(screenPos.y + 1) / 2); - + screenPos.y = domElement.clientHeight * (1 - (screenPos.y + 1) / 2); + this.menu.setPosition(screenPos.x, screenPos.y); } - } - - //render(camera, target){ + + // render(camera, target){ // this.update(); // this.renderer.render(this.sceneTransform, camera, target); - //} - -}; \ No newline at end of file + // } +}; diff --git a/src/utils/TranslationTool.js b/src/utils/TranslationTool.js index d80ef8b3..096aabef 100644 --- a/src/utils/TranslationTool.js +++ b/src/utils/TranslationTool.js @@ -1,242 +1,216 @@ -Potree.TranslationTool = function(camera) { - THREE.Object3D.call( this ); +Potree.TranslationTool = function (camera) { + THREE.Object3D.call(this); var scope = this; this.camera = camera; this.geometry = new THREE.Geometry(); - this.material = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ); - + this.material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff }); + this.STATE = { DEFAULT: 0, TRANSLATE_X: 1, TRANSLATE_Y: 2, TRANSLATE_Z: 3 }; - + this.parts = { - ARROW_X : {name: "arrow_x", object: undefined, color: new THREE.Color( 0xff0000 ), state: this.STATE.TRANSLATE_X}, - ARROW_Y : {name: "arrow_y", object: undefined, color: new THREE.Color( 0x00ff00 ), state: this.STATE.TRANSLATE_Y}, - ARROW_Z : {name: "arrow_z", object: undefined, color: new THREE.Color( 0x0000ff ), state: this.STATE.TRANSLATE_Z} + ARROW_X: {name: 'arrow_x', object: undefined, color: new THREE.Color(0xff0000), state: this.STATE.TRANSLATE_X}, + ARROW_Y: {name: 'arrow_y', object: undefined, color: new THREE.Color(0x00ff00), state: this.STATE.TRANSLATE_Y}, + ARROW_Z: {name: 'arrow_z', object: undefined, color: new THREE.Color(0x0000ff), state: this.STATE.TRANSLATE_Z} }; - + this.state = this.STATE.DEFAULT; this.highlighted = null; this.targets = null; - - this.build = function(){ + + this.build = function () { var arrowX = scope.createArrow(scope.parts.ARROW_X, scope.parts.ARROW_X.color); - arrowX.rotation.z = -Math.PI/2; - + arrowX.rotation.z = -Math.PI / 2; + var arrowY = scope.createArrow(scope.parts.ARROW_Y, scope.parts.ARROW_Y.color); - + var arrowZ = scope.createArrow(scope.parts.ARROW_Z, scope.parts.ARROW_Z.color); - arrowZ.rotation.x = -Math.PI/2; - + arrowZ.rotation.x = -Math.PI / 2; + scope.add(arrowX); scope.add(arrowY); scope.add(arrowZ); - - - var boxXY = scope.createBox(new THREE.Color( 0xffff00 )); + + var boxXY = scope.createBox(new THREE.Color(0xffff00)); boxXY.scale.z = 0.02; boxXY.position.set(0.5, 0.5, 0); - - var boxXZ = scope.createBox(new THREE.Color( 0xff00ff )); + + var boxXZ = scope.createBox(new THREE.Color(0xff00ff)); boxXZ.scale.y = 0.02; boxXZ.position.set(0.5, 0, -0.5); - - var boxYZ = scope.createBox(new THREE.Color( 0x00ffff )); + + var boxYZ = scope.createBox(new THREE.Color(0x00ffff)); boxYZ.scale.x = 0.02; boxYZ.position.set(0, 0.5, -0.5); - + scope.add(boxXY); scope.add(boxXZ); scope.add(boxYZ); - - + scope.parts.ARROW_X.object = arrowX; scope.parts.ARROW_Y.object = arrowY; scope.parts.ARROW_Z.object = arrowZ; - - + scope.scale.multiplyScalar(5); }; - - this.createBox = function(color){ + + this.createBox = function (color) { var boxGeometry = new THREE.BoxGeometry(1, 1, 1); var boxMaterial = new THREE.MeshBasicMaterial({color: color, transparent: true, opacity: 0.5}); var box = new THREE.Mesh(boxGeometry, boxMaterial); - + return box; }; - - this.createArrow = function(partID, color){ + + this.createArrow = function (partID, color) { var material = new THREE.MeshBasicMaterial({color: color}); - + var shaftGeometry = new THREE.CylinderGeometry(0.1, 0.1, 3, 10, 1, false); - var shaftMatterial = material; + var shaftMatterial = material; var shaft = new THREE.Mesh(shaftGeometry, shaftMatterial); shaft.position.y = 1.5; - + var headGeometry = new THREE.CylinderGeometry(0, 0.3, 1, 10, 1, false); - var headMaterial = material; + var headMaterial = material; var head = new THREE.Mesh(headGeometry, headMaterial); head.position.y = 3; - + var arrow = new THREE.Object3D(); arrow.add(shaft); arrow.add(head); arrow.partID = partID; arrow.material = material; - + return arrow; }; - - this.setHighlighted = function(partID){ - if(partID === undefined){ - if(scope.highlighted){ + + this.setHighlighted = function (partID) { + if (partID === undefined) { + if (scope.highlighted) { scope.highlighted.object.material.color = scope.highlighted.color; scope.highlighted = undefined; } - - return; - }else if(scope.highlighted !== undefined && scope.highlighted !== partID){ + + return; + } else if (scope.highlighted !== undefined && scope.highlighted !== partID) { scope.highlighted.object.material.color = scope.highlighted.color; } scope.highlighted = partID; partID.object.material.color = new THREE.Color(0xffff00); }; - - this.getHoveredObject = function(mouse){ - var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 ); + + this.getHoveredObject = function (mouse) { + var vector = new THREE.Vector3(mouse.x, mouse.y, 0.5); vector.unproject(scope.camera); - + var raycaster = new THREE.Raycaster(); - raycaster.ray.set( scope.camera.position, vector.sub( scope.camera.position ).normalize() ); - + raycaster.ray.set(scope.camera.position, vector.sub(scope.camera.position).normalize()); + var intersections = raycaster.intersectObject(scope, true); - if(intersections.length === 0){ + if (intersections.length === 0) { scope.setHighlighted(undefined); return undefined; } - + var I = intersections[0]; var partID = I.object.parent.partID; - - return partID; - }; - - this.onMouseMove = function(event){ + return partID; + }; + + this.onMouseMove = function (event) { var mouse = event.normalizedPosition; - - if(scope.state === scope.STATE.DEFAULT){ + + if (scope.state === scope.STATE.DEFAULT) { scope.setHighlighted(scope.getHoveredObject(mouse)); - }else if(scope.state === scope.STATE.TRANSLATE_X || scope.state === scope.STATE.TRANSLATE_Y || scope.state === scope.STATE.TRANSLATE_Z){ + } else if (scope.state === scope.STATE.TRANSLATE_X || scope.state === scope.STATE.TRANSLATE_Y || scope.state === scope.STATE.TRANSLATE_Z) { var origin = scope.start.lineStart.clone(); var direction = scope.start.lineEnd.clone().sub(scope.start.lineStart); direction.normalize(); - + var mousePoint = new THREE.Vector3(mouse.x, mouse.y); - + var directionDistance = new THREE.Vector3().subVectors(mousePoint, origin).dot(direction); var pointOnLine = direction.clone().multiplyScalar(directionDistance).add(origin); - + pointOnLine.unproject(scope.camera); - + var diff = pointOnLine.clone().sub(scope.position); scope.position.copy(pointOnLine); - - for(var i = 0; i < scope.targets.length; i++){ + + for (var i = 0; i < scope.targets.length; i++) { var target = scope.targets[0]; target.position.add(diff); } - + event.signal.halt(); } - }; - - this.onMouseDown = function(event){ - - if(scope.state === scope.STATE.DEFAULT){ + + this.onMouseDown = function (event) { + if (scope.state === scope.STATE.DEFAULT) { var hoveredObject = scope.getHoveredObject(event.normalizedPosition, scope.camera); - if(hoveredObject){ + if (hoveredObject) { scope.state = hoveredObject.state; - + var lineStart = scope.position.clone(); var lineEnd; - - if(scope.state === scope.STATE.TRANSLATE_X){ + + if (scope.state === scope.STATE.TRANSLATE_X) { lineEnd = scope.position.clone(); lineEnd.x += 2; - }else if(scope.state === scope.STATE.TRANSLATE_Y){ + } else if (scope.state === scope.STATE.TRANSLATE_Y) { lineEnd = scope.position.clone(); lineEnd.y += 2; - }else if(scope.state === scope.STATE.TRANSLATE_Z){ + } else if (scope.state === scope.STATE.TRANSLATE_Z) { lineEnd = scope.position.clone(); lineEnd.z -= 2; } - + lineStart.project(scope.camera); lineEnd.project(scope.camera); - + scope.start = { mouse: event.normalizedPosition, lineStart: lineStart, lineEnd: lineEnd }; - + event.signal.halt(); } - - } + } }; - - this.onMouseUp = function(event){ + + this.onMouseUp = function (event) { scope.setHighlighted(); scope.state = scope.STATE.DEFAULT; - }; - - this.setTargets = function(targets){ + + this.setTargets = function (targets) { scope.targets = targets; - - if(scope.targets.length === 0){ + + if (scope.targets.length === 0) { return; } - - //TODO calculate centroid of all targets + + // TODO calculate centroid of all targets var centroid = targets[0].position.clone(); - //for(var i = 0; i < targets.length; i++){ + // for(var i = 0; i < targets.length; i++){ // var target = targets[i]; - //} - + // } + scope.position.copy(centroid); - }; this.build(); }; -Potree.TranslationTool.prototype = Object.create( THREE.Object3D.prototype ); - - - - - - - - - - - - - - - - - +Potree.TranslationTool.prototype = Object.create(THREE.Object3D.prototype); diff --git a/src/utils/Volume.js b/src/utils/Volume.js index 674c0c98..25a8802a 100644 --- a/src/utils/Volume.js +++ b/src/utils/Volume.js @@ -1,49 +1,48 @@ -Potree.Volume = class extends THREE.Object3D{ - - constructor(args = {}){ +Potree.Volume = class extends THREE.Object3D { + constructor (args = {}) { super(); - + this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1; - - this.name = "volume_" + this.constructor.counter; - + + this.name = 'volume_' + this.constructor.counter; + this._clip = args.clip || false; this._modifiable = args.modifiable || true; - + let boxGeometry = new THREE.BoxGeometry(1, 1, 1); boxGeometry.computeBoundingBox(); - + let boxFrameGeometry = new THREE.Geometry(); { - let l = 0.1; - + // let l = 0.1; + // corner vertices - let v = [ - [-0.5, -0.5, -0.5], - [-0.5, -0.5, +0.5], - [-0.5, +0.5, -0.5], - [-0.5, +0.5, +0.5], - [+0.5, -0.5, -0.5], - [+0.5, -0.5, +0.5], - [+0.5, +0.5, -0.5], - [+0.5, +0.5, +0.5] - ]; + // let v = [ + // [-0.5, -0.5, -0.5], + // [-0.5, -0.5, +0.5], + // [-0.5, +0.5, -0.5], + // [-0.5, +0.5, +0.5], + // [+0.5, -0.5, -0.5], + // [+0.5, -0.5, +0.5], + // [+0.5, +0.5, -0.5], + // [+0.5, +0.5, +0.5] + // ]; + // + /// / create a cross at each corner with cross length l + // for(let b of v){ // - //// create a cross at each corner with cross length l - //for(let b of v){ - // // let b1 = [ b[0] - l * Math.sign(b[0]), b[1], b[2] ]; // let b2 = [ b[0], b[1] - l * Math.sign(b[1]), b[2] ]; // let b3 = [ b[0], b[1], b[2] - l * Math.sign(b[2]) ]; - // + // // // create the 3 lines that a cross consists of // for(let d of [b, b1, b, b2, b, b3]){ // boxFrameGeometry.vertices.push(new THREE.Vector3().fromArray(d)); // } - // - //} - + // + // } + // bottom boxFrameGeometry.vertices.push(new THREE.Vector3(-0.5, -0.5, 0.5)); boxFrameGeometry.vertices.push(new THREE.Vector3(0.5, -0.5, 0.5)); @@ -73,75 +72,74 @@ Potree.Volume = class extends THREE.Object3D{ boxFrameGeometry.vertices.push(new THREE.Vector3(-0.5, 0.5, -0.5)); } - this.dimension = new THREE.Vector3(1,1,1); - this.material = new THREE.MeshBasicMaterial( { - color: 0x00ff00, - transparent: true, + this.dimension = new THREE.Vector3(1, 1, 1); + this.material = new THREE.MeshBasicMaterial({ + color: 0x00ff00, + transparent: true, opacity: 0.3, - depthTest: true, - depthWrite: false} ); + depthTest: true, + depthWrite: false}); this.box = new THREE.Mesh(boxGeometry, this.material); this.box.geometry.computeBoundingBox(); this.boundingBox = this.box.geometry.boundingBox; this.add(this.box); - - this.frame = new THREE.LineSegments( boxFrameGeometry, new THREE.LineBasicMaterial({color: 0x000000})); - //this.frame.mode = THREE.Lines; + + this.frame = new THREE.LineSegments(boxFrameGeometry, new THREE.LineBasicMaterial({color: 0x000000})); + // this.frame.mode = THREE.Lines; this.add(this.frame); - - this.label = new Potree.TextSprite("0"); - this.label.setBorderColor({r:0, g:255, b:0, a:0.0}); - this.label.setBackgroundColor({r:0, g:255, b:0, a:0.0}); + + this.label = new Potree.TextSprite('0'); + this.label.setBorderColor({r: 0, g: 255, b: 0, a: 0.0}); + this.label.setBackgroundColor({r: 0, g: 255, b: 0, a: 0.0}); this.label.material.depthTest = false; this.label.material.depthWrite = false; this.label.material.transparent = true; this.label.position.y -= 0.5; this.add(this.label); - + this.label.updateMatrixWorld = () => { var volumeWorldPos = new THREE.Vector3(); - volumeWorldPos.setFromMatrixPosition( this.matrixWorld ); + volumeWorldPos.setFromMatrixPosition(this.matrixWorld); this.label.position.copy(volumeWorldPos); this.label.updateMatrix(); this.label.matrixWorld.copy(this.label.matrix); this.label.matrixWorldNeedsUpdate = false; - - for ( var i = 0, l = this.label.children.length; i < l; i ++ ) { - this.label.children[ i ].updateMatrixWorld( true ); + + for (var i = 0, l = this.label.children.length; i < l; i++) { + this.label.children[ i ].updateMatrixWorld(true); } }; - + { // event listeners - this.addEventListener("select", e => {}); - this.addEventListener("deselect", e => {}); + this.addEventListener('select', e => {}); + this.addEventListener('deselect', e => {}); } - + this.update(); } - getVolume(){ + getVolume () { return Math.abs(this.scale.x * this.scale.y * this.scale.z); } - - update(){ + + update () { this.boundingBox = this.box.geometry.boundingBox; this.boundingSphere = this.boundingBox.getBoundingSphere(); - - if(this._clip){ + + if (this._clip) { this.box.visible = false; this.label.visible = false; - }else{ + } else { this.box.visible = true; this.label.visible = true; } }; - - raycast(raycaster, intersects){ - + + raycast (raycaster, intersects) { let is = []; this.box.raycast(raycaster, is); - - if(is.length > 0){ + + if (is.length > 0) { var I = is[0]; intersects.push({ distance: I.distance, @@ -150,24 +148,24 @@ Potree.Volume = class extends THREE.Object3D{ }); } }; - - get clip(){ + + get clip () { return this._clip; } - - set clip(value){ + + set clip (value) { this._clip = value; - + this.update(); } - - get modifieable(){ + + get modifieable () { return this._modifiable; } - - set modifieable(value){ + + set modifieable (value) { this._modifiable = value; - + this.update(); } -}; \ No newline at end of file +}; diff --git a/src/utils/VolumeTool.js b/src/utils/VolumeTool.js index affe534e..87ee24fb 100644 --- a/src/utils/VolumeTool.js +++ b/src/utils/VolumeTool.js @@ -1,137 +1,130 @@ +Potree.VolumeTool = class VolumeTool extends THREE.EventDispatcher { + constructor (viewer) { + super(); -Potree.VolumeTool = class VolumeTool extends THREE.EventDispatcher{ - - constructor(viewer){ - super() - this.viewer = viewer; this.renderer = viewer.renderer; - - this.addEventListener("start_inserting_volume", e => { + + this.addEventListener('start_inserting_volume', e => { this.viewer.dispatchEvent({ - type: "cancel_insertions" + type: 'cancel_insertions' }); }); this.sceneVolume = new THREE.Scene(); - this.sceneVolume.name = "scene_volume"; - + this.sceneVolume.name = 'scene_volume'; + this.viewer.inputHandler.registerInteractiveScene(this.sceneVolume); this.onRemove = e => { this.sceneVolume.remove(e.volume); }; - + this.onAdd = e => { this.sceneVolume.add(e.volume); }; - - this.viewer.inputHandler.addEventListener("delete", e => { + + this.viewer.inputHandler.addEventListener('delete', e => { let volumes = e.selection.filter(e => (e instanceof Potree.Volume)); volumes.forEach(e => this.viewer.scene.removeVolume(e)); }); } - - setScene(scene){ - if(this.scene === scene){ + + setScene (scene) { + if (this.scene === scene) { return; } - - if(this.scene){ - this.scene.removeEventListeners("volume_added", this.onAdd); - this.scene.removeEventListeners("volume_removed", this.onRemove); + + if (this.scene) { + this.scene.removeEventListeners('volume_added', this.onAdd); + this.scene.removeEventListeners('volume_removed', this.onRemove); } - + this.scene = scene; - - this.scene.addEventListener("volume_added", this.onAdd); - this.scene.addEventListener("volume_removed", this.onRemove); + + this.scene.addEventListener('volume_added', this.onAdd); + this.scene.addEventListener('volume_removed', this.onRemove); } - - startInsertion(args = {}){ - let domElement = this.viewer.renderer.domElement; - + + startInsertion (args = {}) { let volume = new Potree.Volume(); volume.clip = args.clip || false; - volume.name = args.name || "Volume"; - + volume.name = args.name || 'Volume'; + this.dispatchEvent({ - type: "start_inserting_volume", + type: 'start_inserting_volume', volume: volume }); - - //this.sceneVolume.add(volume); + + // this.sceneVolume.add(volume); this.viewer.scene.addVolume(volume); - + let cancel = { callback: null }; let drag = e => { let camera = this.viewer.scene.camera; - + let I = Potree.utils.getMousePointCloudIntersection( - e.drag.end, - this.viewer.scene.camera, - this.viewer.renderer, + e.drag.end, + this.viewer.scene.camera, + this.viewer.renderer, this.viewer.scene.pointclouds); - - if(I){ + + if (I) { volume.position.copy(I.location); - + var wp = volume.getWorldPosition().applyMatrix4(camera.matrixWorldInverse); - var pp = new THREE.Vector4(wp.x, wp.y, wp.z).applyMatrix4(camera.projectionMatrix); - var w = Math.abs((wp.z / 10)); - volume.scale.set(w,w,w); + // var pp = new THREE.Vector4(wp.x, wp.y, wp.z).applyMatrix4(camera.projectionMatrix); + var w = Math.abs((wp.z / 10)); + volume.scale.set(w, w, w); } }; - + let drop = e => { - volume.removeEventListener("drag", drag); - volume.removeEventListener("drop", drop); - + volume.removeEventListener('drag', drag); + volume.removeEventListener('drop', drop); + cancel.callback(); }; - + cancel.callback = e => { - volume.removeEventListener("drag", drag); - volume.removeEventListener("drop", drop); - this.viewer.removeEventListener("cancel_insertions", cancel.callback); + volume.removeEventListener('drag', drag); + volume.removeEventListener('drop', drop); + this.viewer.removeEventListener('cancel_insertions', cancel.callback); }; - - volume.addEventListener("drag", drag); - volume.addEventListener("drop", drop); - this.viewer.addEventListener("cancel_insertions", cancel.callback); - + + volume.addEventListener('drag', drag); + volume.addEventListener('drop', drop); + this.viewer.addEventListener('cancel_insertions', cancel.callback); + this.viewer.inputHandler.startDragging(volume); } - - update(delta){ - - if(!this.scene){ + + update (delta) { + if (!this.scene) { return; } - + let camera = this.viewer.scene.camera; let domElement = this.viewer.renderer.domElement; - //let labels = this.viewer.scene.volumes.map(e => e.label); - + // let labels = this.viewer.scene.volumes.map(e => e.label); + let volumes = this.viewer.scene.volumes; - for(let volume of volumes){ + for (let volume of volumes) { let label = volume.label; - + { let distance = label.position.distanceTo(camera.position); let pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, domElement.clientHeight); let scale = (70 / pr); label.scale.set(scale, scale, scale); } - - let text = Potree.utils.addCommas(volume.getVolume().toFixed(3)) + "\u00B3"; + + let text = Potree.utils.addCommas(volume.getVolume().toFixed(3)) + '\u00B3'; label.setText(text); } - } - -}; \ No newline at end of file +}; diff --git a/src/viewer/ProgressBar.js b/src/viewer/ProgressBar.js index fb648533..ae85705c 100644 --- a/src/viewer/ProgressBar.js +++ b/src/viewer/ProgressBar.js @@ -1,81 +1,78 @@ - -function ProgressBar(){ +function ProgressBar () { this._progress = 0; - this._message = ""; - + this._message = ''; + this.maxOpacity = 0.6; - - this.element = document.createElement("div"); - this.elProgress = document.createElement("div"); - this.elProgressMessage = document.createElement("div"); - - //this.element.innerHTML = "element"; - //this.elProgress.innerHTML = "progress"; - - this.element.innerHTML = ""; - this.element.style.position = "fixed"; - this.element.style.bottom = "40px"; - this.element.style.width = "200px"; - this.element.style.marginLeft = "-100px"; - this.element.style.left = "50%"; - this.element.style.borderRadius = "5px"; - this.element.style.border = "1px solid #727678"; - this.element.style.height = "16px"; - this.element.style.padding = "1px"; - this.element.style.textAlign = "center"; - this.element.style.backgroundColor = "#6ba8e5"; + + this.element = document.createElement('div'); + this.elProgress = document.createElement('div'); + this.elProgressMessage = document.createElement('div'); + + // this.element.innerHTML = "element"; + // this.elProgress.innerHTML = "progress"; + + this.element.innerHTML = ''; + this.element.style.position = 'fixed'; + this.element.style.bottom = '40px'; + this.element.style.width = '200px'; + this.element.style.marginLeft = '-100px'; + this.element.style.left = '50%'; + this.element.style.borderRadius = '5px'; + this.element.style.border = '1px solid #727678'; + this.element.style.height = '16px'; + this.element.style.padding = '1px'; + this.element.style.textAlign = 'center'; + this.element.style.backgroundColor = '#6ba8e5'; this.element.style.opacity = this.maxOpacity; - this.element.style.pointerEvents = "none"; - - this.elProgress.innerHTML = " "; - this.elProgress.style.backgroundColor = "#b8e1fc"; - this.elProgress.style.position = "absolute"; - this.elProgress.style.borderRadius = "5px"; - this.elProgress.style.width = "0%"; - this.elProgress.style.height = "100%"; - this.elProgress.style.margin = "0px"; - this.elProgress.style.padding = "0px"; - - this.elProgressMessage.style.position = "absolute"; - this.elProgressMessage.style.width = "100%"; - this.elProgressMessage.innerHTML = "loading 1 / 10"; - - - + this.element.style.pointerEvents = 'none'; + + this.elProgress.innerHTML = ' '; + this.elProgress.style.backgroundColor = '#b8e1fc'; + this.elProgress.style.position = 'absolute'; + this.elProgress.style.borderRadius = '5px'; + this.elProgress.style.width = '0%'; + this.elProgress.style.height = '100%'; + this.elProgress.style.margin = '0px'; + this.elProgress.style.padding = '0px'; + + this.elProgressMessage.style.position = 'absolute'; + this.elProgressMessage.style.width = '100%'; + this.elProgressMessage.innerHTML = 'loading 1 / 10'; + document.body.appendChild(this.element); this.element.appendChild(this.elProgress); this.element.appendChild(this.elProgressMessage); - + this.hide(); }; -ProgressBar.prototype.hide = function(){ +ProgressBar.prototype.hide = function () { this.element.style.opacity = 0; - this.element.style.transition = "all 0.2s ease"; + this.element.style.transition = 'all 0.2s ease'; }; -ProgressBar.prototype.show = function(){ +ProgressBar.prototype.show = function () { this.element.style.opacity = this.maxOpacity; - this.element.style.transition = "all 0.2s ease"; + this.element.style.transition = 'all 0.2s ease'; }; -Object.defineProperty(ProgressBar.prototype, "progress", { - get: function(){ +Object.defineProperty(ProgressBar.prototype, 'progress', { + get: function () { return this._progress; }, - set: function(value){ + set: function (value) { this._progress = value; - this.elProgress.style.width = (value * 100) + "%"; + this.elProgress.style.width = (value * 100) + '%'; } }); -Object.defineProperty(ProgressBar.prototype, "message", { - get: function(){ +Object.defineProperty(ProgressBar.prototype, 'message', { + get: function () { return this._message; }, - set: function(message){ + set: function (message) { this._message = message; this.elProgressMessage.innerHTML = message; } -}); \ No newline at end of file +}); diff --git a/src/viewer/map.js b/src/viewer/map.js index de4f1b7b..78ce7f5a 100644 --- a/src/viewer/map.js +++ b/src/viewer/map.js @@ -1,24 +1,23 @@ // http://epsg.io/ -proj4.defs("UTM10N", "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"); +proj4.defs('UTM10N', '+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs'); -Potree.MapView = class{ - - constructor(viewer){ +Potree.MapView = class { + constructor (viewer) { this.viewer = viewer; - - this.webMapService = "WMTS"; - this.mapProjectionName = "EPSG:3857"; + + this.webMapService = 'WMTS'; + this.mapProjectionName = 'EPSG:3857'; this.mapProjection = proj4.defs(this.mapProjectionName); this.sceneProjection = null; - + this.extentsLayer = null; this.cameraLayer = null; this.toolLayer = null; this.sourcesLayer = null; this.sourcesLabelLayer = null; this.enabled = false; - + this.createAnnotationStyle = (text) => { return [ new ol.style.Style({ @@ -45,10 +44,10 @@ Potree.MapView = class{ width: 2 }) }) - })*/ + }) */ ]; - } - + }; + this.createLabelStyle = (text) => { let style = new ol.style.Style({ image: new ol.style.Circle({ @@ -73,129 +72,123 @@ Potree.MapView = class{ }) }) }); - + return style; - } - - + }; } - - showSources(show){ + + showSources (show) { this.sourcesLayer.setVisible(show); this.sourcesLabelLayer.setVisible(show); } - - init(){ - this.elMap = $("#potree_map"); + + init () { + this.elMap = $('#potree_map'); this.elMap.draggable({ handle: $('#potree_map_header') }); this.elMap.resizable(); - + this.elTooltip = $(`
`); this.elMap.append(this.elTooltip); - + let extentsLayer = this.getExtentsLayer(); let cameraLayer = this.getCameraLayer(); - let toolLayer = this.getToolLayer(); + this.getToolLayer(); let sourcesLayer = this.getSourcesLayer(); - let sourcesLabelLayer = this.getSourcesLabelLayer(); - let annotationsLayer = this.getAnnotationsLayer(); - + this.getSourcesLabelLayer(); + this.getAnnotationsLayer(); + let mousePositionControl = new ol.control.MousePosition({ coordinateFormat: ol.coordinate.createStringXY(5), - projection: "EPSG:4326", + projection: 'EPSG:4326', undefinedHTML: ' ' }); - + let _this = this; - let DownloadSelectionControl = function(opt_options){ - let options = opt_options || {}; - + let DownloadSelectionControl = function (optOptions) { + let options = optOptions || {}; + // TOGGLE TILES let btToggleTiles = document.createElement('button'); btToggleTiles.innerHTML = 'T'; btToggleTiles.addEventListener('click', () => { let visible = sourcesLayer.getVisible(); _this.showSources(!visible); - //sourcesLayer.setVisible(!visible); - //sourcesLabelLayer.setVisible(!visible); }, false); - btToggleTiles.style.float = "left"; - btToggleTiles.title = "show / hide tiles"; - + btToggleTiles.style.float = 'left'; + btToggleTiles.title = 'show / hide tiles'; + // DOWNLOAD SELECTED TILES - let link = document.createElement("a"); - link.href = "#"; - link.download = "list.txt"; - link.style.float = "left"; - + let link = document.createElement('a'); + link.href = '#'; + link.download = 'list.txt'; + link.style.float = 'left'; + let button = document.createElement('button'); button.innerHTML = 'D'; link.appendChild(button); - - let this_ = this; + let handleDownload = (e) => { let features = selectedFeatures.getArray(); - - let url = [location.protocol, '//', location.host, location.pathname].join(''); - - if(features.length === 0){ - alert("No tiles were selected. Select area with ctrl + left mouse button!"); + + let url = [document.location.protocol, '//', document.location.host, document.location.pathname].join(''); + + if (features.length === 0) { + alert('No tiles were selected. Select area with ctrl + left mouse button!'); e.preventDefault(); e.stopImmediatePropagation(); return false; - }else if(features.length === 1){ + } else if (features.length === 1) { let feature = features[0]; - - if(feature.source){ + + if (feature.source) { let cloudjsurl = feature.pointcloud.pcoGeometry.url; let sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name); link.href = sourceurl.href; link.download = feature.source.name; } - }else{ - let content = ""; - for(var i = 0; i < features.length; i++){ + } else { + let content = ''; + for (var i = 0; i < features.length; i++) { let feature = features[i]; - - if(feature.source){ + + if (feature.source) { let cloudjsurl = feature.pointcloud.pcoGeometry.url; let sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name); - content += sourceurl.href + "\n"; + content += sourceurl.href + '\n'; } } - - let uri = "data:application/octet-stream;base64,"+btoa(content); + + let uri = 'data:application/octet-stream;base64,' + btoa(content); link.href = uri; - link.download = "list_of_files.txt"; + link.download = 'list_of_files.txt'; } }; - + button.addEventListener('click', handleDownload, false); - + // assemble container let element = document.createElement('div'); element.className = 'ol-unselectable ol-control'; element.appendChild(link); element.appendChild(btToggleTiles); - element.style.bottom = "0.5em"; - element.style.left = "0.5em"; - element.title = "Download file or list of selected tiles. Select tile with left mouse button or area using ctrl + left mouse."; - + element.style.bottom = '0.5em'; + element.style.left = '0.5em'; + element.title = 'Download file or list of selected tiles. Select tile with left mouse button or area using ctrl + left mouse.'; + ol.control.Control.call(this, { element: element, target: options.target }); - }; ol.inherits(DownloadSelectionControl, ol.control.Control); - + this.map = new ol.Map({ controls: ol.control.defaults({ attributionOptions: ({ - collapsible: false + collapsible: false }) }).extend([ - //this.controls.zoomToExtent, + // this.controls.zoomToExtent, new DownloadSelectionControl(), mousePositionControl ]), @@ -220,51 +213,51 @@ Potree.MapView = class{ source: new ol.source.Vector({}), style: new ol.style.Style({ stroke: new ol.style.Stroke({ - color: 'rgba(0, 0, 255, 1)', - width: 2 + color: 'rgba(0, 0, 255, 1)', + width: 2 }) }) }); this.map.addLayer(this.dragBoxLayer); - + let select = new ol.interaction.Select(); this.map.addInteraction(select); - + let selectedFeatures = select.getFeatures(); - + let dragBox = new ol.interaction.DragBox({ - condition: ol.events.condition.platformModifierKeyOnly + condition: ol.events.condition.platformModifierKeyOnly }); - + this.map.addInteraction(dragBox); - + this.map.on('pointermove', evt => { let pixel = evt.pixel; - let feature = this.map.forEachFeatureAtPixel(pixel, function(feature) { + let feature = this.map.forEachFeatureAtPixel(pixel, function (feature) { return feature; }); - - //console.log(feature); - //this.elTooltip.css("display", feature ? '' : 'none'); - this.elTooltip.css("display", "none"); - if(feature && feature.onHover){ + + // console.log(feature); + // this.elTooltip.css("display", feature ? '' : 'none'); + this.elTooltip.css('display', 'none'); + if (feature && feature.onHover) { feature.onHover(evt); - //overlay.setPosition(evt.coordinate); - //tooltip.innerHTML = feature.get('name'); + // overlay.setPosition(evt.coordinate); + // tooltip.innerHTML = feature.get('name'); } }); - + this.map.on('click', evt => { let pixel = evt.pixel; - let feature = this.map.forEachFeatureAtPixel(pixel, function(feature) { + let feature = this.map.forEachFeatureAtPixel(pixel, function (feature) { return feature; }); - - if(feature && feature.onHover){ + + if (feature && feature.onHover) { feature.onClick(evt); } }); - + dragBox.on('boxend', (e) => { // features that intersect the box are added to the collection of // selected features, and their names are displayed in the "info" @@ -274,7 +267,7 @@ Potree.MapView = class{ selectedFeatures.push(feature); }); }); - + // clear selection when drawing a new box and when clicking on the map dragBox.on('boxstart', (e) => { selectedFeatures.clear(); @@ -283,84 +276,84 @@ Potree.MapView = class{ selectedFeatures.clear(); }); - this.viewer.addEventListener("scene_changed", e => { + this.viewer.addEventListener('scene_changed', e => { this.setScene(e.scene); }); - + this.onPointcloudAdded = e => { this.load(e.pointcloud); }; - + this.onAnnotationAdded = e => { - if(!this.sceneProjection){ + if (!this.sceneProjection) { return; } - + let annotation = e.annotation; let position = annotation.position; let mapPos = this.toMap.forward([position.x, position.y]); let feature = new ol.Feature({ - geometry: new ol.geom.Point(mapPos), - name: annotation.title + geometry: new ol.geom.Point(mapPos), + name: annotation.title }); feature.setStyle(this.createAnnotationStyle(annotation.title)); - + feature.onHover = evt => { let coordinates = feature.getGeometry().getCoordinates(); let p = this.map.getPixelFromCoordinate(coordinates); - + this.elTooltip.html(annotation.title); - this.elTooltip.css("display", ""); - this.elTooltip.css("left", `${p[0]}px`); - this.elTooltip.css("top", `${p[1]}px`); + this.elTooltip.css('display', ''); + this.elTooltip.css('left', `${p[0]}px`); + this.elTooltip.css('top', `${p[1]}px`); }; - + feature.onClick = evt => { annotation.clickTitle(); }; - + this.getAnnotationsLayer().getSource().addFeature(feature); }; - + this.setScene(this.viewer.scene); } - - setScene(scene){ - if(this.scene === scene){ + + setScene (scene) { + if (this.scene === scene) { return; }; - - if(this.scene){ - this.scene.removeEventListener("pointcloud_added", this.onPointcloudAdded); - this.scene.annotations.removeEventListener("annotation_added", this.onAnnotationAdded); + + if (this.scene) { + this.scene.removeEventListener('pointcloud_added', this.onPointcloudAdded); + this.scene.annotations.removeEventListener('annotation_added', this.onAnnotationAdded); } - + this.scene = scene; - - this.scene.addEventListener("pointcloud_added", this.onPointcloudAdded); - this.scene.annotations.addEventListener("annotation_added", this.onAnnotationAdded); - - for(let pointcloud of this.viewer.scene.pointclouds){ + + this.scene.addEventListener('pointcloud_added', this.onPointcloudAdded); + this.scene.annotations.addEventListener('annotation_added', this.onAnnotationAdded); + + for (let pointcloud of this.viewer.scene.pointclouds) { this.load(pointcloud); } - + this.viewer.scene.annotations.traverseDescendants(annotation => { this.onAnnotationAdded({annotation: annotation}); }); } - - getExtentsLayer(){ - if(this.extentsLayer){ + + getExtentsLayer () { + if (this.extentsLayer) { return this.extentsLayer; } - - this.gExtent = new ol.geom.LineString([[0,0], [0,0]]); - + + this.gExtent = new ol.geom.LineString([[0, 0], [0, 0]]); + let feature = new ol.Feature(this.gExtent); let featureVector = new ol.source.Vector({ features: [feature] }); - + this.extentsLayer = new ol.layer.Vector({ source: featureVector, style: new ol.style.Style({ @@ -368,8 +361,8 @@ Potree.MapView = class{ color: 'rgba(255, 255, 255, 0.2)' }), stroke: new ol.style.Stroke({ - color: '#0000ff', - width: 2 + color: '#0000ff', + width: 2 }), image: new ol.style.Circle({ radius: 3, @@ -379,15 +372,15 @@ Potree.MapView = class{ }) }) }); - + return this.extentsLayer; } - - getAnnotationsLayer(){ - if(this.annotationsLayer){ + + getAnnotationsLayer () { + if (this.annotationsLayer) { return this.annotationsLayer; } - + this.annotationsLayer = new ol.layer.Vector({ source: new ol.source.Vector({ }), @@ -396,45 +389,45 @@ Potree.MapView = class{ color: 'rgba(255, 0, 0, 1)' }), stroke: new ol.style.Stroke({ - color: 'rgba(255, 0, 0, 1)', - width: 2 + color: 'rgba(255, 0, 0, 1)', + width: 2 }) }) }); - + return this.annotationsLayer; } - - getCameraLayer(){ - if(this.cameraLayer){ + + getCameraLayer () { + if (this.cameraLayer) { return this.cameraLayer; } - + // CAMERA LAYER - this.gCamera = new ol.geom.LineString([[0,0], [0,0], [0,0], [0,0]]); + this.gCamera = new ol.geom.LineString([[0, 0], [0, 0], [0, 0], [0, 0]]); let feature = new ol.Feature(this.gCamera); let featureVector = new ol.source.Vector({ features: [feature] }); - + this.cameraLayer = new ol.layer.Vector({ source: featureVector, style: new ol.style.Style({ stroke: new ol.style.Stroke({ - color: '#0000ff', - width: 2 + color: '#0000ff', + width: 2 }) }) }); - + return this.cameraLayer; } - - getToolLayer(){ - if(this.toolLayer){ + + getToolLayer () { + if (this.toolLayer) { return this.toolLayer; } - + this.toolLayer = new ol.layer.Vector({ source: new ol.source.Vector({ }), @@ -443,20 +436,20 @@ Potree.MapView = class{ color: 'rgba(255, 0, 0, 1)' }), stroke: new ol.style.Stroke({ - color: 'rgba(255, 0, 0, 1)', - width: 2 + color: 'rgba(255, 0, 0, 1)', + width: 2 }) }) }); - + return this.toolLayer; } - - getSourcesLayer(){ - if(this.sourcesLayer){ + + getSourcesLayer () { + if (this.sourcesLayer) { return this.sourcesLayer; } - + this.sourcesLayer = new ol.layer.Vector({ source: new ol.source.Vector({}), style: new ol.style.Style({ @@ -464,20 +457,20 @@ Potree.MapView = class{ color: 'rgba(0, 0, 150, 0.1)' }), stroke: new ol.style.Stroke({ - color: 'rgba(0, 0, 150, 1)', - width: 1 + color: 'rgba(0, 0, 150, 1)', + width: 1 }) }) }); - + return this.sourcesLayer; } - - getSourcesLabelLayer(){ - if(this.sourcesLabelLayer){ + + getSourcesLabelLayer () { + if (this.sourcesLabelLayer) { return this.sourcesLabelLayer; } - + this.sourcesLabelLayer = new ol.layer.Vector({ source: new ol.source.Vector({ }), @@ -486,205 +479,194 @@ Potree.MapView = class{ color: 'rgba(255, 0, 0, 0.1)' }), stroke: new ol.style.Stroke({ - color: 'rgba(255, 0, 0, 1)', - width: 2 + color: 'rgba(255, 0, 0, 1)', + width: 2 }) }), minResolution: 0.01, - maxResolution: 20 + maxResolution: 20 }); - + return this.sourcesLabelLayer; } - - setSceneProjection(sceneProjection){ + + setSceneProjection (sceneProjection) { this.sceneProjection = sceneProjection; this.toMap = proj4(this.sceneProjection, this.mapProjection); this.toScene = proj4(this.mapProjection, this.sceneProjection); }; - - getMapExtent(){ + + getMapExtent () { let bb = this.viewer.getBoundingBox(); - + let bottomLeft = this.toMap.forward([bb.min.x, bb.min.y]); let bottomRight = this.toMap.forward([bb.max.x, bb.min.y]); let topRight = this.toMap.forward([bb.max.x, bb.max.y]); let topLeft = this.toMap.forward([bb.min.x, bb.max.y]); - + let extent = { bottomLeft: bottomLeft, bottomRight: bottomRight, topRight: topRight, topLeft: topLeft }; - + return extent; }; - - getMapCenter(){ + + getMapCenter () { let mapExtent = this.getMapExtent(); - + let mapCenter = [ - (mapExtent.bottomLeft[0] + mapExtent.topRight[0]) / 2, + (mapExtent.bottomLeft[0] + mapExtent.topRight[0]) / 2, (mapExtent.bottomLeft[1] + mapExtent.topRight[1]) / 2 ]; - + return mapCenter; - }; - - updateToolDrawings(){ + }; + + updateToolDrawings () { this.toolLayer.getSource().clear(); - + let profiles = this.viewer.profileTool.profiles; - for(var i = 0; i < profiles.length; i++){ + for (let i = 0; i < profiles.length; i++) { let profile = profiles[i]; let coordinates = []; - - for(var j = 0; j < profile.points.length; j++){ + + for (let j = 0; j < profile.points.length; j++) { let point = profile.points[j]; let pointMap = this.toMap.forward([point.x, point.y]); coordinates.push(pointMap); } - + let line = new ol.geom.LineString(coordinates); let feature = new ol.Feature(line); this.toolLayer.getSource().addFeature(feature); } - + let measurements = this.viewer.measuringTool.measurements; - for(var i = 0; i < measurements.length; i++){ + for (let i = 0; i < measurements.length; i++) { let measurement = measurements[i]; let coordinates = []; - - for(var j = 0; j < measurement.points.length; j++){ + + for (let j = 0; j < measurement.points.length; j++) { let point = measurement.points[j].position; let pointMap = this.toMap.forward([point.x, point.y]); coordinates.push(pointMap); } - - if(measurement.closed && measurement.points.length > 0){ + + if (measurement.closed && measurement.points.length > 0) { coordinates.push(coordinates[0]); } - + let line = new ol.geom.LineString(coordinates); let feature = new ol.Feature(line); this.toolLayer.getSource().addFeature(feature); } } - - - load(pointcloud){ - - if(!pointcloud){ + + load (pointcloud) { + if (!pointcloud) { return; } - - if(!pointcloud.projection){ + + if (!pointcloud.projection) { return; } - - if(!this.sceneProjection){ + + if (!this.sceneProjection) { this.setSceneProjection(pointcloud.projection); } - + let mapExtent = this.getMapExtent(); let mapCenter = this.getMapCenter(); - - + let view = this.map.getView(); view.setCenter(mapCenter); - + this.gExtent.setCoordinates([ - mapExtent.bottomLeft, - mapExtent.bottomRight, - mapExtent.topRight, + mapExtent.bottomLeft, + mapExtent.bottomRight, + mapExtent.topRight, mapExtent.topLeft, mapExtent.bottomLeft ]); - + view.fit(this.gExtent, [300, 300], { constrainResolution: false }); - - - let url = pointcloud.pcoGeometry.url + "/../sources.json"; + let url = pointcloud.pcoGeometry.url + '/../sources.json'; $.getJSON(url, (data) => { let sources = data.sources; - - for(var i = 0; i < sources.length; i++){ + + for (var i = 0; i < sources.length; i++) { let source = sources[i]; let name = source.name; - let points = source.points; let bounds = source.bounds; let mapBounds = { - min: this.toMap.forward( [bounds.min[0], bounds.min[1]] ), - max: this.toMap.forward( [bounds.max[0], bounds.max[1]] ) - } + min: this.toMap.forward([bounds.min[0], bounds.min[1]]), + max: this.toMap.forward([bounds.max[0], bounds.max[1]]) + }; let mapCenter = [ (mapBounds.min[0] + mapBounds.max[0]) / 2, - (mapBounds.min[1] + mapBounds.max[1]) / 2, + (mapBounds.min[1] + mapBounds.max[1]) / 2 ]; - - let p1 = this.toMap.forward( [bounds.min[0], bounds.min[1]] ); - let p2 = this.toMap.forward( [bounds.max[0], bounds.min[1]] ); - let p3 = this.toMap.forward( [bounds.max[0], bounds.max[1]] ); - let p4 = this.toMap.forward( [bounds.min[0], bounds.max[1]] ); - - let boxes = []; - //var feature = new ol.Feature({ + + let p1 = this.toMap.forward([bounds.min[0], bounds.min[1]]); + let p2 = this.toMap.forward([bounds.max[0], bounds.min[1]]); + let p3 = this.toMap.forward([bounds.max[0], bounds.max[1]]); + let p4 = this.toMap.forward([bounds.min[0], bounds.max[1]]); + + // var feature = new ol.Feature({ // 'geometry': new ol.geom.LineString([p1, p2, p3, p4, p1]) - //}); + // }); let feature = new ol.Feature({ 'geometry': new ol.geom.Polygon([[p1, p2, p3, p4, p1]]) }); feature.source = source; feature.pointcloud = pointcloud; this.getSourcesLayer().getSource().addFeature(feature); - - + feature = new ol.Feature({ - geometry: new ol.geom.Point(mapCenter), - name: name + geometry: new ol.geom.Point(mapCenter), + name: name }); feature.setStyle(this.createLabelStyle(name)); this.sourcesLabelLayer.getSource().addFeature(feature); } }); - } - - toggle(){ - - if(this.elMap.is(":visible")){ - this.elMap.css("display", "none"); + + toggle () { + if (this.elMap.is(':visible')) { + this.elMap.css('display', 'none'); this.enabled = false; - }else{ - this.elMap.css("display", "block"); + } else { + this.elMap.css('display', 'block'); this.enabled = true; } - } - - update(delta){ - if(!this.sceneProjection){ + + update (delta) { + if (!this.sceneProjection) { return; } - - let pm = $( "#potree_map" ); - - if(!this.enabled){ + + let pm = $('#potree_map'); + + if (!this.enabled) { return; } - + // resize let mapSize = this.map.getSize(); - let resized = (pm.width() != mapSize[0] || pm.height() != mapSize[1]); - if(resized){ + let resized = (pm.width() !== mapSize[0] || pm.height() !== mapSize[1]); + if (resized) { this.map.updateSize(); } - + // camera let scale = this.map.getView().getResolution(); let camera = this.viewer.scene.camera; @@ -699,24 +681,19 @@ Potree.MapView = class{ mapLookAt = mapPos.clone().add(mapDir.clone().multiplyScalar(30 * scale)); let mapLength = mapPos.distanceTo(mapLookAt); let mapSide = new THREE.Vector2(-mapDir.y, mapDir.x); - + let p1 = mapPos.toArray(); let p2 = mapLookAt.clone().sub(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray(); let p3 = mapLookAt.clone().add(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray(); - this.gCamera.setCoordinates([p1, p2, p3, p1]); } - - get sourcesVisible(){ + + get sourcesVisible () { return this.getSourcesLayer().getVisible(); } - - set sourcesVisible(value){ + + set sourcesVisible (value) { this.getSourcesLayer().setVisible(value); } - }; - - - diff --git a/src/viewer/profile.js b/src/viewer/profile.js index 3eacc4c8..d884774d 100644 --- a/src/viewer/profile.js +++ b/src/viewer/profile.js @@ -1,27 +1,25 @@ -Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher{ - - constructor(){ +Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher { + constructor () { super(); - - this.elRoot = $("#profile_window"); - this.renderArea = this.elRoot.find("#profileCanvasContainer"); - this.svg = d3.select("svg#profileSVG"); + + this.elRoot = $('#profile_window'); + this.renderArea = this.elRoot.find('#profileCanvasContainer'); + this.svg = d3.select('svg#profileSVG'); this.mouseIsDown = false; - + this.projectedBox = new THREE.Box3(); this.pointclouds = new Map(); - this.numPoints = 0 - - this.geometryPool = new class{ - constructor(){ + this.numPoints = 0; + + this.geometryPool = new class { + constructor () { this.geometries = []; this.maxPoints = 50000; } - - getGeometry(){ - if(this.geometries.length === 0){ - + + getGeometry () { + if (this.geometries.length === 0) { let geometry = new THREE.BufferGeometry(); let buffers = { position: new Float32Array(3 * this.maxPoints), @@ -32,115 +30,114 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher{ numberOfReturns: new Uint8Array(this.maxPoints), pointSourceID: new Uint16Array(this.maxPoints) }; - - geometry.addAttribute("position", new THREE.BufferAttribute(buffers.position, 3)); - geometry.addAttribute("color", new THREE.BufferAttribute(buffers.color, 3, true)); - geometry.addAttribute("intensity", new THREE.BufferAttribute(buffers.intensity, 1, false)); - geometry.addAttribute("classification", new THREE.BufferAttribute(buffers.classification, 1, false)); - geometry.addAttribute("returnNumber", new THREE.BufferAttribute(buffers.returnNumber, 1, false)); - geometry.addAttribute("numberOfReturns", new THREE.BufferAttribute(buffers.numberOfReturns, 1, false)); - geometry.addAttribute("pointSourceID", new THREE.BufferAttribute(buffers.pointSourceID, 1, false)); - + + geometry.addAttribute('position', new THREE.BufferAttribute(buffers.position, 3)); + geometry.addAttribute('color', new THREE.BufferAttribute(buffers.color, 3, true)); + geometry.addAttribute('intensity', new THREE.BufferAttribute(buffers.intensity, 1, false)); + geometry.addAttribute('classification', new THREE.BufferAttribute(buffers.classification, 1, false)); + geometry.addAttribute('returnNumber', new THREE.BufferAttribute(buffers.returnNumber, 1, false)); + geometry.addAttribute('numberOfReturns', new THREE.BufferAttribute(buffers.numberOfReturns, 1, false)); + geometry.addAttribute('pointSourceID', new THREE.BufferAttribute(buffers.pointSourceID, 1, false)); + geometry.setDrawRange(0, 0); - + this.geometries.push(geometry); } - + return this.geometries.pop(); } - - returnGeometry(geometry){ + + returnGeometry (geometry) { this.geometries.push(geometry); } - }; - - this.materialPool = new class{ - constructor(){ + }(); + + this.materialPool = new class { + constructor () { this.materials = []; } - - getMaterial(){ - if(this.materials.length === 0){ + + getMaterial () { + if (this.materials.length === 0) { let material = new Potree.PointCloudMaterial(); this.materials.push(material); } - + return this.materials.pop(); } - - returnMaterial(material){ + + returnMaterial (material) { this.materials.push(material); } - }; - + }(); + this.mouse = new THREE.Vector2(0, 0); this.scale = new THREE.Vector3(1, 1, 1); - + let csvIcon = `${Potree.resourcePath}/icons/file_csv_2d.svg`; - $("#potree_download_csv_icon").attr("src", csvIcon); - + $('#potree_download_csv_icon').attr('src', csvIcon); + let lasIcon = `${Potree.resourcePath}/icons/file_las_3d.svg`; - $("#potree_download_las_icon").attr("src", lasIcon); - + $('#potree_download_las_icon').attr('src', lasIcon); + this.initTHREE(); this.initSVG(); this.initListeners(); } - - initListeners(){ - $(window).resize( () => { + + initListeners () { + $(window).resize(() => { this.render(); }); - + this.renderArea.mousedown(e => { this.mouseIsDown = true; }); - + this.renderArea.mouseup(e => { this.mouseIsDown = false; }); - - this.renderArea.mousemove( e => { - if(this.pointclouds.size === 0){ + + this.renderArea.mousemove(e => { + if (this.pointclouds.size === 0) { return; } - + let rect = this.renderArea[0].getBoundingClientRect(); let x = e.clientX - rect.left; let y = e.clientY - rect.top; - + let newMouse = new THREE.Vector2(x, y); - - if(this.mouseIsDown){ + + if (this.mouseIsDown) { // DRAG this.autoFit = false; - + let cPos = [this.scaleX.invert(this.mouse.x), this.scaleY.invert(this.mouse.y)]; let ncPos = [this.scaleX.invert(newMouse.x), this.scaleY.invert(newMouse.y)]; - + this.camera.position.x -= ncPos[0] - cPos[0]; this.camera.position.y -= ncPos[1] - cPos[1]; - + this.render(); - }else if(this.pointclouds.size > 0){ - // FIND HOVERED POINT - let pixelRadius = 10; + } else if (this.pointclouds.size > 0) { + // FIND HOVERED POINT let radius = Math.abs(this.scaleX.invert(0) - this.scaleX.invert(5)); let mileage = this.scaleX.invert(newMouse.x); let elevation = this.scaleY.invert(newMouse.y); let point = this.selectPoint(mileage, elevation, radius); - - if(point){ - this.elRoot.find("#profileSelectionProperties").fadeIn(200); + + if (point) { + this.elRoot.find('#profileSelectionProperties').fadeIn(200); this.pickSphere.visible = true; this.pickSphere.scale.set(0.5 * radius, 0.5 * radius, 0.5 * radius); this.pickSphere.position.set(point.mileage, point.position[2], 0); - - let info = this.elRoot.find("#profileSelectionProperties"); - let html = ""; - for(let attribute of Object.keys(point)){ + + let info = this.elRoot.find('#profileSelectionProperties'); + let html = '
'; + for (let attribute of Object.keys(point)) { let value = point[attribute]; - if(attribute === "position"){ + if (attribute === 'position') { let values = [...value].map(v => Potree.utils.addCommas(v.toFixed(3))); html += ` @@ -155,135 +152,130 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher{ `; - }else if(attribute === "color"){ + } else if (attribute === 'color') { html += ` - + `; - }else if(attribute === "normal"){ + } else if (attribute === 'normal') { continue; - }else if(attribute === "mileage"){ + } else if (attribute === 'mileage') { html += ` `; - }else{ + } else { html += ` `; } - } - html += "
z ${values[2]}
${attribute}${value.join(", ")}${value.join(', ')}
${attribute} ${value.toFixed(3)}
${attribute} ${value}
" + html += ''; info.html(html); - + this.selectedPoint = point; - }else{ - //this.pickSphere.visible = false; - //this.selectedPoint = null; + } else { + // this.pickSphere.visible = false; + // this.selectedPoint = null; } this.render(); - - } - + this.mouse.copy(newMouse); }); - - + let onWheel = e => { this.autoFit = false; let delta = 0; - if( e.wheelDelta !== undefined ) { // WebKit / Opera / Explorer 9 + if (e.wheelDelta !== undefined) { // WebKit / Opera / Explorer 9 delta = e.wheelDelta; - } else if ( e.detail !== undefined ) { // Firefox + } else if (e.detail !== undefined) { // Firefox delta = -e.detail; } - + let ndelta = Math.sign(delta); - - //let sPos = new THREE.Vector3(this.mouse.x, this.mouse.y, 0); - //let cPos = this.toCamSpace(sPos); - + + // let sPos = new THREE.Vector3(this.mouse.x, this.mouse.y, 0); + // let cPos = this.toCamSpace(sPos); + let cPos = [this.scaleX.invert(this.mouse.x), this.scaleY.invert(this.mouse.y)]; - - if(ndelta > 0){ + + if (ndelta > 0) { // + 10% this.scale.multiplyScalar(1.1); - }else{ + } else { // - 10% - this.scale.multiplyScalar(100/110); + this.scale.multiplyScalar(100 / 110); } - - //this.scale.max(new THREE.Vector3(0.5, 0.5, 0.5)); - //this.scale.min(new THREE.Vector3(100, 100, 100)); - + + // this.scale.max(new THREE.Vector3(0.5, 0.5, 0.5)); + // this.scale.min(new THREE.Vector3(100, 100, 100)); + this.updateScales(); let ncPos = [this.scaleX.invert(this.mouse.x), this.scaleY.invert(this.mouse.y)]; - + this.camera.position.x -= ncPos[0] - cPos[0]; this.camera.position.y -= ncPos[1] - cPos[1]; - + this.render(); }; - $(this.renderArea)[0].addEventListener("mousewheel", onWheel, false ); - $(this.renderArea)[0].addEventListener("DOMMouseScroll", onWheel, false ); // Firefox - + $(this.renderArea)[0].addEventListener('mousewheel', onWheel, false); + $(this.renderArea)[0].addEventListener('DOMMouseScroll', onWheel, false); // Firefox + $('#closeProfileContainer').click(() => { this.hide(); }); - + $('#potree_download_csv_icon').click(() => { let points = new Potree.Points(); this.pointclouds.forEach((value, key) => { points.add(value.points); }); - + let string = Potree.CSVExporter.toString(points); - - let uri = "data:application/octet-stream;base64,"+btoa(string); - $('#potree_download_profile_ortho_link').attr("href", uri); + + let uri = 'data:application/octet-stream;base64,' + btoa(string); + $('#potree_download_profile_ortho_link').attr('href', uri); }); - + $('#potree_download_las_icon').click(() => { let points = new Potree.Points(); this.pointclouds.forEach((value, key) => { points.add(value.points); }); - + let buffer = Potree.LASExporter.toLAS(points); let u8view = new Uint8Array(buffer); - let binString = ""; - for(let i = 0; i < u8view.length; i++){ + let binString = ''; + for (let i = 0; i < u8view.length; i++) { binString += String.fromCharCode(u8view[i]); } - - let uri = "data:application/octet-stream;base64,"+btoa(binString); - $('#potree_download_profile_link').attr("href", uri); - - //let uri = "data:application/octet-stream;base64,"+btoa(string); - //$('#potree_download_profile_ortho_link').attr("href", uri); - - //let las = viewer.profileWindow.getPointsInProfileAsLas(); - //let u8view = new Uint8Array(las); + + let uri = 'data:application/octet-stream;base64,' + btoa(binString); + $('#potree_download_profile_link').attr('href', uri); + + // let uri = "data:application/octet-stream;base64,"+btoa(string); + // $('#potree_download_profile_ortho_link').attr("href", uri); + + // let las = viewer.profileWindow.getPointsInProfileAsLas(); + // let u8view = new Uint8Array(las); // - //let binString = ""; - //for(let i = 0; i < u8view.length; i++){ + // let binString = ""; + // for(let i = 0; i < u8view.length; i++){ // binString += String.fromCharCode(u8view[i]); - //} + // } // - //let uri = "data:application/octet-stream;base64,"+btoa(binString); - //$('#potree_download_profile_link').attr("href", uri); + // let uri = "data:application/octet-stream;base64,"+btoa(binString); + // $('#potree_download_profile_link').attr("href", uri); }); } - - selectPoint(mileage, elevation, radius){ - + + selectPoint (mileage, elevation, radius) { let closest = { distance: Infinity, pointcloud: null, @@ -291,18 +283,17 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher{ index: null }; - for(let [pointcloud, entry] of this.pointclouds){ + for (let [pointcloud, entry] of this.pointclouds) { let points = entry.points; - - for(let i = 0; i < points.numPoints; i++){ - - //let pos = new THREE.Vector3(...points.data.position.subarray(3*i, 3*i+3)); + + for (let i = 0; i < points.numPoints; i++) { + // let pos = new THREE.Vector3(...points.data.position.subarray(3*i, 3*i+3)); let m = points.data.mileage[i] - mileage; - let e = points.data.position[3*i+2] - elevation; - - let r = Math.sqrt(m*m + e*e); - - if(r < radius && r < closest.distance){ + let e = points.data.position[3 * i + 2] - elevation; + + let r = Math.sqrt(m * m + e * e); + + if (r < radius && r < closest.distance) { closest = { distance: r, pointcloud: pointcloud, @@ -312,288 +303,277 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher{ } } } - - if(closest.distance < Infinity){ + + if (closest.distance < Infinity) { let points = closest.points; - + let point = {}; - + let attributes = Object.keys(points.data); - for(let attribute of attributes){ + for (let attribute of attributes) { let attributeData = points.data[attribute]; let itemSize = attributeData.length / points.numPoints; let value = attributeData.subarray(itemSize * closest.index, itemSize * closest.index + itemSize); - - if(value.length === 1){ + + if (value.length === 1) { point[attribute] = value[0]; - }else{ + } else { point[attribute] = value; } } - + return point; - }else{ + } else { return null; } } - - initTHREE(){ + + initTHREE () { this.renderer = new THREE.WebGLRenderer({alpha: true, premultipliedAlpha: false}); - this.renderer.setClearColor( 0x000000, 0 ); + this.renderer.setClearColor(0x000000, 0); this.renderer.setSize(10, 10); this.renderer.autoClear = true; this.renderArea.append($(this.renderer.domElement)); - this.renderer.domElement.tabIndex = "2222"; - this.renderer.context.getExtension("EXT_frag_depth"); - $(this.renderer.domElement).css("width", "100%"); - $(this.renderer.domElement).css("height", "100%"); - + this.renderer.domElement.tabIndex = '2222'; + this.renderer.context.getExtension('EXT_frag_depth'); + $(this.renderer.domElement).css('width', '100%'); + $(this.renderer.domElement).css('height', '100%'); + this.camera = new THREE.OrthographicCamera(-10, 10, 10, -10, -1000, 1000); - + this.scene = new THREE.Scene(); - + let sg = new THREE.SphereGeometry(1, 16, 16); let sm = new THREE.MeshNormalMaterial(); this.pickSphere = new THREE.Mesh(sg, sm); this.pickSphere.visible = false; this.scene.add(this.pickSphere); } - - initSVG(){ + + initSVG () { let width = this.renderArea[0].clientWidth; let height = this.renderArea[0].clientHeight; let marginLeft = this.renderArea[0].offsetLeft; - - this.svg.selectAll("*").remove(); - + + this.svg.selectAll('*').remove(); + this.scaleX = d3.scale.linear() .domain([this.camera.left + this.camera.position.x, this.camera.right + this.camera.position.x]) .range([0, width]); this.scaleY = d3.scale.linear() .domain([this.camera.bottom + this.camera.position.y, this.camera.top + this.camera.position.y]) .range([height, 0]); - + this.xAxis = d3.svg.axis() .scale(this.scaleX) - .orient("bottom") + .orient('bottom') .innerTickSize(-height) .outerTickSize(1) .tickPadding(10) .ticks(width / 50); - + this.yAxis = d3.svg.axis() .scale(this.scaleY) - .orient("left") + .orient('left') .innerTickSize(-width) .outerTickSize(1) .tickPadding(10) .ticks(height / 20); - - this.svg.append("g") - .attr("class", "x axis") - .attr("transform", `translate(${marginLeft}, ${height})`) + + this.svg.append('g') + .attr('class', 'x axis') + .attr('transform', `translate(${marginLeft}, ${height})`) .call(this.xAxis); - - this.svg.append("g") - .attr("class", "y axis") - .attr("transform", `translate(${marginLeft}, 0)`) + + this.svg.append('g') + .attr('class', 'y axis') + .attr('transform', `translate(${marginLeft}, 0)`) .call(this.yAxis); } - - setProfile(profile){ - + + setProfile (profile) { this.render(); } - - addPoints(pointcloud, points){ - - if(this.pointclouds.get(pointcloud) === undefined){ - + + addPoints (pointcloud, points) { + if (this.pointclouds.get(pointcloud) === undefined) { let material = this.materialPool.getMaterial(); let geometry = this.geometryPool.getGeometry(); let model = new THREE.Points(geometry, material); this.scene.add(model); - + let materialChanged = e => { this.render(); }; - - pointcloud.material.addEventListener("material_property_changed", materialChanged); - + + pointcloud.material.addEventListener('material_property_changed', materialChanged); + this.pointclouds.set(pointcloud, { points: new Potree.Points(), material: material, geometry: geometry, model: model, listeners: [{ - target: pointcloud.material, - type: "material_property_changed", + target: pointcloud.material, + type: 'material_property_changed', callback: materialChanged}] }); } - + let pc = this.pointclouds.get(pointcloud); pc.points.add(points); - + // rebuild 3d model let projectedBox = new THREE.Box3(); { let geometry = pc.geometry; - - for(let attribute of Object.keys(pc.points.data)){ - + + for (let attribute of Object.keys(pc.points.data)) { let buffer = pc.points.data[attribute]; - let itemSize = buffer.length / pc.points.numPoints; - - if(attribute === "position"){ - + + if (attribute === 'position') { let posBuffer = new Float32Array(buffer.length); - - for(let i = 0; i < pc.points.numPoints; i++){ + + for (let i = 0; i < pc.points.numPoints; i++) { let x = pc.points.data.mileage[i]; - let y = buffer[3*i + 2]; - - posBuffer[3*i + 0] = x; - posBuffer[3*i + 1] = y; - posBuffer[3*i + 2] = y; + let y = buffer[3 * i + 2]; + + posBuffer[3 * i + 0] = x; + posBuffer[3 * i + 1] = y; + posBuffer[3 * i + 2] = y; projectedBox.expandByPoint(new THREE.Vector3(x, y, 0)); } - - if(!posBuffer){ - console.log("wtf"); + + if (!posBuffer) { + console.log('wtf'); } - + geometry.attributes[attribute].array.set(posBuffer); - }else if(attribute === "color"){ + } else if (attribute === 'color') { geometry.attributes[attribute].array.set(buffer); - }else if(attribute === "mileage"){ + } else if (attribute === 'mileage') { continue; - }else if(geometry.attributes[attribute] === undefined){ + } else if (geometry.attributes[attribute] === undefined) { continue; - }else{ + } else { geometry.attributes[attribute].array.set(buffer); } - + geometry.attributes[attribute].needsUpdate = true; geometry.setDrawRange(0, pc.points.numPoints); } - - let radius = pc.points.boundingBox.getSize().toArray().reduce((a, v) => Math.max(a, v)) - geometry.boundingSphere = new THREE.Sphere(this.camera.position, radius) + + let radius = pc.points.boundingBox.getSize().toArray().reduce((a, v) => Math.max(a, v)); + geometry.boundingSphere = new THREE.Sphere(this.camera.position, radius); geometry.boundingBox = geometry.boundingSphere.getBoundingBox(); } - + this.projectedBox.union(projectedBox); - - if(this.autoFit){ // SCALE + + if (this.autoFit) { // SCALE let width = this.renderArea[0].clientWidth; let height = this.renderArea[0].clientHeight; - + let size = this.projectedBox.getSize(); - + let sx = width / size.x; let sy = height / size.y; let scale = Math.min(sx, sy); - + let center = this.projectedBox.getCenter(); this.scale.set(scale, scale, 1); this.camera.position.copy(center); } - + let numPoints = 0; - for(let entry of this.pointclouds.entries()){ + for (let entry of this.pointclouds.entries()) { numPoints += entry[1].points.numPoints; - + $(`#profile_num_points`).html(Potree.utils.addCommas(numPoints)); } - + this.render(); } - - reset(){ - + + reset () { this.autoFit = true; this.projectedBox = new THREE.Box3(); - - for(let entry of this.pointclouds){ - - let pointcloud = entry[0]; + + for (let entry of this.pointclouds) { + // entry[0]; -> pointcloud let material = entry[1].model.material; let geometry = entry[1].model.geometry; this.materialPool.returnMaterial(material); this.geometryPool.returnGeometry(geometry); entry[1].model.material = null; entry[1].model.geometry = null; - - for(let listener of entry[1].listeners){ + + for (let listener of entry[1].listeners) { listener.target.removeEventListener(listener.type, listener.callback); } - } - + this.pointclouds.clear(); this.mouseIsDown = false; this.mouse.set(0, 0); this.scale.set(1, 1, 1); this.pickSphere.visible = false; - + this.scene.children .filter(c => c instanceof THREE.Points) .forEach(c => this.scene.remove(c)); - - this.elRoot.find("#profileSelectionProperties").hide(); - - + + this.elRoot.find('#profileSelectionProperties').hide(); + this.render(); } - - show(){ + + show () { this.elRoot.fadeIn(); this.enabled = true; } - - hide(){ + + hide () { this.elRoot.fadeOut(); this.enabled = false; } - - updateScales(){ + + updateScales () { let width = this.renderArea[0].clientWidth; let height = this.renderArea[0].clientHeight; - - let left = (-width / 2) / this.scale.x; - let right = (+width / 2) / this.scale.x; - let top = (+height / 2) / this.scale.y; + + let left = (-width / 2) / this.scale.x; + let right = (+width / 2) / this.scale.x; + let top = (+height / 2) / this.scale.y; let bottom = (-height / 2) / this.scale.y; - + this.camera.left = left; this.camera.right = right; this.camera.top = top; this.camera.bottom = bottom; this.camera.updateProjectionMatrix(); - + this.scaleX.domain([this.camera.left + this.camera.position.x, this.camera.right + this.camera.position.x]) .range([0, width]); this.scaleY.domain([this.camera.bottom + this.camera.position.y, this.camera.top + this.camera.position.y]) .range([height, 0]); } - - render(){ + + render () { let width = this.renderArea[0].clientWidth; let height = this.renderArea[0].clientHeight; - - this.updateScales(); - - { // THREEJS + this.updateScales(); + + { // THREEJS let radius = Math.abs(this.scaleX.invert(0) - this.scaleX.invert(5)); this.pickSphere.scale.set(radius, radius, radius); this.pickSphere.position.z = this.camera.far - radius; - - for(let entry of this.pointclouds){ + + for (let entry of this.pointclouds) { let pointcloud = entry[0]; let material = entry[1].material; - + material.pointColorType = pointcloud.material.pointColorType; material.uniforms.intensityRange.value = pointcloud.material.uniforms.intensityRange.value; material.heightMin = pointcloud.material.heightMin; @@ -606,152 +586,142 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher{ material.intensityContrast = pointcloud.material.intensityContrast; material.intensityBrightness = pointcloud.material.intensityBrightness; } - + this.renderer.setSize(width, height); - + this.renderer.render(this.scene, this.camera); } - + { // SVG SCALES let marginLeft = this.renderArea[0].offsetLeft; - + this.xAxis.scale(this.scaleX) - .orient("bottom") + .orient('bottom') .innerTickSize(-height) .outerTickSize(1) .tickPadding(10) .ticks(width / 50); this.yAxis.scale(this.scaleY) - .orient("left") + .orient('left') .innerTickSize(-width) .outerTickSize(1) .tickPadding(10) .ticks(height / 20); - - d3.select(".x,axis") - .attr("transform", `translate(${marginLeft}, ${height})`) + + d3.select('.x,axis') + .attr('transform', `translate(${marginLeft}, ${height})`) .call(this.xAxis); - d3.select(".y,axis") - .attr("transform", `translate(${marginLeft}, 0)`) + d3.select('.y,axis') + .attr('transform', `translate(${marginLeft}, 0)`) .call(this.yAxis); } } - }; -Potree.ProfileWindowController = class ProfileWindowController{ - - constructor(viewer){ +Potree.ProfileWindowController = class ProfileWindowController { + constructor (viewer) { this.viewer = viewer; this.profileWindow = viewer.profileWindow; this.profile = null; this.numPoints = 0; - this.threshold = 30*1000; + this.threshold = 30 * 1000; this.scheduledRecomputeTime = null; - - this.enabled = true; - - this.requests = []; - - this._recompute = () => {this.recompute()}; - } - - setProfile(profile){ - - if(this.profile !== null && this.profile !== profile){ - this.profile.removeEventListener("marker_moved", this._recompute); - this.profile.removeEventListener("marker_added", this._recompute); - this.profile.removeEventListener("marker_removed", this._recompute); - this.profile.removeEventListener("width_changed", this._recompute); - } - - this.profile = profile; - - { - this.profile.addEventListener("marker_moved", this._recompute); - this.profile.addEventListener("marker_added", this._recompute); - this.profile.addEventListener("marker_removed", this._recompute); - this.profile.addEventListener("width_changed", this._recompute); + this.enabled = true; + + this.requests = []; + + this._recompute = () => { this.recompute(); }; + } + + setProfile (profile) { + if (this.profile !== null && this.profile !== profile) { + this.profile.removeEventListener('marker_moved', this._recompute); + this.profile.removeEventListener('marker_added', this._recompute); + this.profile.removeEventListener('marker_removed', this._recompute); + this.profile.removeEventListener('width_changed', this._recompute); } - + + this.profile = profile; + + { + this.profile.addEventListener('marker_moved', this._recompute); + this.profile.addEventListener('marker_added', this._recompute); + this.profile.addEventListener('marker_removed', this._recompute); + this.profile.addEventListener('width_changed', this._recompute); + } + this.recompute(); } - - reset(){ + + reset () { this.profileWindow.reset(); - + this.numPoints = 0; - - if(this.profile){ - for(let request of this.requests){ + + if (this.profile) { + for (let request of this.requests) { request.cancel(); } } } - - progressHandler(pointcloud, progress){ - - for(let segment of progress.segments){ + + progressHandler (pointcloud, progress) { + for (let segment of progress.segments) { this.profileWindow.addPoints(pointcloud, segment.points); this.numPoints += segment.points.numPoints; } } - - cancel(){ - for(let request of this.requests){ + + cancel () { + for (let request of this.requests) { request.cancel(); - //request.finishLevelThenCancel(); + // request.finishLevelThenCancel(); } - + this.requests = []; }; - - recompute(){ - - if(!this.profile){ + + recompute () { + if (!this.profile) { return; } - - if(this.scheduledRecomputeTime !== null && this.scheduledRecomputeTime > new Date().getTime()){ + + if (this.scheduledRecomputeTime !== null && this.scheduledRecomputeTime > new Date().getTime()) { return; - }else{ + } else { this.scheduledRecomputeTime = new Date().getTime() + 100; } this.scheduledRecomputeTime = null; - + this.reset(); - - for(let pointcloud of this.viewer.scene.pointclouds.filter(p => p.visible)){ - + + for (let pointcloud of this.viewer.scene.pointclouds.filter(p => p.visible)) { let request = pointcloud.getPointsInProfile(this.profile, null, { - "onProgress": (event) => { - if(!this.enabled){ + 'onProgress': (event) => { + if (!this.enabled) { return; } - + this.progressHandler(pointcloud, event.points); - - if(this.numPoints > this.threshold){ + + if (this.numPoints > this.threshold) { this.cancel(); } }, - "onFinish": (event) => { - if(!this.enabled){ - return; + 'onFinish': (event) => { + if (!this.enabled) { + } }, - "onCancel": () => { - if(!this.enabled){ - return; + 'onCancel': () => { + if (!this.enabled) { + } } - }); - + }); + this.requests.push(request); } - } - - -}; \ No newline at end of file +}; diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index d8e2f369..4587e7c2 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -1,2564 +1,2496 @@ - - - -let createToolIcon = function(icon, title, callback){ - let element = $(` - - `); - - element.click(callback); - - return element; -}; - -function initToolbar(){ - - // ANGLE - let elToolbar = $("#tools"); - elToolbar.append(createToolIcon( - Potree.resourcePath + "/icons/angle.png", - "[title]tt.angle_measurement", - function(){ - $("#menu_measurements").next().slideDown(); - viewer.measuringTool.startInsertion({ - showDistances: false, - showAngles: true, - showArea: false, - closed: true, - maxMarkers: 3, - name: "Angle"}); - } - )); - - // POINT - elToolbar.append(createToolIcon( - Potree.resourcePath + "/icons/point.svg", - "[title]tt.point_measurement", - function(){ - $("#menu_measurements").next().slideDown(); - viewer.measuringTool.startInsertion({ - showDistances: false, - showAngles: false, - showCoordinates: true, - showArea: false, - closed: true, - maxMarkers: 1, - name: "Point"}); - } - )); - - // DISTANCE - elToolbar.append(createToolIcon( - Potree.resourcePath + "/icons/distance.svg", - "[title]tt.distance_measurement", - function(){ - $("#menu_measurements").next().slideDown(); - viewer.measuringTool.startInsertion({ - showDistances: true, - showArea: false, - closed: false, - name: "Distance"}); - } - )); - - // HEIGHT - elToolbar.append(createToolIcon( - Potree.resourcePath + "/icons/height.svg", - "[title]tt.height_measurement", - function(){ - $("#menu_measurements").next().slideDown(); - viewer.measuringTool.startInsertion({ - showDistances: false, - showHeight: true, - showArea: false, - closed: false, - maxMarkers: 2, - name: "Height"}); - } - )); - - // AREA - elToolbar.append(createToolIcon( - Potree.resourcePath + "/icons/area.svg", - "[title]tt.area_measurement", - function(){ - $("#menu_measurements").next().slideDown(); - viewer.measuringTool.startInsertion({ - showDistances: true, - showArea: true, - closed: true, - name: "Area"}); - } - )); - - // VOLUME - elToolbar.append(createToolIcon( - Potree.resourcePath + "/icons/volume.svg", - "[title]tt.volume_measurement", - function(){viewer.volumeTool.startInsertion()} - )); - - // PROFILE - elToolbar.append(createToolIcon( - Potree.resourcePath + "/icons/profile.svg", - "[title]tt.height_profile", - function(){ - $("#menu_measurements").next().slideDown();; - viewer.profileTool.startInsertion(); - } - )); - - // CLIP VOLUME - elToolbar.append(createToolIcon( - Potree.resourcePath + "/icons/clip_volume.svg", - "[title]tt.clip_volume", - function(){viewer.volumeTool.startInsertion({clip: true})} - )); - - // REMOVE ALL - elToolbar.append(createToolIcon( - Potree.resourcePath + "/icons/reset_tools.svg", - "[title]tt.remove_all_measurement", - function(){ - viewer.scene.removeAllMeasurements(); - } - )); -} - -function initClassificationList(){ - let elClassificationList = $("#classificationList"); - - let addClassificationItem = function(code, name){ - - let inputID = "chkClassification_" + code; - +initSidebar = (function (viewer) { + let createToolIcon = function (icon, title, callback) { let element = $(` -
  • - -
  • + `); - - let elInput = element.find("input"); - - elInput.click(event => { - viewer.setClassificationVisibility(code, event.target.checked); - }); - - elClassificationList.append(element); - }; - - addClassificationItem(0, "never classified"); - addClassificationItem(1, "unclassified"); - addClassificationItem(2, "ground"); - addClassificationItem(3, "low vegetation"); - addClassificationItem(4, "medium vegetation"); - addClassificationItem(5, "high vegetation"); - addClassificationItem(6, "building"); - addClassificationItem(7, "low point(noise)"); - addClassificationItem(8, "key-point"); - addClassificationItem(9, "water"); - addClassificationItem(12, "overlap"); -} -function initAccordion(){ - - $(".accordion > h3").each(function(){ - let header = $(this); - let content = $(this).next(); - - header.addClass("accordion-header ui-widget"); - content.addClass("accordion-content ui-widget"); - - content.hide(); - - header.click(function(){ - content.slideToggle(); - }); - }); - - // to close all, call - // $(".accordion > div").hide() - - // to open the, for example, tool menu, call: - // $("#menu_tools").next().show() - -} + element.click(callback); -function initAppearance(){ - - //$( "#optQuality" ).selectmenu(); - - //$("#optQuality").val(viewer.getQuality()).selectmenu("refresh") - //$("#optQuality").selectmenu({ - // change: function(event, ui){ - // viewer.setQuality(ui.item.value); - // } - //}); - - - $( "#sldPointBudget" ).slider({ - value: viewer.getPointBudget(), - min: 100*1000, - max: 5*1000*1000, - step: 1000, - slide: function( event, ui ) {viewer.setPointBudget(ui.value);} - }); - - $( "#sldFOV" ).slider({ - value: viewer.getFOV(), - min: 20, - max: 100, - step: 1, - slide: function( event, ui ) {viewer.setFOV(ui.value);} - }); - - $( "#sldEDLRadius" ).slider({ - value: viewer.getEDLRadius(), - min: 1, - max: 4, - step: 0.01, - slide: function( event, ui ) {viewer.setEDLRadius(ui.value);} - }); - - $( "#sldEDLStrength" ).slider({ - value: viewer.getEDLStrength(), - min: 0, - max: 5, - step: 0.01, - slide: function( event, ui ) {viewer.setEDLStrength(ui.value);} - }); - - viewer.addEventListener("point_budget_changed", function(event){ - $( '#lblPointBudget')[0].innerHTML = Potree.utils.addCommas(viewer.getPointBudget()); - $( "#sldPointBudget" ).slider({value: viewer.getPointBudget()}); - }); - - viewer.addEventListener("fov_changed", function(event){ - $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); - $( "#sldFOV" ).slider({value: viewer.getFOV()}); - }); - - //viewer.addEventListener("quality_changed", e => { - // - // let name = viewer.quality; - // - // $( "#optQuality" ) - // .selectmenu() - // .val(name) - // .selectmenu("refresh"); - //}); - - viewer.addEventListener("edl_radius_changed", function(event){ - $('#lblEDLRadius')[0].innerHTML = viewer.getEDLRadius().toFixed(1); - $( "#sldEDLRadius" ).slider({value: viewer.getEDLRadius()}); - }); - - viewer.addEventListener("edl_strength_changed", function(event){ - $('#lblEDLStrength')[0].innerHTML = viewer.getEDLStrength().toFixed(1); - $( "#sldEDLStrength" ).slider({value: viewer.getEDLStrength()}); - }); - - viewer.addEventListener("background_changed", function(event){ - $("input[name=background][value='" + viewer.getBackground() + "']").prop("checked",true); - }); - - - $('#lblPointBudget')[0].innerHTML = Potree.utils.addCommas(viewer.getPointBudget()); - $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); - $('#lblEDLRadius')[0].innerHTML = viewer.getEDLRadius().toFixed(1); - $('#lblEDLStrength')[0].innerHTML = viewer.getEDLStrength().toFixed(1); - $('#chkEDLEnabled')[0].checked = viewer.getEDLEnabled(); - $("input[name=background][value='" + viewer.getBackground() + "']").prop("checked",true); -} - - -function initNavigation(){ - - let elNavigation = $("#navigation"); - let sldMoveSpeed = $("#sldMoveSpeed"); - let lblMoveSpeed = $('#lblMoveSpeed'); - - elNavigation.append(createToolIcon( - Potree.resourcePath + "/icons/earth_controls_1.png", - "[title]tt.earth_control", - function(){viewer.setNavigationMode(Potree.EarthControls)} - )); - - elNavigation.append(createToolIcon( - Potree.resourcePath + "/icons/fps_controls.png", - "[title]tt.flight_control", - function(){viewer.setNavigationMode(Potree.FirstPersonControls)} - )); - - elNavigation.append(createToolIcon( - Potree.resourcePath + "/icons/orbit_controls.svg", - "[title]tt.orbit_control", - function(){viewer.setNavigationMode(Potree.OrbitControls)} - )); - - elNavigation.append(createToolIcon( - Potree.resourcePath + "/icons/focus.svg", - "[title]tt.focus_control", - function(){viewer.fitToScreen()} - )); - - elNavigation.append(createToolIcon( - Potree.resourcePath + "/icons/topview.svg", - "[title]tt.top_view_control", - function(){viewer.setTopView()} - )); - - elNavigation.append(createToolIcon( - Potree.resourcePath + "/icons/frontview.svg", - "[title]tt.front_view_control", - function(){viewer.setFrontView()} - )); - - elNavigation.append(createToolIcon( - Potree.resourcePath + "/icons/leftview.svg", - "[title]tt.left_view_control", - function(){viewer.setLeftView()} - )); - - let speedRange = new THREE.Vector2(1, 10*1000); - - let toLinearSpeed = function(value){ - return Math.pow(value, 4) * speedRange.y + speedRange.x; - }; - - let toExpSpeed = function(value){ - return Math.pow((value - speedRange.x) / speedRange.y, 1 / 4); + return element; }; - sldMoveSpeed.slider({ - value: toExpSpeed( viewer.getMoveSpeed() ), - min: 0, - max: 1, - step: 0.01, - slide: function( event, ui ) { viewer.setMoveSpeed(toLinearSpeed(ui.value)); } - }); - - viewer.addEventListener("move_speed_changed", function(event){ - lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); - sldMoveSpeed.slider({value: toExpSpeed(viewer.getMoveSpeed())}); - }); - - lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); -} + function initToolbar () { + // ANGLE + let elToolbar = $('#tools'); + elToolbar.append(createToolIcon( + Potree.resourcePath + '/icons/angle.png', + '[title]tt.angle_measurement', + function () { + $('#menu_measurements').next().slideDown(); + viewer.measuringTool.startInsertion({ + showDistances: false, + showAngles: true, + showArea: false, + closed: true, + maxMarkers: 3, + name: 'Angle'}); + } + )); + + // POINT + elToolbar.append(createToolIcon( + Potree.resourcePath + '/icons/point.svg', + '[title]tt.point_measurement', + function () { + $('#menu_measurements').next().slideDown(); + viewer.measuringTool.startInsertion({ + showDistances: false, + showAngles: false, + showCoordinates: true, + showArea: false, + closed: true, + maxMarkers: 1, + name: 'Point'}); + } + )); + + // DISTANCE + elToolbar.append(createToolIcon( + Potree.resourcePath + '/icons/distance.svg', + '[title]tt.distance_measurement', + function () { + $('#menu_measurements').next().slideDown(); + viewer.measuringTool.startInsertion({ + showDistances: true, + showArea: false, + closed: false, + name: 'Distance'}); + } + )); + + // HEIGHT + elToolbar.append(createToolIcon( + Potree.resourcePath + '/icons/height.svg', + '[title]tt.height_measurement', + function () { + $('#menu_measurements').next().slideDown(); + viewer.measuringTool.startInsertion({ + showDistances: false, + showHeight: true, + showArea: false, + closed: false, + maxMarkers: 2, + name: 'Height'}); + } + )); + + // AREA + elToolbar.append(createToolIcon( + Potree.resourcePath + '/icons/area.svg', + '[title]tt.area_measurement', + function () { + $('#menu_measurements').next().slideDown(); + viewer.measuringTool.startInsertion({ + showDistances: true, + showArea: true, + closed: true, + name: 'Area'}); + } + )); + + // VOLUME + elToolbar.append(createToolIcon( + Potree.resourcePath + '/icons/volume.svg', + '[title]tt.volume_measurement', + function () { viewer.volumeTool.startInsertion(); } + )); + + // PROFILE + elToolbar.append(createToolIcon( + Potree.resourcePath + '/icons/profile.svg', + '[title]tt.height_profile', + function () { + $('#menu_measurements').next().slideDown(); ; + viewer.profileTool.startInsertion(); + } + )); + + // CLIP VOLUME + elToolbar.append(createToolIcon( + Potree.resourcePath + '/icons/clip_volume.svg', + '[title]tt.clip_volume', + function () { viewer.volumeTool.startInsertion({clip: true}); } + )); + + // REMOVE ALL + elToolbar.append(createToolIcon( + Potree.resourcePath + '/icons/reset_tools.svg', + '[title]tt.remove_all_measurement', + function () { + viewer.scene.removeAllMeasurements(); + } + )); + } + + function initClassificationList () { + let elClassificationList = $('#classificationList'); + + let addClassificationItem = function (code, name) { + let inputID = 'chkClassification_' + code; -function initAnnotationDetails(){ - - // annotation_details - let annotationPanel = $("#annotation_details"); - - let registeredEvents = []; - - let rebuild = () => { - annotationPanel.empty(); - for(let registeredEvent of registeredEvents){ - let {type, dispatcher, callback} = registeredEvent; - dispatcher.removeEventListener(type, callback); - } - registeredEvents = []; - - let checked = viewer.getShowAnnotations() ? "checked" : ""; - - let chkEnable = $(` -
  • - - -
  • - `); - annotationPanel.append(chkEnable); - - - //let stack = viewer.scene.annotations.children.reverse().map( - // a => ({annotation: a, container: annotationPanel})); - - let stack = viewer.scene.annotations.children.map( - a => ({annotation: a, container: annotationPanel})); - - - while(stack.length > 0){ - - let {annotation, container} = stack.shift(); - - // â–º U+25BA \u25BA - // â–¼ U+25BC \u25BC - let element = $(` -
    - - \u25BA - - ${annotation.title} - - -
    +
  • + +
  • `); - - let elMain = element.find(".annotation-main"); - let elExpand = element.find(".annotation-expand"); - - elExpand.css("display", annotation.children.length > 0 ? "block" : "none"); - - let actions = []; - { // ACTIONS, INCLUDING GOTO LOCATION - if(annotation.hasView()){ - let action = new Potree.Action({ - "icon": Potree.resourcePath + "/icons/target.svg", - "onclick": (e) => {annotation.moveHere(viewer.scene.camera)} - }); - - actions.push(action); - } - - for(let action of annotation.actions){ - actions.push(action); - } - } - - actions = actions.filter( - a => a.showIn === undefined || a.showIn.includes("sidebar")); - - // FIRST ACTION - if(annotation.children.length === 0 && actions.length > 0){ - let action = actions[0]; - - let elIcon = $(``); - - if(action.tooltip){ - elIcon.attr("title", action.tooltip); - } - - elMain.append(elIcon); - elMain.click(e => action.onclick({annotation: annotation})); - elMain.mouseover(e => elIcon.css("opacity", 1)); - elMain.mouseout(e => elIcon.css("opacity", 0.5)); - - { - let iconChanged = e => { - elIcon.attr("src", e.icon); - }; - - action.addEventListener("icon_changed", iconChanged); - registeredEvents.push({ - type: "icon_changed", - dispatcher: action, - callback: iconChanged - }); - } - - actions.splice(0, 1); - } - - // REMAINING ACTIONS - for(let action of actions){ - - let elIcon = $(``); - - if(action.tooltip){ - elIcon.attr("title", action.tooltip); - } - - elIcon.click(e => { - action.onclick({annotation: annotation}); - return false; - }); - elIcon.mouseover(e => elIcon.css("opacity", 1)); - elIcon.mouseout(e => elIcon.css("opacity", 0.5)); - - { - let iconChanged = e => { - elIcon.attr("src", e.icon); - }; - - action.addEventListener("icon_changed", iconChanged); - registeredEvents.push({ - type: "icon_changed", - dispatcher: action, - callback: iconChanged - }); - } - - element.append(elIcon); - } - - element.mouseover(e => annotation.setHighlighted(true)); - element.mouseout(e => annotation.setHighlighted(false)); - - annotation.setHighlighted(false); - - container.append(element); - - if(annotation.children.length > 0){ - - element.click(e => { - - if(element.next().is(":visible")){ - elExpand.html("\u25BA"); - }else{ - elExpand.html("\u25BC"); - } - - element.next().toggle(100); - }); - - //let left = ((annotation.level()) * 20) + "px"; - let left = "20px"; - let childContainer = $(`
    `); - for(let child of annotation.children){ - container.append(childContainer); - stack.push({annotation: child, container: childContainer}); - } - } - - }; - - annotationPanel.i18n(); - }; - - let annotationsChanged = e => { - rebuild(); - }; - - viewer.addEventListener("scene_changed", e => { - e.oldScene.annotations.removeEventListener("annotation_added", annotationsChanged); - e.scene.annotations.addEventListener("annotation_added", annotationsChanged); - - rebuild(); - }); - - viewer.scene.annotations.addEventListener("annotation_added", annotationsChanged); - - rebuild(); -} -function initMeasurementDetails(){ - - let id = 0; - let trackedItems = new Map(); - - let removeIconPath = Potree.resourcePath + "/icons/remove.svg"; - let mlist = $("#measurement_list"); - - let createCoordinatesTable = (measurement) => { - - let table = $(` - - - - - - -
    xyz
    - `); - - for(let point of measurement.points){ - let position = point instanceof THREE.Vector3 ? point : point.position; - - let x = Potree.utils.addCommas(position.x.toFixed(3)); - let y = Potree.utils.addCommas(position.y.toFixed(3)); - let z = Potree.utils.addCommas(position.z.toFixed(3)); - - let row = $(` - - ${x} - ${y} - ${z} - + let elInput = element.find('input'); + + elInput.click(event => { + viewer.setClassificationVisibility(code, event.target.checked); + }); + + elClassificationList.append(element); + }; + + addClassificationItem(0, 'never classified'); + addClassificationItem(1, 'unclassified'); + addClassificationItem(2, 'ground'); + addClassificationItem(3, 'low vegetation'); + addClassificationItem(4, 'medium vegetation'); + addClassificationItem(5, 'high vegetation'); + addClassificationItem(6, 'building'); + addClassificationItem(7, 'low point(noise)'); + addClassificationItem(8, 'key-point'); + addClassificationItem(9, 'water'); + addClassificationItem(12, 'overlap'); + } + + function initAccordion () { + $('.accordion > h3').each(function () { + let header = $(this); + let content = $(this).next(); + + header.addClass('accordion-header ui-widget'); + content.addClass('accordion-content ui-widget'); + + content.hide(); + + header.click(function () { + content.slideToggle(); + }); + }); + + // to close all, call + // $(".accordion > div").hide() + + // to open the, for example, tool menu, call: + // $("#menu_tools").next().show() + } + + function initAppearance () { + // $( "#optQuality" ).selectmenu(); + + // $("#optQuality").val(viewer.getQuality()).selectmenu("refresh") + // $("#optQuality").selectmenu({ + // change: function(event, ui){ + // viewer.setQuality(ui.item.value); + // } + // }); + + $('#sldPointBudget').slider({ + value: viewer.getPointBudget(), + min: 100 * 1000, + max: 5 * 1000 * 1000, + step: 1000, + slide: function (event, ui) { viewer.setPointBudget(ui.value); } + }); + + $('#sldFOV').slider({ + value: viewer.getFOV(), + min: 20, + max: 100, + step: 1, + slide: function (event, ui) { viewer.setFOV(ui.value); } + }); + + $('#sldEDLRadius').slider({ + value: viewer.getEDLRadius(), + min: 1, + max: 4, + step: 0.01, + slide: function (event, ui) { viewer.setEDLRadius(ui.value); } + }); + + $('#sldEDLStrength').slider({ + value: viewer.getEDLStrength(), + min: 0, + max: 5, + step: 0.01, + slide: function (event, ui) { viewer.setEDLStrength(ui.value); } + }); + + viewer.addEventListener('point_budget_changed', function (event) { + $('#lblPointBudget')[0].innerHTML = Potree.utils.addCommas(viewer.getPointBudget()); + $('#sldPointBudget').slider({value: viewer.getPointBudget()}); + }); + + viewer.addEventListener('fov_changed', function (event) { + $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); + $('#sldFOV').slider({value: viewer.getFOV()}); + }); + + // viewer.addEventListener("quality_changed", e => { + // + // let name = viewer.quality; + // + // $( "#optQuality" ) + // .selectmenu() + // .val(name) + // .selectmenu("refresh"); + // }); + + viewer.addEventListener('edl_radius_changed', function (event) { + $('#lblEDLRadius')[0].innerHTML = viewer.getEDLRadius().toFixed(1); + $('#sldEDLRadius').slider({value: viewer.getEDLRadius()}); + }); + + viewer.addEventListener('edl_strength_changed', function (event) { + $('#lblEDLStrength')[0].innerHTML = viewer.getEDLStrength().toFixed(1); + $('#sldEDLStrength').slider({value: viewer.getEDLStrength()}); + }); + + viewer.addEventListener('background_changed', function (event) { + $("input[name=background][value='" + viewer.getBackground() + "']").prop('checked', true); + }); + + $('#lblPointBudget')[0].innerHTML = Potree.utils.addCommas(viewer.getPointBudget()); + $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); + $('#lblEDLRadius')[0].innerHTML = viewer.getEDLRadius().toFixed(1); + $('#lblEDLStrength')[0].innerHTML = viewer.getEDLStrength().toFixed(1); + $('#chkEDLEnabled')[0].checked = viewer.getEDLEnabled(); + $("input[name=background][value='" + viewer.getBackground() + "']").prop('checked', true); + } + + function initNavigation () { + let elNavigation = $('#navigation'); + let sldMoveSpeed = $('#sldMoveSpeed'); + let lblMoveSpeed = $('#lblMoveSpeed'); + + elNavigation.append(createToolIcon( + Potree.resourcePath + '/icons/earth_controls_1.png', + '[title]tt.earth_control', + function () { viewer.setNavigationMode(Potree.EarthControls); } + )); + + elNavigation.append(createToolIcon( + Potree.resourcePath + '/icons/fps_controls.png', + '[title]tt.flight_control', + function () { viewer.setNavigationMode(Potree.FirstPersonControls); } + )); + + elNavigation.append(createToolIcon( + Potree.resourcePath + '/icons/orbit_controls.svg', + '[title]tt.orbit_control', + function () { viewer.setNavigationMode(Potree.OrbitControls); } + )); + + elNavigation.append(createToolIcon( + Potree.resourcePath + '/icons/focus.svg', + '[title]tt.focus_control', + function () { viewer.fitToScreen(); } + )); + + elNavigation.append(createToolIcon( + Potree.resourcePath + '/icons/topview.svg', + '[title]tt.top_view_control', + function () { viewer.setTopView(); } + )); + + elNavigation.append(createToolIcon( + Potree.resourcePath + '/icons/frontview.svg', + '[title]tt.front_view_control', + function () { viewer.setFrontView(); } + )); + + elNavigation.append(createToolIcon( + Potree.resourcePath + '/icons/leftview.svg', + '[title]tt.left_view_control', + function () { viewer.setLeftView(); } + )); + + let speedRange = new THREE.Vector2(1, 10 * 1000); + + let toLinearSpeed = function (value) { + return Math.pow(value, 4) * speedRange.y + speedRange.x; + }; + + let toExpSpeed = function (value) { + return Math.pow((value - speedRange.x) / speedRange.y, 1 / 4); + }; + + sldMoveSpeed.slider({ + value: toExpSpeed(viewer.getMoveSpeed()), + min: 0, + max: 1, + step: 0.01, + slide: function (event, ui) { viewer.setMoveSpeed(toLinearSpeed(ui.value)); } + }); + + viewer.addEventListener('move_speed_changed', function (event) { + lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); + sldMoveSpeed.slider({value: toExpSpeed(viewer.getMoveSpeed())}); + }); + + lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); + } + + function initAnnotationDetails () { + // annotation_details + let annotationPanel = $('#annotation_details'); + + let registeredEvents = []; + + let rebuild = () => { + annotationPanel.empty(); + for (let registeredEvent of registeredEvents) { + let {type, dispatcher, callback} = registeredEvent; + dispatcher.removeEventListener(type, callback); + } + registeredEvents = []; + + let checked = viewer.getShowAnnotations() ? 'checked' : ''; + + let chkEnable = $(` +
  • + + +
  • `); - - table.append(row); - } - - return table; - }; - - let createAttributesTable = (measurement) => { - - let elTable = $('
    '); - - let point = measurement.points[0]; - - if(point.color){ - let color = point.color; - let text = color.join(", "); - - elTable.append($(` - - rgb - ${text} - - `)); - } - - return elTable; - }; - - class MeasurePanel{ - constructor(scene, measurement){ - this.scene = scene; - this.measurement = measurement; - this.icon = null; - - this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1; - this.id = this.constructor.counter; - - let title = measurement.name; - - this.elPanel = $(` - - -
    - - ${title} + annotationPanel.append(chkEnable); + + // let stack = viewer.scene.annotations.children.reverse().map( + // a => ({annotation: a, container: annotationPanel})); + + let stack = viewer.scene.annotations.children.map( + a => ({annotation: a, container: annotationPanel})); + + while (stack.length > 0) { + let {annotation, container} = stack.shift(); + + // â–º U+25BA \u25BA + // â–¼ U+25BC \u25BC + + let element = $(` +
    + + \u25BA + + ${annotation.title} + +
    - + `); + + let elMain = element.find('.annotation-main'); + let elExpand = element.find('.annotation-expand'); + + elExpand.css('display', annotation.children.length > 0 ? 'block' : 'none'); + + let actions = []; + { // ACTIONS, INCLUDING GOTO LOCATION + if (annotation.hasView()) { + let action = new Potree.Action({ + 'icon': Potree.resourcePath + '/icons/target.svg', + 'onclick': (e) => { annotation.moveHere(viewer.scene.camera); } + }); + + actions.push(action); + } + } + + for (let action of annotation.actions) { + actions.push(action); + } + + actions = actions.filter( + a => a.showIn === undefined || a.showIn.includes('sidebar')); + + // FIRST ACTION + if (annotation.children.length === 0 && actions.length > 0) { + let action = actions[0]; + + let elIcon = $(``); + + if (action.tooltip) { + elIcon.attr('title', action.tooltip); + } + + elMain.append(elIcon); + elMain.click(e => action.onclick({annotation: annotation})); + elMain.mouseover(e => elIcon.css('opacity', 1)); + elMain.mouseout(e => elIcon.css('opacity', 0.5)); + + { + let iconChanged = e => { + elIcon.attr('src', e.icon); + }; + + action.addEventListener('icon_changed', iconChanged); + registeredEvents.push({ + type: 'icon_changed', + dispatcher: action, + callback: iconChanged + }); + } + + actions.splice(0, 1); + } + + // REMAINING ACTIONS + for (let action of actions) { + let elIcon = $(``); + + if (action.tooltip) { + elIcon.attr('title', action.tooltip); + } + + elIcon.click(e => { + action.onclick({annotation: annotation}); + return false; + }); + elIcon.mouseover(e => elIcon.css('opacity', 1)); + elIcon.mouseout(e => elIcon.css('opacity', 0.5)); + + { + let iconChanged = e => { + elIcon.attr('src', e.icon); + }; + + action.addEventListener('icon_changed', iconChanged); + registeredEvents.push({ + type: 'icon_changed', + dispatcher: action, + callback: iconChanged + }); + } + + element.append(elIcon); + } + + element.mouseover(e => annotation.setHighlighted(true)); + element.mouseout(e => annotation.setHighlighted(false)); + + annotation.setHighlighted(false); + + container.append(element); + + if (annotation.children.length > 0) { + element.click(e => { + if (element.next().is(':visible')) { + elExpand.html('\u25BA'); + } else { + elExpand.html('\u25BC'); + } + + element.next().toggle(100); + }); + + // let left = ((annotation.level()) * 20) + "px"; + let left = '20px'; + let childContainer = $(`
    `); + for (let child of annotation.children) { + container.append(childContainer); + stack.push({annotation: child, container: childContainer}); + } + } + }; + + annotationPanel.i18n(); + }; + + let annotationsChanged = e => { + rebuild(); + }; + + viewer.addEventListener('scene_changed', e => { + e.oldScene.annotations.removeEventListener('annotation_added', annotationsChanged); + e.scene.annotations.addEventListener('annotation_added', annotationsChanged); + + rebuild(); + }); + + viewer.scene.annotations.addEventListener('annotation_added', annotationsChanged); + + rebuild(); + } + + function initMeasurementDetails () { + let trackedItems = new Map(); + + let removeIconPath = Potree.resourcePath + '/icons/remove.svg'; + let mlist = $('#measurement_list'); + + let createCoordinatesTable = (measurement) => { + let table = $(` + + + + + + +
    xyz
    + `); + + for (let point of measurement.points) { + let position = point instanceof THREE.Vector3 ? point : point.position; + + let x = Potree.utils.addCommas(position.x.toFixed(3)); + let y = Potree.utils.addCommas(position.y.toFixed(3)); + let z = Potree.utils.addCommas(position.z.toFixed(3)); + + let row = $(` + + ${x} + ${y} + ${z} + + `); + + table.append(row); + } + + return table; + }; + + let createAttributesTable = (measurement) => { + let elTable = $('
    '); + + let point = measurement.points[0]; + + if (point.color) { + let color = point.color; + let text = color.join(', '); + + elTable.append($(` + + rgb + ${text} + + `)); + } + + return elTable; + }; + + class MeasurePanel { + constructor (scene, measurement) { + this.scene = scene; + this.measurement = measurement; + this.icon = null; + + this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1; + this.id = this.constructor.counter; + + let title = measurement.name; + + this.elPanel = $(` + + +
    + + ${title} +
    + + + +
    + `); + + this.elContentContainer = this.elPanel.find('.measurement_content'); + this.elIcon = this.elPanel.find('.measurement_item_icon'); + + this._update = () => { this.update(); }; + } + + destroy () { + + } + + update () { + + } + }; + + class DistancePanel extends MeasurePanel { + constructor (scene, measurement) { + super(scene, measurement); + + this.typename = 'Distance'; + this.icon = Potree.resourcePath + '/icons/distance.svg'; + this.elIcon.attr('src', this.icon); + + this.elContent = $(` +
    + + + + +
    + +
    + + +
    + + + +
    +
    + `); + this.elContentContainer.append(this.elContent); + + let elRemove = this.elContent.find('.measurement_action_remove'); + elRemove.click(() => { this.scene.removeMeasurement(measurement); }); + + this.measurement.addEventListener('marker_added', this._update); + this.measurement.addEventListener('marker_removed', this._update); + this.measurement.addEventListener('marker_moved', this._update); + + this.update(); + } + + update () { + let elCoordiantesContainer = this.elContent.find('.coordinates_table_container'); + elCoordiantesContainer.empty(); + elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); + + let positions = this.measurement.points.map(p => p.position); + let distances = []; + for (let i = 0; i < positions.length - 1; i++) { + let d = positions[i].distanceTo(positions[i + 1]); + distances.push(d.toFixed(3)); + } + + let totalDistance = this.measurement.getTotalDistance().toFixed(3); + let elDistanceTable = this.elContent.find(`#distances_table_${this.id}`); + elDistanceTable.empty(); + + for (let i = 0; i < distances.length; i++) { + let label = (i === 0) ? 'Distances: ' : ''; + let distance = distances[i]; + let elDistance = $(` + + ${label} + ${distance} + `); + elDistanceTable.append(elDistance); + } + + let elTotal = $(` + + Total: ${totalDistance} + `); + elDistanceTable.append(elTotal); + + // let elDistance = this.elContent.find(`#distance_${this.id}`); + // elDistance.html(totalDistance); + } + + destroy () { + this.elPanel.remove(); + + this.measurement.removeEventListener('marker_added', this._update); + this.measurement.removeEventListener('marker_removed', this._update); + this.measurement.removeEventListener('marker_moved', this._update); + } + }; + + class PointPanel extends MeasurePanel { + constructor (scene, measurement) { + super(scene, measurement); + + this.typename = 'Point'; + this.icon = Potree.resourcePath + '/icons/point.svg'; + + this.elIcon.attr('src', this.icon); + + this.elContent = $(` +
    + + +
    + + + + + +
    + + + +
    +
    + `); + this.elContentContainer.append(this.elContent); + + let elRemove = this.elContent.find('.measurement_action_remove'); + elRemove.click(() => { this.scene.removeMeasurement(measurement); }); + + this.measurement.addEventListener('marker_added', this._update); + this.measurement.addEventListener('marker_removed', this._update); + this.measurement.addEventListener('marker_moved', this._update); + + this.update(); + } + + update () { + let elCoordiantesContainer = this.elContent.find('.coordinates_table_container'); + elCoordiantesContainer.empty(); + elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); + + let elAttributesContainer = this.elContent.find('.attributes_table_container'); + elAttributesContainer.empty(); + elAttributesContainer.append(createAttributesTable(this.measurement)); + } + + destroy () { + this.elPanel.remove(); + + this.measurement.removeEventListener('marker_added', this._update); + this.measurement.removeEventListener('marker_removed', this._update); + this.measurement.removeEventListener('marker_moved', this._update); + } + }; + + class AreaPanel extends MeasurePanel { + constructor (scene, measurement) { + super(scene, measurement); + + this.typename = 'Area'; + this.icon = Potree.resourcePath + '/icons/area.svg'; + + this.elIcon.attr('src', this.icon); + + this.elContent = $(` +
    + + +
    + + Area: + + + +
    + + + +
    +
    + `); + this.elContentContainer.append(this.elContent); + + let elRemove = this.elContent.find('.measurement_action_remove'); + elRemove.click(() => { this.scene.removeMeasurement(measurement); }); + + this.measurement.addEventListener('marker_added', this._update); + this.measurement.addEventListener('marker_removed', this._update); + this.measurement.addEventListener('marker_moved', this._update); + + this.update(); + } + + update () { + let elCoordiantesContainer = this.elContent.find('.coordinates_table_container'); + elCoordiantesContainer.empty(); + elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); + + let elArea = this.elContent.find(`#measurement_area_${this.id}`); + elArea.html(this.measurement.getArea().toFixed(3)); + } + + destroy () { + this.elPanel.remove(); + + this.measurement.removeEventListener('marker_added', this._update); + this.measurement.removeEventListener('marker_removed', this._update); + this.measurement.removeEventListener('marker_moved', this._update); + } + }; + + class AnglePanel extends MeasurePanel { + constructor (scene, measurement) { + super(scene, measurement); + + this.typename = 'Angle'; + this.icon = Potree.resourcePath + '/icons/angle.png'; + + this.elIcon.attr('src', this.icon); + + this.elContent = $(` +
    + + +
    + + + + + + + + + + + + +
    \u03b1\u03b2\u03b3
    + + +
    + + + +
    +
    + `); + this.elContentContainer.append(this.elContent); + + let elRemove = this.elContent.find('.measurement_action_remove'); + elRemove.click(() => { this.scene.removeMeasurement(measurement); }); + + this.measurement.addEventListener('marker_added', this._update); + this.measurement.addEventListener('marker_removed', this._update); + this.measurement.addEventListener('marker_moved', this._update); + + this.update(); + } + + update () { + let elCoordiantesContainer = this.elContent.find('.coordinates_table_container'); + elCoordiantesContainer.empty(); + elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); + + let angles = []; + for (let i = 0; i < this.measurement.points.length; i++) { + angles.push(this.measurement.getAngle(i) * (180.0 / Math.PI)); + } + angles = angles.map(a => a.toFixed(1) + '\u00B0'); + + let elAlpha = this.elContent.find(`#angle_cell_alpha_${this.id}`); + let elBetta = this.elContent.find(`#angle_cell_betta_${this.id}`); + let elGamma = this.elContent.find(`#angle_cell_gamma_${this.id}`); + + elAlpha.html(angles[0]); + elBetta.html(angles[1]); + elGamma.html(angles[2]); + } + + destroy () { + this.elPanel.remove(); + + this.measurement.removeEventListener('marker_added', this._update); + this.measurement.removeEventListener('marker_removed', this._update); + this.measurement.removeEventListener('marker_moved', this._update); + } + }; + + class HeightPanel extends MeasurePanel { + constructor (scene, measurement) { + super(scene, measurement); + + this.typename = 'Height'; + this.icon = Potree.resourcePath + '/icons/height.svg'; + + this.elIcon.attr('src', this.icon); + + this.elContent = $(` +
    + + +
    + + Height:
    + + +
    + + + +
    +
    + `); + this.elContentContainer.append(this.elContent); + + let elRemove = this.elContent.find('.measurement_action_remove'); + elRemove.click(() => { this.scene.removeMeasurement(measurement); }); + + this.measurement.addEventListener('marker_added', this._update); + this.measurement.addEventListener('marker_removed', this._update); + this.measurement.addEventListener('marker_moved', this._update); + + this.update(); + } + + update () { + let elCoordiantesContainer = this.elContent.find('.coordinates_table_container'); + elCoordiantesContainer.empty(); + elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); + + { + let points = this.measurement.points; + + let sorted = points.slice().sort((a, b) => a.position.z - b.position.z); + let lowPoint = sorted[0].position.clone(); + let highPoint = sorted[sorted.length - 1].position.clone(); + let min = lowPoint.z; + let max = highPoint.z; + let height = max - min; + height = height.toFixed(3); + + this.elHeightLabel = this.elContent.find(`#height_label_${this.id}`); + this.elHeightLabel.html(`Height: ${height}`); + } + } + + destroy () { + this.elPanel.remove(); + + this.measurement.removeEventListener('marker_added', this._update); + this.measurement.removeEventListener('marker_removed', this._update); + this.measurement.removeEventListener('marker_moved', this._update); + } + }; + + class ProfilePanel extends MeasurePanel { + constructor (scene, measurement) { + super(scene, measurement); + + this.typename = 'Profile'; + this.icon = Potree.resourcePath + '/icons/profile.svg'; + + this.elIcon.attr('src', this.icon); + + let sliderID = 'sldProfileWidth_' + this.id; + + this.elContent = $(` +
    + + +
    + + + Width: + + +
    + + + + +
    + + + + +
    + + + +
    +
    + `); + this.elContentContainer.append(this.elContent); + this.elShow2DProfile = this.elContent.find(`#show_2d_profile_${this.id}`); + this.elShow2DProfile.click(() => { + viewer.profileWindow.show(); + viewer.profileWindowController.setProfile(measurement); + // viewer.profileWindow.draw(measurement); + }); + + { // download + this.elDownloadButton = this.elContent.find(`#download_profile_${this.id}`); + + if (viewer.server) { + this.elDownloadButton.click(() => this.download()); + } else { + this.elDownloadButton.hide(); + } + } + + { // width spinner + let elWidthSlider = this.elContent.find(`#${sliderID}`); + + elWidthSlider.spinner({ + min: 0, + max: 10 * 1000 * 1000, + step: 0.01, + numberFormat: 'n', + start: () => {}, + spin: (event, ui) => { + let value = elWidthSlider.spinner('value'); + measurement.setWidth(value); + }, + change: (event, ui) => { + let value = elWidthSlider.spinner('value'); + measurement.setWidth(value); + }, + stop: (event, ui) => { + let value = elWidthSlider.spinner('value'); + measurement.setWidth(value); + }, + incremental: (count) => { + let value = elWidthSlider.spinner('value'); + let step = elWidthSlider.spinner('option', 'step'); + + let delta = value * 0.05; + let increments = Math.max(1, parseInt(delta / step)); + + return increments; + } + }); + elWidthSlider.spinner('value', measurement.getWidth()); + elWidthSlider.spinner('widget').css('width', '100%'); + + this.widthListener = (event) => { + let value = elWidthSlider.spinner('value'); + if (value !== measurement.getWidth()) { + elWidthSlider.spinner('value', measurement.getWidth()); + } + }; + + measurement.addEventListener('width_changed', this.widthListener); + } + + let elRemove = this.elContent.find('.measurement_action_remove'); + elRemove.click(() => { this.scene.removeProfile(measurement); }); + + this.measurement.addEventListener('marker_added', this._update); + this.measurement.addEventListener('marker_removed', this._update); + this.measurement.addEventListener('marker_moved', this._update); + + this.update(); + } + + update () { + let elCoordiantesContainer = this.elContent.find('.coordinates_table_container'); + elCoordiantesContainer.empty(); + let coordinatesTable = createCoordinatesTable(this.measurement); + + let cells = coordinatesTable.find('span'); + cells.attr('contenteditable', 'true'); + + cells = cells.toArray(); + + for (let i = 0; i < cells.length; i++) { + let cell = cells[i]; + let measure = this.measurement; + let updateCallback = this._update; + + let assignValue = () => { + let text = Potree.utils.removeCommas($(cell).html()); + + let num = Number(text); + + if (!isNaN(num)) { + $(cell).removeClass('invalid_value'); + + measure.removeEventListener('marker_moved', updateCallback); + + let index = parseInt(i / 3); + let coordinateComponent = i % 3; + + let position = measure.points[index].clone(); + + if (coordinateComponent === 0) { + position.x = num; + } else if (coordinateComponent === 1) { + position.y = num; + } else if (coordinateComponent === 2) { + position.z = num; + } + + measure.setPosition(index, position); + measure.addEventListener('marker_moved', updateCallback); + } else { + $(cell).addClass('invalid_value'); + } + }; + + $(cell).on('keypress', (e) => { + if (e.which === 13) { + assignValue(); + return false; + } + }); + + $(cell).focusout(() => assignValue()); + + $(cell).on('input', function (e) { + let text = Potree.utils.removeCommas($(this).html()); + + let num = Number(text); + + if (!isNaN(num)) { + $(this).removeClass('invalid_value'); + } else { + $(this).addClass('invalid_value'); + } + }); + } + + elCoordiantesContainer.append(coordinatesTable); + } + + download () { + let profile = this.measurement; + let boxes = profile.getSegmentMatrices() + .map(m => m.elements.join(',')) + .join(','); + + let minLOD = 0; + let maxLOD = 100; + + let pcs = []; + for (let pointcloud of this.scene.pointclouds) { + let urlIsAbsolute = new RegExp('^(?:[a-z]+:)?//', 'i').test(pointcloud.pcoGeometry.url); + let pc = ''; + if (urlIsAbsolute) { + pc = pointcloud.pcoGeometry.url; + } else { + pc = `${window.location.href}/../${pointcloud.pcoGeometry.url}`; + } + + pcs.push(pc); + } + + let pc = pcs + .map(v => `pointcloud[]=${v}`) + .join('&'); + + let request = `${viewer.server}/start_extract_region_worker?minLOD=${minLOD}&maxLOD=${maxLOD}&box=${boxes}&${pc}`; + // console.log(request); + + let elMessage = this.elContent.find(`#download_profile_status_${this.id}`); + elMessage.html('sending request...'); + + let workerID = null; + + let start = new Date().getTime(); + + let observe = () => { + let request = `${viewer.server}/observe_status?workerID=${workerID}`; + + let loaded = 0; + + let xhr = new XMLHttpRequest(); + xhr.withCredentials = true; + xhr.addEventListener('progress', e => { + let nowLoaded = e.loaded; + + let response = xhr.responseText.substring(loaded, nowLoaded); + response = JSON.parse(response); + + if (response.status === 'FINISHED') { + elMessage.html(`
    Download ready`); + } else { + let current = new Date().getTime(); + let duration = (current - start); + let seconds = parseInt(duration / 1000); + + elMessage.html(`processing request... ${seconds}s`); + } + + loaded = nowLoaded; + }); + xhr.open('GET', request, true); + xhr.send(null); + }; + + let xhr = new XMLHttpRequest(); + xhr.withCredentials = true; + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + // alert(xhr.responseText); + let res = JSON.parse(xhr.responseText); + console.log(res); + + if (res.status === 'OK') { + workerID = res.workerID; + elMessage.html('request is being processed'); + // checkUntilFinished(); + observe(); + } else if (res.status === 'ERROR_POINT_PROCESSED_ESTIMATE_TOO_LARGE') { + elMessage.html('Too many candidate points in selection.'); + } else { + elMessage.html(`${res.status}`); + } + } + }; + xhr.open('GET', request, true); + xhr.send(null); + } + + destroy () { + this.elPanel.remove(); + + this.measurement.removeEventListener('marker_added', this._update); + this.measurement.removeEventListener('marker_removed', this._update); + this.measurement.removeEventListener('marker_moved', this._update); + this.measurement.removeEventListener('width_changed', this.widthListener); + } + }; + + class VolumePanel extends MeasurePanel { + constructor (scene, measurement) { + super(scene, measurement); + + this.typename = 'Volume'; + this.icon = Potree.resourcePath + '/icons/volume.svg'; + + this.elIcon.attr('src', this.icon); + + this.values = {}; + + this.elContent = $(` +
    + +
    +
    + x + y + z +
    +
    + + + +
    +
    + +
    +
    + length + width + height +
    +
    + + + +
    +
    + +
    +
    + α + β + γ +
    +
    + + + +
    +
    + + + + + + + + + +
    + + + +
    +
    + `); + this.elContentContainer.append(this.elContent); + + this.elClip = this.elContent.find(`#chkClip_${this.measurement.id}`); + this.elVisible = this.elContent.find(`#chkVisible_${this.measurement.id}`); + + this.elClip.click(() => { + this.measurement.clip = this.elClip.is(':checked'); + }); + + this.elVisible.click(() => { + this.measurement.visible = this.elVisible.is(':checked'); + }); + + this.elClip.prop('checked', this.measurement.clip); + this.elVisible.prop('checked', this.measurement.visible); + + this.elX = this.elContent.find(`#volume_input_x_${this.measurement.id}`); + this.elY = this.elContent.find(`#volume_input_y_${this.measurement.id}`); + this.elZ = this.elContent.find(`#volume_input_z_${this.measurement.id}`); + + this.elLength = this.elContent.find(`#volume_input_length_${this.measurement.id}`); + this.elWidth = this.elContent.find(`#volume_input_width_${this.measurement.id}`); + this.elHeight = this.elContent.find(`#volume_input_height_${this.measurement.id}`); + + this.elAlpha = this.elContent.find(`#volume_input_alpha_${this.measurement.id}`); + this.elBeta = this.elContent.find(`#volume_input_beta_${this.measurement.id}`); + this.elGamma = this.elContent.find(`#volume_input_gamma_${this.measurement.id}`); + + this.elX.on('change', (e) => { + let val = this.elX.val(); + if ($.isNumeric(val)) { + val = parseFloat(val); + + this.measurement.position.x = val; + } + }); + + this.elY.on('change', (e) => { + let val = this.elY.val(); + if ($.isNumeric(val)) { + val = parseFloat(val); + + this.measurement.position.y = val; + } + }); + + this.elZ.on('change', (e) => { + let val = this.elZ.val(); + if ($.isNumeric(val)) { + val = parseFloat(val); + + this.measurement.position.z = val; + } + }); + + this.elLength.on('change', (e) => { + let val = this.elLength.val(); + if ($.isNumeric(val)) { + val = parseFloat(val); + + this.measurement.scale.x = val; + } + }); + + this.elWidth.on('change', (e) => { + let val = this.elWidth.val(); + if ($.isNumeric(val)) { + val = parseFloat(val); + + this.measurement.scale.y = val; + } + }); + + this.elHeight.on('change', (e) => { + let val = this.elHeight.val(); + if ($.isNumeric(val)) { + val = parseFloat(val); + + this.measurement.scale.z = val; + } + }); + + let toRadians = (d) => Math.PI * d / 180; + + this.elAlpha.on('change', (e) => { + let val = this.elAlpha.val(); + if ($.isNumeric(val)) { + val = parseFloat(val); + + this.measurement.rotation.x = toRadians(val); + } + }); + + this.elBeta.on('change', (e) => { + let val = this.elBeta.val(); + if ($.isNumeric(val)) { + val = parseFloat(val); + + this.measurement.rotation.y = toRadians(val); + } + }); + + this.elGamma.on('change', (e) => { + let val = this.elGamma.val(); + if ($.isNumeric(val)) { + val = parseFloat(val); + + this.measurement.rotation.z = toRadians(val); + } + }); + + this.elDownloadButton = this.elContent.find(`#download_volume_${this.id}`); + + if (viewer.server) { + this.elDownloadButton.click(() => this.download()); + } else { + this.elDownloadButton.hide(); + } + + let elRemove = this.elContent.find('.measurement_action_remove'); + elRemove.click(() => { this.scene.removeVolume(measurement); }); + + this.measurement.addEventListener('marker_added', this._update); + this.measurement.addEventListener('marker_removed', this._update); + this.measurement.addEventListener('marker_moved', this._update); + + this.elContent.i18n(); + + this.update(); + } + + download () { + let volume = this.measurement; + let boxes = volume.matrixWorld.elements.join(','); + let minLOD = 0; + let maxLOD = 100; + + let pcs = []; + for (let pointcloud of this.scene.pointclouds) { + let urlIsAbsolute = new RegExp('^(?:[a-z]+:)?//', 'i').test(pointcloud.pcoGeometry.url); + let pc = ''; + if (urlIsAbsolute) { + pc = pointcloud.pcoGeometry.url; + } else { + pc = `${window.location.href}/../${pointcloud.pcoGeometry.url}`; + } + + pcs.push(pc); + } + + let pc = pcs + .map(v => `pointcloud[]=${v}`) + .join('&'); + + let request = `${viewer.server}/start_extract_region_worker?minLOD=${minLOD}&maxLOD=${maxLOD}&box=${boxes}&${pc}`;// &pointCloud=${pc}`; + // console.log(request); + + let elMessage = this.elContent.find(`#download_volume_status_${this.id}`); + elMessage.html('sending request...'); + + let workerID = null; + + let start = new Date().getTime(); + + let observe = () => { + let request = `${viewer.server}/observe_status?workerID=${workerID}`; + + let loaded = 0; + + let xhr = new XMLHttpRequest(); + xhr.withCredentials = true; + xhr.addEventListener('progress', e => { + let nowLoaded = e.loaded; + + let response = xhr.responseText.substring(loaded, nowLoaded); + response = JSON.parse(response); + + if (response.status === 'FINISHED') { + elMessage.html(`
    Download ready`); + } else { + let current = new Date().getTime(); + let duration = (current - start); + let seconds = parseInt(duration / 1000); + + elMessage.html(`processing request... ${seconds}s`); + } + + loaded = nowLoaded; + }); + xhr.open('GET', request, true); + xhr.send(null); + }; + + let xhr = new XMLHttpRequest(); + xhr.withCredentials = true; + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + // alert(xhr.responseText); + let res = JSON.parse(xhr.responseText); + console.log(res); + + if (res.status === 'OK') { + workerID = res.workerID; + elMessage.html('request is being processed'); + // checkUntilFinished(); + observe(); + } else if (res.status === 'ERROR_POINT_PROCESSED_ESTIMATE_TOO_LARGE') { + elMessage.html('Too many candidate points in selection.'); + } else { + elMessage.html(`${res.status}`); + } + } + }; + xhr.open('GET', request, true); + xhr.send(null); + } + + update () { + if (!this.destroyed) { + requestAnimationFrame(this._update); + } + + if (!this.elContent.is(':visible')) { + return; + } + + if (this.measurement.position.x !== this.values.x) { + this.elX.val(this.measurement.position.x.toFixed(3)); + this.values.x = this.measurement.position.x; + } + + if (this.measurement.position.y !== this.values.y) { + let elY = this.elContent.find(`#volume_input_y_${this.measurement.id}`); + elY.val(this.measurement.position.y.toFixed(3)); + this.values.y = this.measurement.position.y; + } + + if (this.measurement.position.z !== this.values.z) { + let elZ = this.elContent.find(`#volume_input_z_${this.measurement.id}`); + elZ.val(this.measurement.position.z.toFixed(3)); + this.values.z = this.measurement.position.z; + } + + if (this.measurement.scale.x !== this.values.length) { + this.elLength.val(this.measurement.scale.x.toFixed(3)); + this.values.length = this.measurement.scale.x; + } + + if (this.measurement.scale.y !== this.values.width) { + this.elWidth.val(this.measurement.scale.y.toFixed(3)); + this.values.width = this.measurement.scale.y; + } + + if (this.measurement.scale.z !== this.values.height) { + this.elHeight.val(this.measurement.scale.z.toFixed(3)); + this.values.height = this.measurement.scale.z; + } + + let toDegrees = (r) => 180 * r / Math.PI; + + if (this.measurement.rotation.x !== this.values.alpha) { + this.elAlpha.val(toDegrees(this.measurement.rotation.x).toFixed(1)); + this.values.alpha = this.measurement.rotation.x; + } + + if (this.measurement.rotation.y !== this.values.beta) { + this.elBeta.val(toDegrees(this.measurement.rotation.y).toFixed(1)); + this.values.beta = this.measurement.rotation.y; + } + + if (this.measurement.rotation.z !== this.values.gamma) { + this.elGamma.val(toDegrees(this.measurement.rotation.z).toFixed(1)); + this.values.gamma = this.measurement.rotation.z; + } + } + + destroy () { + this.elPanel.remove(); + + this.measurement.removeEventListener('marker_added', this._update); + this.measurement.removeEventListener('marker_removed', this._update); + this.measurement.removeEventListener('marker_moved', this._update); + + this.destroyed = true; + } + }; + + let TYPE = { + DISTANCE: {panel: DistancePanel}, + AREA: {panel: AreaPanel}, + POINT: {panel: PointPanel}, + ANGLE: {panel: AnglePanel}, + HEIGHT: {panel: HeightPanel}, + PROFILE: {panel: ProfilePanel}, + VOLUME: {panel: VolumePanel} + }; + + let getType = (measurement) => { + if (measurement instanceof Potree.Measure) { + if (measurement.showDistances && !measurement.showArea && !measurement.showAngles) { + return TYPE.DISTANCE; + } else if (measurement.showDistances && measurement.showArea && !measurement.showAngles) { + return TYPE.AREA; + } else if (measurement.maxMarkers === 1) { + return TYPE.POINT; + } else if (!measurement.showDistances && !measurement.showArea && measurement.showAngles) { + return TYPE.ANGLE; + } else if (measurement.showHeight) { + return TYPE.HEIGHT; + } else { + return TYPE.OTHER; + } + } else if (measurement instanceof Potree.Profile) { + return TYPE.PROFILE; + } else if (measurement instanceof Potree.Volume) { + return TYPE.VOLUME; + } + }; + + let trackMeasurement = (scene, measurement) => { + // TODO: Dead code? + // id++; + + let type = getType(measurement); + + const Panel = type.panel; + + let panel = new Panel(scene, measurement); + mlist.append(panel.elPanel); + + let track = { + scene: scene, + measurement: measurement, + panel: panel, + stopTracking: (e) => { panel.destroy(); } + }; + trackedItems.set(measurement, track); + + let onremove = (e) => { + let remove = () => { + panel.destroy(); + scene.removeEventListener('measurement_removed', onremove); + scene.removeEventListener('profile_removed', onremove); + scene.removeEventListener('volume_removed', onremove); + }; + + if (e.measurement instanceof Potree.Measure && e.measurement === measurement) { + remove(); + } else if (e.profile instanceof Potree.Profile && e.profile === measurement) { + remove(); + } else if (e.volume instanceof Potree.Volume && e.volume === measurement) { + remove(); + } + }; + + scene.addEventListener('measurement_removed', onremove); + scene.addEventListener('profile_removed', onremove); + scene.addEventListener('volume_removed', onremove); + }; + + let scenelistener = (e) => { + if (e.measurement) { + trackMeasurement(e.scene, e.measurement); + } else if (e.profile) { + trackMeasurement(e.scene, e.profile); + + viewer.profileWindow.show(); + viewer.profileWindowController.setProfile(e.profile); + } else if (e.volume) { + trackMeasurement(e.scene, e.volume); + } + }; + + let trackScene = (scene) => { + // $("#measurement_details").empty(); + + trackedItems.forEach(function (trackedItem, key, map) { + trackedItem.stopTracking(); + }); + + let items = scene.measurements + .concat(scene.profiles) + .concat(scene.volumes); + + for (let measurement of items) { + trackMeasurement(scene, measurement); + } + + if (!scene.hasEventListener('measurement_added', scenelistener)) { + scene.addEventListener('measurement_added', scenelistener); + } + + if (!scene.hasEventListener('profile_added', scenelistener)) { + scene.addEventListener('profile_added', scenelistener); + } + + if (!scene.hasEventListener('volume_added', scenelistener)) { + scene.addEventListener('volume_added', scenelistener); + } + }; + + trackScene(viewer.scene); + + viewer.addEventListener('scene_changed', (e) => { trackScene(e.scene); }); + + { // BOTTOM ACTIONS + let elActionsB = $('#measurement_list_after'); + + { + let icon = Potree.resourcePath + '/icons/file_geojson.svg'; + let elDownload = $(` + + + `); + elActionsB.append(elDownload); + + elDownload.click(function (e) { + let scene = viewer.scene; + let measurements = [scene.measurements, scene.profiles, scene.volumes].reduce((a, v) => a.concat(v)); + + let geojson = Potree.GeoJSONExporter.toString(measurements); + + let url = window.URL.createObjectURL(new Blob([geojson], {type: 'data:application/octet-stream'})); + elDownload.attr('href', url); + }); + } + + { + let icon = Potree.resourcePath + '/icons/file_dxf.svg'; + let elDownload = $(` + + + `); + elActionsB.append(elDownload); + + elDownload.click(function (e) { + let scene = viewer.scene; + let measurements = [scene.measurements, scene.profiles, scene.volumes].reduce((a, v) => a.concat(v)); + + let dxf = Potree.DXFExporter.toString(measurements); + + let url = window.URL.createObjectURL(new Blob([dxf], {type: 'data:application/octet-stream'})); + elDownload.attr('href', url); + }); + } + } + }; + + function initSceneList () { + let scenelist = $('#scene_list'); + + // length units + $('#optLengthUnit').selectmenu({ + style: 'popup', + position: { + my: 'top', + at: 'bottom', + collision: 'flip' }, + change: function (e) { + let selectedValue = $('#optLengthUnit').selectmenu().val(); + viewer.setLengthUnit(selectedValue); + } + }); + $('#optLengthUnit').selectmenu().val(viewer.lengthUnit.code); + $('#optLengthUnit').selectmenu('refresh'); + + let initUIElements = function (i) { + // scene panel in scene list + + let pointcloud = viewer.scene.pointclouds[i]; + let title = pointcloud.name; + let pcMaterial = pointcloud.material; + let checked = pointcloud.visible ? 'checked' : ''; + + let scenePanel = $(` + + +
    +
    + + ${title} +
    + -