itowns 2.37.0 → 2.38.2

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 (77) hide show
  1. package/README.md +12 -1
  2. package/changelog.md +101 -0
  3. package/dist/debug.js +1 -1
  4. package/dist/debug.js.LICENSE.txt +2 -2
  5. package/dist/debug.js.map +1 -1
  6. package/dist/itowns.js +1 -1
  7. package/dist/itowns.js.LICENSE.txt +2 -2
  8. package/dist/itowns.js.map +1 -1
  9. package/dist/itowns_widgets.js +1 -1
  10. package/dist/itowns_widgets.js.map +1 -1
  11. package/examples/config.json +4 -1
  12. package/examples/css/example.css +21 -1
  13. package/examples/css/widgets.css +118 -6
  14. package/examples/images/code-logo.svg +43 -0
  15. package/examples/index.html +5 -5
  16. package/examples/mars.html +0 -1
  17. package/examples/misc_orthographic_camera.html +7 -19
  18. package/examples/vector_tile_3d_mesh.html +155 -0
  19. package/examples/vector_tile_raster_3d.html +0 -5
  20. package/examples/view_25d_map.html +6 -19
  21. package/examples/view_2d_map.html +6 -19
  22. package/examples/view_3d_map.html +106 -81
  23. package/examples/widgets_minimap.html +3 -1
  24. package/examples/widgets_navigation.html +6 -1
  25. package/examples/widgets_scale.html +96 -0
  26. package/examples/widgets_searchbar.html +124 -0
  27. package/lib/Controls/PlanarControls.js +10 -42
  28. package/lib/Converter/Feature2Mesh.js +225 -61
  29. package/lib/Converter/Feature2Texture.js +4 -3
  30. package/lib/Converter/convertToTile.js +10 -5
  31. package/lib/Core/Feature.js +57 -30
  32. package/lib/Core/MainLoop.js +136 -62
  33. package/lib/Core/TileMesh.js +21 -5
  34. package/lib/Core/View.js +46 -15
  35. package/lib/Layer/FeatureGeometryLayer.js +37 -10
  36. package/lib/Layer/GeoidLayer.js +17 -6
  37. package/lib/Layer/GeometryLayer.js +6 -54
  38. package/lib/Layer/OrientedImageLayer.js +1 -0
  39. package/lib/Layer/RasterLayer.js +3 -1
  40. package/lib/Layer/ReferencingLayerProperties.js +50 -0
  41. package/lib/Main.js +1 -1
  42. package/lib/Parser/B3dmParser.js +3 -2
  43. package/lib/Parser/GeoJsonParser.js +29 -7
  44. package/lib/Parser/VectorTileParser.js +5 -4
  45. package/lib/Parser/deprecated/LegacyGLTFLoader.js +3 -3
  46. package/lib/Process/3dTilesProcessing.js +3 -3
  47. package/lib/Process/FeatureProcessing.js +36 -86
  48. package/lib/Process/LayeredMaterialNodeProcessing.js +9 -3
  49. package/lib/Process/ObjectRemovalHelper.js +4 -0
  50. package/lib/Provider/3dTilesProvider.js +2 -7
  51. package/lib/Provider/Fetcher.js +5 -2
  52. package/lib/Provider/TileProvider.js +18 -2
  53. package/lib/Renderer/Camera.js +33 -12
  54. package/lib/Renderer/ColorLayersOrdering.js +3 -1
  55. package/lib/Renderer/LayeredMaterial.js +32 -7
  56. package/lib/Renderer/OBB.js +8 -4
  57. package/lib/Renderer/OrientedImageMaterial.js +8 -5
  58. package/lib/Renderer/PointsMaterial.js +1 -0
  59. package/lib/Renderer/RenderMode.js +3 -1
  60. package/lib/Renderer/Shader/ShaderChunk.js +5 -1
  61. package/lib/Renderer/c3DEngine.js +9 -6
  62. package/lib/Source/FileSource.js +8 -1
  63. package/lib/Source/VectorTilesSource.js +5 -0
  64. package/lib/Source/WFSSource.js +9 -3
  65. package/lib/ThreeExtended/{WebGL.js → capabilities/WebGL.js} +8 -7
  66. package/lib/ThreeExtended/loaders/GLTFLoader.js +3 -4
  67. package/lib/Utils/DEMUtils.js +3 -1
  68. package/lib/Utils/gui/Main.js +39 -0
  69. package/lib/Utils/gui/Minimap.js +195 -0
  70. package/lib/Utils/gui/Navigation.js +322 -0
  71. package/lib/Utils/gui/Scale.js +154 -0
  72. package/lib/Utils/gui/Searchbar.js +299 -0
  73. package/lib/Utils/gui/Widget.js +119 -0
  74. package/package.json +27 -22
  75. package/examples/images/compass.svg +0 -60
  76. package/examples/images/widget-logo.svg +0 -66
  77. package/examples/js/Scale.js +0 -41
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.
@@ -192,6 +200,12 @@ var viewers = []; // Size of the camera frustrum, in meters
192
200
 
