itowns 2.44.3-next.9 → 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 (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,456 +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
- console.warn('C3DTilesLayer is deprecated and will be removed in iTowns 3.0 version. Use OGC3DTilesLayer instead.');
106
- super(id, new THREE.Group(), {
107
- source: config.source
108
- });
109
- this.isC3DTilesLayer = true;
110
- this.sseThreshold = config.sseThreshold || 16;
111
- this.cleanupDelay = config.cleanupDelay || 1000;
112
- this.protocol = '3d-tiles';
113
- this.name = config.name;
114
- this.registeredExtensions = config.registeredExtensions || new C3DTExtensions();
115
- this.pntsMode = PNTS_MODE.COLOR;
116
- this.pntsShape = PNTS_SHAPE.CIRCLE;
117
- this.classification = config.classification;
118
- this.pntsSizeMode = PNTS_SIZE_MODE.VALUE;
119
- this.pntsMinAttenuatedSize = config.pntsMinAttenuatedSize || 1;
120
- this.pntsMaxAttenuatedSize = config.pntsMaxAttenuatedSize || 7;
121
- if (config.pntsMode) {
122
- const exists = Object.values(PNTS_MODE).includes(config.pntsMode);
123
- if (!exists) {
124
- console.warn("The points cloud mode doesn't exist. Use 'COLOR' or 'CLASSIFICATION' instead.");
125
- } else {
126
- this.pntsMode = config.pntsMode;
127
- }
128
- }
129
- if (config.pntsShape) {
130
- const exists = Object.values(PNTS_SHAPE).includes(config.pntsShape);
131
- if (!exists) {
132
- console.warn("The points cloud point shape doesn't exist. Use 'CIRCLE' or 'SQUARE' instead.");
133
- } else {
134
- this.pntsShape = config.pntsShape;
135
- }
136
- }
137
- if (config.pntsSizeMode) {
138
- const exists = Object.values(PNTS_SIZE_MODE).includes(config.pntsSizeMode);
139
- if (!exists) {
140
- console.warn("The points cloud size mode doesn't exist. Use 'VALUE' or 'ATTENUATED' instead.");
141
- } else {
142
- this.pntsSizeMode = config.pntsSizeMode;
143
- }
144
- }
145
-
146
- /** @type {Style} */
147
- this.style = config.style || null;
148
-
149
- /** @type {Map<string, THREE.MeshStandardMaterial>} */
150
- this.#fillColorMaterialsBuffer = new Map();
151
-
152
- /**
153
- * Map all C3DTFeature of the layer according their tileId and their batchId
154
- * Map< tileId, Map< batchId, C3DTFeature>>
155
- *
156
- * @type {Map<number, Map<number,C3DTFeature>>}
157
- */
158
- this.tilesC3DTileFeatures = new Map();
159
- if (config.onTileContentLoaded) {
160
- console.warn('DEPRECATED onTileContentLoaded should not be passed at the contruction, use C3DTILES_LAYER_EVENTS.ON_TILE_CONTENT_LOADED event instead');
161
- this.addEventListener(C3DTILES_LAYER_EVENTS.ON_TILE_CONTENT_LOADED, config.onTileContentLoaded);
162
- }
163
- if (config.overrideMaterials) {
164
- console.warn('overrideMaterials is deprecated, use style API instead');
165
- this.overrideMaterials = config.overrideMaterials;
166
- }
167
- this._cleanableTiles = [];
168
- const resolve = this.addInitializationStep();
169
- this.source.whenReady.then(tileset => {
170
- this.tileset = new C3DTileset(tileset, this.source.baseUrl, this.registeredExtensions);
171
- // Verify that extensions of the tileset have been registered in the layer
172
- if (this.tileset.extensionsUsed) {
173
- for (const extensionUsed of this.tileset.extensionsUsed) {
174
- // if current extension is not registered
175
- if (!this.registeredExtensions.isExtensionRegistered(extensionUsed)) {
176
- // if it is required to load the tileset
177
- if (this.tileset.extensionsRequired && this.tileset.extensionsRequired.includes(extensionUsed)) {
178
- console.error(`3D Tiles tileset required extension "${extensionUsed}" must be registered to the 3D Tiles layer of iTowns to be parsed and used.`);
179
- } else {
180
- console.warn(`3D Tiles tileset used extension "${extensionUsed}" must be registered to the 3D Tiles layer of iTowns to be parsed and used.`);
181
- }
182
- }
183
- }
184
- }
185
- // TODO: Move all init3dTilesLayer code to constructor
186
- init3dTilesLayer(view, view.mainLoop.scheduler, this, tileset.root).then(resolve);
187
- });
188
- }
189
- preUpdate(context) {
190
- return pre3dTilesUpdate.bind(this)(context);
191
- }
192
- update(context, layer, node) {
193
- return update(context, layer, node);
194
- }
195
- getObjectToUpdateForAttachedLayers(meta) {
196
- if (meta.content) {
197
- const result = [];
198
- meta.content.traverse(obj => {
199
- if (obj.isObject3D && obj.material && obj.layer == meta.layer) {
200
- result.push(obj);
201
- }
202
- });
203
- const p = meta.parent;
204
- if (p && p.content) {
205
- return {
206
- elements: result,
207
- parent: p.content
208
- };
209
- } else {
210
- return {
211
- elements: result
212
- };
213
- }
214
- }
215
- }
216
-
217
- /**
218
- * Get the closest c3DTileFeature of an intersects array.
219
- * @param {Array} intersects - @return An array containing all
220
- * targets picked under specified coordinates. Intersects can be
221
- * computed with view.pickObjectsAt(..). See fillHTMLWithPickingInfo()
222
- * in 3dTilesHelper.js for an example.
223
- *
224
- * @returns {C3DTileFeature} - the closest C3DTileFeature of the intersects array
225
- */
226
- getC3DTileFeatureFromIntersectsArray(intersects) {
227
- // find closest intersect with an attributes _BATCHID + face != undefined
228
- let closestIntersect = null;
229
- for (let index = 0; index < intersects.length; index++) {
230
- const i = intersects[index];
231
- if (i.object.geometry && i.object.geometry.attributes._BATCHID && i.face &&
232
- // need face to get batch id
233
- i.layer == this // just to be sure that the right layer intersected
234
- ) {
235
- closestIntersect = i;
236
- break;
237
- }
238
- }
239
- if (!closestIntersect) {
240
- return null;
241
- }
242
- const tileId = findTileID(closestIntersect.object);
243
- // face is a Face3 object of THREE which is a
244
- // triangular face. face.a is its first vertex
245
- const vertex = closestIntersect.face.a;
246
- const batchID = closestIntersect.object.geometry.attributes._BATCHID.getX(vertex);
247
- return this.tilesC3DTileFeatures.get(tileId).get(batchID);
248
- }
249
-
250
- /**
251
- * Called when a tile content is loaded
252
- * @param {THREE.Object3D} tileContent - tile as THREE.Object3D
253
- */
254
- onTileContentLoaded(tileContent) {
255
- this.initC3DTileFeatures(tileContent);
256
-
257
- // notify observer
258
- this.dispatchEvent({
259
- type: C3DTILES_LAYER_EVENTS.ON_TILE_CONTENT_LOADED,
260
- tileContent
261
- });
262
-
263
- // only update style of tile features
264
- this.updateStyle([tileContent.tileId]);
265
- }
266
-
267
- /**
268
- * Initialize C3DTileFeatures from tileContent
269
- * @param {THREE.Object3D} tileContent - tile as THREE.Object3D
270
- */
271
- initC3DTileFeatures(tileContent) {
272
- this.tilesC3DTileFeatures.set(tileContent.tileId, new Map()); // initialize
273
- tileContent.traverse(child => {
274
- if (object3DHasFeature(child)) {
275
- const batchIdAttribute = child.geometry.getAttribute('_BATCHID');
276
- let currentBatchId = batchIdAttribute.getX(0);
277
- let start = 0;
278
- let count = 0;
279
- const registerBatchIdGroup = () => {
280
- if (this.tilesC3DTileFeatures.get(tileContent.tileId).has(currentBatchId)) {
281
- // already created
282
- const c3DTileFeature = this.tilesC3DTileFeatures.get(tileContent.tileId).get(currentBatchId);
283
- // add new group
284
- c3DTileFeature.groups.push({
285
- start,
286
- count
287
- });
288
- } else {
289
- // first occurence
290
- const c3DTileFeature = new C3DTFeature(tileContent.tileId, currentBatchId, [{
291
- start,
292
- count
293
- }],
294
- // initialize with current group
295
- {}, child);
296
- this.tilesC3DTileFeatures.get(tileContent.tileId).set(currentBatchId, c3DTileFeature);
297
- }
298
- };
299
-
300
- // TODO: Could be simplified by incrementing of 1 and stopping the iteration at positionAttributeSize.count
301
- // See https://github.com/iTowns/itowns/pull/2266#discussion_r1483285122
302
- const positionAttribute = child.geometry.getAttribute('position');
303
- const positionAttributeSize = positionAttribute.count * positionAttribute.itemSize;
304
- for (let index = 0; index < positionAttributeSize; index += positionAttribute.itemSize) {
305
- const batchIndex = index / positionAttribute.itemSize;
306
- const batchId = batchIdAttribute.getX(batchIndex);
307
-
308
- // check if batchId is currentBatchId
309
- if (currentBatchId !== batchId) {
310
- registerBatchIdGroup();
311
-
312
- // reset
313
- currentBatchId = batchId;
314
- start = batchIndex;
315
- count = 0;
316
- }
317
-
318
- // record this position in current C3DTileFeature
319
- count++;
320
-
321
- // check if end of the array
322
- if (index + positionAttribute.itemSize >= positionAttributeSize) {
323
- registerBatchIdGroup();
324
- }
325
- }
326
- }
327
- });
328
- }
329
-
330
- /**
331
- * Update style of the C3DTFeatures, an allowList of tile id can be passed to only update certain tile.
332
- * Note that this function only update THREE.Object3D materials, in order to see style changes you should call view.notifyChange()
333
- * @param {Array<number>|null} [allowTileIdList] - tile ids to allow in updateStyle computation if null all tiles are updated
334
- *
335
- * @returns {boolean} true if style updated false otherwise
336
- */
337
- updateStyle() {
338
- let allowTileIdList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
339
- if (!this._style) {
340
- return false;
341
- }
342
- if (!this.object3d) {
343
- return false;
344
- }
345
- const currentMaterials = []; // list materials used for this update
346
-
347
- const mapObjects3d = new Map();
348
- this.object3d.traverse(child => {
349
- if (object3DHasFeature(child)) {
350
- const tileId = findTileID(child);
351
- if (allowTileIdList && !allowTileIdList.includes(tileId)) {
352
- return; // this tileId is not updated
353
- }
354
-
355
- // push for update style
356
- if (!mapObjects3d.has(tileId)) {
357
- mapObjects3d.set(tileId, []);
358
- }
359
- mapObjects3d.get(tileId).push(child);
360
- }
361
- });
362
- for (const [tileId, objects3d] of mapObjects3d) {
363
- const c3DTileFeatures = this.tilesC3DTileFeatures.get(tileId); // features of this tile
364
- objects3d.forEach(object3d => {
365
- // clear
366
- object3d.geometry.clearGroups();
367
- object3d.material = [];
368
- for (const [, c3DTileFeature] of c3DTileFeatures) {
369
- if (c3DTileFeature.object3d != object3d) {
370
- continue; // this feature do not belong to object3d
371
- }
372
- this._style.context.setGeometry({
373
- properties: c3DTileFeature
374
- });
375
-
376
- /** @type {THREE.Color} */
377
- const color = new THREE.Color(this._style.fill.color);
378
-
379
- /** @type {number} */
380
- const opacity = this._style.fill.opacity;
381
- const materialId = color.getHexString() + opacity;
382
- let material = null;
383
- if (this.#fillColorMaterialsBuffer.has(materialId)) {
384
- material = this.#fillColorMaterialsBuffer.get(materialId);
385
- } else {
386
- material = new THREE.MeshStandardMaterial({
387
- color,
388
- opacity,
389
- transparent: opacity < 1,
390
- alphaTest: 0.09
391
- });
392
- this.#fillColorMaterialsBuffer.set(materialId, material); // bufferize
393
- }
394
-
395
- // compute materialIndex
396
- let materialIndex = -1;
397
- for (let index = 0; index < object3d.material.length; index++) {
398
- const childMaterial = object3d.material[index];
399
- if (material.uuid === childMaterial.uuid) {
400
- materialIndex = index;
401
- break;
402
- }
403
- }
404
- if (materialIndex < 0) {
405
- // not in object3d.material add it
406
- object3d.material.push(material);
407
- materialIndex = object3d.material.length - 1;
408
- }
409
-
410
- // materialIndex groups is computed
411
- c3DTileFeature.groups.forEach(group => {
412
- object3d.geometry.addGroup(group.start, group.count, materialIndex);
413
- });
414
- }
415
- optimizeGeometryGroups(object3d);
416
-
417
- // record material(s) used in object3d
418
- if (object3d.material instanceof Array) {
419
- object3d.material.forEach(material => {
420
- if (!currentMaterials.includes(material)) {
421
- currentMaterials.push(material);
422
- }
423
- });
424
- } else if (!currentMaterials.includes(object3d.material)) {
425
- currentMaterials.push(object3d.material);
426
- }
427
- });
428
- }
429
-
430
- // remove buffered materials not in currentMaterials
431
- for (const [id, fillMaterial] of this.#fillColorMaterialsBuffer) {
432
- if (!currentMaterials.includes(fillMaterial)) {
433
- fillMaterial.dispose();
434
- this.#fillColorMaterialsBuffer.delete(id);
435
- }
436
- }
437
- return true;
438
- }
439
- get materialCount() {
440
- return this.#fillColorMaterialsBuffer.size;
441
- }
442
- set style(value) {
443
- if (value instanceof Style) {
444
- this._style = value;
445
- } else if (!value) {
446
- this._style = null;
447
- } else {
448
- this._style = new Style(value);
449
- }
450
- this.updateStyle();
451
- }
452
- get style() {
453
- return this._style;
454
- }
455
- }
456
- 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;