itowns 2.44.3-next.4 → 2.44.3-next.41

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 (217) 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 -608
  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 -726
  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/TileGeometry.js +0 -40
  100. package/lib/Core/TileMesh.js +0 -108
  101. package/lib/Core/View.js +0 -1109
  102. package/lib/Layer/C3DTilesLayer.js +0 -455
  103. package/lib/Layer/ColorLayer.js +0 -128
  104. package/lib/Layer/CopcLayer.js +0 -58
  105. package/lib/Layer/ElevationLayer.js +0 -107
  106. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  107. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  108. package/lib/Layer/GeoidLayer.js +0 -80
  109. package/lib/Layer/GeometryLayer.js +0 -202
  110. package/lib/Layer/InfoLayer.js +0 -64
  111. package/lib/Layer/LabelLayer.js +0 -452
  112. package/lib/Layer/Layer.js +0 -304
  113. package/lib/Layer/LayerUpdateState.js +0 -89
  114. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  115. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  116. package/lib/Layer/OrientedImageLayer.js +0 -222
  117. package/lib/Layer/PointCloudLayer.js +0 -359
  118. package/lib/Layer/Potree2Layer.js +0 -164
  119. package/lib/Layer/PotreeLayer.js +0 -65
  120. package/lib/Layer/RasterLayer.js +0 -27
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  122. package/lib/Layer/TiledGeometryLayer.js +0 -403
  123. package/lib/Loader/LASLoader.js +0 -193
  124. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  125. package/lib/Loader/Potree2Loader.js +0 -207
  126. package/lib/Main.js +0 -115
  127. package/lib/MainBundle.js +0 -4
  128. package/lib/Parser/B3dmParser.js +0 -174
  129. package/lib/Parser/CameraCalibrationParser.js +0 -94
  130. package/lib/Parser/GDFParser.js +0 -72
  131. package/lib/Parser/GTXParser.js +0 -75
  132. package/lib/Parser/GeoJsonParser.js +0 -212
  133. package/lib/Parser/GpxParser.js +0 -25
  134. package/lib/Parser/ISGParser.js +0 -71
  135. package/lib/Parser/KMLParser.js +0 -25
  136. package/lib/Parser/LASParser.js +0 -137
  137. package/lib/Parser/MapBoxUrlParser.js +0 -83
  138. package/lib/Parser/PntsParser.js +0 -131
  139. package/lib/Parser/Potree2BinParser.js +0 -92
  140. package/lib/Parser/PotreeBinParser.js +0 -106
  141. package/lib/Parser/PotreeCinParser.js +0 -29
  142. package/lib/Parser/ShapefileParser.js +0 -78
  143. package/lib/Parser/VectorTileParser.js +0 -202
  144. package/lib/Parser/XbilParser.js +0 -108
  145. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  146. package/lib/Parser/iGLTFLoader.js +0 -168
  147. package/lib/Process/3dTilesProcessing.js +0 -304
  148. package/lib/Process/FeatureProcessing.js +0 -76
  149. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  150. package/lib/Process/ObjectRemovalHelper.js +0 -97
  151. package/lib/Process/handlerNodeError.js +0 -23
  152. package/lib/Provider/3dTilesProvider.js +0 -149
  153. package/lib/Provider/DataSourceProvider.js +0 -8
  154. package/lib/Provider/Fetcher.js +0 -229
  155. package/lib/Provider/PointCloudProvider.js +0 -45
  156. package/lib/Provider/TileProvider.js +0 -16
  157. package/lib/Provider/URLBuilder.js +0 -105
  158. package/lib/Renderer/Camera.js +0 -281
  159. package/lib/Renderer/Color.js +0 -56
  160. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  161. package/lib/Renderer/CommonMaterial.js +0 -31
  162. package/lib/Renderer/Label2DRenderer.js +0 -190
  163. package/lib/Renderer/LayeredMaterial.js +0 -243
  164. package/lib/Renderer/OBB.js +0 -153
  165. package/lib/Renderer/OrientedImageCamera.js +0 -118
  166. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  167. package/lib/Renderer/PointsMaterial.js +0 -485
  168. package/lib/Renderer/RasterTile.js +0 -209
  169. package/lib/Renderer/RenderMode.js +0 -31
  170. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  171. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  172. package/lib/Renderer/SphereHelper.js +0 -23
  173. package/lib/Renderer/WebXR.js +0 -51
  174. package/lib/Renderer/c3DEngine.js +0 -214
  175. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  176. package/lib/Source/C3DTilesIonSource.js +0 -54
  177. package/lib/Source/C3DTilesSource.js +0 -30
  178. package/lib/Source/CopcSource.js +0 -115
  179. package/lib/Source/EntwinePointTileSource.js +0 -62
  180. package/lib/Source/FileSource.js +0 -189
  181. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  182. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  183. package/lib/Source/OGC3DTilesSource.js +0 -21
  184. package/lib/Source/OrientedImageSource.js +0 -59
  185. package/lib/Source/Potree2Source.js +0 -167
  186. package/lib/Source/PotreeSource.js +0 -82
  187. package/lib/Source/Source.js +0 -223
  188. package/lib/Source/TMSSource.js +0 -143
  189. package/lib/Source/VectorTilesSource.js +0 -178
  190. package/lib/Source/WFSSource.js +0 -165
  191. package/lib/Source/WMSSource.js +0 -130
  192. package/lib/Source/WMTSSource.js +0 -86
  193. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  194. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  195. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  196. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  197. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  198. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  199. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  200. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  201. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  202. package/lib/Utils/CameraUtils.js +0 -555
  203. package/lib/Utils/DEMUtils.js +0 -350
  204. package/lib/Utils/FeaturesUtils.js +0 -156
  205. package/lib/Utils/Gradients.js +0 -16
  206. package/lib/Utils/OrientationUtils.js +0 -457
  207. package/lib/Utils/ThreeUtils.js +0 -115
  208. package/lib/Utils/gui/C3DTilesStyle.js +0 -216
  209. package/lib/Utils/gui/Main.js +0 -7
  210. package/lib/Utils/gui/Minimap.js +0 -154
  211. package/lib/Utils/gui/Navigation.js +0 -245
  212. package/lib/Utils/gui/Scale.js +0 -107
  213. package/lib/Utils/gui/Searchbar.js +0 -234
  214. package/lib/Utils/gui/Widget.js +0 -80
  215. package/lib/Utils/placeObjectOnGround.js +0 -137
  216. package/lib/Worker/LASLoaderWorker.js +0 -19
  217. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,216 +0,0 @@
