itowns 2.44.3-next.40 → 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 (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,175 +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 (style.zoom.min > style.context.zoom || style.zoom.max <= style.context.zoom) {
75
- return;
76
- }
77
- if (feature.type === FEATURE_TYPES.POINT && style.point) {
78
- // cross multiplication to know in the extent system the real size of
79
- // the point
80
- const px = (Math.round(style.point.radius * invCtxScale) || 3 * invCtxScale) * scaleRadius;
81
- for (const indice of geometry.indices) {
82
- const offset = indice.offset * feature.size;
83
- const count = offset + indice.count * feature.size;
84
- for (let j = offset; j < count; j += feature.size) {
85
- coord.setFromArray(feature.vertices, j);
86
- if (extent.isPointInside(coord, px)) {
87
- drawPoint(ctx, feature.vertices[j], feature.vertices[j + 1], invCtxScale);
88
- }
89
- }
90
- }
91
- } else {
92
- drawPolygon(ctx, feature.vertices, geometry.indices, feature.size, extent, invCtxScale, feature.type == FEATURE_TYPES.POLYGON);
93
- }
94
- }
95
- }
96
- }
97
- const origin = new THREE.Vector3();
98
- const dimension = new THREE.Vector3(0, 0, 1);
99
- const scale = new THREE.Vector3();
100
- const quaternion = new THREE.Quaternion();
101
- const world2texture = new THREE.Matrix4();
102
- const feature2texture = new THREE.Matrix4();
103
- const worldTextureOrigin = new THREE.Vector3();
104
- const featureExtent = new Extent('EPSG:4326', 0, 0, 0, 0);
105
- export default {
106
- // backgroundColor is a THREE.Color to specify a color to fill the texture
107
- // with, given there is no feature passed in parameter
108
- createTextureFromFeature(collection, extent, sizeTexture, layerStyle, backgroundColor) {
109
- style = layerStyle || defaultStyle;
110
- style.setContext(context);
111
- let texture;
112
- if (collection) {
113
- // A texture is instancied drawn canvas
114
- // origin and dimension are used to transform the feature's coordinates to canvas's space
115
- extent.planarDimensions(dimension);
116
- const c = document.createElement('canvas');
117
- coord.crs = extent.crs;
118
- c.width = sizeTexture;
119
- c.height = sizeTexture;
120
- const ctx = c.getContext('2d', {
121
- willReadFrequently: true
122
- });
123
- if (backgroundColor) {
124
- ctx.fillStyle = backgroundColor.getStyle();
125
- ctx.fillRect(0, 0, sizeTexture, sizeTexture);
126
- }
127
-
128
- // Documentation needed !!
129
- ctx.globalCompositeOperation = layerStyle.globalCompositeOperation || 'source-over';
130
- ctx.imageSmoothingEnabled = false;
131
- ctx.lineJoin = 'round';
132
-
133
- // transform extent to feature projection
134
- extent.as(collection.crs, featureExtent);
135
- // transform extent to local system
136
- featureExtent.applyMatrix4(collection.matrixWorldInverse);
137
-
138
- // compute matrix transformation `world2texture` to convert coordinates to texture coordinates
139
- if (collection.isInverted) {
140
- worldTextureOrigin.set(extent.west, extent.north, 0);
141
- scale.set(ctx.canvas.width, -ctx.canvas.height, 1.0).divide(dimension);
142
- } else {
143
- worldTextureOrigin.set(extent.west, extent.south, 0);
144
- scale.set(ctx.canvas.width, ctx.canvas.height, 1.0).divide(dimension);
145
- }
146
- world2texture.compose(worldTextureOrigin.multiply(scale).negate(), quaternion, scale);
147
-
148
- // compute matrix transformation `feature2texture` to convert features coordinates to texture coordinates
149
- feature2texture.multiplyMatrices(world2texture, collection.matrixWorld);
150
- feature2texture.decompose(origin, quaternion, scale);
151
- ctx.setTransform(scale.x, 0, 0, scale.y, origin.x, origin.y);
152
-
153
- // to scale line width and radius circle
154
- const invCtxScale = Math.abs(1 / scale.x);
155
- context.setZoom(extent.zoom);
156
-
157
- // Draw the canvas
158
- for (const feature of collection.features) {
159
- context.setFeature(feature);
160
- drawFeature(ctx, feature, featureExtent, invCtxScale);
161
- }
162
- texture = new THREE.CanvasTexture(c);
163
- texture.flipY = collection.isInverted;
164
- } else if (backgroundColor) {
165
- const data = new Uint8Array(3);
166
- data[0] = backgroundColor.r * 255;
167
- data[1] = backgroundColor.g * 255;
168
- data[2] = backgroundColor.b * 255;
169
- texture = new THREE.DataTexture(data, 1, 1, THREE.RGBAFormat);
170
- } else {
171
- texture = new THREE.Texture();
172
- }
173
- return texture;
174
- }
175
- };
@@ -1,70 +0,0 @@
1
- import * as THREE from 'three';
2
- import TileMesh from "../Core/TileMesh.js";
3
- import LayeredMaterial from "../Renderer/LayeredMaterial.js";
4
- import { newTileGeometry } from "../Core/Prefab/TileBuilder.js";
5
- import ReferLayerProperties from "../Layer/ReferencingLayerProperties.js";
6
- import { geoidLayerIsVisible } from "../Layer/GeoidLayer.js";
7
- const dimensions = new THREE.Vector2();
8
- function setTileFromTiledLayer(tile, tileLayer) {
9
- if (tileLayer.diffuse) {
10
- tile.material.diffuse = tileLayer.diffuse;
11
- }
12
- if (tileLayer.isGlobeLayer) {
13
- // Computes a point used for horizon culling.
14
- // If the point is below the horizon,
15
- // the tile is guaranteed to be below the horizon as well.
16
- tile.horizonCullingPoint = tile.extent.center().as('EPSG:4978').toVector3();
17
- tile.extent.planarDimensions(dimensions).multiplyScalar(THREE.MathUtils.DEG2RAD);
18
-
19
- // alpha is maximum angle between two points of tile
20
- const alpha = dimensions.length();
21
- const h = Math.abs(1.0 / Math.cos(alpha * 0.5));
22
- tile.horizonCullingPoint.setLength(h * tile.horizonCullingPoint.length());
23
- tile.horizonCullingPointElevationScaled = tile.horizonCullingPoint.clone();
24
- }
25
- }
26
- export default {
27
- convert(requester, extent, layer) {
28
- const builder = layer.builder;
29
- const parent = requester;
30
- const level = parent !== undefined ? parent.level + 1 : 0;
31
- const paramsGeometry = {
32
- extent,
33
- level,
34
- segments: layer.segments || 16,
35
- disableSkirt: layer.disableSkirt,
36
- hideSkirt: layer.hideSkirt
37
- };
38
- return newTileGeometry(builder, paramsGeometry).then(result => {
39
- // build tile mesh
40
- result.geometry.increaseRefCount();
41
- const crsCount = layer.tileMatrixSets.length;
42
- const material = new LayeredMaterial(layer.materialOptions, crsCount);
43
- ReferLayerProperties(material, layer);
44
- const tile = new TileMesh(result.geometry, material, layer, extent, level);
45
- if (parent && parent.isTileMesh) {
46
- // get parent extent transformation
47
- const pTrans = builder.computeShareableExtent(parent.extent);
48
- // place relative to his parent
49
- result.position.sub(pTrans.position).applyQuaternion(pTrans.quaternion.invert());
50
- result.quaternion.premultiply(pTrans.quaternion);
51
- }
52
- tile.position.copy(result.position);
53
- tile.quaternion.copy(result.quaternion);
54
- tile.visible = false;
55
- tile.updateMatrix();
56
- setTileFromTiledLayer(tile, layer);
57
- if (parent) {
58
- tile.geoidHeight = parent.geoidHeight;
59
- const geoidHeight = geoidLayerIsVisible(layer) ? tile.geoidHeight : 0;
60
- tile.setBBoxZ({
61
- min: parent.obb.z.min,
62
- max: parent.obb.z.max,
63
- geoidHeight
64
- });
65
- tile.material.geoidHeight = geoidHeight;
66
- }
67
- return tile;
68
- });
69
- }
70
- };
@@ -1,43 +0,0 @@
1
- import * as THREE from 'three';
2
- import Feature2Texture from "./Feature2Texture.js";
3
- import Extent from "../Core/Geographic/Extent.js";
4
- const extentTexture = new Extent('EPSG:4326');
5
- const textureLayer = (texture, layer) => {
6
- texture.generateMipmaps = false;
7
- texture.magFilter = layer.magFilter || THREE.LinearFilter;
8
- texture.minFilter = layer.minFilter || THREE.LinearFilter;
9
- return texture;
10
- };
11
- function textureColorLayer(texture, layer) {
12
- texture.anisotropy = 16;
13
- texture.premultiplyAlpha = layer.transparent;
14
- return textureLayer(texture, layer);
15
- }
16
- export default {
17
- convert(data, destinationTile, layer) {
18
- let texture;
19
- if (data.isFeatureCollection) {
20
- const backgroundLayer = layer.source.backgroundLayer;
21
- const backgroundColor = backgroundLayer && backgroundLayer.paint ? new THREE.Color(backgroundLayer.paint['background-color']) : undefined;
22
- destinationTile.toExtent(layer.crs, extentTexture);
23
- texture = Feature2Texture.createTextureFromFeature(data, extentTexture, layer.subdivisionThreshold, layer.style, backgroundColor);
24
- texture.features = data;
25
- texture.extent = destinationTile;
26
- } else if (data.isTexture) {
27
- texture = data;
28
- } else {
29
- throw new Error('Data type is not supported to convert into texture');
30
- }
31
- if (layer.isColorLayer) {
32
- return textureColorLayer(texture, layer);
33
- } else if (layer.isElevationLayer) {
34
- if (texture.flipY) {
35
- // DataTexture default to false, so make sure other Texture types
36
- // do the same (eg image texture)
37
- // See UV construction for more details
38
- texture.flipY = false;
39
- }
40
- return textureLayer(texture, layer);
41
- }
42
- }
43
- };
@@ -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;