itowns 2.35.0 → 2.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CONTRIBUTING.md +30 -17
  2. package/CONTRIBUTORS.md +1 -0
  3. package/changelog.md +146 -0
  4. package/dist/debug.js +1 -1
  5. package/dist/debug.js.LICENSE.txt +1 -1
  6. package/dist/debug.js.map +1 -1
  7. package/dist/itowns.js +1 -1
  8. package/dist/itowns.js.map +1 -1
  9. package/dist/itowns_widgets.js +2 -0
  10. package/dist/itowns_widgets.js.map +1 -0
  11. package/examples/3dtiles_basic.html +2 -2
  12. package/examples/config.json +25 -6
  13. package/examples/css/widgets.css +248 -0
  14. package/examples/geoid_geoidLayer.html +102 -0
  15. package/examples/images/compass.svg +60 -0
  16. package/examples/images/widget-logo.svg +66 -0
  17. package/examples/itowns-potree.html +252 -0
  18. package/examples/js/GUI/GuiTools.js +17 -0
  19. package/examples/js/Scale.js +1 -0
  20. package/examples/js/plugins/CSVnVRTParser.js +0 -1
  21. package/examples/layers/JSONLayers/Administrative.json +1 -1
  22. package/examples/layers/JSONLayers/Cada.json +1 -1
  23. package/examples/layers/JSONLayers/EtatMajor.json +1 -1
  24. package/examples/layers/JSONLayers/IGN_MNT.json +1 -1
  25. package/examples/layers/JSONLayers/IGN_MNT_HIGHRES.json +1 -1
  26. package/examples/layers/JSONLayers/WORLD_DTM.json +1 -1
  27. package/examples/misc_custom_label.html +0 -2
  28. package/examples/plugins_vrt.html +0 -1
  29. package/examples/source_file_from_fetched_data.html +90 -0
  30. package/examples/source_file_from_format.html +85 -0
  31. package/examples/source_file_from_methods.html +87 -0
  32. package/examples/source_file_from_parsed_data.html +104 -0
  33. package/examples/source_file_geojson_raster.html +21 -48
  34. package/examples/source_file_gpx_raster.html +28 -36
  35. package/examples/source_file_kml_raster.html +1 -4
  36. package/examples/source_file_shapefile.html +39 -35
  37. package/examples/source_stream_wfs_25d.html +29 -29
  38. package/examples/source_stream_wfs_3d.html +21 -12
  39. package/examples/source_stream_wfs_raster.html +20 -20
  40. package/examples/view_25d_map.html +28 -0
  41. package/examples/view_immersive.html +13 -14
  42. package/examples/view_multi_25d.html +1 -1
  43. package/examples/widgets_minimap.html +122 -0
  44. package/examples/widgets_navigation.html +119 -0
  45. package/lib/Controls/FirstPersonControls.js +10 -1
  46. package/lib/Controls/GlobeControls.js +26 -11
  47. package/lib/Controls/PlanarControls.js +1 -1
  48. package/lib/Converter/Feature2Mesh.js +1 -0
  49. package/lib/Converter/Feature2Texture.js +2 -2
  50. package/lib/Converter/convertToTile.js +6 -2
  51. package/lib/Core/3DTiles/C3DTBoundingVolume.js +4 -1
  52. package/lib/Core/Deprecated/Undeprecator.js +1 -1
  53. package/lib/Core/Feature.js +42 -42
  54. package/lib/Core/Geographic/Coordinates.js +56 -0
  55. package/lib/Core/Geographic/Crs.js +15 -0
  56. package/lib/Core/Geographic/Extent.js +100 -12
  57. package/lib/Core/Geographic/GeoidGrid.js +143 -0
  58. package/lib/Core/MainLoop.js +1 -1
  59. package/lib/Core/Math/Ellipsoid.js +27 -9
  60. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +1 -1
  61. package/lib/Core/Prefab/Globe/SkyShader.js +3 -1
  62. package/lib/Core/Prefab/Planar/PlanarLayer.js +3 -1
  63. package/lib/Core/Prefab/PlanarView.js +1 -1
  64. package/lib/Core/Style.js +2 -1
  65. package/lib/Core/TileGeometry.js +3 -1
  66. package/lib/Core/TileMesh.js +11 -16
  67. package/lib/Core/View.js +43 -5
  68. package/lib/Layer/ElevationLayer.js +15 -18
  69. package/lib/Layer/FeatureGeometryLayer.js +3 -1
  70. package/lib/Layer/GeoidLayer.js +131 -0
  71. package/lib/Layer/InfoLayer.js +1 -1
  72. package/lib/Layer/LabelLayer.js +7 -1
  73. package/lib/Layer/Layer.js +1 -1
  74. package/lib/Layer/LayerUpdateStrategy.js +1 -1
  75. package/lib/Layer/PotreeLayer.js +3 -1
  76. package/lib/Layer/TiledGeometryLayer.js +3 -1
  77. package/lib/Main.js +214 -174
  78. package/lib/MainBundle.js +1 -1
  79. package/lib/Parser/B3dmParser.js +2 -1
  80. package/lib/Parser/GDFParser.js +118 -0
  81. package/lib/Parser/GTXParser.js +92 -0
  82. package/lib/Parser/ISGParser.js +121 -0
  83. package/lib/Parser/LASParser.js +3 -1
  84. package/lib/Parser/ShapefileParser.js +0 -1
  85. package/lib/Parser/VectorTileParser.js +1 -1
  86. package/lib/Parser/XbilParser.js +1 -1
  87. package/lib/Process/3dTilesProcessing.js +10 -10
  88. package/lib/Process/FeatureProcessing.js +3 -1
  89. package/lib/Process/LayeredMaterialNodeProcessing.js +7 -4
  90. package/lib/Process/ObjectRemovalHelper.js +5 -2
  91. package/lib/Provider/URLBuilder.js +1 -1
  92. package/lib/Renderer/Label2DRenderer.js +14 -11
  93. package/lib/Renderer/LayeredMaterial.js +4 -3
  94. package/lib/Renderer/OBB.js +20 -27
  95. package/lib/Renderer/PointsMaterial.js +5 -6
  96. package/lib/Renderer/RasterTile.js +23 -5
  97. package/lib/Renderer/Shader/ShaderChunk.js +3 -3
  98. package/lib/Renderer/Shader/ShaderUtils.js +4 -2
  99. package/lib/Source/C3DTilesSource.js +3 -1
  100. package/lib/Source/EntwinePointTileSource.js +3 -1
  101. package/lib/Source/FileSource.js +2 -7
  102. package/lib/Source/PotreeSource.js +3 -1
  103. package/lib/Source/Source.js +15 -10
  104. package/lib/Source/VectorTilesSource.js +19 -0
  105. package/lib/Source/WMTSSource.js +3 -1
  106. package/lib/ThreeExtended/loaders/GLTFLoader.js +239 -98
  107. package/lib/Utils/CameraUtils.js +12 -2
  108. package/lib/Utils/DEMUtils.js +3 -3
  109. package/lib/Utils/FeaturesUtils.js +8 -4
  110. package/package.json +25 -25
