itowns 2.44.3-next.4 → 2.44.3-next.40

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 (109) hide show
  1. package/CODING.md +1 -1
  2. package/CONTRIBUTORS.md +1 -0
  3. package/dist/debug.js +1 -1
  4. package/dist/debug.js.map +1 -1
  5. package/dist/itowns.js +1 -1
  6. package/dist/itowns.js.LICENSE.txt +0 -2
  7. package/dist/itowns.js.map +1 -1
  8. package/dist/itowns_widgets.js +1 -1
  9. package/dist/itowns_widgets.js.map +1 -1
  10. package/examples/3dtiles_loader.html +123 -48
  11. package/examples/config.json +3 -10
  12. package/examples/copc_simple_loader.html +15 -5
  13. package/examples/effects_stereo.html +2 -2
  14. package/examples/entwine_3d_loader.html +3 -1
  15. package/examples/entwine_simple_loader.html +1 -1
  16. package/examples/images/itowns_logo.svg +123 -0
  17. package/examples/js/plugins/COGParser.js +1 -1
  18. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  19. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  20. package/examples/misc_collada.html +2 -2
  21. package/examples/source_file_geojson_3d.html +0 -1
  22. package/examples/source_file_kml_raster_usgs.html +0 -1
  23. package/examples/source_stream_wfs_raster.html +0 -7
  24. package/examples/vector_tile_mapbox_raster.html +91 -0
  25. package/examples/view_3d_map_webxr.html +3 -1
  26. package/examples/view_multi_25d.html +2 -2
  27. package/lib/Controls/GlobeControls.js +45 -28
  28. package/lib/Controls/StateControl.js +5 -2
  29. package/lib/Converter/Feature2Mesh.js +10 -4
  30. package/lib/Converter/Feature2Texture.js +6 -1
  31. package/lib/Converter/convertToTile.js +3 -8
  32. package/lib/Converter/textureConverter.js +4 -5
  33. package/lib/Core/Deprecated/Undeprecator.js +0 -1
  34. package/lib/Core/Feature.js +3 -4
  35. package/lib/Core/Geographic/Coordinates.js +143 -132
  36. package/lib/Core/Geographic/Crs.js +140 -145
  37. package/lib/Core/Geographic/Extent.js +221 -397
  38. package/lib/Core/Geographic/GeoidGrid.js +1 -1
  39. package/lib/Core/MainLoop.js +1 -3
  40. package/lib/Core/Math/Ellipsoid.js +62 -21
  41. package/lib/Core/Prefab/Globe/Atmosphere.js +4 -8
  42. package/lib/Core/Prefab/Globe/GlobeLayer.js +22 -15
  43. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +111 -0
  44. package/lib/Core/Prefab/GlobeView.js +2 -7
  45. package/lib/Core/Prefab/Planar/PlanarLayer.js +17 -11
  46. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +43 -43
  47. package/lib/Core/Prefab/TileBuilder.js +42 -40
  48. package/lib/Core/Prefab/computeBufferTileGeometry.js +195 -130
  49. package/lib/Core/Scheduler/Cache.js +1 -240
  50. package/lib/Core/Style.js +34 -495
  51. package/lib/Core/StyleOptions.js +486 -0
  52. package/lib/Core/Tile/Tile.js +207 -0
  53. package/lib/Core/Tile/TileGrid.js +49 -0
  54. package/lib/Core/TileGeometry.js +112 -28
  55. package/lib/Core/TileMesh.js +3 -3
  56. package/lib/Core/View.js +15 -8
  57. package/lib/Layer/C3DTilesLayer.js +20 -16
  58. package/lib/Layer/ColorLayer.js +35 -9
  59. package/lib/Layer/CopcLayer.js +7 -2
  60. package/lib/Layer/ElevationLayer.js +39 -7
  61. package/lib/Layer/EntwinePointTileLayer.js +14 -7
  62. package/lib/Layer/FeatureGeometryLayer.js +20 -6
  63. package/lib/Layer/GeometryLayer.js +42 -11
  64. package/lib/Layer/LabelLayer.js +45 -27
  65. package/lib/Layer/Layer.js +92 -61
  66. package/lib/Layer/OGC3DTilesLayer.js +212 -56
  67. package/lib/Layer/OrientedImageLayer.js +11 -5
  68. package/lib/Layer/PointCloudLayer.js +76 -30
  69. package/lib/Layer/Potree2Layer.js +9 -2
  70. package/lib/Layer/PotreeLayer.js +10 -3
  71. package/lib/Layer/RasterLayer.js +12 -2
  72. package/lib/Layer/TiledGeometryLayer.js +69 -13
  73. package/lib/Main.js +2 -2
  74. package/lib/Parser/GeoJsonParser.js +1 -1
  75. package/lib/Parser/VectorTileParser.js +42 -29
  76. package/lib/Parser/XbilParser.js +14 -2
  77. package/lib/Provider/Fetcher.js +5 -1
  78. package/lib/Provider/URLBuilder.js +22 -11
  79. package/lib/Renderer/Camera.js +1 -1
  80. package/lib/Renderer/Label2DRenderer.js +9 -7
  81. package/lib/Renderer/OBB.js +11 -13
  82. package/lib/Renderer/PointsMaterial.js +5 -5
  83. package/lib/Renderer/RasterTile.js +1 -2
  84. package/lib/Renderer/SphereHelper.js +0 -6
  85. package/lib/Source/CopcSource.js +13 -2
  86. package/lib/Source/EntwinePointTileSource.js +14 -4
  87. package/lib/Source/FileSource.js +9 -10
  88. package/lib/Source/OrientedImageSource.js +2 -2
  89. package/lib/Source/Source.js +26 -46
  90. package/lib/Source/TMSSource.js +10 -9
  91. package/lib/Source/VectorTilesSource.js +38 -34
  92. package/lib/Source/WFSSource.js +18 -13
  93. package/lib/Source/WMSSource.js +56 -18
  94. package/lib/Source/WMTSSource.js +13 -7
  95. package/lib/ThreeExtended/libs/ktx-parse.module.js +310 -274
  96. package/lib/ThreeExtended/loaders/DRACOLoader.js +3 -2
  97. package/lib/ThreeExtended/loaders/GLTFLoader.js +6 -3
  98. package/lib/ThreeExtended/loaders/KTX2Loader.js +144 -60
  99. package/lib/ThreeExtended/math/ColorSpaces.js +59 -0
  100. package/lib/Utils/CameraUtils.js +1 -1
  101. package/lib/Utils/gui/C3DTilesStyle.js +2 -3
  102. package/lib/Utils/placeObjectOnGround.js +0 -1
  103. package/package.json +10 -8
  104. package/examples/3dtiles_25d.html +0 -120
  105. package/examples/3dtiles_basic.html +0 -94
  106. package/examples/3dtiles_batch_table.html +0 -86
  107. package/examples/3dtiles_ion.html +0 -126
  108. package/examples/3dtiles_pointcloud.html +0 -95
  109. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
