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
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports["default"] = exports.ellipsoidSizes = void 0;
10
+ exports.ellipsoidSizes = exports["default"] = void 0;
11
11
 
12
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
13
 
@@ -34,6 +34,7 @@ var Ellipsoid = /*#__PURE__*/function () {
34
34
  this.size = new THREE.Vector3();
35
35
  this._radiiSquared = new THREE.Vector3();
36
36
  this._invRadiiSquared = new THREE.Vector3();
37
+ this.eccentricity = 0;
37
38
  this.setSize(size);
38
39
  }
39
40
 
@@ -62,6 +63,7 @@ var Ellipsoid = /*#__PURE__*/function () {
62
63
  this._invRadiiSquared.x = size.x == 0 ? 0 : 1 / this._radiiSquared.x;
63
64
  this._invRadiiSquared.y = size.y == 0 ? 0 : 1 / this._radiiSquared.y;
64
65
  this._invRadiiSquared.z = size.z == 0 ? 0 : 1 / this._radiiSquared.z;
66
+ this.eccentricity = Math.sqrt(this._radiiSquared.x - this._radiiSquared.z) / this.size.x;
65
67
  }
66
68
  }, {
67
69
  key: "cartographicToCartesian",
@@ -165,19 +167,35 @@ var Ellipsoid = /*#__PURE__*/function () {
165
167
  }, {
166
168
  key: "computeDistance",
167
169
  value: function computeDistance(coordCarto1, coordCarto2) {
170
+ console.warn('computeDistance is renamed to geodesicDistance');
171
+ this.geodesicDistance(coordCarto1, coordCarto2);
172
+ }
173
+ /**
174
+ * Calculate the geodesic distance, between coordCarto1 and coordCarto2.
175
+ * It's most short distance on ellipsoid surface between coordCarto1 and coordCarto2.
176
+ * It's called orthodromy.
177
+ *
178
+ * @param {Coordinates} coordCarto1 The coordinate carto 1
179
+ * @param {Coordinates} coordCarto2 The coordinate carto 2
180
+ * @return {number} The orthodromic distance between the two given coordinates.
181
+ */
182
+
183
+ }, {
184
+ key: "geodesicDistance",
185
+ value: function geodesicDistance(coordCarto1, coordCarto2) {
186
+ // The formula uses the distance on approximated sphere,
187
+ // with the nearest local radius of curvature of the ellipsoid
188
+ // https://geodesie.ign.fr/contenu/fichiers/Distance_longitude_latitude.pdf
168
189
  var longitude1 = THREE.MathUtils.degToRad(coordCarto1.longitude);
169
190
  var latitude1 = THREE.MathUtils.degToRad(coordCarto1.latitude);
170
191
  var longitude2 = THREE.MathUtils.degToRad(coordCarto2.longitude);
171
192
  var latitude2 = THREE.MathUtils.degToRad(coordCarto2.latitude);
172
193
  var distRad = Math.acos(Math.sin(latitude1) * Math.sin(latitude2) + Math.cos(latitude1) * Math.cos(latitude2) * Math.cos(longitude2 - longitude1));
173
- var a = this.size.x;
174
- var b = this.size.z;
175
- var e = Math.sqrt((a * a - b * b) / (a * a));
176
- var latMoy = (latitude1 + latitude2) / 2;
177
- var rho = a * (1 - e * e) / Math.sqrt(1 - e * e * Math.sin(latMoy) * Math.sin(latMoy));
178
- var N = a / Math.sqrt(1 - e * e * Math.sin(latMoy) * Math.sin(latMoy));
179
- var distMeter = distRad * Math.sqrt(rho * N);
180
- return distMeter;
194
+ var e = this.eccentricity;
195
+ var es = Math.pow(e * Math.sin((latitude1 + latitude2) * 0.5), 2);
196
+ var rho = this.size.x * (1 - Math.pow(e, 2)) / Math.pow(1 - es, 3 / 2);
197
+ var N = this.size.x / Math.sqrt(1 - es);
198
+ return distRad * Math.sqrt(rho * N);
181
199
  }
182
200
  }]);
183
201
  return Ellipsoid;
@@ -79,7 +79,7 @@ var BuilderEllipsoidTile = /*#__PURE__*/function () {
79
79
  longitude: 0,
80
80
  latitude: 0
81
81
  };
