itowns 2.36.2 → 2.38.1

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 (122) hide show
  1. package/CONTRIBUTING.md +30 -17
  2. package/README.md +12 -1
  3. package/changelog.md +138 -0
  4. package/dist/debug.js +1 -1
  5. package/dist/debug.js.LICENSE.txt +2 -2
  6. package/dist/debug.js.map +1 -1
  7. package/dist/itowns.js +1 -1
  8. package/dist/itowns.js.LICENSE.txt +2 -2
  9. package/dist/itowns.js.map +1 -1
  10. package/dist/itowns_widgets.js +2 -0
  11. package/dist/itowns_widgets.js.map +1 -0
  12. package/examples/config.json +28 -6
  13. package/examples/css/example.css +21 -1
  14. package/examples/css/widgets.css +360 -0
  15. package/examples/geoid_geoidLayer.html +102 -0
  16. package/examples/images/code-logo.svg +43 -0
  17. package/examples/index.html +5 -5
  18. package/examples/itowns-potree.html +252 -0
  19. package/examples/js/GUI/GuiTools.js +17 -0
  20. package/examples/mars.html +0 -1
  21. package/examples/misc_orthographic_camera.html +7 -19
  22. package/examples/source_file_from_fetched_data.html +90 -0
  23. package/examples/source_file_from_format.html +85 -0
  24. package/examples/source_file_from_methods.html +87 -0
  25. package/examples/source_file_from_parsed_data.html +104 -0
  26. package/examples/source_file_geojson_raster.html +21 -45
  27. package/examples/source_file_gpx_raster.html +28 -36
  28. package/examples/source_file_kml_raster.html +1 -4
  29. package/examples/source_file_shapefile.html +39 -34
  30. package/examples/source_stream_wfs_25d.html +21 -13
  31. package/examples/source_stream_wfs_3d.html +21 -12
  32. package/examples/source_stream_wfs_raster.html +20 -20
  33. package/examples/vector_tile_3d_mesh.html +155 -0
  34. package/examples/vector_tile_raster_3d.html +0 -5
  35. package/examples/view_25d_map.html +6 -19
  36. package/examples/view_2d_map.html +6 -19
  37. package/examples/view_3d_map.html +106 -81
  38. package/examples/view_immersive.html +13 -14
  39. package/examples/widgets_minimap.html +124 -0
  40. package/examples/widgets_navigation.html +124 -0
  41. package/examples/widgets_scale.html +96 -0
  42. package/examples/widgets_searchbar.html +124 -0
  43. package/lib/Controls/GlobeControls.js +13 -0
  44. package/lib/Controls/PlanarControls.js +11 -43
  45. package/lib/Converter/Feature2Mesh.js +203 -45
  46. package/lib/Converter/convertToTile.js +13 -4
  47. package/lib/Core/3DTiles/C3DTBoundingVolume.js +4 -1
  48. package/lib/Core/Deprecated/Undeprecator.js +1 -1
  49. package/lib/Core/Feature.js +60 -34
  50. package/lib/Core/Geographic/Extent.js +1 -1
  51. package/lib/Core/Geographic/GeoidGrid.js +143 -0
  52. package/lib/Core/MainLoop.js +137 -63
  53. package/lib/Core/Math/Ellipsoid.js +1 -1
  54. package/lib/Core/Prefab/Globe/SkyShader.js +3 -1
  55. package/lib/Core/Prefab/Planar/PlanarLayer.js +3 -1
  56. package/lib/Core/Style.js +1 -1
  57. package/lib/Core/TileGeometry.js +3 -1
  58. package/lib/Core/TileMesh.js +32 -22
  59. package/lib/Core/View.js +81 -15
  60. package/lib/Layer/ElevationLayer.js +6 -2
  61. package/lib/Layer/FeatureGeometryLayer.js +36 -7
  62. package/lib/Layer/GeoidLayer.js +142 -0
  63. package/lib/Layer/GeometryLayer.js +6 -54
  64. package/lib/Layer/InfoLayer.js +1 -1
  65. package/lib/Layer/Layer.js +1 -1
  66. package/lib/Layer/LayerUpdateStrategy.js +1 -1
  67. package/lib/Layer/OrientedImageLayer.js +1 -0
  68. package/lib/Layer/PotreeLayer.js +3 -1
  69. package/lib/Layer/RasterLayer.js +3 -1
  70. package/lib/Layer/ReferencingLayerProperties.js +50 -0
  71. package/lib/Layer/TiledGeometryLayer.js +3 -1
  72. package/lib/Main.js +214 -174
  73. package/lib/MainBundle.js +1 -1
  74. package/lib/Parser/B3dmParser.js +5 -3
  75. package/lib/Parser/GDFParser.js +118 -0
  76. package/lib/Parser/GTXParser.js +92 -0
  77. package/lib/Parser/GeoJsonParser.js +29 -7
  78. package/lib/Parser/ISGParser.js +121 -0
  79. package/lib/Parser/LASParser.js +3 -1
  80. package/lib/Parser/VectorTileParser.js +4 -3
  81. package/lib/Parser/XbilParser.js +1 -1
  82. package/lib/Parser/deprecated/LegacyGLTFLoader.js +1 -1
  83. package/lib/Process/3dTilesProcessing.js +2 -2
  84. package/lib/Process/FeatureProcessing.js +38 -86
  85. package/lib/Process/LayeredMaterialNodeProcessing.js +16 -7
  86. package/lib/Process/ObjectRemovalHelper.js +4 -0
  87. package/lib/Provider/3dTilesProvider.js +2 -7
  88. package/lib/Provider/Fetcher.js +4 -1
  89. package/lib/Provider/TileProvider.js +18 -2
  90. package/lib/Provider/URLBuilder.js +1 -1
  91. package/lib/Renderer/Camera.js +33 -12
  92. package/lib/Renderer/ColorLayersOrdering.js +3 -1
  93. package/lib/Renderer/LayeredMaterial.js +34 -9
  94. package/lib/Renderer/OBB.js +22 -25
  95. package/lib/Renderer/OrientedImageMaterial.js +8 -5
  96. package/lib/Renderer/PointsMaterial.js +6 -6
  97. package/lib/Renderer/RasterTile.js +1 -1
  98. package/lib/Renderer/RenderMode.js +3 -1
  99. package/lib/Renderer/Shader/ShaderChunk.js +5 -1
  100. package/lib/Renderer/Shader/ShaderUtils.js +4 -2
  101. package/lib/Renderer/c3DEngine.js +9 -6
  102. package/lib/Source/C3DTilesSource.js +3 -1
  103. package/lib/Source/EntwinePointTileSource.js +3 -1
  104. package/lib/Source/FileSource.js +8 -1
  105. package/lib/Source/PotreeSource.js +3 -1
  106. package/lib/Source/Source.js +15 -10
  107. package/lib/Source/VectorTilesSource.js +5 -0
  108. package/lib/Source/WFSSource.js +9 -3
  109. package/lib/Source/WMTSSource.js +3 -1
  110. package/lib/ThreeExtended/{WebGL.js → capabilities/WebGL.js} +8 -7
  111. package/lib/ThreeExtended/loaders/GLTFLoader.js +88 -39
  112. package/lib/Utils/CameraUtils.js +11 -1
  113. package/lib/Utils/DEMUtils.js +4 -2
  114. package/lib/Utils/FeaturesUtils.js +8 -4
  115. package/lib/Utils/gui/Main.js +39 -0
  116. package/lib/Utils/gui/Minimap.js +197 -0
  117. package/lib/Utils/gui/Navigation.js +322 -0
  118. package/lib/Utils/gui/Scale.js +154 -0
  119. package/lib/Utils/gui/Searchbar.js +299 -0
  120. package/lib/Utils/gui/Widget.js +119 -0
  121. package/package.json +32 -27
  122. package/examples/js/Scale.js +0 -40
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
23
+
24
+ var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
25
+
26
+ var _Fetcher = _interopRequireDefault(require("../../Provider/Fetcher"));
27
+
28
+ var _Widget2 = _interopRequireDefault(require("./Widget"));
29
+
30
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
31
+
32
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
+
34
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
35
+
36
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
37
+
38
+ var DEFAULT_OPTIONS = {
39
+ width: 300,
40
+ height: 38,
41
+ position: 'top',
42
+ maxSuggestionNumber: 10,
43
+ fontSize: 16,
44
+ placeholder: 'Search location'
45
+ };
46
+
47
+ function addActive(htmlElements, index) {
48
+ var _htmlElements$index;
49
+
50
+ if (!htmlElements) {
51
+ return index;
52
+ }
53
+
54
+ removeAllActives(htmlElements);
55
+
56
+ if (index >= htmlElements.length) {
57
+ index = 0;
58
+ } else if (index < 0) {
59
+ index = htmlElements.length - 1;
60
+ }
61
+
62
+ (_htmlElements$index = htmlElements[index]) === null || _htmlElements$index === void 0 ? void 0 : _htmlElements$index.classList.add('active');
63
+ return index;
64
+ }
65
+
66
+ function removeAllActives(htmlElements) {
67
+ for (var i = 0; i < htmlElements.length; i++) {
68
+ htmlElements[i].classList.remove('active');
69
+ }
70
+ }
71
+
72
+ function eraseSuggestionList(form) {
73
+ while (form.children.length > 1) {
74
+ form.removeChild(form.lastChild);
75
+ }
76
+ }
77
+ /**
78
+ * A widget for searchbar
79
+ *
80
+ * To use it, you need to link the widgets' stylesheet to your html webpage. This stylesheet is included in
81
+ * [itowns bundles](https://github.com/iTowns/itowns/releases) if you downloaded them, or it can be found in
82
+ * `node_modules/itowns/examples/css` if you installed iTowns with npm. Otherwise, it can be found at
83
+ * [this link](https://raw.githubusercontent.com/iTowns/itowns/master/examples/css/widgets.css). See
84
+ * [this example](http://www.itowns-project.org/itowns/examples/#widgets_searchbar) for more details.
85
+ *
86
+ * @extends Widget
87
+ *
88
+ * @property {HTMLElement} domElement An html div containing the searchbar.
89
+ * @property {HTMLElement} parentElement The parent HTML container of `this.domElement`.
90
+ */
91
+
92
+
93
+ var _onSelected = /*#__PURE__*/new WeakMap();
94
+
95
+ var Searchbar = /*#__PURE__*/function (_Widget) {
96
+ (0, _inherits2["default"])(Searchbar, _Widget);
97
+
98
+ var _super = _createSuper(Searchbar);
99
+
100
+ /**
101
+ * @param {View} view The iTowns view the searchbar should be linked
102
+ * to.
103
+ *
104
+ * @param {Object} geocodingOptions Configuration for geocoding.
105
+ * @param {URL} geocodingOptions.url The URL of a geocoding service that should be
106
+ * used to build suggestions.
107
+ * @param {function} geocodingOptions.parser A method to parse fetched results from geocoding
108
+ * url into a Map object. For each entry of this
109
+ * Map, the key must be a string that will be
110
+ * displayed as the html content of each
111
+ * suggestion bellow the searchbar. The value
112
+ * associated to the key is whatever the user
113
+ * wants. The value is the parameter that is
114
+ * passed to the `onSelected` method (specified
115
+ * in another `geocodingOptions` parameter).
116
+ * @param {function} [geocodingOptions.onSelected] A method which describes what should be done
117
+ * when user selects a location (by clicking or
118
+ * hitting enter on a suggestion). The only
119
+ * parameter of this method is the value mapped
120
+ * with `geocodingOptions.parser` method.
121
+ *
122
+ * @param {Object} [options] The searchbar optional configuration.
123
+ * @param {HTMLElement} [options.parentElement=view.domElement] The parent HTML container of the div which
124
+ * contains searchbar widgets.
125
+ * @param {number} [options.size] The size of the searchbar. It is a number that
126
+ * describes both width and height in pixels of
127
+ * the searchbar.
128
+ * @param {number} [options.width=300] The width in pixels of the searchbar.
129
+ * @param {number} [options.height=38] The height in pixels of the searchbar.
130
+ * @param {string} [options.position='top'] Defines which position within the
131
+ * `parentElement` the searchbar should be
132
+ * displayed to. Possible values are `top`,
133
+ * `bottom`, `left`, `right`, `top-left`,
134
+ * `top-right`, `bottom-left` and `bottom-right`.
135
+ * If the input value does not match one of
136
+ * these, it will be defaulted to `top`.
137
+ * @param {Object} [options.translate] An optional translation of the searchbar.
138
+ * @param {number} [options.translate.x=0] The searchbar translation along the page x-axis.
139
+ * @param {number} [options.translate.y=0] The searchbar translation along the page y-axis.
140
+ * @param {number} [options.fontSize=16] The font size in pixel of the searchbar content.
141
+ * @param {number} [options.maxSuggestionNumber=10] The maximum number of suggestions that should
142
+ * appear under the searchbar.
143
+ * @param {string} [options.placeholder='Search location'] The placeholder that appears in the searchbar
144
+ * when nothing has yet been typed.
145
+ */
146
+ function Searchbar(view, geocodingOptions) {
147
+ var _geocodingOptions$onS;
148
+
149
+ var _this;
150
+
151
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
152
+ (0, _classCallCheck2["default"])(this, Searchbar);
153
+ // ---------- BUILD PROPERTIES ACCORDING TO DEFAULT OPTIONS AND OPTIONS PASSED IN PARAMETERS : ----------
154
+ _this = _super.call(this, view, options, DEFAULT_OPTIONS); // Check if `geocodingOptions` parameter was correctly specified.
155
+
156
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _onSelected, {
157
+ writable: true,
158
+ value: void 0
159
+ });
160
+
161
+ if (!geocodingOptions || !geocodingOptions.url || !geocodingOptions.parser || typeof geocodingOptions.parser !== 'function') {
162
+ throw new Error('\'geocodingOptions\' parameter for \'Searchbar\' constructor is not a valid option. Please refer to ' + 'the documentation.');
163
+ }
164
+
165
+ (0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _onSelected, (_geocodingOptions$onS = geocodingOptions.onSelected) !== null && _geocodingOptions$onS !== void 0 ? _geocodingOptions$onS : function () {}); // ---------- this.domElement SETTINGS SPECIFIC TO SEARCHBAR : ----------
166
+
167
+ _this.domElement.id = 'widgets-searchbar';
168
+ _this.domElement.style.height = 'auto';
169
+ var form = document.createElement('form');
170
+ form.setAttribute('autocomplete', 'off');
171
+ form.id = 'searchbar-autocompletion-form';
172
+
173
+ _this.domElement.appendChild(form);
174
+
175
+ var input = document.createElement('input');
176
+ input.setAttribute('type', 'text');
177
+ input.setAttribute('name', 'mySearch');
178
+ input.setAttribute('placeholder', options.placeholder || DEFAULT_OPTIONS.placeholder);
179
+ input.style.height = "".concat(options.height || options.size || DEFAULT_OPTIONS.height, "px");
180
+ input.style.fontSize = "".concat(options.fontSize || DEFAULT_OPTIONS.fontSize, "px");
181
+ form.appendChild(input); // currentFocus variable stores the index of the suggestions that is focused by user, either with mouse or arrow
182
+ // keys.
183
+
184
+ var currentFocus; // ---------- BUILD AUTOCOMPLETION SUGGESTIONS LIST WHEN TYPING THE SEARCHBAR INPUT : ----------
185
+
186
+ input.addEventListener('input', function () {
187
+ var value = input.value; // Close any already opened list of autocompleted values
188
+
189
+ eraseSuggestionList(form);
190
+ currentFocus = -1;
191
+
192
+ if (!value) {
193
+ return false;
194
+ }
195
+
196
+ geocodingOptions.url.searchParams.set('text', value);
197
+
198
+ _Fetcher["default"].json(geocodingOptions.url).then(function (geocodingResult) {
199
+ var result = geocodingOptions.parser(geocodingResult);
200
+ var i = 0;
201
+ result.forEach(function (info, location) {
202
+ // Stop looping through the map if enough location have been proceeded.
203
+ if (i === Math.min(result.size, options.maxSuggestionNumber || DEFAULT_OPTIONS.maxSuggestionNumber)) {
204
+ return;
205
+ }
206
+
207
+ var mapIndex = i;
208
+ i++;
209
+ var index = location.toUpperCase().indexOf(value.toUpperCase());
210
+
211
+ if (index > -1) {
212
+ var autocompleteItem = document.createElement('div');
213
+ autocompleteItem.style.minHeight = input.style.height;
214
+ autocompleteItem.style.fontSize = "".concat(options.fontSize || DEFAULT_OPTIONS.fontSize, "px"); // Make the matching letters bold.
215
+
216
+ var start = location.slice(0, index);
217
+ var bold = location.slice(index, index + value.length);
218
+ var end = location.slice(index + value.length, location.length);
219
+ autocompleteItem.innerHTML = "<p>".concat(start, "<strong>").concat(bold, "</strong>").concat(end, "</p>"); // Store the current location value as an attribute of autocompleteItem div.
220
+
221
+ autocompleteItem.setAttribute('location', location);
222
+ form.appendChild(autocompleteItem); // eslint-disable-next-line no-loop-func
223
+
224
+ autocompleteItem.addEventListener('mouseover', function () {
225
+ removeAllActives(form.children);
226
+ currentFocus = mapIndex;
227
+ autocompleteItem.classList.add('active');
228
+ });
229
+ autocompleteItem.addEventListener('click', function () {
230
+ (0, _classPrivateFieldGet2["default"])((0, _assertThisInitialized2["default"])(_this), _onSelected).call((0, _assertThisInitialized2["default"])(_this), info);
231
+ input.value = autocompleteItem.getAttribute('location');
232
+ eraseSuggestionList(form);
233
+ });
234
+ }
235
+ });
236
+ });
237
+ }); // ---------- MANAGE KEYBOARD INTERACTIONS ON AUTOCOMPLETION SUGGESTIONS : ----------
238
+ // When searchbar is positioned at the bottom of the screen (therefore is a flex with `column-reverse`
239
+ // direction, we must exchange up and down arrow actions.
240
+
241
+ var topOrBottom = (options.position || DEFAULT_OPTIONS.position).includes('top') ? 1 : -1;
242
+ input.addEventListener('keydown', function (event) {
243
+ event.stopPropagation();
244
+ var completionSuggestions = form.getElementsByTagName('div');
245
+
246
+ switch (event.code) {
247
+ case 'Escape':
248
+ eraseSuggestionList(form);
249
+ input.value = '';
250
+ view.domElement.focus();
251
+ break;
252
+
253
+ case 'ArrowDown':
254
+ event.preventDefault();
255
+ currentFocus = addActive(completionSuggestions, currentFocus + topOrBottom);
256
+ break;
257
+
258
+ case 'ArrowUp':
259
+ event.preventDefault();
260
+ currentFocus = addActive(completionSuggestions, currentFocus - topOrBottom);
261
+ break;
262
+
263
+ case 'Enter':
264
+ event.preventDefault();
265
+
266
+ if (completionSuggestions[Math.max(currentFocus, 0)]) {
267
+ completionSuggestions[Math.max(currentFocus, 0)].click();
268
+ view.domElement.focus();
269
+ }
270
+
271
+ break;
272
+
273
+ default:
274
+ break;
275
+ }
276
+ }); // ---------- MANAGE FOCUS AND ACTIVE SUGGESTION WHEN USER ENTERS OR LEAVES THE SEARCHBAR : ----------
277
+ // User clicks the searchbar.
278
+
279
+ input.addEventListener('focus', function () {
280
+ form.classList.add('focus');
281
+ }); // User clicks out of the searchbar.
282
+
283
+ input.addEventListener('blur', function () {
284
+ form.classList.remove('focus');
285
+ removeAllActives(form.children);
286
+ }); // Cursor leaves the searchbar.
287
+
288
+ form.addEventListener('mouseleave', function () {
289
+ removeAllActives(form.children);
290
+ currentFocus = -1;
291
+ });
292
+ return _this;
293
+ }
294
+
295
+ return (0, _createClass2["default"])(Searchbar);
296
+ }(_Widget2["default"]);
297
+
298
+ var _default = Searchbar;
299
+ exports["default"] = _default;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
15
+
16
+ var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
17
+
18
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
19
+
20
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
21
+
22
+ var _display = /*#__PURE__*/new WeakMap();
23
+
24
+ /**
25
+ * An interface that stores common methods for all specific widgets.
26
+ *
27
+ * @hideconstructor
28
+ */
29
+ var Widget = /*#__PURE__*/function () {
30
+ function Widget(view) {
31
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
32
+ var defaultOptions = arguments.length > 2 ? arguments[2] : undefined;
33
+ (0, _classCallCheck2["default"])(this, Widget);
34
+
35
+ _classPrivateFieldInitSpec(this, _display, {
36
+ writable: true,
37
+ value: void 0
38
+ });
39
+
40
+ this.parentElement = options.parentElement || view.domElement;
41
+ this.position = options.position || defaultOptions.position;
42
+
43
+ if (!['top-left', 'top-right', 'bottom-left', 'bottom-right', 'top', 'bottom', 'left', 'right'].includes(this.position)) {
44
+ console.warn('\'position\' optional parameter for \'Widget\' constructor is not a valid option. ' + "It will be set to '".concat(defaultOptions.position, "'."));
45
+ this.position = defaultOptions.position;
46
+ } // ---------- CREATE A DomElement WITH id, classes AND style RELEVANT TO THE WIDGET PROPERTIES : ----------
47
+ // Create a div containing minimap widget and add it to its specified parent.
48
+
49
+
50
+ this.domElement = document.createElement('div');
51
+ this.parentElement.appendChild(this.domElement); // Size widget according to options.
52
+
53
+ this.domElement.style.width = "".concat(options.width || options.size || defaultOptions.width, "px");
54
+ this.domElement.style.height = "".concat(options.height || options.size || defaultOptions.height, "px"); // Position widget according to options.
55
+
56
+ var positionArray = this.position.split('-');
57
+ this.domElement.classList.add("".concat(positionArray[0], "-widget"));
58
+
59
+ if (positionArray[1]) {
60
+ this.domElement.classList.add("".concat(positionArray[1], "-widget"));
61
+ } else {
62
+ // If only one position parameter was given, center the domElement on the other axis.
63
+ // TODO : at this stage, offsetWidth and offsetHeight do no include borders. This should be worked around.
64
+ switch (positionArray[0]) {
65
+ case 'top':
66
+ case 'bottom':
67
+ this.domElement.style.left = "calc(50% - ".concat(this.domElement.offsetWidth / 2, "px)");
68
+ break;
69
+
70
+ case 'left':
71
+ case 'right':
72
+ this.domElement.style.top = "calc(50% - ".concat(this.domElement.offsetHeight / 2, "px)");
73
+ break;
74
+
75
+ default:
76
+ break;
77
+ }
78
+ } // Translate widget div according to optional translate parameter.
79
+
80
+
81
+ if (options.translate) {
82
+ this.domElement.style.transform = "translate(".concat(options.translate.x || 0, "px, ").concat(options.translate.y || 0, "px)");
83
+ } // Prevent triggering `GlobeControls` and `PlanarControls` mouse or pointer events when clicking the search bar.
84
+ // For example, this prevents triggering an animated travel when double-clicking search bar in a `GlobeView`.
85
+
86
+
87
+ this.domElement.addEventListener('pointerdown', function (e) {
88
+ e.stopPropagation();
89
+ });
90
+ this.domElement.addEventListener('mousedown', function (e) {
91
+ e.stopPropagation();
92
+ });
93
+ }
94
+ /**
95
+ * Change the widget style `display` property so that the widget becomes visible.
96
+ */
97
+
98
+
99
+ (0, _createClass2["default"])(Widget, [{
100
+ key: "show",
101
+ value: function show() {
102
+ this.domElement.style.display = (0, _classPrivateFieldGet2["default"])(this, _display);
103
+ }
104
+ /**
105
+ * Change the widget style `display` property so that the widget becomes invisible.
106
+ */
107
+
108
+ }, {
109
+ key: "hide",
110
+ value: function hide() {
111
+ (0, _classPrivateFieldSet2["default"])(this, _display, window.getComputedStyle(this.domElement).display);
112
+ this.domElement.style.display = 'none';
113
+ }
114
+ }]);
115
+ return Widget;
116
+ }();
117
+
118
+ var _default = Widget;
119
+ exports["default"] = _default;
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.36.2",
3
+ "version": "2.38.1",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "main": "lib/Main.js",
6
+ "exports": {
7
+ ".": "./lib/Main.js",
8
+ "./widgets": "./lib/Utils/gui/Main.js"
9
+ },
6
10
  "scripts": {
7
11
  "lint": "eslint \"src/**/*.js\" \"test/**/*.js\" \"examples/**/*.js\" \"docs/*.js\"",
8
12
  "doc": "jsdoc --readme docs/HOMEPAGE.md -c docs/config.json",
@@ -47,8 +51,8 @@
47
51
  },
