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,56 +0,0 @@
1
- export function lab2rgb(lab) {
2
- let y = (lab[0] + 16) / 116;
3
- let x = lab[1] / 500 + y;
4
- let z = y - lab[2] / 200;
5
- let r;
6
- let g;
7
- let b;
8
- x = 0.95047 * (x * x * x > 0.008856 ? x * x * x : (x - 16 / 116) / 7.787);
9
- y = 1.00000 * (y * y * y > 0.008856 ? y * y * y : (y - 16 / 116) / 7.787);
10
- z = 1.08883 * (z * z * z > 0.008856 ? z * z * z : (z - 16 / 116) / 7.787);
11
- r = x * 3.2406 + y * -1.5372 + z * -0.4986;
12
- g = x * -0.9689 + y * 1.8758 + z * 0.0415;
13
- b = x * 0.0557 + y * -0.2040 + z * 1.0570;
14
- r = r > 0.0031308 ? 1.055 * r ** (1 / 2.4) - 0.055 : 12.92 * r;
15
- g = g > 0.0031308 ? 1.055 * g ** (1 / 2.4) - 0.055 : 12.92 * g;
16
- b = b > 0.0031308 ? 1.055 * b ** (1 / 2.4) - 0.055 : 12.92 * b;
17
- return [Math.max(0, Math.min(1, r)) * 255, Math.max(0, Math.min(1, g)) * 255, Math.max(0, Math.min(1, b)) * 255];
18
- }
19
- export function rgb2lab(rgb) {
20
- let r = rgb.r || rgb[0] / 255;
21
- let g = rgb.g || rgb[1] / 255;
22
- let b = rgb.b || rgb[2] / 255;
23
- let x;
24
- let y;
25
- let z;
26
- r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
27
- g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
28
- b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
29
- x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;
30
- y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;
31
- z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;
32
- x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
33
- y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
34
- z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
35
- return [116 * y - 16, 500 * (x - y), 200 * (y - z)];
36
- }
37
-
38
- // calculate the perceptual distance between colors in CIELAB
39
- // https://github.com/THEjoezack/ColorMine/blob/master/ColorMine/ColorSpaces/Comparisons/Cie94Comparison.cs
40
- export function deltaE(rgbA, rgbB) {
41
- const labA = rgb2lab(rgbA);
42
- const labB = rgb2lab(rgbB);
43
- const deltaL = labA[0] - labB[0];
44
- const deltaA = labA[1] - labB[1];
45
- const deltaB = labA[2] - labB[2];
46
- const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);
47
- const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);
48
- const deltaC = c1 - c2;
49
- let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;
50
- deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);
51
- const deltaLKlsl = deltaL / 1.0;
52
- const deltaCkcsc = deltaC / (1.0 + 0.045 * c1);
53
- const deltaHkhsh = deltaH / (1.0 + 0.015 * c1);
54
- const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;
55
- return i < 0 ? 0 : Math.sqrt(i);
56
- }
@@ -1,115 +0,0 @@
1
- import { ImageryLayers } from "../Layer/Layer.js";
2
- function updateLayersOrdering(geometryLayer, imageryLayers) {
3
- const sequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers);
4
- const cO = function (object) {
5
- if (object.material?.setSequence) {
6
- object.material.setSequence(sequence);
7
- }
8
- };
9
- for (const node of geometryLayer.level0Nodes) {
10
- node.traverse(cO);
11
- }
12
- }
13
- export const COLOR_LAYERS_ORDER_CHANGED = 'layers-order-changed';
14
-
15
- /**
16
- * Utilitary to organize {@link ColorLayer} in a {@link View}.
17
- *
18
- * @module ColorLayersOrdering
19
- */
20
- export default {
21
- /**
22
- * Moves up in the layer list. This function has no effect if the layer is
23
- * moved to its current index.
24
- *
25
- * @param {View} view - The view in which the layer is moved up.
26
- * @param {string} layerId - The ID of the layer to move.
27
- *
28
- * @example
29
- * itowns.ColorLayersOrdering.moveLayerUp(viewer, 'idLayerToUp');
30
- */
31
- moveLayerUp(view, layerId) {
32
- const imageryLayers = view.getLayers(l => l.isColorLayer);
33
- const layer = view.getLayerById(layerId);
34
- if (layer) {
35
- const previousSequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers);
36
- ImageryLayers.moveLayerUp(layer, imageryLayers);
37
- updateLayersOrdering(view.tileLayer, imageryLayers);
38
- view.dispatchEvent({
39
- type: COLOR_LAYERS_ORDER_CHANGED,
40
- previous: {
41
- sequence: previousSequence
42
- },
43
- new: {
44
- sequence: ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers)
45
- }
46
- });
47
- view.notifyChange(view.tileLayer);
48
- } else {
49
- throw new Error(`${layerId} isn't color layer`);
50
- }
51
- },
52
- /**
53
- * Moves down in the layer list. This function has no effect if the layer is
54
- * moved to its current index.
55
- *
56
- * @param {View} view - The view in which the layer is moved down.
57
- * @param {string} layerId - The ID of the layer to move.
58
- *
59
- * @example
60
- * itowns.ColorLayersOrdering.moveLayerDown(viewer, 'idLayerToDown');
61
- */
62
- moveLayerDown(view, layerId) {
63
- const imageryLayers = view.getLayers(l => l.isColorLayer);
64
- const layer = view.getLayerById(layerId);
65
- if (layer) {
66
- const previousSequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers);
67
- ImageryLayers.moveLayerDown(layer, imageryLayers);
68
- updateLayersOrdering(view.tileLayer, imageryLayers);
69
- view.dispatchEvent({
70
- type: COLOR_LAYERS_ORDER_CHANGED,
71
- previous: {
72
- sequence: previousSequence
73
- },
74
- new: {
75
- sequence: ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers)
76
- }
77
- });
78
- view.notifyChange(view.tileLayer);
79
- } else {
80
- throw new Error(`${layerId} isn't color layer`);
81
- }
82
- },
83
- /**
84
- * Moves a specific layer to a specific index in the layer list. This
85
- * function has no effect if the layer is moved to its current index.
86
- *
87
- * @param {View} view - The view in which the layer is moved.
88
- * @param {string} layerId - The ID of the layer to move.
89
- * @param {number} index - The index to move the layer to.
90
- *
91
- * @example
92
- * itowns.ColorLayersOrdering.moveLayerToIndex(viewer, 'idLayerToChangeIndex', 2);
93
- */
94
- moveLayerToIndex(view, layerId, index) {
95
- const imageryLayers = view.getLayers(l => l.isColorLayer);
96
- const layer = view.getLayerById(layerId);
97
- if (layer) {
98
- const previousSequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers);
99
- ImageryLayers.moveLayerToIndex(layer, index, imageryLayers);
100
- updateLayersOrdering(view.tileLayer, imageryLayers);
101
- view.dispatchEvent({
102
- type: COLOR_LAYERS_ORDER_CHANGED,
103
- previous: {
104
- sequence: previousSequence
105
- },
106
- new: {
107
- sequence: ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers)
108
- }
109
- });
110
- view.notifyChange(view.tileLayer);
111
- } else {
112
- throw new Error(`${layerId} isn't color layer`);
113
- }
114
- }
115
- };
@@ -1,31 +0,0 @@
1
- import * as THREE from 'three';
2
- export default {
3
- setDefineMapping(object, PROPERTY, mapping) {
4
- Object.keys(mapping).forEach(key => {
5
- object.defines[`${PROPERTY}_${key}`] = mapping[key];
6
- });
7
- },
8
- setDefineProperty(object, property, PROPERTY, initValue) {
9
- object.defines[PROPERTY] = initValue;
10
- Object.defineProperty(object, property, {
11
- get: () => object.defines[PROPERTY],
12
- set: value => {
13
- if (object.defines[PROPERTY] != value) {
14
- object.defines[PROPERTY] = value;
15
- object.needsUpdate = true;
16
- }
17
- }
18
- });
19
- },
20
- setUniformProperty(object, property, initValue) {
21
- object.uniforms[property] = new THREE.Uniform(initValue);
22
- Object.defineProperty(object, property, {
23
- get: () => object.uniforms[property].value,
24
- set: value => {
25
- if (object.uniforms[property].value != value) {
26
- object.uniforms[property].value = value;
27
- }
28
- }
29
- });
30
- }
31
- };
@@ -1,192 +0,0 @@
1
- import * as THREE from 'three';
2
- import GlobeLayer from "../Core/Prefab/Globe/GlobeLayer.js";
3
- function isIntersectedOrOverlaped(a, b) {
4
- return !(a.left > b.right || a.right < b.left || a.top > b.bottom || a.bottom < b.top);
5
- }
6
- const frustum = new THREE.Frustum();
7
-
8
- // A grid to manage labels on the screen.
9
- export class ScreenGrid {
10
- constructor() {
11
- let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 12;
12
- let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
13
- let width = arguments.length > 2 ? arguments[2] : undefined;
14
- let height = arguments.length > 3 ? arguments[3] : undefined;
15
- this.x = x;
16
- this.y = y;
17
- this.grid = [];
18
- this.visible = [];
19
- this.resize();
20
- this.reset();
21
- this.width = width;
22
- this.height = height;
23
- }
24
-
25
- // Reset each cell and hidden and visible.
26
- reset() {
27
- for (let i = 0; i < this.x; i++) {
28
- for (let j = 0; j < this.y; j++) {
29
- // Splice is prefered to creating a new array, in term of memory
30
- this.grid[i][j].splice(0, this.grid[i][j].length);
31
- }
32
- }
33
- this.visible = [];
34
- }
35
-
36
- // Add rows if needed — but don't delete anything else. Columns are taken
37
- // care in reset().
38
- resize() {
39
- for (let i = 0; i < this.x; i++) {
40
- if (!this.grid[i]) {
41
- this.grid[i] = [];
42
- }
43
- for (let j = 0; j < this.y; j++) {
44
- if (!this.grid[i][j]) {
45
- this.grid[i][j] = [];
46
- }
47
- }
48
- }
49
- }
50
-
51
- // Insert a label using its boundaries. It is either added to hidden or
52
- // visible, given the result. The grid is populated with true for every
53
- // filled cell.
54
- insert(obj) {
55
- const minx = Math.max(0, Math.floor(obj.boundaries.left / this.width * this.x));
56
- const maxx = Math.min(this.x - 1, Math.floor(obj.boundaries.right / this.width * this.x));
57
- const miny = Math.max(0, Math.floor(obj.boundaries.top / this.height * this.y));
58
- const maxy = Math.min(this.y - 1, Math.floor(obj.boundaries.bottom / this.height * this.y));
59
- for (let i = minx; i <= maxx; i++) {
60
- for (let j = miny; j <= maxy; j++) {
61
- if (this.grid[i][j].length > 0) {
62
- if (this.grid[i][j].some(l => isIntersectedOrOverlaped(l.boundaries, obj.boundaries))) {
63
- obj.visible = false;
64
- return false;
65
- }
66
- }
67
- }
68
- }
69
- for (let i = minx; i <= maxx; i++) {
70
- for (let j = miny; j <= maxy; j++) {
71
- this.grid[i][j].push(obj);
72
- }
73
- }
74
- return true;
75
- }
76
- }
77
- const worldPosition = new THREE.Vector3();
78
-
79
- /**
80
- * This renderer is inspired by the
81
- * [`THREE.CSS2DRenderer`](https://threejs.org/docs/#examples/en/renderers/CSS2DRenderer).
82
- * It is instanciated in `c3DEngine`, as another renderer to handles Labels.
83
- */
84
- class Label2DRenderer {
85
- constructor() {
86
- this.domElement = document.createElement('div');
87
- this.domElement.style.overflow = 'hidden';
88
- this.domElement.style.position = 'absolute';
89
- this.domElement.style.top = '0';
90
- this.domElement.style.height = '100%';
91
- this.domElement.style.width = '100%';
92
- this.domElement.style.zIndex = 1;
93
-
94
- // Used to destroy labels that are not added to the DOM
95
- this.garbage = document.createElement('div');
96
- this.garbage.style.display = 'none';
97
- this.domElement.appendChild(this.garbage);
98
- this.halfWidth = 0;
99
- this.halfHeight = 0;
100
- this.grid = new ScreenGrid();
101
- this.infoTileLayer = undefined;
102
- }
103
- setSize(width, height) {
104
- this.domElement.style.width = `${width}`;
105
- this.domElement.style.height = `${height}`;
106
- this.halfWidth = width / 2;
107
- this.halfHeight = height / 2;
108
- this.grid.width = width;
109
- this.grid.height = height;
110
- this.grid.x = Math.ceil(width / 20);
111
- this.grid.y = Math.ceil(height / 20);
112
- this.grid.resize();
113
- }
114
- registerLayer(layer) {
115
- this.domElement.appendChild(layer.domElement.dom);
116
- }
117
- render(scene, camera) {
118
- const labelLayers = this.infoTileLayer && this.infoTileLayer.layer.attachedLayers.filter(l => l.isLabelLayer && l.visible);
119
- if (labelLayers.length == 0) {
120
- return;
121
- }
122
- this.grid.reset();
123
-
124
- // set camera frustum
125
- frustum.setFromProjectionMatrix(camera.projectionMatrix);
126
- labelLayers.forEach(labelLayer => {
127
- labelLayer.submittedLabelNodes.forEach(labelsNode => {
128
- labelsNode.labels.forEach(label => {
129
- labelsNode.updatePosition(label);
130
- this.culling(label, camera);
131
- });
132
- labelsNode.domElements.labels.show();
133
- labelsNode.needsUpdate = false;
134
- });
135
- });
136
-
137
- // sort by order, then by visibility inside those subsets
138
- // https://docs.mapbox.com/help/troubleshooting/optimize-map-label-placement/#label-hierarchy
139
- this.grid.visible.sort((a, b) => {
140
- const r = b.order - a.order;
141
- if (r == 0) {
142
- if (!a.visible && b.visible) {
143
- return 1;
144
- } else {
145
- return -1;
146
- }
147
- } else {
148
- return r;
149
- }
150
- });
151
- this.grid.visible.forEach(l => {
152
- if (this.grid.insert(l)) {
153
- l.visible = true;
154
- l.updateCSSPosition();
155
- } else {
156
- l.visible = false;
157
- }
158
- });
159
- labelLayers.forEach(labelLayer => {
160
- labelLayer.toHide.children.forEach(labelsNode => labelsNode.domElements?.labels.hide());
161
- labelLayer.toHide.clear();
162
- });
163
- }
164
- culling(label, camera) {
165
- label.getWorldPosition(worldPosition);
166
- // Check if the frustum contains tle label
167
- if (!frustum.containsPoint(worldPosition.applyMatrix4(camera.matrixWorldInverse)) ||
168
- // Check if globe horizon culls the label
169
- // Do some horizon culling (if possible) if the tiles level is small enough.
170
- label.horizonCullingPoint && GlobeLayer.horizonCulling(label.horizonCullingPoint)
171
- // Why do we might need this part ?
172
- // || // Check if content isn't present in visible labels
173
- // this.grid.visible.some((l) => {
174
- // // TODO for icon without text filter by position
175
- // const textContent = label.content.textContent;
176
- // return textContent !== '' && l.content.textContent.toLowerCase() == textContent.toLowerCase();
177
- // })
178
- ) {
179
- label.visible = false;
180
- } else {
181
- // projecting world position label
182
- worldPosition.applyMatrix4(camera.projectionMatrix);
183
- label.updateProjectedPosition(worldPosition.x * this.halfWidth + this.halfWidth, -worldPosition.y * this.halfHeight + this.halfHeight);
184
- this.grid.visible.push(label);
185
- }
186
- }
187
- removeLabelDOM(label) {
188
- this.garbage.appendChild(label.content);
189
- this.garbage.innerHTML = '';
190
- }
191
- }
192
- export default Label2DRenderer;
@@ -1,243 +0,0 @@
1
- import * as THREE from 'three';
2
- /* babel-plugin-inline-import './Shader/TileVS.glsl' */
3
- const TileVS = "#include <itowns/precision_qualifier>\n#include <common>\n#include <itowns/elevation_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#if NUM_CRS > 1\nattribute float uv_1;\n#endif\n\nuniform bool lightingEnabled;\nvarying vec2 vHighPrecisionZW;\n\n#if MODE == MODE_FINAL\n#include <fog_pars_vertex>\nvarying vec3 vUv;\nvarying vec3 vNormal;\n#endif\nvoid main() {\n #include <begin_vertex>\n #include <itowns/elevation_vertex>\n #include <itowns/geoid_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n vHighPrecisionZW = gl_Position.zw;\n#if MODE == MODE_FINAL\n #include <fog_vertex>\n #if NUM_CRS > 1\n vUv = vec3(uv, (uv_1 > 0.) ? uv_1 : uv.y); // set uv_1 = uv if uv_1 is undefined\n #else\n vUv = vec3(uv, 0.0);\n #endif\n vNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );\n#endif\n}\n";
4
- /* babel-plugin-inline-import './Shader/TileFS.glsl' */
5
- const TileFS = "#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#include <itowns/pitUV>\n#include <itowns/color_layers_pars_fragment>\n#if MODE == MODE_FINAL\n#include <itowns/fog_pars_fragment>\n#include <itowns/overlay_pars_fragment>\n#include <itowns/lighting_pars_fragment>\n#endif\n#include <itowns/mode_pars_fragment>\n\nuniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vUv; // uv.x/uv_1.x, uv.y, uv_1.y\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n #include <logdepthbuf_fragment>\n\n#if MODE == MODE_ID\n\n #include <itowns/mode_id_fragment>\n\n#elif MODE == MODE_DEPTH\n\n #include <itowns/mode_depth_fragment>\n\n#else\n\n gl_FragColor = vec4(diffuse, opacity);\n\n uvs[0] = vec3(vUv.xy, 0.);\n\n#if NUM_CRS > 1\n uvs[1] = vec3(vUv.x, fract(vUv.z), floor(vUv.z));\n#endif\n\n vec4 color;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_FS_TEXTURES; i ++ ) {\n color = getLayerColor( i , colorTextures[ i ], colorOffsetScales[ i ], colorLayers[ i ]);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n }\n\n #if defined(DEBUG)\n if (showOutline) {\n #pragma unroll_loop\n for ( int i = 0; i < NUM_CRS; i ++) {\n color = getOutlineColor( outlineColors[ i ], uvs[ i ].xy);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n }\n }\n #endif\n\n #include <itowns/fog_fragment>\n #include <itowns/lighting_fragment>\n #include <itowns/overlay_fragment>\n\n#endif\n}\n";
6
- import ShaderUtils from "./Shader/ShaderUtils.js";
7
- import Capabilities from "../Core/System/Capabilities.js";
8
- import RenderMode from "./RenderMode.js";
9
- import CommonMaterial from "./CommonMaterial.js";
10
- const identityOffsetScale = new THREE.Vector4(0.0, 0.0, 1.0, 1.0);
11
- const defaultTex = new THREE.Texture();
12
-
13
- // from three.js packDepthToRGBA
14
- const UnpackDownscale = 255 / 256; // 0..1 -> fraction (excluding 1)
15
- const bitSh = new THREE.Vector4(UnpackDownscale, UnpackDownscale / 256.0, UnpackDownscale / (256.0 * 256.0), UnpackDownscale / (256.0 * 256.0 * 256.0));
16
- export function unpack1K(color, factor) {
17
- return factor ? bitSh.dot(color) * factor : bitSh.dot(color);
18
- }
19
-
20
- // Max sampler color count to LayeredMaterial
21
- // Because there's a statement limitation to unroll, in getColorAtIdUv method
22
- const maxSamplersColorCount = 15;
23
- const samplersElevationCount = 1;
24
- export function getMaxColorSamplerUnitsCount() {
25
- const maxSamplerUnitsCount = Capabilities.getMaxTextureUnitsCount();
26
- return Math.min(maxSamplerUnitsCount - samplersElevationCount, maxSamplersColorCount);
27
- }
28
- export const colorLayerEffects = {
29
- noEffect: 0,
30
- removeLightColor: 1,
31
- removeWhiteColor: 2,
32
- customEffect: 3
33
- };
34
- const defaultStructLayer = {
35
- bias: 0,
36
- noDataValue: -99999,
37
- zmin: 0,
38
- zmax: 0,
39
- scale: 0,
40
- mode: 0,
41
- textureOffset: 0,
42
- opacity: 0,
43
- crs: 0,
44
- effect_parameter: 0,
45
- effect_type: colorLayerEffects.noEffect,
46
- transparent: false
47
- };
48
- function updateLayersUniforms(uniforms, olayers, max) {
49
- // prepare convenient access to elevation or color uniforms
50
- const layers = uniforms.layers.value;
51
- const textures = uniforms.textures.value;
52
- const offsetScales = uniforms.offsetScales.value;
53
- const textureCount = uniforms.textureCount;
54
-
55
- // flatten the 2d array [i,j] -> layers[_layerIds[i]].textures[j]
56
- let count = 0;
57
- for (const layer of olayers) {
58
- // textureOffset property is added to RasterTile
59
- layer.textureOffset = count;
60
- for (let i = 0, il = layer.textures.length; i < il; ++i, ++count) {
61
- if (count < max) {
62
- offsetScales[count] = layer.offsetScales[i];
63
- textures[count] = layer.textures[i];
64
- layers[count] = layer;
65
- }
66
- }
67
- }
68
- if (count > max) {
69
- console.warn(`LayeredMaterial: Not enough texture units (${max} < ${count}), excess textures have been discarded.`);
70
- }
71
- textureCount.value = count;
72
-
73
- // WebGL 2.0 doesn't support the undefined uniforms.
74
- // So the undefined uniforms are defined by default value.
75
- for (let i = count; i < textures.length; i++) {
76
- textures[i] = defaultTex;
77
- offsetScales[i] = identityOffsetScale;
78
- layers[i] = defaultStructLayer;
79
- }
80
- }
81
- export const ELEVATION_MODES = {
82
- RGBA: 0,
83
- COLOR: 1,
84
- DATA: 2
85
- };
86
- let nbSamplers;
87
- const fragmentShader = [];
88
- class LayeredMaterial extends THREE.ShaderMaterial {
89
- #_visible = true;
90
- constructor() {
91
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
92
- let crsCount = arguments.length > 1 ? arguments[1] : undefined;
93
- super(options);
94
- nbSamplers = nbSamplers || [samplersElevationCount, getMaxColorSamplerUnitsCount()];
95
- this.defines.NUM_VS_TEXTURES = nbSamplers[0];
96
- this.defines.NUM_FS_TEXTURES = nbSamplers[1];
97
- // TODO: We do not use the fog from the scene, is this a desired
98
- // behavior?
99
- this.defines.USE_FOG = 1;
100
- this.defines.NUM_CRS = crsCount;
101
- CommonMaterial.setDefineMapping(this, 'ELEVATION', ELEVATION_MODES);
102
- CommonMaterial.setDefineMapping(this, 'MODE', RenderMode.MODES);
103
- CommonMaterial.setDefineProperty(this, 'mode', 'MODE', RenderMode.MODES.FINAL);
104
- this.vertexShader = TileVS;
105
- // three loop unrolling of ShaderMaterial only supports integer bounds,
106
- // see https://github.com/mrdoob/three.js/issues/28020
107
- fragmentShader[crsCount] = fragmentShader[crsCount] || ShaderUtils.unrollLoops(TileFS, this.defines);
108
- this.fragmentShader = fragmentShader[crsCount];
109
-
110
- // Color uniforms
111
- CommonMaterial.setUniformProperty(this, 'diffuse', new THREE.Color(0.04, 0.23, 0.35));
112
- CommonMaterial.setUniformProperty(this, 'opacity', this.opacity);
113
-
114
- // Lighting uniforms
115
- CommonMaterial.setUniformProperty(this, 'lightingEnabled', false);
116
- CommonMaterial.setUniformProperty(this, 'lightPosition', new THREE.Vector3(-0.5, 0.0, 1.0));
117
-
118
- // Misc properties
119
- CommonMaterial.setUniformProperty(this, 'fogDistance', 1000000000.0);
120
- CommonMaterial.setUniformProperty(this, 'fogColor', new THREE.Color(0.76, 0.85, 1.0));
121
- CommonMaterial.setUniformProperty(this, 'overlayAlpha', 0);
122
- CommonMaterial.setUniformProperty(this, 'overlayColor', new THREE.Color(1.0, 0.3, 0.0));
123
- CommonMaterial.setUniformProperty(this, 'objectId', 0);
124
- CommonMaterial.setUniformProperty(this, 'geoidHeight', 0.0);
125
-
126
- // > 0 produces gaps,
127
- // < 0 causes oversampling of textures
128
- // = 0 causes sampling artefacts due to bad estimation of texture-uv gradients
129
- // best is a small negative number
130
- CommonMaterial.setUniformProperty(this, 'minBorderDistance', -0.01);
131
-
132
- // LayeredMaterialLayers
133
- this.layers = [];
134
- this.elevationLayerIds = [];
135
- this.colorLayerIds = [];
136
-
137
- // elevation layer uniforms, to be updated using updateUniforms()
138
- this.uniforms.elevationLayers = new THREE.Uniform(new Array(nbSamplers[0]).fill(defaultStructLayer));
139
- this.uniforms.elevationTextures = new THREE.Uniform(new Array(nbSamplers[0]).fill(defaultTex));
140
- this.uniforms.elevationOffsetScales = new THREE.Uniform(new Array(nbSamplers[0]).fill(identityOffsetScale));
141
- this.uniforms.elevationTextureCount = new THREE.Uniform(0);
142
-
143
- // color layer uniforms, to be updated using updateUniforms()
144
- this.uniforms.colorLayers = new THREE.Uniform(new Array(nbSamplers[1]).fill(defaultStructLayer));
145
- this.uniforms.colorTextures = new THREE.Uniform(new Array(nbSamplers[1]).fill(defaultTex));
146
- this.uniforms.colorOffsetScales = new THREE.Uniform(new Array(nbSamplers[1]).fill(identityOffsetScale));
147
- this.uniforms.colorTextureCount = new THREE.Uniform(0);
148
-
149
- // can't do an ES6 setter/getter here
150
- Object.defineProperty(this, 'visible', {
151
- // Knowing the visibility of a `LayeredMaterial` is useful. For example in a
152
- // `GlobeView`, if you zoom in, "parent" tiles seems hidden; in fact, there
153
- // are not, it is only their material (so `LayeredMaterial`) that is set to
154
- // not visible.
155
-
156
- // Adding an event when changing this property can be useful to hide others
157
- // things, like in `TileDebug`, or in later PR to come (#1303 for example).
158
- //
159
- // TODO : verify if there is a better mechanism to avoid this event
160
- get() {
161
- return this.#_visible;
162
- },
163
- set(v) {
164
- if (this.#_visible != v) {
165
- this.#_visible = v;
166
- this.dispatchEvent({
167
- type: v ? 'shown' : 'hidden'
168
- });
169
- }
170
- }
171
- });
172
- }
173
- getUniformByType(type) {
174
- return {
175
- layers: this.uniforms[`${type}Layers`],
176
- textures: this.uniforms[`${type}Textures`],
177
- offsetScales: this.uniforms[`${type}OffsetScales`],
178
- textureCount: this.uniforms[`${type}TextureCount`]
179
- };
180
- }
181
- updateLayersUniforms() {
182
- const colorlayers = this.layers.filter(l => this.colorLayerIds.includes(l.id) && l.visible && l.opacity > 0);
183
- colorlayers.sort((a, b) => this.colorLayerIds.indexOf(a.id) - this.colorLayerIds.indexOf(b.id));
184
- updateLayersUniforms(this.getUniformByType('color'), colorlayers, this.defines.NUM_FS_TEXTURES);
185
- if (this.elevationLayerIds.some(id => this.getLayer(id)) || this.uniforms.elevationTextureCount.value && !this.elevationLayerIds.length) {
186
- const elevationLayer = this.getElevationLayer() ? [this.getElevationLayer()] : [];
187
- updateLayersUniforms(this.getUniformByType('elevation'), elevationLayer, this.defines.NUM_VS_TEXTURES);
188
- }
189
- this.layersNeedUpdate = false;
190
- }
191
- dispose() {
192
- this.dispatchEvent({
193
- type: 'dispose'
194
- });
195
- this.layers.forEach(l => l.dispose(true));
196
- this.layers.length = 0;
197
- this.layersNeedUpdate = true;
198
- }
199
-
200
- // TODO: rename to setColorLayerIds and add setElevationLayerIds ?
201
- setSequence(sequenceLayer) {
202
- this.colorLayerIds = sequenceLayer;
203
- this.layersNeedUpdate = true;
204
- }
205
- setSequenceElevation(layerId) {
206
- this.elevationLayerIds[0] = layerId;
207
- this.layersNeedUpdate = true;
208
- }
209
- removeLayer(layerId) {
210
- const index = this.layers.findIndex(l => l.id === layerId);
211
- if (index > -1) {
212
- this.layers[index].dispose();
213
- this.layers.splice(index, 1);
214
- const idSeq = this.colorLayerIds.indexOf(layerId);
215
- if (idSeq > -1) {
216
- this.colorLayerIds.splice(idSeq, 1);
217
- } else {
218
- this.elevationLayerIds = [];
219
- }
220
- }
221
- }
222
- addLayer(rasterNode) {
223
- if (rasterNode.layer.id in this.layers) {
224
- console.warn('The "{layer.id}" layer was already present in the material, overwritting.');
225
- }
226
- this.layers.push(rasterNode);
227
- }
228
- getLayer(id) {
229
- return this.layers.find(l => l.id === id);
230
- }
231
- getLayers(ids) {
232
- return this.layers.filter(l => ids.includes(l.id));
233
- }
234
- getElevationLayer() {
235
- return this.layers.find(l => l.id === this.elevationLayerIds[0]);
236
- }
237
- setElevationScale(scale) {
238
- if (this.elevationLayerIds.length) {
239
- this.getElevationLayer().scale = scale;
240
- }
241
- }
242
- }
243
- export default LayeredMaterial;