itowns 2.44.3-next.8 → 2.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -615
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -534
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/Tile/Tile.js +0 -219
  100. package/lib/Core/Tile/TileGrid.js +0 -46
  101. package/lib/Core/TileGeometry.js +0 -40
  102. package/lib/Core/TileMesh.js +0 -109
  103. package/lib/Core/View.js +0 -1109
  104. package/lib/Layer/C3DTilesLayer.js +0 -455
  105. package/lib/Layer/ColorLayer.js +0 -128
  106. package/lib/Layer/CopcLayer.js +0 -58
  107. package/lib/Layer/ElevationLayer.js +0 -107
  108. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  109. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  110. package/lib/Layer/GeoidLayer.js +0 -80
  111. package/lib/Layer/GeometryLayer.js +0 -202
  112. package/lib/Layer/InfoLayer.js +0 -64
  113. package/lib/Layer/LabelLayer.js +0 -456
  114. package/lib/Layer/Layer.js +0 -304
  115. package/lib/Layer/LayerUpdateState.js +0 -89
  116. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  117. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  118. package/lib/Layer/OrientedImageLayer.js +0 -222
  119. package/lib/Layer/PointCloudLayer.js +0 -359
  120. package/lib/Layer/Potree2Layer.js +0 -164
  121. package/lib/Layer/PotreeLayer.js +0 -65
  122. package/lib/Layer/RasterLayer.js +0 -27
  123. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  124. package/lib/Layer/TiledGeometryLayer.js +0 -403
  125. package/lib/Loader/LASLoader.js +0 -193
  126. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  127. package/lib/Loader/Potree2Loader.js +0 -207
  128. package/lib/Main.js +0 -115
  129. package/lib/MainBundle.js +0 -4
  130. package/lib/Parser/B3dmParser.js +0 -174
  131. package/lib/Parser/CameraCalibrationParser.js +0 -94
  132. package/lib/Parser/GDFParser.js +0 -72
  133. package/lib/Parser/GTXParser.js +0 -75
  134. package/lib/Parser/GeoJsonParser.js +0 -212
  135. package/lib/Parser/GpxParser.js +0 -25
  136. package/lib/Parser/ISGParser.js +0 -71
  137. package/lib/Parser/KMLParser.js +0 -25
  138. package/lib/Parser/LASParser.js +0 -137
  139. package/lib/Parser/MapBoxUrlParser.js +0 -83
  140. package/lib/Parser/PntsParser.js +0 -131
  141. package/lib/Parser/Potree2BinParser.js +0 -92
  142. package/lib/Parser/PotreeBinParser.js +0 -106
  143. package/lib/Parser/PotreeCinParser.js +0 -29
  144. package/lib/Parser/ShapefileParser.js +0 -78
  145. package/lib/Parser/VectorTileParser.js +0 -202
  146. package/lib/Parser/XbilParser.js +0 -119
  147. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  148. package/lib/Parser/iGLTFLoader.js +0 -168
  149. package/lib/Process/3dTilesProcessing.js +0 -304
  150. package/lib/Process/FeatureProcessing.js +0 -76
  151. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  152. package/lib/Process/ObjectRemovalHelper.js +0 -97
  153. package/lib/Process/handlerNodeError.js +0 -23
  154. package/lib/Provider/3dTilesProvider.js +0 -149
  155. package/lib/Provider/DataSourceProvider.js +0 -8
  156. package/lib/Provider/Fetcher.js +0 -229
  157. package/lib/Provider/PointCloudProvider.js +0 -45
  158. package/lib/Provider/TileProvider.js +0 -16
  159. package/lib/Provider/URLBuilder.js +0 -116
  160. package/lib/Renderer/Camera.js +0 -281
  161. package/lib/Renderer/Color.js +0 -56
  162. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  163. package/lib/Renderer/CommonMaterial.js +0 -31
  164. package/lib/Renderer/Label2DRenderer.js +0 -190
  165. package/lib/Renderer/LayeredMaterial.js +0 -243
  166. package/lib/Renderer/OBB.js +0 -153
  167. package/lib/Renderer/OrientedImageCamera.js +0 -118
  168. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  169. package/lib/Renderer/PointsMaterial.js +0 -485
  170. package/lib/Renderer/RasterTile.js +0 -209
  171. package/lib/Renderer/RenderMode.js +0 -31
  172. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  173. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  174. package/lib/Renderer/SphereHelper.js +0 -23
  175. package/lib/Renderer/WebXR.js +0 -51
  176. package/lib/Renderer/c3DEngine.js +0 -214
  177. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  178. package/lib/Source/C3DTilesIonSource.js +0 -54
  179. package/lib/Source/C3DTilesSource.js +0 -30
  180. package/lib/Source/CopcSource.js +0 -115
  181. package/lib/Source/EntwinePointTileSource.js +0 -62
  182. package/lib/Source/FileSource.js +0 -189
  183. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  184. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  185. package/lib/Source/OGC3DTilesSource.js +0 -21
  186. package/lib/Source/OrientedImageSource.js +0 -59
  187. package/lib/Source/Potree2Source.js +0 -167
  188. package/lib/Source/PotreeSource.js +0 -82
  189. package/lib/Source/Source.js +0 -223
  190. package/lib/Source/TMSSource.js +0 -145
  191. package/lib/Source/VectorTilesSource.js +0 -178
  192. package/lib/Source/WFSSource.js +0 -168
  193. package/lib/Source/WMSSource.js +0 -133
  194. package/lib/Source/WMTSSource.js +0 -86
  195. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  196. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  197. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  198. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  199. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  200. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  201. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  202. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  203. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  204. package/lib/Utils/CameraUtils.js +0 -555
  205. package/lib/Utils/DEMUtils.js +0 -350
  206. package/lib/Utils/FeaturesUtils.js +0 -156
  207. package/lib/Utils/Gradients.js +0 -16
  208. package/lib/Utils/OrientationUtils.js +0 -457
  209. package/lib/Utils/ThreeUtils.js +0 -115
  210. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  211. package/lib/Utils/gui/Main.js +0 -7
  212. package/lib/Utils/gui/Minimap.js +0 -154
  213. package/lib/Utils/gui/Navigation.js +0 -245
  214. package/lib/Utils/gui/Scale.js +0 -107
  215. package/lib/Utils/gui/Searchbar.js +0 -234
  216. package/lib/Utils/gui/Widget.js +0 -80
  217. package/lib/Utils/placeObjectOnGround.js +0 -137
  218. package/lib/Worker/LASLoaderWorker.js +0 -19
  219. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,455 +0,0 @@
