itowns 2.44.3-next.9 → 2.45.1-next.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 (214) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +20 -6
  3. package/examples/config.json +1 -0
  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/jsm/.eslintrc.cjs +0 -38
  43. package/lib/Controls/FirstPersonControls.js +0 -308
  44. package/lib/Controls/FlyControls.js +0 -175
  45. package/lib/Controls/GlobeControls.js +0 -1162
  46. package/lib/Controls/PlanarControls.js +0 -1025
  47. package/lib/Controls/StateControl.js +0 -429
  48. package/lib/Controls/StreetControls.js +0 -392
  49. package/lib/Converter/Feature2Mesh.js +0 -615
  50. package/lib/Converter/Feature2Texture.js +0 -170
  51. package/lib/Converter/convertToTile.js +0 -75
  52. package/lib/Converter/textureConverter.js +0 -44
  53. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  54. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  55. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  56. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  57. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  58. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  59. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  60. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  61. package/lib/Core/AnimationPlayer.js +0 -142
  62. package/lib/Core/CopcNode.js +0 -174
  63. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  64. package/lib/Core/EntwinePointTileNode.js +0 -126
  65. package/lib/Core/Feature.js +0 -490
  66. package/lib/Core/Geographic/CoordStars.js +0 -80
  67. package/lib/Core/Geographic/Coordinates.js +0 -320
  68. package/lib/Core/Geographic/Crs.js +0 -175
  69. package/lib/Core/Geographic/Extent.js +0 -534
  70. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  71. package/lib/Core/Label.js +0 -222
  72. package/lib/Core/MainLoop.js +0 -211
  73. package/lib/Core/Math/Ellipsoid.js +0 -144
  74. package/lib/Core/Picking.js +0 -255
  75. package/lib/Core/PointCloudNode.js +0 -42
  76. package/lib/Core/Potree2Node.js +0 -206
  77. package/lib/Core/Potree2PointAttributes.js +0 -139
  78. package/lib/Core/PotreeNode.js +0 -101
  79. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  80. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  81. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  82. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  83. package/lib/Core/Prefab/GlobeView.js +0 -161
  84. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  85. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  86. package/lib/Core/Prefab/PlanarView.js +0 -62
  87. package/lib/Core/Prefab/TileBuilder.js +0 -80
  88. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  89. package/lib/Core/Scheduler/Cache.js +0 -256
  90. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  91. package/lib/Core/Scheduler/Scheduler.js +0 -294
  92. package/lib/Core/Style.js +0 -1121
  93. package/lib/Core/System/Capabilities.js +0 -63
  94. package/lib/Core/Tile/Tile.js +0 -219
  95. package/lib/Core/Tile/TileGrid.js +0 -46
  96. package/lib/Core/TileGeometry.js +0 -40
  97. package/lib/Core/TileMesh.js +0 -109
  98. package/lib/Core/View.js +0 -1109
  99. package/lib/Layer/C3DTilesLayer.js +0 -456
  100. package/lib/Layer/ColorLayer.js +0 -128
  101. package/lib/Layer/CopcLayer.js +0 -58
  102. package/lib/Layer/ElevationLayer.js +0 -107
  103. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  104. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  105. package/lib/Layer/GeoidLayer.js +0 -80
  106. package/lib/Layer/GeometryLayer.js +0 -202
  107. package/lib/Layer/InfoLayer.js +0 -64
  108. package/lib/Layer/LabelLayer.js +0 -456
  109. package/lib/Layer/Layer.js +0 -304
  110. package/lib/Layer/LayerUpdateState.js +0 -89
  111. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  112. package/lib/Layer/OGC3DTilesLayer.js +0 -412
  113. package/lib/Layer/OrientedImageLayer.js +0 -222
  114. package/lib/Layer/PointCloudLayer.js +0 -359
  115. package/lib/Layer/Potree2Layer.js +0 -164
  116. package/lib/Layer/PotreeLayer.js +0 -65
  117. package/lib/Layer/RasterLayer.js +0 -27
  118. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  119. package/lib/Layer/TiledGeometryLayer.js +0 -403
  120. package/lib/Loader/LASLoader.js +0 -193
  121. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  122. package/lib/Loader/Potree2Loader.js +0 -207
  123. package/lib/Main.js +0 -115
  124. package/lib/MainBundle.js +0 -4
  125. package/lib/Parser/B3dmParser.js +0 -174
  126. package/lib/Parser/CameraCalibrationParser.js +0 -94
  127. package/lib/Parser/GDFParser.js +0 -72
  128. package/lib/Parser/GTXParser.js +0 -75
  129. package/lib/Parser/GeoJsonParser.js +0 -212
  130. package/lib/Parser/GpxParser.js +0 -25
  131. package/lib/Parser/ISGParser.js +0 -71
  132. package/lib/Parser/KMLParser.js +0 -25
  133. package/lib/Parser/LASParser.js +0 -137
  134. package/lib/Parser/MapBoxUrlParser.js +0 -83
  135. package/lib/Parser/PntsParser.js +0 -131
  136. package/lib/Parser/Potree2BinParser.js +0 -92
  137. package/lib/Parser/PotreeBinParser.js +0 -106
  138. package/lib/Parser/PotreeCinParser.js +0 -29
  139. package/lib/Parser/ShapefileParser.js +0 -78
  140. package/lib/Parser/VectorTileParser.js +0 -202
  141. package/lib/Parser/XbilParser.js +0 -119
  142. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  143. package/lib/Parser/iGLTFLoader.js +0 -168
  144. package/lib/Process/3dTilesProcessing.js +0 -304
  145. package/lib/Process/FeatureProcessing.js +0 -76
  146. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  147. package/lib/Process/ObjectRemovalHelper.js +0 -97
  148. package/lib/Process/handlerNodeError.js +0 -23
  149. package/lib/Provider/3dTilesProvider.js +0 -149
  150. package/lib/Provider/DataSourceProvider.js +0 -8
  151. package/lib/Provider/Fetcher.js +0 -229
  152. package/lib/Provider/PointCloudProvider.js +0 -45
  153. package/lib/Provider/TileProvider.js +0 -16
  154. package/lib/Provider/URLBuilder.js +0 -116
  155. package/lib/Renderer/Camera.js +0 -281
  156. package/lib/Renderer/Color.js +0 -56
  157. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  158. package/lib/Renderer/CommonMaterial.js +0 -31
  159. package/lib/Renderer/Label2DRenderer.js +0 -190
  160. package/lib/Renderer/LayeredMaterial.js +0 -243
  161. package/lib/Renderer/OBB.js +0 -153
  162. package/lib/Renderer/OrientedImageCamera.js +0 -118
  163. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  164. package/lib/Renderer/PointsMaterial.js +0 -485
  165. package/lib/Renderer/RasterTile.js +0 -209
  166. package/lib/Renderer/RenderMode.js +0 -31
  167. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  168. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  169. package/lib/Renderer/SphereHelper.js +0 -23
  170. package/lib/Renderer/WebXR.js +0 -51
  171. package/lib/Renderer/c3DEngine.js +0 -214
  172. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  173. package/lib/Source/C3DTilesIonSource.js +0 -54
  174. package/lib/Source/C3DTilesSource.js +0 -30
  175. package/lib/Source/CopcSource.js +0 -115
  176. package/lib/Source/EntwinePointTileSource.js +0 -62
  177. package/lib/Source/FileSource.js +0 -189
  178. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  179. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  180. package/lib/Source/OGC3DTilesSource.js +0 -21
  181. package/lib/Source/OrientedImageSource.js +0 -59
  182. package/lib/Source/Potree2Source.js +0 -167
  183. package/lib/Source/PotreeSource.js +0 -82
  184. package/lib/Source/Source.js +0 -223
  185. package/lib/Source/TMSSource.js +0 -145
  186. package/lib/Source/VectorTilesSource.js +0 -178
  187. package/lib/Source/WFSSource.js +0 -168
  188. package/lib/Source/WMSSource.js +0 -133
  189. package/lib/Source/WMTSSource.js +0 -86
  190. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  191. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  192. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  193. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  194. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  195. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  196. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  197. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  198. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  199. package/lib/Utils/CameraUtils.js +0 -555
  200. package/lib/Utils/DEMUtils.js +0 -350
  201. package/lib/Utils/FeaturesUtils.js +0 -156
  202. package/lib/Utils/Gradients.js +0 -16
  203. package/lib/Utils/OrientationUtils.js +0 -457
  204. package/lib/Utils/ThreeUtils.js +0 -115
  205. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  206. package/lib/Utils/gui/Main.js +0 -7
  207. package/lib/Utils/gui/Minimap.js +0 -154
  208. package/lib/Utils/gui/Navigation.js +0 -245
  209. package/lib/Utils/gui/Scale.js +0 -107
  210. package/lib/Utils/gui/Searchbar.js +0 -234
  211. package/lib/Utils/gui/Widget.js +0 -80
  212. package/lib/Utils/placeObjectOnGround.js +0 -137
  213. package/lib/Worker/LASLoaderWorker.js +0 -19
  214. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,412 +0,0 @@