package/lib/MainBundle.js CHANGED
@@ -11,13 +11,13 @@ var _exportNames = {
11
11
  THREE: true,
12
12
  proj4: true
13
13
  };
14
+ exports.THREE = void 0;
14
15
  Object.defineProperty(exports, "proj4", {
15
16
  enumerable: true,
16
17
  get: function get() {
17
18
  return _proj["default"];
18
19
  }
19
20
  });
20
- exports.THREE = void 0;
21
21
 
22
22
  var THREE = _interopRequireWildcard(require("three"));
23
23
 
@@ -7,8 +7,9 @@ var _typeof3 = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
+ exports["default"] = void 0;
10
11
  exports.enableDracoLoader = enableDracoLoader;
11
- exports["default"] = exports.legacyGLTFLoader = exports.glTFLoader = void 0;
12
+ exports.legacyGLTFLoader = exports.glTFLoader = void 0;
12
13
 
13
14
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
14
15
 
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+ exports.getHeaderAttribute = getHeaderAttribute;
12
+
13
+ var THREE = _interopRequireWildcard(require("three"));
14
+
15
+ var _GeoidGrid = _interopRequireDefault(require("../Core/Geographic/GeoidGrid"));
16
+
17
+ var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
18
+
19
+ var _GTXParser = require("./GTXParser");
20
+
21
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
+
23
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
+
25
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
26
+
27
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
+
29
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
30
+
31
+ function getHeaderAttribute(header, attributeName) {
32
+ var attributeRow = header[header.indexOf(header.find(function (element) {
33
+ return element.includes(attributeName);
34
+ }))].split(' ').filter(function (value) {
35
+ return value !== '';
36
+ });
37
+ return parseFloat(attributeRow[attributeRow.length - 1]);
38
+ }
39
+ /**
40
+ * The `GDFParser` module provides a `[parse]{@link module:GDFParser.parse}` method. This method takes the content of a
41
+ * GDF file in, and returns a `{@link GeoidGrid}`. the `{@link GeoidGrid}` contains all the necessary attributes and
42
+ * methods to access the GDF data in iTowns.
43
+ *
44
+ * @module GDFParser
45
+ */
46
+
47
+
48
+ var _default = {
49
+ /**
50
+ * Parses a GDF file content and returns a corresponding `{@link GeoidGrid}`.
51
+ *
52
+ * @param {string} gdf The content of the GDF file to parse.
53
+ * @param {Object} options An object gathering the optional parameters to pass to
54
+ * the parser.
55
+ * @param {Object} [options.in={}] Information on the GDF data.
56
+ * @param {string} [options.in.crs='EPSG:4326'] The Coordinates Reference System (CRS) of the GDF data.
57
+ * It must be a geographic CRS, and must be given as an EPSG
58
+ * code.
59
+ *
60
+ * @returns {Promise<GeoidGrid>} A promise resolving with a `{@link GeoidGrid}`, which contains all the necessary
61
+ * attributes and methods to access GDF file data.
62
+ */
63
+ parse: function parse(gdf) {
64
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
65
+ "in": {}
66
+ };
67
+ var rows = gdf.split('\n');
68
+ var firstMeasureLine = rows.indexOf(rows.find(function (row) {
69
+ return row.includes('end_of_head');
70
+ })) + 1;
71
+ var rawHeaderData = rows.slice(0, firstMeasureLine); // ---------- GET METADATA FROM THE FILE : ----------
72
+
73
+ var metadata = {
74
+ minX: getHeaderAttribute(rawHeaderData, 'longlimit_west'),
75
+ maxX: getHeaderAttribute(rawHeaderData, 'longlimit_east'),
76
+ minY: getHeaderAttribute(rawHeaderData, 'latlimit_south'),
77
+ maxY: getHeaderAttribute(rawHeaderData, 'latlimit_north'),
78
+ stepX: getHeaderAttribute(rawHeaderData, 'gridstep'),
79
+ stepY: getHeaderAttribute(rawHeaderData, 'gridstep'),
80
+ nRows: getHeaderAttribute(rawHeaderData, 'latitude_parallels'),
81
+ nColumns: getHeaderAttribute(rawHeaderData, 'longitude_parallels')
82
+ }; // ---------- BUILD A DATA VIEWER FROM THE TEXT DATA : ----------
83
+
84
+ var data = new DataView(new ArrayBuffer(_GTXParser.BYTES_PER_DOUBLE * metadata.nRows * metadata.nColumns));
85
+ var index = 0;
86
+
87
+ var _iterator = _createForOfIteratorHelper(rows.slice(firstMeasureLine, rows.length)),
88
+ _step;
89
+
90
+ try {
91
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
92
+ var row = _step.value;
93
+ row = row.split(' ').filter(function (value) {
94
+ return value !== '';
95
+ });
96
+
97
+ if (!row.length) {
98
+ continue;
99
+ }
100
+
101
+ data.setFloat64(index * _GTXParser.BYTES_PER_DOUBLE, parseFloat(row[2]));
102
+ index++;
103
+ } // ---------- CREATE A GeoidGrid FOR THE GIVEN FILE DATA : ----------
104
+
105
+ } catch (err) {
106
+ _iterator.e(err);
107
+ } finally {
108
+ _iterator.f();
109
+ }
110
+
111
+ var dataExtent = new _Extent["default"](options["in"].crs || 'EPSG:4326', metadata.minX, metadata.maxX, metadata.minY, metadata.maxY);
112
+ var dataStep = new THREE.Vector2(metadata.stepX, metadata.stepY);
113
+ return Promise.resolve(new _GeoidGrid["default"](dataExtent, dataStep, function getData(verticalIndex, horizontalIndex) {
114
+ return data.getFloat64((metadata.nColumns * (metadata.nRows - verticalIndex - 1) + horizontalIndex) * _GTXParser.BYTES_PER_DOUBLE);
115
+ }));
116
+ }
117
+ };
118
+ exports["default"] = _default;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = exports.BYTES_PER_FLOAT = exports.BYTES_PER_DOUBLE = void 0;
11
+
12
+ var THREE = _interopRequireWildcard(require("three"));
13
+
14
+ var _GeoidGrid = _interopRequireDefault(require("../Core/Geographic/GeoidGrid"));
15
+
16
+ var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ var BYTES_PER_DOUBLE = 8;
23
+ exports.BYTES_PER_DOUBLE = BYTES_PER_DOUBLE;
24
+ var BYTES_PER_FLOAT = 4;
25
+ /**
26
+ * The `GTXParser` module provides a `[parse]{@link module:GTXParser.parse}` method. This method takes the content of a
27
+ * GTX file in, and returns a `{@link GeoidGrid}`. The `{@link GeoidGrid}` contains all the necessary attributes and
28
+ * methods to access the GTX data in iTowns.
29
+ *
30
+ * @module GTXParser
31
+ */
32
+
33
+ exports.BYTES_PER_FLOAT = BYTES_PER_FLOAT;
34
+ var _default = {
35
+ /**
36
+ * Parses a GTX file content and returns a corresponding `{@link GeoidGrid}`.
37
+ *
38
+ * @param {ArrayBuffer} gtx The content of the GTX file to parse.
39
+ * @param {Object} options An object gathering the optional parameters to pass to
40
+ * the parser.
41
+ * @param {Object} [options.in={}] Information on the GTX data.
42
+ * @param {string} [options.in.crs='EPSG:4326'] The Coordinates Reference System (CRS) of the GTX data.
43
+ * It must be a geographic CRS, and must be given as an
44
+ * EPSG code.
45
+ * @param {string} [options.in.dataType='float'] The encoding of geoid height data within the GTX file.
46
+ * Must be `'float'` or `'double'`.
47
+ *
48
+ * @returns {Promise<GeoidGrid>} A promise resolving with a `{@link GeoidGrid}`, which contains all the necessary
49
+ * attributes and methods to access GTX file data.
50
+ */
51
+ parse: function parse(gtx) {
52
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
53
+ "in": {}
54
+ };
55
+ var dataType = options["in"].dataType || 'float';
56
+
57
+ if (!['float', 'double'].includes(dataType)) {
58
+ throw new Error('`dataType` parameter is incorrect for GTXParser.parse method. ' + 'This parameter must be either `double` or `float`.');
59
+ } // ---------- GET METADATA FROM THE FILE : ----------
60
+
61
+
62
+ var headerView = new DataView(gtx, 0, 40);
63
+ var metadata = {
64
+ minX: headerView.getFloat64(8),
65
+ minY: headerView.getFloat64(0),
66
+ stepX: headerView.getFloat64(24),
67
+ stepY: headerView.getFloat64(16),
68
+ nColumns: headerView.getInt32(36),
69
+ nRows: headerView.getInt32(32)
70
+ }; // ---------- BUILD A DATA VIEWER : ----------
71
+
72
+ var dataView = new DataView(gtx, 40); // ---------- CREATE A GeoidGrid FOR THE GIVEN FILE DATA : ----------
73
+ // formula for the max longitude : maxLongitude = minLongitude + deltaLongitude * (nColumns - 1)
74
+
75
+ var maxX = metadata.minX + metadata.stepX * (metadata.nColumns - 1); // formula for the max latitude : maxLatitude = minLatitude + deltaLatitude * (nRows - 1)
76
+
77
+ var maxY = metadata.minY + metadata.stepY * (metadata.nRows - 1);
78
+ var dataExtent = new _Extent["default"](options["in"].crs || 'EPSG:4326', metadata.minX, maxX, metadata.minY, maxY);
79
+ var dataStep = new THREE.Vector2(metadata.stepX, metadata.stepY);
80
+ return Promise.resolve(new _GeoidGrid["default"](dataExtent, dataStep, function getData(verticalIndex, horizontalIndex) {
81
+ // formula to get the index of a geoid height from a latitude and longitude indexes is :
82
+ // ``(nColumns * latIndex + lonIndex) * nBytes``, where nBytes stands for the number of bytes geoid
83
+ // height data are encoded on.
84
+ if (dataType === 'float') {
85
+ return dataView.getFloat32((metadata.nColumns * verticalIndex + horizontalIndex) * BYTES_PER_FLOAT);
86
+ } else if (dataType === 'double') {
87
+ return dataView.getFloat64((metadata.nColumns * verticalIndex + horizontalIndex) * BYTES_PER_DOUBLE);
88
+ }
89
+ }));
90
+ }
91
+ };
92
+ exports["default"] = _default;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ var THREE = _interopRequireWildcard(require("three"));
13
+
14
+ var _GeoidGrid = _interopRequireDefault(require("../Core/Geographic/GeoidGrid"));
15
+
16
+ var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
17
+
18
+ var _GDFParser = require("./GDFParser");
19
+
20
+ var _GTXParser = require("./GTXParser");
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
27
+
28
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
29
+
30
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
31
+
32
+ /**
33
+ * The `ISGParser` module provides a `[parse]{@link module:ISGParser.parse}` method. This method takes the content of a
34
+ * ISG file in, and returns a `{@link GeoidGrid}`. the `{@link GeoidGrid}` contains all the necessary attributes and
35
+ * methods to access the ISG data in iTowns.
36
+ *
37
+ * @module ISGParser
38
+ */
39
+ var _default = {
40
+ /**
41
+ * Parses an ISG file content and returns a corresponding `{@link GeoidGrid}`.
42
+ *
43
+ * @param {string} isg The content of the ISG file to parse.
44
+ * @param {Object} options An object gathering the optional parameters to pass to
45
+ * the parser.
46
+ * @param {Object} [options.in={}] Information on the ISG data.
47
+ * @param {string} [options.in.crs='EPSG:4326'] The Coordinates Reference System (CRS) of the ISG data.
48
+ * It must be a geographic CRS, and must be given as an EPSG
49
+ * code.
50
+ *
51
+ * @returns {Promise<GeoidGrid>} A promise resolving with a `{@link GeoidGrid}`, which contains all the necessary
52
+ * attributes and methods to access ISG file data.
53
+ */
54
+ parse: function parse(isg) {
55
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
56
+ "in": {}
57
+ };
58
+ var rows = isg.split('\n');
59
+ var firstMeasureLine = rows.indexOf(rows.find(function (row) {
60
+ return row.includes('end_of_head');
61
+ })) + 1;
62
+ var rawHeaderData = rows.slice(0, firstMeasureLine); // ---------- GET METADATA FROM THE FILE : ----------
63
+
64
+ var metadata = {
65
+ minX: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'lon min'),
66
+ maxX: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'lon max'),
67
+ minY: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'lat min'),
68
+ maxY: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'lat max'),
69
+ stepX: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'delta lon'),
70
+ stepY: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'delta lat'),
71
+ nRows: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'nrows'),
72
+ nColumns: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'ncols')
73
+ }; // ---------- BUILD A DATA VIEWER FROM THE TEXT DATA : ----------
74
+
75
+ var data = new DataView(new ArrayBuffer(_GTXParser.BYTES_PER_DOUBLE * metadata.nRows * metadata.nColumns));
76
+ var index = 0;
77
+
78
+ var _iterator = _createForOfIteratorHelper(rows.slice(firstMeasureLine, rows.length)),
79
+ _step;
80
+
81
+ try {
82
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
83
+ var row = _step.value;
84
+ row = row.split(' ').filter(function (value) {
85
+ return value !== '';
86
+ });
87
+
88
+ if (!row.length) {
89
+ continue;
90
+ }
91
+
92
+ var _iterator2 = _createForOfIteratorHelper(row),
93
+ _step2;
94
+
95
+ try {
96
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
97
+ var value = _step2.value;
98
+ data.setFloat64(index * _GTXParser.BYTES_PER_DOUBLE, parseFloat(value));
99
+ index++;
100
+ }
101
+ } catch (err) {
102
+ _iterator2.e(err);
103
+ } finally {
104
+ _iterator2.f();
105
+ }
106
+ } // ---------- CREATE A GeoidGrid FOR THE GIVEN FILE DATA : ----------
107
+
108
+ } catch (err) {
109
+ _iterator.e(err);
110
+ } finally {
111
+ _iterator.f();
112
+ }
113
+
114
+ var dataExtent = new _Extent["default"](options["in"].crs || 'EPSG:4326', metadata.minX + metadata.stepX / 2, metadata.maxX - metadata.stepX / 2, metadata.minY + metadata.stepY / 2, metadata.maxY - metadata.stepY / 2);
115
+ var dataStep = new THREE.Vector2(metadata.stepX, metadata.stepY);
116
+ return Promise.resolve(new _GeoidGrid["default"](dataExtent, dataStep, function getData(verticalIndex, horizontalIndex) {
117
+ return data.getFloat64((metadata.nColumns * verticalIndex + horizontalIndex) * _GTXParser.BYTES_PER_DOUBLE);
118
+ }));
119
+ }
120
+ };
121
+ exports["default"] = _default;
@@ -56,7 +56,9 @@ var _default = {
56
56
  }