48
52
  "homepage": "https://itowns.github.io/",
49
53
  "dependencies": {
50
- "@loaders.gl/las": "^3.0.12",
51
- "@mapbox/mapbox-gl-style-spec": "^13.22.0",
54
+ "@loaders.gl/las": "^3.1.7",
55
+ "@mapbox/mapbox-gl-style-spec": "^13.23.1",
52
56
  "@mapbox/vector-tile": "^1.3.1",
53
57
  "@tmcw/togeojson": "^4.5.0",
54
58
  "@tweenjs/tween.js": "^18.6.4",
@@ -61,49 +65,50 @@
61
65
  },
62
66
  "peerDependencies": {
63
67
  "proj4": "^2.7.5",
64
- "three": "0.133.1"
68
+ "three": "0.137.5"
65
69
  },
66
70
  "devDependencies": {
67
- "@babel/cli": "^7.15.7",
68
- "@babel/plugin-transform-runtime": "^7.15.8",
69
- "@babel/preset-env": "^7.15.8",
70
- "@babel/register": "^7.15.3",
71
+ "@babel/cli": "^7.17.0",
72
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
73
+ "@babel/plugin-transform-runtime": "^7.17.0",
74
+ "@babel/preset-env": "^7.16.11",
75
+ "@babel/register": "^7.17.0",
71
76
  "babel-inline-import-loader": "^1.0.1",
72
- "babel-loader": "^8.2.2",
77
+ "babel-loader": "^8.2.3",
73
78
  "babel-plugin-inline-import": "^3.0.0",
74
79
  "babel-plugin-minify-dead-code-elimination": "^0.5.1",
75
80
  "babel-plugin-minify-replace": "^0.5.0",
76
81
  "babel-plugin-module-resolver": "^4.1.0",
77
82
  "chalk": "^4.1.2",
78
- "chart.js": "^3.5.1",
83
+ "chart.js": "^3.7.0",
79
84
  "compare-func": "^2.0.0",
80
- "conventional-changelog-cli": "^2.1.1",
85
+ "conventional-changelog-cli": "^2.2.2",
81
86
  "copyfiles": "^2.4.1",
82
- "core-js": "^3.18.3",
87
+ "core-js": "^3.21.0",
83
88
  "cross-env": "^7.0.3",
84
- "eslint": "^7.32.0",
85
- "eslint-config-airbnb-base": "^14.2.1",
86
- "eslint-import-resolver-webpack": "^0.13.1",
87
- "eslint-loader": "^4.0.2",
88
- "eslint-plugin-import": "^2.25.2",
89
+ "eslint": "^8.8.0",
90
+ "eslint-config-airbnb-base": "^15.0.0",
91
+ "eslint-import-resolver-webpack": "^0.13.2",
92
+ "eslint-plugin-import": "^2.25.4",
93
+ "eslint-webpack-plugin": "^3.1.1",
89
94
  "github-url-from-git": "^1.5.0",
90
95
  "grunt": "^1.4.1",
91
96
  "grunt-bump": "^0.8.0",
92
97
  "https-proxy-agent": "^5.0.0",
93
- "jsdoc": "^3.6.7",
94
- "marked": "^3.0.7",
95
- "mocha": "^9.1.2",
96
- "node-fetch": "^2.6.2",
98
+ "jsdoc": "^3.6.10",
99
+ "marked": "^4.0.12",
100
+ "mocha": "^9.2.0",
101
+ "node-fetch": "^2.6.7",
97
102
  "nyc": "^15.1.0",
98
103
  "proj4": "^2.7.5",
99
- "puppeteer": "^10.4.0",
104
+ "puppeteer": "^13.2.0",
100
105
  "q": "^1.5.1",
101
- "replace-in-file": "^6.2.0",
102
- "three": "0.133.1",
106
+ "replace-in-file": "^6.3.2",
107
+ "three": "0.137.5",
103
108
  "url-polyfill": "^1.1.12",
104
- "webpack": "^5.58.1",
105
- "webpack-cli": "^4.9.0",
106
- "webpack-dev-server": "^4.3.1",
109
+ "webpack": "^5.68.0",
110
+ "webpack-cli": "^4.9.2",
111
+ "webpack-dev-server": "^4.7.4",
107
112
  "whatwg-fetch": "^3.6.2"
108
113
  }
