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
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports["default"] = exports.FeatureGeometry = exports.FeatureCollection = exports.FeatureBuildingOptions = exports.FEATURE_TYPES = void 0;
11
11
 
12
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
+
12
14
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
13
15
 
14
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -17,6 +19,10 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
17
19
 
18
20
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
21
 
22
+ var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
23
+
24
+ var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
25
+
20
26
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
27
 
22
28
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -45,6 +51,10 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
45
51
 
46
52
  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; } }
47
53
 
54
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
55
+
56
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
57
+
48
58
  function defaultExtent(crs) {
49
59
  return new _Extent["default"](crs, Infinity, -Infinity, Infinity, -Infinity);
50
60
  }
@@ -71,7 +81,6 @@ function _setGeometryValues(geom, feature, _long, lat, alt, normal) {
71
81
  }
72
82
 
73
83
  var coordOut = new _Coordinates["default"]('EPSG:4326', 0, 0, 0);
74
- var defaultNormal = new THREE.Vector3(0, 0, 1);
75
84
  var FEATURE_TYPES = {
76
85
  POINT: 0,
77
86
  LINE: 1,
@@ -114,19 +123,27 @@ var FeatureBuildingOptions = /*#__PURE__*/(0, _createClass2["default"])(function
114
123
 
115
124
  exports.FeatureBuildingOptions = FeatureBuildingOptions;
116
125
 
126
+ var _currentExtent = /*#__PURE__*/new WeakMap();
127
+
117
128
  var FeatureGeometry = /*#__PURE__*/function () {
118
129
  /**
119
130
  * @param {Feature} feature geometry
120
131
  */
121
132
  function FeatureGeometry(feature) {
122
133
  (0, _classCallCheck2["default"])(this, FeatureGeometry);
134
+
135
+ _classPrivateFieldInitSpec(this, _currentExtent, {
136
+ writable: true,
137
+ value: void 0
138
+ });
139
+
123
140
  this.indices = [];
124
141
  this.properties = {};
125
142
  this.size = feature.size;
126
143
 
127
144
  if (feature.extent) {
128
145
  this.extent = defaultExtent(feature.extent.crs);
129
- this._currentExtent = defaultExtent(feature.extent.crs);
146
+ (0, _classPrivateFieldSet2["default"])(this, _currentExtent, defaultExtent(feature.extent.crs));
130
147
  }
131
148
 
132
149
  this.altitude = {
@@ -154,7 +171,7 @@ var FeatureGeometry = /*#__PURE__*/function () {
154
171
  count: count,
155
172
  extent: extent
156
173
  });
157
- this._currentExtent = extent;
174
+ (0, _classPrivateFieldSet2["default"])(this, _currentExtent, extent);
158
175
 
159
176
  _extendBuffer(feature, count);
160
177
  }
@@ -174,12 +191,12 @@ var FeatureGeometry = /*#__PURE__*/function () {
174
191
  this.indices.push({
175
192
  offset: offset,
176
193
  count: count,
177
- extent: this._currentExtent
194
+ extent: (0, _classPrivateFieldGet2["default"])(this, _currentExtent)
178
195
  });
179
196
 
180
197
  if (this.extent) {
181
- this.extent.union(this._currentExtent);
182
- this._currentExtent = defaultExtent(this.extent.crs);
198
+ this.extent.union((0, _classPrivateFieldGet2["default"])(this, _currentExtent));
199
+ (0, _classPrivateFieldSet2["default"])(this, _currentExtent, defaultExtent(this.extent.crs));
183
200
  }
184
201
  }
185
202
  }, {
@@ -210,8 +227,8 @@ var FeatureGeometry = /*#__PURE__*/function () {
210
227
  _setGeometryValues(this, feature, coordOut.x, coordOut.y, coordOut.z, coordOut.geodesicNormal); // expand extent if present
211
228
 
212
229
 
213
- if (this._currentExtent) {
214
- this._currentExtent.expandByCoordinates(feature.useCrsOut ? coordOut : coordIn);
230
+ if ((0, _classPrivateFieldGet2["default"])(this, _currentExtent)) {
231
+ (0, _classPrivateFieldGet2["default"])(this, _currentExtent).expandByCoordinates(feature.useCrsOut ? coordOut : coordIn);
215
232
  }
216
233
  }
217
234
  /**
@@ -222,20 +239,19 @@ var FeatureGeometry = /*#__PURE__*/function () {
222
239
  * @param {Feature} feature - the feature containing the geometry
223
240
  * @param {number} long The longitude coordinate.
224
241
  * @param {number} lat The latitude coordinate.
225
- * @param {THREE.Vector3} [normal=THREE.Vector3(0,0,1)] the normal on coordinates.
242
+ * @param {THREE.Vector3} [normal] the normal on coordinates (only for `EPSG:4978` projection).
226
243
  */
227
244
 
228
245
  }, {
229
246
  key: "pushCoordinatesValues",
230
- value: function pushCoordinatesValues(feature, _long2, lat) {
231
- var normal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : defaultNormal;
247
+ value: function pushCoordinatesValues(feature, _long2, lat, normal) {
232
248
  var altitude = this.baseAltitude(feature);
233
249
 
234
250
  _setGeometryValues(this, feature, _long2, lat, altitude, normal); // expand extent if present
235
251
 
236
252
 
237
- if (this._currentExtent) {
238
- this._currentExtent.expandByValuesCoordinates(_long2, lat);
253
+ if ((0, _classPrivateFieldGet2["default"])(this, _currentExtent)) {
254
+ (0, _classPrivateFieldGet2["default"])(this, _currentExtent).expandByValuesCoordinates(_long2, lat);
239
255
  }
240
256
  }
241
257
  /**
@@ -324,7 +340,7 @@ var Feature = /*#__PURE__*/function () {
324
340
  this.vertices = [];
325
341
  this.crs = collection.crs;
326
342
  this.size = collection.size;
327
- this.normals = collection.size == 3 ? [] : undefined;
343
+ this.normals = collection.crs == 'EPSG:4978' ? [] : undefined;
328
344
  this.transformToLocalSystem = collection.transformToLocalSystem.bind(collection);
329
345
 
330
346
  if (collection.extent) {
@@ -447,6 +463,10 @@ var alignYtoEast = new THREE.Quaternion();
447
463
  *
448
464
  */
449
465
 
466
+ var _transformToLocalSystem = /*#__PURE__*/new WeakMap();
467
+
468
+ var _setLocalSystem = /*#__PURE__*/new WeakMap();
469
+
450
470
  var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
451
471
  (0, _inherits2["default"])(FeatureCollection, _THREE$Object3D);
452
472
 
@@ -456,12 +476,25 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
456
476
  * @param {FeatureBuildingOptions|Layer} options The building options .
457
477
  */
458
478
  function FeatureCollection(options) {
479
+ var _options$source;
480
+
459
481
  var _this;
460
482
 
461
483
  (0, _classCallCheck2["default"])(this, FeatureCollection);
462
484
  _this = _super.call(this);
485
+
486
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _transformToLocalSystem, {
487
+ writable: true,
488
+ value: transformToLocalSystem2D
489
+ });
490
+
491
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, {
492
+ writable: true,
493
+ value: doNothing
494
+ });
495
+
463
496
  _this.isFeatureCollection = true;
464
- _this.crs = _Crs["default"].formatToEPSG(options.crs);
497
+ _this.crs = _Crs["default"].formatToEPSG(options.accurate || !((_options$source = options.source) !== null && _options$source !== void 0 && _options$source.crs) ? options.crs : options.source.crs);
465
498
  _this.features = [];
466
499
  _this.mergeFeatures = options.mergeFeatures === undefined ? true : options.mergeFeatures;
467
500
  _this.size = options.structure == '3d' ? 3 : 2;
@@ -473,8 +506,7 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
473
506
 
474
507
  if (_this.size == 2) {
475
508
  _this.extent = options.buildExtent === false ? undefined : defaultExtent(options.forcedExtentCrs || _this.crs);
476
-
477
- _this._setLocalSystem = function (center) {
509
+ (0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, function (center) {
478
510
  // set local system center
479
511
  center.as('EPSG:4326', _this.center); // set position to local system center
480
512
 
@@ -482,14 +514,11 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
482
514
 
483
515
  _this.updateMatrixWorld();
484
516
 
485
- _this._setLocalSystem = doNothing;
486
- };
487
-
488
- _this._transformToLocalSystem = transformToLocalSystem2D;
517
+ (0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, doNothing);
518
+ });
489
519
  } else {
490
520
  _this.extent = options.buildExtent ? defaultExtent(options.forcedExtentCrs || _this.crs) : undefined;
491
-
492
- _this._setLocalSystem = function (center) {
521
+ (0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, function (center) {
493
522
  // set local system center
494
523
  center.as('EPSG:4326', _this.center);
495
524
 
@@ -511,10 +540,9 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
511
540
  _this.normalMatrix.getNormalMatrix(_this.matrix);
512
541
 
513
542
  _this.normalMatrixInverse = new THREE.Matrix3().copy(_this.normalMatrix).invert();
514
- _this._setLocalSystem = doNothing;
515
- };
516
-
517
- _this._transformToLocalSystem = transformToLocalSystem3D;
543
+ (0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, doNothing);
544
+ });
545
+ (0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _transformToLocalSystem, transformToLocalSystem3D);
518
546
  }
519
547
 
520
548
  _this.altitude = {
@@ -536,9 +564,8 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
536
564
  (0, _createClass2["default"])(FeatureCollection, [{
537
565
  key: "transformToLocalSystem",
538
566
  value: function transformToLocalSystem(coordinates) {
539
- this._setLocalSystem(coordinates);
540
-
541
- return this._transformToLocalSystem(coordinates, this);
567
+ (0, _classPrivateFieldGet2["default"])(this, _setLocalSystem).call(this, coordinates);
568
+ return (0, _classPrivateFieldGet2["default"])(this, _transformToLocalSystem).call(this, coordinates, this);
542
569
  }
543
570
  /**
544
571
  * Update FeatureCollection extent with `extent` or all features extent if
@@ -1,12 +1,42 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports["default"] = exports.RENDERING_SCHEDULED = exports.RENDERING_PAUSED = exports.MAIN_LOOP_EVENTS = void 0;
7
9
 
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
23
+
24
+ var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
25
+
8
26
  var _three = require("three");
9
27
 
28
+ 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); }; }
29
+
30
+ 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; } }
31
+
32
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
33
+
34
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
35
+
36
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
37
+
38
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
39
+
10
40
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
11
41
 
12
42
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -43,42 +73,17 @@ var MAIN_LOOP_EVENTS = {
43
73
  };
44
74
  exports.MAIN_LOOP_EVENTS = MAIN_LOOP_EVENTS;
45
75
 
46
- function MainLoop(scheduler, engine) {
47
- this.renderingState = RENDERING_PAUSED;
48
- this.needsRedraw = false;
49
- this.scheduler = scheduler;
50
- this.gfxEngine = engine; // TODO: remove me
51
-
52
- this._updateLoopRestarted = true;
53
- }
54
-
55
- MainLoop.prototype = Object.create(_three.EventDispatcher.prototype);
56
- MainLoop.prototype.constructor = MainLoop;
57
-
58
- MainLoop.prototype.scheduleViewUpdate = function (view, forceRedraw) {
59
- var _this = this;
60
-
61
- this.needsRedraw |= forceRedraw;
62
-
63
- if (this.renderingState !== RENDERING_SCHEDULED) {
64
- this.renderingState = RENDERING_SCHEDULED;
65
- requestAnimationFrame(function (timestamp) {
66
- _this._step(view, timestamp);
67
- });
68
- }
69
- };
70
-
71
76
  function updateElements(context, geometryLayer, elements) {
72
77
  if (!elements) {
73
78
  return;
74
79
  }
75
80
 
76
81
  var _iterator = _createForOfIteratorHelper(elements),
77
- _step2;
82
+ _step;
78
83
 
79
84
  try {
80
- for (_iterator.s(); !(_step2 = _iterator.n()).done;) {
81
- var element = _step2.value;
85
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
86
+ var element = _step.value;
82
87
  // update element
83
88
  // TODO find a way to notify attachedLayers when geometryLayer deletes some elements
84
89
  // and then update Debug.js:addGeometryLayerDebugFeatures
@@ -89,11 +94,11 @@ function updateElements(context, geometryLayer, elements) {
89
94
  if (sub.element) {
90
95
  // update attached layers
91
96
  var _iterator2 = _createForOfIteratorHelper(geometryLayer.attachedLayers),
92
- _step3;
97
+ _step2;
93
98
 
94
99
  try {
95
- for (_iterator2.s(); !(_step3 = _iterator2.n()).done;) {
96
- var attachedLayer = _step3.value;
100
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
101
+ var attachedLayer = _step2.value;
97
102
 
98
103
  if (attachedLayer.ready) {
99
104
  attachedLayer.update(context, attachedLayer, sub.element, sub.parent);
@@ -113,11 +118,11 @@ function updateElements(context, geometryLayer, elements) {
113
118
 
114
119
 
115
120
  var _iterator3 = _createForOfIteratorHelper(geometryLayer.attachedLayers),
116
- _step4;
121
+ _step3;
117
122
 
118
123
  try {
119
- for (_iterator3.s(); !(_step4 = _iterator3.n()).done;) {
120
- var _attachedLayer = _step4.value;
124
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
125
+ var _attachedLayer = _step3.value;
121
126
 
122
127
  if (_attachedLayer.ready) {
123
128
  _attachedLayer.update(context, _attachedLayer, sub.elements[i], sub.parent);
@@ -157,7 +162,76 @@ function filterChangeSources(updateSources, geometryLayer) {
157
162
  return fullUpdate ? new Set([geometryLayer]) : filtered;
158
163
  }
159
164
 
160
- MainLoop.prototype._update = function (view, updateSources, dt) {
165
+ var _needsRedraw = /*#__PURE__*/new WeakMap();
166
+
167
+ var _updateLoopRestarted = /*#__PURE__*/new WeakMap();
168
+
169
+ var _lastTimestamp = /*#__PURE__*/new WeakMap();
170
+
171
+ var _update = /*#__PURE__*/new WeakSet();
172
+
173
+ var _step4 = /*#__PURE__*/new WeakSet();
174
+
175
+ var _renderView = /*#__PURE__*/new WeakSet();
176
+
177
+ var MainLoop = /*#__PURE__*/function (_EventDispatcher) {
178
+ (0, _inherits2["default"])(MainLoop, _EventDispatcher);
179
+
180
+ var _super = _createSuper(MainLoop);
181
+
182
+ function MainLoop(scheduler, engine) {
183
+ var _this;
184
+
185
+ (0, _classCallCheck2["default"])(this, MainLoop);
186
+ _this = _super.call(this);
187
+
188
+ _classPrivateMethodInitSpec((0, _assertThisInitialized2["default"])(_this), _renderView);
189
+
190
+ _classPrivateMethodInitSpec((0, _assertThisInitialized2["default"])(_this), _step4);
191
+
192
+ _classPrivateMethodInitSpec((0, _assertThisInitialized2["default"])(_this), _update);
193
+
194
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _needsRedraw, {
195
+ writable: true,
196
+ value: false
197
+ });
198
+
199
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _updateLoopRestarted, {
200
+ writable: true,
201
+ value: true
202
+ });
203
+
204
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _lastTimestamp, {
205
+ writable: true,
206
+ value: 0
207
+ });
208
+
209
+ _this.renderingState = RENDERING_PAUSED;
210
+ _this.scheduler = scheduler;
211
+ _this.gfxEngine = engine; // TODO: remove me
212
+
213
+ return _this;
214
+ }
215
+
216
+ (0, _createClass2["default"])(MainLoop, [{
217
+ key: "scheduleViewUpdate",
218
+ value: function scheduleViewUpdate(view, forceRedraw) {
219
+ var _this2 = this;
220
+
221
+ (0, _classPrivateFieldSet2["default"])(this, _needsRedraw, (0, _classPrivateFieldGet2["default"])(this, _needsRedraw) | forceRedraw);
222
+
223
+ if (this.renderingState !== RENDERING_SCHEDULED) {
224
+ this.renderingState = RENDERING_SCHEDULED;
225
+ requestAnimationFrame(function (timestamp) {
226
+ _classPrivateMethodGet(_this2, _step4, _step5).call(_this2, view, timestamp);
227
+ });
228
+ }
229
+ }
230
+ }]);
231
+ return MainLoop;
232
+ }(_three.EventDispatcher);
233
+
234
+ function _update2(view, updateSources, dt) {
161
235
  var context = {
162
236
  camera: view.camera,
163
237
  engine: this.gfxEngine,
@@ -176,26 +250,26 @@ MainLoop.prototype._update = function (view, updateSources, dt) {
176
250
  var _iterator4 = _createForOfIteratorHelper(view.getLayers(function (x, y) {
177
251
  return !y;
178
252
  })),
179
- _step5;
253
+ _step6;
180
254
 
181
255
  try {
182
- for (_iterator4.s(); !(_step5 = _iterator4.n()).done;) {
183
- var geometryLayer = _step5.value;
256
+ for (_iterator4.s(); !(_step6 = _iterator4.n()).done;) {
257
+ var geometryLayer = _step6.value;
184
258
  context.geometryLayer = geometryLayer;
185
259
 
186
260
  if (geometryLayer.ready && geometryLayer.visible && !geometryLayer.frozen) {
187
- view.execFrameRequesters(MAIN_LOOP_EVENTS.BEFORE_LAYER_UPDATE, dt, this._updateLoopRestarted, geometryLayer); // Filter updateSources that are relevant for the geometryLayer
261
+ view.execFrameRequesters(MAIN_LOOP_EVENTS.BEFORE_LAYER_UPDATE, dt, (0, _classPrivateFieldGet2["default"])(this, _updateLoopRestarted), geometryLayer); // Filter updateSources that are relevant for the geometryLayer
188
262
 
189
263
  var srcs = filterChangeSources(updateSources, geometryLayer);
190
264
 
191
265
  if (srcs.size > 0) {
192
266
  // pre update attached layer
193
267
  var _iterator5 = _createForOfIteratorHelper(geometryLayer.attachedLayers),
194
- _step6;
268
+ _step7;
195
269
 
196
270
  try {
197
- for (_iterator5.s(); !(_step6 = _iterator5.n()).done;) {
198
- var attachedLayer = _step6.value;
271
+ for (_iterator5.s(); !(_step7 = _iterator5.n()).done;) {
272
+ var attachedLayer = _step7.value;
199
273
 
200
274
  if (attachedLayer.ready && attachedLayer.preUpdate) {
201
275
  attachedLayer.preUpdate(context, srcs);
@@ -217,7 +291,7 @@ MainLoop.prototype._update = function (view, updateSources, dt) {
217
291
 
218
292
 
219
293
  geometryLayer.cache.flush();
220
- view.execFrameRequesters(MAIN_LOOP_EVENTS.AFTER_LAYER_UPDATE, dt, this._updateLoopRestarted, geometryLayer);
294
+ view.execFrameRequesters(MAIN_LOOP_EVENTS.AFTER_LAYER_UPDATE, dt, (0, _classPrivateFieldGet2["default"])(this, _updateLoopRestarted), geometryLayer);
221
295
  }
222
296
  }
223
297
  } catch (err) {
@@ -225,19 +299,19 @@ MainLoop.prototype._update = function (view, updateSources, dt) {
225
299
  } finally {
226
300
  _iterator4.f();
227
301
  }
228
- };
302
+ }
229
303
 
230
- MainLoop.prototype._step = function (view, timestamp) {
231
- var dt = timestamp - this._lastTimestamp;
304
+ function _step5(view, timestamp) {
305
+ var dt = timestamp - (0, _classPrivateFieldGet2["default"])(this, _lastTimestamp);
232
306
 
233
307
  view._executeFrameRequestersRemovals();
234
308
 
235
- view.execFrameRequesters(MAIN_LOOP_EVENTS.UPDATE_START, dt, this._updateLoopRestarted);
236
- var willRedraw = this.needsRedraw;
237
- this._lastTimestamp = timestamp; // Reset internal state before calling _update (so future calls to View.notifyChange()
309
+ view.execFrameRequesters(MAIN_LOOP_EVENTS.UPDATE_START, dt, (0, _classPrivateFieldGet2["default"])(this, _updateLoopRestarted));
310
+ var willRedraw = (0, _classPrivateFieldGet2["default"])(this, _needsRedraw);
311
+ (0, _classPrivateFieldSet2["default"])(this, _lastTimestamp, timestamp); // Reset internal state before calling _update (so future calls to View.notifyChange()
238
312
  // can properly change it)
239
313
 
240
- this.needsRedraw = false;
314
+ (0, _classPrivateFieldSet2["default"])(this, _needsRedraw, false);
241
315
  this.renderingState = RENDERING_PAUSED;
242
316
  var updateSources = new Set(view._changeSources);
243
317
 
@@ -245,9 +319,9 @@ MainLoop.prototype._step = function (view, timestamp) {
245
319
 
246
320
 
247
321
  var dim = this.gfxEngine.getWindowSize();
248
- view.execFrameRequesters(MAIN_LOOP_EVENTS.BEFORE_CAMERA_UPDATE, dt, this._updateLoopRestarted);
322
+ view.execFrameRequesters(MAIN_LOOP_EVENTS.BEFORE_CAMERA_UPDATE, dt, (0, _classPrivateFieldGet2["default"])(this, _updateLoopRestarted));
249
323
  view.camera.update(dim.x, dim.y);
250
- view.execFrameRequesters(MAIN_LOOP_EVENTS.AFTER_CAMERA_UPDATE, dt, this._updateLoopRestarted); // Disable camera's matrix auto update to make sure the camera's
324
+ view.execFrameRequesters(MAIN_LOOP_EVENTS.AFTER_CAMERA_UPDATE, dt, (0, _classPrivateFieldGet2["default"])(this, _updateLoopRestarted)); // Disable camera's matrix auto update to make sure the camera's
251
325
  // world matrix is never updated mid-update.
252
326
  // Otherwise inconsistencies can appear because object visibility
253
327
  // testing and object drawing could be performed using different
@@ -258,31 +332,31 @@ MainLoop.prototype._step = function (view, timestamp) {
258
332
  var oldAutoUpdate = view.camera.camera3D.matrixAutoUpdate;
259
333
  view.camera.camera3D.matrixAutoUpdate = false; // update data-structure
260
334
 
261
- this._update(view, updateSources, dt);
335
+ _classPrivateMethodGet(this, _update, _update2).call(this, view, updateSources, dt);
262
336
 
263
337
  if (this.scheduler.commandsWaitingExecutionCount() == 0) {
264
338
  this.dispatchEvent({
265
339
  type: 'command-queue-empty'
266
340
  });
267
341
  } // Redraw *only* if needed.
268
- // (redraws only happen when this.needsRedraw is true, which in turn only happens when
342
+ // (redraws only happen when this.#needsRedraw is true, which in turn only happens when
269
343
  // view.notifyChange() is called with redraw=true)
270
344
  // As such there's no continuous update-loop, instead we use a ad-hoc update/render
271
345
  // mechanism.
272
346
 
273
347
 
274
348
  if (willRedraw) {
275
- this._renderView(view, dt);
349
+ _classPrivateMethodGet(this, _renderView, _renderView2).call(this, view, dt);
276
350
  } // next time, we'll consider that we've just started the loop if we are still PAUSED now
277
351
 
278
352
 
279
- this._updateLoopRestarted = this.renderingState === RENDERING_PAUSED;
353
+ (0, _classPrivateFieldSet2["default"])(this, _updateLoopRestarted, this.renderingState === RENDERING_PAUSED);
280
354
  view.camera.camera3D.matrixAutoUpdate = oldAutoUpdate;
281
- view.execFrameRequesters(MAIN_LOOP_EVENTS.UPDATE_END, dt, this._updateLoopRestarted);
282
- };
355
+ view.execFrameRequesters(MAIN_LOOP_EVENTS.UPDATE_END, dt, (0, _classPrivateFieldGet2["default"])(this, _updateLoopRestarted));
356
+ }
283
357
 
284
- MainLoop.prototype._renderView = function (view, dt) {
285
- view.execFrameRequesters(MAIN_LOOP_EVENTS.BEFORE_RENDER, dt, this._updateLoopRestarted);
358
+ function _renderView2(view, dt) {
359
+ view.execFrameRequesters(MAIN_LOOP_EVENTS.BEFORE_RENDER, dt, (0, _classPrivateFieldGet2["default"])(this, _updateLoopRestarted));
286
360
 
287
361
  if (view.render) {
288
362
  view.render();
@@ -291,8 +365,8 @@ MainLoop.prototype._renderView = function (view, dt) {
291
365
  this.gfxEngine.renderView(view);
292
366
  }
293
367
 
294
- view.execFrameRequesters(MAIN_LOOP_EVENTS.AFTER_RENDER, dt, this._updateLoopRestarted);
295
- };
368
+ view.execFrameRequesters(MAIN_LOOP_EVENTS.AFTER_RENDER, dt, (0, _classPrivateFieldGet2["default"])(this, _updateLoopRestarted));
369
+ }
296
370
 
297
371
  var _default = MainLoop;
298
372
  exports["default"] = _default;
@@ -13,16 +13,22 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
13
13
 
14
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
15
 
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
16
18
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
19
 
18
20
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
21
 
20
22
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
23
 
24
+ var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
25
+
22
26
  var THREE = _interopRequireWildcard(require("three"));
23
27
 
24
28
  var _Crs = _interopRequireDefault(require("./Geographic/Crs"));
25
29
 
30
+ var _GeoidLayer = require("../Layer/GeoidLayer");
31
+
26
32
  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); }
27
33
 
28
34
  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; }
@@ -37,6 +43,12 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
37
43
 
38
44
  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; } }
39
45
 
46
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
47
+
48
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
49
+
50
+ var _tms = /*#__PURE__*/new WeakMap();
51
+
40
52
  /**
41
53
  * A TileMesh is a THREE.Mesh with a geometricError and an OBB
42
54
  * The objectId property of the material is the with the id of the TileMesh
@@ -59,6 +71,11 @@ var TileMesh = /*#__PURE__*/function (_THREE$Mesh) {
59
71
  (0, _classCallCheck2["default"])(this, TileMesh);
60
72
  _this = _super.call(this, geometry, material);
61
73
 
74
+ _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _tms, {
75
+ writable: true,
76
+ value: new Map()
77
+ });
78
+
62
79
  if (!extent) {
63
80
  throw new Error('extent is mandatory to build a TileMesh');
64
81
  }
@@ -73,16 +90,13 @@ var TileMesh = /*#__PURE__*/function (_THREE$Mesh) {
73
90
 
74
91
  _this.obb.box3D.getBoundingSphere(_this.boundingSphere);
75
92
 
76
- _this._tms = new Map();
77
-
78
93
  var _iterator = _createForOfIteratorHelper(layer.tileMatrixSets),
79
94
  _step;
80
95
 
81
96
  try {
82
97
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
83
98
  var tms = _step.value;
84
-
85
- _this._tms.set(tms, _this.extent.tiledCovering(tms));
99
+ (0, _classPrivateFieldGet2["default"])((0, _assertThisInitialized2["default"])(_this), _tms).set(tms, _this.extent.tiledCovering(tms));
86
100
  }
87
101
  } catch (err) {
88
102
  _iterator.e(err);
@@ -97,6 +111,7 @@ var TileMesh = /*#__PURE__*/function (_THREE$Mesh) {
97
111
  _this.isTileMesh = true;
98
112
  _this.domElements = {};
99
113
  _this.geoidHeight = 0;
114
+ _this.link = [];
100
115
  return _this;
101
116
  }
102
117
  /**
@@ -113,6 +128,7 @@ var TileMesh = /*#__PURE__*/function (_THREE$Mesh) {
113
128
  (0, _createClass2["default"])(TileMesh, [{
114
129
  key: "setBBoxZ",
115
130
  value: function setBBoxZ(elevation) {
131
+ elevation.geoidHeight = (0, _GeoidLayer.geoidLayerIsVisible)(this.layer) ? this.geoidHeight : 0;
116
132
  this.obb.updateZ(elevation);
117
133
 
118
134
  if (this.horizonCullingPointElevationScaled) {
@@ -124,7 +140,7 @@ var TileMesh = /*#__PURE__*/function (_THREE$Mesh) {
124
140
  }, {
125
141
  key: "getExtentsByProjection",
126
142
  value: function getExtentsByProjection(crs) {
127
- return this._tms.get(_Crs["default"].formatToTms(crs));
143
+ return (0, _classPrivateFieldGet2["default"])(this, _tms).get(_Crs["default"].formatToTms(crs));
128
144
  }
129
145
  /**
130
146
  * Search for a common ancestor between this tile and another one. It goes