itowns 2.44.3-next.40 → 2.44.3-next.42

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 (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,107 +0,0 @@
1
- import { CONTROL_EVENTS } from "../../Controls/GlobeControls.js";
2
- import { GLOBE_VIEW_EVENTS } from "../../Core/Prefab/GlobeView.js";
3
- import { PLANAR_CONTROL_EVENT } from "../../Controls/PlanarControls.js";
4
- import { VIEW_EVENTS } from "../../Core/View.js";
5
- import Widget from "./Widget.js";
6
- const DEFAULT_OPTIONS = {
7
- width: 200,
8
- height: 30,
9
- position: 'bottom-left'
10
- };
11
-
12
- /**
13
- * A widget for scale
14
- *
15
- * To use it, you need to link the widgets' stylesheet to your html webpage. This stylesheet is included in
16
- * [itowns bundles](https://github.com/iTowns/itowns/releases) if you downloaded them, or it can be found in
17
- * `node_modules/itowns/examples/css` if you installed iTowns with npm. Otherwise, it can be found at
18
- * [this link](https://raw.githubusercontent.com/iTowns/itowns/master/examples/css/widgets.css). See
19
- * [this example](http://www.itowns-project.org/itowns/examples/#widgets_scale) for more details.
20
- *
21
- * @extends Widget
22
- *
23
- * @property {HTMLElement} domElement An html div containing the scale.
24
- * @property {HTMLElement} parentElement The parent HTML container of `this.domElement`.
25
- */
26
- class Scale extends Widget {
27
- /**
28
- * @param {View} view The iTowns view the scale should be
29
- * linked to. If it is a
30
- * {@link PlanarView} or a
31
- * {@link GlobeView}, the scale will be
32
- * automatically updated. Otherwise, user
33
- * will need to implement the update
34
- * automation using the `Scale.update`
35
- * method.
36
- * @param {Object} [options] The scale optional configuration.
37
- * @param {HTMLElement} [options.parentElement=view.domElement] The parent HTML container of the div
38
- * which contains scale widgets.
39
- * @param {number} [options.width=200] The width in pixels of the scale.
40
- * @param {number} [options.height=30] The height in pixels of the scale.
41
- * @param {string} [options.position='bottom-left'] Defines which position within the
42
- * `parentElement` the scale should be
43
- * displayed to. Possible values are
44
- * `top`, `bottom`, `left`, `right`,
45
- * `top-left`, `top-right`, `bottom-left`
46
- * and `bottom-right`. If the input value
47
- * does not match one of these, it will
48
- * be defaulted to `bottom-left`.
49
- * @param {Object} [options.translate] An optional translation of the scale.
50
- * @param {number} [options.translate.x=0] The scale translation along the page
51
- * x-axis.
52
- * @param {number} [options.translate.y=0] The scale translation along the page
53
- * y-axis.
54
- */
55
- constructor(view) {
56
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
57
- // ---------- BUILD PROPERTIES ACCORDING TO DEFAULT OPTIONS AND OPTIONS PASSED IN PARAMETERS : ----------
58
-
59
- super(view, options, DEFAULT_OPTIONS);
60
-
61
- // ---------- this.domElement SETTINGS SPECIFIC TO SCALE : ----------
62
-
63
- this.domElement.id = 'widgets-scale';
64
- this.view = view;
65
-
66
- // Initialize the text content of the scale, which will later be updated by a numerical value.
67
- this.domElement.innerHTML = 'Scale';
68
- this.width = options.width || DEFAULT_OPTIONS.width;
69
- if (this.view.isGlobeView) {
70
- this.view.addEventListener(GLOBE_VIEW_EVENTS.GLOBE_INITIALIZED, () => {
71
- this.update();
72
- });
73
- this.view.controls.addEventListener(CONTROL_EVENTS.RANGE_CHANGED, () => {
74
- this.update();
75
- });
76
- } else if (this.view.isPlanarView) {
77
- this.view.addEventListener(VIEW_EVENTS.INITIALIZED, () => {
78
- this.update();
79
- });
80
- this.view.addEventListener(PLANAR_CONTROL_EVENT.MOVED, () => {
81
- this.update();
82
- });
83
- } else {
84
- console.warn('The \'view\' linked to scale widget is neither a \'GlobeView\' nor a \'PlanarView\'. The ' + 'scale wont automatically update. You can implement its update automation using \'Scale.update\' ' + 'method.');
85
- }
86
- }
87
- addEventListeners() {}
88
-
89
- /**
90
- * Update the scale size and content according to view camera position.
91
- */
92
- update() {
93
- // Calculate the rounded metric distance which matches the scale width in pixels.
94
- let metricDistance = Math.round(this.view.getPixelsToMeters(this.width));
95
- const digit = 10 ** (metricDistance.toString().length - 1);
96
- metricDistance = Math.round(metricDistance / digit) * digit;
97
- const pixelDistance = this.view.getMetersToPixels(metricDistance);
98
- let unit = 'm';
99
- if (metricDistance >= 1000) {
100
- metricDistance /= 1000;
101
- unit = 'km';
102
- }
103
- this.domElement.innerHTML = `${metricDistance} ${unit}`;
104
- this.domElement.style.width = `${pixelDistance}px`;
105
- }
106
- }
107
- export default Scale;
@@ -1,234 +0,0 @@
1
- import Fetcher from "../../Provider/Fetcher.js";
2
- import Widget from "./Widget.js";
3
- const DEFAULT_OPTIONS = {
4
- width: 300,
5
- height: 38,
6
- position: 'top',
7
- maxSuggestionNumber: 10,
8
- fontSize: 16,
9
- placeholder: 'Search location'
10
- };
11
- function addActive(htmlElements, index) {
12
- if (!htmlElements) {
13
- return index;
14
- }
15
- removeAllActives(htmlElements);
16
- if (index >= htmlElements.length) {
17
- index = 0;
18
- } else if (index < 0) {
19
- index = htmlElements.length - 1;
20
- }
21
- htmlElements[index]?.classList.add('active');
22
- return index;
23
- }
24
- function removeAllActives(htmlElements) {
25
- for (let i = 0; i < htmlElements.length; i++) {
26
- htmlElements[i].classList.remove('active');
27
- }
28
- }
29
- function eraseSuggestionList(form) {
30
- while (form.children.length > 1) {
31
- form.removeChild(form.lastChild);
32
- }
33
- }
34
-
35
- /**
36
- * A widget for searchbar
37
- *
38
- * To use it, you need to link the widgets' stylesheet to your html webpage. This stylesheet is included in
39
- * [itowns bundles](https://github.com/iTowns/itowns/releases) if you downloaded them, or it can be found in
40
- * `node_modules/itowns/examples/css` if you installed iTowns with npm. Otherwise, it can be found at
41
- * [this link](https://raw.githubusercontent.com/iTowns/itowns/master/examples/css/widgets.css). See
42
- * [this example](http://www.itowns-project.org/itowns/examples/#widgets_searchbar) for more details.
43
- *
44
- * @extends Widget
45
- *
46
- * @property {HTMLElement} domElement An html div containing the searchbar.
47
- * @property {HTMLElement} parentElement The parent HTML container of `this.domElement`.
48
- */
49
- class Searchbar extends Widget {
50
- #_onSelected;
51
-
52
- /**
53
- * @param {View} view The iTowns view the searchbar should be linked
54
- * to.
55
- *
56
- * @param {Object} geocodingOptions Configuration for geocoding.
57
- * @param {URL} geocodingOptions.url The URL of a geocoding service that should be
58
- * used to build suggestions.
59
- * @param {function} geocodingOptions.parser A method to parse fetched results from geocoding
60
- * url into a Map object. For each entry of this
61
- * Map, the key must be a string that will be
62
- * displayed as the html content of each
63
- * suggestion bellow the searchbar. The value
64
- * associated to the key is whatever the user
65
- * wants. The value is the parameter that is
66
- * passed to the `onSelected` method (specified
67
- * in another `geocodingOptions` parameter).
68
- * @param {function} [geocodingOptions.onSelected] A method which describes what should be done
69
- * when user selects a location (by clicking or
70
- * hitting enter on a suggestion). The only
71
- * parameter of this method is the value mapped
72
- * with `geocodingOptions.parser` method.
73
- *
74
- * @param {Object} [options] The searchbar optional configuration.
75
- * @param {HTMLElement} [options.parentElement=view.domElement] The parent HTML container of the div which
76
- * contains searchbar widgets.
77
- * @param {number} [options.size] The size of the searchbar. It is a number that
78
- * describes both width and height in pixels of
79
- * the searchbar.
80
- * @param {number} [options.width=300] The width in pixels of the searchbar.
81
- * @param {number} [options.height=38] The height in pixels of the searchbar.
82
- * @param {string} [options.position='top'] Defines which position within the
83
- * `parentElement` the searchbar should be
84
- * displayed to. Possible values are `top`,
85
- * `bottom`, `left`, `right`, `top-left`,
86
- * `top-right`, `bottom-left` and `bottom-right`.
87
- * If the input value does not match one of
88
- * these, it will be defaulted to `top`.
89
- * @param {Object} [options.translate] An optional translation of the searchbar.
90
- * @param {number} [options.translate.x=0] The searchbar translation along the page x-axis.
91
- * @param {number} [options.translate.y=0] The searchbar translation along the page y-axis.
92
- * @param {number} [options.fontSize=16] The font size in pixel of the searchbar content.
93
- * @param {number} [options.maxSuggestionNumber=10] The maximum number of suggestions that should
94
- * appear under the searchbar.
95
- * @param {string} [options.placeholder='Search location'] The placeholder that appears in the searchbar
96
- * when nothing has yet been typed.
97
- */
98
- constructor(view, geocodingOptions) {
99
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
100
- // ---------- BUILD PROPERTIES ACCORDING TO DEFAULT OPTIONS AND OPTIONS PASSED IN PARAMETERS : ----------
101
- super(view, options, DEFAULT_OPTIONS);
102
-
103
- // Check if `geocodingOptions` parameter was correctly specified.
104
- if (!geocodingOptions || !geocodingOptions.url || !geocodingOptions.parser || typeof geocodingOptions.parser !== 'function') {
105
- throw new Error('\'geocodingOptions\' parameter for \'Searchbar\' constructor is not a valid option. Please refer to ' + 'the documentation.');
106
- }
107
- this.#_onSelected = geocodingOptions.onSelected ?? (() => {});
108
-
109
- // ---------- this.domElement SETTINGS SPECIFIC TO SEARCHBAR : ----------
110
-
111
- this.domElement.id = 'widgets-searchbar';
112
- this.domElement.style.height = 'auto';
113
- const form = document.createElement('form');
114
- form.setAttribute('autocomplete', 'off');
115
- form.id = 'searchbar-autocompletion-form';
116
- this.domElement.appendChild(form);
117
- const input = document.createElement('input');
118
- input.setAttribute('type', 'text');
119
- input.setAttribute('name', 'mySearch');
120
- input.setAttribute('placeholder', options.placeholder || DEFAULT_OPTIONS.placeholder);
121
- input.style.height = `${options.height || options.size || DEFAULT_OPTIONS.height}px`;
122
- input.style.fontSize = `${options.fontSize || DEFAULT_OPTIONS.fontSize}px`;
123
- form.appendChild(input);
124
-
125
- // currentFocus variable stores the index of the suggestions that is focused by user, either with mouse or arrow
126
- // keys.
127
- let currentFocus;
128
-
129
- // ---------- BUILD AUTOCOMPLETION SUGGESTIONS LIST WHEN TYPING THE SEARCHBAR INPUT : ----------
130
-
131
- input.addEventListener('input', () => {
132
- const value = input.value;
133
-
134
- // Close any already opened list of autocompleted values
135
- eraseSuggestionList(form);
136
- currentFocus = -1;
137
- if (!value) {
138
- return false;
139
- }
140
- geocodingOptions.url.searchParams.set('text', value);
141
- Fetcher.json(geocodingOptions.url).then(geocodingResult => {
142
- const result = geocodingOptions.parser(geocodingResult);
143
- let i = 0;
144
- result.forEach((info, location) => {
145
- // Stop looping through the map if enough location have been proceeded.
146
- if (i === Math.min(result.size, options.maxSuggestionNumber || DEFAULT_OPTIONS.maxSuggestionNumber)) {
147
- return;
148
- }
149
- const mapIndex = i;
150
- i++;
151
- const index = location.toUpperCase().indexOf(value.toUpperCase());
152
- if (index > -1) {
153
- const autocompleteItem = document.createElement('div');
154
- autocompleteItem.style.minHeight = input.style.height;
155
- autocompleteItem.style.fontSize = `${options.fontSize || DEFAULT_OPTIONS.fontSize}px`;
156
-
157
- // Make the matching letters bold.
158
- const start = location.slice(0, index);
159
- const bold = location.slice(index, index + value.length);
160
- const end = location.slice(index + value.length, location.length);
161
- autocompleteItem.innerHTML = `<p>${start}<strong>${bold}</strong>${end}</p>`;
162
- // Store the current location value as an attribute of autocompleteItem div.
163
- autocompleteItem.setAttribute('location', location);
164
- form.appendChild(autocompleteItem);
165
-
166
- // eslint-disable-next-line no-loop-func
167
- autocompleteItem.addEventListener('mouseover', () => {
168
- removeAllActives(form.children);
169
- currentFocus = mapIndex;
170
- autocompleteItem.classList.add('active');
171
- });
172
- autocompleteItem.addEventListener('click', () => {
173
- this.#_onSelected(info);
174
- input.value = autocompleteItem.getAttribute('location');
175
- eraseSuggestionList(form);
176
- });
177
- }
178
- });
179
- });
180
- });
181
-
182
- // ---------- MANAGE KEYBOARD INTERACTIONS ON AUTOCOMPLETION SUGGESTIONS : ----------
183
-
184
- // When searchbar is positioned at the bottom of the screen (therefore is a flex with `column-reverse`
185
- // direction, we must exchange up and down arrow actions.
186
- const topOrBottom = (options.position || DEFAULT_OPTIONS.position).includes('top') ? 1 : -1;
187
- input.addEventListener('keydown', event => {
188
- event.stopPropagation();
189
- const completionSuggestions = form.getElementsByTagName('div');
190
- switch (event.code) {
191
- case 'Escape':
192
- eraseSuggestionList(form);
193
- input.value = '';
194
- view.domElement.focus();
195
- break;
196
- case 'ArrowDown':
197
- event.preventDefault();
198
- currentFocus = addActive(completionSuggestions, currentFocus + topOrBottom);
199
- break;
200
- case 'ArrowUp':
201
- event.preventDefault();
202
- currentFocus = addActive(completionSuggestions, currentFocus - topOrBottom);
203
- break;
204
- case 'Enter':
205
- event.preventDefault();
206
- if (completionSuggestions[Math.max(currentFocus, 0)]) {
207
- completionSuggestions[Math.max(currentFocus, 0)].click();
208
- view.domElement.focus();
209
- }
210
- break;
211
- default:
212
- break;
213
- }
214
- });
215
-
216
- // ---------- MANAGE FOCUS AND ACTIVE SUGGESTION WHEN USER ENTERS OR LEAVES THE SEARCHBAR : ----------
217
-
218
- // User clicks the searchbar.
219
- input.addEventListener('focus', () => {
220
- form.classList.add('focus');
221
- });
222
- // User clicks out of the searchbar.
223
- input.addEventListener('blur', () => {
224
- form.classList.remove('focus');
225
- removeAllActives(form.children);
226
- });
227
- // Cursor leaves the searchbar.
228
- form.addEventListener('mouseleave', () => {
229
- removeAllActives(form.children);
230
- currentFocus = -1;
231
- });
232
- }
233
- }
234
- export default Searchbar;
@@ -1,80 +0,0 @@
1
- /**
2
- * An interface that stores common methods for all specific widgets.
3
- *
4
- * @hideconstructor
5
- */
6
- class Widget {
7
- #_display;
8
- constructor(view) {
9
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
10
- let defaultOptions = arguments.length > 2 ? arguments[2] : undefined;
11
- this.parentElement = options.parentElement || view.domElement;
12
- this.position = options.position || defaultOptions.position;
13
- if (!['top-left', 'top-right', 'bottom-left', 'bottom-right', 'top', 'bottom', 'left', 'right'].includes(this.position)) {
14
- console.warn('\'position\' optional parameter for \'Widget\' constructor is not a valid option. ' + `It will be set to '${defaultOptions.position}'.`);
15
- this.position = defaultOptions.position;
16
- }
17
-
18
- // ---------- CREATE A DomElement WITH id, classes AND style RELEVANT TO THE WIDGET PROPERTIES : ----------
19
-
20
- // Create a div containing minimap widget and add it to its specified parent.
21
- this.domElement = document.createElement('div');
22
- this.parentElement.appendChild(this.domElement);
23
-
24
- // Size widget according to options.
25
- this.domElement.style.width = `${options.width || options.size || defaultOptions.width}px`;
26
- this.domElement.style.height = `${options.height || options.size || defaultOptions.height}px`;
27
-
28
- // Position widget according to options.
29
- const positionArray = this.position.split('-');
30
- this.domElement.classList.add(`${positionArray[0]}-widget`);
31
- if (positionArray[1]) {
32
- this.domElement.classList.add(`${positionArray[1]}-widget`);
33
- } else {
34
- // If only one position parameter was given, center the domElement on the other axis.
35
- // TODO : at this stage, offsetWidth and offsetHeight do no include borders. This should be worked around.
36
- switch (positionArray[0]) {
37
- case 'top':
38
- case 'bottom':
39
- this.domElement.style.left = `calc(50% - ${this.domElement.offsetWidth / 2}px)`;
40
- break;
41
- case 'left':
42
- case 'right':
43
- this.domElement.style.top = `calc(50% - ${this.domElement.offsetHeight / 2}px)`;
44
- break;
45
- default:
46
- break;
47
- }
48
- }
49
-
50
- // Translate widget div according to optional translate parameter.
51
- if (options.translate) {
52
- this.domElement.style.transform = `translate(${options.translate.x || 0}px, ${options.translate.y || 0}px)`;
53
- }
54
-
55
- // Prevent triggering `GlobeControls` and `PlanarControls` mouse or pointer events when clicking the search bar.
56
- // For example, this prevents triggering an animated travel when double-clicking search bar in a `GlobeView`.
57
- this.domElement.addEventListener('pointerdown', e => {
58
- e.stopPropagation();
59
- });
60
- this.domElement.addEventListener('mousedown', e => {
61
- e.stopPropagation();
62
- });
63
- }
64
-
65
- /**
66
- * Change the widget style `display` property so that the widget becomes visible.
67
- */
68
- show() {
69
- this.domElement.style.display = this.#_display;
70
- }
71
-
72
- /**
73
- * Change the widget style `display` property so that the widget becomes invisible.
74
- */
75
- hide() {
76
- this.#_display = window.getComputedStyle(this.domElement).display;
77
- this.domElement.style.display = 'none';
78
- }
79
- }
80
- export default Widget;
@@ -1,136 +0,0 @@
1
- import * as THREE from 'three';
2
- import DEMUtils from "./DEMUtils.js";
3
- import Coordinates from "../Core/Geographic/Coordinates.js";
4
- const temp = {
5
- v: new THREE.Vector3(),
6
- coord1: new Coordinates('EPSG:4978'),
7
- coord2: new Coordinates('EPSG:4978'),
8
- offset: new THREE.Vector2()
9
- };
10
- function _updateVector3(layer, method, nodes, vecCRS, vec, offset) {
11
- let matrices = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
12
- let coords = arguments.length > 7 ? arguments[7] : undefined;
13
- let cache = arguments.length > 8 ? arguments[8] : undefined;
14
- const coord = coords || new Coordinates(vecCRS);
15
- if (matrices.worldFromLocal) {
16
- coord.setFromVector3(temp.v.copy(vec).applyMatrix4(matrices.worldFromLocal));
17
- } else {
18
- coord.setFromVector3(vec);
19
- }
20
- const result = DEMUtils.getTerrainObjectAt(layer, coord, method, nodes, cache);
21
- if (result) {
22
- result.coord.z += offset;
23
- result.coord.as(vecCRS, temp.coord2).toVector3(vec);
24
- if (matrices.localFromWorld) {
25
- vec.applyMatrix4(matrices.localFromWorld);
26
- }
27
- return {
28
- id: result.texture.id,
29
- version: result.texture.version,
30
- tile: result.tile
31
- };
32
- }
33
- }
34
-
35
- /**
36
- * @deprecated
37
- * Helper method that will position an object directly on the ground.
38
- *
39
- * @param {TiledGeometryLayer} layer - The tile layer owning the elevation
40
- * textures we're going to query. This is typically a `GlobeLayer` or
41
- * `PlanarLayer` (accessible through `view.tileLayer`).
42
- * @param {string} crs - The CRS used by the object coordinates. You
43
- * probably want to use `view.referenceCRS` here.
44
- * @param {Object3D} obj - the object we want to modify.
45
- * @param {Object} options
46
- * @param {number} [options.method=FAST_READ_Z] - There are two available methods:
47
- * `FAST_READ_Z` (default) or `PRECISE_READ_Z`. The first one is faster,
48
- * while the second one is slower but gives better precision.
49
- * @param {boolean} options.modifyGeometry - if unset/false, this function
50
- * will modify object.position. If true, it will modify
51
- * `obj.geometry.vertices` or `obj.geometry.attributes.position`.
52
- * @param {TileMesh[]} [tileHint] - Optional array of tiles to speed up the
53
- * process. You can give candidates tiles likely to contain `coord`.
54
- * Otherwise the lookup process starts from the root of `layer`.
55
- *
56
- * @return {boolean} true if successful, false if we couldn't lookup the elevation at the given coords
57
- */
58
- function placeObjectOnGround(layer, crs, obj) {
59
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
60
- let tileHint = arguments.length > 4 ? arguments[4] : undefined;
61
- console.warn('placeObjectOnGround has been deprecated because it needs review and test');
62
- let tiles;
63
- if (tileHint) {
64
- tiles = tileHint.concat(layer.level0Nodes);
65
- } else {
66
- tiles = layer.level0Nodes;
67
- }
68
- if (!options.modifyGeometry) {
69
- if (options.cache) {
70
- options.cache.length = 1;
71
- }
72
- const matrices = {
73
- worldFromLocal: obj.parent ? obj.parent.matrixWorld : undefined,
74
- localFromWorld: obj.parent ? new THREE.Matrix4().copy(obj.parent.matrixWorld).invert() : undefined
75
- };
76
- const result = _updateVector3(layer, options.method || DEMUtils.FAST_READ_Z, tiles, crs, obj.position, options.offset || 0, matrices, undefined, options.cache ? options.cache[0] : undefined);
77
- if (result) {
78
- if (options.cache) {
79
- options.cache[0] = result;
80
- }
81
- obj.updateMatrix();
82
- obj.updateMatrixWorld();
83
- return true;
84
- }
85
- } else {
86
- const matrices = {
87
- worldFromLocal: obj.matrixWorld,
88
- localFromWorld: new THREE.Matrix4().copy(obj.matrixWorld).invert()
89
- };
90
- const geometry = obj.geometry;
91
- if (geometry.vertices) {
92
- if (options.cache) {
93
- options.cache.length = geometry.vertices.length;
94
- }
95
- let success = true;
96
- const coord = new Coordinates(crs);
97
- for (let i = 0; i < geometry.vertices.length; i++) {
98
- const cached = options.cache ? options.cache[i] : undefined;
99
- const result = _updateVector3(layer, options.method || DEMUtils.FAST_READ_Z, tiles, crs, geometry.vertices[i], options.offset || 0, matrices, coord, cached);
100
- if (options.cache) {
101
- options.cache[i] = result;
102
- }
103
- if (!result) {
104
- success = false;
105
- }
106
- }
107
- geometry.verticesNeedUpdate = true;
108
- return success;
109
- } else if (geometry.isBufferGeometry) {
110
- if (options.cache) {
111
- options.cache.length = geometry.attributes.position.count;
112
- }
113
- let success = true;
114
- const tmp = new THREE.Vector3();
115
- const coord = new Coordinates(crs);
116
- for (let i = 0; i < geometry.attributes.position.count; i++) {
117
- const cached = options.cache ? options.cache[i] : undefined;
118
- tmp.fromBufferAttribute(geometry.attributes.position, i);
119
- const prev = tmp.z;
120
- const result = _updateVector3(layer, options.method || DEMUtils.FAST_READ_Z, tiles, crs, tmp, options.offset || 0, matrices, coord, cached);
121
- if (options.cache) {
122
- options.cache[i] = result;
123
- }
124
- if (!result) {
125
- success = false;
126
- }
127
- if (prev != tmp.z) {
128
- geometry.attributes.position.needsUpdate = true;
129
- }
130
- geometry.attributes.position.setXYZ(i, tmp.x, tmp.y, tmp.z);
131
- }
132
- return success;
133
- }
134
- }
135
- }
136
- export default placeObjectOnGround;
@@ -1,19 +0,0 @@
1
- import { expose, Transfer } from 'threads/worker';
2
- import LASLoader from "../Loader/LASLoader.js";
3
- const loader = new LASLoader();
4
- function transferable(attributes) {
5
- return Object.values(attributes).filter(ArrayBuffer.isView).map(a => a.buffer);
6
- }
7
- expose({
8
- lazPerf(path) {
9
- loader.lazPerf = path;
10
- },
11
- async parseChunk(data, options) {
12
- const result = await loader.parseChunk(data, options);
13
- return Transfer(result, transferable(result.attributes));
14
- },
15
- async parseFile(data, options) {
16
- const result = await loader.parseFile(data, options);
17
- return Transfer(result, transferable(result.attributes));
18
- }
19
- });
@@ -1,21 +0,0 @@
1
- import load from "../Loader/Potree2Loader.js";
2
- import loadBrotli from "../Loader/Potree2BrotliLoader.js";
3
- import { expose, Transfer } from 'threads/worker';
4
- function transfer(buffer, data) {
5
- const transferables = [];
6
- Object.keys(data.attributeBuffers).forEach(property => {
7
- transferables.push(data.attributeBuffers[property].buffer);
8
- });
9
- transferables.push(buffer);
10
- return transferables;
11
- }
12
- expose({
13
- async parse(buffer, options) {
14
- const data = await load(buffer, options);
15
- return Transfer(data, transfer(buffer, data));
16
- },
17
- async parseBrotli(buffer, options) {
18
- const data = await loadBrotli(buffer, options);
19
- return Transfer(data, transfer(buffer, data));
20
- }
21
- });