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,490 +0,0 @@
1
- import * as THREE from 'three';
2
- import Extent from "./Geographic/Extent.js";
3
- import Coordinates from "./Geographic/Coordinates.js";
4
- import CRS from "./Geographic/Crs.js";
5
- import Style from "./Style.js";
6
- function defaultExtent(crs) {
7
- return new Extent(crs, Infinity, -Infinity, Infinity, -Infinity);
8
- }
9
- function _extendBuffer(feature, size) {
10
- feature.vertices.length += size * feature.size;
11
- if (feature.normals) {
12
- feature.normals.length = feature.vertices.length;
13
- }
14
- }
15
- function _setGeometryValues(feature, coord) {
16
- if (feature.normals) {
17
- coord.geodesicNormal.toArray(feature.normals, feature._pos);
18
- }
19
- feature._pushValues(coord.x, coord.y, coord.z);
20
- }
21
- const coordOut = new Coordinates('EPSG:4326', 0, 0, 0);
22
- export const FEATURE_TYPES = {
23
- POINT: 0,
24
- LINE: 1,
25
- POLYGON: 2
26
- };
27
-
28
- /**
29
- * @typedef {Object} FeatureBuildingOptions
30
- * @property {string} crs - The CRS to convert the input coordinates to.
31
- * @property {string} [structure='2d'] - data structure type : 2d or 3d.
32
- * If the structure is 3d, the feature have 3 dimensions by vertices positions and
33
- * a normal for each vertices.
34
- * @property {Extent|boolean} [filteringExtent=undefined] - Optional filter to reject
35
- * features outside of extent. Extent filtering is file extent if filteringExtent is true.
36
- * @property {boolean} [buildExtent] - If true the geometry will
37
- * have an extent property containing the area covered by the geometry.
38
- * Default value is false if `structure` parameter is set to '3d', and true otherwise.
39
- * True if the layer does not inherit from {@link GeometryLayer}.
40
- * @property {string} forcedExtentCrs - force feature extent crs if buildExtent is true.
41
- * @property {function} [filter] - Filter function to remove features
42
- * @property {boolean} [mergeFeatures=true] - If true all geometries are merged by type and multi-type.
43
- * @property {Style} style - The style to inherit when creating
44
- * style for all new features.
45
- *
46
- */
47
-
48
- /**
49
- * @property {Extent} extent - The 2D extent containing all the points
50
- * composing the geometry.
51
- * @property {Object[]} indices - Contains the indices that define the geometry.
52
- * Objects stored in this array have two properties, an `offset` and a `count`.
53
- * The offset is related to the overall number of vertices in the Feature.
54
- *
55
- * @property {Object} properties - Properties of the geometry. It can be
56
- * anything specified in the GeoJSON under the `properties` property.
57
- */
58
- export class FeatureGeometry {
59
- #currentExtent;
60
- /**
61
- * @param {Feature} feature geometry
62
- */
63
- constructor(feature) {
64
- this.indices = [];
65
- this.properties = {};
66
- this.size = feature.size;
67
- if (feature.extent) {
68
- this.extent = defaultExtent(feature.extent.crs);
69
- this.#currentExtent = defaultExtent(feature.extent.crs);
70
- }
71
- }
72
- /**
73
- * Add a new marker to indicate the starting of sub geometry and extends the vertices buffer.
74
- * Then you have to push new the coordinates of sub geometry.
75
- * The sub geometry stored in indices, see constructor for more information.
76
- * @param {number} count - count of vertices
77
- * @param {Feature} feature - the feature containing the geometry
78
- */
79
- startSubGeometry(count, feature) {
80
- const last = this.indices.length - 1;
81
- const extent = this.extent ? defaultExtent(this.extent.crs) : undefined;
82
- const offset = last > -1 ? this.indices[last].offset + this.indices[last].count : feature.vertices.length / this.size;
83
- this.indices.push({
84
- offset,
85
- count,
86
- extent
87
- });
88
- this.#currentExtent = extent;
89
- _extendBuffer(feature, count);
90
- }
91
-
92
- /**
93
- * After you have pushed new the coordinates of sub geometry without
94
- * `startSubGeometry`, this function close sub geometry. The sub geometry
95
- * stored in indices, see constructor for more information.
96
- * @param {number} count count of vertices
97
- * @param {Feature} feature - the feature containing the geometry
98
- */
99
- closeSubGeometry(count, feature) {
100
- const last = this.indices.length - 1;
101
- const offset = last > -1 ? this.indices[last].offset + this.indices[last].count : feature.vertices.length / this.size - count;
102
- this.indices.push({
103
- offset,
104
- count,
105
- extent: this.#currentExtent
106
- });
107
- if (this.extent) {
108
- this.extent.union(this.#currentExtent);
109
- this.#currentExtent = defaultExtent(this.extent.crs);
110
- }
111
- }
112
- getLastSubGeometry() {
113
- const last = this.indices.length - 1;
114
- return this.indices[last];
115
- }
116
-
117
- /**
118
- * Push new coordinates in vertices buffer.
119
- * @param {Feature} feature - the feature containing the geometry
120
- * @param {Coordinates} coordIn The coordinates to push.
121
- */
122
- pushCoordinates(feature, coordIn) {
123
- if (feature.isCoordinates) {
124
- console.warn('Deprecated: change in arguments order, use pushCoordinates(feature, coordIn) instead');
125
- this.pushCoordinates(coordIn, feature);
126
- return;
127
- }
128
- coordIn.as(feature.crs, coordOut);
129
- feature.transformToLocalSystem(coordOut);
130
- _setGeometryValues(feature, coordOut);
131
-
132
- // expand extent if present
133
- if (this.#currentExtent) {
134
- this.#currentExtent.expandByCoordinates(feature.useCrsOut ? coordOut : coordIn);
135
- }
136
- }
137
-
138
- /**
139
- * Push new values coordinates in vertices buffer without any transformation.
140
- * No geographical conversion is made or the normal doesn't stored.
141
- *
142
- * @param {Feature} feature - the feature containing the geometry
143
- * @param {Object} coordIn An object containing the coordinates values to push.
144
- * @param {number} coordIn.x the x coordinate (in a local system).
145
- * @param {number} coordIn.y the y coordinate (in a local system).
146
- * @param {THREE.Vector3} [coordIn.normal] the normal on coordinates (only for `EPSG:4978` projection).
147
- * @param {Coordinates} [coordProj] An optional argument containing the geodesic coordinates in EPSG:4326
148
- * It allows the user to get access to the feature coordinates to set style.base_altitude.
149
- */
150
- pushCoordinatesValues(feature, coordIn, coordProj) {
151
- if ((arguments.length <= 3 ? 0 : arguments.length - 3) > 0) {
152
- console.warn('Deprecated: change in arguments, use pushCoordinatesValues(feature, {x: long, y: lat, normal}, coordProj) instead');
153
- this.pushCoordinatesValues(feature, {
154
- x: coordIn,
155
- y: coordProj,
156
- normal: arguments.length <= 3 ? undefined : arguments[3]
157
- }, arguments.length <= 4 ? undefined : arguments[4]);
158
- return;
159
- }
160
- _setGeometryValues(feature, coordIn);
161
-
162
- // expand extent if present
163
- if (this.#currentExtent) {
164
- this.#currentExtent.expandByValuesCoordinates(coordIn.x, coordIn.y);
165
- }
166
- }
167
-
168
- /**
169
- * update geometry extent with the last sub geometry extent.
170
- */
171
- updateExtent() {
172
- if (this.extent) {
173
- const last = this.indices[this.indices.length - 1];
174
- if (last) {
175
- this.extent.union(last.extent);
176
- }
177
- }
178
- }
179
- }
180
- function push2DValues(value0, value1) {
181
- this.vertices[this._pos++] = value0;
182
- this.vertices[this._pos++] = value1;
183
- }
184
- function push3DValues(value0, value1) {
185
- let value2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
186
- this.vertices[this._pos++] = value0;
187
- this.vertices[this._pos++] = value1;
188
- this.vertices[this._pos++] = value2;
189
- }
190
-
191
- /**
192
- *
193
- * This class improves and simplifies the construction and conversion of geographic data structures.
194
- * It's an intermediary structure between geomatic formats and THREE objects.
195
- *
196
- * **Warning**, the data (`extent` or `Coordinates`) can be stored in a local system.
197
- * To use vertices or extent in `Feature.crs` projection,
198
- * it's necessary to transform `Coordinates` or `Extent` by `FeatureCollection.matrixWorld`.
199
- *
200
- * ```js
201
- * // To have feature extent in featureCollection.crs projection:
202
- * feature.extent.applyMatrix4(featureCollection.matrixWorld);
203
- *
204
- * // To have feature vertex in feature.crs projection:
205
- * coord.crs = feature.crs;
206
- * coord.setFromArray(feature.vertices)
207
- * coord.applyMatrix4(featureCollection.matrixWorld);
208
- *```
209
- *
210
- * @property {string} type - Geometry type, can be `point`, `line`, or
211
- * `polygon`.
212
- * @property {number[]} vertices - All the vertices of the Feature.
213
- * @property {number[]} normals - All the normals of the Feature.
214
- * @property {number} size - the number of values of the array that should be associated with a coordinates.
215
- * The size is 3 with altitude and 2 without altitude.
216
- * @property {boolean} hasRawElevationData - indicates if the geographic coordinates, from original source, has an elevation,
217
- * the coordinates has a third coordinate.
218
- * @property {string} crs - Geographic or Geocentric coordinates system.
219
- * @property {FeatureGeometry[]} geometries - An array containing all {@link
220
- * FeatureGeometry}.
221
- * @property {Extent?} extent - The extent containing all the geometries
222
- * composing the feature.
223
- */
224
- class Feature {
225
- /**
226
- *
227
- * @param {string} type type of Feature. It can be 'point', 'line' or 'polygon'.
228
- * @param {FeatureCollection} collection Parent feature collection.
229
- */
230
- constructor(type, collection) {
231
- if (Object.keys(FEATURE_TYPES).find(t => FEATURE_TYPES[t] === type)) {
232
- this.type = type;
233
- } else {
234
- throw new Error(`Unsupported Feature type: ${type}`);
235
- }
236
- this.geometries = [];
237
- this.vertices = [];
238
- this.crs = collection.crs;
239
- this.size = collection.size;
240
- this.normals = collection.crs == 'EPSG:4978' ? [] : undefined;
241
- this.hasRawElevationData = false;
242
- this.transformToLocalSystem = collection.transformToLocalSystem.bind(collection);
243
- if (collection.extent) {
244
- // this.crs is final crs projection, is out projection.
245
- // If the extent crs is the same then we use output coordinate (coordOut) to expand it.
246
- this.extent = defaultExtent(collection.extent.crs);
247
- this.useCrsOut = this.extent.crs == this.crs;
248
- }
249
- this._pos = 0;
250
- this._pushValues = (this.size === 3 ? push3DValues : push2DValues).bind(this);
251
- this.style = Style.setFromProperties;
252
- }
253
- /**
254
- * Instance a new {@link FeatureGeometry} and push in {@link Feature}.
255
- * @returns {FeatureGeometry} the instancied geometry.
256
- */
257
- bindNewGeometry() {
258
- const geometry = new FeatureGeometry(this);
259
- this.geometries.push(geometry);
260
- return geometry;
261
- }
262
- /**
263
- * Update {@link Extent} feature with {@link Extent} geometry
264
- * @param {FeatureGeometry} geometry used to update Feature {@link Extent}
265
- */
266
- updateExtent(geometry) {
267
- if (this.extent) {
268
- this.extent.union(geometry.extent);
269
- }
270
- }
271
-
272
- /**
273
- * @returns {number} the count of geometry.
274
- */
275
- get geometryCount() {
276
- return this.geometries.length;
277
- }
278
- }
279
- export default Feature;
280
- const doNothing = () => {};
281
- const transformToLocalSystem3D = (coord, collection) => {
282
- coord.geodesicNormal.applyNormalMatrix(collection.normalMatrixInverse);
283
- return coord.applyMatrix4(collection.matrixWorldInverse);
284
- };
285
- const transformToLocalSystem2D = (coord, collection) => coord.applyMatrix4(collection.matrixWorldInverse);
286
- const axisZ = new THREE.Vector3(0, 0, 1);
287
- const alignYtoEast = new THREE.Quaternion();
288
- /**
289
- * An object regrouping a list of [features]{@link Feature} and the extent of this collection.
290
- * **Warning**, the data (`extent` or `Coordinates`) can be stored in a local system.
291
- * The local system center is the `center` property.
292
- * To use `Feature` vertices or `FeatureCollection/Feature` extent in FeatureCollection.crs projection,
293
- * it's necessary to transform `Coordinates` or `Extent` by `FeatureCollection.matrixWorld`.
294
- *
295
- * ```js
296
- * // To have featureCollection extent in featureCollection.crs projection:
297
- * featureCollection.extent.applyMatrix4(featureCollection.matrixWorld);
298
- *
299
- * // To have feature vertex in featureCollection.crs projection:
300
- * const vertices = featureCollection.features[0].vertices;
301
- * coord.crs = featureCollection.crs;
302
- * coord.setFromArray(vertices)
303
- * coord.applyMatrix4(featureCollection.matrixWorld);
304
- *```
305
- *
306
- * @extends THREE.Object3D
307
- *
308
- * @property {Feature[]} features - The array of features composing the
309
- * collection.
310
- * @property {Extent?} extent - The 2D extent containing all the features
311
- * composing the collection. The extent projection is the same local projection `FeatureCollection`.
312
- * To transform `FeatureCollection.extent` to `FeatureCollection.crs` projection, the transformation matrix must be applied.
313
- *
314
- * **WARNING** if crs is `EPSG:4978` because the 3d geocentric system doesn't work with 2D `Extent`,
315
- * The FeatureCollection.extent projection is the original projection.
316
- * In this case, there isn't need to transform the extent.
317
- *
318
- * @property {string} crs - Geographic or Geocentric coordinates system.
319
- * @property {boolean} isFeatureCollection - Used to check whether this is FeatureCollection.
320
- * @property {number} size - The size structure, it's 3 for 3d and 2 for 2d.
321
- * @property {Style} style - The collection style used to display the feature collection.
322
- * @property {boolean} isInverted - This option is to be set to the
323
- * correct value, true or false (default being false), if the computation of
324
- * the coordinates needs to be inverted to same scheme as OSM, Google Maps
325
- * or other system. See [this link](
326
- * https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates)
327
- * for more informations.
328
- * @property {THREE.Matrix4} matrixWorldInverse - The matrix world inverse.
329
- * @property {Coordinates} center - The local center coordinates in `EPSG:4326`.
330
- * The local system is centred in this center.
331
- *
332
- */
333
-
334
- export class FeatureCollection extends THREE.Object3D {
335
- #transformToLocalSystem = (() => transformToLocalSystem2D)();
336
- #setLocalSystem = (() => doNothing)();
337
- /**
338
- * @param {FeatureBuildingOptions|Layer} options The building options .
339
- */
340
- constructor(options) {
341
- super();
342
- this.isFeatureCollection = true;
343
- this.crs = CRS.formatToEPSG(options.accurate || !options.source?.crs ? options.crs : options.source.crs);
344
- this.features = [];
345
- this.mergeFeatures = options.mergeFeatures === undefined ? true : options.mergeFeatures;
346
- this.size = options.structure == '3d' ? 3 : 2;
347
- this.filterExtent = options.filterExtent;
348
- this.style = options.style;
349
- this.isInverted = false;
350
- this.matrixWorldInverse = new THREE.Matrix4();
351
- this.center = new Coordinates('EPSG:4326', 0, 0);
352
- if (this.size == 2) {
353
- this.extent = options.buildExtent === false ? undefined : defaultExtent(options.forcedExtentCrs || this.crs);
354
- this.#setLocalSystem = center => {
355
- // set local system center
356
- center.as(this.crs, this.center);
357
-
358
- // set position to local system center
359
- this.position.copy(center);
360
- this.updateMatrixWorld();
361
- this.#setLocalSystem = doNothing;
362
- };
363
- } else {
364
- this.extent = options.buildExtent ? defaultExtent(options.forcedExtentCrs || this.crs) : undefined;
365
- this.#setLocalSystem = center => {
366
- // set local system center
367
- center.as('EPSG:4326', this.center);
368
- if (this.crs == 'EPSG:4978') {
369
- // align Z axe to geodesic normal.
370
- this.quaternion.setFromUnitVectors(axisZ, center.geodesicNormal);
371
- // align Y axe to East
372
- alignYtoEast.setFromAxisAngle(axisZ, THREE.MathUtils.degToRad(90 + this.center.longitude));
373
- this.quaternion.multiply(alignYtoEast);
374
- }
375
-
376
- // set position to local system center
377
- this.position.copy(center);
378
- this.updateMatrixWorld();
379
- this.normalMatrix.getNormalMatrix(this.matrix);
380
- this.normalMatrixInverse = new THREE.Matrix3().copy(this.normalMatrix).invert();
381
- this.#setLocalSystem = doNothing;
382
- };
383
- this.#transformToLocalSystem = transformToLocalSystem3D;
384
- }
385
- }
386
-
387
- /**
388
- * Apply the matrix World inverse on the coordinates.
389
- * This method is used when the coordinates is pushed
390
- * to transform it in local system.
391
- *
392
- * @param {Coordinates} coordinates The coordinates
393
- * @returns {Coordinates} The coordinates in local system
394
- */
395
- transformToLocalSystem(coordinates) {
396
- this.#setLocalSystem(coordinates);
397
- return this.#transformToLocalSystem(coordinates, this);
398
- }
399
-
400
- /**
401
- * Update FeatureCollection extent with `extent` or all features extent if
402
- * `extent` is `undefined`.
403
- * @param {Extent} extent
404
- */
405
- updateExtent(extent) {
406
- if (this.extent) {
407
- const extents = extent ? [extent] : this.features.map(feature => feature.extent);
408
- for (const ext of extents) {
409
- this.extent.union(ext);
410
- }
411
- }
412
- }
413
-
414
- /**
415
- * Updates the global transform of the object and its descendants.
416
- *
417
- * @param {boolean} force The force
418
- */
419
- updateMatrixWorld(force) {
420
- super.updateMatrixWorld(force);
421
- this.matrixWorldInverse.copy(this.matrixWorld).invert();
422
- }
423
-
424
- /**
425
- * Remove features that don't have {@link FeatureGeometry}.
426
- */
427
- removeEmptyFeature() {
428
- this.features = this.features.filter(feature => feature.geometries.length);
429
- }
430
-
431
- /**
432
- * Push the `feature` in FeatureCollection.
433
- * @param {Feature} feature
434
- */
435
- pushFeature(feature) {
436
- this.features.push(feature);
437
- this.updateExtent(feature.extent);
438
- }
439
- requestFeature(type, callback) {
440
- const feature = this.features.find(callback);
441
- if (feature && this.mergeFeatures) {
442
- return feature;
443
- } else {
444
- const newFeature = new Feature(type, this);
445
- this.features.push(newFeature);
446
- return newFeature;
447
- }
448
- }
449
-
450
- /**
451
- * Returns the Feature by type if `mergeFeatures` is `true` or returns the
452
- * new instance of typed Feature.
453
- *
454
- * @param {string} type the type requested
455
- * @returns {Feature}
456
- */
457
- requestFeatureByType(type) {
458
- return this.requestFeature(type, feature => feature.type === type);
459
- }
460
-
461
- /**
462
- * Returns the Feature by type if `mergeFeatures` is `true` or returns the
463
- * new instance of typed Feature.
464
- *
465
- * @param {string} id the id requested
466
- * @param {string} type the type requested
467
- * @returns {Feature}
468
- */
469
- requestFeatureById(id, type) {
470
- return this.requestFeature(type, feature => feature.id === id);
471
- }
472
- /**
473
- * Add a new feature with references to all properties.
474
- * It allows to have features with different styles
475
- * without having to duplicate the geometry.
476
- * @param {Feature} feature The feature to reference.
477
- * @return {Feature} The new referenced feature
478
- */
479
- newFeatureByReference(feature) {
480
- const ref = new Feature(feature.type, this);
481
- ref.extent = feature.extent;
482
- ref.geometries = feature.geometries;
483
- ref.normals = feature.normals;
484
- ref.size = feature.size;
485
- ref.vertices = feature.vertices;
486
- ref._pos = feature._pos;
487
- this.features.push(ref);
488
- return ref;
489
- }
490
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * Generated On: 2016-02-25
3
- * Class: CoordStars
4
- * Description: get coord of stars like earth...
5
- */
6
- import Coordinates from "./Coordinates.js";
7
- const CoordStars = {
8
- getSunPosition() {
9
- const m = Math;
10
- const PI = m.PI;
11
- const sin = m.sin;
12
- const cos = m.cos;
13
- const tan = m.tan;
14
- const asin = m.asin;
15
- const atan = m.atan2;
16
- const rad = PI / 180;
17
- const e = rad * 23.4397; // obliquity of the Earth
18
-
19
- function toJulian(date) {
20
- return date.valueOf() / (1000 * 60 * 60 * 24) - 0.5 + 2440588;
21
- }
22
- function toDays(date) {
23
- return toJulian(date) - 2451545;
24
- }
25
- function getRightAscension(l, b) {
26
- return atan(sin(l) * cos(e) - tan(b) * sin(e), cos(l));
27
- }
28
- function getDeclination(l, b) {
29
- return asin(sin(b) * cos(e) + cos(b) * sin(e) * sin(l));
30
- }
31
- function getAzimuth(H, phi, dec) {
32
- return atan(sin(H), cos(H) * sin(phi) - tan(dec) * cos(phi));
33
- }
34
- function getAltitude(H, phi, dec) {
35
- return asin(sin(phi) * sin(dec) + cos(phi) * cos(dec) * cos(H));
36
- }
37
- function getSiderealTime(d, lw) {
38
- return rad * (280.16 + 360.9856235 * d) - lw;
39
- }
40
- function getSolarMeanAnomaly(d) {
41
- return rad * (357.5291 + 0.98560028 * d);
42
- }
43
- function getEquationOfCenter(M) {
44
- return rad * (1.9148 * sin(M) + 0.0200 * sin(2 * M) + 0.0003 * sin(3 * M));
45
- }
46
- function getEclipticLongitude(M, C) {
47
- // perihelion of the Earth
48
- return M + C + rad * 102.9372 + PI;
49
- }
50
- return function (date, lat, lon) {
51
- const phi = rad * lat;
52
- const d = toDays(date);
53
- const M = getSolarMeanAnomaly(d);
54
- const C = getEquationOfCenter(M);
55
- const L = getEclipticLongitude(M, C);
56
- const D = getDeclination(L, 0);
57
- const A = getRightAscension(L, 0);
58
- const t = getSiderealTime(d, rad * -lon);
59
- const H = t - A;
60
- return {
61
- EclipticLongitude: L,
62
- declinaison: D,
63
- ascension: A,
64
- H,
65
- SiderealTime: t,
66
- altitude: getAltitude(H, phi, D),
67
- azimuth: getAzimuth(H, phi, D) + PI / 2 // + PI// - PI/2 // origin: north !!! not like original Mourner code but more classical ref
68
- };
69
- };
70
- },
71
- // Return scene coordinate ({x,y,z}) of sun
72
- getSunPositionInScene(date, lat, lon) {
73
- const sun = CoordStars.getSunPosition()(date, lat, lon);
74
- const dayMilliSec = 24 * 3600000;
75
- const longitude = sun.ascension + date % dayMilliSec / dayMilliSec * -360 + 180; // cause midday
76
- const coSunCarto = new Coordinates('EPSG:4326', longitude, lat, 50000000).as('EPSG:4978').toVector3();
77
- return coSunCarto;
78
- }
79
- };
80
- export default CoordStars;