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
@@ -0,0 +1,96 @@
1
+ <html>
2
+ <head>
3
+ <title>Itowns - Scale widget</title>
4
+
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+
8
+ <link rel="stylesheet" type="text/css" href="css/example.css">
9
+ <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
10
+
11
+ <!-- Import stylesheet for itowns Widgets plugin. This stylesheet is included in the bundles if you downloaded
12
+ them, or it can be found in `node_modules/itowns/examples/css` if you installed iTowns with npm. Otherwise, it
13
+ can be found here : https://raw.githubusercontent.com/iTowns/itowns/master/examples/css/widgets.css -->
14
+ <link rel="stylesheet" type="text/css" href="css/widgets.css">
15
+
16
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
17
+ </head>
18
+ <body>
19
+ <!-- Create a container for itowns viewer -->
20
+ <div id="viewerDiv"></div>
21
+
22
+ <!-- Import iTowns source code -->
23
+ <script src="../dist/itowns.js"></script>
24
+ <script src="../dist/debug.js"></script>
25
+ <!-- Import iTowns Widgets plugin -->
26
+ <script src="../dist/itowns_widgets.js"></script>
27
+ <!-- Import iTowns LoadingScreen and GuiTools plugins -->
28
+ <script src="js/GUI/LoadingScreen.js"></script>
29
+ <script src="js/GUI/GuiTools.js"></script>
30
+
31
+
32
+ <script type="text/javascript">
33
+
34
+
35
+
36
+ // ---------- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION : ----------
37
+
38
+ // Define camera initial position
39
+ const placement = {
40
+ coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712),
41
+ range: 6000,
42
+ tilt: 50,
43
+ }
44
+
45
+ // `viewerDiv` contains iTowns' rendering area (`<canvas>`)
46
+ const viewerDiv = document.getElementById('viewerDiv');
47
+
48
+ // Create a GlobeView
49
+ const view = new itowns.GlobeView(viewerDiv, placement);
50
+
51
+ // Setup loading screen and debug menu
52
+ setupLoadingScreen(viewerDiv, view);
53
+ const debugMenu = new GuiTools('menuDiv', view);
54
+
55
+
56
+
57
+ // ---------- DISPLAY CONTEXTUAL DATA : ----------
58
+
59
+ // Add one imagery layer to the scene. This layer's properties are defined in a json file, but it could be
60
+ // defined as a plain js object. See `Layer` documentation for more info.
61
+ itowns.Fetcher.json('layers/JSONLayers/Ortho.json').then((config) => {
62
+ config.source = new itowns.WMTSSource(config.source);
63
+ view.addLayer(
64
+ new itowns.ColorLayer(config.id, config),
65
+ ).then(debugMenu.addLayerGUI.bind(debugMenu));
66
+ });
67
+
68
+ // Add two elevation layers, each with a different level of detail. Here again, each layer's properties are
69
+ // defined in a json file.
70
+ function addElevationLayerFromConfig(config) {
71
+ config.source = new itowns.WMTSSource(config.source);
72
+ view.addLayer(
73
+ new itowns.ElevationLayer(config.id, config),
74
+ ).then(debugMenu.addLayerGUI.bind(debugMenu));
75
+ }
76
+ itowns.Fetcher.json('layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig);
77
+ itowns.Fetcher.json('layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig);
78
+
79
+
80
+
81
+ // ---------- ADD SCALE WIDGET : ----------
82
+
83
+ const scale = new itowns_widgets.Scale(view, {
84
+ position: 'bottom-right',
85
+ translate: { x: -70 },
86
+ });
87
+
88
+
89
+
90
+ // ---------- DEBUG TOOLS : ----------
91
+
92
+ debug.createTileDebugUI(debugMenu.gui, view);
93
+
94
+ </script>
95
+ </body>
96
+ </html>
@@ -0,0 +1,124 @@
1
+ <html>
2
+ <head>
3
+ <title>Itowns - Searchbar widget</title>
4
+
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+
8
+ <link rel="stylesheet" type="text/css" href="css/example.css">
9
+ <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
10
+
11
+ <!-- Import stylesheet for itowns Widgets plugin. This stylesheet is included in the bundles if you downloaded
12
+ them, or it can be found in `node_modules/itowns/examples/css` if you installed iTowns with npm. Otherwise, it
13
+ can be found here : https://raw.githubusercontent.com/iTowns/itowns/master/examples/css/widgets.css -->
14
+ <link rel="stylesheet" type="text/css" href="css/widgets.css">
15
+
16
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
17
+ </head>
18
+ <body>
19
+ <!-- Create a container for itowns viewer -->
20
+ <div id="viewerDiv"></div>
21
+
22
+ <!-- Import iTowns source code -->
23
+ <script src="../dist/itowns.js"></script>
24
+ <script src="../dist/debug.js"></script>
25
+ <!-- Import iTowns Widgets plugin -->
26
+ <script src="../dist/itowns_widgets.js"></script>
27
+ <!-- Import iTowns LoadingScreen and GuiTools plugins -->
28
+ <script src="js/GUI/LoadingScreen.js"></script>
29
+ <script src="js/GUI/GuiTools.js"></script>
30
+
31
+
32
+ <script type="text/javascript">
33
+
34
+
35
+
36
+ // ---------- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION : ----------
37
+
38
+ // Define camera initial position
39
+ const placement = {
40
+ coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712),
41
+ range: 6000,
42
+ tilt: 50,
43
+ }
44
+
45
+ // `viewerDiv` contains iTowns' rendering area (`<canvas>`)
46
+ const viewerDiv = document.getElementById('viewerDiv');
47
+
48
+ // Create a GlobeView
49
+ const view = new itowns.GlobeView(viewerDiv, placement);
50
+
51
+ // Setup loading screen and debug menu
52
+ setupLoadingScreen(viewerDiv, view);
53
+ const debugMenu = new GuiTools('menuDiv', view);
54
+
55
+
56
+
57
+ // ---------- DISPLAY CONTEXTUAL DATA : ----------
58
+
59
+ // Add one imagery layer to the scene. This layer's properties are defined in a json file, but it could be
60
+ // defined as a plain js object. See `Layer` documentation for more info.
61
+ itowns.Fetcher.json('layers/JSONLayers/Ortho.json').then((config) => {
62
+ config.source = new itowns.WMTSSource(config.source);
63
+ view.addLayer(
64
+ new itowns.ColorLayer(config.id, config),
65
+ ).then(debugMenu.addLayerGUI.bind(debugMenu));
66
+ });
67
+
68
+ // Add two elevation layers, each with a different level of detail. Here again, each layer's properties are
69
+ // defined in a json file.
70
+ function addElevationLayerFromConfig(config) {
71
+ config.source = new itowns.WMTSSource(config.source);
72
+ view.addLayer(
73
+ new itowns.ElevationLayer(config.id, config),
74
+ ).then(debugMenu.addLayerGUI.bind(debugMenu));
75
+ }
76
+ itowns.Fetcher.json('layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig);
77
+ itowns.Fetcher.json('layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig);
78
+
79
+
80
+
81
+ // ---------- ADD SEARCH BAR WIDGET : ----------
82
+
83
+ // Function that should be called when clicking a location suggestion.
84
+ function lookAtCoordinate(coordinates) {
85
+ view.controls.lookAtCoordinate({ coord: coordinates, range: 20000, tilt: 45, heading: 0 });
86
+ }
87
+
88
+ // Define options for geocoding service that should be used by the searchbar.
89
+ const geocodingOptions = {
90
+ url: new URL(
91
+ 'https://wxs.ign.fr/ayxvok72rcocdyn8xyvy32og/ols/apis/completion?text=&type=StreetAddress,' +
92
+ 'PositionOfInterest',
93
+ ),
94
+ // As precised in the doc (http://www.itowns-project.org/itowns/docs/#api/Widgets/Searchbar), the parser
95
+ // method must parse the geocoding service response into a Map object. For each item of this Map, the
96
+ // key is a string that is displayed in the suggestions bellow the searchbar, and the value is whatever
97
+ // the user wants. The value is the parameter that is passed to the `onSelected` method when a
98
+ // suggestion is clicked. Here, we se the value as the `Coordinates` associated to the location.
99
+ parser: (response) => {
100
+ const map = new Map();
101
+ response.results.forEach(location => {
102
+ map.set(location.fulltext, new itowns.Coordinates('EPSG:4326', location.x, location.y));
103
+ });
104
+ return map;
105
+ },
106
+ onSelected: lookAtCoordinate,
107
+ }
108
+
109
+ // Create the searchbar
110
+ const searchbar = new itowns_widgets.Searchbar(view, geocodingOptions, {
111
+ // We want to display at maximum 15 location suggestions when typing the searchbar.
112
+ maxSuggestionNumber: 15,
113
+ placeholder: 'Search a location in France',
114
+ });
115
+
116
+
117
+
118
+ // ---------- DEBUG TOOLS : ----------
119
+
120
+ debug.createTileDebugUI(debugMenu.gui, view);
121
+
122
+ </script>
123
+ </body>
124
+ </html>
@@ -126,8 +126,6 @@ var defaultOptions = {
126
126
  instantTravel: false,
127
127
  minZenithAngle: 0,
128
128
  maxZenithAngle: 82.5,
129
- focusOnMouseOver: true,
130
- focusOnMouseClick: true,
131
129
  handleCollision: true,
132
130
  minDistanceCollision: 30,
133
131
  enableSmartTravel: true,
@@ -183,8 +181,6 @@ var PLANAR_CONTROL_EVENT = {
183
181
  * rotation, in degrees.
184
182
  * @param {number} [options.maxZenithAngle=82.5] The maximum reachable zenith angle for a camera
185
183
  * rotation, in degrees.
186
- * @param {boolean} [options.focusOnMouseOver=true] Set the focus on the canvas if hovered.
187
- * @param {boolean} [options.focusOnMouseClick=true] Set the focus on the canvas if clicked.
188
184
  * @param {boolean} [options.handleCollision=true]
189
185
  */
190
186
 
@@ -280,8 +276,14 @@ var PlanarControls = /*#__PURE__*/function (_THREE$EventDispatche) {
280
276
 
281
277
  _this.maxZenithAngle = (options.maxZenithAngle || defaultOptions.maxZenithAngle) * Math.PI / 180; // focus policy options
282
278
 
283
- _this.focusOnMouseOver = options.focusOnMouseOver || defaultOptions.focusOnMouseOver;
284
- _this.focusOnMouseClick = options.focusOnMouseClick || defaultOptions.focusOnMouseClick; // set collision options
279
+ if (options.focusOnMouseOver) {
280
+ console.warn('Planar controls \'focusOnMouseOver\' optional parameter has been removed.');
281
+ }
282
+
283
+ if (options.focusOnMouseClick) {
284
+ console.warn('Planar controls \'focusOnMouseClick\' optional parameter has been removed.');
285
+ } // set collision options
286
+
285
287
 
286
288
  _this.handleCollision = options.handleCollision === undefined ? defaultOptions.handleCollision : options.handleCollision;
287
289
  _this.minDistanceCollision = defaultOptions.minDistanceCollision; // enable smart travel
@@ -307,8 +309,6 @@ var PlanarControls = /*#__PURE__*/function (_THREE$EventDispatche) {
307
309
  _this._handlerOnMouseUp = _this.onMouseUp.bind((0, _assertThisInitialized2["default"])(_this));
308
310
  _this._handlerOnMouseMove = _this.onMouseMove.bind((0, _assertThisInitialized2["default"])(_this));
309
311
  _this._handlerOnMouseWheel = _this.onMouseWheel.bind((0, _assertThisInitialized2["default"])(_this));
310
- _this._handlerFocusOnMouseClick = _this.onMouseClick.bind((0, _assertThisInitialized2["default"])(_this));
311
- _this._handlerFocusOnMouseOver = _this.onMouseOver.bind((0, _assertThisInitialized2["default"])(_this));
312
312
  _this._handlerContextMenu = _this.onContextMenu.bind((0, _assertThisInitialized2["default"])(_this));
313
313
  _this._handlerUpdate = _this.update.bind((0, _assertThisInitialized2["default"])(_this)); // add this PlanarControl instance to the view's frameRequesters
314
314
  // with this, PlanarControl.update() will be called each frame
@@ -856,18 +856,9 @@ var PlanarControls = /*#__PURE__*/function (_THREE$EventDispatche) {
856
856
  this.view.domElement.addEventListener('mouseup', this._handlerOnMouseUp, false);
857
857
  this.view.domElement.addEventListener('mouseleave', this._handlerOnMouseUp, false);
858
858
  this.view.domElement.addEventListener('mousemove', this._handlerOnMouseMove, false);
859
- this.view.domElement.addEventListener('wheel', this._handlerOnMouseWheel, false); // focus policy
860
-
861
- if (this.focusOnMouseOver) {
862
- this.view.domElement.addEventListener('mouseover', this._handlerFocusOnMouseOver, false);
863
- }
864
-
865
- if (this.focusOnMouseClick) {
866
- this.view.domElement.addEventListener('click', this._handlerFocusOnMouseClick, false);
867
- } // prevent the default context menu from appearing when right-clicking
859
+ this.view.domElement.addEventListener('wheel', this._handlerOnMouseWheel, false); // prevent the default context menu from appearing when right-clicking
868
860
  // this allows to use right-click for input without the menu appearing
869
861
 
870
-
871
862
  this.view.domElement.addEventListener('contextmenu', this._handlerContextMenu, false);
872
863
  }
873
864
  /**
@@ -885,8 +876,6 @@ var PlanarControls = /*#__PURE__*/function (_THREE$EventDispatche) {
885
876
  this.view.domElement.removeEventListener('mouseleave', this._handlerOnMouseUp, false);
886
877
  this.view.domElement.removeEventListener('mousemove', this._handlerOnMouseMove, false);
887
878
  this.view.domElement.removeEventListener('wheel', this._handlerOnMouseWheel, false);
888
- this.view.domElement.removeEventListener('mouseover', this._handlerFocusOnMouseOver, false);
889
- this.view.domElement.removeEventListener('click', this._handlerFocusOnMouseClick, false);
890
879
  this.view.domElement.removeEventListener('contextmenu', this._handlerContextMenu, false);
891
880
  }
892
881
  /**
@@ -959,6 +948,7 @@ var PlanarControls = /*#__PURE__*/function (_THREE$EventDispatche) {
959
948
  key: "onMouseDown",
960
949
  value: function onMouseDown(event) {
961
950
  event.preventDefault();
951
+ this.view.domElement.focus();
962
952
 
963
953
  if (STATE.NONE !== this.state) {
964
954
  return;
@@ -1086,28 +1076,6 @@ var PlanarControls = /*#__PURE__*/function (_THREE$EventDispatche) {
1086
1076
  this.initiateZoom(event);
1087
1077
  }
1088
1078
  }
1089
- /**
1090
- * Set the focus on view's domElement according to focus policy regarding MouseOver
1091
- *
1092
- * @ignore
1093
- */
1094
-
1095
- }, {
1096
- key: "onMouseOver",
1097
- value: function onMouseOver() {
1098
- this.view.domElement.focus();
1099
- }
1100
- /**
1101
- * Set the focus on view's domElement according to focus policy regarding MouseClick
1102
- *
1103
- * @ignore
1104
- */
1105
-
1106
- }, {
1107
- key: "onMouseClick",
1108
- value: function onMouseClick() {
1109
- this.view.domElement.focus();
1110
- }
1111
1079
  /**
1112
1080
  * Catch and manage the event when the context menu is called (by a right-click on the window). We use this
1113
1081
  * to prevent the context menu from appearing so we can use right click for other inputs.