itowns 2.44.3-next.8 → 2.45.0

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 (219) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -615
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -534
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/Tile/Tile.js +0 -219
  100. package/lib/Core/Tile/TileGrid.js +0 -46
  101. package/lib/Core/TileGeometry.js +0 -40
  102. package/lib/Core/TileMesh.js +0 -109
  103. package/lib/Core/View.js +0 -1109
  104. package/lib/Layer/C3DTilesLayer.js +0 -455
  105. package/lib/Layer/ColorLayer.js +0 -128
  106. package/lib/Layer/CopcLayer.js +0 -58
  107. package/lib/Layer/ElevationLayer.js +0 -107
  108. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  109. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  110. package/lib/Layer/GeoidLayer.js +0 -80
  111. package/lib/Layer/GeometryLayer.js +0 -202
  112. package/lib/Layer/InfoLayer.js +0 -64
  113. package/lib/Layer/LabelLayer.js +0 -456
  114. package/lib/Layer/Layer.js +0 -304
  115. package/lib/Layer/LayerUpdateState.js +0 -89
  116. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  117. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  118. package/lib/Layer/OrientedImageLayer.js +0 -222
  119. package/lib/Layer/PointCloudLayer.js +0 -359
  120. package/lib/Layer/Potree2Layer.js +0 -164
  121. package/lib/Layer/PotreeLayer.js +0 -65
  122. package/lib/Layer/RasterLayer.js +0 -27
  123. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  124. package/lib/Layer/TiledGeometryLayer.js +0 -403
  125. package/lib/Loader/LASLoader.js +0 -193
  126. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  127. package/lib/Loader/Potree2Loader.js +0 -207
  128. package/lib/Main.js +0 -115
  129. package/lib/MainBundle.js +0 -4
  130. package/lib/Parser/B3dmParser.js +0 -174
  131. package/lib/Parser/CameraCalibrationParser.js +0 -94
  132. package/lib/Parser/GDFParser.js +0 -72
  133. package/lib/Parser/GTXParser.js +0 -75
  134. package/lib/Parser/GeoJsonParser.js +0 -212
  135. package/lib/Parser/GpxParser.js +0 -25
  136. package/lib/Parser/ISGParser.js +0 -71
  137. package/lib/Parser/KMLParser.js +0 -25
  138. package/lib/Parser/LASParser.js +0 -137
  139. package/lib/Parser/MapBoxUrlParser.js +0 -83
  140. package/lib/Parser/PntsParser.js +0 -131
  141. package/lib/Parser/Potree2BinParser.js +0 -92
  142. package/lib/Parser/PotreeBinParser.js +0 -106
  143. package/lib/Parser/PotreeCinParser.js +0 -29
  144. package/lib/Parser/ShapefileParser.js +0 -78
  145. package/lib/Parser/VectorTileParser.js +0 -202
  146. package/lib/Parser/XbilParser.js +0 -119
  147. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  148. package/lib/Parser/iGLTFLoader.js +0 -168
  149. package/lib/Process/3dTilesProcessing.js +0 -304
  150. package/lib/Process/FeatureProcessing.js +0 -76
  151. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  152. package/lib/Process/ObjectRemovalHelper.js +0 -97
  153. package/lib/Process/handlerNodeError.js +0 -23
  154. package/lib/Provider/3dTilesProvider.js +0 -149
  155. package/lib/Provider/DataSourceProvider.js +0 -8
  156. package/lib/Provider/Fetcher.js +0 -229
  157. package/lib/Provider/PointCloudProvider.js +0 -45
  158. package/lib/Provider/TileProvider.js +0 -16
  159. package/lib/Provider/URLBuilder.js +0 -116
  160. package/lib/Renderer/Camera.js +0 -281
  161. package/lib/Renderer/Color.js +0 -56
  162. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  163. package/lib/Renderer/CommonMaterial.js +0 -31
  164. package/lib/Renderer/Label2DRenderer.js +0 -190
  165. package/lib/Renderer/LayeredMaterial.js +0 -243
  166. package/lib/Renderer/OBB.js +0 -153
  167. package/lib/Renderer/OrientedImageCamera.js +0 -118
  168. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  169. package/lib/Renderer/PointsMaterial.js +0 -485
  170. package/lib/Renderer/RasterTile.js +0 -209
  171. package/lib/Renderer/RenderMode.js +0 -31
  172. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  173. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  174. package/lib/Renderer/SphereHelper.js +0 -23
  175. package/lib/Renderer/WebXR.js +0 -51
  176. package/lib/Renderer/c3DEngine.js +0 -214
  177. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  178. package/lib/Source/C3DTilesIonSource.js +0 -54
  179. package/lib/Source/C3DTilesSource.js +0 -30
  180. package/lib/Source/CopcSource.js +0 -115
  181. package/lib/Source/EntwinePointTileSource.js +0 -62
  182. package/lib/Source/FileSource.js +0 -189
  183. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  184. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  185. package/lib/Source/OGC3DTilesSource.js +0 -21
  186. package/lib/Source/OrientedImageSource.js +0 -59
  187. package/lib/Source/Potree2Source.js +0 -167
  188. package/lib/Source/PotreeSource.js +0 -82
  189. package/lib/Source/Source.js +0 -223
  190. package/lib/Source/TMSSource.js +0 -145
  191. package/lib/Source/VectorTilesSource.js +0 -178
  192. package/lib/Source/WFSSource.js +0 -168
  193. package/lib/Source/WMSSource.js +0 -133
  194. package/lib/Source/WMTSSource.js +0 -86
  195. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  196. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  197. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  198. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  199. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  200. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  201. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  202. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  203. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  204. package/lib/Utils/CameraUtils.js +0 -555
  205. package/lib/Utils/DEMUtils.js +0 -350
  206. package/lib/Utils/FeaturesUtils.js +0 -156
  207. package/lib/Utils/Gradients.js +0 -16
  208. package/lib/Utils/OrientationUtils.js +0 -457
  209. package/lib/Utils/ThreeUtils.js +0 -115
  210. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  211. package/lib/Utils/gui/Main.js +0 -7
  212. package/lib/Utils/gui/Minimap.js +0 -154
  213. package/lib/Utils/gui/Navigation.js +0 -245
  214. package/lib/Utils/gui/Scale.js +0 -107
  215. package/lib/Utils/gui/Searchbar.js +0 -234
  216. package/lib/Utils/gui/Widget.js +0 -80
  217. package/lib/Utils/placeObjectOnGround.js +0 -137
  218. package/lib/Worker/LASLoaderWorker.js +0 -19
  219. 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,137 +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