57
57
  }).then(function (parsedData) {
58
58
  var geometry = new THREE.BufferGeometry();
59
- geometry.userData = parsedData.loaderData.header;
59
+ geometry.userData = parsedData.loaderData;
60
+ geometry.userData.vertexCount = parsedData.header.vertexCount;
61
+ geometry.userData.boundingBox = parsedData.header.boundingBox;
60
62
  var positionBuffer = new THREE.BufferAttribute(parsedData.attributes.POSITION.value, 3, false);
61
63
  geometry.setAttribute('position', positionBuffer);
62
64
  var intensityBuffer = new THREE.BufferAttribute(parsedData.attributes.intensity.value, 1, true);
@@ -44,7 +44,6 @@ var _Undeprecator = require("../Core/Deprecated/Undeprecator");
44
44
  * },
45
45
  * out: {
46
46
  * crs: view.tileLayer.extent.crs,
47
- * buildExtent: true,
48
47
  * }
49
48
  * });
50
49
  * }).then(function _(geojson) {
@@ -25,7 +25,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
25
25
 
26
26
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
27
27
 
28
- var worldDimension3857 = _Extent.globalExtentTMS.get('EPSG:3857').dimensions();
28
+ var worldDimension3857 = _Extent.globalExtentTMS.get('EPSG:3857').planarDimensions();
29
29
 
30
30
  var globalExtent = new _three.Vector3(worldDimension3857.x, worldDimension3857.y, 1);
31
31
  var lastPoint = new _three.Vector2();
@@ -5,8 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.computeMinMaxElevation = computeMinMaxElevation;
9
8
  exports.checkNodeElevationTextureValidity = checkNodeElevationTextureValidity;
9
+ exports.computeMinMaxElevation = computeMinMaxElevation;
10
10
  exports.insertSignificantValuesFromParent = insertSignificantValuesFromParent;
11
11
 
12
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
@@ -8,11 +8,11 @@ Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
  exports.$3dTilesCulling = $3dTilesCulling;
11
- exports.pre3dTilesUpdate = pre3dTilesUpdate;
11
+ exports.$3dTilesSubdivisionControl = $3dTilesSubdivisionControl;
12
12
  exports.computeNodeSSE = computeNodeSSE;
13
13
  exports.init3dTilesLayer = init3dTilesLayer;
14
+ exports.pre3dTilesUpdate = pre3dTilesUpdate;
14
15
  exports.process3dTilesNode = process3dTilesNode;
15
- exports.$3dTilesSubdivisionControl = $3dTilesSubdivisionControl;
16
16
 
17
17
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
18
18
 
@@ -80,12 +80,10 @@ function boundingVolumeToExtent(crs, volume, transform) {
80
80
  return _Extent["default"].fromBox3(crs, _box);
81
81
  } else {
82
82
  var sphere = tmpSphere.copy(volume.sphere).applyMatrix4(transform);
83
- return new _Extent["default"](crs, {
84
- west: sphere.center.x - sphere.radius,
85
- east: sphere.center.x + sphere.radius,
86
- south: sphere.center.y - sphere.radius,
87
- north: sphere.center.y + sphere.radius
88
- });
83
+
84
+ var _box2 = sphere.getBoundingBox(tmpBox3);
85
+
86
+ return _Extent["default"].fromBox3(crs, _box2);
89
87
  }
90
88
  }
91
89
 
@@ -120,7 +118,8 @@ function _subdivideNodeAdditive(context, layer, node, cullingTest) {
120
118
 
121
119
  child.promise = requestNewTile(context.view, context.scheduler, layer, child, node, true).then(function (tile) {
122
120
  node.add(tile);
123
- tile.updateMatrixWorld();
121
+ tile.updateMatrixWorld(); // The extent is calculated but it's never used in 3D tiles process
122
+
124
123
  var extent = boundingVolumeToExtent(layer.extent.crs, tile.boundingVolume, tile.matrixWorld);
125
124
  tile.traverse(function (obj) {
126
125
  obj.extent = extent;
@@ -379,7 +378,8 @@ function init3dTilesLayer(view, scheduler, layer, rootTile) {
379
378
  layer.object3d.add(tile);
380
379
  tile.updateMatrixWorld();
381
380
  layer.tileset.tiles[tile.tileId].loaded = true;
382
- layer.root = tile;
381
+ layer.root = tile; // The extent is calculated but it's never used in 3D tiles process
382
+
383
383
  layer.extent = boundingVolumeToExtent(layer.crs || view.referenceCrs, tile.boundingVolume, tile.matrixWorld);
384
384
  layer.onTileContentLoaded(tile);
385
385
  });
@@ -94,7 +94,8 @@ var _default = {
94
94
  var zoomDest = extentsDestination[0].zoom; // check if it's tile level is equal to display level layer.
95
95
 
96
96
  if (zoomDest != layer.zoom.min || // check if there's data in extent tile.
97
- !this.source.extentInsideLimit(node.extent, zoomDest) || layer.source.isFileSource && !node.extent.isPointInside(layer.source.extent.center(coord))) {
97
+ !this.source.extentInsideLimit(node.extent, zoomDest) || // In FileSource case, check if the feature center is in extent tile.
98
+ layer.source.isFileSource && !node.extent.isPointInside(layer.source.extent.center(coord))) {
98
99
  // if not, there's not data to add at this tile.
99
100
  node.layerUpdateState[layer.id].noMoreUpdatePossible();
100
101
  return;
@@ -135,6 +136,7 @@ var _default = {
135
136
  group.layer = layer;
136
137
  group.matrixWorld.copy(node.matrixWorld).invert();
137
138
  group.matrixWorld.decompose(group.position, group.quaternion, group.scale);
139
+ group.position.z += node.geoidHeight;
138
140
  node.add(group.add(result));
139
141
  group.updateMatrixWorld(true);
140
142
  } else {
@@ -5,10 +5,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.updateLayeredMaterialNodeImagery = updateLayeredMaterialNodeImagery;
9
- exports.updateLayeredMaterialNodeElevation = updateLayeredMaterialNodeElevation;
8
+ exports.SIZE_TEXTURE_TILE = exports.SIZE_DIAGONAL_TEXTURE = void 0;
10
9
  exports.removeLayeredMaterialNodeLayer = removeLayeredMaterialNodeLayer;
11
- exports.SIZE_DIAGONAL_TEXTURE = exports.SIZE_TEXTURE_TILE = void 0;
10
+ exports.updateLayeredMaterialNodeElevation = updateLayeredMaterialNodeElevation;
11
+ exports.updateLayeredMaterialNodeImagery = updateLayeredMaterialNodeImagery;
12
12
 
13
13
  var _LayerUpdateStrategy = require("../Layer/LayerUpdateStrategy");
14
14
 
@@ -263,7 +263,10 @@ function removeLayeredMaterialNodeLayer(layerId) {
263
263
  node.material.removeLayer(layerId);
264
264
 
265
265
  if (node.material.elevationLayerIds[0] == layerId) {
266
- node.setBBoxZ(0, 0);
266
+ node.setBBoxZ({
267
+ min: 0,
268
+ max: 0
269
+ });
267
270
  }
268
271
  }
269
272
 
@@ -51,9 +51,12 @@ var _default = {
51
51
  }
52
52
  } else {
53
53
  obj.material.dispose();
54
- } // obj.material = null;
55
-
54
+ }
56
55
  }
56
+
57
+ obj.dispatchEvent({
58
+ type: 'dispose'
59
+ });
57
60
  }
58
61
  },
59
62
 
@@ -98,7 +98,7 @@ var _default = {
98
98
  *
99
99
  * @return {string} the formed url
100
100
  */
101
- bbox: function bbox(bbox, source) {
101
+ bbox: function (bbox, source) {
102
102
  var precision = source.crs == 'EPSG:4326' ? 9 : 2;
103
103
  bbox.as(source.crs, extent);
104
104
  var w = extent.west.toFixed(precision);
@@ -31,8 +31,9 @@ function hasLabelChildren(object) {
31
31
  return cc.isLabel;
32
32
  });
33
33
  });
34
- } // A grid to manage labels on the screen.
34
+ }
35
35
 
36
+ var frustum = new THREE.Frustum(); // A grid to manage labels on the screen.
36
37
 
37
38
  var ScreenGrid = /*#__PURE__*/function () {
38
39
  function ScreenGrid() {
@@ -119,8 +120,7 @@ var ScreenGrid = /*#__PURE__*/function () {
119
120
  return ScreenGrid;
120
121
  }();
121
122
 
122
- var viewProjectionMatrix = new THREE.Matrix4();
123
- var vector = new THREE.Vector3();
123
+ var worldPosition = new THREE.Vector3();
124
124
  /**
125
125
  * This renderer is inspired by the
126
126
  * [`THREE.CSS2DRenderer`](https://threejs.org/docs/#examples/en/renderers/CSS2DRenderer).
@@ -176,9 +176,10 @@ var Label2DRenderer = /*#__PURE__*/function () {
176
176
  return;
177
177
  }
178
178
 
179
- this.grid.reset();
180
- viewProjectionMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
181
- this.culling(scene, this.infoTileLayer.displayed.extent); // sort by order, then by visibility inside those subsets
179
+ this.grid.reset(); // set camera frustum
180
+
181
+ frustum.setFromProjectionMatrix(camera.projectionMatrix);
182
+ this.culling(scene, this.infoTileLayer.displayed.extent, camera); // sort by order, then by visibility inside those subsets
182
183
  // https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-hierarchy
183
184
 
184
185
  this.grid.visible.sort(function (a, b) {
@@ -206,7 +207,7 @@ var Label2DRenderer = /*#__PURE__*/function () {
206
207
  }
207
208
  }, {
208
209
  key: "culling",
209
- value: function culling(object, extent) {
210
+ value: function culling(object, extent, camera) {
210
211
  var _this2 = this;
211
212
 
212
213
  if (!object.isLabel) {
@@ -221,17 +222,19 @@ var Label2DRenderer = /*#__PURE__*/function () {
221
222
 
222
223
  this.showNodeDOM(object);
223
224
  object.children.forEach(function (c) {
224
- return _this2.culling(c, extent);
225
+ return _this2.culling(c, extent, camera);
225
226
  }); // the presence of the label inside the visible extent and if children has label, we can filter more labels.
226
227
  } else if (!extent.isPointInside(object.coordinates) || hasLabelChildren(object)) {
228
+ this.grid.hidden.push(object); // the presence of the label inside frustum camera.
229
+ } else if (!frustum.containsPoint(object.getWorldPosition(worldPosition).applyMatrix4(camera.matrixWorldInverse))) {
227
230
  this.grid.hidden.push(object); // Do some horizon culling (if possible) if the tiles level is small
228
231
  // enough. The chosen value of 4 seems to provide a good result.
229
232
  } else if (object.parent.level < 4 && object.parent.layer.horizonCulling && object.parent.layer.horizonCulling(object.horizonCullingPoint)) {
230
233
  this.grid.hidden.push(object);
231
234
  } else {
232
- vector.setFromMatrixPosition(object.matrixWorld);
233
- vector.applyMatrix4(viewProjectionMatrix);
234
- object.updateProjectedPosition(vector.x * this.halfWidth + this.halfWidth, -vector.y * this.halfHeight + this.halfHeight); // Are considered duplicates, labels that have the same screen
235
+ // projecting world position object
236
+ worldPosition.applyMatrix4(camera.projectionMatrix);
237
+ object.updateProjectedPosition(worldPosition.x * this.halfWidth + this.halfWidth, -worldPosition.y * this.halfHeight + this.halfHeight); // Are considered duplicates, labels that have the same screen
235
238
  // coordinates and the same base content.
236
239
 
237
240
  if (this.grid.visible.some(function (l) {
@@ -7,9 +7,9 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.unpack1K = unpack1K;
10
+ exports["default"] = exports.colorLayerEffects = exports.ELEVATION_MODES = void 0;
11
11
  exports.getMaxColorSamplerUnitsCount = getMaxColorSamplerUnitsCount;
12
- exports["default"] = exports.ELEVATION_MODES = exports.colorLayerEffects = void 0;
12
+ exports.unpack1K = unpack1K;
13
13
 
14
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
15
 
@@ -91,7 +91,8 @@ var defaultStructLayer = {
91
91
  opacity: 0,
92
92
  crs: 0,
93
93
  effect_parameter: 0,
94
- effect_type: colorLayerEffects.noEffect
94
+ effect_type: colorLayerEffects.noEffect,
95
+ transparent: false
95
96
  };
96
97
 
97
98
  function _updateLayersUniforms(uniforms, olayers, max) {