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,170 +0,0 @@
1
- import * as THREE from 'three';
2
- import { FEATURE_TYPES } from "../Core/Feature.js";
3
- import Extent from "../Core/Geographic/Extent.js";
4
- import Coordinates from "../Core/Geographic/Coordinates.js";
5
- import Style, { StyleContext } from "../Core/Style.js";
6
- const defaultStyle = new Style();
7
- const context = new StyleContext();
8
- let style;
9
-
10
- /**
11
- * Draw polygon (contour, line edge and fill) based on feature vertices into canvas
12
- * using the given style(s). Several styles will re-draws the polygon each one with
13
- * a different style.
14
- * @param {CanvasRenderingContext2D} ctx - canvas' 2D rendering context.
15
- * @param {Number[]} vertices - All the vertices of the Feature.
16
- * @param {Object[]} indices - Contains the indices that define the geometry.
17
- * Objects stored in this array have two properties, an `offset` and a `count`.
18
- * The offset is related to the overall number of vertices in the Feature.
19
- * @param {Number} size - The size of the feature.
20
- * @param {Number} extent - The extent.
21
- * @param {Number} invCtxScale - The ration to scale line width and radius circle.
22
- * @param {Boolean} canBeFilled - true if feature.type == FEATURE_TYPES.POLYGON
23
- */
24
- function drawPolygon(ctx, vertices) {
25
- let indices = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [{
26
- offset: 0,
27
- count: 1
28
- }];
29
- let size = arguments.length > 3 ? arguments[3] : undefined;
30
- let extent = arguments.length > 4 ? arguments[4] : undefined;
31
- let invCtxScale = arguments.length > 5 ? arguments[5] : undefined;
32
- let canBeFilled = arguments.length > 6 ? arguments[6] : undefined;
33
- if (vertices.length === 0) {
34
- return;
35
- }
36
- // build contour
37
- const path = new Path2D();
38
- for (const indice of indices) {
39
- if (indice.extent && Extent.intersectsExtent(indice.extent, extent)) {
40
- const offset = indice.offset * size;
41
- const count = offset + indice.count * size;
42
- path.moveTo(vertices[offset], vertices[offset + 1]);
43
- for (let j = offset + size; j < count; j += size) {
44
- path.lineTo(vertices[j], vertices[j + 1]);
45
- }
46
- }
47
- }
48
- style.applyToCanvasPolygon(ctx, path, invCtxScale, canBeFilled);
49
- }
50
- function drawPoint(ctx, x, y, invCtxScale) {
51
- ctx.beginPath();
52
- const opacity = style.point.opacity == undefined ? 1.0 : style.point.opacity;
53
- if (opacity !== ctx.globalAlpha) {
54
- ctx.globalAlpha = opacity;
55
- }
56
- ctx.arc(x, y, (style.point.radius || 3.0) * invCtxScale, 0, 2 * Math.PI, false);
57
- if (style.point.color) {
58
- ctx.fillStyle = style.point.color;
59
- ctx.fill();
60
- }
61
- if (style.point.line) {
62
- ctx.lineWidth = (style.point.width || 1.0) * invCtxScale;
63
- ctx.strokeStyle = style.point.line;
64
- ctx.stroke();
65
- }
66
- }
67
- const coord = new Coordinates('EPSG:4326', 0, 0, 0);
68
- function drawFeature(ctx, feature, extent, invCtxScale) {
69
- const extentDim = extent.planarDimensions();
70
- const scaleRadius = extentDim.x / ctx.canvas.width;
71
- for (const geometry of feature.geometries) {
72
- if (Extent.intersectsExtent(geometry.extent, extent)) {
73
- context.setGeometry(geometry);
74
- if (feature.type === FEATURE_TYPES.POINT && style.point) {
75
- // cross multiplication to know in the extent system the real size of
76
- // the point
77
- const px = (Math.round(style.point.radius * invCtxScale) || 3 * invCtxScale) * scaleRadius;
78
- for (const indice of geometry.indices) {
79
- const offset = indice.offset * feature.size;
80
- const count = offset + indice.count * feature.size;
81
- for (let j = offset; j < count; j += feature.size) {
82
- coord.setFromArray(feature.vertices, j);
83
- if (extent.isPointInside(coord, px)) {
84
- drawPoint(ctx, feature.vertices[j], feature.vertices[j + 1], invCtxScale);
85
- }
86
- }
87
- }
88
- } else {
89
- drawPolygon(ctx, feature.vertices, geometry.indices, feature.size, extent, invCtxScale, feature.type == FEATURE_TYPES.POLYGON);
90
- }
91
- }
92
- }
93
- }
94
- const origin = new THREE.Vector3();
95
- const dimension = new THREE.Vector3(0, 0, 1);
96
- const scale = new THREE.Vector3();
97
- const quaternion = new THREE.Quaternion();
98
- const world2texture = new THREE.Matrix4();
99
- const feature2texture = new THREE.Matrix4();
100
- const worldTextureOrigin = new THREE.Vector3();
101
- const featureExtent = new Extent('EPSG:4326', 0, 0, 0, 0);
102
- export default {
103
- // backgroundColor is a THREE.Color to specify a color to fill the texture
104
- // with, given there is no feature passed in parameter
105
- createTextureFromFeature(collection, extent, sizeTexture, layerStyle, backgroundColor) {
106
- style = layerStyle || defaultStyle;
107
- style.setContext(context);
108
- let texture;
109
- if (collection) {
110
- // A texture is instancied drawn canvas
111
- // origin and dimension are used to transform the feature's coordinates to canvas's space
112
- extent.planarDimensions(dimension);
113
- const c = document.createElement('canvas');
114
- coord.crs = extent.crs;
115
- c.width = sizeTexture;
116
- c.height = sizeTexture;
117
- const ctx = c.getContext('2d');
118
- if (backgroundColor) {
119
- ctx.fillStyle = backgroundColor.getStyle();
120
- ctx.fillRect(0, 0, sizeTexture, sizeTexture);
121
- }
122
-
123
- // Documentation needed !!
124
- ctx.globalCompositeOperation = layerStyle.globalCompositeOperation || 'source-over';
125
- ctx.imageSmoothingEnabled = false;
126
- ctx.lineJoin = 'round';
127
-
128
- // transform extent to feature projection
129
- extent.as(collection.crs, featureExtent);
130
- // transform extent to local system
131
- featureExtent.applyMatrix4(collection.matrixWorldInverse);
132
-
133
- // compute matrix transformation `world2texture` to convert coordinates to texture coordinates
134
- if (collection.isInverted) {
135
- worldTextureOrigin.set(extent.west, extent.north, 0);
136
- scale.set(ctx.canvas.width, -ctx.canvas.height, 1.0).divide(dimension);
137
- } else {
138
- worldTextureOrigin.set(extent.west, extent.south, 0);
139
- scale.set(ctx.canvas.width, ctx.canvas.height, 1.0).divide(dimension);
140
- }
141
- world2texture.compose(worldTextureOrigin.multiply(scale).negate(), quaternion, scale);
142
-
143
- // compute matrix transformation `feature2texture` to convert features coordinates to texture coordinates
144
- feature2texture.multiplyMatrices(world2texture, collection.matrixWorld);
145
- feature2texture.decompose(origin, quaternion, scale);
146
- ctx.setTransform(scale.x, 0, 0, scale.y, origin.x, origin.y);
147
-
148
- // to scale line width and radius circle
149
- const invCtxScale = Math.abs(1 / scale.x);
150
- context.setZoom(extent.zoom);
151
-
152
- // Draw the canvas
153
- for (const feature of collection.features) {
154
- context.setFeature(feature);
155
- drawFeature(ctx, feature, featureExtent, invCtxScale);
156
- }
157
- texture = new THREE.CanvasTexture(c);
158
- texture.flipY = collection.isInverted;
159
- } else if (backgroundColor) {
160
- const data = new Uint8Array(3);
161
- data[0] = backgroundColor.r * 255;
162
- data[1] = backgroundColor.g * 255;
163
- data[2] = backgroundColor.b * 255;
164
- texture = new THREE.DataTexture(data, 1, 1, THREE.RGBAFormat);
165
- } else {
166
- texture = new THREE.Texture();
167
- }
168
- return texture;
169
- }
170
- };
@@ -1,75 +0,0 @@
1
- /*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
- import * as THREE from 'three';
7
- import TileMesh from "../Core/TileMesh.js";
8
- import LayeredMaterial from "../Renderer/LayeredMaterial.js";
9
- import newTileGeometry from "../Core/Prefab/TileBuilder.js";
10
- import ReferLayerProperties from "../Layer/ReferencingLayerProperties.js";
11
- import { geoidLayerIsVisible } from "../Layer/GeoidLayer.js";
12
- const dimensions = new THREE.Vector2();
13
- function setTileFromTiledLayer(tile, tileLayer) {
14
- if (tileLayer.diffuse) {
15
- tile.material.diffuse = tileLayer.diffuse;
16
- }
17
- if (tileLayer.isGlobeLayer) {
18
- // Computes a point used for horizon culling.
19
- // If the point is below the horizon,
20
- // the tile is guaranteed to be below the horizon as well.
21
- tile.horizonCullingPoint = tile.extent.center().as('EPSG:4978').toVector3();
22
- tile.extent.planarDimensions(dimensions).multiplyScalar(THREE.MathUtils.DEG2RAD);
23
-
24
- // alpha is maximum angle between two points of tile
25
- const alpha = dimensions.length();
26
- const h = Math.abs(1.0 / Math.cos(alpha * 0.5));
27
- tile.horizonCullingPoint.setLength(h * tile.horizonCullingPoint.length());
28
- tile.horizonCullingPointElevationScaled = tile.horizonCullingPoint.clone();
29
- }
30
- }
31
- export default {
32
- convert(requester, extent, layer) {
33
- const builder = layer.builder;
34
- const parent = requester;
35
- const level = parent !== undefined ? parent.level + 1 : 0;
36
- const paramsGeometry = {
37
- extent,
38
- level,
39
- segments: layer.segments || 16,
40
- disableSkirt: layer.disableSkirt,
41
- hideSkirt: layer.hideSkirt
42
- };
43
- return newTileGeometry(builder, paramsGeometry).then(result => {
44
- // build tile mesh
45
- result.geometry._count++;
46
- const crsCount = layer.tileMatrixSets.length;
47
- const material = new LayeredMaterial(layer.materialOptions, crsCount);
48
- ReferLayerProperties(material, layer);
49
- const tile = new TileMesh(result.geometry, material, layer, extent, level);
50
- if (parent && parent.isTileMesh) {
51
- // get parent extent transformation
52
- const pTrans = builder.computeSharableExtent(parent.extent);
53
- // place relative to his parent
54
- result.position.sub(pTrans.position).applyQuaternion(pTrans.quaternion.invert());
55
- result.quaternion.premultiply(pTrans.quaternion);
56
- }
57
- tile.position.copy(result.position);
58
- tile.quaternion.copy(result.quaternion);
59
- tile.visible = false;
60
- tile.updateMatrix();
61
- setTileFromTiledLayer(tile, layer);
62
- if (parent) {
63
- tile.geoidHeight = parent.geoidHeight;
64
- const geoidHeight = geoidLayerIsVisible(layer) ? tile.geoidHeight : 0;
65
- tile.setBBoxZ({
66
- min: parent.obb.z.min,
67
- max: parent.obb.z.max,
68
- geoidHeight
69
- });
70
- tile.material.geoidHeight = geoidHeight;
71
- }
72
- return tile;
73
- });
74
- }
75
- };
@@ -1,44 +0,0 @@
1
- import * as THREE from 'three';
2
- import Feature2Texture from "./Feature2Texture.js";
3
- import Extent from "../Core/Geographic/Extent.js";
4
- import CRS from "../Core/Geographic/Crs.js";
5
- const extentTexture = new Extent('EPSG:4326', [0, 0, 0, 0]);
6
- const textureLayer = (texture, layer) => {
7
- texture.generateMipmaps = false;
8
- texture.magFilter = layer.magFilter || THREE.LinearFilter;
9
- texture.minFilter = layer.minFilter || THREE.LinearFilter;
10
- return texture;
11
- };
12
- function textureColorLayer(texture, layer) {
13
- texture.anisotropy = 16;
14
- texture.premultiplyAlpha = layer.transparent;
15
- return textureLayer(texture, layer);
16
- }
17
- export default {
18
- convert(data, destinationTile, layer) {
19
- let texture;
20
- if (data.isFeatureCollection) {
21
- const backgroundLayer = layer.source.backgroundLayer;
22
- const backgroundColor = backgroundLayer && backgroundLayer.paint ? new THREE.Color(backgroundLayer.paint['background-color']) : undefined;
23
- destinationTile.toExtent(CRS.formatToEPSG(layer.crs), extentTexture);
24
- texture = Feature2Texture.createTextureFromFeature(data, extentTexture, layer.subdivisionThreshold, layer.style, backgroundColor);
25
- texture.features = data;
26
- texture.extent = destinationTile;
27
- } else if (data.isTexture) {
28
- texture = data;
29
- } else {
30
- throw new Error('Data type is not supported to convert into texture');
31
- }
32
- if (layer.isColorLayer) {
33
- return textureColorLayer(texture, layer);
34
- } else if (layer.isElevationLayer) {
35
- if (texture.flipY) {
36
- // DataTexture default to false, so make sure other Texture types
37
- // do the same (eg image texture)
38
- // See UV construction for more details
39
- texture.flipY = false;
40
- }
41
- return textureLayer(texture, layer);
42
- }
43
- }
44
- };
@@ -1,131 +0,0 @@
1
- import binaryPropertyAccessor from "./utils/BinaryPropertyAccessor.js";
2
- import { C3DTilesTypes } from "./C3DTilesEnums.js";
3
- const utf8Decoder = new TextDecoder();
4
-
5
- /**
6
- * A 3D Tiles
7
- * [batch
8
- * table](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/BatchTable).
9
- * @property {C3DTilesTypes} type - Used by 3D Tiles extensions
10
- * (e.g. {@link C3DTBatchTableHierarchyExtension}) to know in which context
11
- * (i.e. for which 3D Tiles class) the parsing of the extension should be done.
12
- * @property {number} batchLength - the length of the batch.
13
- * @property {object} content - the content of the batch table in the form:
14
- * {property1: values[], property2: values[], ...}.
15
- * @property {object} extensions - 3D Tiles extensions of the batch table
16
- * stored in the following format:
17
- * {extensioName1: extensionObject1, extensioName2: extensionObject2, ...}
18
- */
19
- class C3DTBatchTable {
20
- /**
21
- * @param {ArrayBuffer} [buffer=new ArrayBuffer()] - batch table buffer to parse
22
- * @param {number} [jsonLength=0] - batch table json part length
23
- * @param {number} [binaryLength=0] - batch table binary part length
24
- * @param {number} [batchLength=0] - the length of the batch.
25
- * @param {Object} [registeredExtensions] - extensions registered to the layer
26
- */
27
- constructor() {
28
- let buffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new ArrayBuffer();
29
- let jsonLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
30
- let binaryLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
31
- let batchLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
32
- let registeredExtensions = arguments.length > 4 ? arguments[4] : undefined;
33
- if (arguments.length === 4 && typeof batchLength === 'object' && !Array.isArray(batchLength) && batchLength !== null) {
34
- console.warn('You most likely used a deprecated constructor of C3DTBatchTable.');
35
- }
36
- if (jsonLength + binaryLength !== buffer.byteLength) {
37
- console.error('3DTiles batch table json length and binary length are not consistent with total buffer' + ' length. The batch table may be wrong.');
38
- }
39
- this.type = C3DTilesTypes.batchtable;
40
- this.batchLength = batchLength;
41
- const jsonBuffer = buffer.slice(0, jsonLength);
42
- const decodedJsonBuffer = utf8Decoder.decode(new Uint8Array(jsonBuffer));
43
- const jsonContent = decodedJsonBuffer === '' ? null : JSON.parse(decodedJsonBuffer);
44
- if (binaryLength > 0) {
45
- const binaryBuffer = buffer.slice(jsonLength, jsonLength + binaryLength);
46
- for (const propKey in jsonContent) {
47
- if (!Object.prototype.hasOwnProperty.call(jsonContent, propKey)) {
48
- continue;
49
- }
50
- const propVal = jsonContent[propKey];
51
- // Batch table entries that have already been parsed from the JSON buffer have an array of values.
52
- if (Array.isArray(propVal)) {
53
- continue;
54
- }
55
- if (typeof propVal?.byteOffset !== 'undefined' && typeof propVal?.componentType !== 'undefined' && typeof propVal?.type !== 'undefined') {
56
- jsonContent[propKey] = binaryPropertyAccessor(binaryBuffer, this.batchLength, propVal.byteOffset, propVal.componentType, propVal.type);
57
- } else {
58
- console.error('Invalid 3D Tiles batch table property that is neither a JSON array nor a valid ' + 'accessor to a binary body');
59
- }
60
- }
61
- }
62
-
63
- // Separate the content and the possible extensions
64
- // When an extension is found, we call its parser and append the
65
- // returned object to batchTable.extensions
66
- // Extensions must be registered in the layer (see an example of this in
67
- // 3dtiles_hierarchy.html)
68
- if (jsonContent && jsonContent.extensions) {
69
- this.extensions = registeredExtensions.parseExtensions(jsonContent.extensions, this.type);
70
- delete jsonContent.extensions;
71
- }
72
-
73
- // Store batch table json content
74
- this.content = jsonContent;
75
- }
76
-
77
- /**
78
- * Creates and returns a javascript object holding the displayable
79
- * information from the batch table and from extensions of the batch table,
80
- * for a given feature (identified with its batchID).
81
- * @param {integer} batchID - id of the feature
82
- * @returns {Object} - displayable information relative to the batch
83
- * table and its extensions. Object is formatted as follow:
84
- * {batchTable:
85
- * {property1: value1
86
- * property2: value2
87
- * ...}
88
- * extensions:
89
- * {extension1:
90
- * {property1: value1
91
- * ...}
92
- * extension2: {...}
93
- * ...}
94
- * }
95
- */
96
- getInfoById(batchID) {
97
- // Verify that the batch ID is valid
98
- if (batchID < 0 && batchID < this.batchLength) {
99
- throw new Error(`Batch Id (${batchID}) must be between 0 and
100
- ${this.batchLength} to access feature properties from the batch
101
- table.`);
102
- }
103
- const featureDisplayableInfo = {};
104
- featureDisplayableInfo.batchTable = {};
105
- // Get properties from batch table content
106
- for (const property in this.content) {
107
- // check that the property is not inherited from prototype chain
108
- if (Object.prototype.hasOwnProperty.call(this.content, property)) {
109
- const val = this.content[property][batchID];
110
- // Property value may be a threejs vector (see 3D Tiles spec and BinaryPropertyAccessor.js)
111
- if (val && (val.isVector2 || val.isVector3 || val.isVector4)) {
112
- featureDisplayableInfo.batchTable[property] = val.toArray();
113
- } else {
114
- featureDisplayableInfo.batchTable[property] = val;
115
- }
116
- }
117
- }
118
-
119
- // Extensions
120
- if (this.extensions) {
121
- featureDisplayableInfo.extensions = {};
122
- for (const extName in this.extensions) {
123
- if (Object.prototype.hasOwnProperty.call(this.extensions, extName)) {
124
- featureDisplayableInfo.extensions[extName] = this.extensions[extName].getInfoById(batchID);
125
- }
126
- }
127
- }
128
- return featureDisplayableInfo;
129
- }
130
- }
131
- export default C3DTBatchTable;
@@ -1,96 +0,0 @@
1
- /**
2
- * Batch Table part of the 3D Tiles
3
- * [Batch Table Hierarchy Extension](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/extensions/3DTILES_batch_table_hierarchy)
4
- * @property {object} classes - The classes as defined in the specification.
5
- * @property {object} inverseHierarchy - InverseHierarchy contains for each
6
- * instance (i.e. georgraphic feature e.g. building, roof, etc.) an array of the
7
- * indexes of its parents. For example, the parents of the instance 0 can be
8
- * found using inverseHierarchy[0].
9
- * @property {number[]} instancesIdxs - For each instance of the extension,
10
- * contains a javascript object with classId and instanceIdx. classId is the id
11
- * of the class (from this.classes) of the instance. instanceIdx is the index of
12
- * the instance in this class. Goal: Ease the retrieval of the properties of an
13
- * instance.
14
- */
15
- class C3DTBatchTableHierarchyExtension {
16
- /**
17
- * Constructor of the C3DTBatchTableHierarchyExtension class.
18
- * @param {Object} json - The parsed json of the batch table part of the 3D
19
- * Tiles [Batch Table Hierarchy Extension](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/extensions/3DTILES_batch_table_hierarchy)
20
- */
21
- constructor(json) {
22
- this.classes = json.classes;
23
- this.inverseHierarchy = {};
24
- this.instancesIdxs = [];
25
-
26
- // Counts the number of instances of a class
27
- const classCounter = {};
28
- let parentIdsCounter = 0;
29
-
30
- // if omitted, parentCounts is an array of length instancesLength,
31
- // where all values are 1 (cf. spec)
32
- let parentCounts = json.parentCounts;
33
- if (parentCounts === undefined) {
34
- parentCounts = new Array(json.instancesLength);
35
- parentCounts.fill(1);
36
- }
37
-
38
- // for each instance
39
- for (let i = 0; i < json.instancesLength; i++) {
40
- // for each parent of the current instance
41
- for (let j = 0; j < parentCounts[i]; j++) {
42
- // When an instance's parentId points to itself, then it has no
43
- // parent" (cf. spec)
44
- if (i !== json.parentIds[parentIdsCounter]) {
45
- if (this.inverseHierarchy[i] === undefined) {
46
- this.inverseHierarchy[i] = [];
47
- }
48
- this.inverseHierarchy[i].push(json.parentIds[parentIdsCounter]);
49
- parentIdsCounter++;
50
- }
51
- }
52
- const classId = json.classIds[i];
53
- if (classCounter[classId] === undefined) {
54
- classCounter[classId] = 0;
55
- }
56
- this.instancesIdxs[i] = {
57
- classId,
58
- instanceIdx: classCounter[classId]
59
- };
60
- classCounter[classId]++;
61
- }
62
- }
63
-
64
- /**
65
- * Creates and returns a javascript object holding the displayable
66
- * information relative to this extension for a given feature.
67
- * @param {integer} featureId - id of the feature
68
- * @returns {Object} - displayable information relative to this
69
- * extension, for the feature with id=featureId and for its parents
70
- */
71
- getInfoById(featureId) {
72
- const instanceProperties = {};
73
- // get feature class name
74
- const instanceClassId = this.instancesIdxs[featureId].classId;
75
- const featureClass = this.classes[instanceClassId].name;
76
- // get feature properties and values
77
- const instanceIdx = this.instancesIdxs[featureId].instanceIdx;
78
- const instances = this.classes[instanceClassId].instances;
79
- for (const key in instances) {
80
- if (Object.prototype.hasOwnProperty.call(instances, key)) {
81
- instanceProperties[key] = instances[key][instanceIdx];
82
- }
83
- }
84
- // create return object: className: {featureProperties and values}
85
- const pickingInfo = {};
86
- pickingInfo[featureClass] = instanceProperties;
87
- // If this feature has parent(s), recurse on them
88
- if (this.inverseHierarchy && this.inverseHierarchy[featureId]) {
89
- for (const parentID of this.inverseHierarchy[featureId]) {
90
- Object.assign(pickingInfo, this.getInfoById(parentID));
91
- }
92
- }
93
- return pickingInfo;
94
- }
95
- }
96
- export default C3DTBatchTableHierarchyExtension;
@@ -1,157 +0,0 @@
1
- import * as THREE from 'three';
2
- import Ellipsoid from "../Math/Ellipsoid.js";
3
- import Coordinates from "../Geographic/Coordinates.js";
4
- import { C3DTilesTypes, C3DTilesBoundingVolumeTypes } from "./C3DTilesEnums.js";
5
- const ellipsoid = new Ellipsoid();
6
-
7
- // bounding box scratch variables
8
- const boxSize = new THREE.Vector3();
9
- const boxCenter = new THREE.Vector3();
10
-
11
- // Bounding region scratch variables
12
- const southEastUpCarto = new Coordinates('EPSG:4326');
13
- const southEastUpVec3 = new THREE.Vector3();
14
- const northWestBottomCarto = new Coordinates('EPSG:4326');
15
- const northWestBottomVec3 = new THREE.Vector3();
16
- const radiusScratch = new THREE.Vector3();
17
-
18
- // Culling scratch value
19
- const worldCoordinateCenter = new THREE.Vector3();
20
-
21
- /**
22
- * Bounding region is converted to a bounding sphere to simplify and speed computation and culling. This function
23
- * computes a sphere enclosing the bounding region.
24
- * @param {Object} region - the parsed json from the tile representing the region
25
- * @param {THREE.Matrix4} tileMatrixInverse - the inverse transformation matrix of the tile to transform the produced
26
- * sphere from a global to a reference local to the tile
27
- * @return {THREE.Sphere} a sphere enclosing the given region
28
- */
29
- function initFromRegion(region, tileMatrixInverse) {
30
- const east = region[2];
31
- const west = region[0];
32
- const south = region[1];
33
- const north = region[3];
34
- const minHeight = region[4];
35
- const maxHeight = region[5];
36
- const eastDeg = THREE.MathUtils.radToDeg(east);
37
- const westDeg = THREE.MathUtils.radToDeg(west);
38
- const southDeg = THREE.MathUtils.radToDeg(south);
39
- const northDeg = THREE.MathUtils.radToDeg(north);
40
- northWestBottomCarto.setFromValues(westDeg, northDeg, minHeight);
41
- ellipsoid.cartographicToCartesian(northWestBottomCarto, northWestBottomVec3);
42
- southEastUpCarto.setFromValues(eastDeg, southDeg, maxHeight);
43
- ellipsoid.cartographicToCartesian(southEastUpCarto, southEastUpVec3);
44
- const regionCenter = new THREE.Vector3();
45
- regionCenter.lerpVectors(northWestBottomVec3, southEastUpVec3, 0.5);
46
- const radius = radiusScratch.subVectors(northWestBottomVec3, southEastUpVec3).length() / 2;
47
- const sphere = new THREE.Sphere(regionCenter, radius);
48
- sphere.applyMatrix4(tileMatrixInverse);
49
- return sphere;
50
- }
51
-
52
- /**
53
- * Create a bounding box from a json describing a box in a 3D Tiles tile.
54
- * @param {Object} box - the parsed json from the tile representing the box
55
- * @return {THREE.Box3} the bounding box of the tile
56
- */
57
- function initFromBox(box) {
58
- // box[0], box[1], box[2] = center of the box
59
- // box[3], box[4], box[5] = x axis direction and half-length
60
- // box[6], box[7], box[8] = y axis direction and half-length
61
- // box[9], box[10], box[11] = z axis direction and half-length
62
- boxCenter.set(box[0], box[1], box[2]);
63
- boxSize.set(box[3], box[7], box[11]).multiplyScalar(2);
64
- const box3 = new THREE.Box3();
65
- box3.setFromCenterAndSize(boxCenter, boxSize);
66
- return box3;
67
- }
68
-
69
- /**
70
- * Creats a bounding sphere from a json describing a sphere in a 3D Tiles tile.
71
- * @param {Object} sphere - the parsed json from the tile representing the sphere
72
- * @returns {THREE.Sphere} the bounding sphere of the tile
73
- */
74
- function initFromSphere(sphere) {
75
- const sphereCenter = new THREE.Vector3();
76
- sphereCenter.set(sphere[0], sphere[1], sphere[2]);
77
- return new THREE.Sphere(sphereCenter, sphere[3]);
78
- }
79
-
80
- /**
81
- * [bounding volume](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json)
82
- * Used to represent bounding volumes and viewer request volumes. The input bounding volume (from the dataset) can be a
83
- * box, a sphere or a region. Regions are transformed to spheres internally for simplification of parsing and to speed
84
- * up computations such as culling.
85
- * @property {C3DTilesTypes} type - Used by 3D Tiles extensions
86
- * (e.g. {@link C3DTBatchTableHierarchyExtension}) to know in which context
87
- * (i.e. for which 3D Tiles class) the parsing of the extension should be done.
88
- * @property {String} initialVolumeType - the initial volume type to be able to dissociate spheres
89
- * and regions if needed since both are converted to spheres (one of {@link C3DTilesBoundingVolumeTypes})
90
- * @property {THREE.Box3|THREE.Sphere} volume - The 3D bounding volume created. Can be a THREE.Box3 for bounding volumes
91
- * of types box or a THREE.Sphere for bounding volumes of type sphere or region.
92
- * @property {object} extensions - 3D Tiles extensions of the bounding volume
93
- * stored in the following format:
94
- * {extensioName1: extensionObject1, extensioName2: extensionObject2, ...}
95
- */
96
- class C3DTBoundingVolume {
97
- constructor(json, tileMatrixInverse, registeredExtensions) {
98
- this.type = C3DTilesTypes.boundingVolume;
99
- if (json.region) {
100
- this.initialVolumeType = C3DTilesBoundingVolumeTypes.region;
101
- this.volume = initFromRegion(json.region, tileMatrixInverse);
102
- } else if (json.box) {
103
- this.initialVolumeType = C3DTilesBoundingVolumeTypes.box;
104
- this.volume = initFromBox(json.box);
105
- } else if (json.sphere) {
106
- this.initialVolumeType = C3DTilesBoundingVolumeTypes.sphere;
107
- this.volume = initFromSphere(json.sphere);
108
- } else {
109
- throw new Error(`Unknown bounding volume type: ${json}. 3D Tiles nodes must have a bounding volume of type
110
- region, box or sphere.`);
111
- }
112
- if (json.extensions) {
113
- this.extensions = registeredExtensions.parseExtensions(json.extensions, this.type);
114
- }
115
- }
116
-
117
- /**
118
- * Performs camera frustum culling on bounding volumes.
119
- * @param {Camera} camera - the camera to perform culling for
120
- * @param {THREE.Matrix4} tileMatrixWorld - the world matrix of the tile
121
- * @returns {boolean} true if the tile should be culled out (bounding volume not in camera frustum), false otherwise.
122
- */
123
- boundingVolumeCulling(camera, tileMatrixWorld) {
124
- if (this.initialVolumeType === C3DTilesBoundingVolumeTypes.box) {
125
- return !camera.isBox3Visible(this.volume, tileMatrixWorld);
126
- } else if (this.initialVolumeType === C3DTilesBoundingVolumeTypes.sphere || this.initialVolumeType === C3DTilesBoundingVolumeTypes.region) {
127
- return !camera.isSphereVisible(this.volume, tileMatrixWorld);
128
- } else {
129
- throw new Error('Unknown bounding volume type.');
130
- }
131
- }
132
-
133
- /**
134
- * Checks if the camera is inside the [viewer request volumes](https://github.com/CesiumGS/3d-tiles/tree/main/specification#viewer-request-volume).
135
- * @param {Camera} camera - the camera to perform culling for
136
- * @param {THREE.Matrix4} tileMatrixWorld - the world matrix of the tile
137
- * @returns {boolean} true if the camera is outside the viewer request volume, false otherwise.
138
- */
139
- viewerRequestVolumeCulling(camera, tileMatrixWorld) {
140
- if (this.initialVolumeType === C3DTilesBoundingVolumeTypes.region) {
141
- console.warn('Region viewerRequestVolume not yet supported');
142
- return true;
143
- }
144
- if (this.initialVolumeType === C3DTilesBoundingVolumeTypes.box) {
145
- console.warn('Bounding box viewerRequestVolume not yet supported');
146
- return true;
147
- }
148
- if (this.initialVolumeType === C3DTilesBoundingVolumeTypes.sphere) {
149
- worldCoordinateCenter.copy(this.volume.center);
150
- worldCoordinateCenter.applyMatrix4(tileMatrixWorld);
151
- // To check the distance between the center sphere and the camera
152
- return !(camera.camera3D.position.distanceTo(worldCoordinateCenter) <= this.volume.radius);
153
- }
154
- return false;
155
- }
156
- }
157
- export default C3DTBoundingVolume;