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,229 +0,0 @@
1
- import { TextureLoader, DataTexture, RedFormat, FloatType } from 'three';
2
- const textureLoader = new TextureLoader();
3
- const SIZE_TEXTURE_TILE = 256;
4
- function checkResponse(response) {
5
- if (!response.ok) {
6
- const error = new Error(`Error loading ${response.url}: status ${response.status}`);
7
- error.response = response;
8
- throw error;
9
- }
10
- }
11
- const arrayBuffer = function (url) {
12
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
13
- return fetch(url, options).then(response => {
14
- checkResponse(response);
15
- return response.arrayBuffer();
16
- });
17
- };
18
- function getTextureFloat(buffer) {
19
- const texture = new DataTexture(buffer, SIZE_TEXTURE_TILE, SIZE_TEXTURE_TILE, RedFormat, FloatType);
20
- texture.internalFormat = 'R32F';
21
- texture.needsUpdate = true;
22
- return texture;
23
- }
24
-
25
- /**
26
- * Utilitary to fetch resources from a server using the [fetch API](
27
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch).
28
- *
29
- * @module Fetcher
30
- */
31
- export default {
32
- /**
33
- * Wrapper over fetch to get some text.
34
- *
35
- * @param {string} url - The URL of the resources to fetch.
36
- * @param {Object} options - Fetch options (passed directly to `fetch()`),
37
- * see [the syntax for more information](
38
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
39
- *
40
- * @return {Promise<string>} Promise containing the text.
41
- */
42
- text(url) {
43
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
44
- return fetch(url, options).then(response => {
45
- checkResponse(response);
46
- return response.text();
47
- });
48
- },
49
- /**
50
- * Little wrapper over fetch to get some JSON.
51
- *
52
- * @param {string} url - The URL of the resources to fetch.
53
- * @param {Object} options - Fetch options (passed directly to `fetch()`),
54
- * see [the syntax for more information](
55
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
56
- *
57
- * @return {Promise<Object>} Promise containing the JSON object.
58
- */
59
- json(url) {
60
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
61
- return fetch(url, options).then(response => {
62
- checkResponse(response);
63
- return response.json();
64
- });
65
- },
66
- /**
67
- * Wrapper over fetch to get some XML.
68
- *
69
- * @param {string} url - The URL of the resources to fetch.
70
- * @param {Object} options - Fetch options (passed directly to `fetch()`),
71
- * see [the syntax for more information](
72
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
73
- *
74
- * @return {Promise<Document>} Promise containing the XML Document.
75
- */
76
- xml(url) {
77
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
78
- return fetch(url, options).then(response => {
79
- checkResponse(response);
80
- return response.text();
81
- }).then(text => new window.DOMParser().parseFromString(text, 'text/xml'));
82
- },
83
- /**
84
- * Wrapper around [THREE.TextureLoader](https://threejs.org/docs/#api/en/loaders/TextureLoader).
85
- *
86
- * @param {string} url - The URL of the resources to fetch.
87
- * @param {Object} options - Fetch options (passed directly to `fetch()`),
88
- * see [the syntax for more information](
89
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
90
- * Note that THREE.js docs mentions `withCredentials`, but it is not
91
- * actually used in [THREE.TextureLoader](https://threejs.org/docs/#api/en/loaders/TextureLoader).
92
- *
93
- * @return {Promise<THREE.Texture>} Promise containing the
94
- * [THREE.Texture](https://threejs.org/docs/api/en/textures/Texture.html).
95
- */
96
- texture(url) {
97
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
98
- let res;
99
- let rej;
100
- textureLoader.crossOrigin = options.crossOrigin;
101
- const promise = new Promise((resolve, reject) => {
102
- res = resolve;
103
- rej = reject;
104
- });
105
- textureLoader.load(url, res, () => {}, rej);
106
- return promise;
107
- },
108
- /**
109
- * Wrapper over fetch to get some ArrayBuffer.
110
- *
111
- * @param {string} url - The URL of the resources to fetch.
112
- * @param {Object} options - Fetch options (passed directly to `fetch()`),
113
- * see [the syntax for more information](
114
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
115
- *
116
- * @return {Promise<ArrayBuffer>} Promise containing the ArrayBuffer.
117
- */
118
- arrayBuffer,
119
- /**
120
- * Wrapper over fetch to get some
121
- * [THREE.DataTexture](https://threejs.org/docs/#api/en/textures/DataTexture).
122
- *
123
- * @param {string} url - The URL of the resources to fetch.
124
- * @param {Object} options - Fetch options (passed directly to `fetch()`),
125
- * see [the syntax for more information](
126
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
127
- *
128
- * @return {Promise<THREE.DataTexture>} Promise containing the DataTexture.
129
- */
130
- textureFloat(url) {
131
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
132
- return arrayBuffer(url, options).then(buffer => {
133
- const floatArray = new Float32Array(buffer);
134
- const texture = getTextureFloat(floatArray);
135
- return texture;
136
- });
137
- },
138
- /**
139
- * Wrapper over fetch to get a bunch of files sharing the same name, but
140
- * different extensions.
141
- *
142
- * @param {string} baseUrl - The shared URL of the resources to fetch.
143
- * @param {Object} extensions - An object containing arrays. The keys of
144
- * each of this array are available fetch type, such as `text`, `json` or
145
- * even `arrayBuffer`. The arrays contains the extensions to append after
146
- * the `baseUrl` (see example below).
147
- * @param {Object} options - Fetch options (passed directly to `fetch()`),
148
- * see [the syntax for more information](
149
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
150
- *
151
- * @return {Promise[]} An array of promises, containing all the files,
152
- * organized by their extensions (see the example below).
153
- *
154
- * @example
155
- * itowns.Fetcher.multiple('http://geo.server/shapefile', {
156
- * // will fetch:
157
- * // - http://geo.server/shapefile.shp
158
- * // - http://geo.server/shapefile.dbf
159
- * // - http://geo.server/shapefile.shx
160
- * // - http://geo.server/shapefile.prj
161
- * arrayBuffer: ['shp', 'dbf', 'shx'],
162
- * text: ['prj'],
163
- * }).then(function _(result) {
164
- * // result looks like:
165
- * result = {
166
- * shp: ArrayBuffer
167
- * dbf: ArrayBuffer
168
- * shx: ArrayBuffer
169
- * prj: string
170
- * };
171
- * });
172
- */
173
- multiple(baseUrl, extensions) {
174
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
175
- const promises = [];
176
- let url;
177
- for (const fetchType in extensions) {
178
- if (!this[fetchType]) {
179
- throw new Error(`${fetchType} is not a valid Fetcher method.`);
180
- } else {
181
- for (const extension of extensions[fetchType]) {
182
- url = `${baseUrl}.${extension}`;
183
- promises.push(this[fetchType](url, options).then(result => ({
184
- type: extension,
185
- result
186
- })));
187
- }
188
- }
189
- }
190
- return Promise.all(promises).then(result => {
191
- const all = {};
192
- for (const res of result) {
193
- all[res.type] = res.result;
194
- }
195
- return Promise.resolve(all);
196
- });
197
- },
198
- get() {
199
- let format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
200
- const [type, subtype] = format.split('/');
201
- switch (type) {
202
- case 'application':
203
- switch (subtype) {
204
- case 'geo+json':
205
- case 'json':
206
- return this.json;
207
- case 'kml':
208
- case 'gpx':
209
- return this.xml;
210
- case 'x-protobuf;type=mapbox-vector':
211
- case 'gtx':
212
- return this.arrayBuffer;
213
- case 'isg':
214
- case 'gdf':
215
- default:
216
- return this.text;
217
- }
218
- case 'image':
219
- switch (subtype) {
220
- case 'x-bil;bits=32':
221
- return this.textureFloat;
222
- default:
223
- return this.texture;
224
- }
225
- default:
226
- return this.texture;
227
- }
228
- }
229
- };
@@ -1,45 +0,0 @@
1
- import * as THREE from 'three';
2
- import Extent from "../Core/Geographic/Extent.js";
3
- let nextuuid = 1;
4
- function addPickingAttribute(points) {
5
- // generate unique id for picking
6
- const numPoints = points.geometry.attributes.position.count;
7
- const ids = new Uint8Array(4 * numPoints);
8
- const baseId = nextuuid++;
9
- if (numPoints > 0xffff || baseId > 0xffff) {
10
- // TODO: fixme
11
- console.warn('Currently picking is limited to Points with less than 65535 elements and less than 65535 Points instances');
12
- return points;
13
- }
14
- for (let i = 0; i < numPoints; i++) {
15
- // todo numpoints > 16bits
16
- const v = baseId << 16 | i;
17
- ids[4 * i + 0] = (v & 0xff000000) >> 24;
18
- ids[4 * i + 1] = (v & 0x00ff0000) >> 16;
19
- ids[4 * i + 2] = (v & 0x0000ff00) >> 8;
20
- ids[4 * i + 3] = (v & 0x000000ff) >> 0;
21
- }
22
- points.baseId = baseId;
23
- points.geometry.setAttribute('unique_id', new THREE.BufferAttribute(ids, 4, true));
24
- return points;
25
- }
26
- export default {
27
- executeCommand(command) {
28
- const layer = command.layer;
29
- const node = command.requester;
30
- return node.load().then(geometry => {
31
- const points = new THREE.Points(geometry, layer.material);
32
- addPickingAttribute(points);
33
- points.frustumCulled = false;
34
- points.matrixAutoUpdate = false;
35
- points.position.copy(geometry.userData.origin || node.bbox.min);
36
- points.scale.copy(layer.scale);
37
- points.updateMatrix();
38
- points.tightbbox = geometry.boundingBox.applyMatrix4(points.matrix);
39
- points.layer = layer;
40
- points.extent = Extent.fromBox3(command.view.referenceCrs, node.bbox);
41
- points.userData.node = node;
42
- return points;
43
- });
44
- }
45
- };
@@ -1,16 +0,0 @@
1
- import CancelledCommandException from "../Core/Scheduler/CancelledCommandException.js";
2
- export default {
3
- executeCommand(command) {
4
- const promises = [];
5
- const layer = command.layer;
6
- const requester = command.requester;
7
- const extentsSource = command.extentsSource;
8
- if (requester && !requester.material) {
9
- return Promise.reject(new CancelledCommandException(command));
10
- }
11
- for (const extent of extentsSource) {
12
- promises.push(layer.convert(requester, extent));
13
- }
14
- return Promise.all(promises);
15
- }
16
- };
@@ -1,116 +0,0 @@
1
- let subDomainsCount = 0;
2
-
3
- /**
4
- * @param {string} url
5
- * @returns {string}
6
- */
7
- function subDomains(url) {
8
- const subDomainsPtrn = /\$\{u:([\w-_.|]+)\}/.exec(url);
9
- if (!subDomainsPtrn) {
10
- return url;
11
- }
12
- const subDomainsList = subDomainsPtrn[1].split('|');
13
- return url.replace(subDomainsPtrn[0], subDomainsList[subDomainsCount++ % subDomainsList.length]);
14
- }
15
-
16
- /**
17
- * This module performs basic operations around urls, to replace some elements
18
- * in it by coordinates or other things.
19
- *
20
- * In an url, it is also possible to specify subdomains alternatives using the
21
- * `${u:a|b|c}` pattern, by separating differents options using `|`. It will go
22
- * through the following alternative each time (no random). For example
23
- * `https://${u:xyz.org|yzx.org|zxy.org}/${z}/${x}/${y}.png` or
24
- * `https://${u:a|b|c}.tile.openstreetmap.org/${z}/${x}/${y}.png`.
25
- *
26
- * @module URLBuilder
27
- */
28
- export default {
29
- subDomains,
30
- /**
31
- * Builds an URL knowing the coordinates and the source to query.
32
- * <br><br>
33
- * The source object needs to have an url property, which should have some
34
- * specific strings that will be replaced by coordinates.
35
- * <ul>
36
- * <li>`${x}` or `%COL` will be replaced by `coords.col`</li>
37
- * <li>`${y}` or `%ROW` will be replaced by `coords.row`</li>
38
- * <li>`${z}` or `%TILEMATRIX` will be replaced by `coords.zoom`</li>
39
- * </ul>
40
- *
41
- * @example
42
- * coords = new Extent(CRS.formatToTms('EPSG:4326'), 12, 1410, 2072);
43
- * source.url = 'http://server.geo/wmts/SERVICE=WMTS&TILEMATRIX=%TILEMATRIX&TILEROW=%ROW&TILECOL=%COL';
44
- * url = URLBuilder.xyz(coords, source);
45
- *
46
- * // The resulting url is:
47
- * // http://server.geo/wmts/SERVICE=WMTS&TILEMATRIX=12&TILEROW=1410&TILECOL=2072;
48
- *
49
- * @example
50
- * coords = new Extent('TMS', 15, 2142, 3412);
51
- * source.url = 'http://server.geo/tms/${z}/${y}/${x}.jpg';
52
- * url = URLBuilder.xyz(coords, source);
53
- *
54
- * // The resulting url is:
55
- * // http://server.geo/tms/15/2142/3412.jpg;
56
- *
57
- * @param {Object} coords - tile coordinates
58
- * @param {number} coords.row - tile row
59
- * @param {number} coords.col - tile column
60
- * @param {number} coords.zoom - tile zoom
61
- * @param {Object} source
62
- * @param {string} source.url
63
- * @param {Function} source.tileMatrixCallback
64
- *
65
- * @return {string} the formed url
66
- */
67
- xyz: function (coords, source) {
68
- return subDomains(source.url.replace(/(\$\{z\}|%TILEMATRIX)/, source.tileMatrixCallback(coords.zoom)).replace(/(\$\{y\}|%ROW)/, coords.row).replace(/(\$\{x\}|%COL)/, coords.col));
69
- },
70
- /**
71
- * Builds an URL knowing the bounding box and the source to query.
72
- * <br><br>
73
- * The source object needs to have an url property, which should have the
74
- * string `%bbox` in it. This string will be replaced by the four cardinal
75
- * points composing the bounding box.
76
- * <br><br>
77
- * Order of the points can be specified in the `axisOrder` property in
78
- * source, using the letters `w, s, e, n` respectively for `WEST, SOUTH,
79
- * EAST, NORTH`. The default order is `wsen`.
80
- *
81
- * @example
82
- * extent = new Extent('EPSG:4326', 12, 14, 35, 46);
83
- * source.crs = 'EPSG:4326';
84
- * source.url = 'http://server.geo/wms/BBOX=%bbox&FORMAT=jpg&SERVICE=WMS';
85
- * url = URLBuilder.bbox(extent, source);
86
- *
87
- * // The resulting url is:
88
- * // http://server.geo/wms/BBOX=12,35,14,46&FORMAT=jpg&SERVICE=WMS
89
- *
90
- * @param {Object} bbox - the bounding box
91
- * @param {number} bbox.west
92
- * @param {number} bbox.south
93
- * @param {number} bbox.east
94
- * @param {number} bbox.north
95
- * @param {Object} source - the source of data
96
- * @param {string} source.crs
97
- * @param {number} source.bboxDigits
98
- * @param {string} source.url
99
- * @param {string} source.axisOrder
100
- *
101
- * @return {string} the formed url
102
- */
103
- bbox: function (bbox, source) {
104
- let precision = source.crs == 'EPSG:4326' ? 9 : 2;
105
- if (source.bboxDigits !== undefined) {
106
- precision = source.bboxDigits;
107
- }
108
- const w = bbox.west.toFixed(precision);
109
- const s = bbox.south.toFixed(precision);
110
- const e = bbox.east.toFixed(precision);
111
- const n = bbox.north.toFixed(precision);
112
- let bboxInUnit = source.axisOrder || 'wsen';
113
- bboxInUnit = bboxInUnit.replace('w', `${w},`).replace('s', `${s},`).replace('e', `${e},`).replace('n', `${n},`).slice(0, -1);
114
- return subDomains(source.url.replace('%bbox', bboxInUnit));
115
- }
116
- };
@@ -1,281 +0,0 @@
1
- import * as THREE from 'three';
2
- import Coordinates from "../Core/Geographic/Coordinates.js";
3
- import DEMUtils from "../Utils/DEMUtils.js";
4
-
5
- /**
6
- * @typedef {object} Camera~CAMERA_TYPE
7
- * Stores the different types of camera usable in iTowns.
8
- *
9
- * @property {number} PERSPECTIVE Perspective type of camera
10
- * @property {number} ORTHOGRAPHIC Orthographic type of camera
11
- */
12
- export const CAMERA_TYPE = {
13
- PERSPECTIVE: 0,
14
- ORTHOGRAPHIC: 1
15
- };
16
- const tmp = {
17
- frustum: new THREE.Frustum(),
18
- matrix: new THREE.Matrix4(),
19
- box3: new THREE.Box3()
20
- };
21
- const ndcBox3 = new THREE.Box3(new THREE.Vector3(-1, -1, -1), new THREE.Vector3(1, 1, 1));
22
- function updatePreSse(camera, height, fov) {
23
- // sse = projected geometric error on screen plane from distance
24
- // We're using an approximation, assuming that the geometric error of all
25
- // objects is perpendicular to the camera view vector (= we always compute
26
- // for worst case).
27
- //
28
- // screen plane object
29
- // | __
30
- // | / \
31
- // | geometric{|
32
- // < fov angle . } sse error {| |
33
- // | \__/
34
- // |
35
- // |<--------------------->
36
- // | distance
37
- //
38
- // geometric_error * screen_width (resp. screen_height)
39
- // = ---------------------------------------
40
- // 2 * distance * tan (horizontal_fov / 2) (resp. vertical_fov)
41
- //
42
- //
43
- // We pre-compute the preSSE (= constant part of the screen space error formula) once here
44
-
45
- // Note: the preSSE for the horizontal FOV is the same value
46
- // focal = (this.height * 0.5) / Math.tan(verticalFOV * 0.5);
47
- // horizontalFOV = 2 * Math.atan(this.width * 0.5 / focal);
48
- // horizontalPreSSE = this.width / (2.0 * Math.tan(horizontalFOV * 0.5)); (1)
49
- // => replacing horizontalFOV in Math.tan(horizontalFOV * 0.5)
50
- // Math.tan(horizontalFOV * 0.5) = Math.tan(2 * Math.atan(this.width * 0.5 / focal) * 0.5)
51
- // = Math.tan(Math.atan(this.width * 0.5 / focal))
52
- // = this.width * 0.5 / focal
53
- // => now replacing focal
54
- // = this.width * 0.5 / (this.height * 0.5) / Math.tan(verticalFOV * 0.5)
55
- // = Math.tan(verticalFOV * 0.5) * this.width / this.height
56
- // => back to (1)
57
- // horizontalPreSSE = this.width / (2.0 * Math.tan(verticalFOV * 0.5) * this.width / this.height)
58
- // = this.height / 2.0 * Math.tan(verticalFOV * 0.5)
59
- // = verticalPreSSE
60
-
61
- if (camera.camera3D.isOrthographicCamera) {
62
- camera._preSSE = height;
63
- } else {
64
- const verticalFOV = THREE.MathUtils.degToRad(fov);
65
- camera._preSSE = height / (2.0 * Math.tan(verticalFOV * 0.5));
66
- }
67
- }
68
-
69
- /**
70
- * Wrapper around Three.js camera to expose some geographic helpers.
71
- *
72
- * @property {string} crs The camera's coordinate projection system.
73
- * @property {THREE.Camera} camera3D The Three.js camera that is wrapped around.
74
- * @property {number} width The width of the camera.
75
- * @property {number} height The height of the camera.
76
- * @property {number} _preSSE The precomputed constant part of the screen space error.
77
- */
78
- class Camera {
79
- #_viewMatrixNeedsUpdate = true;
80
- #_viewMatrix = (() => new THREE.Matrix4())();
81
-
82
- /**
83
- * @param {string} crs The camera's coordinate projection system.
84
- * @param {number} width The width (in pixels) of the view the
85
- * camera is associated to.
86
- * @param {number} height The height (in pixels) of the view the
87
- * camera is associated to.
88
- * @param {Object} [options] Options for the camera.
89
- * @param {THREE.Camera} [options.cameraThree] A custom Three.js camera object to wrap
90
- * around.
91
- * @param {Camera~CAMERA_TYPE} [options.type=CAMERA_TYPE.PERSPECTIVE] The type of the camera. See {@link
92
- * CAMERA_TYPE}.
93
- * @constructor
94
- */
95
- constructor(crs, width, height) {
96
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
97
- this.crs = crs;
98
- if (options.isCamera) {
99
- console.warn('options.camera parameter is deprecated. Use options.camera.cameraThree to place a custom ' + 'camera as a parameter. See the documentation of Camera.');
100
- this.camera3D = options;
101
- } else if (options.cameraThree) {
102
- this.camera3D = options.cameraThree;
103
- } else {
104
- switch (options.type) {
105
- case CAMERA_TYPE.ORTHOGRAPHIC:
106
- this.camera3D = new THREE.OrthographicCamera();
107
- break;
108
- case CAMERA_TYPE.PERSPECTIVE:
109
- default:
110
- this.camera3D = new THREE.PerspectiveCamera(30);
111
- break;
112
- }
113
- }
114
- this.camera3D.aspect = this.camera3D.aspect ?? 1;
115
- this.width = width;
116
- this.height = height;
117
- this.resize(width, height);
118
- this._preSSE = Infinity;
119
- if (this.camera3D.isPerspectiveCamera) {
120
- let fov = this.camera3D.fov;
121
- Object.defineProperty(this.camera3D, 'fov', {
122
- get: () => fov,
123
- set: newFov => {
124
- fov = newFov;
125
- updatePreSse(this, this.height, fov);
126
- }
127
- });
128
- }
129
- }
130
-
131
- /**
132
- * Resize the camera to a given width and height.
133
- *
134
- * @param {number} width The width to resize the camera to. Must be strictly positive, won't resize otherwise.
135
- * @param {number} height The height to resize the camera to. Must be strictly positive, won't resize otherwise.
136
- */
137
- resize(width, height) {
138
- if (!width || width <= 0 || !height || height <= 0) {
139
- console.warn(`Trying to resize the Camera with invalid height (${height}) or width (${width}). Skipping resize.`);
140
- return;
141
- }
142
- const ratio = width / height;
143
- if (this.camera3D.aspect !== ratio) {
144
- if (this.camera3D.isOrthographicCamera) {
145
- this.camera3D.zoom *= this.width / width;
146
- const halfH = this.camera3D.top * this.camera3D.aspect / ratio;
147
- this.camera3D.bottom = -halfH;
148
- this.camera3D.top = halfH;
149
- } else if (this.camera3D.isPerspectiveCamera) {
150
- this.camera3D.fov = 2 * THREE.MathUtils.radToDeg(Math.atan(height / this.height * Math.tan(THREE.MathUtils.degToRad(this.camera3D.fov) / 2)));
151
- }
152
- this.camera3D.aspect = ratio;
153
- }
154
- this.width = width;
155
- this.height = height;
156
- updatePreSse(this, this.height, this.camera3D.fov);
157
- if (this.camera3D.updateProjectionMatrix) {
158
- this.camera3D.updateProjectionMatrix();
159
- this.#_viewMatrixNeedsUpdate = true;
160
- }
161
- }
162
- update() {
163
- // update matrix
164
- this.camera3D.updateMatrixWorld();
165
- this.#_viewMatrixNeedsUpdate = true;
166
- }
167
-
168
- /**
169
- * Return the position in the requested CRS, or in camera's CRS if undefined.
170
- *
171
- * @param {string} [crs] If defined (e.g 'EPSG:4326'), the camera position will be returned in this CRS.
172
- *
173
- * @return {Coordinates} Coordinates object holding camera's position.
174
- */
175
- position(crs) {
176
- return new Coordinates(this.crs, this.camera3D.position).as(crs || this.crs);
177
- }
178
-
179
- /**
180
- * Set the position of the camera using a Coordinates object.
181
- * If you want to modify the position directly using x,y,z values then use `camera.camera3D.position.set(x, y, z)`
182
- *
183
- * @param {Coordinates} position The new position of the camera.
184
- */
185
- setPosition(position) {
186
- this.camera3D.position.copy(position.as(this.crs));
187
- }
188
- isBox3Visible(box3, matrixWorld) {
189
- return this.box3SizeOnScreen(box3, matrixWorld).intersectsBox(ndcBox3);
190
- }
191
- isSphereVisible(sphere, matrixWorld) {
192
- if (this.#_viewMatrixNeedsUpdate) {
193
- // update visibility testing matrix
194
- this.#_viewMatrix.multiplyMatrices(this.camera3D.projectionMatrix, this.camera3D.matrixWorldInverse);
195
- this.#_viewMatrixNeedsUpdate = false;
196
- }
197
- if (matrixWorld) {
198
- tmp.matrix.multiplyMatrices(this.#_viewMatrix, matrixWorld);
199
- tmp.frustum.setFromProjectionMatrix(tmp.matrix);
200
- } else {
201
- tmp.frustum.setFromProjectionMatrix(this.#_viewMatrix);
202
- }
203
- return tmp.frustum.intersectsSphere(sphere);
204
- }
205
- box3SizeOnScreen(box3, matrixWorld) {
206
- const pts = projectBox3PointsInCameraSpace(this, box3, matrixWorld);
207
-
208
- // All points are in front of the near plane -> box3 is invisible
209
- if (!pts) {
210
- return tmp.box3.makeEmpty();
211
- }
212
-
213
- // Project points on screen
214
- for (let i = 0; i < 8; i++) {
215
- pts[i].applyMatrix4(this.camera3D.projectionMatrix);
216
- }
217
- return tmp.box3.setFromPoints(pts);
218
- }
219
-
220
- /**
221
- * Test for collision between camera and a geometry layer (DTM/DSM) to adjust camera position.
222
- * It could be modified later to handle an array of geometry layers.
223
- * TODO Improve Coordinates class to handle altitude for any coordinate system (even projected one)
224
- *
225
- * @param {View} view The view where we test the collision between geometry layers
226
- * and the camera
227
- * @param {ElevationLayer} elevationLayer The elevation layer (DTM/DSM) used to test the collision
228
- * with the camera. Could be another geometry layer.
229
- * @param {number} minDistanceCollision The minimum distance allowed between the camera and the
230
- * surface.
231
- */
232
- adjustAltitudeToAvoidCollisionWithLayer(view, elevationLayer, minDistanceCollision) {
233
- // We put the camera location in geographic by default to easily handle altitude.
234
- // (Should be improved in Coordinates class for all ref)
235
- const camLocation = view.camera.position().as('EPSG:4326');
236
- if (elevationLayer !== undefined) {
237
- const elevationUnderCamera = DEMUtils.getElevationValueAt(elevationLayer, camLocation);
238
- if (elevationUnderCamera !== undefined) {
239
- const difElevation = camLocation.altitude - (elevationUnderCamera + minDistanceCollision);
240
- // We move the camera to avoid collision if too close to terrain
241
- if (difElevation < 0) {
242
- camLocation.altitude = elevationUnderCamera + minDistanceCollision;
243
- view.camera3D.position.copy(camLocation.as(view.referenceCrs));
244
- view.notifyChange(this.camera3D);
245
- }
246
- }
247
- }
248
- }
249
- }
250
- const points = [new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3()];
251
- function projectBox3PointsInCameraSpace(camera, box3, matrixWorld) {
252
- // Projects points in camera space
253
- // We don't project directly on screen to avoid artifacts when projecting
254
- // points behind the near plane.
255
- let m = camera.camera3D.matrixWorldInverse;
256
- if (matrixWorld) {
257
- m = tmp.matrix.multiplyMatrices(camera.camera3D.matrixWorldInverse, matrixWorld);
258
- }
259
- points[0].set(box3.min.x, box3.min.y, box3.min.z).applyMatrix4(m);
260
- points[1].set(box3.min.x, box3.min.y, box3.max.z).applyMatrix4(m);
261
- points[2].set(box3.min.x, box3.max.y, box3.min.z).applyMatrix4(m);
262
- points[3].set(box3.min.x, box3.max.y, box3.max.z).applyMatrix4(m);
263
- points[4].set(box3.max.x, box3.min.y, box3.min.z).applyMatrix4(m);
264
- points[5].set(box3.max.x, box3.min.y, box3.max.z).applyMatrix4(m);
265
- points[6].set(box3.max.x, box3.max.y, box3.min.z).applyMatrix4(m);
266
- points[7].set(box3.max.x, box3.max.y, box3.max.z).applyMatrix4(m);
267
-
268
- // In camera space objects are along the -Z axis
269
- // So if min.z is > -near, the object is invisible
270
- let atLeastOneInFrontOfNearPlane = false;
271
- for (let i = 0; i < 8; i++) {
272
- if (points[i].z <= -camera.camera3D.near) {
273
- atLeastOneInFrontOfNearPlane = true;
274
- } else {
275
- // Clamp to near plane
276
- points[i].z = -camera.camera3D.near;
277
- }
278
- }
279
- return atLeastOneInFrontOfNearPlane ? points : undefined;
280
- }
281
- export default Camera;