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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -608
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -726
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/TileGeometry.js +0 -40
  100. package/lib/Core/TileMesh.js +0 -108
  101. package/lib/Core/View.js +0 -1109
  102. package/lib/Layer/C3DTilesLayer.js +0 -455
  103. package/lib/Layer/ColorLayer.js +0 -128
  104. package/lib/Layer/CopcLayer.js +0 -58
  105. package/lib/Layer/ElevationLayer.js +0 -107
  106. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  107. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  108. package/lib/Layer/GeoidLayer.js +0 -80
  109. package/lib/Layer/GeometryLayer.js +0 -202
  110. package/lib/Layer/InfoLayer.js +0 -64
  111. package/lib/Layer/LabelLayer.js +0 -452
  112. package/lib/Layer/Layer.js +0 -304
  113. package/lib/Layer/LayerUpdateState.js +0 -89
  114. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  115. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  116. package/lib/Layer/OrientedImageLayer.js +0 -222
  117. package/lib/Layer/PointCloudLayer.js +0 -359
  118. package/lib/Layer/Potree2Layer.js +0 -164
  119. package/lib/Layer/PotreeLayer.js +0 -65
  120. package/lib/Layer/RasterLayer.js +0 -27
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  122. package/lib/Layer/TiledGeometryLayer.js +0 -403
  123. package/lib/Loader/LASLoader.js +0 -193
  124. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  125. package/lib/Loader/Potree2Loader.js +0 -207
  126. package/lib/Main.js +0 -115
  127. package/lib/MainBundle.js +0 -4
  128. package/lib/Parser/B3dmParser.js +0 -174
  129. package/lib/Parser/CameraCalibrationParser.js +0 -94
  130. package/lib/Parser/GDFParser.js +0 -72
  131. package/lib/Parser/GTXParser.js +0 -75
  132. package/lib/Parser/GeoJsonParser.js +0 -212
  133. package/lib/Parser/GpxParser.js +0 -25
  134. package/lib/Parser/ISGParser.js +0 -71
  135. package/lib/Parser/KMLParser.js +0 -25
  136. package/lib/Parser/LASParser.js +0 -137
  137. package/lib/Parser/MapBoxUrlParser.js +0 -83
  138. package/lib/Parser/PntsParser.js +0 -131
  139. package/lib/Parser/Potree2BinParser.js +0 -92
  140. package/lib/Parser/PotreeBinParser.js +0 -106
  141. package/lib/Parser/PotreeCinParser.js +0 -29
  142. package/lib/Parser/ShapefileParser.js +0 -78
  143. package/lib/Parser/VectorTileParser.js +0 -202
  144. package/lib/Parser/XbilParser.js +0 -108
  145. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  146. package/lib/Parser/iGLTFLoader.js +0 -168
  147. package/lib/Process/3dTilesProcessing.js +0 -304
  148. package/lib/Process/FeatureProcessing.js +0 -76
  149. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  150. package/lib/Process/ObjectRemovalHelper.js +0 -97
  151. package/lib/Process/handlerNodeError.js +0 -23
  152. package/lib/Provider/3dTilesProvider.js +0 -149
  153. package/lib/Provider/DataSourceProvider.js +0 -8
  154. package/lib/Provider/Fetcher.js +0 -229
  155. package/lib/Provider/PointCloudProvider.js +0 -45
  156. package/lib/Provider/TileProvider.js +0 -16
  157. package/lib/Provider/URLBuilder.js +0 -105
  158. package/lib/Renderer/Camera.js +0 -281
  159. package/lib/Renderer/Color.js +0 -56
  160. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  161. package/lib/Renderer/CommonMaterial.js +0 -31
  162. package/lib/Renderer/Label2DRenderer.js +0 -190
  163. package/lib/Renderer/LayeredMaterial.js +0 -243
  164. package/lib/Renderer/OBB.js +0 -153
  165. package/lib/Renderer/OrientedImageCamera.js +0 -118
  166. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  167. package/lib/Renderer/PointsMaterial.js +0 -485
  168. package/lib/Renderer/RasterTile.js +0 -209
  169. package/lib/Renderer/RenderMode.js +0 -31
  170. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  171. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  172. package/lib/Renderer/SphereHelper.js +0 -23
  173. package/lib/Renderer/WebXR.js +0 -51
  174. package/lib/Renderer/c3DEngine.js +0 -214
  175. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  176. package/lib/Source/C3DTilesIonSource.js +0 -54
  177. package/lib/Source/C3DTilesSource.js +0 -30
  178. package/lib/Source/CopcSource.js +0 -115
  179. package/lib/Source/EntwinePointTileSource.js +0 -62
  180. package/lib/Source/FileSource.js +0 -189
  181. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  182. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  183. package/lib/Source/OGC3DTilesSource.js +0 -21
  184. package/lib/Source/OrientedImageSource.js +0 -59
  185. package/lib/Source/Potree2Source.js +0 -167
  186. package/lib/Source/PotreeSource.js +0 -82
  187. package/lib/Source/Source.js +0 -223
  188. package/lib/Source/TMSSource.js +0 -143
  189. package/lib/Source/VectorTilesSource.js +0 -178
  190. package/lib/Source/WFSSource.js +0 -165
  191. package/lib/Source/WMSSource.js +0 -130
  192. package/lib/Source/WMTSSource.js +0 -86
  193. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  194. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  195. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  196. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  197. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  198. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  199. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  200. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  201. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  202. package/lib/Utils/CameraUtils.js +0 -555
  203. package/lib/Utils/DEMUtils.js +0 -350
  204. package/lib/Utils/FeaturesUtils.js +0 -156
  205. package/lib/Utils/Gradients.js +0 -16
  206. package/lib/Utils/OrientationUtils.js +0 -457
  207. package/lib/Utils/ThreeUtils.js +0 -115
  208. package/lib/Utils/gui/C3DTilesStyle.js +0 -216
  209. package/lib/Utils/gui/Main.js +0 -7
  210. package/lib/Utils/gui/Minimap.js +0 -154
  211. package/lib/Utils/gui/Navigation.js +0 -245
  212. package/lib/Utils/gui/Scale.js +0 -107
  213. package/lib/Utils/gui/Searchbar.js +0 -234
  214. package/lib/Utils/gui/Widget.js +0 -80
  215. package/lib/Utils/placeObjectOnGround.js +0 -137
  216. package/lib/Worker/LASLoaderWorker.js +0 -19
  217. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,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
