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
package/lib/Core/View.js CHANGED
@@ -23,6 +23,10 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
23
23
 
24
24
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
25
25
 
26
+ var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
27
+
28
+ var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
29
+
26
30
  var THREE = _interopRequireWildcard(require("three"));
27
31
 
28
32
  var _Camera = _interopRequireDefault(require("../Renderer/Camera"));
@@ -65,6 +69,10 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
65
69
 
66
70
  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; } }
67
71
 
72
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
73
+
74
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
75
+
68
76
  var VIEW_EVENTS = {
69
77
  /**
70
78
  * Fires when all the layers of the view are considered initialized.
@@ -80,7 +88,8 @@ var VIEW_EVENTS = {
80
88
  LAYER_REMOVED: 'layer-removed',
81
89
  LAYER_ADDED: 'layer-added',
82
90
  INITIALIZED: 'initialized',
83
- COLOR_LAYERS_ORDER_CHANGED: _ColorLayersOrdering.COLOR_LAYERS_ORDER_CHANGED
91
+ COLOR_LAYERS_ORDER_CHANGED: _ColorLayersOrdering.COLOR_LAYERS_ORDER_CHANGED,
92
+ CAMERA_MOVED: 'camera-moved'
84
93
  };
85
94
  /**
86
95
  * Fired on current view's domElement when double right-clicking it. Copies all properties of the second right-click
@@ -191,6 +200,12 @@ var viewers = []; // Size of the camera frustrum, in meters
191
200
 
192
201
  var screenMeters;
193
202
 
203
+ var _layers = /*#__PURE__*/new WeakMap();
204
+
205
+ var _pixelDepthBuffer = /*#__PURE__*/new WeakMap();
206
+
207
+ var _fullSizeDepthBuffer = /*#__PURE__*/new WeakMap();
208
+
194
209
  var View = /*#__PURE__*/function (_THREE$EventDispatche) {
195
210
  (0, _inherits2["default"])(View, _THREE$EventDispatche);
196
211
 
@@ -241,9 +256,24 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
241
256
  }
242
257
 
243
258
  _this = _super.call(this);
259
+
260
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _layers, {
261
+ writable: true,
262
+ value: []
263
+ });
264
+
265
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _pixelDepthBuffer, {
266
+ writable: true,
267
+ value: new Uint8Array(4)
268
+ });
269
+
270
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _fullSizeDepthBuffer, {
271
+ writable: true,
272
+ value: void 0
273
+ });
274
+
244
275
  _this.domElement = viewerDiv;
245
276
  _this.referenceCrs = crs;
246
- coordinates.crs = crs;
247
277
  var engine; // options.renderer can be 2 separate things:
248
278
  // - an actual renderer (in this case we don't use viewerDiv)
249
279
  // - options for the renderer to be created
@@ -263,7 +293,6 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
263
293
 
264
294
  _this.camera = new _Camera["default"](_this.referenceCrs, _this.mainLoop.gfxEngine.getWindowSize().x, _this.mainLoop.gfxEngine.getWindowSize().y, options.camera);
265
295
  _this._frameRequesters = {};
266
- _this._layers = [];
267
296
  window.addEventListener('resize', function () {
268
297
  return _this.resize();
269
298
  }, false);
@@ -297,8 +326,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
297
326
 
298
327
  _this.addEventListener(VIEW_EVENTS.LAYERS_INITIALIZED, fn);
299
328
 
300
- _this._fullSizeDepthBuffer = new Uint8Array(4 * _this.camera.width * _this.camera.height);
301
- _this._pixelDepthBuffer = new Uint8Array(4); // Indicates that view's domElement can be focused (the negative value indicates that domElement can't be
329
+ (0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _fullSizeDepthBuffer, new Uint8Array(4 * _this.camera.width * _this.camera.height)); // Indicates that view's domElement can be focused (the negative value indicates that domElement can't be
302
330
  // focused sequentially using tab key). Focus is needed to capture some key events.
303
331
 
304
332
  _this.domElement.tabIndex = -1; // Set focus on view's domElement.
@@ -469,7 +497,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
469
497
  return layer._reject(new Error('Cant add GeometryLayer: missing a preUpdate function'));
470
498
  }
471
499
 
472
- this._layers.push(layer);
500
+ (0, _classPrivateFieldGet2["default"])(this, _layers).push(layer);
473
501
  }
474
502
 