1
- import * as THREE from 'three';
2
- import { TilesRenderer, GLTFStructuralMetadataExtension, GLTFMeshFeaturesExtension, GLTFCesiumRTCExtension, CesiumIonAuthPlugin, GoogleCloudAuthPlugin, ImplicitTilingPlugin } from '3d-tiles-renderer';
3
- import GeometryLayer from "./GeometryLayer.js";
4
- import iGLTFLoader from "../Parser/iGLTFLoader.js";
5
- import { DRACOLoader } from "../ThreeExtended/loaders/DRACOLoader.js";
6
- import { KTX2Loader } from "../ThreeExtended/loaders/KTX2Loader.js";
7
- import ReferLayerProperties from "./ReferencingLayerProperties.js";
8
- import PointsMaterial, { PNTS_MODE, PNTS_SHAPE, PNTS_SIZE_MODE, ClassificationScheme } from "../Renderer/PointsMaterial.js";
9
- const _raycaster = new THREE.Raycaster();
10
-
11
- // Internal instance of GLTFLoader, passed to 3d-tiles-renderer-js to support GLTF 1.0 and 2.0
12
- // Temporary exported to be used in deprecated B3dmParser
13
- export const itownsGLTFLoader = new iGLTFLoader();
14
- itownsGLTFLoader.register(() => new GLTFMeshFeaturesExtension());
15
- itownsGLTFLoader.register(() => new GLTFStructuralMetadataExtension());
16
- itownsGLTFLoader.register(() => new GLTFCesiumRTCExtension());
17
-
18
- // Instantiated by the first tileset. Used to share cache and download and parse queues between tilesets
19
- let lruCache = null;
20
- let downloadQueue = null;
21
- let parseQueue = null;
22
- export const OGC3DTILES_LAYER_EVENTS = {
23
- /**
24
- * Fired when a new root or child tile set is loaded
25
- * @event OGC3DTilesLayer#load-tile-set
26
- * @type {Object}
27
- * @property {Object} tileset - the tileset json parsed in an Object
28
- * @property {String} url - tileset url
29
- */
30
- LOAD_TILE_SET: 'load-tile-set',
31
- /**
32
- * Fired when a tile model is loaded
33
- * @event OGC3DTilesLayer#load-model
34
- * @type {Object}
35
- * @property {THREE.Group} scene - the model (tile content) parsed in a THREE.GROUP
36
- * @property {Object} tile - the tile metadata from the tileset
37
- */
38
- LOAD_MODEL: 'load-model',
39
- /**
40
- * Fired when a tile model is disposed
41
- * @event OGC3DTilesLayer#dispose-model
42
- * @type {Object}
43
- * @property {THREE.Group} scene - the model (tile content) that is disposed
44
- * @property {Object} tile - the tile metadata from the tileset
45
- */
46
- DISPOSE_MODEL: 'dispose-model',
47
- /**
48
- * Fired when a tiles visibility changes
49
- * @event OGC3DTilesLayer#tile-visibility-change
50
- * @type {Object}
51
- * @property {THREE.Group} scene - the model (tile content) parsed in a THREE.GROUP
52
- * @property {Object} tile - the tile metadata from the tileset
53
- * @property {boolean} visible - the tile visible state
54
- */
55
- TILE_VISIBILITY_CHANGE: 'tile-visibility-change',
56
- /**
57
- * Fired when a new batch of tiles start loading (can be fired multiple times, e.g. when the camera moves and new tiles
58
- * start loading)
59
- * @event OGC3DTilesLayer#tiles-load-start
60
- */
61
- TILES_LOAD_START: 'tiles-load-start',
62
- /**
63
- * Fired when all visible tiles are loaded (can be fired multiple times, e.g. when the camera moves and new tiles
64
- * are loaded)
65
- * @event OGC3DTilesLayer#tiles-load-end
66
- */
67
- TILES_LOAD_END: 'tiles-load-end'
68
- };
69
-
70
- /**
71
- * Enable loading 3D Tiles with [Draco](https://google.github.io/draco/) geometry extension.
72
- *
73
- * @param {String} path path to draco library folder containing the JS and WASM decoder libraries. They can be found in
74
- * [itowns examples](https://github.com/iTowns/itowns/tree/master/examples/libs/draco).
75
- * @param {Object} [config] optional configuration for Draco decoder (see threejs'
76
- * [setDecoderConfig](https://threejs.org/docs/index.html?q=draco#examples/en/loaders/DRACOLoader.setDecoderConfig) that
77
- * is called under the hood with this configuration for details.
78
- */
79
- export function enableDracoLoader(path, config) {
80
- if (!path) {
81
- throw new Error('Path to draco folder is mandatory');
82
- }
83
- const dracoLoader = new DRACOLoader();
84
- dracoLoader.setDecoderPath(path);
85
- if (config) {
86
- dracoLoader.setDecoderConfig(config);
87
- }
88
- itownsGLTFLoader.setDRACOLoader(dracoLoader);
89
- }
90
-
91
- /**
92
- * Enable loading 3D Tiles with [KTX2](https://www.khronos.org/ktx/) texture extension.
93
- *
94
- * @param {String} path path to ktx2 library folder containing the JS and WASM decoder libraries. They can be found in
95
- * [itowns examples](https://github.com/iTowns/itowns/tree/master/examples/libs/basis).
96
- * @param {THREE.WebGLRenderer} renderer the threejs renderer
97
- */
98
- export function enableKtx2Loader(path, renderer) {
99
- if (!path || !renderer) {
100
- throw new Error('Path to ktx2 folder and renderer are mandatory');
101
- }
102
- const ktx2Loader = new KTX2Loader();
103
- ktx2Loader.setTranscoderPath(path);
104
- ktx2Loader.detectSupport(renderer);
105
- itownsGLTFLoader.setKTX2Loader(ktx2Loader);
106
- }
107
- class OGC3DTilesLayer extends GeometryLayer {
108
- /**
109
- * Layer for [3D Tiles](https://www.ogc.org/standard/3dtiles/) datasets.
110
- *
111
- * Advanced configuration note: 3D Tiles rendering is delegated to 3DTilesRendererJS that exposes several
112
- * configuration options accessible through the tilesRenderer property of this class. see the
113
- * [3DTilesRendererJS doc](https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/README.md). Also note that
114
- * the cache is shared amongst 3D tiles layers and can be configured through tilesRenderer.lruCache (see the
115
- * [following documentation](https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/README.md#lrucache-1).
116
- *
117
- * @extends Layer
118
- *
119
- * @param {String} id - unique layer id.
120
- * @param {Object} config - layer specific configuration
121
- * @param {OGC3DTilesSource} config.source - data source configuration
122
- * @param {String} [config.pntsMode= PNTS_MODE.COLOR] Point cloud coloring mode (passed to {@link PointsMaterial}).
123
- * Only 'COLOR' or 'CLASSIFICATION' are possible. COLOR uses RGB colors of the points,
124
- * CLASSIFICATION uses a classification property of the batch table to color points.
125
- * @param {ClassificationScheme} [config.classificationScheme] {@link PointsMaterial} classification scheme
126
- * @param {String} [config.pntsShape= PNTS_SHAPE.CIRCLE] Point cloud point shape. Only 'CIRCLE' or 'SQUARE' are possible.
127
- * (passed to {@link PointsMaterial}).
128
- * @param {String} [config.pntsSizeMode= PNTS_SIZE_MODE.VALUE] {@link PointsMaterial} Point cloud size mode (passed to {@link PointsMaterial}).
129
- * Only 'VALUE' or 'ATTENUATED' are possible. VALUE use constant size, ATTENUATED compute size depending on distance
130
- * from point to camera.
131
- * @param {Number} [config.pntsMinAttenuatedSize=3] Minimum scale used by 'ATTENUATED' size mode.
132
- * @param {Number} [config.pntsMaxAttenuatedSize=10] Maximum scale used by 'ATTENUATED' size mode.
133
- */
134
- constructor(id, config) {
135
- super(id, new THREE.Group(), {
136
- source: config.source
137
- });
138
- this.isOGC3DTilesLayer = true;
139
- this._handlePointsMaterialConfig(config);
140
- this.tilesRenderer = new TilesRenderer(this.source.url);
141
- if (config.source.isOGC3DTilesIonSource) {
142
- this.tilesRenderer.registerPlugin(new CesiumIonAuthPlugin({
143
- apiToken: config.source.accessToken,
144
- assetId: config.source.assetId,
145
- autoRefreshToken: true
146
- }));
147
- } else if (config.source.isOGC3DTilesGoogleSource) {
148
- this.tilesRenderer.registerPlugin(new GoogleCloudAuthPlugin({
149
- apiToken: config.source.key,
150
- autoRefreshToken: true
151
- }));
152
- }
153
- this.tilesRenderer.registerPlugin(new ImplicitTilingPlugin());
154
- this.tilesRenderer.manager.addHandler(/\.gltf$/, itownsGLTFLoader);
155
- this._setupCacheAndQueues();
156
- this._setupEvents();
157
- this.object3d.add(this.tilesRenderer.group);
158
-
159
- // Add an initialization step that is resolved when the root tileset is loaded (see this._setup below), meaning
160
- // that the layer will be marked ready when the tileset has been loaded.
161
- this._res = this.addInitializationStep();
162
-
163
- /**
164
- * @type {number}
165
- */
166
- this.sseThreshold = this.tilesRenderer.errorTarget;
167
- Object.defineProperty(this, 'sseThreshold', {
168
- get() {
169
- return this.tilesRenderer.errorTarget;
170
- },
171
- set(value) {
172
- this.tilesRenderer.errorTarget = value;
173
- }
174
- });
175
- if (config.sseThreshold) {
176
- this.sseThreshold = config.sseThreshold;
177
- }
178
- }
179
-
180
- /**
181
- * Store points material config so they can be used later to substitute points tiles material by our own PointsMaterial
182
- * These properties should eventually be managed through the Style API (see https://github.com/iTowns/itowns/issues/2336)
183
- * @param {Object} config - points material configuration as passed to the layer constructor.
184
- * @private
185
- */
186
- _handlePointsMaterialConfig(config) {
187
- this.pntsMode = config.pntsMode ?? PNTS_MODE.COLOR;
188
- this.pntsShape = config.pntsShape ?? PNTS_SHAPE.CIRCLE;
189
- this.classification = config.classification ?? ClassificationScheme.DEFAULT;
190
- this.pntsSizeMode = config.pntsSizeMode ?? PNTS_SIZE_MODE.VALUE;
191
- this.pntsMinAttenuatedSize = config.pntsMinAttenuatedSize || 3;
192
- this.pntsMaxAttenuatedSize = config.pntsMaxAttenuatedSize || 10;
193
- }
194
-
195
- /**
196
- * Sets the lruCache and download and parse queues so they are shared amongst all tilesets.
197
- * @private
198
- */
199
- _setupCacheAndQueues() {
200
- if (lruCache === null) {
201
- lruCache = this.tilesRenderer.lruCache;
202
- } else {
203
- this.tilesRenderer.lruCache = lruCache;
204
- }
205
- if (downloadQueue === null) {
206
- downloadQueue = this.tilesRenderer.downloadQueue;
207
- } else {
208
- this.tilesRenderer.downloadQueue = downloadQueue;
209
- }
210
- if (parseQueue === null) {
211
- parseQueue = this.tilesRenderer.parseQueue;
212
- } else {
213
- this.tilesRenderer.parseQueue = parseQueue;
214
- }
215
- }
216
-
217
- /**
218
- * Binds 3d-tiles-renderer events to this layer.
219
- * @private
220
- */
221
- _setupEvents() {
222
- for (const ev of Object.values(OGC3DTILES_LAYER_EVENTS)) {
223
- this.tilesRenderer.addEventListener(ev, e => {
224
- this.dispatchEvent(e);
225
- });
226
- }
227
- }
228
-
229
- /**
230
- * Setup 3D tiles renderer js TilesRenderer with the camera, binds events and start updating. Executed when the
231
- * layer has been added to the view.
232
- * @param {View} view - the view the layer has been added to.
233
- * @private
234
- */
235
- _setup(view) {
236
- this.tilesRenderer.setCamera(view.camera3D);
237
- this.tilesRenderer.setResolutionFromRenderer(view.camera3D, view.renderer);
238
- // Setup whenReady to be fullfiled when the root tileset has been loaded
239
- let rootTilesetLoaded = false;
240
- this.tilesRenderer.addEventListener('load-tile-set', () => {
241
- view.notifyChange(this);
242
- if (!rootTilesetLoaded) {
243
- rootTilesetLoaded = true;
244
- this._res();
245
- }
246
- });
247
- this.tilesRenderer.addEventListener('load-model', _ref => {
248
- let {
249
- scene
250
- } = _ref;
251
- scene.traverse(obj => {
252
- this._assignFinalMaterial(obj);
253
- this._assignFinalAttributes(obj);
254
- });
255
- view.notifyChange(this);
256
- });
257
- // Start loading tileset and tiles
258
- this.tilesRenderer.update();
259
- }
260
-
261
- /**
262
- * Replace materials from GLTFLoader by our own custom materials. Note that
263
- * the replaced materials are not compiled yet and will be disposed by the
264
- * GC.
265
- * @param {Object3D} model
266
- * @private
267
- */
268
- _assignFinalMaterial(model) {
269
- let material = model.material;
270
- if (model.isPoints) {
271
- const pointsMaterial = new PointsMaterial({
272
- mode: this.pntsMode,
273
- shape: this.pntsShape,
274
- classificationScheme: this.classification,
275
- sizeMode: this.pntsSizeMode,
276
- minAttenuatedSize: this.pntsMinAttenuatedSize,
277
- maxAttenuatedSize: this.pntsMaxAttenuatedSize
278
- });
279
- pointsMaterial.copy(material);
280
- material = pointsMaterial;
281
- }
282
- if (material) {
283
- ReferLayerProperties(material, this);
284
- }
285
- model.material = material;
286
- }
287
-
288
- /**
289
- * @param {Object3D} model
290
- * @private
291
- */
292
- _assignFinalAttributes(model) {
293
- const geometry = model.geometry;
294
- const batchTable = model.batchTable;
295
-
296
- // Setup classification bufferAttribute
297
- if (model.isPoints) {
298
- const classificationData = batchTable?.getPropertyArray('Classification');
299
- if (classificationData) {
300
- geometry.setAttribute('classification', new THREE.BufferAttribute(classificationData, 1));
301
- }
302
- }
303
- }
304
- preUpdate(context) {
305
- this.scale = context.camera._preSSE;
306
- this.tilesRenderer.update();
307
- return null; // don't return any element because 3d-tiles-renderer already updates them
308
- }
309
- update() {
310
- // empty, elements are updated by 3d-tiles-renderer
311
- }
312
-
313
- /**
314
- * Deletes the layer and frees associated memory
315
- */
316
- delete() {
317
- this.tilesRenderer.dispose();
318
- }
319
-
320
- /**
321
- * Get the attributes for the closest intersection from a list of
322
- * intersects.
323
- * @param {Array} intersects - An array containing all
324
- * objects picked under mouse coordinates computed with view.pickObjectsAt(..).
325
- * @returns {Object | null} - An object containing
326
- */
327
- getC3DTileFeatureFromIntersectsArray(intersects) {
328
- if (!intersects.length) {
329
- return null;
330
- }
331
- const {
332
- face,
333
- index,
334
- object
335
- } = intersects[0];
336
-
337
- /** @type{number|null} */
338
- let batchId;
339
- if (object.isPoints && index) {
340
- batchId = object.geometry.getAttribute('_BATCHID')?.getX(index) ?? index;
341
- } else if (object.isMesh && face) {
342
- batchId = object.geometry.getAttribute('_BATCHID')?.getX(face.a);
343
- }
344
- if (batchId === undefined) {
345
- return null;
346
- }
347
- let tileObject = object;
348
- while (!tileObject.batchTable) {
349
- tileObject = tileObject.parent;
350
- }
351
- return tileObject.batchTable.getDataFromId(batchId);
352
- }
353
-
354
- /**
355
- * Get all 3D objects (mesh and points primitives) as intersects at the
356
- * given non-normalized screen coordinates.
357
- * @param {View} view - The view instance.
358
- * @param {THREE.Vector2} coords - The coordinates to pick in the view. It
359
- * should have at least `x` and `y` properties.
360
- * @param {number} radius - Radius of the picking circle.
361
- * @param {Array} [target=[]] - Target array to push results too
362
- * @returns {Array} Array containing all target objects picked under the
363
- * specified coordinates.
364
- */
365
- pickObjectsAt(view, coords) {
366
- let target = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
367
- const camera = view.camera.camera3D;
368
- _raycaster.setFromCamera(view.viewToNormalizedCoords(coords), camera);
369
- _raycaster.near = camera.near;
370
- _raycaster.far = camera.far;
371
- _raycaster.firstHitOnly = true;
372
- const picked = _raycaster.intersectObject(this.tilesRenderer.group, true);
373
- // Store the layer of the picked object to conform to the interface of what's returned by Picking.js (used for
374
- // other GeometryLayers
375
- picked.forEach(p => {
376
- p.layer = this;
377
- });
378
- target.push(...picked);
379
- return target;
380
- }
381
-
382
- // eslint-disable-next-line no-unused-vars
383
- attach() {
384
- console.warn('[OGC3DTilesLayer]: Attaching / detaching layers is not yet implemented for OGC3DTilesLayer.');
385
- }
386
-
387
- // eslint-disable-next-line no-unused-vars
388
- detach() {
389
- console.warn('[OGC3DTilesLayer]: Attaching / detaching layers is not yet implemented for OGC3DTilesLayer.');
390
- return true;
391
- }
392
-
393
- // eslint-disable-next-line no-unused-vars
394
- getObjectToUpdateForAttachedLayers() {
395
- return null;
396
- }
397
-
398
- /**
399
- * Executes a callback for each tile of this layer tileset.
400
- *
401
- * @param {Function} callback The callback to execute for each tile. Has the following two parameters:
402
- * 1. tile (Object) - the JSON tile
403
- * 2. scene (THREE.Object3D | null) - The tile content. Contains a `batchTable` property. Can be null if the tile
404
- * has not yet been loaded.
405
- */
406
- forEachTile(callback) {
407
- this.tilesRenderer.traverse(tile => {
408
- callback(tile, tile.cached.scene);
409
- });
410
- }
411
- }
412
- export default OGC3DTilesLayer;
@@ -1,222 +0,0 @@
1
- import * as THREE from 'three';
2
- import GeometryLayer from "./GeometryLayer.js";
3
- import OrientedImageMaterial from "../Renderer/OrientedImageMaterial.js";
4
- import GeoJsonParser from "../Parser/GeoJsonParser.js";
5
- import CameraCalibrationParser from "../Parser/CameraCalibrationParser.js";
6
- import Coordinates from "../Core/Geographic/Coordinates.js";
7
- import OrientationUtils from "../Utils/OrientationUtils.js";
8
- const coord = new Coordinates('EPSG:4978', 0, 0, 0);
9
- const commandCancellation = cmd => cmd.requester.id !== cmd.layer.currentPano.id;
10
- function updatePano(context, camera, layer) {
11
- const newPano = layer.mostNearPano(camera.position);
12
- // detection of oriented image change
13
- const currentId = layer.currentPano ? layer.currentPano.id : undefined;
14
- if (newPano && currentId != newPano.id) {
15
- layer.currentPano = newPano;
16
-
17
- // callback to indicate current pano has changed
18
- layer.onPanoChanged({
19
- previousPanoPosition: layer.getPreviousPano() ? layer.getPreviousPano().position : undefined,
20
- currentPanoPosition: layer.getCurrentPano().position,
21
- nextPanoPosition: layer.getNextPano().position
22
- });
23
- // prepare informations about the needed textures
24
- const panoCameras = newPano.geometries[0].properties.idSensors;
25
- const imagesInfo = layer.cameras.map(cam => ({
26
- cameraId: cam.name,
27
- panoId: newPano.id,
28
- as: () => {}
29
- })).filter(info => !panoCameras || panoCameras.includes(info.cameraId));
30
- const command = {
31
- layer,
32
- // put informations about image URL as extent to be used by generic DataSourceProvider, OrientedImageSource will use that.
33
- extentsSource: imagesInfo,
34
- view: context.view,
35
- requester: newPano,
36
- earlyDropFunction: commandCancellation
37
- };
38
-
39
- // async call to scheduler to get textures
40
- context.scheduler.execute(command).then(textures => {
41
- if (newPano.id === layer.currentPano.id) {
42
- layer.material.setTextures(textures, newPano, layer.getCamerasNameFromFeature(newPano));
43
- layer.material.updateUniforms(context.camera.camera3D);
44
- context.view.notifyChange(layer, true);
45
- }
46
- }, () => {});
47
- }
48
- }
49
- function updateBackground(layer) {
50
- if (layer.background && layer.currentPano) {
51
- layer.background.position.copy(layer.currentPano.position);
52
- layer.background.updateMatrixWorld();
53
- layer.background.material = layer.material || layer.background.material;
54
- }
55
- }
56
- function createBackground(radius) {
57
- if (!radius || radius <= 0) {
58
- return undefined;
59
- }
60
- const geometry = new THREE.SphereGeometry(radius, 32, 32);
61
- const material = new THREE.MeshPhongMaterial({
62
- color: 0x7777ff,
63
- side: THREE.DoubleSide,
64
- transparent: true,
65
- opacity: 0.5,
66
- wireframe: true
67
- });
68
- const sphere = new THREE.Mesh(geometry, material);
69
- sphere.visible = true;
70
- sphere.name = 'OrientedImageBackground';
71
- return sphere;
72
- }
73
-
74
- /**
75
- * OrientedImageLayer loads oriented images, and project these textures on the scene.
76
- * It is design to create an immersive view. </br>
77
- * It loads a set of panoramic position and orientation,
78
- * a set of camera calibration file (it's the same set of camera for each panoramic),
79
- * and a set of texture (each image for each camera for each panoramic), all organised in an {@link OrientedImageSource}. </br>
80
- * It creates an {@link OrientedImageMaterial} used to do projective texture mapping on the scene.
81
- * @extends GeometryLayer
82
- */
83
- class OrientedImageLayer extends GeometryLayer {
84
- /**
85
- * @param { string } id - The id of the layer, a unique name.
86
- * @param { Object } config - configuration of the layer
87
- * @param { number } config.backgroundDistance - Radius in meter of the sphere used as a background
88
- * @param { function } config.onPanoChanged - callback fired when current panoramic changes
89
- * @param { string } config.crs - crs projection of the view
90
- * @param { string } config.orientation - Json object, using GeoJSon format to represent points,
91
- * it's a set of panoramic position and orientation.
92
- * @param { string } config.calibrations - Json object, representing a set of camera.
93
- * see {@link CameraCalibrationParser}
94
- * @param { OrientedImageSource } config.source - Source used to build url of texture for each oriented image,
95
- * a tecture is need for each camera, for each panoramic.
96
- */
97
- constructor(id) {
98
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
99
- /* istanbul ignore next */
100
- if (config.projection) {
101
- console.warn('OrientedImageLayer projection parameter is deprecated, use crs instead.');
102
- config.crs = config.crs || config.projection;
103
- }
104
- super(id, new THREE.Group(), config);
105
- this.isOrientedImageLayer = true;
106
- this.background = config.background || createBackground(config.backgroundDistance);
107
- if (this.background) {
108
- // Add layer id to easily identify the objects later on (e.g. to delete the geometries when deleting the layer)
109
- this.background.layer = this.background.layer ?? {};
110
- this.background.layer.id = this.background.layer.id ?? id;
111
- this.object3d.add(this.background);
112
- }
113
-
114
- // currentPano is the current point, means it's the closest from the camera
115
- this.currentPano = undefined;
116
-
117
- // store a callback to fire event when current panoramic change
118
- this.onPanoChanged = config.onPanoChanged || (() => {});
119
-
120
- // function to get cameras name from panoramic feature
121
- this.getCamerasNameFromFeature = config.getCamerasNameFromFeature || (() => {});
122
- const resolve = this.addInitializationStep();
123
- this.mergeFeatures = false;
124
- this.filteringExtent = false;
125
- this.accurate = true;
126
- const options = {
127
- out: this
128
- };
129
-
130
- // panos is an array of feature point, representing many panoramics.
131
- // for each point, there is a position and a quaternion attribute.
132
- this.source.whenReady.then(metadata => GeoJsonParser.parse(config.orientation || metadata.orientation, options).then(orientation => {
133
- this.panos = orientation.features;
134
-
135
- // the crs input is parsed in geojson parser
136
- // and returned in options.in
137
- const crsIn = options.in.crs;
138
- const crsOut = config.crs;
139
- const crs2crs = OrientationUtils.quaternionFromCRSToCRS(crsIn, crsOut);
140
- const quat = new THREE.Quaternion();
141
-
142
- // add position and quaternion attributes from point feature
143
- let i = 0;
144
- for (const pano of this.panos) {
145
- // set position
146
- coord.crs = pano.crs;
147
- coord.setFromArray(pano.vertices).applyMatrix4(orientation.matrix);
148
- pano.position = coord.toVector3();
149
-
150
- // set quaternion
151
- crs2crs(coord, quat);
152
- pano.quaternion = OrientationUtils.quaternionFromAttitude(pano.geometries[0].properties).premultiply(quat);
153
- pano.id = pano.geometries[0].properties.id;
154
- pano.index = i++;
155
- }
156
- }).then(() => {
157
- // array of cameras, represent the projective texture configuration for each panoramic.
158
- CameraCalibrationParser.parse(config.calibration || metadata.calibration, config).then(cameras => {
159
- this.cameras = cameras;
160
- // create the material
161
- this.material = new OrientedImageMaterial(this.cameras, config);
162
- resolve();
163
- });
164
- }));
165
- }
166
-
167
- // eslint-disable-next-line
168
- update() {}
169
- set boostLight(value) {
170
- this.material.uniforms.boostLight.value = value;
171
- }
172
- get boostLight() {
173
- return this.material.uniforms.boostLight.value;
174
- }
175
- preUpdate(context) {
176
- updatePano(context, context.camera.camera3D, this);
177
- this.material.updateUniforms(context.camera.camera3D);
178
- updateBackground(this);
179
- }
180
- getNextPano() {
181
- const index = (this.currentPano.index + 1) % this.panos.length;
182
- return this.panos[index];
183
- }
184
- getCurrentPano() {
185
- return this.currentPano;
186
- }
187
- getPreviousPano() {
188
- const index = (this.currentPano.index - 1) % this.panos.length;
189
- return this.panos[index];
190
- }
191
-
192
- /**
193
- * Delete background, but doesn't delete OrientedImageLayer.material. For the moment, this material visibility is set to false.
194
- * You need to replace OrientedImageLayer.material applied on each object, if you want to continue displaying them.
195
- * This issue (see #1018 {@link https://github.com/iTowns/itowns/issues/1018}) will be fixed when OrientedImageLayer will be a ColorLayer.
196
- * @param {boolean} [clearCache=false] Whether to clear the layer cache or not
197
- */
198
- delete(clearCache) {
199
- if (this.background) {
200
- // only delete geometries if it has some
201
- super.delete();
202
- }
203
- if (clearCache) {
204
- this.cache.clear();
205
- }
206
- this.material.visible = false;
207
- console.warn('You need to replace OrientedImageLayer.material applied on each object. This issue will be fixed when OrientedImageLayer will be a ColorLayer. the material visibility is set to false. To follow issue see https://github.com/iTowns/itowns/issues/1018');
208
- }
209
- mostNearPano(position) {
210
- let minDistance = Infinity;
211
- let nearPano;
212
- for (const pano of this.panos) {
213
- const distance = position.distanceTo(pano.position);
214
- if (distance < minDistance) {
215
- minDistance = distance;
216
- nearPano = pano;
217
- }
218
- }
219
- return nearPano;
220
- }
221
- }
222
- export default OrientedImageLayer;