1
- import Style from "../../Core/Style.js";
2
- import { C3DTILES_LAYER_EVENTS } from "../../Layer/C3DTilesLayer.js";
3
- import Widget from "./Widget.js";
4
- const DEFAULT_OPTIONS = {
5
- width: 200,
6
- position: 'top-right'
7
- };
8
-
9
- /**
10
- * A widget for dynamic 3DTiles styling
11
- *
12
- * To use it, you need to link the widgets' stylesheet to your html webpage. This stylesheet is included in
13
- * [itowns bundles](https://github.com/iTowns/itowns/releases) if you downloaded them, or it can be found in
14
- * `node_modules/itowns/examples/css` if you installed iTowns with npm. Otherwise, it can be found at
15
- * [this link](https://raw.githubusercontent.com/iTowns/itowns/master/examples/css/widgets.css). See
16
- * [this example](http://www.itowns-project.org/itowns/examples/#widgets_3dtiles_style) for more details.
17
- *
18
- * @extends Widget
19
- *
20
- * @property {HTMLElement} domElement An html div containing the minimap.
21
- * @property {HTMLElement} parentElement The parent HTML container of `this.domElement`.
22
- */
23
- class C3DTilesStyle extends Widget {
24
- /**
25
- *
26
- * @param {View} view view
27
- * @param {*} options options
28
- */
29
- constructor(view, options) {
30
- super(view, options, DEFAULT_OPTIONS);
31
- this.domElement.onclick = event => event.stopImmediatePropagation();
32
-
33
- // create select of the C3DTilesLayers
34
- const selectC3DTilesLayer = document.createElement('select');
35
- this.domElement.appendChild(selectC3DTilesLayer);
36
-
37
- /** @type {Map<HTMLElement, HTMLElement>} */
38
- const selectOptionLayerContent = new Map();
39
- const updateSelectedLayer = () => {
40
- for (const [sO, lC] of selectOptionLayerContent) {
41
- lC.hidden = sO !== selectC3DTilesLayer.selectedOptions[0];
42
- }
43
- };
44
- selectC3DTilesLayer.onchange = updateSelectedLayer;
45
- view.getLayers().filter(el => el.isC3DTilesLayer === true).forEach(c3DTilesLayer => {
46
- const selectC3DTilesLayerOption = document.createElement('option');
47
- selectC3DTilesLayerOption.innerText = c3DTilesLayer.name;
48
- selectC3DTilesLayer.add(selectC3DTilesLayerOption);
49
- const layerContent = document.createElement('div');
50
- this.domElement.appendChild(layerContent);
51
-
52
- // link select option to layer content
53
- selectOptionLayerContent.set(selectC3DTilesLayerOption, layerContent);
54
-
55
- // wait for C3DTileFeatures to load
56
- c3DTilesLayer.addEventListener(C3DTILES_LAYER_EVENTS.ON_TILE_CONTENT_LOADED, () => {
57
- // reset
58
- while (layerContent.firstChild) {
59
- layerContent.firstChild.remove();
60
- }
61
-
62
- /** @type {Map<string,Array>} */
63
- const buffer = new Map(); // record what are the possible values for a key in batchTable
64
- for (const [, tileC3DTileFeatures] of c3DTilesLayer.tilesC3DTileFeatures) {
65
- for (const [, c3DTileFeature] of tileC3DTileFeatures) {
66
- // eslint-disable-next-line guard-for-in
67
- for (const key in c3DTileFeature.getInfo().batchTable) {
68
- if (!buffer.has(key)) {
69
- buffer.set(key, []);
70
- }
71
-
72
- // check possible value for this key
73
- const value = c3DTileFeature.getInfo().batchTable[key];
74
- if (!buffer.get(key).includes(value)) {
75
- buffer.get(key).push(value);
76
- }
77
- }
78
- }
79
- }
80
-
81
- /** @type {Map<HTMLElement, Function>} */
82
- const colorFunctions = new Map();
83
- /** @type {Map<HTMLElement, Function>} */
84
- const opacityFunctions = new Map();
85
- const appendInputColorAndOpacity = (getKeyValue, key, possibleValues) => {
86
- const inputColor = document.createElement('input');
87
- inputColor.setAttribute('type', 'color');
88
- layerContent.appendChild(inputColor);
89
- inputColor.onchange = () => {
90
- const keyValue = getKeyValue();
91
- if (!possibleValues.includes(keyValue)) {
92
- return;
93
- }
94
- const colorSelected = inputColor.value; // copy
95
- colorFunctions.set(keyValue, c3DTileFeature => {
96
- if (c3DTileFeature.getInfo().batchTable[key] == keyValue) {
97
- return colorSelected;
98
- }
99
- return null;
100
- });
101
- c3DTilesLayer.updateStyle();
102
- view.notifyChange();
103
- };
104
- const opacityElement = document.createElement('input');
105
- opacityElement.setAttribute('type', 'range');
106
- opacityElement.min = 0;
107
- opacityElement.max = 1;
108
- opacityElement.step = 0.1;
109
- opacityElement.value = 1;
110
- layerContent.appendChild(opacityElement);
111
- opacityElement.onchange = () => {
112
- const keyValue = getKeyValue();
113
- if (!possibleValues.includes(keyValue)) {
114
- return;
115
- }
116
- const opacitySelected = opacityElement.value; // copy
117
- opacityFunctions.set(keyValue, c3DTileFeature => {
118
- if (c3DTileFeature.getInfo().batchTable[key] == keyValue) {
119
- return opacitySelected;
120
- }
121
- return null;
122
- });
123
- c3DTilesLayer.updateStyle();
124
- view.notifyChange();
125
- };
126
- return {
127
- inputColor,
128
- opacityElement
129
- };
130
- };
131
- const appendFilterSelect = (key, values) => {
132
- const label = document.createElement('label');
133
- label.innerText = key;
134
- layerContent.appendChild(label);
135
- const selectKey = document.createElement('select');
136
- layerContent.appendChild(selectKey);
137
- values.forEach(value => {
138
- const selectKeyOption = document.createElement('option');
139
- selectKeyOption.value = value;
140
- selectKeyOption.text = value;
141
- selectKey.add(selectKeyOption);
142
- });
143
- appendInputColorAndOpacity(() => selectKey.selectedOptions[0].value, key, values);
144
- };
145
- const appendFilterInputText = (key, values) => {
146
- const label = document.createElement('label');
147
- label.innerText = key;
148
- layerContent.appendChild(label);
149
- const inputText = document.createElement('input');
150
- inputText.setAttribute('type', 'text');
151
- layerContent.appendChild(inputText);
152
- const {
153
- inputColor,
154
- opacityElement
155
- } = appendInputColorAndOpacity(() => inputText.value, key, values);
156
- inputText.onchange = () => {
157
- if (!values.includes(inputText.value)) {
158
- return;
159
- }
160
- const colorSelected = inputColor.value; // copy
161
- const textSelected = inputText.value; // copy
162
- colorFunctions.set(textSelected, c3DTileFeature => {
163
- if (c3DTileFeature.getInfo().batchTable[key] == textSelected) {
164
- return colorSelected;
165
- }
166
- return null;
167
- });
168
- const opacitySelected = opacityElement.value; // copy
169
- opacityFunctions.set(textSelected, c3DTileFeature => {
170
- if (c3DTileFeature.getInfo().batchTable[key] == textSelected) {
171
- return opacitySelected;
172
- }
173
- return null;
174
- });
175
- c3DTilesLayer.updateStyle();
176
- view.notifyChange();
177
- };
178
- };
179
-
180
- // create ui from buffer
181
- for (const [key, values] of buffer) {
182
- if (values.length < C3DTilesStyle.MAX_SELECT_VALUE) {
183
- appendFilterSelect(key, values);
184
- } else {
185
- appendFilterInputText(key, values);
186
- }
187
- }
188
-
189
- // set style
190
- c3DTilesLayer.style = new Style({
191
- fill: {
192
- color: c3DTileFeature => {
193
- let result = null;
194
- for (const [, colorFunction] of colorFunctions) {
195
- result = colorFunction(c3DTileFeature) || result;
196
- }
197
- return result;
198
- },
199
- opacity: c3DTileFeature => {
200
- let result = 1;
201
- for (const [, opacityFunction] of opacityFunctions) {
202
- result = opacityFunction(c3DTileFeature) || result;
203
- }
204
- return result;
205
- }
206
- }
207
- });
208
- });
209
- });
210
- updateSelectedLayer();
211
- }
212
- static get MAX_SELECT_VALUE() {
213
- return 10;
214
- }
215
- }
216
- export default C3DTilesStyle;
@@ -1,7 +0,0 @@
1
- // eslint-disable-next-line import/prefer-default-export
2
- export { default as Navigation } from "./Navigation.js";
3
- export { default as Minimap } from "./Minimap.js";
4
- export { default as Scale } from "./Scale.js";
5
- export { default as Searchbar } from "./Searchbar.js";
6
- export { default as Widget } from "./Widget.js";
7
- export { default as C3DTilesStyle } from "./C3DTilesStyle.js";
@@ -1,154 +0,0 @@
1
- import Coordinates from "../../Core/Geographic/Coordinates.js";
2
- import { MAIN_LOOP_EVENTS } from "../../Core/MainLoop.js";
3
- import PlanarView from "../../Core/Prefab/PlanarView.js";
4
- import { CAMERA_TYPE } from "../../Renderer/Camera.js";
5
- import Widget from "./Widget.js";
6
- const DEFAULT_OPTIONS = {
7
- minScale: 1 / 500000,
8
- maxScale: 1 / 5E8,
9
- zoomRatio: 1 / 30,
10
- width: 150,
11
- height: 150,
12
- position: 'bottom-left'
13
- };
14
-
15
- /**
16
- * A widget for minimap
17
- *
18
- * To use it, you need to link the widgets' stylesheet to your html webpage. This stylesheet is included in
19
- * [itowns bundles](https://github.com/iTowns/itowns/releases) if you downloaded them, or it can be found in
20
- * `node_modules/itowns/examples/css` if you installed iTowns with npm. Otherwise, it can be found at
21
- * [this link](https://raw.githubusercontent.com/iTowns/itowns/master/examples/css/widgets.css). See
22
- * [this example](http://www.itowns-project.org/itowns/examples/#widgets_minimap) for more details.
23
- *
24
- * @extends Widget
25
- *
26
- * @property {HTMLElement} domElement An html div containing the minimap.
27
- * @property {HTMLElement} parentElement The parent HTML container of `this.domElement`.
28
- */
29
- class Minimap extends Widget {
30
- /**
31
- * @param {GlobeView} view The iTowns view the minimap should be
32
- * linked to. Only {@link GlobeView} is
33
- * supported at the moment.
34
- * @param {ColorLayer} layer The {@link ColorLayer} that should be
35
- * displayed on the minimap.
36
- * @param {Object} [options] The minimap optional configuration.
37
- * @param {HTMLElement} [options.parentElement=view.domElement] The parent HTML container of the div
38
- * which contains minimap widgets.
39
- * @param {number} [options.size] The size of the minimap. It is a number
40
- * that describes both width and height
41
- * in pixels of the minimap.
42
- * @param {number} [options.width=150] The width in pixels of the minimap.
43
- * @param {number} [options.height=150] The height in pixels of the minimap.
44
- * @param {string} [options.position='bottom-left'] Defines which position within the
45
- * `parentElement` the minimap should be
46
- * displayed to. Possible values are
47
- * `top`, `bottom`, `left`, `right`,
48
- * `top-left`, `top-right`, `bottom-left`
49
- * and `bottom-right`. If the input value
50
- * does not match one of these, it will
51
- * be defaulted to `bottom-left`.
52
- * @param {Object} [options.translate] An optional translation of the minimap.
53
- * @param {number} [options.translate.x=0] The minimap translation along the page
54
- * x-axis.
55
- * @param {number} [options.translate.y=0] The minimap translation along the page
56
- * y-axis.
57
- * @param {HTMLElement|string} [options.cursor] An html element or an HTML string
58
- * describing a cursor showing minimap
59
- * view camera target position at the
60
- * center of the minimap.
61
- * @param {number} [options.minScale=1/2000] The minimal scale the minimap can reach.
62
- * @param {number} [options.maxScale=1/1_250_000] The maximal scale the minimap can reach.
63
- * @param {number} [options.zoomRatio=1/30] The ratio between minimap camera zoom
64
- * and view camera zoom.
65
- * @param {number} [options.pitch=0.28] The screen pixel pitch, used to compute
66
- * view and minimap scale.
67
- */
68
- constructor(view, layer) {
69
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
70
- // ---------- BUILD PROPERTIES ACCORDING TO DEFAULT OPTIONS AND OPTIONS PASSED IN PARAMETERS : ----------
71
-
72
- if (!view.isGlobeView) {
73
- throw new Error('\'Minimap\' plugin only supports \'GlobeView\'. Therefore, the \'view\' parameter must be a ' + '\'GlobeView\'.');
74
- }
75
- if (!layer.isColorLayer) {
76
- throw new Error('\'layer\' parameter form \'Minimap\' constructor should be a \'ColorLayer\'.');
77
- }
78
- super(view, options, DEFAULT_OPTIONS);
79
- this.minScale = options.minScale || DEFAULT_OPTIONS.minScale;
80
- this.maxScale = options.maxScale || DEFAULT_OPTIONS.maxScale;
81
-
82
- // TODO : it could be interesting to be able to specify a method as zoomRatio parameter. This method could
83
- // return a zoom ratio from the scale of the minimap.
84
- this.zoomRatio = options.zoomRatio || DEFAULT_OPTIONS.zoomRatio;
85
-
86
- // ---------- this.domElement SETTINGS SPECIFIC TO MINIMAP : ----------
87
-
88
- this.domElement.id = 'widgets-minimap';
89
-
90
- // Display a cursor at the center of the minimap, if requested.
91
- if (options.cursor) {
92
- // Wrap cursor domElement inside a div to center it in minimap.
93
- const cursorWrapper = document.createElement('div');
94
- cursorWrapper.id = 'cursor-wrapper';
95
- this.domElement.appendChild(cursorWrapper);
96
-
97
- // Add specified cursor to its wrapper.
98
- if (typeof options.cursor === 'string') {
99
- cursorWrapper.innerHTML = options.cursor;
100
- } else if (options.cursor instanceof HTMLElement) {
101
- cursorWrapper.appendChild(options.cursor);
102
- }
103
- }
104
-
105
- // ---------- CREATE A MINIMAP View AND DISPLAY DATA PASSED IN Layer PARAMETER : ----------
106
-
107
- this.view = new PlanarView(this.domElement, layer.source.extent, {
108
- camera: {
109
- type: CAMERA_TYPE.ORTHOGRAPHIC
110
- },
111
- placement: layer.source.extent,
112
- // TODO : the default placement should be the view extent for ortho camera
113
- noControls: true,
114
- maxSubdivisionLevel: view.tileLayer.maxSubdivisionLevel,
115
- disableFocusOnStart: true
116
- });
117
- this.view.addLayer(layer); // TODO : should this promise be returned by constructor so that user can use it ?
118
-
119
- // Prevent the minimap domElement to get focus when clicked, and prevent click event to be propagated to the
120
- // main view controls.
121
- this.domElement.addEventListener('pointerdown', event => {
122
- event.preventDefault();
123
- });
124
-
125
- // ---------- UPDATE MINIMAP VIEW WHEN UPDATING THE MAIN VIEW : ----------
126
-
127
- // The minimal and maximal value the minimap camera3D zoom can reach in order to stay in the scale limits.
128
- const initialScale = this.view.getScale(options.pitch);
129
- const minZoom = this.view.camera3D.zoom * this.maxScale / initialScale;
130
- const maxZoom = this.view.camera3D.zoom * this.minScale / initialScale;
131
-
132
- // Coordinates used to transform position vectors from the main view CRS to the minimap view CRS.
133
- const mainViewCoordinates = new Coordinates(view.referenceCrs);
134
- const viewCoordinates = new Coordinates(this.view.referenceCrs);
135
- const targetPosition = view.controls.getCameraTargetPosition();
136
- view.addFrameRequester(MAIN_LOOP_EVENTS.AFTER_RENDER, () => {
137
- // Update minimap camera zoom
138
- const distance = view.camera3D.position.distanceTo(targetPosition);
139
- const scale = view.getScaleFromDistance(options.pitch, distance);
140
- this.view.camera3D.zoom = this.zoomRatio * maxZoom * scale / this.minScale;
141
- this.view.camera3D.zoom = Math.min(Math.max(this.view.camera3D.zoom, minZoom), maxZoom);
142
- this.view.camera3D.updateProjectionMatrix();
143
-
144
- // Update minimap camera position.
145
- mainViewCoordinates.setFromVector3(view.controls.getCameraTargetPosition());
146
- mainViewCoordinates.as(this.view.referenceCrs, viewCoordinates);
147
- this.view.camera3D.position.x = viewCoordinates.x;
148
- this.view.camera3D.position.y = viewCoordinates.y;
149
- this.view.camera3D.updateMatrixWorld(true);
150
- this.view.notifyChange(this.view.camera3D);
151
- });
152
- }
153
- }
154
- export default Minimap;
@@ -1,245 +0,0 @@
1
- import { VIEW_EVENTS } from "../../Core/View.js";
2
- import Widget from "./Widget.js";
3
- const DEFAULT_OPTIONS = {
4
- displayCompass: true,
5
- display3DToggle: true,
6
- displayZoomIn: true,
7
- displayZoomOut: true,
8
- animationDuration: 500,
9
- position: 'bottom-left',
10
- direction: 'column'
11
- };
12
- const DEFAULT_BUTTONS = {
13
- compass: {
14
- id: 'compass',
15
- content: '',
16
- info: 'Rotate the camera to face North',
17
- parentId: 'widgets'
18
- },
19
- toggle3D: {
20
- id: '3d-button',
21
- content: '3D',
22
- info: 'Tilt the camera'
23
- },
24
- zoomIn: {
25
- id: 'zoom-in-button',
26
- content: '<span class="widget-zoom-button-logo"></span>',
27
- info: 'Zoom in',
28
- parentId: 'zoom-button-bar'
29
- },
30
- zoomOut: {
31
- id: 'zoom-out-button',
32
- content: '<span id="zoom-out-logo" class="widget-zoom-button-logo"></span>',
33
- info: 'Zoom out',
34
- parentId: 'zoom-button-bar'
35
- }
36
- };
37
-
38
- /**
39
- * A widget menu manager for navigation.
40
- *
41
- * To use it, you need to link the widgets' stylesheet to your html webpage. This stylesheet is included in
42
- * [itowns bundles](https://github.com/iTowns/itowns/releases) if you downloaded them, or it can be found in
43
- * `node_modules/itowns/examples/css` if you installed iTowns with npm. Otherwise, it can be found at
44
- * [this link](https://raw.githubusercontent.com/iTowns/itowns/master/examples/css/widgets.css). See
45
- * [this example](http://www.itowns-project.org/itowns/examples/#widgets_navigation) for more details.
46
- *
47
- * @extends Widget
48
- *
49
- * @property {HTMLElement} domElement An html div containing all navigation widgets.
50
- * @property {HTMLElement} parentElement The parent HTML container of `this.domElement`.
51
- * @property {HTMLButtonElement} compass The HTML button for the compass.
52
- * @property {HTMLButtonElement} toggle3D The HTML button for the 3D/2D toggle button.
53
- * @property {HTMLButtonElement} zoomIn The HTML button for the zoom-in button.
54
- * @property {HTMLButtonElement} zoomOut The HTML button for the zoom-out button.
55
- *
56
- * @example
57
- * // Create a Navigation widget in the bottom-right corner of an iTowns view domElement
58
- * const navigation = new Navigation(view, { position: 'bottom-right' };
59
- *
60
- * // Change the tooltip for the compass :
61
- * navigation.compass.title = 'new tooltip';
62
- *
63
- * // Change the method ran when clicking zoom-in button :
64
- * function newMethod() {
65
- * // do something
66
- * }
67
- * navigation.zoomIn.onclick = newMethod;
68
- */
69
- class Navigation extends Widget {
70
- #_view;
71
- #_action(params) {
72
- params.time = this.animationDuration;
73
- return this.#_view.controls.lookAtCoordinate(params);
74
- }
75
- #_addDefaultButton(settings, onclick) {
76
- return this.addButton(settings.id, settings.content, settings.info, onclick, settings.parentId);
77
- }
78
-
79
- /**
80
- * @param {GlobeView} view The iTowns view the navigation should be linked
81
- * to. For the moment, only `{@link GlobeView}`
82
- * is supported.
83
- * @param {Object} options The navigation menu optional configuration.
84
- * @param {HTMLElement} [options.parentElement=view.domElement] The parent HTML container of the div which
85
- * contains navigation widgets.
86
- * @param {boolean} [options.displayCompass=true] Whether the compass widget should be displayed.
87
- * @param {boolean} [options.display3DToggle=true] Whether the navigation should include a widget
88
- * to toggle between top and oblique view.
89
- * @param {boolean} [options.displayZoomIn=true] Whether the zoom-in widget should be displayed.
90
- * @param {boolean} [options.displayZoomOut=true] Whether the zoom-out widget should be displayed.
91
- * @param {number} [options.animationDuration=500] The duration of travel animations, when clicking
92
- * navigation widgets.
93
- * @param {string} [options.position='bottom-left'] Defines which corner of the `parentElement` the
94
- * navigation menu should be displayed to.
95
- * Possible values are `top-left`, `top-right`,
96
- * `bottom-left` and `bottom-right`. If the input
97
- * value does not match one of these, it will be
98
- * defaulted to `bottom-left`.
99
- * @param {string} [options.direction='column'] Whether the navigation menu should expand
100
- * horizontally or vertically. Possible values
101
- * are `column` and `row`. If the input value
102
- * does not match one of these, it will be
103
- * defaulted to `column`.
104
- * @param {Object} [options.translate] An optional translation of the navigation menu.
105
- * @param {number} [options.translate.x=0] The navigation menu translation along the page
106
- * x-axis.
107
- * @param {number} [options.translate.y=0] The navigation menu translation along the page
108
- * y-axis.
109
- */
110
- constructor(view) {
111
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
112
- // ---------- BUILD PROPERTIES ACCORDING TO DEFAULT OPTIONS AND OPTIONS PASSED IN PARAMETERS : ----------
113
-
114
- // Check if the view is supported.
115
- if (!view.isGlobeView) {
116
- throw new Error('\'Navigation\' plugin only supports \'GlobeView\'. Therefore, the \'view\' parameter must be a ' + '\'GlobeView\'.');
117
- }
118
-
119
- // `top`, `bottom`, `left` and `right` values for `position` option are not relevant for navigation widget.
120
- if (['top', 'bottom', 'left', 'right'].includes(options.position)) {
121
- console.warn('\'position\' optional parameter for \'Navigation\' is not a valid option. ' + `It will be set to '${DEFAULT_OPTIONS.position}'.`);
122
- options.position = DEFAULT_OPTIONS.position;
123
- }
124
- super(view, options, DEFAULT_OPTIONS);
125
- this.#_view = view;
126
- this.direction = options.direction || DEFAULT_OPTIONS.direction;
127
- if (!['column', 'row'].includes(this.direction)) {
128
- console.warn('\'direction\' optional parameter for \'Navigation\' constructor is not a valid option. ' + `It will be set to '${DEFAULT_OPTIONS.direction}'.`);
129
- this.direction = DEFAULT_OPTIONS.direction;
130
- }
131
- this.animationDuration = options.animationDuration === undefined ? DEFAULT_OPTIONS.animationDuration : options.animationDuration;
132
-
133
- // ---------- CREATE A DomElement WITH id AND classes RELEVANT TO THE WIDGET PROPERTIES : ----------
134
-
135
- // Create a div containing all widgets and add it to its specified parent.
136
- this.domElement.id = 'widgets-navigation';
137
-
138
- // Position widget div according to options.
139
- this.domElement.classList.add(`${this.direction}-widget`);
140
-
141
- // ---------- CREATE THE DEFAULT WIDGETS IF NOT HIDDEN (COMPASS, 3D AND ZOOM BUTTONS) : ----------
142
-
143
- // Add a compass widget if requested.
144
- if (options.displayCompass ?? DEFAULT_OPTIONS.displayCompass) {
145
- this.compass = this.#_addDefaultButton(DEFAULT_BUTTONS.compass, () => {
146
- this.#_action({
147
- heading: 0,
148
- tilt: 89.5
149
- });
150
- });
151
-
152
- // Manage compass rotation when the view's camera is moved.
153
- view.addEventListener(VIEW_EVENTS.CAMERA_MOVED, event => {
154
- this.compass.style.transform = `rotate(${-event.heading}deg)`;
155
- });
156
- }
157
-
158
- // Add a 3D toggle button if requested.
159
- if (options.display3DToggle ?? DEFAULT_OPTIONS.display3DToggle) {
160
- this.toggle3D = this.#_addDefaultButton(DEFAULT_BUTTONS.toggle3D, () => {
161
- this.#_action({
162
- tilt: this.#_view.controls.getTilt() < 89 ? 89.5 : 40
163
- });
164
- });
165
-
166
- // Manage button content toggle when the view's camera is moved.
167
- view.addEventListener(VIEW_EVENTS.CAMERA_MOVED, event => {
168
- this.toggle3D.innerHTML = event.tilt < 89 ? '2D' : '3D';
169
- });
170
- }
171
-
172
- // Add a zoom-in button if requested.
173
- if (options.displayZoomIn ?? DEFAULT_OPTIONS.displayZoomIn) {
174
- this.zoomIn = this.#_addDefaultButton(DEFAULT_BUTTONS.zoomIn, () => {
175
- this.#_action({
176
- zoom: Math.min(20, this.#_view.controls.getZoom() + 1)
177
- });
178
- });
179
- }
180
-
181
- // Add a zoom-out button if requested.
182
- if (options.displayZoomOut ?? DEFAULT_OPTIONS.displayZoomOut) {
183
- this.zoomOut = this.#_addDefaultButton(DEFAULT_BUTTONS.zoomOut, () => {
184
- this.#_action({
185
- zoom: Math.max(3, this.#_view.controls.getZoom() - 1)
186
- });
187
- });
188
- }
189
- }
190
-
191
- /**
192
- *
193
- * @param {string} id The unique id the created button should be given.
194
- * @param {string} [content=''] An HTML string defining the content of the button.
195
- * @param {string} [title=''] An HTML string defining information on the button. This string will be
196
- * displayed in a tooltip when hovering the button.
197
- * @param {function} [onclick] The method that should be executed when the button is clicked on.
198
- * @param {string} [parentId] The unique id of a button bar in which the created button should be added.
199
- * A button bar is a group which contains one or several buttons. All
200
- * buttons created with Navigation are in a button bar. If the given id does
201
- * not match an already existing button bar, a new button bar will be created
202
- * with this id. If no id is given, a button bar will be created with no id.
203
- * The later case can be useful for creating isolated buttons.
204
- *
205
- * @returns {HTMLButtonElement} The created button.
206
- */
207
- addButton(id) {
208
- let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
209
- let title = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
210
- let onclick = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => {};
211
- let parentId = arguments.length > 4 ? arguments[4] : undefined;
212
- let buttonBar = document.getElementById(parentId);
213
- if (!buttonBar) {
214
- buttonBar = this.addButtonBar(parentId);
215
- }
216
- const button = document.createElement('button');
217
- button.className = 'widget-button';
218
- button.id = id;
219
- button.innerHTML = content;
220
- button.title = title;
221
- button.onclick = onclick;
222
- buttonBar.appendChild(button);
223
-
224
- // The buttons must not be focused using tab key.
225
- button.tabIndex = -1;
226
- // When releasing the mouse after clicking the button, we give the focus back to the view. Therefore, we can use
227
- // key events on the view without having to click the view to grant it focus.
228
- window.addEventListener('pointerup', () => {
229
- if (document.activeElement === button) {
230
- this.#_view.domElement.focus();
231
- }
232
- });
233
- return button;
234
- }
235
- addButtonBar(id) {
236
- const buttonBar = document.createElement('div');
237
- buttonBar.className = 'widget-button-bar';
238
- if (id) {
239
- buttonBar.id = id;
240
- }
241
- this.domElement.appendChild(buttonBar);
242
- return buttonBar;
243
- }
244
- }
245
- export default Navigation;