193
201
  var screenMeters;
194
202
 
203
+ var _layers = /*#__PURE__*/new WeakMap();
204
+
205
+ var _pixelDepthBuffer = /*#__PURE__*/new WeakMap();
206
+
207
+ var _fullSizeDepthBuffer = /*#__PURE__*/new WeakMap();
208
+
195
209
  var View = /*#__PURE__*/function (_THREE$EventDispatche) {
196
210
  (0, _inherits2["default"])(View, _THREE$EventDispatche);
197
211
 
@@ -228,6 +242,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
228
242
  * @param {?Scene} [options.scene3D] - [THREE.Scene](https://threejs.org/docs/#api/en/scenes/Scene) instance to use, otherwise a default one will be constructed
229
243
  * @param {?Color} options.diffuse - [THREE.Color](https://threejs.org/docs/?q=color#api/en/math/Color) Diffuse color terrain material.
230
244
  * This color is applied to terrain if there isn't color layer on terrain extent (by example on pole).
245
+ * @param {boolean} [options.enableFocusOnStart=true] - enable focus on dom element on start.
231
246
  *
232
247
  * @constructor
233
248
  */
@@ -242,6 +257,22 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
242
257
  }
243
258
 
244
259
  _this = _super.call(this);
260
+
261
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _layers, {
262
+ writable: true,
263
+ value: []
264
+ });
265
+
266
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _pixelDepthBuffer, {
267
+ writable: true,
268
+ value: new Uint8Array(4)
269
+ });
270
+
271
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _fullSizeDepthBuffer, {
272
+ writable: true,
273
+ value: void 0
274
+ });
275
+
245
276
  _this.domElement = viewerDiv;
246
277
  _this.referenceCrs = crs;
247
278
  var engine; // options.renderer can be 2 separate things:
@@ -263,7 +294,6 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
263
294
 
264
295
  _this.camera = new _Camera["default"](_this.referenceCrs, _this.mainLoop.gfxEngine.getWindowSize().x, _this.mainLoop.gfxEngine.getWindowSize().y, options.camera);
265
296
  _this._frameRequesters = {};
266
- _this._layers = [];
267
297
  window.addEventListener('resize', function () {
268
298
  return _this.resize();
269
299
  }, false);
@@ -297,13 +327,14 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
297
327
 
298
328
  _this.addEventListener(VIEW_EVENTS.LAYERS_INITIALIZED, fn);
299
329
 
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
330
+ (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
331
  // focused sequentially using tab key). Focus is needed to capture some key events.
303
332
 
304
333
  _this.domElement.tabIndex = -1; // Set focus on view's domElement.
305
334
 
306
- _this.domElement.focus(); // Create a custom `dblclick-right` event that is triggered when double right-clicking
335
+ if (!options.disableFocusOnStart) {
336
+ _this.domElement.focus();
337
+ } // Create a custom `dblclick-right` event that is triggered when double right-clicking
307
338
 
308
339
 
309
340
  var rightClickTimeStamp;
@@ -469,7 +500,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
469
500
  return layer._reject(new Error('Cant add GeometryLayer: missing a preUpdate function'));
470
501
  }
471
502
 
472
- this._layers.push(layer);
503
+ (0, _classPrivateFieldGet2["default"])(this, _layers).push(layer);
473
504
  }
474
505
 