82
- params.extent.dimensions(this.tmp.dimension);
82
+ params.extent.planarDimensions(this.tmp.dimension);
83
83
  } // get center tile in cartesian 3D
84
84
 
85
85
  }, {
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports["default"] = void 0;
11
11
 
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
12
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
15
 
14
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -87,7 +89,7 @@ var Sky = /*#__PURE__*/function (_THREE$Mesh) {
87
89
  return _super.call(this, skyGeo, skyMat);
88
90
  }
89
91
 
90
- return Sky;
92
+ return (0, _createClass2["default"])(Sky);
91
93
  }(THREE.Mesh);
92
94
 
93
95
  var _default = Sky;
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports["default"] = void 0;
11
11
 
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
12
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
15
 
14
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -96,7 +98,7 @@ var PlanarLayer = /*#__PURE__*/function (_TiledGeometryLayer) {
96
98
  return _this;
97
99
  }
98
100
 
99
- return PlanarLayer;
101
+ return (0, _createClass2["default"])(PlanarLayer);
100
102
  }(_TiledGeometryLayer2["default"]);
101
103
 
102
104
  var _default = PlanarLayer;
@@ -81,7 +81,7 @@ var PlanarView = /*#__PURE__*/function (_View) {
81
81
  _this = _super.call(this, extent.crs, viewerDiv, options);
82
82
  _this.isPlanarView = true; // Configure camera
83
83
 
84
- var dim = extent.dimensions();
84
+ var dim = extent.planarDimensions();
85
85
  var max = Math.max(dim.x, dim.y);
86
86
  var camera3D = _this.camera.camera3D;
87
87
  camera3D.near = 0.1;
package/lib/Core/Style.js CHANGED
@@ -7,8 +7,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.readExpression = readExpression;
11
10
  exports["default"] = exports.cacheStyle = void 0;
11
+ exports.readExpression = readExpression;
12
12
 
13
13
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
14
14
 
@@ -472,6 +472,7 @@ var Style = /*#__PURE__*/function () {
472
472
  mapPropertiesFromContext('icon', this, style, context);
473
473
  }
474
474
 
475
+ style.order = this.order;
475
476
  return style;
476
477
  }
477
478
  /**
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports["default"] = void 0;
11
11
 
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
12
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
15
 
14
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -75,7 +77,7 @@ var TileGeometry = /*#__PURE__*/function (_THREE$BufferGeometry) {
75
77
  return _this;
76
78
  }
77
79
 
78
- return TileGeometry;
80
+ return (0, _createClass2["default"])(TileGeometry);
79
81
  }(THREE.BufferGeometry);
80
82
 
81
83
  var _default = TileGeometry;
@@ -96,35 +96,30 @@ var TileMesh = /*#__PURE__*/function (_THREE$Mesh) {
96
96
  _this.layerUpdateState = {};
97
97
  _this.isTileMesh = true;
98
98
  _this.domElements = {};
99
+ _this.geoidHeight = 0;
99
100
  return _this;
100
101
  }
101
102
  /**
102
103
  * If specified, update the min and max elevation of the OBB
103
104
  * and updates accordingly the bounding sphere and the geometric error
104
105
  *
105
- * @param {?number} min
106
- * @param {?number} max
107
- * @param {?number} scale
106
+ * @param {Object} elevation
107
+ * @param {number} [elevation.min]
108
+ * @param {number} [elevation.max]
109
+ * @param {number} [elevation.scale]
108
110
  */
109
111
 
110
112
 