@@ -1,249 +1,136 @@
1
1
  import * as THREE from 'three';
2
+ import * as CRS from "./Crs.js";
2
3
  import Coordinates from "./Coordinates.js";
3
- import CRS from "./Crs.js";
4
-
5
- /**
6
- * Extent is a SIG-area (so 2D)
7
- * It can use explicit coordinates (e.g: lon/lat) or implicit (WMTS coordinates)
8
- */
9
-
10
4
  const _dim = new THREE.Vector2();
11
5
  const _dim2 = new THREE.Vector2();
12
- const _countTiles = new THREE.Vector2();
13
6
  const _box = new THREE.Box3();
14
- const tmsCoord = new THREE.Vector2();
15
- const dimensionTile = new THREE.Vector2();
16
7
  const defaultScheme = new THREE.Vector2(2, 2);
17
- const r = {
18
- row: 0,
19
- col: 0,
20
- invDiff: 0
21
- };
22
8
  const cNorthWest = new Coordinates('EPSG:4326', 0, 0, 0);
23
9
  const cSouthWest = new Coordinates('EPSG:4326', 0, 0, 0);
24
10
  const cNorthEast = new Coordinates('EPSG:4326', 0, 0, 0);
25
11
  const southWest = new THREE.Vector3();
26
12
  const northEast = new THREE.Vector3();
27
- function _rowColfromParent(extent, zoom) {
28
- const diffLevel = extent.zoom - zoom;
29
- const diff = 2 ** diffLevel;
30
- r.invDiff = 1 / diff;
31
- r.row = (extent.row - extent.row % diff) * r.invDiff;
32
- r.col = (extent.col - extent.col % diff) * r.invDiff;
33
- return r;
34
- }
35
13
  let _extent;
36
- let _extent2;
37
14
  const cardinals = new Array(8);
38
15
  for (let i = cardinals.length - 1; i >= 0; i--) {
39
- cardinals[i] = new Coordinates('EPSG:4326', 0, 0, 0, 0);
16
+ cardinals[i] = new Coordinates('EPSG:4326', 0, 0, 0);
40
17
  }
41
18
  const _c = new Coordinates('EPSG:4326', 0, 0);
