itowns 2.44.3-next.40 → 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 (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,151 +0,0 @@
1
- import * as THREE from 'three';
2
- import * as CRS from "../Core/Geographic/Crs.js";
3
- import { TileGeometry } from "../Core/TileGeometry.js";
4
- import { GlobeTileBuilder } from "../Core/Prefab/Globe/GlobeTileBuilder.js";
5
- import Coordinates from "../Core/Geographic/Coordinates.js";
6
-
7
- // get oriented bounding box of tile
8
- const builder = new GlobeTileBuilder({
9
- uvCount: 1
10
- });
11
- const size = new THREE.Vector3();
12
- const dimension = new THREE.Vector2();
13
- const center = new THREE.Vector3();
14
- const coord = new Coordinates('EPSG:4326', 0, 0, 0);
15
- let obb;
16
-
17
- // it could be considered to remove THREE.Object3D extend.
18
- /**
19
- * Oriented bounding box
20
- * @extends THREE.Object3D
21
- */
22
- class OBB extends THREE.Object3D {
23
- /**
24
- * @param {THREE.Vector3} min representing the lower (x, y, z) boundary of the box. Default is ( + Infinity, + Infinity, + Infinity ).
25
- * @param {THREE.Vector3} max representing the lower upper (x, y, z) boundary of the box. Default is ( - Infinity, - Infinity, - Infinity ).
26
- */
27
- constructor() {
28
- let min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector3(+Infinity, +Infinity, +Infinity);
29
- let max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector3(-Infinity, -Infinity, -Infinity);
30
- super();
31
- this.box3D = new THREE.Box3(min.clone(), max.clone());
32
- this.natBox = this.box3D.clone();
33
- this.z = {
34
- min: 0,
35
- max: 0,
36
- scale: 1.0
37
- };
38
- }
39
-
40
- /**
41
- * Creates a new instance of the object with same properties than original.
42
- *
43
- * @return {OBB} Copy of this object.
44
- */
45
- clone() {
46
- return new OBB().copy(this);
47
- }
48
-
49
- /**
50
- * Copy the property of OBB
51
- *
52
- * @param {OBB} cOBB OBB to copy
53
- * @return {OBB} the copy
54
- */
55
- copy(cOBB) {
56
- super.copy(cOBB);
57
- this.box3D.copy(cOBB.box3D);
58
- this.natBox.copy(cOBB.natBox);
59
- this.z.min = cOBB.z.min;
60
- this.z.max = cOBB.z.max;
61
- this.z.scale = cOBB.z.scale;
62
- return this;
63
- }
64
-
65
- /**
66
- * Update z min, z max and z scale of oriented bounding box
67
- *
68
- * @param {Object} [elevation={}]
69
- * @param {number} [elevation.min] The minimum of oriented bounding box
70
- * @param {number} [elevation.max] The maximum of oriented bounding box
71
- * @param {number} [elevation.scale] The scale of oriented bounding box Z axis
72
- * @param {number} [elevation.geoidHeight] The geoid height added to ellipsoid.
73
- */
74
- updateZ() {
75
- let elevation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
76
- this.z.min = elevation.min ?? this.z.min;
77
- this.z.max = elevation.max ?? this.z.max;
78
- this.z.scale = elevation.scale > 0 ? elevation.scale : this.z.scale;
79
- this.z.delta = Math.abs(this.z.max - this.z.min) * this.z.scale;
80
- const geoidHeight = elevation.geoidHeight || 0;
81
- this.box3D.min.z = this.natBox.min.z + this.z.min * this.z.scale + geoidHeight;
82
- this.box3D.max.z = this.natBox.max.z + this.z.max * this.z.scale + geoidHeight;
83
- }
84
-
85
- /**
86
- * Determines if the sphere is above the XY space of the box
87
- *
88
- * @param {Sphere} sphere The sphere
89
- * @return {boolean} True if sphere is above the XY space of the box, False otherwise.
90
- */
91
- isSphereAboveXYBox(sphere) {
92
- const localSpherePosition = this.worldToLocal(sphere.center);
93
- // get obb closest point to sphere center by clamping
94
- const x = Math.max(this.box3D.min.x, Math.min(localSpherePosition.x, this.box3D.max.x));
95
- const y = Math.max(this.box3D.min.y, Math.min(localSpherePosition.y, this.box3D.max.y));
96
-
97
- // this is the same as isPointInsideSphere.position
98
- const distance = Math.sqrt((x - localSpherePosition.x) * (x - localSpherePosition.x) + (y - localSpherePosition.y) * (y - localSpherePosition.y));
99
- return distance < sphere.radius;
100
- }
101
-
102
- /**
103
- * Compute OBB from extent.
104
- * The OBB resulted can be only in the system 'EPSG:3946'.
105
- *
106
- * @param {Extent} extent The extent (with crs 'EPSG:4326') to compute oriented bounding box
107
- * @param {number} minHeight The minimum height of OBB
108
- * @param {number} maxHeight The maximum height of OBB
109
- * @return {OBB} return this object
110
- */
111
- setFromExtent(extent) {
112
- let minHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extent.min || 0;
113
- let maxHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extent.max || 0;
114
- if (extent.crs == 'EPSG:4326') {
115
- const {
116
- shareableExtent,
117
- quaternion,
118
- position
119
- } = builder.computeShareableExtent(extent);
120
- // Compute the minimum count of segment to build tile
121
- const segments = Math.max(Math.floor(shareableExtent.planarDimensions(dimension).x / 90 + 1), 2);
122
- const geometry = new TileGeometry(builder, {
123
- extent: shareableExtent,
124
- level: 0,
125
- segments,
126
- disableSkirt: true
127
- });
128
- obb.box3D.copy(geometry.boundingBox);
129
- obb.natBox.copy(geometry.boundingBox);
130
- this.copy(obb);
131
- this.updateZ({
132
- min: minHeight,
133
- max: maxHeight
134
- });
135
- this.position.copy(position);
136
- this.quaternion.copy(quaternion);
137
- this.updateMatrixWorld(true);
138
- } else if (CRS.isMetricUnit(extent.crs)) {
139
- extent.center(coord).toVector3(this.position);
140
- extent.planarDimensions(dimension);
141
- size.set(dimension.x, dimension.y, Math.abs(maxHeight - minHeight));
142
- this.box3D.setFromCenterAndSize(center, size);
143
- this.updateMatrixWorld(true);
144
- } else {
145
- throw new Error('Unsupported extent crs');
146
- }
147
- return this;
148
- }
149
- }
150
- obb = new OBB();
151
- 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;