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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,489 +0,0 @@
1
- import * as THREE from 'three';
2
- import Extent from "./Geographic/Extent.js";
3
- import Coordinates from "./Geographic/Coordinates.js";
4
- import StyleOptions from "./StyleOptions.js";
5
- function defaultExtent(crs) {
6
- return new Extent(crs, Infinity, -Infinity, Infinity, -Infinity);
7
- }
8
- function _extendBuffer(feature, size) {
9
- feature.vertices.length += size * feature.size;
10
- if (feature.normals) {
11
- feature.normals.length = feature.vertices.length;
12
- }
13
- }
14
- function _setGeometryValues(feature, coord) {
15
- if (feature.normals) {
16
- coord.geodesicNormal.toArray(feature.normals, feature._pos);
17
- }
18
- feature._pushValues(coord.x, coord.y, coord.z);
19
- }
20
- const coordOut = new Coordinates('EPSG:4326', 0, 0, 0);
21
- export const FEATURE_TYPES = {
22
- POINT: 0,
23
- LINE: 1,
24
- POLYGON: 2
25
- };
26
-
27
- /**
28
- * @typedef {Object} FeatureBuildingOptions
29
- * @property {string} crs - The CRS to convert the input coordinates to.
30
- * @property {string} [structure='2d'] - data structure type : 2d or 3d.
31
- * If the structure is 3d, the feature have 3 dimensions by vertices positions and
32
- * a normal for each vertices.
33
- * @property {Extent|boolean} [filteringExtent=undefined] - Optional filter to reject
34
- * features outside of extent. Extent filtering is file extent if filteringExtent is true.
35
- * @property {boolean} [buildExtent] - If true the geometry will
36
- * have an extent property containing the area covered by the geometry.
37
- * Default value is false if `structure` parameter is set to '3d', and true otherwise.
38
- * True if the layer does not inherit from {@link GeometryLayer}.
39
- * @property {string} forcedExtentCrs - force feature extent crs if buildExtent is true.
40
- * @property {function} [filter] - Filter function to remove features
41
- * @property {boolean} [mergeFeatures=true] - If true all geometries are merged by type and multi-type.
42
- * @property {Style} style - The style to inherit when creating
43
- * style for all new features.
44
- *
45
- */
46
-
47
- /**
48
- * @property {Extent} extent - The 2D extent containing all the points
49
- * composing the geometry.
50
- * @property {Object[]} indices - Contains the indices that define the geometry.
51
- * Objects stored in this array have two properties, an `offset` and a `count`.
52
- * The offset is related to the overall number of vertices in the Feature.
53
- *
54
- * @property {Object} properties - Properties of the geometry. It can be
55
- * anything specified in the GeoJSON under the `properties` property.
56
- */
57
- export class FeatureGeometry {
58
- #currentExtent;
59
- /**
60
- * @param {Feature} feature geometry
61
- */
62
- constructor(feature) {
63
- this.indices = [];
64
- this.properties = {};
65
- this.size = feature.size;
66
- if (feature.extent) {
67
- this.extent = defaultExtent(feature.extent.crs);
68
- this.#currentExtent = defaultExtent(feature.extent.crs);
69
- }
70
- }
71
- /**
72
- * Add a new marker to indicate the starting of sub geometry and extends the vertices buffer.
73
- * Then you have to push new the coordinates of sub geometry.
74
- * The sub geometry stored in indices, see constructor for more information.
75
- * @param {number} count - count of vertices
76
- * @param {Feature} feature - the feature containing the geometry
77
- */
78
- startSubGeometry(count, feature) {
79
- const last = this.indices.length - 1;
80
- const extent = this.extent ? defaultExtent(this.extent.crs) : undefined;
81
- const offset = last > -1 ? this.indices[last].offset + this.indices[last].count : feature.vertices.length / this.size;
82
- this.indices.push({
83
- offset,
84
- count,
85
- extent
86
- });
87
- this.#currentExtent = extent;
88
- _extendBuffer(feature, count);
89
- }
90
-
91
- /**
92
- * After you have pushed new the coordinates of sub geometry without
93
- * `startSubGeometry`, this function close sub geometry. The sub geometry
94
- * stored in indices, see constructor for more information.
95
- * @param {number} count count of vertices
96
- * @param {Feature} feature - the feature containing the geometry
97
- */
98
- closeSubGeometry(count, feature) {
99
- const last = this.indices.length - 1;
100
- const offset = last > -1 ? this.indices[last].offset + this.indices[last].count : feature.vertices.length / this.size - count;
101
- this.indices.push({
102
- offset,
103
- count,
104
- extent: this.#currentExtent
105
- });
106
- if (this.extent) {
107
- this.extent.union(this.#currentExtent);
108
- this.#currentExtent = defaultExtent(this.extent.crs);
109
- }
110
- }
111
- getLastSubGeometry() {
112
- const last = this.indices.length - 1;
113
- return this.indices[last];
114
- }
115
-
116
- /**
117
- * Push new coordinates in vertices buffer.
118
- * @param {Feature} feature - the feature containing the geometry
119
- * @param {Coordinates} coordIn The coordinates to push.
120
- */
121
- pushCoordinates(feature, coordIn) {
122
- if (feature.isCoordinates) {
123
- console.warn('Deprecated: change in arguments order, use pushCoordinates(feature, coordIn) instead');
124
- this.pushCoordinates(coordIn, feature);
125
- return;
126
- }
127
- coordIn.as(feature.crs, coordOut);
128
- feature.transformToLocalSystem(coordOut);
129
- _setGeometryValues(feature, coordOut);
130
-
131
- // expand extent if present
132
- if (this.#currentExtent) {
133
- this.#currentExtent.expandByCoordinates(feature.useCrsOut ? coordOut : coordIn);
134
- }
135
- }
136
-
137
- /**
138
- * Push new values coordinates in vertices buffer without any transformation.
139
- * No geographical conversion is made or the normal doesn't stored.
140
- *
141
- * @param {Feature} feature - the feature containing the geometry
142
- * @param {Object} coordIn An object containing the coordinates values to push.
143
- * @param {number} coordIn.x the x coordinate (in a local system).
144
- * @param {number} coordIn.y the y coordinate (in a local system).
145
- * @param {THREE.Vector3} [coordIn.normal] the normal on coordinates (only for `EPSG:4978` projection).
146
- * @param {Coordinates} [coordProj] An optional argument containing the geodesic coordinates in EPSG:4326
147
- * It allows the user to get access to the feature coordinates to set style.base_altitude.
148
- */
149
- pushCoordinatesValues(feature, coordIn, coordProj) {
150
- if ((arguments.length <= 3 ? 0 : arguments.length - 3) > 0) {
151
- console.warn('Deprecated: change in arguments, use pushCoordinatesValues(feature, {x: long, y: lat, normal}, coordProj) instead');
152
- this.pushCoordinatesValues(feature, {
153
- x: coordIn,
154
- y: coordProj,
155
- normal: arguments.length <= 3 ? undefined : arguments[3]
156
- }, arguments.length <= 4 ? undefined : arguments[4]);
157
- return;
158
- }
159
- _setGeometryValues(feature, coordIn);
160
-
161
- // expand extent if present
162
- if (this.#currentExtent) {
163
- this.#currentExtent.expandByValuesCoordinates(coordIn.x, coordIn.y);
164
- }
165
- }
166
-
167
- /**
168
- * update geometry extent with the last sub geometry extent.
169
- */
170
- updateExtent() {
171
- if (this.extent) {
172
- const last = this.indices[this.indices.length - 1];
173
- if (last) {
174
- this.extent.union(last.extent);
175
- }
176
- }
177
- }
178
- }
179
- function push2DValues(value0, value1) {
180
- this.vertices[this._pos++] = value0;
181
- this.vertices[this._pos++] = value1;
182
- }
183
- function push3DValues(value0, value1) {
184
- let value2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
185
- this.vertices[this._pos++] = value0;
186
- this.vertices[this._pos++] = value1;
187
- this.vertices[this._pos++] = value2;
188
- }
189
-
190
- /**
191
- *
192
- * This class improves and simplifies the construction and conversion of geographic data structures.
193
- * It's an intermediary structure between geomatic formats and THREE objects.
194
- *
195
- * **Warning**, the data (`extent` or `Coordinates`) can be stored in a local system.
196
- * To use vertices or extent in `Feature.crs` projection,
197
- * it's necessary to transform `Coordinates` or `Extent` by `FeatureCollection.matrixWorld`.
198
- *
199
- * ```js
200
- * // To have feature extent in featureCollection.crs projection:
201
- * feature.extent.applyMatrix4(featureCollection.matrixWorld);
202
- *
203
- * // To have feature vertex in feature.crs projection:
204
- * coord.crs = feature.crs;
205
- * coord.setFromArray(feature.vertices)
206
- * coord.applyMatrix4(featureCollection.matrixWorld);
207
- *```
208
- *
209
- * @property {string} type - Geometry type, can be `point`, `line`, or
210
- * `polygon`.
211
- * @property {number[]} vertices - All the vertices of the Feature.
212
- * @property {number[]} normals - All the normals of the Feature.
213
- * @property {number} size - the number of values of the array that should be associated with a coordinates.
214
- * The size is 3 with altitude and 2 without altitude.
215
- * @property {boolean} hasRawElevationData - indicates if the geographic coordinates, from original source, has an elevation,
216
- * the coordinates has a third coordinate.
217
- * @property {string} crs - Geographic or Geocentric coordinates system.
218
- * @property {FeatureGeometry[]} geometries - An array containing all {@link
219
- * FeatureGeometry}.
220
- * @property {Extent?} extent - The extent containing all the geometries
221
- * composing the feature.
222
- */
223
- class Feature {
224
- /**
225
- *
226
- * @param {string} type type of Feature. It can be 'point', 'line' or 'polygon'.
227
- * @param {FeatureCollection} collection Parent feature collection.
228
- */
229
- constructor(type, collection) {
230
- if (Object.keys(FEATURE_TYPES).find(t => FEATURE_TYPES[t] === type)) {
231
- this.type = type;
232
- } else {
233
- throw new Error(`Unsupported Feature type: ${type}`);
234
- }
235
- this.geometries = [];
236
- this.vertices = [];
237
- this.crs = collection.crs;
238
- this.size = collection.size;
239
- this.normals = collection.crs == 'EPSG:4978' ? [] : undefined;
240
- this.hasRawElevationData = false;
241
- this.transformToLocalSystem = collection.transformToLocalSystem.bind(collection);
242
- if (collection.extent) {
243
- // this.crs is final crs projection, is out projection.
244
- // If the extent crs is the same then we use output coordinate (coordOut) to expand it.
245
- this.extent = defaultExtent(collection.extent.crs);
246
- this.useCrsOut = this.extent.crs == this.crs;
247
- }
248
- this._pos = 0;
249
- this._pushValues = (this.size === 3 ? push3DValues : push2DValues).bind(this);
250
- this.style = StyleOptions.setFromProperties;
251
- }
252
- /**
253
- * Instance a new {@link FeatureGeometry} and push in {@link Feature}.
254
- * @returns {FeatureGeometry} the instancied geometry.
255
- */
256
- bindNewGeometry() {
257
- const geometry = new FeatureGeometry(this);
258
- this.geometries.push(geometry);
259
- return geometry;
260
- }
261
- /**
262
- * Update {@link Extent} feature with {@link Extent} geometry
263
- * @param {FeatureGeometry} geometry used to update Feature {@link Extent}
264
- */
265
- updateExtent(geometry) {
266
- if (this.extent) {
267
- this.extent.union(geometry.extent);
268
- }
269
- }
270
-
271
- /**
272
- * @returns {number} the count of geometry.
273
- */
274
- get geometryCount() {
275
- return this.geometries.length;
276
- }
277
- }
278
- export default Feature;
279
- const doNothing = () => {};
280
- const transformToLocalSystem3D = (coord, collection) => {
281
- coord.geodesicNormal.applyNormalMatrix(collection.normalMatrixInverse);
282
- return coord.applyMatrix4(collection.matrixWorldInverse);
283
- };
284
- const transformToLocalSystem2D = (coord, collection) => coord.applyMatrix4(collection.matrixWorldInverse);
285
- const axisZ = new THREE.Vector3(0, 0, 1);
286
- const alignYtoEast = new THREE.Quaternion();
287
- /**
288
- * An object regrouping a list of [features]{@link Feature} and the extent of this collection.
289
- * **Warning**, the data (`extent` or `Coordinates`) can be stored in a local system.
290
- * The local system center is the `center` property.
291
- * To use `Feature` vertices or `FeatureCollection/Feature` extent in FeatureCollection.crs projection,
292
- * it's necessary to transform `Coordinates` or `Extent` by `FeatureCollection.matrixWorld`.
293
- *
294
- * ```js
295
- * // To have featureCollection extent in featureCollection.crs projection:
296
- * featureCollection.extent.applyMatrix4(featureCollection.matrixWorld);
297
- *
298
- * // To have feature vertex in featureCollection.crs projection:
299
- * const vertices = featureCollection.features[0].vertices;
300
- * coord.crs = featureCollection.crs;
301
- * coord.setFromArray(vertices)
302
- * coord.applyMatrix4(featureCollection.matrixWorld);
303
- *```
304
- *
305
- * @extends THREE.Object3D
306
- *
307
- * @property {Feature[]} features - The array of features composing the
308
- * collection.
309
- * @property {Extent?} extent - The 2D extent containing all the features
310
- * composing the collection. The extent projection is the same local projection `FeatureCollection`.
311
- * To transform `FeatureCollection.extent` to `FeatureCollection.crs` projection, the transformation matrix must be applied.
312
- *
313
- * **WARNING** if crs is `EPSG:4978` because the 3d geocentric system doesn't work with 2D `Extent`,
314
- * The FeatureCollection.extent projection is the original projection.
315
- * In this case, there isn't need to transform the extent.
316
- *
317
- * @property {string} crs - Geographic or Geocentric coordinates system.
318
- * @property {boolean} isFeatureCollection - Used to check whether this is FeatureCollection.
319
- * @property {number} size - The size structure, it's 3 for 3d and 2 for 2d.
320
- * @property {Style} style - The collection style used to display the feature collection.
321
- * @property {boolean} isInverted - This option is to be set to the
322
- * correct value, true or false (default being false), if the computation of
323
- * the coordinates needs to be inverted to same scheme as OSM, Google Maps
324
- * or other system. See [this link](
325
- * https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates)
326
- * for more informations.
327
- * @property {THREE.Matrix4} matrixWorldInverse - The matrix world inverse.
328
- * @property {Coordinates} center - The local center coordinates in `EPSG:4326`.
329
- * The local system is centred in this center.
330
- *
331
- */
332
-
333
- export class FeatureCollection extends THREE.Object3D {
334
- #transformToLocalSystem = (() => transformToLocalSystem2D)();
335
- #setLocalSystem = (() => doNothing)();
336
- /**
337
- * @param {FeatureBuildingOptions|Layer} options The building options .
338
- */
339
- constructor(options) {
340
- super();
341
- this.isFeatureCollection = true;
342
- this.crs = options.accurate || !options.source?.crs ? options.crs : options.source.crs;
343
- this.features = [];
344
- this.mergeFeatures = options.mergeFeatures === undefined ? true : options.mergeFeatures;
345
- this.size = options.structure == '3d' ? 3 : 2;
346
- this.filterExtent = options.filterExtent;
347
- this.style = options.style;
348
- this.isInverted = false;
349
- this.matrixWorldInverse = new THREE.Matrix4();
350
- this.center = new Coordinates('EPSG:4326', 0, 0);
351
- if (this.size == 2) {
352
- this.extent = options.buildExtent === false ? undefined : defaultExtent(options.forcedExtentCrs || this.crs);
353
- this.#setLocalSystem = center => {
354
- // set local system center
355
- center.as(this.crs, this.center);
356
-
357
- // set position to local system center
358
- this.position.copy(center);
359
- this.updateMatrixWorld();
360
- this.#setLocalSystem = doNothing;
361
- };
362
- } else {
363
- this.extent = options.buildExtent ? defaultExtent(options.forcedExtentCrs || this.crs) : undefined;
364
- this.#setLocalSystem = center => {
365
- // set local system center
366
- center.as('EPSG:4326', this.center);
367
- if (this.crs == 'EPSG:4978') {
368
- // align Z axe to geodesic normal.
369
- this.quaternion.setFromUnitVectors(axisZ, center.geodesicNormal);
370
- // align Y axe to East
371
- alignYtoEast.setFromAxisAngle(axisZ, THREE.MathUtils.degToRad(90 + this.center.longitude));
372
- this.quaternion.multiply(alignYtoEast);
373
- }
374
-
375
- // set position to local system center
376
- this.position.copy(center);
377
- this.updateMatrixWorld();
378
- this.normalMatrix.getNormalMatrix(this.matrix);
379
- this.normalMatrixInverse = new THREE.Matrix3().copy(this.normalMatrix).invert();
380
- this.#setLocalSystem = doNothing;
381
- };
382
- this.#transformToLocalSystem = transformToLocalSystem3D;
383
- }
384
- }
385
-
386
- /**
387
- * Apply the matrix World inverse on the coordinates.
388
- * This method is used when the coordinates is pushed
389
- * to transform it in local system.
390
- *
391
- * @param {Coordinates} coordinates The coordinates
392
- * @returns {Coordinates} The coordinates in local system
393
- */
394
- transformToLocalSystem(coordinates) {
395
- this.#setLocalSystem(coordinates);
396
- return this.#transformToLocalSystem(coordinates, this);
397
- }
398
-
399
- /**
400
- * Update FeatureCollection extent with `extent` or all features extent if
401
- * `extent` is `undefined`.
402
- * @param {Extent} extent
403
- */
404
- updateExtent(extent) {
405
- if (this.extent) {
406
- const extents = extent ? [extent] : this.features.map(feature => feature.extent);
407
- for (const ext of extents) {
408
- this.extent.union(ext);
409
- }
410
- }
411
- }
412
-
413
- /**
414
- * Updates the global transform of the object and its descendants.
415
- *
416
- * @param {boolean} force The force
417
- */
418
- updateMatrixWorld(force) {
419
- super.updateMatrixWorld(force);
420
- this.matrixWorldInverse.copy(this.matrixWorld).invert();
421
- }
422
-
423
- /**
424
- * Remove features that don't have {@link FeatureGeometry}.
425
- */
426
- removeEmptyFeature() {
427
- this.features = this.features.filter(feature => feature.geometries.length);
428
- }
429
-
430
- /**
431
- * Push the `feature` in FeatureCollection.
432
- * @param {Feature} feature
433
- */
434
- pushFeature(feature) {
435
- this.features.push(feature);
436
- this.updateExtent(feature.extent);
437
- }
438
- requestFeature(type, callback) {
439
- const feature = this.features.find(callback);
440
- if (feature && this.mergeFeatures) {
441
- return feature;
442
- } else {
443
- const newFeature = new Feature(type, this);
444
- this.features.push(newFeature);
445
- return newFeature;
446
- }
447
- }
448
-
449
- /**
450
- * Returns the Feature by type if `mergeFeatures` is `true` or returns the
451
- * new instance of typed Feature.
452
- *
453
- * @param {string} type the type requested
454
- * @returns {Feature}
455
- */
456
- requestFeatureByType(type) {
457
- return this.requestFeature(type, feature => feature.type === type);
458
- }
459
-
460
- /**
461
- * Returns the Feature by type if `mergeFeatures` is `true` or returns the
462
- * new instance of typed Feature.
463
- *
464
- * @param {string} id the id requested
465
- * @param {string} type the type requested
466
- * @returns {Feature}
467
- */
468
- requestFeatureById(id, type) {
469
- return this.requestFeature(type, feature => feature.id === id);
470
- }
471
- /**
472
- * Add a new feature with references to all properties.
473
- * It allows to have features with different styles
474
- * without having to duplicate the geometry.
475
- * @param {Feature} feature The feature to reference.
476
- * @return {Feature} The new referenced feature
477
- */
478
- newFeatureByReference(feature) {
479
- const ref = new Feature(feature.type, this);
480
- ref.extent = feature.extent;
481
- ref.geometries = feature.geometries;
482
- ref.normals = feature.normals;
483
- ref.size = feature.size;
484
- ref.vertices = feature.vertices;
485
- ref._pos = feature._pos;
486
- this.features.push(ref);
487
- return ref;
488
- }
489
- }
@@ -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;