475
503
  if (layer.object3d && !layer.object3d.parent && layer.object3d !== this.scene) {
@@ -514,7 +542,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
514
542
  throw new Error("Error to detach ".concat(layerId, " from ").concat(parentLayer.id));
515
543
  } else if (parentLayer == undefined) {
516
544
  // Remove layer from viewer
517
- this._layers.splice(this._layers.findIndex(function (l) {
545
+ (0, _classPrivateFieldGet2["default"])(this, _layers).splice((0, _classPrivateFieldGet2["default"])(this, _layers).findIndex(function (l) {
518
546
  return l.id == layerId;
519
547
  }), 1);
520
548
  }
@@ -596,7 +624,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
596
624
  this._changeSources.add(changeSource);
597
625
 
598
626
  if (changeSource.isTileMesh || changeSource.isCamera) {
599
- this._fullSizeDepthBuffer.needsUpdate = true;
627
+ (0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer).needsUpdate = true;
600
628
  }
601
629
  }
602
630
 
@@ -627,7 +655,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
627
655
  value: function getLayers(filter) {
628
656
  var result = [];
629
657
 
630
- var _iterator6 = _createForOfIteratorHelper(this._layers),
658
+ var _iterator6 = _createForOfIteratorHelper((0, _classPrivateFieldGet2["default"])(this, _layers)),
631
659
  _step6;
632
660
 
633
661
  try {
@@ -1030,6 +1058,11 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1030
1058
  key: "getScale",
1031
1059
  value: function getScale() {
1032
1060
  var pitch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.28;
1061
+
1062
+ if (this.camera.camera3D.isOrthographicCamera) {
1063
+ return pitch * 1E-3 / this.getPixelsToMeters();
1064
+ }
1065
+
1033
1066
  return this.getScaleFromDistance(pitch, this.getDistanceFromCamera());
1034
1067
  }
1035
1068
  }, {
@@ -1192,6 +1225,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1192
1225
  }
1193
1226
 
1194
1227
  this.getPickingPositionFromDepth(mouse, positionVector);
1228
+ coordinates.crs = this.referenceCrs;
1195
1229
  coordinates.setFromVector3(positionVector); // Get the correct precision; the position variable will be set in this
1196
1230
  // function.
1197
1231
 
@@ -1349,15 +1383,15 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1349
1383
  var buffer;
1350
1384
 
1351
1385
  if (viewPaused) {
1352
- if (this._fullSizeDepthBuffer.needsUpdate) {
1353
- this.readDepthBuffer(0, 0, dim.x, dim.y, this._fullSizeDepthBuffer);
1354
- this._fullSizeDepthBuffer.needsUpdate = false;
1386
+ if ((0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer).needsUpdate) {
1387
+ this.readDepthBuffer(0, 0, dim.x, dim.y, (0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer));
1388
+ (0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer).needsUpdate = false;
1355
1389
  }
1356
1390
 
1357
1391
  var id = ((dim.y - mouse.y - 1) * dim.x + mouse.x) * 4;
1358
- buffer = this._fullSizeDepthBuffer.slice(id, id + 4);
1392
+ buffer = (0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer).slice(id, id + 4);
1359
1393
  } else {
1360
- buffer = this.readDepthBuffer(mouse.x, mouse.y, 1, 1, this._pixelDepthBuffer);
1394
+ buffer = this.readDepthBuffer(mouse.x, mouse.y, 1, 1, (0, _classPrivateFieldGet2["default"])(this, _pixelDepthBuffer));
1361
1395
  }
1362
1396
 
1363
1397
  screen.x = mouse.x / dim.x * 2 - 1;
@@ -1394,6 +1428,38 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1394
1428
 
1395
1429
  return target;
1396
1430
  }
1431
+ /**
1432
+ * Returns the world {@link Coordinates} at given view coordinates.
1433
+ *
1434
+ * @param {THREE.Vector2|event} [mouse] The view coordinates at which the world coordinates must be
1435
+ * returned. This parameter can also be set to a mouse event from
1436
+ * which the view coordinates will be deducted. If not specified, it
1437
+ * will be defaulted to the view's center coordinates.
1438
+ * @param {Coordinates} [target] The result will be copied into this {@link Coordinates}. If not
1439
+ * specified, a new {@link Coordinates} instance will be created.
1440
+ *
1441
+ * @returns {Coordinates} The world {@link Coordinates} at the given view coordinates.
1442
+ */
1443
+
1444
+ }, {
1445
+ key: "pickCoordinates",
1446
+ value: function pickCoordinates(mouse) {
1447
+ var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _Coordinates["default"](this.tileLayer.extent.crs);
1448
+
1449
+ if (mouse instanceof Event) {
1450
+ this.eventToViewCoords(mouse);
1451
+ } else if (mouse && mouse.x !== undefined && mouse.y !== undefined) {
1452
+ _eventCoords.copy(mouse);
1453
+ } else {
1454
+ _eventCoords.set(this.mainLoop.gfxEngine.width / 2, this.mainLoop.gfxEngine.height / 2);
1455
+ }
1456
+
1457
+ this.getPickingPositionFromDepth(_eventCoords, positionVector);
1458
+ coordinates.crs = this.referenceCrs;
1459
+ coordinates.setFromVector3(positionVector);
1460
+ coordinates.as(target.crs, target);
1461
+ return target;
1462
+ }
1397
1463
  /**
1398
1464
  * Resize the viewer.
1399
1465
  *
@@ -1414,7 +1480,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1414
1480
  height = this.domElement.clientHeight;
1415
1481
  }
1416
1482
 
1417
- this._fullSizeDepthBuffer = new Uint8Array(4 * width * height);
1483
+ (0, _classPrivateFieldSet2["default"])(this, _fullSizeDepthBuffer, new Uint8Array(4 * width * height));
1418
1484
  this.mainLoop.gfxEngine.onWindowResize(width, height);
1419
1485
  this.camera.resize(width, height);
1420
1486
  this.notifyChange(this.camera.camera3D);
@@ -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",
@@ -112,7 +112,11 @@ var ElevationLayer = /*#__PURE__*/function (_RasterLayer) {
112
112
  node.material.setSequenceElevation(this.id); // bounding box initialisation
113
113
 
114
114
  var updateBBox = function () {
115
- 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
+ });
116
120
  };
117
121
 
118
122
  updateBBox(); // listen elevation updating
@@ -9,6 +9,8 @@ exports["default"] = void 0;
9
9
 
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
 
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
12
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
15
 
14
16
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -49,28 +51,55 @@ var FeatureGeometryLayer = /*#__PURE__*/function (_GeometryLayer) {
49
51
  * @param {string} id - The id of the layer, that should be unique. It is
50
52
  * not mandatory, but an error will be emitted if this layer is added a
51
53
  * {@link View} that already has a layer going by that id.
52
- * @param {Object} [config] - Optional configuration, all elements in it
54
+ * @param {Object} [options] - Optional configuration, all elements in it
53
55
  * will be merged as is in the layer.
54
56
  * @param {function} [options.batchId] - optional function to create batchId attribute.
55
57
  * It is passed the feature property and the feature index.
56
58
  * As the batchId is using an unsigned int structure on 32 bits, the batchId could be between 0 and 4,294,967,295.
57
- * @param {THREE.Object3D} [config.object3d=new THREE.Group()] root object3d layer.
59
+ * @param {THREE.Object3D} [options.object3d=new THREE.Group()] root object3d layer.
60
+ * @param {function} [options.onMeshCreated] this callback is called when the mesh is created. The callback parameters are the
61
+ * `mesh` and the `context`.
62
+ * @param {boolean} [options.accurate=TRUE] If `accurate` is `true`, data are re-projected with maximum geographical accuracy.
63
+ * With `true`, `proj4` is used to transform data source.
64
+ *
65
+ * If `accurate` is `false`, re-projecting is faster but less accurate.
66
+ * With `false`, an affine transformation is used to transform data source.
67
+ * This method is an approximation. The error increases with the extent
68
+ * dimension of the object or queries.
58
69
  *
70
+ * For example :
71
+ * * for a **100** meter dimension, there's a difference of **0.001** meter with the accurate method
72
+ * * for a **500** meter dimension, there's a difference of **0.05** meter with the accurate method
73
+ * * for a **20000** meter dimension, there's a difference of **40** meter with the accurate method
74
+ *
75
+ * **WARNING** If the source is `VectorTilesSource` then `accurate` is always false.
59
76
  */
60
77
  function FeatureGeometryLayer(id) {
78
+ var _options$accurate;
79
+
61
80
  var _this;
62
81
 
63
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
82
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
64
83
  (0, _classCallCheck2["default"])(this, FeatureGeometryLayer);
65
- config.update = _FeatureProcessing["default"].update;
66
- config.convert = _Feature2Mesh["default"].convert({
67
- batchId: config.batchId
84
+ options.update = _FeatureProcessing["default"].update;
85
+ options.convert = _Feature2Mesh["default"].convert({
86
+ batchId: options.batchId
68
87
  });
69
- _this = _super.call(this, id, config.object3d || new _three.Group(), config);
88
+ _this = _super.call(this, id, options.object3d || new _three.Group(), options);
70
89
  _this.isFeatureGeometryLayer = true;
90
+ _this.accurate = (_options$accurate = options.accurate) !== null && _options$accurate !== void 0 ? _options$accurate : true;
91
+ _this.buildExtent = !_this.accurate;
71
92
  return _this;
72
93
  }
73
94
 
95
+ (0, _createClass2["default"])(FeatureGeometryLayer, [{
96
+ key: "preUpdate",
97
+ value: function preUpdate(context, sources) {
98
+ if (sources.has(this.parent)) {
99
+ this.object3d.clear();
100
+ }
101
+ }
102
+ }]);
74
103
  return FeatureGeometryLayer;
75
104
  }(_GeometryLayer2["default"]);
76
105
 
@@ -0,0 +1,142 @@
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
+ exports.geoidLayerIsVisible = geoidLayerIsVisible;
10
+
11
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
+
13
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
+
15
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
+
17
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
18
+
19
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
20
+
21
+ var _Layer2 = _interopRequireDefault(require("./Layer"));
22
+
23
+ var _LayerUpdateState = _interopRequireDefault(require("./LayerUpdateState"));
24
+
25
+ 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); }; }
26
+
27
+ 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; } }
28
+
29
+ function geoidLayerIsVisible(tilelayer) {
30
+ var _tilelayer$attachedLa;
31
+
32
+ return tilelayer === null || tilelayer === void 0 ? void 0 : (_tilelayer$attachedLa = tilelayer.attachedLayers.filter(function (l) {
33
+ return l.isGeoidLayer;
34
+ })[0]) === null || _tilelayer$attachedLa === void 0 ? void 0 : _tilelayer$attachedLa.visible;
35
+ }
36
+ /**
37
+ * `GeoidLayer` is a specific `{@link Layer}` which supports geoid height data. When added to a `{@link View}`, it
38
+ * vertically translates each of the view's tiles by a proper geoid height value. For a given tile, the geoid height
39
+ * value used for translation is the geoid height computed at the center of the tile.
40
+ *
41
+ * @example
42
+ * // Create a GeoidLayer from a GTX geoid heights file.
43
+ * const geoidLayer = new GeoidLayer('geoid', {
44
+ * source: new FileSource({
45
+ * url: 'url-to-some-GTX-geoid-heights-file.gtx',
46
+ * crs: 'EPSG:4326',
47
+ * format: 'application/gtx',
48
+ * }),
49
+ * });
50
+ */
51
+
52
+
53
+ var GeoidLayer = /*#__PURE__*/function (_Layer) {
54
+ (0, _inherits2["default"])(GeoidLayer, _Layer);
55
+
56
+ var _super = _createSuper(GeoidLayer);
57
+
58
+ /**
59
+ * Creates a new instance of `GeoidLayer`.
60
+ *
61
+ * @param {string} id An unique identifier for the layer.
62
+ * @param {Object} config The layer configuration. All elements in it will be merged as is in the
63
+ * layer. For example, if the configuration contains three elements `name,
64
+ * protocol, extent`, these elements will be available using `layer.name` or
65
+ * something else depending on the property name. Only `config.source`
66
+ * parameter is mandatory.
67
+ * @param {Object} config.source The source of the geoid data displayed by the `GeoidLayer`. It is mandatory
68
+ * that the source data for a `GeoidLayer` be parsed into a
69
+ * `{@link GeoidGrid}`. You can refer to `{@link GTXParser}`,
70
+ * `{@link GDFParser}` and `{@link ISGParser}` to see how three standard
71
+ * geoid height grid file formats are parsed into `{@link GeoidGrid}`.
72
+ */
73
+ function GeoidLayer(id) {
74
+ var _this;
75
+
76
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
77
+ (0, _classCallCheck2["default"])(this, GeoidLayer);
78
+ _this = _super.call(this, id, config);
79
+ _this.isGeoidLayer = true;
80
+
81
+ _this.defineLayerProperty('visible', true);
82
+
83
+ return _this;
84
+ }
85
+
86
+ (0, _createClass2["default"])(GeoidLayer, [{
87
+ key: "updateNodeZ",
88
+ value: function updateNodeZ(node) {
89
+ node.material.geoidHeight = this.visible ? node.geoidHeight : 0;
90
+ node.obb.updateZ({
91
+ geoidHeight: node.material.geoidHeight
92
+ });
93
+ }
94
+ }, {
95
+ key: "update",
96
+ value: function update(context, layer, node, parent) {
97
+ var _this2 = this;
98
+
99
+ if (!parent || !node.material) {
100
+ return;
101
+ } // Don't update tile if its zoom is not within the layer's zoom limits
102
+
103
+
104
+ var extentsDestination = node.getExtentsByProjection(layer.crs);
105
+ var zoom = extentsDestination[0].zoom;
106
+
107
+ if (zoom > layer.zoom.max || zoom < layer.zoom.min) {
108
+ return;
109
+ }
110
+
111
+ if (node.layerUpdateState[layer.id] === undefined) {
112
+ node.layerUpdateState[layer.id] = new _LayerUpdateState["default"]();
113
+
114
+ var updateNodeZ = function () {
115
+ return _this2.updateNodeZ(node);
116
+ };
117
+
118
+ layer.addEventListener('visible-property-changed', updateNodeZ);
119
+ node.addEventListener('dispose', function () {
120
+ layer.removeEventListener('visible-property-changed', updateNodeZ);
121
+ });
122
+ }
123
+
124
+ if (layer.frozen || !layer.visible || !node.material.visible || !node.layerUpdateState[layer.id].canTryUpdate()) {
125
+ return;
126
+ }
127
+
128
+ node.layerUpdateState[layer.id].newTry();
129
+ return this.getData(node.extent, extentsDestination).then(function (result) {
130
+ node.geoidHeight = result.getHeightAtCoordinates(node.extent.center());
131
+
132
+ _this2.updateNodeZ(node);
133
+
134
+ node.layerUpdateState[layer.id].noMoreUpdatePossible();
135
+ });
136
+ }
137
+ }]);
138
+ return GeoidLayer;
139
+ }(_Layer2["default"]);
140
+
141
+ var _default = GeoidLayer;
142
+ exports["default"] = _default;
@@ -140,11 +140,13 @@ var GeometryLayer = /*#__PURE__*/function (_Layer) {
140
140
  * view.addLayer(geometry);
141
141
  */
142
142
  function GeometryLayer(id, object3d) {
143
+ var _config$cacheLifeTime;
144
+
143
145
  var _this;
144
146
 
145
147
  var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
146
148
  (0, _classCallCheck2["default"])(this, GeometryLayer);
147
- config.cacheLifeTime = config.cacheLifeTime == undefined ? _Cache.CACHE_POLICIES.GEOMETRY : config.cacheLifeTime;
149
+ config.cacheLifeTime = (_config$cacheLifeTime = config.cacheLifeTime) !== null && _config$cacheLifeTime !== void 0 ? _config$cacheLifeTime : _Cache.CACHE_POLICIES.GEOMETRY;
148
150
  _this = _super.call(this, id, config);
149
151
  _this.isGeometryLayer = true;
150
152
 
@@ -161,33 +163,8 @@ var GeometryLayer = /*#__PURE__*/function (_Layer) {
161
163
  writable: false,
162
164
  configurable: true
163
165
  });
164
-
165
- _this.defineLayerProperty('opacity', 1.0, function () {
166
- var root = _this.parent ? _this.parent.object3d : _this.object3d;
167
- root.traverse(function (object) {
168
- if (object.layer == (0, _assertThisInitialized2["default"])(_this)) {
169
- _this.changeOpacity(object);
170
- } else if (object.content && object.content.layer == (0, _assertThisInitialized2["default"])(_this)) {
171
- object.content.traverse(_this.changeOpacity);
172
- }
173
- });
174
- });
175
-
176
- _this.defineLayerProperty('wireframe', false, function () {
177
- var root = _this.parent ? _this.parent.object3d : _this.object3d;
178
- root.traverse(function (object) {
179
- if (object.layer == (0, _assertThisInitialized2["default"])(_this) && object.material) {
180
- object.material.wireframe = _this.wireframe;
181
- } else if (object.content && object.content.layer == (0, _assertThisInitialized2["default"])(_this)) {
182
- object.content.traverse(function (o) {
183
- if (o.material && o.layer == (0, _assertThisInitialized2["default"])(_this)) {
184
- o.material.wireframe = _this.wireframe;
185
- }
186
- });
187
- }
188
- });
189
- });
190
-
166
+ _this.opacity = 1.0;
167
+ _this.wireframe = false;
191
168
  _this.attachedLayers = [];
192
169
  _this.visible = config.visible == undefined ? true : config.visible;
193
170
  Object.defineProperty(_this.zoom, 'max', {
@@ -311,32 +288,7 @@ var GeometryLayer = /*#__PURE__*/function (_Layer) {
311
288
  value: function pickObjectsAt(view, coordinates) {
312
289
  var radius = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.options.defaultPickingRadius;
313
290
  var target = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
314
- var object3d = this.parent ? this.parent.object3d : this.object3d;
315
- return _Picking["default"].pickObjectsAt(view, coordinates, radius, object3d, target, this.threejsLayer);
316
- }
317
- /**
318
- * Change the opacity of an object, according to the value of the `opacity`
319
- * property of this layer.
320
- *
321
- * @param {Object} object - The object to change the opacity from. It is
322
- * usually a `THREE.Object3d` or an implementation of it.
323
- */
324
-
325
- }, {
326
- key: "changeOpacity",
327
- value: function changeOpacity(object) {
328
- if (object.material) {
329
- // != undefined: we want the test to pass if opacity is 0
330
- if (object.material.opacity != undefined) {
331
- object.material.transparent = this.opacity < 1.0;
332
- object.material.opacity = this.opacity;
333
- }
334
-
335
- if (object.material.uniforms && object.material.uniforms.opacity != undefined) {
336
- object.material.transparent = this.opacity < 1.0;
337
- object.material.uniforms.opacity.value = this.opacity;
338
- }
339
- }
291
+ return _Picking["default"].pickObjectsAt(view, coordinates, radius, this.object3d, target, this.threejsLayer);
340
292
  }
341
293
  }]);
342
294
  return GeometryLayer;
@@ -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
 
@@ -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
 
@@ -188,6 +188,7 @@ var OrientedImageLayer = /*#__PURE__*/function (_GeometryLayer) {
188
188
 
189
189
  _this.mergeFeatures = false;
190
190
  _this.filteringExtent = false;
191
+ _this.accurate = true;
191
192
  var options = {
192
193
  out: (0, _assertThisInitialized2["default"])(_this)
193
194
  }; // panos is an array of feature point, representing many panoramics.
@@ -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;
@@ -41,8 +41,10 @@ var RasterLayer = /*#__PURE__*/function (_Layer) {
41
41
  var _super = _createSuper(RasterLayer);
42
42
 
43
43
  function RasterLayer(id, config) {
44
+ var _config$cacheLifeTime;
45
+
44
46
  (0, _classCallCheck2["default"])(this, RasterLayer);
45
- config.cacheLifeTime = config.cacheLifeTime == undefined ? _Cache.CACHE_POLICIES.TEXTURE : config.cacheLifeTime;
47
+ config.cacheLifeTime = (_config$cacheLifeTime = config.cacheLifeTime) !== null && _config$cacheLifeTime !== void 0 ? _config$cacheLifeTime : _Cache.CACHE_POLICIES.TEXTURE;
46
48
  return _super.call(this, id, config);
47
49
  }
48
50
 
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ // next step is move these properties to Style class
9
+ // and hide transparent mechanism
10
+ function ReferLayerProperties(material, layer) {
11
+ if (layer && layer.isGeometryLayer) {
12
+ var transparent = material.transparent;
13
+ material.layer = layer;
14
+
15
+ if (material.uniforms && material.uniforms.opacity != undefined) {
16
+ Object.defineProperty(material.uniforms.opacity, 'value', {
17
+ get: function get() {
18
+ return material.layer.opacity;
19
+ }
20
+ });
21
+ } else if (material.opacity != undefined) {
22
+ Object.defineProperty(material, 'opacity', {
23
+ get: function get() {
24
+ return material.layer.opacity;
25
+ }
26
+ });
27
+ }
28
+
29
+ Object.defineProperty(material, 'wireframe', {
30
+ get: function get() {
31
+ return material.layer.wireframe;
32
+ }
33
+ });
34
+ Object.defineProperty(material, 'transparent', {
35
+ get: function get() {
36
+ if (transparent != material.layer.opacity < 1.0) {
37
+ material.needsUpdate = true;
38
+ transparent = material.layer.opacity < 1.0;
39
+ }
40
+
41
+ return transparent;
42
+ }
43
+ });
44
+ }
45
+
46
+ return material;
47
+ }
48
+
49
+ var _default = ReferLayerProperties;
50
+ exports["default"] = _default;
@@ -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;