- /** @type {THREE.Color} */
372
- let color = null;
373
- if (typeof this._style.fill.color === 'function') {
374
- color = new THREE.Color(this._style.fill.color(c3DTileFeature));
375
- } else {
376
- color = new THREE.Color(this._style.fill.color);
377
- }
378
-
379
- /** @type {number} */
380
- let opacity = null;
381
- if (typeof this._style.fill.opacity === 'function') {
382
- opacity = this._style.fill.opacity(c3DTileFeature);
383
- } else {
384
- opacity = this._style.fill.opacity;
385
- }
386
- const materialId = color.getHexString() + opacity;
387
- let material = null;
388
- if (this.#fillColorMaterialsBuffer.has(materialId)) {
389
- material = this.#fillColorMaterialsBuffer.get(materialId);
390
- } else {
391
- material = new THREE.MeshStandardMaterial({
392
- color,
393
- opacity,
394
- transparent: opacity < 1,
395
- alphaTest: 0.09
396
- });
397
- this.#fillColorMaterialsBuffer.set(materialId, material); // bufferize
398
- }
399
-
400
- // compute materialIndex
401
- let materialIndex = -1;
402
- for (let index = 0; index < object3d.material.length; index++) {
403
- const childMaterial = object3d.material[index];
404
- if (material.uuid === childMaterial.uuid) {
405
- materialIndex = index;
406
- break;
407
- }
408
- }
409
- if (materialIndex < 0) {
410
- // not in object3d.material add it
411
- object3d.material.push(material);
412
- materialIndex = object3d.material.length - 1;
413
- }
414
-
415
- // materialIndex groups is computed
416
- c3DTileFeature.groups.forEach(group => {
417
- object3d.geometry.addGroup(group.start, group.count, materialIndex);
418
- });
419
- }
420
- optimizeGeometryGroups(object3d);
421
-
422
- // record material(s) used in object3d
423
- if (object3d.material instanceof Array) {
424
- object3d.material.forEach(material => {
425
- if (!currentMaterials.includes(material)) {
426
- currentMaterials.push(material);
427
- }
428
- });
429
- } else if (!currentMaterials.includes(object3d.material)) {
430
- currentMaterials.push(object3d.material);
431
- }
432
- });
433
- }
434
-
435
- // remove buffered materials not in currentMaterials
436
- for (const [id, fillMaterial] of this.#fillColorMaterialsBuffer) {
437
- if (!currentMaterials.includes(fillMaterial)) {
438
- fillMaterial.dispose();
439
- this.#fillColorMaterialsBuffer.delete(id);
440
- }
441
- }
442
- return true;
443
- }
444
- get materialCount() {
445
- return this.#fillColorMaterialsBuffer.size;
446
- }
447
- set style(value) {
448
- this._style = value;
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;