475
506
  if (layer.object3d && !layer.object3d.parent && layer.object3d !== this.scene) {
@@ -514,7 +545,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
514
545
  throw new Error("Error to detach ".concat(layerId, " from ").concat(parentLayer.id));
515
546
  } else if (parentLayer == undefined) {
516
547
  // Remove layer from viewer
517
- this._layers.splice(this._layers.findIndex(function (l) {
548
+ (0, _classPrivateFieldGet2["default"])(this, _layers).splice((0, _classPrivateFieldGet2["default"])(this, _layers).findIndex(function (l) {
518
549
  return l.id == layerId;
519
550
  }), 1);
520
551
  }
@@ -596,7 +627,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
596
627
  this._changeSources.add(changeSource);
597
628
 
598
629
  if (changeSource.isTileMesh || changeSource.isCamera) {
599
- this._fullSizeDepthBuffer.needsUpdate = true;
630
+ (0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer).needsUpdate = true;
600
631
  }
601
632
  }
602
633
 
@@ -627,7 +658,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
627
658
  value: function getLayers(filter) {
628
659
  var result = [];
629
660
 
630
- var _iterator6 = _createForOfIteratorHelper(this._layers),
661
+ var _iterator6 = _createForOfIteratorHelper((0, _classPrivateFieldGet2["default"])(this, _layers)),
631
662
  _step6;
632
663
 
633
664
  try {
@@ -1355,15 +1386,15 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1355
1386
  var buffer;
1356
1387
 
1357
1388
  if (viewPaused) {
1358
- if (this._fullSizeDepthBuffer.needsUpdate) {
1359
- this.readDepthBuffer(0, 0, dim.x, dim.y, this._fullSizeDepthBuffer);
1360
- this._fullSizeDepthBuffer.needsUpdate = false;
1389
+ if ((0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer).needsUpdate) {
1390
+ this.readDepthBuffer(0, 0, dim.x, dim.y, (0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer));
1391
+ (0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer).needsUpdate = false;
1361
1392
  }
1362
1393
 
1363
1394
  var id = ((dim.y - mouse.y - 1) * dim.x + mouse.x) * 4;
1364
- buffer = this._fullSizeDepthBuffer.slice(id, id + 4);
1395
+ buffer = (0, _classPrivateFieldGet2["default"])(this, _fullSizeDepthBuffer).slice(id, id + 4);
1365
1396
  } else {
1366
- buffer = this.readDepthBuffer(mouse.x, mouse.y, 1, 1, this._pixelDepthBuffer);
1397
+ buffer = this.readDepthBuffer(mouse.x, mouse.y, 1, 1, (0, _classPrivateFieldGet2["default"])(this, _pixelDepthBuffer));
1367
1398
  }
1368
1399
 
1369
1400
  screen.x = mouse.x / dim.x * 2 - 1;
@@ -1420,7 +1451,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1420
1451
 
1421
1452
  if (mouse instanceof Event) {
1422
1453
  this.eventToViewCoords(mouse);
1423
- } else if (mouse.x !== undefined && mouse.y !== undefined) {
1454
+ } else if (mouse && mouse.x !== undefined && mouse.y !== undefined) {
1424
1455
  _eventCoords.copy(mouse);
1425
1456
  } else {
1426
1457
  _eventCoords.set(this.mainLoop.gfxEngine.width / 2, this.mainLoop.gfxEngine.height / 2);
@@ -1452,7 +1483,7 @@ var View = /*#__PURE__*/function (_THREE$EventDispatche) {
1452
1483
  height = this.domElement.clientHeight;
1453
1484
  }
1454
1485
 
1455
- this._fullSizeDepthBuffer = new Uint8Array(4 * width * height);
1486
+ (0, _classPrivateFieldSet2["default"])(this, _fullSizeDepthBuffer, new Uint8Array(4 * width * height));
1456
1487
  this.mainLoop.gfxEngine.onWindowResize(width, height);
1457
1488
  this.camera.resize(width, height);
1458
1489
  this.notifyChange(this.camera.camera3D);
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
-
12
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
11
 
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
15
 
16
16
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -51,29 +51,56 @@ var FeatureGeometryLayer = /*#__PURE__*/function (_GeometryLayer) {
51
51
  * @param {string} id - The id of the layer, that should be unique. It is
52
52
  * not mandatory, but an error will be emitted if this layer is added a
53
53
  * {@link View} that already has a layer going by that id.
54
- * @param {Object} [config] - Optional configuration, all elements in it
54
+ * @param {Object} [options] - Optional configuration, all elements in it
55
55
  * will be merged as is in the layer.
56
56
  * @param {function} [options.batchId] - optional function to create batchId attribute.
57
57
  * It is passed the feature property and the feature index.
58
58
  * As the batchId is using an unsigned int structure on 32 bits, the batchId could be between 0 and 4,294,967,295.
59
- * @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.
60
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.
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.
61
76
  */
62
77
  function FeatureGeometryLayer(id) {
78
+ var _options$accurate;
79
+
63
80
  var _this;
64
81
 
65
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
82
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
66
83
  (0, _classCallCheck2["default"])(this, FeatureGeometryLayer);
67
- config.update = _FeatureProcessing["default"].update;
68
- config.convert = _Feature2Mesh["default"].convert({
69
- batchId: config.batchId
84
+ options.update = _FeatureProcessing["default"].update;
85
+ options.convert = _Feature2Mesh["default"].convert({
86
+ batchId: options.batchId
70
87
  });
71
- _this = _super.call(this, id, config.object3d || new _three.Group(), config);
88
+ _this = _super.call(this, id, options.object3d || new _three.Group(), options);
72
89
  _this.isFeatureGeometryLayer = true;
90
+ _this.accurate = (_options$accurate = options.accurate) !== null && _options$accurate !== void 0 ? _options$accurate : true;
91
+ _this.buildExtent = !_this.accurate;
73
92
  return _this;
74
93
  }
75
94
 
76
- return (0, _createClass2["default"])(FeatureGeometryLayer);
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
+ }]);
103
+ return FeatureGeometryLayer;
77
104
  }(_GeometryLayer2["default"]);
78
105
 
79
106
  var _default = FeatureGeometryLayer;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = void 0;
9
+ exports.geoidLayerIsVisible = geoidLayerIsVisible;
9
10
 
10
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
12
 
@@ -25,6 +26,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
25
26
 
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; } }
27
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
+ }
28
36
  /**
29
37
  * `GeoidLayer` is a specific `{@link Layer}` which supports geoid height data. When added to a `{@link View}`, it
30
38
  * vertically translates each of the view's tiles by a proper geoid height value. For a given tile, the geoid height
@@ -40,6 +48,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
40
48
  * }),
41
49
  * });
42
50
  */
51
+
52
+
43
53
  var GeoidLayer = /*#__PURE__*/function (_Layer) {
44
54
  (0, _inherits2["default"])(GeoidLayer, _Layer);
45
55
 
@@ -75,10 +85,11 @@ var GeoidLayer = /*#__PURE__*/function (_Layer) {
75
85
 
76
86
  (0, _createClass2["default"])(GeoidLayer, [{
77
87
  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);
88
+ value: function updateNodeZ(node) {
89
+ node.material.geoidHeight = this.visible ? node.geoidHeight : 0;
90
+ node.obb.updateZ({
91
+ geoidHeight: node.material.geoidHeight
92
+ });
82
93
  }
83
94
  }, {
84
95
  key: "update",
@@ -101,7 +112,7 @@ var GeoidLayer = /*#__PURE__*/function (_Layer) {
101
112
  node.layerUpdateState[layer.id] = new _LayerUpdateState["default"]();
102
113
 
103
114
  var updateNodeZ = function () {
104
- return _this2.updateNodeZ(node, parent);
115
+ return _this2.updateNodeZ(node);
105
116
  };
106
117
 
107
118
  layer.addEventListener('visible-property-changed', updateNodeZ);
@@ -118,7 +129,7 @@ var GeoidLayer = /*#__PURE__*/function (_Layer) {
118
129
  return this.getData(node.extent, extentsDestination).then(function (result) {
119
130
  node.geoidHeight = result.getHeightAtCoordinates(node.extent.center());
120
131
 
121
- _this2.updateNodeZ(node, parent);
132
+ _this2.updateNodeZ(node);
122
133
 
123
134
  node.layerUpdateState[layer.id].noMoreUpdatePossible();
124
135
  });
@@ -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;
@@ -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.
@@ -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;
package/lib/Main.js CHANGED
@@ -730,7 +730,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
730
730
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
731
731
 
732
732
  var conf = {
733
- version: '2.37.0'
733
+ version: '2.38.2'
734
734
  };
735
735
  var REVISION = conf.version; // Geographic tools
736
736
 
@@ -29,6 +29,8 @@ var _Utf8Decoder = _interopRequireDefault(require("../Utils/Utf8Decoder"));
29
29
 
30
30
  var _C3DTBatchTable = _interopRequireDefault(require("../Core/3DTiles/C3DTBatchTable"));
31
31
 
32
+ var _ReferencingLayerProperties = _interopRequireDefault(require("../Layer/ReferencingLayerProperties"));
33
+
32
34
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
35
 
34
36
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -258,8 +260,7 @@ var _default = {
258
260
  console.warn('b3dm shader has been patched to add log depth buffer support');
259
261
  }
260
262
 
261
- mesh.material.transparent = options.opacity < 1.0;
262
- mesh.material.opacity = options.opacity;
263
+ (0, _ReferencingLayerProperties["default"])(mesh.material, options.layer);
263
264
  }
264
265
  });
265
266
  resolve(gltf);
@@ -26,16 +26,17 @@ function readCRS(json) {
26
26
  if (json.crs.type.toLowerCase() == 'epsg') {
27
27
  return "EPSG:".concat(json.crs.properties.code);
28
28
  } else if (json.crs.type.toLowerCase() == 'name') {
29
- var epsgIdx = json.crs.properties.name.toLowerCase().indexOf('epsg:');
30
-
31
- if (epsgIdx >= 0) {
32
- // authority:version:code => EPSG:[...]:code
33
- var codeStart = json.crs.properties.name.indexOf(':', epsgIdx + 5);
29
+ if (json.crs.properties.name.toLowerCase().includes('epsg:')) {
30
+ // OGC CRS URN: urn:ogc:def:crs:authority:version:code => EPSG:[...]:code
31
+ // legacy identifier: authority:code => EPSG:code
32
+ var codeStart = json.crs.properties.name.lastIndexOf(':');
34
33
 
35
34
  if (codeStart > 0) {
36
35
  return "EPSG:".concat(json.crs.properties.name.substr(codeStart + 1));
37
36
  }
38
37
  }
38
+
39
+ throw new Error("Unsupported CRS authority '".concat(json.crs.properties.name, "'"));
39
40
  }
40
41
 
41
42
  throw new Error("Unsupported CRS type '".concat(json.crs, "'"));
@@ -45,7 +46,9 @@ function readCRS(json) {
45
46
  return 'EPSG:4326';
46
47
  }
47
48
 
48
- var coord = new _Coordinates["default"]('EPSG:4978', 0, 0, 0); // filter with the first point
49
+ var coord = new _Coordinates["default"]('EPSG:4978', 0, 0, 0);
50
+ var last = new _Coordinates["default"]('EPSG:4978', 0, 0, 0);
51
+ var first = new _Coordinates["default"]('EPSG:4978', 0, 0, 0); // filter with the first point
49
52
 
50
53
  var firstPtIsOut = function (extent, aCoords, crs) {
51
54
  coord.crs = crs;
@@ -76,6 +79,25 @@ var toFeature = {
76
79
 
77
80
  geometry.updateExtent();
78
81
  },
82
+ // compute clockwise polygon
83
+ populateGeometryWithCCW: function populateGeometryWithCCW(crsIn, coordinates, geometry, feature) {
84
+ geometry.startSubGeometry(coordinates.length, feature);
85
+ coord.crs = crsIn;
86
+ var sum = 0;
87
+ first.setFromValues(coordinates[0][0], coordinates[0][1], coordinates[0][2]);
88
+ last.copy(first);
89
+
90
+ for (var i = 0; i < coordinates.length; i++) {
91
+ coord.setFromValues(coordinates[i][0], coordinates[i][1], coordinates[i][2]);
92
+ sum += (last.x - coord.x) * (last.y + coord.y);
93
+ last.copy(coord);
94
+ geometry.pushCoordinates(coord, feature);
95
+ }
96
+
97
+ sum += (last.x - first.x) * (last.y + first.y);
98
+ geometry.getLastSubGeometry().ccw = sum < 0;
99
+ geometry.updateExtent();
100
+ },
79
101
  point: function point(feature, crsIn, coordsIn, collection, properties) {
80
102
  this["default"](feature, crsIn, [coordsIn], collection, properties);
81
103
  },
@@ -101,7 +123,7 @@ var toFeature = {
101
123
  geometry.properties.style = new _Style["default"]({}, feature.style).setFromGeojsonProperties(properties, feature.type); // Then read contour and holes
102
124
 
103
125
  for (var i = 0; i < coordsIn.length; i++) {
104
- this.populateGeometry(crsIn, coordsIn[i], geometry, feature);
126
+ this.populateGeometryWithCCW(crsIn, coordsIn[i], geometry, feature);
105
127
  }
106
128
 
107
129
  feature.updateExtent(geometry);
@@ -38,7 +38,8 @@ var firstPoint = new _three.Vector2(); // Classify option, it allows to classify
38
38
  function vtFeatureToFeatureGeometry(vtFeature, feature) {
39
39
  var classify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
40
40
  var geometry = feature.bindNewGeometry();
41
- classify = classify && feature.type === _Feature.FEATURE_TYPES.POLYGON;
41
+ var isPolygon = feature.type === _Feature.FEATURE_TYPES.POLYGON;
42
+ classify = classify && isPolygon;
42
43
  geometry.properties = vtFeature.properties;
43
44
  var pbf = vtFeature._pbf;
44
45
  pbf.pos = vtFeature._geometry;
@@ -85,7 +86,7 @@ function vtFeatureToFeatureGeometry(vtFeature, feature) {
85
86
  if (count == 1) {
86
87
  firstPoint.set(x, y);
87
88
  lastPoint.set(x, y);
88
- } else if (classify && count > 1) {
89
+ } else if (isPolygon && count > 1) {
89
90
  sum += (lastPoint.x - x) * (lastPoint.y + y);
90
91
  lastPoint.set(x, y);
91
92
  }
@@ -94,7 +95,7 @@ function vtFeatureToFeatureGeometry(vtFeature, feature) {
94
95
  count++;
95
96
  geometry.pushCoordinatesValues(feature, firstPoint.x, firstPoint.y);
96
97
 
97
- if (classify) {
98
+ if (isPolygon) {
98
99
  sum += (lastPoint.x - firstPoint.x) * (lastPoint.y + firstPoint.y);
99
100
  }
100
101
  }
@@ -161,7 +162,7 @@ function readPBF(file, options) {
161
162
  _step;
162
163
 
163
164
  try {
164
- var _loop2 = function () {
165
+ var _loop2 = function _loop2() {
165
166
  var layer = _step.value;
166
167
 
167
168
  if (!feature) {
@@ -385,7 +385,7 @@ threeExamples.LegacyGLTFLoader = function () {
385
385
  5121: THREE.UnsignedByteType,
386
386
  32819: THREE.UnsignedShort4444Type,
387
387
  32820: THREE.UnsignedShort5551Type,
388
- 33635: THREE.UnsignedShort565Type
388
+ 33635: THREE.UnsignedShort5551Type
389
389
  };
390
390
  var WEBGL_SIDES = {
391
391
  1028: THREE.BackSide,
@@ -1434,7 +1434,7 @@ threeExamples.LegacyGLTFLoader = function () {
1434
1434
 
1435
1435
 
1436
1436
  if (skinEntry) {
1437
- var getJointNode = function (jointId) {
1437
+ var getJointNode = function getJointNode(jointId) {
1438
1438
  var keys = Object.keys(__nodes);
1439
1439
 
1440
1440
  for (var i = 0, il = keys.length; i < il; i++) {
@@ -1470,7 +1470,7 @@ threeExamples.LegacyGLTFLoader = function () {
1470
1470
 
1471
1471
  child.bind(new THREE.Skeleton(bones, boneInverses), skinEntry.bindShapeMatrix);
1472
1472
 
1473
- var buildBoneGraph = function (parentJson, parentObject, property) {
1473
+ var buildBoneGraph = function buildBoneGraph(parentJson, parentObject, property) {
1474
1474
  var children = parentJson[property];
1475
1475
  if (children === undefined) return;
1476
1476
 
@@ -94,7 +94,7 @@ function _subdivideNodeAdditive(context, layer, node, cullingTest) {
94
94
  _step;
95
95
 
96
96
  try {
97
- var _loop = function () {
97
+ var _loop = function _loop() {
98
98
  var child = _step.value;
99
99
 
100
100
  // child being downloaded => skip
@@ -157,7 +157,7 @@ function _subdivideNodeSubstractive(context, layer, node) {
157
157
  node.pendingSubdivision = true;
158
158
  var promises = [];
159
159
 
160
- var _loop2 = function (i) {
160
+ var _loop2 = function _loop2(i) {
161
161
  promises.push(requestNewTile(context.view, context.scheduler, layer, childrenTiles[i], node, false).then(function (tile) {
162
162
  childrenTiles[i].loaded = true;
163
163
  node.add(tile);
@@ -416,7 +416,7 @@ function markForDeletion(layer, elt) {
416
416
  function process3dTilesNode() {
417
417
  var cullingTest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : $3dTilesCulling;
418
418
  var subdivisionTest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $3dTilesSubdivisionControl;
419
- return function (context, layer, node) {
419
+ return function _process3dTilesNodes(context, layer, node) {
420
420
  // early exit if parent's subdivision is in progress
421
421
  if (node.parent.pendingSubdivision && !node.parent.additiveRefinement) {
422
422
  node.visible = false;