1
- import * as THREE from 'three';
2
- import GeometryLayer from "./GeometryLayer.js";
3
- import { init3dTilesLayer, pre3dTilesUpdate, process3dTilesNode } from "../Process/3dTilesProcessing.js";
4
- import C3DTileset from "../Core/3DTiles/C3DTileset.js";
5
- import C3DTExtensions from "../Core/3DTiles/C3DTExtensions.js";
6
- import { PNTS_MODE, PNTS_SHAPE, PNTS_SIZE_MODE } from "../Renderer/PointsMaterial.js";
7
- // eslint-disable-next-line no-unused-vars
8
- import Style from "../Core/Style.js";
9
- import C3DTFeature from "../Core/3DTiles/C3DTFeature.js";
10
- import { optimizeGeometryGroups } from "../Utils/ThreeUtils.js";
11
- export const C3DTILES_LAYER_EVENTS = {
12
- /**
13
- * Fires when a tile content has been loaded
14
- * @event C3DTilesLayer#on-tile-content-loaded
15
- * @type {object}
16
- * @property {THREE.Object3D} tileContent - object3D of the tile
17
- */
18
- ON_TILE_CONTENT_LOADED: 'on-tile-content-loaded',
19
- /**
20
- * Fires when a tile is requested
21
- * @event C3DTilesLayer#on-tile-requested
22
- * @type {object}
23
- * @property {object} metadata - tile
24
- */
25
- ON_TILE_REQUESTED: 'on-tile-requested'
26
- };
27
- const update = process3dTilesNode();
28
-
29
- /**
30
- * Find tileId of object
31
- * @param {THREE.Object3D} object - object
32
- *
33
- * @returns {number} tileId
34
- */
35
- function findTileID(object) {
36
- let currentObject = object;
37
- let result = currentObject.tileId;
38
- while (isNaN(result) && currentObject.parent) {
39
- currentObject = currentObject.parent;
40
- result = currentObject.tileId;
41
- }
42
- return result;
43
- }
44
-
45
- /**
46
- * Check if object3d has feature
47
- * @param {THREE.Object3D} object3d - object3d to check
48
- *
49
- * @returns {boolean} - true if object3d has feature
50
- */
51
- function object3DHasFeature(object3d) {
52
- return object3d.geometry && object3d.geometry.attributes._BATCHID;
53
- }
54
- class C3DTilesLayer extends GeometryLayer {
55
- #fillColorMaterialsBuffer;
56
- /**
57
- * @deprecated Deprecated 3D Tiles layer. Use {@link OGC3DTilesLayer} instead.
58
- * @extends GeometryLayer
59
- *
60
- * @example
61
- * // Create a new 3d-tiles layer from a web server
62
- * const l3dt = new C3DTilesLayer('3dtiles', {
63
- * name: '3dtl',
64
- * source: new C3DTilesSource({
65
- * url: 'https://tileset.json'
66
- * })
67
- * }, view);
68
- * View.prototype.addLayer.call(view, l3dt);
69
- *
70
- * // Create a new 3d-tiles layer from a Cesium ion server
71
- * const l3dt = new C3DTilesLayer('3dtiles', {
72
- * name: '3dtl',
73
- * source: new C3DTilesIonSource({
74
- * accessToken: 'myAccessToken',
75
- assetId: 12
76
- * })
77
- * }, view);
78
- * View.prototype.addLayer.call(view, l3dt);
79
- *
80
- * @param {string} id - The id of the layer, that should be unique.
81
- * It is not mandatory, but an error will be emitted if this layer is
82
- * added a
83
- * {@link View} that already has a layer going by that id.
84
- * @param {object} config configuration, all elements in it
85
- * will be merged as is in the layer.
86
- * @param {C3TilesSource} config.source The source of 3d Tiles.
87
- *
88
- * name.
89
- * @param {Number} [config.sseThreshold=16] The [Screen Space Error](https://github.com/CesiumGS/3d-tiles/blob/main/specification/README.md#geometric-error)
90
- * threshold at which child nodes of the current node will be loaded and added to the scene.
91
- * @param {Number} [config.cleanupDelay=1000] The time (in ms) after which a tile content (and its children) are
92
- * removed from the scene.
93
- * @param {C3DTExtensions} [config.registeredExtensions] 3D Tiles extensions managers registered for this tileset.
94
- * @param {String} [config.pntsMode= PNTS_MODE.COLOR] {@link PointsMaterial} Point cloud coloring mode.
95
- * Only 'COLOR' or 'CLASSIFICATION' are possible. COLOR uses RGB colors of the points,
96
- * CLASSIFICATION uses a classification property of the batch table to color points.
97
- * @param {String} [config.pntsShape= PNTS_SHAPE.CIRCLE] Point cloud point shape. Only 'CIRCLE' or 'SQUARE' are possible.
98
- * @param {String} [config.pntsSizeMode= PNTS_SIZE_MODE.VALUE] {@link PointsMaterial} Point cloud size mode. Only 'VALUE' or 'ATTENUATED' are possible. VALUE use constant size, ATTENUATED compute size depending on distance from point to camera.
99
- * @param {Number} [config.pntsMinAttenuatedSize=3] Minimum scale used by 'ATTENUATED' size mode
100
- * @param {Number} [config.pntsMaxAttenuatedSize=10] Maximum scale used by 'ATTENUATED' size mode
101
- * @param {Style} [config.style=null] - style used for this layer
102
- * @param {View} view The view
103
- */
104
- constructor(id, config, view) {
105
- super(id, new THREE.Group(), {
106
- source: config.source
107
- });
108
- this.isC3DTilesLayer = true;
109
- this.sseThreshold = config.sseThreshold || 16;
110
- this.cleanupDelay = config.cleanupDelay || 1000;
111
- this.protocol = '3d-tiles';
112
- this.name = config.name;
113
- this.registeredExtensions = config.registeredExtensions || new C3DTExtensions();
114
- this.pntsMode = PNTS_MODE.COLOR;
115
- this.pntsShape = PNTS_SHAPE.CIRCLE;
116
- this.classification = config.classification;
117
- this.pntsSizeMode = PNTS_SIZE_MODE.VALUE;
118
- this.pntsMinAttenuatedSize = config.pntsMinAttenuatedSize || 1;
119
- this.pntsMaxAttenuatedSize = config.pntsMaxAttenuatedSize || 7;
120
- if (config.pntsMode) {
121
- const exists = Object.values(PNTS_MODE).includes(config.pntsMode);
122
- if (!exists) {
123
- console.warn("The points cloud mode doesn't exist. Use 'COLOR' or 'CLASSIFICATION' instead.");
124
- } else {
125
- this.pntsMode = config.pntsMode;
126
- }
127
- }
128
- if (config.pntsShape) {
129
- const exists = Object.values(PNTS_SHAPE).includes(config.pntsShape);
130
- if (!exists) {
131
- console.warn("The points cloud point shape doesn't exist. Use 'CIRCLE' or 'SQUARE' instead.");
132
- } else {
133
- this.pntsShape = config.pntsShape;
134
- }
135
- }
136
- if (config.pntsSizeMode) {
137
- const exists = Object.values(PNTS_SIZE_MODE).includes(config.pntsSizeMode);
138
- if (!exists) {
139
- console.warn("The points cloud size mode doesn't exist. Use 'VALUE' or 'ATTENUATED' instead.");
140
- } else {
141
- this.pntsSizeMode = config.pntsSizeMode;
142
- }
143
- }
144
-
145
- /** @type {Style} */
146
- this.style = config.style || null;
147
-
148
- /** @type {Map<string, THREE.MeshStandardMaterial>} */
149
- this.#fillColorMaterialsBuffer = new Map();
150
-
151
- /**
152
- * Map all C3DTFeature of the layer according their tileId and their batchId
153
- * Map< tileId, Map< batchId, C3DTFeature>>
154
- *
155
- * @type {Map<number, Map<number,C3DTFeature>>}
156
- */
157
- this.tilesC3DTileFeatures = new Map();
158
- if (config.onTileContentLoaded) {
159
- console.warn('DEPRECATED onTileContentLoaded should not be passed at the contruction, use C3DTILES_LAYER_EVENTS.ON_TILE_CONTENT_LOADED event instead');
160
- this.addEventListener(C3DTILES_LAYER_EVENTS.ON_TILE_CONTENT_LOADED, config.onTileContentLoaded);
161
- }
162
- if (config.overrideMaterials) {
163
- console.warn('overrideMaterials is deprecated, use style API instead');
164
- this.overrideMaterials = config.overrideMaterials;
165
- }
166
- this._cleanableTiles = [];
167
- const resolve = this.addInitializationStep();
168
- this.source.whenReady.then(tileset => {
169
- this.tileset = new C3DTileset(tileset, this.source.baseUrl, this.registeredExtensions);
170
- // Verify that extensions of the tileset have been registered in the layer
171
- if (this.tileset.extensionsUsed) {
172
- for (const extensionUsed of this.tileset.extensionsUsed) {
173
- // if current extension is not registered
174
- if (!this.registeredExtensions.isExtensionRegistered(extensionUsed)) {
175
- // if it is required to load the tileset
176
- if (this.tileset.extensionsRequired && this.tileset.extensionsRequired.includes(extensionUsed)) {
177
- console.error(`3D Tiles tileset required extension "${extensionUsed}" must be registered to the 3D Tiles layer of iTowns to be parsed and used.`);
178
- } else {
179
- console.warn(`3D Tiles tileset used extension "${extensionUsed}" must be registered to the 3D Tiles layer of iTowns to be parsed and used.`);
180
- }
181
- }
182
- }
183
- }
184
- // TODO: Move all init3dTilesLayer code to constructor
185
- init3dTilesLayer(view, view.mainLoop.scheduler, this, tileset.root).then(resolve);
186
- });
187
- }
188
- preUpdate(context) {
189
- return pre3dTilesUpdate.bind(this)(context);
190
- }
191
- update(context, layer, node) {
192
- return update(context, layer, node);
193
- }
194
- getObjectToUpdateForAttachedLayers(meta) {
195
- if (meta.content) {
196
- const result = [];
197
- meta.content.traverse(obj => {
198
- if (obj.isObject3D && obj.material && obj.layer == meta.layer) {
199
- result.push(obj);
200
- }
201
- });
202
- const p = meta.parent;
203
- if (p && p.content) {
204
- return {
205
- elements: result,
206
- parent: p.content
207
- };
208
- } else {
209
- return {
210
- elements: result
211
- };
212
- }
213
- }
214
- }
215
-
216
- /**
217
- * Get the closest c3DTileFeature of an intersects array.
218
- * @param {Array} intersects - @return An array containing all
219
- * targets picked under specified coordinates. Intersects can be
220
- * computed with view.pickObjectsAt(..). See fillHTMLWithPickingInfo()
221
- * in 3dTilesHelper.js for an example.
222
- *
223
- * @returns {C3DTileFeature} - the closest C3DTileFeature of the intersects array
224
- */
225
- getC3DTileFeatureFromIntersectsArray(intersects) {
226
- // find closest intersect with an attributes _BATCHID + face != undefined
227
- let closestIntersect = null;
228
- for (let index = 0; index < intersects.length; index++) {
229
- const i = intersects[index];
230
- if (i.object.geometry && i.object.geometry.attributes._BATCHID && i.face &&
231
- // need face to get batch id
232
- i.layer == this // just to be sure that the right layer intersected
233
- ) {
234
- closestIntersect = i;
235
- break;
236
- }
237
- }
238
- if (!closestIntersect) {
239
- return null;
240
- }
241
- const tileId = findTileID(closestIntersect.object);
242
- // face is a Face3 object of THREE which is a
243
- // triangular face. face.a is its first vertex
244
- const vertex = closestIntersect.face.a;
245
- const batchID = closestIntersect.object.geometry.attributes._BATCHID.getX(vertex);
246
- return this.tilesC3DTileFeatures.get(tileId).get(batchID);
247
- }
248
-
249
- /**
250
- * Called when a tile content is loaded
251
- * @param {THREE.Object3D} tileContent - tile as THREE.Object3D
252
- */
253
- onTileContentLoaded(tileContent) {
254
- this.initC3DTileFeatures(tileContent);
255
-
256
- // notify observer
257
- this.dispatchEvent({
258
- type: C3DTILES_LAYER_EVENTS.ON_TILE_CONTENT_LOADED,
259
- tileContent
260
- });
261
-
262
- // only update style of tile features
263
- this.updateStyle([tileContent.tileId]);
264
- }
265
-
266
- /**
267
- * Initialize C3DTileFeatures from tileContent
268
- * @param {THREE.Object3D} tileContent - tile as THREE.Object3D
269
- */
270
- initC3DTileFeatures(tileContent) {
271
- this.tilesC3DTileFeatures.set(tileContent.tileId, new Map()); // initialize
272
- tileContent.traverse(child => {
273
- if (object3DHasFeature(child)) {
274
- const batchIdAttribute = child.geometry.getAttribute('_BATCHID');
275
- let currentBatchId = batchIdAttribute.getX(0);
276
- let start = 0;
277
- let count = 0;
278
- const registerBatchIdGroup = () => {
279
- if (this.tilesC3DTileFeatures.get(tileContent.tileId).has(currentBatchId)) {
280
- // already created
281
- const c3DTileFeature = this.tilesC3DTileFeatures.get(tileContent.tileId).get(currentBatchId);
282
- // add new group
283
- c3DTileFeature.groups.push({
284
- start,
285
- count
286
- });
287
- } else {
288
- // first occurence
289
- const c3DTileFeature = new C3DTFeature(tileContent.tileId, currentBatchId, [{
290
- start,
291
- count
292
- }],
293
- // initialize with current group
294
- {}, child);
295
- this.tilesC3DTileFeatures.get(tileContent.tileId).set(currentBatchId, c3DTileFeature);
296
- }
297
- };
298
-
299
- // TODO: Could be simplified by incrementing of 1 and stopping the iteration at positionAttributeSize.count
300
- // See https://github.com/iTowns/itowns/pull/2266#discussion_r1483285122
301
- const positionAttribute = child.geometry.getAttribute('position');
302
- const positionAttributeSize = positionAttribute.count * positionAttribute.itemSize;
303
- for (let index = 0; index < positionAttributeSize; index += positionAttribute.itemSize) {
304
- const batchIndex = index / positionAttribute.itemSize;
305
- const batchId = batchIdAttribute.getX(batchIndex);
306
-
307
- // check if batchId is currentBatchId
308
- if (currentBatchId !== batchId) {
309
- registerBatchIdGroup();
310
-
311
- // reset
312
- currentBatchId = batchId;
313
- start = batchIndex;
314
- count = 0;
315
- }
316
-
317
- // record this position in current C3DTileFeature
318
- count++;
319
-
320
- // check if end of the array
321
- if (index + positionAttribute.itemSize >= positionAttributeSize) {
322
- registerBatchIdGroup();
323
- }
324
- }
325
- }
326
- });
327
- }
328
-
329
- /**
330
- * Update style of the C3DTFeatures, an allowList of tile id can be passed to only update certain tile.
331
- * Note that this function only update THREE.Object3D materials, in order to see style changes you should call view.notifyChange()
332
- * @param {Array<number>|null} [allowTileIdList] - tile ids to allow in updateStyle computation if null all tiles are updated
333
- *
334
- * @returns {boolean} true if style updated false otherwise
335
- */
336
- updateStyle() {
337
- let allowTileIdList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
338
- if (!this._style) {
339
- return false;
340
- }
341
- if (!this.object3d) {
342
- return false;
343
- }
344
- const currentMaterials = []; // list materials used for this update
345
-
346
- const mapObjects3d = new Map();
347
- this.object3d.traverse(child => {
348
- if (object3DHasFeature(child)) {
349
- const tileId = findTileID(child);
350
- if (allowTileIdList && !allowTileIdList.includes(tileId)) {
351
- return; // this tileId is not updated
352
- }
353
-
354
- // push for update style
355
- if (!mapObjects3d.has(tileId)) {
356
- mapObjects3d.set(tileId, []);
357
- }
358
- mapObjects3d.get(tileId).push(child);
359
- }
360
- });
361
- for (const [tileId, objects3d] of mapObjects3d) {
362
- const c3DTileFeatures = this.tilesC3DTileFeatures.get(tileId); // features of this tile
363
- objects3d.forEach(object3d => {
364
- // clear
365
- object3d.geometry.clearGroups();
366
- object3d.material = [];
367
- for (const [, c3DTileFeature] of c3DTileFeatures) {
368
- if (c3DTileFeature.object3d != object3d) {
369
- continue; // this feature do not belong to object3d
370
- }
371
- this._style.context.setGeometry({
372
- properties: c3DTileFeature
373
- });
374
-
375
- /** @type {THREE.Color} */
376
- const color = new THREE.Color(this._style.fill.color);
377
-
378
- /** @type {number} */
379
- const opacity = this._style.fill.opacity;
380
- const materialId = color.getHexString() + opacity;
381
- let material = null;
382
- if (this.#fillColorMaterialsBuffer.has(materialId)) {
383
- material = this.#fillColorMaterialsBuffer.get(materialId);
384
- } else {
385
- material = new THREE.MeshStandardMaterial({
386
- color,
387
- opacity,
388
- transparent: opacity < 1,
389
- alphaTest: 0.09
390
- });
391
- this.#fillColorMaterialsBuffer.set(materialId, material); // bufferize
392
- }
393
-
394
- // compute materialIndex
395
- let materialIndex = -1;
396
- for (let index = 0; index < object3d.material.length; index++) {
397
- const childMaterial = object3d.material[index];
398
- if (material.uuid === childMaterial.uuid) {
399
- materialIndex = index;
400
- break;
401
- }
402
- }
403
- if (materialIndex < 0) {
404
- // not in object3d.material add it
405
- object3d.material.push(material);
406
- materialIndex = object3d.material.length - 1;
407
- }
408
-
409
- // materialIndex groups is computed
410
- c3DTileFeature.groups.forEach(group => {
411
- object3d.geometry.addGroup(group.start, group.count, materialIndex);
412
- });
413
- }
414
- optimizeGeometryGroups(object3d);
415
-
416
- // record material(s) used in object3d
417
- if (object3d.material instanceof Array) {
418
- object3d.material.forEach(material => {
419
- if (!currentMaterials.includes(material)) {
420
- currentMaterials.push(material);
421
- }
422
- });
423
- } else if (!currentMaterials.includes(object3d.material)) {
424
- currentMaterials.push(object3d.material);
425
- }
426
- });
427
- }
428
-
429
- // remove buffered materials not in currentMaterials
430
- for (const [id, fillMaterial] of this.#fillColorMaterialsBuffer) {
431
- if (!currentMaterials.includes(fillMaterial)) {
432
- fillMaterial.dispose();
433
- this.#fillColorMaterialsBuffer.delete(id);
434
- }
435
- }
436
- return true;
437
- }
438
- get materialCount() {
439
- return this.#fillColorMaterialsBuffer.size;
440
- }
441
- set style(value) {
442
- if (value instanceof Style) {
443
- this._style = value;
444
- } else if (!value) {
445
- this._style = null;
446
- } else {
447
- this._style = new Style(value);
448
- }
449
- this.updateStyle();
450
- }
451
- get style() {
452
- return this._style;
453
- }
454
- }
455
- export default C3DTilesLayer;
@@ -1,128 +0,0 @@
1
- import RasterLayer from "./RasterLayer.js";
2
- import { updateLayeredMaterialNodeImagery } from "../Process/LayeredMaterialNodeProcessing.js";
3
- import { RasterColorTile } from "../Renderer/RasterTile.js";
4
- import { deprecatedColorLayerOptions } from "../Core/Deprecated/Undeprecator.js";
5
-
6
- /**
7
- * Fires when the visiblity of the layer has changed.
8
- * @event ColorLayer#visible-property-changed
9
- */
10
- /**
11
- * Fires when the opacity of the layer has changed.
12
- * @event ColorLayer#opacity-property-changed
13
- */
14
- /**
15
- * Fires when the sequence of the layer has changed, meaning that the order of
16
- * the layer changed in the view it is attached to.
17
- * @event ColorLayer#sequence-property-changed
18
- */
19
-
20
- /**
21
- * @property {boolean} isColorLayer - Used to checkout whether this layer is a
22
- * ColorLayer. Default is true. You should not change this, as it is used
23
- * internally for optimisation.
24
- * @property {StyleOptions|Style} style - style properties or a Style defined by the user,
25
- * to apply to the layer features.
26
- * @property {boolean} visible - property to display or to hide layer.
27
- * @property {number} opacity - property to adjust transparency, opacity is between 0. and 1.
28
- * @property {boolean} transparent - specify if the layer could be transparent.
29
- * @property {boolean} noTextureParentOutsideLimit - don't parent texture if it's outside limit.
30
- * @property {number} effect_type - type effect to apply on the raster color.
31
- * If `effect_type` equals:
32
- * * `0`: no effect.
33
- * * `1`: light color to invisible effect: transparency effect is stronger for
34
- * light colors (whose distance is closer to white). This effect can be
35
- * amplified by `effect_parameter`.
36
- * * `2`: white color to invisible effect: white color is considered as
37
- * transparent.
38
- * * `3`: custom shader effect: set `ShaderChunk.customBodyColorLayer` and
39
- * `ShaderChunk.customHeaderColorLayer` to add your own glsl code in
40
- * respectively the color layer function body and at top-level.
41
- * @property {number} effect_parameter - value used as parameter of certain type
42
- * of effects. If `effect_type` equals:
43
- * * `0`: unused.
44
- * * `1`: used to amplify the transparency effect.
45
- * * `2`: unused.
46
- * * `3`: could be used by your own glsl code.
47
- */
48
- class ColorLayer extends RasterLayer {
49
- /**
50
- * A simple layer, usually managing a texture to display on a view. For example,
51
- * it can be an aerial view of the ground or a simple transparent layer with the
52
- * roads displayed.
53
- *
54
- * @extends Layer
55
- *
56
- * @param {string} id - The id of the layer, that should be unique. It is
57
- * not mandatory, but an error will be emitted if this layer is added a
58
- * {@link View} that already has a layer going by that id.
59
- * @param {Object} [config] - Optional configuration, all elements in it
60
- * will be merged as is in the layer. For example, if the configuration
61
- * contains three elements `name, protocol, extent`, these elements will be
62
- * available using `layer.name` or something else depending on the property
63
- * name.
64
- * @param {Source} [config.source] - Description and options of the source.
65
- * @param {number} [config.magFilter] - How the texture is sampled when a texel covers more than one pixel. [see](https://threejs.org/docs/?q=texture#api/en/textures/Texture.magFilter)
66
- * @param {number} [config.minFilter] - How the texture is sampled when a texel covers less than one pixel. [see](https://threejs.org/docs/?q=texture#api/en/textures/Texture.minFilter)
67
- * @param {number} [config.effect_type=0] - type effect to apply on raster color.
68
- * if `effect_type` equals:
69
- * * `0`: no special effect.
70
- * * `1`: light color to invisible effect.
71
- * * `2`: white color to invisible effect.
72
- * * `3`: custom shader effect (defined `ShaderChunk.customBodyColorLayer` and `ShaderChunk.customHeaderColorLayer`).
73
- * @param {number} [config.effect_parameter=1.0] - amount value used with effect applied on raster color.
74
- *
75
- * @example
76
- * // Create a ColorLayer
77
- * const color = new ColorLayer('roads', {
78
- * source: new SourceWMTS({
79
- * protocol: 'wmts',
80
- * url: 'http://server.geo/wmts/....',
81
- * format: 'image/png',
82
- * name: 'nameService',
83
- * tileMatrixSet: 'PM',
84
- * }),
85
- * transparent: true,
86
- * opacity: 0.5,
87
- * });
88
- *
89
- * // Add the layer
90
- * view.addLayer(color);
91
- */
92
- constructor(id) {
93
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
94
- deprecatedColorLayerOptions(config);
95
- super(id, config);
96
- this.isColorLayer = true;
97
- this.defineLayerProperty('visible', true);
98
- this.defineLayerProperty('opacity', 1.0);
99
- this.defineLayerProperty('sequence', 0);
100
- this.transparent = config.transparent || this.opacity < 1.0;
101
- this.noTextureParentOutsideLimit = config.source ? config.source.isFileSource : false;
102
- this.effect_type = config.effect_type ?? 0;
103
- this.effect_parameter = config.effect_parameter ?? 1.0;
104
-
105
- // Feature options
106
- this.buildExtent = true;
107
- this.structure = '2d';
108
- }
109
-
110
- /**
111
- * Setup RasterColorTile added to TileMesh. This RasterColorTile handles
112
- * the ColorLayer textures mapped on this TileMesh.
113
- *
114
- * @param {TileMesh} node The node to apply new RasterColorTile;
115
- * @return {RasterColorTile} The raster color node added.
116
- */
117
- setupRasterNode(node) {
118
- const rasterColorNode = new RasterColorTile(node.material, this);
119
- node.material.addLayer(rasterColorNode);
120
- // set up ColorLayer ordering.
121
- node.material.setSequence(this.parent.colorLayersOrder);
122
- return rasterColorNode;
123
- }
124
- update(context, layer, node, parent) {
125
- return updateLayeredMaterialNodeImagery(context, this, node, parent);
126
- }
127
- }
128
- export default ColorLayer;
@@ -1,58 +0,0 @@
1
- import * as THREE from 'three';
2
- import CopcNode from "../Core/CopcNode.js";
3
- import PointCloudLayer from "./PointCloudLayer.js";
4
-
5
- /**
6
- * A layer for [Cloud Optimised Point Cloud](https://copc.io) (COPC) datasets.
7
- * See {@link PointCloudLayer} class for documentation on base properties.
8
- *
9
- * @extends {PointCloudLayer}
10
- *
11
- * @example
12
- * // Create a new COPC layer
13
- * const copcSource = new CopcSource({
14
- * url: 'https://s3.amazonaws.com/hobu-lidar/autzen-classified.copc.laz',
15
- * crs: 'EPSG:4978',
16
- * colorDepth: 16, // bit-depth of 'color' attribute (either 8 or 16 bits)
17
- * });
18
- *
19
- * const copcLayer = new CopcLayer('COPC', {
20
- * source: copcSource,
21
- * });
22
- *
23
- * View.prototype.addLayer.call(view, copcLayer);
24
- */
25
- class CopcLayer extends PointCloudLayer {
26
- /**
27
- * @param {string} id - Unique id of the layer.
28
- * @param {Object} config - See {@link PointCloudLayer} for base pointcloud
29
- * options.
30
- */
31
- constructor(id, config) {
32
- super(id, config);
33
- this.isCopcLayer = true;
34
- const resolve = () => this;
35
- this.whenReady = this.source.whenReady.then((/** @type {CopcSource} */source) => {
36
- const {
37
- cube,
38
- rootHierarchyPage
39
- } = source.info;
40
- const {
41
- pageOffset,
42
- pageLength
43
- } = rootHierarchyPage;
44
- this.root = new CopcNode(0, 0, 0, 0, pageOffset, pageLength, this, -1);
45
- this.root.bbox.min.fromArray(cube, 0);
46
- this.root.bbox.max.fromArray(cube, 3);
47
- this.minElevationRange = source.header.min[2];
48
- this.maxElevationRange = source.header.max[2];
49
- this.scale = new THREE.Vector3(1.0, 1.0, 1.0);
50
- this.offset = new THREE.Vector3(0.0, 0.0, 0.0);
51
- return this.root.loadOctree().then(resolve);
52
- });
53
- }
54
- get spacing() {
55
- return this.source.info.spacing;
56
- }
57
- }
58
- export default CopcLayer;