109
114
  }
@@ -1,40 +0,0 @@
1
- /**
2
- * For a given pixel size, calculates the projected metric distance at the middle of the screen.
3
- * Calculates then the pixel distance equivalent to the rounded computed metric distance.
4
- *
5
- * @param {itowns.View} view View in which the distances are computed.
6
- * @param {number} pixelSize Distance in pixels, at the center of the view.
7
- * @return {{pixels: number, meters: number}} The rounded pixel and metric distances.
8
- */
9
- // eslint-disable-next-line no-unused-vars
10
- function roundPixelsFromMeters(view, pixelSize) {
11
- // Calculate the metric distance which match the given pixel distance :
12
- var distanceMeters = view.getPixelsToMeters(pixelSize);
13
-
14
- // Round the metric distance :
15
- distanceMeters = Math.floor(distanceMeters);
16
- var digit = Math.pow(10, distanceMeters.toString().length - 1);
17
- distanceMeters = Math.round(distanceMeters / digit) * digit;
18
-
19
- // Round the pixel distance to match the rounded metric distance :
20
- var roundedPixDistance = view.getMetersToPixels(distanceMeters);
21
-
22
- return {
23
- pixels: roundedPixDistance,
24
- meters: distanceMeters,
25
- };
26
- }
27
-
28
- // eslint-disable-next-line no-unused-vars
29
- function getMetersUnit(distanceMeters) {
30
- var distance = distanceMeters;
31
- var unit = 'm';
32
- if (distanceMeters >= 1000) {
33
- distance /= 1000;
34
- unit = 'km';
35
- }
36
- return {
37
- distance: distance,
38
- unit: unit,
39
- };
40
- }