42
-
43
- /** @private */
44
- export const globalExtentTMS = new Map();
45
- /** @private */
46
- export const schemeTiles = new Map();
47
- function getInfoTms(crs) {
48
- const epsg = CRS.formatToEPSG(crs);
49
- const globalExtent = globalExtentTMS.get(epsg);
50
- const globalDimension = globalExtent.planarDimensions(_dim2);
51
- const tms = CRS.formatToTms(crs);
52
- const sTs = schemeTiles.get(tms) || schemeTiles.get('default');
53
- // The isInverted parameter is to be set to the correct value, true or false
54
- // (default being false) if the computation of the coordinates needs to be
55
- // inverted to match the same scheme as OSM, Google Maps or other system.
56
- // See link below for more information
57
- // https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/
58
- // in crs includes ':NI' => tms isn't inverted (NOT INVERTED)
59
- const isInverted = !tms.includes(':NI');
60
- return {
61
- epsg,
62
- globalExtent,
63
- globalDimension,
64
- sTs,
65
- isInverted
66
- };
67
- }
68
- function getCountTiles(crs, zoom) {
69
- const sTs = schemeTiles.get(CRS.formatToTms(crs)) || schemeTiles.get('default');
70
- const count = 2 ** zoom;
71
- _countTiles.set(count, count).multiply(sTs);
72
- return _countTiles;
73
- }
19
+ /**
20
+ * A class representing a geographical extent.
21
+ *
22
+ * An extent is a geographical bounding rectangle defined by 4 limits: west,
23
+ * east, south and north.
24
+ *
25
+ * **Warning**: Using a geocentric projection is not suitable for representing a
26
+ * geographical extent. Please use a geographic projection.
27
+ */
74
28
  class Extent {
75
29
  /**
76
- * Extent is geographical bounding rectangle defined by 4 limits: west, east, south and north.
77
- * If crs is tiled projection (WMTS or TMS), the extent is defined by zoom, row and column.
78
- *
79
- * Warning, using geocentric projection isn't consistent with geographical extent.
80
- *
81
- * @param {String} crs projection of limit values.
82
- * @param {number|Array.<number>|Coordinates|Object} v0 west value, zoom
83
- * value, Array of values [west, east, south and north], Coordinates of
84
- * west-south corner or object {west, east, south and north}
85
- * @param {number|Coordinates} [v1] east value, row value or Coordinates of
86
- * east-north corner
87
- * @param {number} [v2] south value or column value
88
- * @param {number} [v3] north value
89
- */
90
- constructor(crs, v0, v1, v2, v3) {
30
+ * Read-only flag to check if a given object is of type `Extent`.
31
+ */
32
+
33
+ /**
34
+ * A default or user-defined CRS (see {@link ProjectionLike}).
35
+ */
36
+
37
+ /**
38
+ * West longitude bound of this extent.
39
+ */
40
+
41
+ /**
42
+ * East longitude bound of this extent.
43
+ */
44
+
45
+ /**
46
+ * South latitude bound of this extent.
47
+ */
48
+
49
+ /**
50
+ * North latitude bound of this extent.
51
+ */
52
+
53
+ /**
54
+ * @param crs - A default or user-defined CRS (see {@link ProjectionLike}).
55
+ * @param west - the `west` value of this extent. Default is 0.
56
+ * @param east - the `east` value of this extent. Default is 0.
57
+ * @param south - the `south` value of this extent. Default is 0.
58
+ * @param north - the `north` value of this extent. Default is 0.
59
+ */
60
+ constructor(crs) {
61
+ let west = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
62
+ let east = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
63
+ let south = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
64
+ let north = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
91
65
  if (CRS.isGeocentric(crs)) {
92
- throw new Error(`${crs} is a geocentric projection, it doesn't make sense with a geographical extent`);
66
+ throw new Error(`Non-compatible geocentric projection ${crs} to build a geographical extent`);
93
67
  }
94
68
  this.isExtent = true;
95
69
  this.crs = crs;
96
- // Scale/zoom
97
- this.zoom = 0;
98
- if (CRS.isTms(this.crs)) {
99
- this.row = 0;
100
- this.col = 0;
101
- } else {
102
- this.west = 0;
103
- this.east = 0;
104
- this.south = 0;
105
- this.north = 0;
106
- }
107
- this.set(v0, v1, v2, v3);
70
+ this.west = 0;
71
+ this.east = 0;
72
+ this.south = 0;
73
+ this.north = 0;
74
+ this.set(west, east, south, north);
108
75
  }
109
76
 
110
77
  /**
111
- * Clone this extent
112
- * @return {Extent} cloned extent
78
+ * Returns a new extent with the same bounds and crs as this one.
113
79
  */
114
80
  clone() {
115
- if (CRS.isTms(this.crs)) {
116
- return new Extent(this.crs, this.zoom, this.row, this.col);
117
- } else {
118
- return new Extent(this.crs, this.west, this.east, this.south, this.north);
119
- }
81
+ return new Extent(this.crs, this.west, this.east, this.south, this.north);
120
82
  }
121
83
 
122
84
  /**
123
- * get tiled extents convering this extent
85
+ * Projects this extent to the specified projection.
124
86
  *
125
- * @param {string} crs WMTS, TMS crs
126
- * @return {Array<Extent>} array of extents covering
127
- */
128
- tiledCovering(crs) {
129
- if (this.crs == 'EPSG:4326' && crs == CRS.tms_3857) {
130
- const extents_WMTS_PM = [];
131
- const extent = _extent.copy(this).as(CRS.formatToEPSG(crs), _extent2);
132
- const {
133
- globalExtent,
134
- globalDimension,
135
- sTs
136
- } = getInfoTms(CRS.formatToEPSG(crs));
137
- extent.clampByExtent(globalExtent);
138
- extent.planarDimensions(dimensionTile);
139
- const zoom = this.zoom + 1 || Math.floor(Math.log2(Math.round(globalDimension.x / (dimensionTile.x * sTs.x))));
140
- const countTiles = getCountTiles(crs, zoom);
141
- const center = extent.center(_c);
142
- tmsCoord.x = center.x - globalExtent.west;
143
- tmsCoord.y = globalExtent.north - extent.north;
144
- tmsCoord.divide(globalDimension).multiply(countTiles).floor();
145
-
146
- // ]N; N+1] => N
147
- const maxRow = Math.ceil((globalExtent.north - extent.south) / globalDimension.x * countTiles.y) - 1;
148
- for (let r = maxRow; r >= tmsCoord.y; r--) {
149
- extents_WMTS_PM.push(new Extent(crs, zoom, r, tmsCoord.x));
150
- }
151
- return extents_WMTS_PM;
152
- } else {
153
- const target = new Extent(crs, 0, 0, 0);
154
- const {
155
- globalExtent,
156
- globalDimension,
157
- sTs,
158
- isInverted
159
- } = getInfoTms(this.crs);
160
- const center = this.center(_c);
161
- this.planarDimensions(dimensionTile);
162
- // Each level has 2^n * 2^n tiles...
163
- // ... so we count how many tiles of the same width as tile we can fit in the layer
164
- // ... 2^zoom = tilecount => zoom = log2(tilecount)
165
- const zoom = Math.floor(Math.log2(Math.round(globalDimension.x / (dimensionTile.x * sTs.x))));
166
- const countTiles = getCountTiles(crs, zoom);
167
-
168
- // Now that we have computed zoom, we can deduce x and y (or row / column)
169
- tmsCoord.x = center.x - globalExtent.west;
170
- tmsCoord.y = isInverted ? globalExtent.north - center.y : center.y - globalExtent.south;
171
- tmsCoord.divide(globalDimension).multiply(countTiles).floor();
172
- target.set(zoom, tmsCoord.y, tmsCoord.x);
173
- return [target];
174
- }
175
- }
176
-
177
- /**
178
- * Convert Extent to the specified projection.
179
- * @param {string} crs the projection of destination.
180
- * @param {Extent} target copy the destination to target.
181
- * @return {Extent}
87
+ * @param crs - target's projection.
88
+ * @param target - The target to store the projected extent. If this not
89
+ * provided a new extent will be created.
182
90
  */
183
- as(crs, target) {
91
+ as(crs) {
92
+ let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Extent('EPSG:4326');
184
93
  CRS.isValid(crs);
185
- target = target || new Extent('EPSG:4326', [0, 0, 0, 0]);
186
- if (CRS.isTms(this.crs)) {
187
- const {
188
- epsg,
189
- globalExtent,
190
- globalDimension
191
- } = getInfoTms(this.crs);
192
- const countTiles = getCountTiles(this.crs, this.zoom);
193
- dimensionTile.set(1, 1).divide(countTiles).multiply(globalDimension);
194
- target.west = globalExtent.west + (globalDimension.x - dimensionTile.x * (countTiles.x - this.col));
195
- target.east = target.west + dimensionTile.x;
196
- target.south = globalExtent.south + dimensionTile.y * (countTiles.y - this.row - 1);
197
- target.north = target.south + dimensionTile.y;
198
- target.crs = epsg;
199
- target.zoom = this.zoom;
200
- return crs == epsg ? target : target.as(crs, target);
201
- } else if (CRS.isEpsg(crs)) {
202
- if (this.crs != crs) {
203
- // Compute min/max in x/y by projecting 8 cardinal points,
204
- // and then taking the min/max of each coordinates.
205
- const center = this.center(_c);
206
- cardinals[0].setFromValues(this.west, this.north);
207
- cardinals[1].setFromValues(center.x, this.north);
208
- cardinals[2].setFromValues(this.east, this.north);
209
- cardinals[3].setFromValues(this.east, center.y);
210
- cardinals[4].setFromValues(this.east, this.south);
211
- cardinals[5].setFromValues(center.x, this.south);
212
- cardinals[6].setFromValues(this.west, this.south);
213
- cardinals[7].setFromValues(this.west, center.y);
214
- target.set(Infinity, -Infinity, Infinity, -Infinity);
215
-
216
- // loop over the coordinates
217
- for (let i = 0; i < cardinals.length; i++) {
218
- // convert the coordinate.
219
- cardinals[i].crs = this.crs;
220
- cardinals[i].as(crs, _c);
221
- target.north = Math.max(target.north, _c.y);
222
- target.south = Math.min(target.south, _c.y);
223
- target.east = Math.max(target.east, _c.x);
224
- target.west = Math.min(target.west, _c.x);
225
- }
226
- target.zoom = this.zoom;
227
- target.crs = crs;
228
- return target;
94
+ if (this.crs != crs) {
95
+ // Compute min/max in x/y by projecting 8 cardinal points,
96
+ // and then taking the min/max of each coordinates.
97
+ const center = this.center(_c);
98
+ cardinals[0].setFromValues(this.west, this.north);
99
+ cardinals[1].setFromValues(center.x, this.north);
100
+ cardinals[2].setFromValues(this.east, this.north);
101
+ cardinals[3].setFromValues(this.east, center.y);
102
+ cardinals[4].setFromValues(this.east, this.south);
103
+ cardinals[5].setFromValues(center.x, this.south);
104
+ cardinals[6].setFromValues(this.west, this.south);
105
+ cardinals[7].setFromValues(this.west, center.y);
106
+ target.set(Infinity, -Infinity, Infinity, -Infinity);
107
+
108
+ // loop over the coordinates
109
+ for (let i = 0; i < cardinals.length; i++) {
110
+ // convert the coordinate.
111
+ cardinals[i].crs = this.crs;
112
+ cardinals[i].as(crs, _c);
113
+ target.north = Math.max(target.north, _c.y);
114
+ target.south = Math.min(target.south, _c.y);
115
+ target.east = Math.max(target.east, _c.x);
116
+ target.west = Math.min(target.west, _c.x);
229
117
  }
230
118
  target.crs = crs;
231
- target.zoom = this.zoom;
232
- target.set(this.west, this.east, this.south, this.north);
233
119
  return target;
234
120
  }
121
+ target.crs = crs;
122
+ target.set(this.west, this.east, this.south, this.north);
123
+ return target;
235
124
  }
236
125
 
237
126
  /**
238
- * Return the center of Extent
239
- * @param {Coordinates} target copy the center to the target.
240
- * @return {Coordinates}
127
+ * Returns the center of the extent.
128
+ *
129
+ * @param target - The target to store the center coordinate. If this not
130
+ * provided a new coordinate will be created.
241
131
  */
242
132
  center() {
243
133
  let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Coordinates(this.crs);
244
- if (CRS.isTms(this.crs)) {
245
- throw new Error('Invalid operation for WMTS bbox');
246
- }
247
134
  this.planarDimensions(_dim);
248
135
  target.crs = this.crs;
249
136
  target.setFromValues(this.west + _dim.x * 0.5, this.south + _dim.y * 0.5);
@@ -251,26 +138,12 @@ class Extent {
251
138
  }
252
139
 
253
140
  /**
254
- * Returns the dimension of the extent, in a `THREE.Vector2`.
255
- *
256
- * @param {THREE.Vector2} [target] - The target to assign the result in.
257
- *
258
- * @return {THREE.Vector2}
259
- */
260
- dimensions() {
261
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
262
- console.warn('Extent.dimensions is deprecated, use planarDimensions, geodeticDimensions or spatialEuclideanDimensions');
263
- target.x = Math.abs(this.east - this.west);
264
- target.y = Math.abs(this.north - this.south);
265
- return target;
266
- }
267
-
268
- /**
269
- * Planar dimensions are two planar distances west/east and south/north.
270
- * Planar distance straight-line Euclidean distance calculated in a 2D Cartesian coordinate system.
141
+ * Returns the planar dimensions as two-vector planar distances west/east
142
+ * and south/north.
143
+ * The planar distance is a straight-line Euclidean distance calculated in a
144
+ * 2D Cartesian coordinate system.
271
145
  *
272
- * @param {THREE.Vector2} [target=new THREE.Vector2()] The target
273
- * @return {THREE.Vector2} Planar dimensions
146
+ * @param target - optional target
274
147
  */
275
148
  planarDimensions() {
276
149
  let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
@@ -279,12 +152,12 @@ class Extent {
279
152
  }
280
153
 
281
154
  /**
282
- * Geodetic dimensions are two planar distances west/east and south/north.
283
- * Geodetic distance is calculated in an ellispoid space as the distance
284
- * across the curved surface of the world.
155
+ * Returns the geodetic dimensions as two-vector planar distances west/east
156
+ * and south/north.
157
+ * Geodetic distance is calculated in an ellispoid space as the distance
158
+ * across the curved surface of the ellipsoid.
285
159
  *
286
- * @param {THREE.Vector2} [target=new THREE.Vector2()] The target
287
- * @return {THREE.Vector2} geodetic dimensions
160
+ * @param target - optional target
288
161
  */
289
162
  geodeticDimensions() {
290
163
  let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
@@ -301,11 +174,11 @@ class Extent {
301
174
  }
302
175
 
303
176
  /**
304
- * Spatial euclidean dimensions are two spatial euclidean distances between west/east corner and south/north corner.
305
- * Spatial euclidean distance chord is calculated in a ellispoid space.
177
+ * Returns the spatial euclidean dimensions as a two-vector spatial
178
+ * euclidean distances between west/east corner and south/north corner.
179
+ * Spatial euclidean distance chord is calculated in an ellispoid space.
306
180
  *
307
- * @param {THREE.Vector2} [target=new THREE.Vector2()] The target
308
- * @return {THREE.Vector2} spatial euclidean dimensions
181
+ * @param target - optional target
309
182
  */
310
183
  spatialEuclideanDimensions() {
311
184
  let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
@@ -322,13 +195,11 @@ class Extent {
322
195
  }
323
196
 
324
197
  /**
325
- * Return true if `coord` is inside the bounding box.
198
+ * Checks whether a coordinates is inside the extent.
326
199
  *
327
- * @param {Coordinates} coord
328
- * @param {number} [epsilon=0] - to take into account when comparing to the
329
- * point.
330
- *
331
- * @return {boolean}
200
+ * @param coord - the given coordinates.
201
+ * @param epsilon - error margin when comparing to the coordinates.
202
+ * Default is 0.
332
203
  */
333
204
  isPointInside(coord) {
334
205
  let epsilon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
@@ -343,47 +214,33 @@ class Extent {
343
214
  }
344
215
 
345
216
  /**
346
- * Return true if `extent` is inside this extent.
347
- *
348
- * @param {Extent} extent the extent to check
349
- * @param {number} epsilon to take into account when comparing to the
350
- * point.
217
+ * Checks whether another extent is inside the extent.
351
218
  *
352
- * @return {boolean}
353
- */
354
- isInside(extent, epsilon) {
355
- if (CRS.isTms(this.crs)) {
356
- if (this.zoom == extent.zoom) {
357
- return this.row == extent.row && this.col == extent.col;
358
- } else if (this.zoom < extent.zoom) {
359
- return false;
360
- } else {
361
- _rowColfromParent(this, extent.zoom);
362
- return r.row == extent.row && r.col == extent.col;
363
- }
364
- } else {
365
- extent.as(this.crs, _extent);
366
- epsilon = epsilon == undefined ? CRS.reasonnableEpsilon(this.crs) : epsilon;
367
- return this.east - _extent.east <= epsilon && _extent.west - this.west <= epsilon && this.north - _extent.north <= epsilon && _extent.south - this.south <= epsilon;
368
- }
219
+ * @param extent - the extent to check
220
+ * @param epsilon - error margin when comparing the extent bounds.
221
+ */
222
+ isInside(extent) {
223
+ let epsilon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CRS.reasonableEpsilon(this.crs);
224
+ extent.as(this.crs, _extent);
225
+ return this.east - _extent.east <= epsilon && _extent.west - this.west <= epsilon && this.north - _extent.north <= epsilon && _extent.south - this.south <= epsilon;
369
226
  }
370
227
 
371
228
  /**
372
- * Return the translation and scale to transform this extent to input extent.
229
+ * Return the translation and scale to transform this extent to the input
230
+ * extent.
373
231
  *
374
- * @param {Extent} extent input extent
375
- * @param {THREE.Vector4} target copy the result to target.
376
- * @return {THREE.Vector4} {x: translation on west-east, y: translation on south-north, z: scale on west-east, w: scale on south-north}
232
+ * @param extent - input extent
233
+ * @param target - copy the result to target.
234
+ * @returns A {@link THREE.Vector4} where the `x` property encodes the
235
+ * translation on west-east, the `y` property the translation on
236
+ * south-north, the `z` property the scale on west-east, the `w` property
237
+ * the scale on south-north.
377
238
  */
378
239
  offsetToParent(extent) {
379
240
  let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector4();
380
241
  if (this.crs != extent.crs) {
381
242
  throw new Error('unsupported mix');
382
243
  }
383
- if (CRS.isTms(this.crs)) {
384
- _rowColfromParent(this, extent.zoom);
385
- return target.set(this.col * r.invDiff - r.col, this.row * r.invDiff - r.row, r.invDiff, r.invDiff);
386
- }
387
244
  extent.planarDimensions(_dim);
388
245
  this.planarDimensions(_dim2);
389
246
  const originX = (this.west - extent.west) / _dim.x;
@@ -394,24 +251,9 @@ class Extent {
394
251
  }
395
252
 
396
253
  /**
397
- * Return parent tiled extent with input level
398
- *
399
- * @param {number} levelParent level of parent.
400
- * @return {Extent}
401
- */
402
- tiledExtentParent(levelParent) {
403
- if (levelParent && levelParent < this.zoom) {
404
- _rowColfromParent(this, levelParent);
405
- return new Extent(this.crs, levelParent, r.row, r.col);
406
- } else {
407
- return this;
408
- }
409
- }
410
-
411
- /**
412
- * Return true if this bounding box intersect with the bouding box parameter
413
- * @param {Extent} extent
414
- * @returns {Boolean}
254
+ * Checks wheter this bounding box intersects with the given extent
255
+ * parameter.
256
+ * @param extent - the provided extent
415
257
  */
416
258
  intersectsExtent(extent) {
417
259
  return Extent.intersectsExtent(this, extent);
@@ -423,13 +265,12 @@ class Extent {
423
265
  }
424
266
 
425
267
  /**
426
- * Return the intersection of this extent with another one
427
- * @param {Extent} extent
428
- * @returns {Boolean}
268
+ * Returns the intersection of this extent with another one.
269
+ * @param extent - extent to intersect
429
270
  */
430
271
  intersect(extent) {
431
272
  if (!this.intersectsExtent(extent)) {
432
- return new Extent(this.crs, 0, 0, 0, 0);
273
+ return new Extent(this.crs);
433
274
  }
434
275
  if (extent.crs != this.crs) {
435
276
  extent = extent.as(this.crs, _extent);
@@ -439,55 +280,27 @@ class Extent {
439
280
 
440
281
  /**
441
282
  * Set west, east, south and north values.
442
- * Or if tiled extent, set zoom, row and column values
443
- *
444
- * @param {number|Array.<number>|Coordinates|Object|Extent} v0 west value,
445
- * zoom value, Array of values [west, east, south and north], Extent of same
446
- * type (tiled or not), Coordinates of west-south corner or object {west,
447
- * east, south and north}
448
- * @param {number|Coordinates} [v1] east value, row value or Coordinates of
449
- * east-north corner
450
- * @param {number} [v2] south value or column value
451
- * @param {number} [v3] north value
452
283
  *
453
- * @return {Extent}
284
+ * @param v0 - the `west` value of this extent. Default is 0.
285
+ * @param v1 - the `east` value of this extent. Default is 0.
286
+ * @param v2 - the `south` value of this extent. Default is 0.
287
+ * @param v3 - the `north` value of this extent. Default is 0.
454
288
  */
455
289
  set(v0, v1, v2, v3) {
456
290
  if (v0 == undefined) {
457
291
  throw new Error('No values to set in the extent');
458
292
  }
459
- if (v0.isExtent) {
460
- if (CRS.isTms(v0.crs)) {
461
- v1 = v0.row;
462
- v2 = v0.col;
463
- v0 = v0.zoom;
464
- } else {
465
- v1 = v0.east;
466
- v2 = v0.south;
467
- v3 = v0.north;
468
- v0 = v0.west;
469
- }
470
- }
471
- if (CRS.isTms(this.crs)) {
472
- this.zoom = v0;
473
- this.row = v1;
474
- this.col = v2;
475
- } else if (v0.isCoordinates) {
476
- // seem never used
477
- this.west = v0.x;
478
- this.east = v1.x;
479
- this.south = v0.y;
480
- this.north = v1.y;
481
- } else if (v0.west !== undefined) {
482
- this.west = v0.west;
483
- this.east = v0.east;
484
- this.south = v0.south;
485
- this.north = v0.north;
293
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
294
+ if (v0.west !== undefined) {
295
+ console.warn('Deprecated Extent#constructor(string, Extent) and Extent#set(Extent),', 'use new Extent(string).setFromExtent(Extent) instead.');
296
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
297
+ this.setFromExtent(v0);
298
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
486
299
  } else if (v0.length == 4) {
487
- this.west = v0[0];
488
- this.east = v0[1];
489
- this.south = v0[2];
490
- this.north = v0[3];
300
+ // deepscan-disable-line
301
+ console.warn('Deprecated Extent#constructor(string, number[]) and Extent#set(number[]),', 'use new Extent(string).setFromArray(number[]) instead.');
302
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
303
+ this.setFromArray(v0);
491
304
  } else if (v3 !== undefined) {
492
305
  this.west = v0;
493
306
  this.east = v1;
@@ -498,18 +311,46 @@ class Extent {
498
311
  }
499
312
 
500
313
  /**
501
- * Copy to this extent to input extent.
502
- * @param {Extent} extent
503
- * @return {Extent} copied extent
314
+ * Sets this extent `west` property to `array[offset + 0]`, `east` property
315
+ * to `array[offset + 1]`, `south` property to `array[offset + 2]` and
316
+ * `north` property to `array[offset + 3]`.
317
+ * @param array - the source array
318
+ * @param offset - offset into the array. Default is 0.
319
+ */
320
+ setFromArray(array) {
321
+ let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
322
+ this.west = array[offset];
323
+ this.east = array[offset + 1];
324
+ this.south = array[offset + 2];
325
+ this.north = array[offset + 3];
326
+ return this;
327
+ }
328
+
329
+ /**
330
+ * Sets this extent `west`, `east`, `south` and `north` properties from an
331
+ * `extent` bounds.
332
+ * @param extent - the source extent
333
+ */
334
+ setFromExtent(extent) {
335
+ this.west = extent.west;
336
+ this.east = extent.east;
337
+ this.south = extent.south;
338
+ this.north = extent.north;
339
+ return this;
340
+ }
341
+
342
+ /**
343
+ * Copies the passed extent to this extent.
344
+ * @param extent - extent to copy.
504
345
  */
505
346
  copy(extent) {
506
347
  this.crs = extent.crs;
507
- return this.set(extent);
348
+ return this.setFromExtent(extent);
508
349
  }
509
350
 
510
351
  /**
511
352
  * Union this extent with the input extent.
512
- * @param {Extent} extent the extent to union.
353
+ * @param extent - the extent to union.
513
354
  */
514
355
  union(extent) {
515
356
  if (extent.crs != this.crs) {
@@ -540,7 +381,7 @@ class Extent {
540
381
  /**
541
382
  * expandByCoordinates perfoms the minimal extension
542
383
  * for the coordinates to belong to this Extent object
543
- * @param {Coordinates} coordinates The coordinates to belong
384
+ * @param coordinates - The coordinates to belong
544
385
  */
545
386
  expandByCoordinates(coordinates) {
546
387
  const coords = coordinates.crs == this.crs ? coordinates : coordinates.as(this.crs, _c);
@@ -550,8 +391,8 @@ class Extent {
550
391
  /**
551
392
  * expandByValuesCoordinates perfoms the minimal extension
552
393
  * for the coordinates values to belong to this Extent object
553
- * @param {number} we The coordinate on west-east
554
- * @param {number} sn The coordinate on south-north
394
+ * @param we - The coordinate on west-east
395
+ * @param sn - The coordinate on south-north
555
396
  *
556
397
  */
557
398
  expandByValuesCoordinates(we, sn) {
@@ -576,9 +417,8 @@ class Extent {
576
417
  * should be the geocentric coordinates of `min` and `max` of a `box3`
577
418
  * in local tangent plane.
578
419
  *
579
- * @param {string} crs Projection of extent to instancied.
580
- * @param {THREE.Box3} box
581
- * @return {Extent}
420
+ * @param crs - Projection of extent to instancied.
421
+ * @param box - Bounding-box
582
422
  */
583
423
  static fromBox3(crs, box) {
584
424
  if (CRS.isGeocentric(crs)) {
@@ -590,7 +430,7 @@ class Extent {
590
430
  cNorthEast.crs = crs;
591
431
  cNorthEast.setFromVector3(box.max).as(crs, cNorthEast).toVector3(box.max);
592
432
  }
593
- return new Extent(crs, {
433
+ return new Extent(crs).setFromExtent({
594
434
  west: box.min.x,
595
435
  east: box.max.x,
596
436
  south: box.min.y,
@@ -600,33 +440,29 @@ class Extent {
600
440
 
601
441
  /**
602
442
  * Return values of extent in string, separated by the separator input.
603
- * @param {string} separator
604
- * @return {string}
443
+ * @param sep - string separator
605
444
  */
606
445
  toString() {
607
- let separator = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
608
- if (CRS.isTms(this.crs)) {
609
- return `${this.zoom}${separator}${this.row}${separator}${this.col}`;
610
- } else {
611
- return `${this.east}${separator}${this.north}${separator}${this.west}${separator}${this.south}`;
612
- }
446
+ let sep = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
447
+ return `${this.east}${sep}${this.north}${sep}${this.west}${sep}${this.south}`;
613
448
  }
614
449
 
615
450
  /**
616
451
  * Subdivide equally an extent from its center to return four extents:
617
452
  * north-west, north-east, south-west and south-east.
618
453
  *
619
- * @returns {Extent[]} An array containing the four sections of the extent. The
620
- * order of the sections is [NW, NE, SW, SE].
454
+ * @returns An array containing the four sections of the extent. The order
455
+ * of the sections is [NW, NE, SW, SE].
621
456
  */
622
457
  subdivision() {
623
458
  return this.subdivisionByScheme();
624
459
  }
460
+
625
461
  /**
626
462
  * subdivise extent by scheme.x on west-east and scheme.y on south-north.
627
463
  *
628
- * @param {Vector2} [scheme=Vector2(2,2)] The scheme to subdivise.
629
- * @return {Array<Extent>} subdivised extents.
464
+ * @param scheme - The scheme to subdivise.
465
+ * @returns subdivised extents.
630
466
  */
631
467
  subdivisionByScheme() {
632
468
  let scheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultScheme;
@@ -643,39 +479,38 @@ class Extent {
643
479
  }
644
480
 
645
481
  /**
646
- * Multiplies all extent `coordinates` (with an implicit 1 in the 4th dimension) and `matrix`.
482
+ * Multiplies all extent `coordinates` (with an implicit 1 in the 4th
483
+ * dimension) and `matrix`.
647
484
  *
648
- * @param {THREE.Matrix4} matrix The matrix
649
- * @return {Extent} return this extent instance.
485
+ * @param matrix - The matrix
486
+ * @returns return this extent instance.
650
487
  */
651
488
  applyMatrix4(matrix) {
652
- if (!CRS.isTms(this.crs)) {
653
- southWest.set(this.west, this.south, 0).applyMatrix4(matrix);
654
- northEast.set(this.east, this.north, 0).applyMatrix4(matrix);
655
- this.west = southWest.x;
656
- this.east = northEast.x;
657
- this.south = southWest.y;
658
- this.north = northEast.y;
659
- if (this.west > this.east) {
660
- const temp = this.west;
661
- this.west = this.east;
662
- this.east = temp;
663
- }
664
- if (this.south > this.north) {
665
- const temp = this.south;
666
- this.south = this.north;
667
- this.north = temp;
668
- }
669
- return this;
489
+ southWest.set(this.west, this.south, 0).applyMatrix4(matrix);
490
+ northEast.set(this.east, this.north, 0).applyMatrix4(matrix);
491
+ this.west = southWest.x;
492
+ this.east = northEast.x;
493
+ this.south = southWest.y;
494
+ this.north = northEast.y;
495
+ if (this.west > this.east) {
496
+ const temp = this.west;
497
+ this.west = this.east;
498
+ this.east = temp;
499
+ }
500
+ if (this.south > this.north) {
501
+ const temp = this.south;
502
+ this.south = this.north;
503
+ this.north = temp;
670
504
  }
505
+ return this;
671
506
  }
672
507
 
673
508
  /**
674
509
  * clamp south and north values
675
510
  *
676
- * @param {number} [south=this.south] The min south
677
- * @param {number} [north=this.north] The max north
678
- * @return {Extent} this extent
511
+ * @param south - The min south
512
+ * @param north - The max north
513
+ * @returns this extent
679
514
  */
680
515
  clampSouthNorth() {
681
516
  let south = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.south;
@@ -688,9 +523,9 @@ class Extent {
688
523
  /**
689
524
  * clamp west and east values
690
525
  *
691
- * @param {number} [west=this.west] The min west
692
- * @param {number} [east=this.east] The max east
693
- * @return {Extent} this extent
526
+ * @param west - The min west
527
+ * @param east - The max east
528
+ * @returns this extent
694
529
  */
695
530
  clampWestEast() {
696
531
  let west = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.west;
@@ -699,28 +534,17 @@ class Extent {
699
534
  this.east = Math.min(this.east, east);
700
535
  return this;
701
536
  }
537
+
702
538
  /**
703
539
  * clamp this extent by passed extent
704
540
  *
705
- * @param {Extent} extent The maximum extent.
706
- * @return {Extent} this extent.
541
+ * @param extent - The maximum extent.
542
+ * @returns this extent.
707
543
  */
708
544
  clampByExtent(extent) {
709
545
  this.clampSouthNorth(extent.south, extent.north);
710
546
  return this.clampWestEast(extent.west, extent.east);
711
547
  }
712
548
  }
713
- _extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
714
- _extent2 = new Extent('EPSG:4326', [0, 0, 0, 0]);
715
- globalExtentTMS.set('EPSG:4326', new Extent('EPSG:4326', -180, 180, -90, 90));
716
-
717
- // Compute global extent of TMS in EPSG:3857
718
- // It's square whose a side is between -180° to 180°.
719
- // So, west extent, it's 180 convert in EPSG:3857
720
- const extent3857 = globalExtentTMS.get('EPSG:4326').as('EPSG:3857');
721
- extent3857.clampSouthNorth(extent3857.west, extent3857.east);
722
- globalExtentTMS.set('EPSG:3857', extent3857);
723
- schemeTiles.set('default', new THREE.Vector2(1, 1));
724
- schemeTiles.set(CRS.tms_3857, schemeTiles.get('default'));
725
- schemeTiles.set(CRS.tms_4326, new THREE.Vector2(2, 1));
549
+ _extent = new Extent('EPSG:4326');
726
550
  export default Extent;