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,457 +0,0 @@
1
- import * as THREE from 'three';
2
- import proj4 from 'proj4';
3
- import Coordinates from "../Core/Geographic/Coordinates.js";
4
- const DEG2RAD = THREE.MathUtils.DEG2RAD;
5
- const matrix = new THREE.Matrix4();
6
- const north = new THREE.Vector3();
7
- const east = new THREE.Vector3();
8
- const axis = new THREE.Vector3().set(0, 0, 1);
9
- const coord = new Coordinates('EPSG:4326', 0, 0, 0);
10
- const euler = new THREE.Euler();
11
- const quat = new THREE.Quaternion();
12
- function quaternionIdentity(coordinates) {
13
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
14
- return coordinates ? target.set(0, 0, 0, 1) : quaternionIdentity;
15
- }
16
-
17
- /**
18
- * The OrientationUtils module provides methods to compute the quaternion that
19
- * models a rotation defined with various conventions, including between different
20
- * CRS.
21
- * The local <a href="https://en.wikipedia.org/wiki/Local_tangent_plane_coordinates#Local_east,_north,_up_(ENU)_coordinates">
22
- * East/North/Up frame (ENU)</a> is used as a pivot frame when computing the rotation between two distinct CRS.
23
- * If the origin of the frame is undefined, CRS-related methods precompute and return a function
24
- * that can be applied efficiently to many points of origin.
25
- * Otherwise, the target quaternion is returned at the provided origin coordinates.
26
- *
27
- * @example
28
- * // Compute the rotation around the point of origin from a frame aligned with Lambert93 axes (epsg:2154),
29
- * // to the geocentric frame (epsg:4978)
30
- * quat_crs2crs = OrientationUtils.quaternionFromCRSToCRS("EPSG:2154", "EPSG:4978")(origin);
31
- * // Compute the rotation of a sensor platform defined by its attitude
32
- * quat_attitude = OrientationUtils.quaternionFromAttitude(attitude);
33
- * // Compute the rotation from the sensor platform frame to the geocentric frame
34
- * quat = quat_crs2crs.multiply(quat_attitude);
35
- *
36
- * @module OrientationUtils
37
- */
38
- export default {
39
- /**
40
- * @typedef {Object} Attitude
41
- * Properties are either defined as (omega, phi, kappa) or as (roll, pitch,
42
- * heading) or all `undefined`.
43
- *
44
- * @property {number} omega - angle in degrees
45
- * @property {number} phi - angle in degrees
46
- * @property {number} kappa - angle in degrees
47
- * @property {number} roll - angle in degrees
48
- * @property {number} pitch - angle in degrees
49
- * @property {number} heading - angle in degrees
50
- */
51
-
52
- /**
53
- * The transform from the platform frame to the local East, North, Up (ENU)
54
- * frame is `RotationZ(heading).RotationX(pitch).RotationY(roll)`
55
- *
56
- * @param {number} [roll=0] - angle in degrees
57
- * @param {number} [pitch=0] - angle in degrees
58
- * @param {number} [heading=0] - angle in degrees
59
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] - output Quaternion
60
- *
61
- * @return {THREE.Quaternion} target quaternion
62
- */
63
- quaternionFromRollPitchHeading() {
64
- let roll = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
65
- let pitch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
66
- let heading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
67
- let target = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new THREE.Quaternion();
68
- roll *= DEG2RAD;
69
- pitch *= DEG2RAD;
70
- heading *= DEG2RAD;
71
- // return this.setFromEuler(euler.set(pitch, roll, heading , 'ZXY')).conjugate();
72
- return target.setFromEuler(euler.set(-pitch, -roll, -heading, 'YXZ')); // optimized version of above
73
- },
74
- /**
75
- * From
76
- * [DocMicMac](https://github.com/micmacIGN/Documentation/raw/master/DocMicMac.pdf),
77
- * the transform from the platform frame to the local East, North, Up (ENU)
78
- * frame is:
79
- *
80
- * ```
81
- * RotationX(omega).RotationY(phi).RotationZ(kappa).RotationX(PI)
82
- * RotationX(PI) <=> Quaternion(1,0,0,0) : converts between the 2 conventions for the camera local frame:
83
- * X right, Y bottom, Z front : convention in photogrammetry and computer vision
84
- * X right, Y top, Z back : convention in webGL, threejs
85
- * ```
86
- *
87
- * @param {number} [omega=0] - angle in degrees
88
- * @param {number} [phi=0] - angle in degrees
89
- * @param {number} [kappa=0] - angle in degrees
90
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
91
- *
92
- * @return {THREE.Quaternion} target quaternion
93
- */
94
- quaternionFromOmegaPhiKappa() {
95
- let omega = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
96
- let phi = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
97
- let kappa = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
98
- let target = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new THREE.Quaternion();
99
- omega *= DEG2RAD;
100
- phi *= DEG2RAD;
101
- kappa *= DEG2RAD;
102
- target.setFromEuler(euler.set(omega, phi, kappa, 'XYZ'));
103
- target.set(target.w, target.z, -target.y, -target.x); // <=> target.multiply(new THREE.Quaternion(1, 0, 0, 0));
104
- return target;
105
- },
106
- /**
107
- * Set the quaternion according to the rotation from the platform frame to
108
- * the local frame.
109
- *
110
- * @param {Attitude} attitude - Attitude
111
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
112
- *
113
- * @return {THREE.Quaternion} target quaternion
114
- */
115
- quaternionFromAttitude(attitude) {
116
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
117
- if (attitude.roll !== undefined || attitude.pitch !== undefined || attitude.heading !== undefined) {
118
- return this.quaternionFromRollPitchHeading(attitude.roll, attitude.pitch, attitude.heading, target);
119
- }
120
- if (attitude.omega !== undefined || attitude.phi !== undefined || attitude.kappa !== undefined) {
121
- return this.quaternionFromOmegaPhiKappa(attitude.omega, attitude.phi, attitude.kappa, target);
122
- }
123
- return target.set(0, 0, 0, 1);
124
- },
125
- /**
126
- * @typedef {Function|THREE.Quaternion} FunctionOrQuaternion - Either a
127
- * THREE.Quaternion or a function that accepts arguments `(coordinates,
128
- * target)` and returns the quaternion that models a rotation around the
129
- * point of origin. If target is not provided, a new quaternion is created
130
- * and returned instead.
131
- *
132
- * @property {Coordinates} coordinates the origin of the local East North Up
133
- * (ENU) frame
134
- * @property {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion.
135
- */
136
-
137
- /**
138
- * A Projection object models a Coordinate Reference System (CRS).
139
- * Such an object is usually created with proj4 using `proj4.defs(crs);`
140
- *
141
- * @typedef {Object} Projection
142
- *
143
- * @property {string} projName
144
- */
145
-
146
- /**
147
- * Set the quaternion according to the rotation from the local East North Up (ENU)
148
- * frame to the geocentric frame. The up direction of the ENU frame is
149
- * provided by the normalized geodetic normal of the provided coordinates
150
- * (geodeticNormal property).
151
- *
152
- * @param {Coordinates} [coordinates] the origin of the local East North Up
153
- * (ENU) frame
154
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
155
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
156
- */
157
- quaternionFromEnuToGeocent(coordinates) {
158
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
159
- if (coordinates) {
160
- return this.quaternionFromEnuToGeocent()(coordinates, target);
161
- }
162
- return function (coordinates) {
163
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
164
- const up = coordinates.geodesicNormal;
165
- if (up.x == 0 && up.y == 0) {
166
- return target.set(0, 0, 0, 1);
167
- }
168
- // this is an optimized version of matrix.lookAt(up, new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 0, 1));
169
- east.set(-up.y, up.x, 0).normalize();
170
- north.crossVectors(up, east);
171
- matrix.makeBasis(east, north, up);
172
- return target.setFromRotationMatrix(matrix);
173
- };
174
- },
175
- /**
176
- * Set the quaternion according to the rotation from a geocentric frame
177
- * to the local East North Up (ENU) frame. The up direction of the ENU frame is
178
- * provided by the normalized geodetic normal of the provided coordinates
179
- * (geodeticNormal property).
180
- *
181
- * @param {Coordinates} [coordinates] the origin of the local East North Up
182
- * (ENU) frame
183
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
184
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
185
- */
186
- quaternionFromGeocentToEnu(coordinates) {
187
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
188
- if (coordinates) {
189
- return this.quaternionFromGeocentToEnu()(coordinates, target);
190
- }
191
- const toGeocent = this.quaternionFromEnuToGeocent();
192
- return function (coordinates) {
193
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
194
- return toGeocent(coordinates, target).conjugate();
195
- };
196
- },
197
- /**
198
- * Computes the rotation from a Lambert Conformal Conic (LCC) frame to the local East North Up (ENU) frame.
199
- * The quaternion accounts for the
200
- * <a href="https://geodesie.ign.fr/contenu/fichiers/documentation/algorithmes/alg0060.pdf">meridian convergence</a>
201
- * between the ENU and LCC frames.
202
- * This is a generally small rotation around Z.
203
- *
204
- * @param {Object} proj the lcc projection (may be parsed using proj4)
205
- * @param {number} proj.lat0 - the latitude of origin
206
- * @param {number} proj.long0 - the longitude of the central meridian
207
- * @param {Coordinates} [coordinates] coordinates the origin of the local East North Up
208
- * (ENU) frame
209
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
210
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
211
- */
212
- quaternionFromLCCToEnu(proj, coordinates) {
213
- let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new THREE.Quaternion();
214
- if (coordinates) {
215
- return this.quaternionFromLCCToEnu(proj)(coordinates, target);
216
- }
217
- const sinlat0 = Math.sin(proj.lat0);
218
- return function (coordinates) {
219
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
220
- const long = coordinates.as(coord.crs, coord).longitude * DEG2RAD;
221
- return target.setFromAxisAngle(axis, sinlat0 * (proj.long0 - long));
222
- };
223
- },
224
- /**
225
- * Computes the rotation from the local East North Up (ENU) frame to a Lambert Conformal Conic (LCC) frame.
226
- * The quaternion accounts for the
227
- * <a href="https://geodesie.ign.fr/contenu/fichiers/documentation/algorithmes/alg0060.pdf">meridian convergence</a>
228
- * between the ENU and LCC frames.
229
- * This is a generally small rotation around Z.
230
- *
231
- * @param {Object} proj the lcc projection (may be parsed using proj4)
232
- * @param {number} proj.lat0 - the latitude of origin
233
- * @param {number} proj.long0 - the longitude of the central meridian
234
- * @param {Coordinates} [coordinates] coordinates the origin of the local East North Up
235
- * (ENU) frame
236
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
237
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
238
- */
239
- quaternionFromEnuToLCC(proj, coordinates) {
240
- let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new THREE.Quaternion();
241
- if (coordinates) {
242
- return this.quaternionFromEnuToLCC(proj)(coordinates, target);
243
- }
244
- const fromLCC = this.quaternionFromLCCToEnu(proj);
245
- return function (coordinates) {
246
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
247
- return fromLCC(coordinates, target).conjugate();
248
- };
249
- },
250
- /**
251
- * Computes the rotation from a Transverse Mercator frame (TMerc) to the local East North Up (ENU) frame.
252
- * The quaternion accounts for the
253
- * <a href="https://geodesie.ign.fr/contenu/fichiers/documentation/algorithmes/alg0061.pdf">meridian convergence</a>
254
- * between the ENU and TMerc frames.
255
- * This is a generally small rotation around Z.
256
- *
257
- * @param {Object} proj the tmerc projection (may be parsed using proj4)
258
- * @param {number} proj.e - the excentricity of the ellipsoid (supersedes {proj.a} and {proj.b})
259
- * @param {number} proj.a - the semimajor radius of the ellipsoid axis
260
- * @param {number} proj.b - the semiminor radius of the ellipsoid axis
261
- * @param {number} proj.long0 - the longitude of the central meridian
262
- *
263
- * @param {Coordinates} [coordinates] coordinates the origin of the local East North Up
264
- * (ENU) frame
265
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
266
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
267
- */
268
- quaternionFromTMercToEnu(proj, coordinates) {
269
- let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new THREE.Quaternion();
270
- if (coordinates) {
271
- return this.quaternionFromTMercToEnu(proj)(coordinates, target);
272
- }
273
- const a2 = proj.a * proj.a;
274
- const b2 = proj.b * proj.b;
275
- const e2 = proj.e * proj.e;
276
- const eta0 = proj.e ? e2 / (1 - e2) : a2 / b2 - 1;
277
- return function (coordinates) {
278
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
279
- coordinates.as(coord.crs, coord);
280
- const long = coord.longitude * DEG2RAD;
281
- const lat = coord.latitude * DEG2RAD;
282
- const dlong = proj.long0 - long;
283
- const coslat = Math.cos(lat);
284
- const sinlat = Math.sin(lat);
285
- const coslat2 = coslat * coslat;
286
- const dl2 = dlong * dlong * coslat2;
287
- const eta2 = eta0 * coslat2;
288
- return target.setFromAxisAngle(axis, dlong * sinlat * (1 + dl2 / 3 * (1 + 3 * eta2 + 2 * eta2 * eta2) + dl2 * dl2 * (2 - sinlat / coslat) / 15));
289
- };
290
- },
291
- /**
292
- * Computes the rotation from the local East North Up (ENU) to a Transverse Mercator frame.
293
- * The quaternion accounts for the
294
- * <a href="https://geodesie.ign.fr/contenu/fichiers/documentation/algorithmes/alg0061.pdf">meridian convergence</a>
295
- * between the ENU and TMerc frames.
296
- * This is a generally small rotation around Z.
297
- *
298
- * @param {Object} proj the tmerc projection (may be parsed using proj4)
299
- * @param {number} proj.e - the excentricity of the ellipsoid (supersedes
300
- * {proj.a} and {proj.b})
301
- * @param {number} proj.a - the semimajor radius of the ellipsoid axis
302
- * @param {number} proj.b - the semiminor radius of the ellipsoid axis
303
- * @param {number} proj.long0 - the longitude of the central meridian
304
- *
305
- * @param {Coordinates} [coordinates] coordinates the origin of the local East North Up
306
- * (ENU) frame
307
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
308
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
309
- */
310
- quaternionFromEnuToTMerc(proj, coordinates) {
311
- let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new THREE.Quaternion();
312
- if (coordinates) {
313
- return this.quaternionFromEnuToTMerc(proj)(coordinates, target);
314
- }
315
- const fromTMerc = this.quaternionFromTMercToEnu(proj);
316
- return function (coordinates) {
317
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
318
- return fromTMerc(coordinates, target).conjugate();
319
- };
320
- },
321
- /**
322
- * Computes the rotation from a LongLat frame to the local East North Up (ENU) frame.
323
- * The identity quaternion (0,0,0,1) is returned, as longlat and ENU frame are assumed to be aligned.
324
- *
325
- * @param {Coordinates} [coordinates] coordinates the origin of the local East North Up
326
- * (ENU) frame
327
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
328
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
329
- */
330
- quaternionFromLongLatToEnu(coordinates) {
331
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
332
- return quaternionIdentity(coordinates, target);
333
- },
334
- /**
335
- * Computes the rotation from the local East North Up (ENU) frame to a LongLat frame.
336
- * The identity quaternion (0,0,0,1) is returned, as longlat and ENU frame are assumed to be aligned.
337
- *
338
- * @param {Coordinates} [coordinates] coordinates the origin of the local East North Up
339
- * (ENU) frame
340
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
341
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
342
- */
343
- quaternionFromEnuToLongLat(coordinates) {
344
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
345
- return quaternionIdentity(coordinates, target);
346
- },
347
- /**
348
- * Warns for an unimplemented projection, sets the quaternion to the
349
- * identity (0,0,0,1).
350
- *
351
- * @param {Projection} proj - the unimplemented projection (may be parsed
352
- * using proj4)
353
- *
354
- * @param {Coordinates} [coordinates] coordinates the origin of the local East North Up
355
- * (ENU) frame
356
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
357
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
358
- */
359
- quaternionUnimplemented(proj, coordinates) {
360
- let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new THREE.Quaternion();
361
- console.warn('This quaternion function is not implemented for projections of type', proj.projName);
362
- return quaternionIdentity(coordinates, target);
363
- },
364
- /**
365
- * Compute the quaternion that models the rotation from the local East North
366
- * Up (ENU) frame to the frame of the given crs.
367
- *
368
- * @param {string|Projection} crsOrProj - the CRS of the target frame or its
369
- * proj4-compatible object.
370
- *
371
- * @param {Coordinates} [coordinates] coordinates the origin of the local East North Up
372
- * (ENU) frame
373
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
374
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
375
- */
376
- quaternionFromEnuToCRS(crsOrProj, coordinates) {
377
- let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new THREE.Quaternion();
378
- if (coordinates) {
379
- return this.quaternionFromEnuToCRS(crsOrProj)(coordinates, target);
380
- }
381
- const proj = crsOrProj.projName ? crsOrProj : proj4.defs(crsOrProj);
382
- switch (proj.projName) {
383
- case 'geocent':
384
- return this.quaternionFromEnuToGeocent();
385
- case 'lcc':
386
- return this.quaternionFromEnuToLCC(proj);
387
- case 'tmerc':
388
- return this.quaternionFromEnuToTMerc(proj);
389
- case 'longlat':
390
- return this.quaternionFromEnuToLongLat();
391
- default:
392
- return this.quaternionUnimplemented(proj);
393
- }
394
- },
395
- /**
396
- * Compute the quaternion that models the rotation from the frame of the
397
- * given crs to the local East North Up (ENU) frame.
398
- *
399
- * @param {string|Projection} crsOrProj - the CRS of the source frame or its
400
- * proj4-compatible object.
401
- *
402
- * @param {Coordinates} [coordinates] coordinates the origin of the local East North Up
403
- * (ENU) frame
404
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
405
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
406
- */
407
- quaternionFromCRSToEnu(crsOrProj, coordinates) {
408
- let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new THREE.Quaternion();
409
- if (coordinates) {
410
- return this.quaternionFromCRSToEnu(crsOrProj)(coordinates, target);
411
- }
412
- const proj = crsOrProj.projName ? crsOrProj : proj4.defs(crsOrProj);
413
- switch (proj.projName) {
414
- case 'geocent':
415
- return this.quaternionFromGeocentToEnu();
416
- case 'lcc':
417
- return this.quaternionFromLCCToEnu(proj);
418
- case 'tmerc':
419
- return this.quaternionFromTMercToEnu(proj);
420
- case 'longlat':
421
- return this.quaternionFromLongLatToEnu();
422
- default:
423
- return this.quaternionUnimplemented(proj);
424
- }
425
- },
426
- /**
427
- * Return the function that computes the quaternion that represents a
428
- * rotation of coordinates between two CRS frames.
429
- *
430
- * @param {string} crsIn - the CRS of the input frame.
431
- * @param {string} crsOut - the CRS of the output frame.
432
- * @param {Coordinates} [coordinates] coordinates - the origin of the local East North Up
433
- * (ENU) frame
434
- * @param {THREE.Quaternion} [target=new THREE.Quaternion()] output Quaternion
435
- * @return {FunctionOrQuaternion} The target quaternion if coordinates is defined, otherwise, a function to compute it from coordinates.
436
- */
437
- quaternionFromCRSToCRS(crsIn, crsOut, coordinates) {
438
- let target = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new THREE.Quaternion();
439
- if (coordinates) {
440
- return this.quaternionFromCRSToCRS(crsIn, crsOut)(coordinates, target);
441
- }
442
- if (crsIn == crsOut) {
443
- return function () {
444
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
445
- return target.set(0, 0, 0, 1);
446
- };
447
- }
448
-
449
- // get rotations from the local East/North/Up (ENU) frame to both CRS.
450
- const fromCrs = this.quaternionFromCRSToEnu(crsIn);
451
- const toCrs = this.quaternionFromEnuToCRS(crsOut);
452
- return function (origin) {
453
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Quaternion();
454
- return toCrs(origin, target).multiply(fromCrs(origin, quat));
455
- };
456
- }
457
- };
@@ -1,115 +0,0 @@
1
- /**
2
- * Find threejs textures from a material
3
- * @param {Material} material the threejs material holding textures
4
- * @returns {Array} an array of textures in the material
5
- */
6
- function findTextures(material) {
7
- const textures = [];
8
- if (material.alphaMap) {
9
- textures.push(material.map);
10
- }
11
- if (material.aoMap) {
12
- textures.push(material.map);
13
- }
14
- if (material.bumpMap) {
15
- textures.push(material.bumpMap);
16
- }
17
- if (material.displacementMap) {
18
- textures.push(material.bumpMap);
19
- }
20
- if (material.emissiveMap) {
21
- textures.push(material.emissiveMap);
22
- }
23
- if (material.envMap) {
24
- textures.push(material.envMap);
25
- }
26
- if (material.lightMap) {
27
- textures.push(material.envMap);
28
- }
29
- if (material.map) {
30
- textures.push(material.map);
31
- }
32
- if (material.metalnessMap) {
33
- textures.push(material.map);
34
- }
35
- if (material.normalMap) {
36
- textures.push(material.map);
37
- }
38
- if (material.roughnessMap) {
39
- textures.push(material.map);
40
- }
41
- if (material.specularMap) {
42
- textures.push(material.specularMap);
43
- }
44
- return textures;
45
- }
46
-
47
- /**
48
- * Removes a material and its textures, memory will be freed.
49
- * IMPORTANT NOTE: the material and the texture must not be referenced by other threejs objects, otherwise the memory
50
- * won't be freed.
51
- * @param {Material} material the material to remove
52
- */
53
- export default function disposeThreeMaterial(material) {
54
- const textures = findTextures(material);
55
- // Remove material
56
- if (Array.isArray(material)) {
57
- for (const m of material) {
58
- m.dispose();
59
- }
60
- } else {
61
- material.dispose();
62
- }
63
- // Remove textures
64
- for (let i = 0; i < textures.length; i++) {
65
- textures[i].dispose();
66
- }
67
- }
68
-
69
- /**
70
- * Merge groups of an object3D when it can to reduce number of them + remove unused materials
71
- * Reduce draw call https://threejs.org/docs/index.html?q=geometry#api/en/core/BufferGeometry.groups
72
- *
73
- * @param {THREE.Object3D} object3D - object to get optimize
74
- */
75
- export function optimizeGeometryGroups(object3D) {
76
- if (!object3D.geometry) {
77
- return;
78
- }
79
- object3D.geometry.groups.sort((a, b) => (a.start - b.start) * -1); // [5,10,7] => [10,7,5]
80
- const lastIndex = object3D.geometry.groups.length - 1;
81
- let currentMaterialIndex = object3D.geometry.groups[lastIndex].materialIndex; // initialized with the lastest group
82
- const usedIndexMaterials = [currentMaterialIndex]; // compute materials actually used by group
83
- // for loop descendant to be able to splice in loop without modifying group index
84
- for (let index = lastIndex - 1; index >= 0; index--) {
85
- // begin at lastIndex - 1 because intialized with lastIndex
86
- const group = object3D.geometry.groups[index];
87
- if (group.materialIndex !== currentMaterialIndex) {
88
- // this is another group (!= materialIndex) take its material as ref to continue
89
- currentMaterialIndex = group.materialIndex;
90
- usedIndexMaterials.push(currentMaterialIndex);
91
- continue;
92
- } else {
93
- // indeed same group merge with previous group
94
- const previousGroup = object3D.geometry.groups[index + 1];
95
- previousGroup.count += group.count; // previous group wrap the current one
96
- object3D.geometry.groups.splice(index, 1); // remove group
97
- }
98
- }
99
-
100
- // clean unused material
101
- for (let index = object3D.material.length - 1; index >= 0; index--) {
102
- if (!usedIndexMaterials.includes(index)) {
103
- // update all materialIndex in groups
104
- object3D.geometry.groups.forEach(group => {
105
- if (group.materialIndex > index) {
106
- // only materialIndex > at index are modified
107
- group.materialIndex -= 1;
108
- }
109
- });
110
-
111
- // remove
112
- object3D.material.splice(index, 1);
113
- }
114
- }
115
- }