- /* istanbul ignore next */
59
- function placeObjectOnGround(layer, crs, obj) {
60
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
61
- let tileHint = arguments.length > 4 ? arguments[4] : undefined;
62
- console.warn('placeObjectOnGround has been deprecated because it needs review and test');
63
- let tiles;
64
- if (tileHint) {
65
- tiles = tileHint.concat(layer.level0Nodes);
66
- } else {
67
- tiles = layer.level0Nodes;
68
- }
69
- if (!options.modifyGeometry) {
70
- if (options.cache) {
71
- options.cache.length = 1;
72
- }
73
- const matrices = {
74
- worldFromLocal: obj.parent ? obj.parent.matrixWorld : undefined,
75
- localFromWorld: obj.parent ? new THREE.Matrix4().copy(obj.parent.matrixWorld).invert() : undefined
76
- };
77
- 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);
78
- if (result) {
79
- if (options.cache) {
80
- options.cache[0] = result;
81
- }
82
- obj.updateMatrix();
83
- obj.updateMatrixWorld();
84
- return true;
85
- }
86
- } else {
87
- const matrices = {
88
- worldFromLocal: obj.matrixWorld,
89
- localFromWorld: new THREE.Matrix4().copy(obj.matrixWorld).invert()
90
- };
91
- const geometry = obj.geometry;
92
- if (geometry.vertices) {
93
- if (options.cache) {
94
- options.cache.length = geometry.vertices.length;
95
- }
96
- let success = true;
97
- const coord = new Coordinates(crs);
98
- for (let i = 0; i < geometry.vertices.length; i++) {
99
- const cached = options.cache ? options.cache[i] : undefined;
100
- const result = _updateVector3(layer, options.method || DEMUtils.FAST_READ_Z, tiles, crs, geometry.vertices[i], options.offset || 0, matrices, coord, cached);
101
- if (options.cache) {
102
- options.cache[i] = result;
103
- }
104
- if (!result) {
105
- success = false;
106
- }
107
- }
108
- geometry.verticesNeedUpdate = true;
109
- return success;
110
- } else if (geometry.isBufferGeometry) {
111
- if (options.cache) {
112
- options.cache.length = geometry.attributes.position.count;
113
- }
114
- let success = true;
115
- const tmp = new THREE.Vector3();
116
- const coord = new Coordinates(crs);
117
- for (let i = 0; i < geometry.attributes.position.count; i++) {
118
- const cached = options.cache ? options.cache[i] : undefined;
119
- tmp.fromBufferAttribute(geometry.attributes.position, i);
120
- const prev = tmp.z;
121
- const result = _updateVector3(layer, options.method || DEMUtils.FAST_READ_Z, tiles, crs, tmp, options.offset || 0, matrices, coord, cached);
122
- if (options.cache) {
123
- options.cache[i] = result;
124
- }
125
- if (!result) {
126
- success = false;
127
- }
128
- if (prev != tmp.z) {
129
- geometry.attributes.position.needsUpdate = true;
130
- }
131
- geometry.attributes.position.setXYZ(i, tmp.x, tmp.y, tmp.z);
132
- }
133
- return success;
134
- }
135
- }
136
- }
137
- 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
- });