111
113
  (0, _createClass2["default"])(TileMesh, [{
112
114
  key: "setBBoxZ",
113
- value: function setBBoxZ(min, max, scale) {
114
- if (min == null && max == null) {
115
- return;
116
- } // FIXME: Why the floors ? This is not conservative : the obb may be too short by almost 1m !
115
+ value: function setBBoxZ(elevation) {
116
+ this.obb.updateZ(elevation);
117
117
 
118
-
119
- if (Math.floor(min) !== Math.floor(this.obb.z.min) || Math.floor(max) !== Math.floor(this.obb.z.max)) {
120
- this.obb.updateZ(min, max, scale);
121
-
122
- if (this.horizonCullingPointElevationScaled) {
123
- this.horizonCullingPointElevationScaled.setLength(this.obb.z.delta + this.horizonCullingPoint.length());
124
- }
125
-
126
- this.obb.box3D.getBoundingSphere(this.boundingSphere);
118
+ if (this.horizonCullingPointElevationScaled) {
119
+ this.horizonCullingPointElevationScaled.setLength(this.obb.z.delta + this.horizonCullingPoint.length());
127
120
  }
121
+
122
+ this.obb.box3D.getBoundingSphere(this.boundingSphere);
128
123
  }
129
124
  }, {
130
125
  key: "getExtentsByProjection",
package/lib/Core/View.js CHANGED
@@ -80,7 +80,8 @@ var VIEW_EVENTS = {
80
80
  LAYER_REMOVED: 'layer-removed',
81
81
  LAYER_ADDED: 'layer-added',
82
82
  INITIALIZED: 'initialized',
83
- COLOR_LAYERS_ORDER_CHANGED: _ColorLayersOrdering.COLOR_LAYERS_ORDER_CHANGED
83
+ COLOR_LAYERS_ORDER_CHANGED: _ColorLayersOrdering.COLOR_LAYERS_ORDER_CHANGED,
84
+ CAMERA_MOVED: 'camera-moved'
84
85
  };
85
86
  /**
86
87
  * Fired on current view's domElement when double right-clicking it. Copies all properties of the second right-click
@@ -154,7 +155,8 @@ function _preprocessLayer(view, layer, parentLayer) {
154
155
  style: layer.style,
155
156
  zoom: layer.zoom,
156
157
  crs: source.crs,
157
- visible: layer.visible
158
+ visible: layer.visible,
159
+ margin: 15
158
160
  });
159
161
  layer.addEventListener('visible-property-changed', function () {
160
162
  labelLayer.visible = layer.visible;
@@ -242,7 +244,6 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
242
244
  _this = _super.call(this);
243
245
  _this.domElement = viewerDiv;
244
246
  _this.referenceCrs = crs;
245
- coordinates.crs = crs;
246
247
  var engine; // options.renderer can be 2 separate things:
247
248
  // - an actual renderer (in this case we don't use viewerDiv)
248
249
  // - options for the renderer to be created
@@ -1029,6 +1030,11 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1029
1030
  key: "getScale",
1030
1031
  value: function getScale() {
1031
1032
  var pitch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.28;
1033
+
1034
+ if (this.camera.camera3D.isOrthographicCamera) {
1035
+ return pitch * 1E-3 / this.getPixelsToMeters();
1036
+ }
1037
+
1032
1038
  return this.getScaleFromDistance(pitch, this.getDistanceFromCamera());
1033
1039
  }
1034
1040
  }, {
@@ -1191,13 +1197,13 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1191
1197
  }
1192
1198
 
1193
1199
  this.getPickingPositionFromDepth(mouse, positionVector);
1194
- var distance = this.camera.camera3D.position.distanceTo(positionVector);
1200
+ coordinates.crs = this.referenceCrs;
1195
1201
  coordinates.setFromVector3(positionVector); // Get the correct precision; the position variable will be set in this
1196
1202
  // function.
1197
1203
 
1198
1204
  var precision;
1199
1205
  var precisions = {
1200
- M: this.getPixelsToMetersFromDistance(radius, distance),
1206
+ M: this.getPixelsToMeters(radius, mouse),
1201
1207
  D: 0.001 * radius
1202
1208
  };
1203
1209
 
@@ -1394,6 +1400,38 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1394
1400
 
1395
1401
  return target;
1396
1402
  }
1403
+ /**
1404
+ * Returns the world {@link Coordinates} at given view coordinates.
1405
+ *
1406
+ * @param {THREE.Vector2|event} [mouse] The view coordinates at which the world coordinates must be
1407
+ * returned. This parameter can also be set to a mouse event from
1408
+ * which the view coordinates will be deducted. If not specified, it
1409
+ * will be defaulted to the view's center coordinates.
1410
+ * @param {Coordinates} [target] The result will be copied into this {@link Coordinates}. If not
1411
+ * specified, a new {@link Coordinates} instance will be created.
1412
+ *
1413
+ * @returns {Coordinates} The world {@link Coordinates} at the given view coordinates.
1414
+ */
1415
+
1416
+ }, {
1417
+ key: "pickCoordinates",
1418
+ value: function pickCoordinates(mouse) {
1419
+ var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _Coordinates["default"](this.tileLayer.extent.crs);
1420
+
1421
+ if (mouse instanceof Event) {
1422
+ this.eventToViewCoords(mouse);
1423
+ } else if (mouse.x !== undefined && mouse.y !== undefined) {
1424
+ _eventCoords.copy(mouse);
1425
+ } else {
1426
+ _eventCoords.set(this.mainLoop.gfxEngine.width / 2, this.mainLoop.gfxEngine.height / 2);
1427
+ }
1428
+
1429
+ this.getPickingPositionFromDepth(_eventCoords, positionVector);
1430
+ coordinates.crs = this.referenceCrs;
1431
+ coordinates.setFromVector3(positionVector);
1432
+ coordinates.as(target.crs, target);
1433
+ return target;
1434
+ }
1397
1435
  /**
1398
1436
  * Resize the viewer.
1399
1437
  *
@@ -71,7 +71,7 @@ var ElevationLayer = /*#__PURE__*/function (_RasterLayer) {
71
71
  * // Create an ElevationLayer
72
72
  * const elevation = new ElevationLayer('IGN_MNT', {
73
73
  * source: new WMTSSource({
74
- * "url": "https://wxs.ign.fr/3ht7xcw6f7nciopo16etuqp2/geoportail/wmts",
74
+ * "url": "https://wxs.ign.fr/altimetrie/geoportail/wmts",
75
75
  * "crs": "EPSG:4326",
76
76
  * "format": "image/x-bil;bits=32",
77
77
  * "name": "ELEVATION.ELEVATIONGRIDCOVERAGE",
@@ -87,22 +87,9 @@ var ElevationLayer = /*#__PURE__*/function (_RasterLayer) {
87
87
  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
88
88
  (0, _classCallCheck2["default"])(this, ElevationLayer);
89
89
  _this = _super.call(this, id, config);
90
- _this.isElevationLayer = true; // This is used to add a factor needed to color texture
90
+ _this.isElevationLayer = true;
91
91
 
92
- var baseScale = 1.0;
93
-
94
- if (_this.useColorTextureElevation) {
95
- baseScale = _this.colorTextureElevationMaxZ - _this.colorTextureElevationMinZ;
96
- }
97
-
98
- _this.defineLayerProperty('scale', _this.scale || 1.0, function (self) {
99
- self.parent.object3d.traverse(function (obj) {
100
- if (obj.layer == self.parent && obj.material) {
101
- obj.material.setElevationScale(self.scale * baseScale);
102
- obj.obb.updateScaleZ(self.scale);
103
- }
104
- });
105
- });
92
+ _this.defineLayerProperty('scale', _this.scale || 1.0);
106
93
 
107
94
  return _this;
108
95
  }
@@ -125,12 +112,22 @@ var ElevationLayer = /*#__PURE__*/function (_RasterLayer) {
125
112
  node.material.setSequenceElevation(this.id); // bounding box initialisation
126
113
 
127
114
  var updateBBox = function () {
128
- return node.setBBoxZ(rasterElevationNode.min, rasterElevationNode.max, _this2.scale);
115
+ return node.setBBoxZ({
116
+ min: rasterElevationNode.min,
117
+ max: rasterElevationNode.max,
118
+ scale: _this2.scale
119
+ });
129
120
  };
130
121
 
131
122
  updateBBox(); // listen elevation updating
132
123
 
133
- rasterElevationNode.addEventListener('updatedElevation', updateBBox);
124
+ rasterElevationNode.addEventListener('updatedElevation', updateBBox); // listen scaling elevation updating
125
+
126
+ this.addEventListener('scale-property-changed', updateBBox); // remove scaling elevation updating if node is removed
127
+
128
+ node.addEventListener('dispose', function () {
129
+ _this2.removeEventListener('scale-property-changed', updateBBox);
130
+ });
134
131
  return rasterElevationNode;
135
132
  }
136
133
  }, {
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+
10
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
13
 
12
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -71,7 +73,7 @@ var FeatureGeometryLayer = /*#__PURE__*/function (_GeometryLayer) {
71
73
  return _this;
72
74
  }
73
75
 
74
- return FeatureGeometryLayer;
76
+ return (0, _createClass2["default"])(FeatureGeometryLayer);
75
77
  }(_GeometryLayer2["default"]);
76
78
 
77
79
  var _default = FeatureGeometryLayer;
@@ -0,0 +1,131 @@
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 _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
+
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+
20
+ var _Layer2 = _interopRequireDefault(require("./Layer"));
21
+
22
+ var _LayerUpdateState = _interopRequireDefault(require("./LayerUpdateState"));
23
+
24
+ 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); }; }
25
+
26
+ 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; } }
27
+
28
+ /**
29
+ * `GeoidLayer` is a specific `{@link Layer}` which supports geoid height data. When added to a `{@link View}`, it
30
+ * vertically translates each of the view's tiles by a proper geoid height value. For a given tile, the geoid height
31
+ * value used for translation is the geoid height computed at the center of the tile.
32
+ *
33
+ * @example
34
+ * // Create a GeoidLayer from a GTX geoid heights file.
35
+ * const geoidLayer = new GeoidLayer('geoid', {
36
+ * source: new FileSource({
37
+ * url: 'url-to-some-GTX-geoid-heights-file.gtx',
38
+ * crs: 'EPSG:4326',
39
+ * format: 'application/gtx',
40
+ * }),
41
+ * });
42
+ */
43
+ var GeoidLayer = /*#__PURE__*/function (_Layer) {
44
+ (0, _inherits2["default"])(GeoidLayer, _Layer);
45
+
46
+ var _super = _createSuper(GeoidLayer);
47
+
48
+ /**
49
+ * Creates a new instance of `GeoidLayer`.
50
+ *
51
+ * @param {string} id An unique identifier for the layer.
52
+ * @param {Object} config The layer configuration. All elements in it will be merged as is in the
53
+ * layer. For example, if the configuration contains three elements `name,
54
+ * protocol, extent`, these elements will be available using `layer.name` or
55
+ * something else depending on the property name. Only `config.source`
56
+ * parameter is mandatory.
57
+ * @param {Object} config.source The source of the geoid data displayed by the `GeoidLayer`. It is mandatory
58
+ * that the source data for a `GeoidLayer` be parsed into a
59
+ * `{@link GeoidGrid}`. You can refer to `{@link GTXParser}`,
60
+ * `{@link GDFParser}` and `{@link ISGParser}` to see how three standard
61
+ * geoid height grid file formats are parsed into `{@link GeoidGrid}`.
62
+ */
63
+ function GeoidLayer(id) {
64
+ var _this;
65
+
66
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
67
+ (0, _classCallCheck2["default"])(this, GeoidLayer);
68
+ _this = _super.call(this, id, config);
69
+ _this.isGeoidLayer = true;
70
+
71
+ _this.defineLayerProperty('visible', true);
72
+
73
+ return _this;
74
+ }
75
+
76
+ (0, _createClass2["default"])(GeoidLayer, [{
77
+ key: "updateNodeZ",
78
+ value: function updateNodeZ(node, parent) {
79
+ node.position.z += (this.visible ? 1 : -1) * (node.geoidHeight - parent.geoidHeight);
80
+ node.updateMatrix();
81
+ node.updateMatrixWorld(true);
82
+ }
83
+ }, {
84
+ key: "update",
85
+ value: function update(context, layer, node, parent) {
86
+ var _this2 = this;
87
+
88
+ if (!parent || !node.material) {
89
+ return;
90
+ } // Don't update tile if its zoom is not within the layer's zoom limits
91
+
92
+
93
+ var extentsDestination = node.getExtentsByProjection(layer.crs);
94
+ var zoom = extentsDestination[0].zoom;
95
+
96
+ if (zoom > layer.zoom.max || zoom < layer.zoom.min) {
97
+ return;
98
+ }
99
+
100
+ if (node.layerUpdateState[layer.id] === undefined) {
101
+ node.layerUpdateState[layer.id] = new _LayerUpdateState["default"]();
102
+
103
+ var updateNodeZ = function () {
104
+ return _this2.updateNodeZ(node, parent);
105
+ };
106
+
107
+ layer.addEventListener('visible-property-changed', updateNodeZ);
108
+ node.addEventListener('dispose', function () {
109
+ layer.removeEventListener('visible-property-changed', updateNodeZ);
110
+ });
111
+ }
112
+
113
+ if (layer.frozen || !layer.visible || !node.material.visible || !node.layerUpdateState[layer.id].canTryUpdate()) {
114
+ return;
115
+ }
116
+
117
+ node.layerUpdateState[layer.id].newTry();
118
+ return this.getData(node.extent, extentsDestination).then(function (result) {
119
+ node.geoidHeight = result.getHeightAtCoordinates(node.extent.center());
120
+
121
+ _this2.updateNodeZ(node, parent);
122
+
123
+ node.layerUpdateState[layer.id].noMoreUpdatePossible();
124
+ });
125
+ }
126
+ }]);
127
+ return GeoidLayer;
128
+ }(_Layer2["default"]);
129
+
130
+ var _default = GeoidLayer;
131
+ exports["default"] = _default;
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.InfoTiledGeometryLayer = exports["default"] = void 0;
8
+ exports["default"] = exports.InfoTiledGeometryLayer = void 0;
9
9
 
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
 
@@ -101,7 +101,12 @@ var LabelLayer = /*#__PURE__*/function (_Layer) {
101
101
  });
102
102
 
103
103
  _this.buildExtent = true;
104
- _this.labelDomelement = config.domElement;
104
+ _this.labelDomelement = config.domElement; // The margin property defines a space around each label that cannot be occupied by another label.
105
+ // For example, if some labelLayer has a margin value of 5, there will be at least 10 pixels
106
+ // between each labels of the layer
107
+ // TODO : this property should be moved to Style after refactoring style properties structure
108
+
109
+ _this.margin = config.margin;
105
110
  return _this;
106
111
  }
107
112
  /**
@@ -186,6 +191,7 @@ var LabelLayer = /*#__PURE__*/function (_Layer) {
186
191
 
187
192
  var label = new _Label["default"](content, coord.clone(), style, _this2.source.sprites);
188
193
  label.layerId = _this2.id;
194
+ label.padding = _this2.margin || label.padding;
189
195
 
190
196
  if (f.size == 2) {
191
197
  label.needsAltitude = true;
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.ImageryLayers = exports["default"] = void 0;
10
+ exports["default"] = exports.ImageryLayers = void 0;
11
11
 
12
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
13
 
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.STRATEGY_PROGRESSIVE = exports.STRATEGY_MIN_NETWORK_TRAFFIC = exports.STRATEGY_GROUP = exports.STRATEGY_DICHOTOMY = void 0;
6
7
  exports.chooseNextLevelToFetch = chooseNextLevelToFetch;
7
- exports.STRATEGY_DICHOTOMY = exports.STRATEGY_PROGRESSIVE = exports.STRATEGY_GROUP = exports.STRATEGY_MIN_NETWORK_TRAFFIC = void 0;
8
8
 
9
9
  var _RasterTile = require("../Renderer/RasterTile");
10
10
 
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports["default"] = void 0;
11
11
 
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
12
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
15
 
14
16
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -114,7 +116,7 @@ var PotreeLayer = /*#__PURE__*/function (_PointCloudLayer) {
114
116
  return _this;
115
117
  }
116
118
 
117
- return PotreeLayer;
119
+ return (0, _createClass2["default"])(PotreeLayer);
118
120
  }(_PointCloudLayer2["default"]);
119
121
 
120
122
  var _default = PotreeLayer;
@@ -118,7 +118,9 @@ var TiledGeometryLayer = /*#__PURE__*/function (_GeometryLayer) {
118
118
  config.cacheLifeTime = _Cache.CACHE_POLICIES.INFINITE;
119
119
  config.source = false;
120
120
  _this = _super.call(this, id, object3d, config);
121
- _this.isTiledGeometryLayer = true;
121
+ _this.isTiledGeometryLayer = true; // TODO : this should be add in a preprocess method specific to GeoidLayer.
122
+
123
+ _this.object3d.geoidHeight = 0;
122
124
  _this.protocol = 'tile';
123
125
  _this.sseSubdivisionThreshold = _this.sseSubdivisionThreshold || 1.0;
124
126
  _this.schemeTile = schemeTile;