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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -608
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -726
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/TileGeometry.js +0 -40
  100. package/lib/Core/TileMesh.js +0 -108
  101. package/lib/Core/View.js +0 -1109
  102. package/lib/Layer/C3DTilesLayer.js +0 -455
  103. package/lib/Layer/ColorLayer.js +0 -128
  104. package/lib/Layer/CopcLayer.js +0 -58
  105. package/lib/Layer/ElevationLayer.js +0 -107
  106. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  107. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  108. package/lib/Layer/GeoidLayer.js +0 -80
  109. package/lib/Layer/GeometryLayer.js +0 -202
  110. package/lib/Layer/InfoLayer.js +0 -64
  111. package/lib/Layer/LabelLayer.js +0 -452
  112. package/lib/Layer/Layer.js +0 -304
  113. package/lib/Layer/LayerUpdateState.js +0 -89
  114. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  115. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  116. package/lib/Layer/OrientedImageLayer.js +0 -222
  117. package/lib/Layer/PointCloudLayer.js +0 -359
  118. package/lib/Layer/Potree2Layer.js +0 -164
  119. package/lib/Layer/PotreeLayer.js +0 -65
  120. package/lib/Layer/RasterLayer.js +0 -27
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  122. package/lib/Layer/TiledGeometryLayer.js +0 -403
  123. package/lib/Loader/LASLoader.js +0 -193
  124. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  125. package/lib/Loader/Potree2Loader.js +0 -207
  126. package/lib/Main.js +0 -115
  127. package/lib/MainBundle.js +0 -4
  128. package/lib/Parser/B3dmParser.js +0 -174
  129. package/lib/Parser/CameraCalibrationParser.js +0 -94
  130. package/lib/Parser/GDFParser.js +0 -72
  131. package/lib/Parser/GTXParser.js +0 -75
  132. package/lib/Parser/GeoJsonParser.js +0 -212
  133. package/lib/Parser/GpxParser.js +0 -25
  134. package/lib/Parser/ISGParser.js +0 -71
  135. package/lib/Parser/KMLParser.js +0 -25
  136. package/lib/Parser/LASParser.js +0 -137
  137. package/lib/Parser/MapBoxUrlParser.js +0 -83
  138. package/lib/Parser/PntsParser.js +0 -131
  139. package/lib/Parser/Potree2BinParser.js +0 -92
  140. package/lib/Parser/PotreeBinParser.js +0 -106
  141. package/lib/Parser/PotreeCinParser.js +0 -29
  142. package/lib/Parser/ShapefileParser.js +0 -78
  143. package/lib/Parser/VectorTileParser.js +0 -202
  144. package/lib/Parser/XbilParser.js +0 -108
  145. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  146. package/lib/Parser/iGLTFLoader.js +0 -168
  147. package/lib/Process/3dTilesProcessing.js +0 -304
  148. package/lib/Process/FeatureProcessing.js +0 -76
  149. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  150. package/lib/Process/ObjectRemovalHelper.js +0 -97
  151. package/lib/Process/handlerNodeError.js +0 -23
  152. package/lib/Provider/3dTilesProvider.js +0 -149
  153. package/lib/Provider/DataSourceProvider.js +0 -8
  154. package/lib/Provider/Fetcher.js +0 -229
  155. package/lib/Provider/PointCloudProvider.js +0 -45
  156. package/lib/Provider/TileProvider.js +0 -16
  157. package/lib/Provider/URLBuilder.js +0 -105
  158. package/lib/Renderer/Camera.js +0 -281
  159. package/lib/Renderer/Color.js +0 -56
  160. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  161. package/lib/Renderer/CommonMaterial.js +0 -31
  162. package/lib/Renderer/Label2DRenderer.js +0 -190
  163. package/lib/Renderer/LayeredMaterial.js +0 -243
  164. package/lib/Renderer/OBB.js +0 -153
  165. package/lib/Renderer/OrientedImageCamera.js +0 -118
  166. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  167. package/lib/Renderer/PointsMaterial.js +0 -485
  168. package/lib/Renderer/RasterTile.js +0 -209
  169. package/lib/Renderer/RenderMode.js +0 -31
  170. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  171. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  172. package/lib/Renderer/SphereHelper.js +0 -23
  173. package/lib/Renderer/WebXR.js +0 -51
  174. package/lib/Renderer/c3DEngine.js +0 -214
  175. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  176. package/lib/Source/C3DTilesIonSource.js +0 -54
  177. package/lib/Source/C3DTilesSource.js +0 -30
  178. package/lib/Source/CopcSource.js +0 -115
  179. package/lib/Source/EntwinePointTileSource.js +0 -62
  180. package/lib/Source/FileSource.js +0 -189
  181. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  182. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  183. package/lib/Source/OGC3DTilesSource.js +0 -21
  184. package/lib/Source/OrientedImageSource.js +0 -59
  185. package/lib/Source/Potree2Source.js +0 -167
  186. package/lib/Source/PotreeSource.js +0 -82
  187. package/lib/Source/Source.js +0 -223
  188. package/lib/Source/TMSSource.js +0 -143
  189. package/lib/Source/VectorTilesSource.js +0 -178
  190. package/lib/Source/WFSSource.js +0 -165
  191. package/lib/Source/WMSSource.js +0 -130
  192. package/lib/Source/WMTSSource.js +0 -86
  193. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  194. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  195. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  196. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  197. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  198. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  199. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  200. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  201. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  202. package/lib/Utils/CameraUtils.js +0 -555
  203. package/lib/Utils/DEMUtils.js +0 -350
  204. package/lib/Utils/FeaturesUtils.js +0 -156
  205. package/lib/Utils/Gradients.js +0 -16
  206. package/lib/Utils/OrientationUtils.js +0 -457
  207. package/lib/Utils/ThreeUtils.js +0 -115
  208. package/lib/Utils/gui/C3DTilesStyle.js +0 -216
  209. package/lib/Utils/gui/Main.js +0 -7
  210. package/lib/Utils/gui/Minimap.js +0 -154
  211. package/lib/Utils/gui/Navigation.js +0 -245
  212. package/lib/Utils/gui/Scale.js +0 -107
  213. package/lib/Utils/gui/Searchbar.js +0 -234
  214. package/lib/Utils/gui/Widget.js +0 -80
  215. package/lib/Utils/placeObjectOnGround.js +0 -137
  216. package/lib/Worker/LASLoaderWorker.js +0 -19
  217. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,153 +0,0 @@
1
- import * as THREE from 'three';
2
- import TileGeometry from "../Core/TileGeometry.js";
3
- import BuilderEllipsoidTile from "../Core/Prefab/Globe/BuilderEllipsoidTile.js";
4
- import Coordinates from "../Core/Geographic/Coordinates.js";
5
- import CRS from "../Core/Geographic/Crs.js";
6
-
7
- // get oriented bounding box of tile
8
- const builder = new BuilderEllipsoidTile({
9
- crs: 'EPSG:4978',
10
- uvCount: 1
11
- });
12
- const size = new THREE.Vector3();
13
- const dimension = new THREE.Vector2();
14
- const center = new THREE.Vector3();
15
- const coord = new Coordinates('EPSG:4326', 0, 0, 0);
16
- let obb;
17
-
18
- // it could be considered to remove THREE.Object3D extend.
19
- /**
20
- * Oriented bounding box
21
- * @extends THREE.Object3D
22
- */
23
- class OBB extends THREE.Object3D {
24
- /**
25
- * @param {THREE.Vector3} min representing the lower (x, y, z) boundary of the box. Default is ( + Infinity, + Infinity, + Infinity ).
26
- * @param {THREE.Vector3} max representing the lower upper (x, y, z) boundary of the box. Default is ( - Infinity, - Infinity, - Infinity ).
27
- */
28
- constructor() {
29
- let min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector3(+Infinity, +Infinity, +Infinity);
30
- let max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector3(-Infinity, -Infinity, -Infinity);
31
- super();
32
- this.box3D = new THREE.Box3(min.clone(), max.clone());
33
- this.natBox = this.box3D.clone();
34
- this.z = {
35
- min: 0,
36
- max: 0,
37
- scale: 1.0
38
- };
39
- }
40
-
41
- /**
42
- * Creates a new instance of the object with same properties than original.
43
- *
44
- * @return {OBB} Copy of this object.
45
- */
46
- clone() {
47
- return new OBB().copy(this);
48
- }
49
-
50
- /**
51
- * Copy the property of OBB
52
- *
53
- * @param {OBB} cOBB OBB to copy
54
- * @return {OBB} the copy
55
- */
56
- copy(cOBB) {
57
- super.copy(cOBB);
58
- this.box3D.copy(cOBB.box3D);
59
- this.natBox.copy(cOBB.natBox);
60
- this.z.min = cOBB.z.min;
61
- this.z.max = cOBB.z.max;
62
- this.z.scale = cOBB.z.scale;
63
- return this;
64
- }
65
-
66
- /**
67
- * Update z min, z max and z scale of oriented bounding box
68
- *
69
- * @param {Object} [elevation={}]
70
- * @param {number} [elevation.min] The minimum of oriented bounding box
71
- * @param {number} [elevation.max] The maximum of oriented bounding box
72
- * @param {number} [elevation.scale] The scale of oriented bounding box Z axis
73
- * @param {number} [elevation.geoidHeight] The geoid height added to ellipsoid.
74
- */
75
- updateZ() {
76
- let elevation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
77
- this.z.min = elevation.min ?? this.z.min;
78
- this.z.max = elevation.max ?? this.z.max;
79
- this.z.scale = elevation.scale > 0 ? elevation.scale : this.z.scale;
80
- this.z.delta = Math.abs(this.z.max - this.z.min) * this.z.scale;
81
- const geoidHeight = elevation.geoidHeight || 0;
82
- this.box3D.min.z = this.natBox.min.z + this.z.min * this.z.scale + geoidHeight;
83
- this.box3D.max.z = this.natBox.max.z + this.z.max * this.z.scale + geoidHeight;
84
- }
85
-
86
- /**
87
- * Determines if the sphere is above the XY space of the box
88
- *
89
- * @param {Sphere} sphere The sphere
90
- * @return {boolean} True if sphere is above the XY space of the box, False otherwise.
91
- */
92
- isSphereAboveXYBox(sphere) {
93
- const localSpherePosition = this.worldToLocal(sphere.center);
94
- // get obb closest point to sphere center by clamping
95
- const x = Math.max(this.box3D.min.x, Math.min(localSpherePosition.x, this.box3D.max.x));
96
- const y = Math.max(this.box3D.min.y, Math.min(localSpherePosition.y, this.box3D.max.y));
97
-
98
- // this is the same as isPointInsideSphere.position
99
- const distance = Math.sqrt((x - localSpherePosition.x) * (x - localSpherePosition.x) + (y - localSpherePosition.y) * (y - localSpherePosition.y));
100
- return distance < sphere.radius;
101
- }
102
-
103
- /**
104
- * Compute OBB from extent.
105
- * The OBB resulted can be only in the system 'EPSG:3946'.
106
- *
107
- * @param {Extent} extent The extent (with crs 'EPSG:4326') to compute oriented bounding box
108
- * @param {number} minHeight The minimum height of OBB
109
- * @param {number} maxHeight The maximum height of OBB
110
- * @return {OBB} return this object
111
- */
112
- setFromExtent(extent) {
113
- let minHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extent.min || 0;
114
- let maxHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extent.max || 0;
115
- if (extent.crs == 'EPSG:4326') {
116
- const {
117
- sharableExtent,
118
- quaternion,
119
- position
120
- } = builder.computeSharableExtent(extent);
121
- // Compute the minimum count of segment to build tile
122
- const segments = Math.max(Math.floor(sharableExtent.planarDimensions(dimension).x / 90 + 1), 2);
123
- const geometry = new TileGeometry({
124
- extent: sharableExtent,
125
- level: 0,
126
- segments,
127
- disableSkirt: true,
128
- builder
129
- });
130
- obb.box3D.copy(geometry.boundingBox);
131
- obb.natBox.copy(geometry.boundingBox);
132
- this.copy(obb);
133
- this.updateZ({
134
- min: minHeight,
135
- max: maxHeight
136
- });
137
- this.position.copy(position);
138
- this.quaternion.copy(quaternion);
139
- this.updateMatrixWorld(true);
140
- } else if (!CRS.isTms(extent.crs) && CRS.isMetricUnit(extent.crs)) {
141
- extent.center(coord).toVector3(this.position);
142
- extent.planarDimensions(dimension);
143
- size.set(dimension.x, dimension.y, Math.abs(maxHeight - minHeight));
144
- this.box3D.setFromCenterAndSize(center, size);
145
- this.updateMatrixWorld(true);
146
- } else {
147
- throw new Error('Unsupported extent crs');
148
- }
149
- return this;
150
- }
151
- }
152
- obb = new OBB();
153
- export default OBB;
@@ -1,118 +0,0 @@
1
- import * as THREE from 'three';
2
- class Distortion {
3
- constructor(size) {
4
- this.size = size;
5
- this.pps = null;
6
- this.polynom = null;
7
- this.l1l2 = null;
8
- }
9
- setFromMicmacCalibration(distortion) {
10
- let imageYDown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
11
- this.pps = new THREE.Vector2().fromArray(distortion.pps);
12
- this.polynom = new THREE.Vector4().fromArray(distortion.poly357);
13
- this.l1l2 = new THREE.Vector3();
14
- // inverse Y pps convention image micmac
15
- this.pps.y = imageYDown ? this.size.y - this.pps.y : this.pps.y;
16
- this.polynom.w = distortion.limit ** 2;
17
- if (distortion.l1l2) {
18
- this.l1l2.fromArray(distortion.l1l2);
19
- this.l1l2.z = distortion.etats;
20
- }
21
- }
22
- clone() {
23
- const dest = new Distortion(this.size.clone());
24
- dest.pps = this.pps.clone();
25
- dest.polynom = this.polynom.clone();
26
- dest.l1l2 = this.l1l2.clone();
27
- return dest;
28
- }
29
- }
30
- const zoom = new THREE.Vector3();
31
-
32
- /**
33
- * OrientedImageCamera is a ThreeJs camera adapted to photogrammetric description.
34
- * So we can build a ThreeJs perspective camera from size and focal information.
35
- */
36
- class OrientedImageCamera extends THREE.PerspectiveCamera {
37
- /**
38
- * @param {number|Vector2} size - image size in pixels (default: x=1024, y=x)
39
- * @param {number|Vector2} focal - focal length in pixels (default: x=1024, y=x)
40
- * @param {Vector2} center - principal point in pixels (default: size/2)
41
- * @param {number} near - Camera frustum near plane (default: see THREE.PerspectiveCamera).
42
- * @param {number} far - Camera frustum far plane (default: see THREE.PerspectiveCamera).
43
- * @param {number} skew - shear transform parameter (default: 0)
44
- * @param {number} aspect - aspect ratio of the camera (default: size.x/size.y).
45
- */
46
- constructor() {
47
- let size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1024;
48
- let focal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1024;
49
- let center = arguments.length > 2 ? arguments[2] : undefined;
50
- let near = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.1;
51
- let far = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10000;
52
- let skew = arguments.length > 5 ? arguments[5] : undefined;
53
- let aspect = arguments.length > 6 ? arguments[6] : undefined;
54
- size = size.isVector2 ? size : new THREE.Vector2(size, size);
55
- aspect = aspect || size.x / size.y;
56
- super(undefined, aspect, near, far);
57
- this.size = size;
58
- this.focal = focal.isVector2 ? focal : new THREE.Vector2(focal, focal);
59
- this.center = center || size.clone().multiplyScalar(0.5);
60
- this.skew = skew || 0;
61
- this.textureMatrixWorldInverse = new THREE.Matrix4();
62
- Object.defineProperty(this, 'fov', {
63
- get: () => 2 * THREE.MathUtils.radToDeg(Math.atan2(this.size.y, 2 * this.focal.y)),
64
- // setting the fov overwrites focal.x and focal.y
65
- set: fov => {
66
- const focal = 0.5 * this.size.y / Math.tan(THREE.MathUtils.degToRad(fov * 0.5));
67
- this.focal.x = focal;
68
- this.focal.y = focal;
69
- }
70
- });
71
- this.distortion = new Distortion(this.size);
72
- this.maskPath = undefined;
73
- this.mask = undefined;
74
- this.updateProjectionMatrix();
75
- }
76
-
77
- // we override PerspectiveCamera.updateProjectionMatrix to
78
- // update the projection matrix depending on other variables
79
- // focal, center and size...
80
- updateProjectionMatrix() {
81
- if (!this.focal) {
82
- return;
83
- }
84
- const near = this.near;
85
- const sx = near / this.focal.x;
86
- const sy = near / this.focal.y;
87
- const left = -sx * this.center.x;
88
- const bottom = -sy * this.center.y;
89
- const right = left + sx * this.size.x;
90
- const top = bottom + sy * this.size.y;
91
- this.projectionMatrix.makePerspective(left, right, top, bottom, near, this.far);
92
- this.projectionMatrix.elements[4] = 2 * this.skew / this.size.x;
93
-
94
- // take zoom and aspect into account
95
- const textureAspect = this.size.x / this.size.y;
96
- const aspectRatio = this.aspect / textureAspect;
97
- zoom.set(this.zoom, this.zoom, 1);
98
- if (aspectRatio > 1) {
99
- zoom.x /= aspectRatio;
100
- } else {
101
- zoom.y *= aspectRatio;
102
- }
103
- this.projectionMatrix.scale(zoom);
104
- }
105
- copy(source, recursive) {
106
- super.copy(source, recursive);
107
- this.size = source.size.clone();
108
- this.focal = source.focal.clone();
109
- this.center = source.center.clone();
110
- this.distortion = source.distortion.clone();
111
- this.textureMatrixWorldInverse = source.textureMatrixWorldInverse.clone();
112
- this.skew = source.skew;
113
- this.maskPath = source.maskPath;
114
- this.mask = source.mask;
115
- return this;
116
- }
117
- }
118
- export default OrientedImageCamera;
@@ -1,167 +0,0 @@
1
- import * as THREE from 'three';
2
- import Capabilities from "../Core/System/Capabilities.js";
3
- /* babel-plugin-inline-import './Shader/ProjectiveTextureVS.glsl' */
4
- const textureVS = "#include <itowns/precision_qualifier>\n#include <itowns/projective_texturing_pars_vertex>\n#include <common>\n#include <logdepthbuf_pars_vertex>\n\nvarying vec3 vNormal;\n\nvoid main() {\n #include <begin_vertex>\n #include <project_vertex>\n vNormal = normal;\n #include <itowns/projective_texturing_vertex>\n #include <logdepthbuf_vertex>\n}\n";
5
- /* babel-plugin-inline-import './Shader/ProjectiveTextureFS.glsl' */
6
- const textureFS = "#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#include <itowns/projective_texturing_pars_fragment>\nvarying vec3 vNormal;\n\n#ifdef USE_BASE_MATERIAL\nstruct noPT {\n vec3 lightDirection;\n vec3 ambient;\n float opacity;\n};\n\nuniform noPT noProjectiveMaterial;\n#endif\n\nvoid main(void)\n{\n #include <logdepthbuf_fragment>\n #ifdef USE_BASE_MATERIAL\n float nDotVP = (max(0.1, dot(vNormal, normalize(noProjectiveMaterial.lightDirection))));\n vec4 color = vec4(noProjectiveMaterial.ambient + nDotVP, 0.0);\n #else\n vec4 color = vec4(0.0);\n #endif\n\n #pragma unroll_loop\n for (int i = 0; i < ORIENTED_IMAGES_COUNT; i++) {\n color = projectiveTextureColor(projectiveTextureCoords[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTextureDistortion[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTexture[ ORIENTED_IMAGES_COUNT - 1 - i ], mask[ORIENTED_IMAGES_COUNT - 1 - i], color);\n }\n\n #ifdef USE_BASE_MATERIAL\n color.a = color.a < 1.0 ? max(noProjectiveMaterial.opacity, color.a) : 1.0 ;\n gl_FragColor = vec4(color.rgb, color.a * opacity);\n #else\n gl_FragColor = vec4(color.rgb / color.a, opacity);\n #endif\n\n}\n";
7
- import ShaderUtils from "./Shader/ShaderUtils.js";
8
- const ndcToTextureMatrix = new THREE.Matrix4(1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 2);
9
- const noMask = new THREE.DataTexture(new Uint8Array([255, 255, 255, 255]), 1, 1, THREE.RGBAFormat, THREE.UnsignedByteType);
10
- noMask.needsUpdate = true;
11
- const noTexture = new THREE.Texture();
12
- const shaderMaterial = new THREE.ShaderMaterial();
13
- /**
14
- * OrientedImageMaterial is a custom shader material used to do projective texture mapping.<br/>
15
- *
16
- * This Material is designed to project many textures simultaneously.
17
- * Each projected texture setting is stored as an {@link OrientedImageCamera}.<br/>
18
- * <br/>
19
- * All cameras settings, like distorsion, can be specified in a configuration file.
20
- * See [CameraCalibrationParser]{@link module:CameraCalibrationParser.parse}
21
- * used to parse a configuration file and create an array of camera.<br/>
22
- * <br/>
23
- * The current implementation supports the following distortion models : <br/>
24
- * - no distortion (polynom==vec3(0),l1l2==vec2(0))<br/>
25
- * - radial distortion (polynom!=vec3(0),l1l2==vec2(0)) (see <b>15.2.2 Radial Model</b> in [MicMac doc](https://github.com/micmacIGN/Documentation/blob/master/DocMicMac.pdf)) </br>
26
- * - equilinear fish eye distortion (polynom!=vec3(0),l1l2 != vec2(0)) (see <b>15.3.4 Fish eye models</b> in [MicMac doc](https://github.com/micmacIGN/Documentation/blob/master/DocMicMac.pdf)) </br>
27
- * (Note: radial decentric parameters P1 are P2 not supported and assumed to be 0).<br/>
28
- * <br/>
29
- * To get a more comprehensive support of camera Micmac models, you can consider using [three-photogrammetric-camera]{@link https://github.com/mbredif/three-photogrammetric-camera} instead.
30
- */
31
- class OrientedImageMaterial extends THREE.ShaderMaterial {
32
- /**
33
- * @param { OrientedImageCamera[]} cameras - Array of {@link OrientedImageCamera}. Each camera will project a texture.
34
- * [CameraCalibrationParser]{@link module:CameraCalibrationParser.parse} can used to create this array of camera from a configuration file.
35
- * @param {Object} [options={}] - Object with one or more properties defining the material's appearance.
36
- * Any property of the material (including any property inherited from
37
- * [THREE.Material]{@link https://threejs.org/docs/#api/en/materials/Material} and
38
- * [THREE.ShaderMaterial]{@link https://threejs.org/docs/#api/en/materials/ShaderMaterial}) can be passed in here.
39
- * @param {Number} [options.side=THREE.DoubleSide] - We override default
40
- * [THREE.Material.side]{@link https://threejs.org/docs/#api/en/materials/Material.side} from FrontSide to DoubleSide.
41
- * @param {Boolean} [options.transparent=true] - We override default
42
- * [THREE.Material.transparent]{@link https://threejs.org/docs/#api/en/materials/Material.transparent} from false to true.
43
- * @param {Number} [options.opacity=0.1] - We override default
44
- * [THREE.Material.opacity]{@link https://threejs.org/docs/#api/en/materials/Material.opacity} from 1 to 0.1.
45
- * @param {Number} [options.alphaBorder=20] - Part of the texture that is blended, when texture crosses each other.
46
- * For example, 10 means a border as large as 1 / 10 of the size of the texture is used to blend colors.
47
- * @param {Number} [options.debugAlphaBorder=0] - Set this option to 1 to see influence of alphaBorder option.
48
- */
49
- constructor(cameras) {
50
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
51
- options.side = options.side ?? THREE.DoubleSide;
52
- options.transparent = options.transparent ?? true;
53
- options.opacity = options.opacity ?? 1;
54
-
55
- // Filter out non-ShaderMaterial options
56
- const shaderMaterialOptions = {};
57
- for (const key in options) {
58
- if (Object.prototype.hasOwnProperty.call(options, key)) {
59
- const currentValue = shaderMaterial[key];
60
- if (currentValue !== undefined) {
61
- shaderMaterialOptions[key] = options[key];
62
- }
63
- }
64
- }
65
- super(shaderMaterialOptions);
66
- this.defines.ORIENTED_IMAGES_COUNT = options.OrientedImagesCount ?? cameras.length;
67
-
68
- // verify that number of textures doesn't exceed GPU capabilities
69
- const maxTexturesUnits = Capabilities.getMaxTextureUnitsCount();
70
- if (this.defines.ORIENTED_IMAGES_COUNT > maxTexturesUnits) {
71
- console.warn(`OrientedImageMaterial: Can't project ${cameras.length} textures, because it's more than GPU capabilities maximum texture units (${maxTexturesUnits})`);
72
-
73
- // Clamp number of textures used
74
- this.defines.ORIENTED_IMAGES_COUNT = maxTexturesUnits - 1;
75
- console.warn(`OrientedImageMaterial: We'll use only the first ${this.defines.ORIENTED_IMAGES_COUNT} cameras.`);
76
- }
77
- if (options.useBaseMaterial) {
78
- this.defines.USE_BASE_MATERIAL = true;
79
- }
80
- this.defines.USE_DISTORTION = Number(cameras.some(camera => camera.distortion.pps !== null));
81
- this.alphaBorder = options.alphaBorder | 20;
82
- this.defines.DEBUG_ALPHA_BORDER = options.debugAlphaBorder | 0;
83
- this.cameras = cameras;
84
- const textureMatrix = [];
85
- const texture = [];
86
- const mask = [];
87
- const distortion = [];
88
- this.group = new THREE.Group();
89
- for (let i = 0; i < this.defines.ORIENTED_IMAGES_COUNT; ++i) {
90
- texture[i] = noTexture;
91
- mask[i] = noMask;
92
- textureMatrix[i] = new THREE.Matrix4();
93
- cameras[i].needsUpdate = true;
94
- distortion[i] = cameras[i].distortion;
95
- this.group.add(cameras[i]);
96
- }
97
- this.uniforms.opacity = new THREE.Uniform(this.opacity);
98
- this.uniforms.projectiveTextureAlphaBorder = new THREE.Uniform(this.alphaBorder);
99
- this.uniforms.projectiveTextureDistortion = new THREE.Uniform(distortion);
100
- this.uniforms.projectiveTextureMatrix = new THREE.Uniform(textureMatrix);
101
- this.uniforms.projectiveTexture = new THREE.Uniform(texture);
102
- this.uniforms.mask = new THREE.Uniform(mask);
103
- this.uniforms.boostLight = new THREE.Uniform(false);
104
- this.uniforms.noProjectiveMaterial = new THREE.Uniform({
105
- lightDirection: new THREE.Vector3(0.5, 0.5, -0.5),
106
- ambient: new THREE.Color(0.1, 0.1, 0.1),
107
- opacity: 0.75
108
- });
109
- this.vertexShader = textureVS;
110
- // three loop unrolling of ShaderMaterial only supports integer bounds,
111
- // see https://github.com/mrdoob/three.js/issues/28020
112
- this.fragmentShader = ShaderUtils.unrollLoops(textureFS, this.defines);
113
- }
114
-
115
- /**
116
- * Set new textures and new position/orientation of the camera set.
117
- * @param {THREE.Texture} textures - Array of [THREE.Texture]{@link https://threejs.org/docs/#api/en/textures/Texture}.
118
- * @param {Object} feature - New position / orientation of the set of cameras
119
- * @param {THREE.Vector3} feature.position - New position.
120
- * @param {THREE.Quaternion} feature.quaternion - New orientation.
121
- * @param {Array} camerasNames - camera names of panoramic feature
122
- */
123
- setTextures(textures, feature, camerasNames) {
124
- if (!textures) {
125
- return;
126
- }
127
- this.group.position.copy(feature.position);
128
- this.group.quaternion.copy(feature.quaternion);
129
- for (let i = 0; i < textures.length && i < this.defines.ORIENTED_IMAGES_COUNT; ++i) {
130
- this.uniforms.projectiveTexture.value[i].dispose();
131
- this.uniforms.projectiveTexture.value[i] = textures[i];
132
-
133
- // check camera changes
134
- if (camerasNames) {
135
- const currentCamera = this.group.children[i];
136
- if (camerasNames[i] != currentCamera.name) {
137
- const camera = this.cameras.find(cam => cam.name === camerasNames[i]);
138
- this.uniforms.mask.value[i] = camera.maskTexture || noMask;
139
- this.uniforms.mask.value[i].needsUpdate = true;
140
- this.uniforms.projectiveTextureDistortion.value[i] = camera.distortion;
141
- this.group.children[i] = camera;
142
- camera.parent = this.group;
143
- }
144
- }
145
- this.group.children[i].needsUpdate = true;
146
- }
147
- this.group.updateMatrixWorld(true); // update the matrixWorldInverse of the cameras
148
- }
149
-
150
- /**
151
- * Udate the uniforms using the current value of camera.matrixWorld.
152
- * Need to be called when the camera of the scene has changed.
153
- * @param {THREE.Camera} viewCamera - Camera of the scene.
154
- */
155
- updateUniforms(viewCamera) {
156
- for (let i = 0; i < this.group.children.length; ++i) {
157
- const camera = this.group.children[i];
158
- if (camera.needsUpdate) {
159
- camera.textureMatrixWorldInverse.multiplyMatrices(ndcToTextureMatrix, camera.projectionMatrix);
160
- camera.textureMatrixWorldInverse.multiply(camera.matrixWorldInverse);
161
- camera.needsUpdate = false;
162
- }
163
- this.uniforms.projectiveTextureMatrix.value[i].multiplyMatrices(camera.textureMatrixWorldInverse, viewCamera.matrixWorld);
164
- }
165
- }
166
- }
167
- export default OrientedImageMaterial;