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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -608
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -726
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/TileGeometry.js +0 -40
  100. package/lib/Core/TileMesh.js +0 -108
  101. package/lib/Core/View.js +0 -1109
  102. package/lib/Layer/C3DTilesLayer.js +0 -455
  103. package/lib/Layer/ColorLayer.js +0 -128
  104. package/lib/Layer/CopcLayer.js +0 -58
  105. package/lib/Layer/ElevationLayer.js +0 -107
  106. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  107. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  108. package/lib/Layer/GeoidLayer.js +0 -80
  109. package/lib/Layer/GeometryLayer.js +0 -202
  110. package/lib/Layer/InfoLayer.js +0 -64
  111. package/lib/Layer/LabelLayer.js +0 -452
  112. package/lib/Layer/Layer.js +0 -304
  113. package/lib/Layer/LayerUpdateState.js +0 -89
  114. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  115. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  116. package/lib/Layer/OrientedImageLayer.js +0 -222
  117. package/lib/Layer/PointCloudLayer.js +0 -359
  118. package/lib/Layer/Potree2Layer.js +0 -164
  119. package/lib/Layer/PotreeLayer.js +0 -65
  120. package/lib/Layer/RasterLayer.js +0 -27
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  122. package/lib/Layer/TiledGeometryLayer.js +0 -403
  123. package/lib/Loader/LASLoader.js +0 -193
  124. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  125. package/lib/Loader/Potree2Loader.js +0 -207
  126. package/lib/Main.js +0 -115
  127. package/lib/MainBundle.js +0 -4
  128. package/lib/Parser/B3dmParser.js +0 -174
  129. package/lib/Parser/CameraCalibrationParser.js +0 -94
  130. package/lib/Parser/GDFParser.js +0 -72
  131. package/lib/Parser/GTXParser.js +0 -75
  132. package/lib/Parser/GeoJsonParser.js +0 -212
  133. package/lib/Parser/GpxParser.js +0 -25
  134. package/lib/Parser/ISGParser.js +0 -71
  135. package/lib/Parser/KMLParser.js +0 -25
  136. package/lib/Parser/LASParser.js +0 -137
  137. package/lib/Parser/MapBoxUrlParser.js +0 -83
  138. package/lib/Parser/PntsParser.js +0 -131
  139. package/lib/Parser/Potree2BinParser.js +0 -92
  140. package/lib/Parser/PotreeBinParser.js +0 -106
  141. package/lib/Parser/PotreeCinParser.js +0 -29
  142. package/lib/Parser/ShapefileParser.js +0 -78
  143. package/lib/Parser/VectorTileParser.js +0 -202
  144. package/lib/Parser/XbilParser.js +0 -108
  145. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  146. package/lib/Parser/iGLTFLoader.js +0 -168
  147. package/lib/Process/3dTilesProcessing.js +0 -304
  148. package/lib/Process/FeatureProcessing.js +0 -76
  149. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  150. package/lib/Process/ObjectRemovalHelper.js +0 -97
  151. package/lib/Process/handlerNodeError.js +0 -23
  152. package/lib/Provider/3dTilesProvider.js +0 -149
  153. package/lib/Provider/DataSourceProvider.js +0 -8
  154. package/lib/Provider/Fetcher.js +0 -229
  155. package/lib/Provider/PointCloudProvider.js +0 -45
  156. package/lib/Provider/TileProvider.js +0 -16
  157. package/lib/Provider/URLBuilder.js +0 -105
  158. package/lib/Renderer/Camera.js +0 -281
  159. package/lib/Renderer/Color.js +0 -56
  160. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  161. package/lib/Renderer/CommonMaterial.js +0 -31
  162. package/lib/Renderer/Label2DRenderer.js +0 -190
  163. package/lib/Renderer/LayeredMaterial.js +0 -243
  164. package/lib/Renderer/OBB.js +0 -153
  165. package/lib/Renderer/OrientedImageCamera.js +0 -118
  166. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  167. package/lib/Renderer/PointsMaterial.js +0 -485
  168. package/lib/Renderer/RasterTile.js +0 -209
  169. package/lib/Renderer/RenderMode.js +0 -31
  170. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  171. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  172. package/lib/Renderer/SphereHelper.js +0 -23
  173. package/lib/Renderer/WebXR.js +0 -51
  174. package/lib/Renderer/c3DEngine.js +0 -214
  175. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  176. package/lib/Source/C3DTilesIonSource.js +0 -54
  177. package/lib/Source/C3DTilesSource.js +0 -30
  178. package/lib/Source/CopcSource.js +0 -115
  179. package/lib/Source/EntwinePointTileSource.js +0 -62
  180. package/lib/Source/FileSource.js +0 -189
  181. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  182. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  183. package/lib/Source/OGC3DTilesSource.js +0 -21
  184. package/lib/Source/OrientedImageSource.js +0 -59
  185. package/lib/Source/Potree2Source.js +0 -167
  186. package/lib/Source/PotreeSource.js +0 -82
  187. package/lib/Source/Source.js +0 -223
  188. package/lib/Source/TMSSource.js +0 -143
  189. package/lib/Source/VectorTilesSource.js +0 -178
  190. package/lib/Source/WFSSource.js +0 -165
  191. package/lib/Source/WMSSource.js +0 -130
  192. package/lib/Source/WMTSSource.js +0 -86
  193. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  194. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  195. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  196. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  197. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  198. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  199. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  200. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  201. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  202. package/lib/Utils/CameraUtils.js +0 -555
  203. package/lib/Utils/DEMUtils.js +0 -350
  204. package/lib/Utils/FeaturesUtils.js +0 -156
  205. package/lib/Utils/Gradients.js +0 -16
  206. package/lib/Utils/OrientationUtils.js +0 -457
  207. package/lib/Utils/ThreeUtils.js +0 -115
  208. package/lib/Utils/gui/C3DTilesStyle.js +0 -216
  209. package/lib/Utils/gui/Main.js +0 -7
  210. package/lib/Utils/gui/Minimap.js +0 -154
  211. package/lib/Utils/gui/Navigation.js +0 -245
  212. package/lib/Utils/gui/Scale.js +0 -107
  213. package/lib/Utils/gui/Searchbar.js +0 -234
  214. package/lib/Utils/gui/Widget.js +0 -80
  215. package/lib/Utils/placeObjectOnGround.js +0 -137
  216. package/lib/Worker/LASLoaderWorker.js +0 -19
  217. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,485 +0,0 @@
1
- import * as THREE from 'three';
2
- /* babel-plugin-inline-import './Shader/PointsVS.glsl' */
3
- const PointsVS = "#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec4 vColor; // color_pars_vertex\n\n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\n\n#define NB_CLASS 8.\n\nuniform float size;\nuniform float scale;\n\nuniform bool picking;\nuniform int mode;\n\nuniform vec2 elevationRange;\nuniform vec2 intensityRange;\nuniform vec2 angleRange;\n\nuniform sampler2D classificationTexture;\nuniform sampler2D discreteTexture;\nuniform sampler2D gradientTexture;\nuniform int sizeMode;\nuniform float minAttenuatedSize;\nuniform float maxAttenuatedSize;\n\nattribute vec4 unique_id;\nattribute float intensity;\nattribute float classification;\nattribute float pointSourceID;\n\nattribute float returnNumber;\nattribute float numberOfReturns;\nattribute float scanAngle;\n\nvoid main() {\n vColor = vec4(1.0);\n if (picking) {\n vColor = unique_id;\n } else {\n if (mode == PNTS_MODE_CLASSIFICATION) {\n vec2 uv = vec2(classification/255., 0.5);\n vColor = texture2D(classificationTexture, uv);\n } else if (mode == PNTS_MODE_NORMAL) {\n vColor.rgb = abs(normal);\n } else if (mode == PNTS_MODE_COLOR) {\n#if defined(USE_COLOR)\n vColor.rgb = color.rgb;\n#elif defined(USE_COLOR_ALPHA)\n vColor = color;\n#endif\n } else if (mode == PNTS_MODE_RETURN_NUMBER) {\n vec2 uv = vec2(returnNumber/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_TYPE) {\n float returnType;\n if (returnNumber > numberOfReturns) {\n returnType = 4.;\n } else if (returnNumber == 1.) {\n if (numberOfReturns == 1.) {\n // single\n returnType = 0.;\n } else {\n // first\n returnType = 1.;\n }\n } else {\n if (returnNumber == numberOfReturns) {\n // last\n returnType = 3.;\n } else {\n // intermediate\n returnType = 2.;\n }\n }\n vec2 uv = vec2(returnType/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_COUNT) {\n vec2 uv = vec2(numberOfReturns/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_POINT_SOURCE_ID) {\n vec2 uv = vec2(mod(pointSourceID, NB_CLASS)/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_SCAN_ANGLE) {\n float i = (scanAngle - angleRange.x) / (angleRange.y - angleRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_INTENSITY) {\n float i = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_ELEVATION) {\n float z = (modelMatrix * vec4(position, 1.0)).z;\n float i = (z - elevationRange.x) / (elevationRange.y - elevationRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n }\n }\n\n#define USE_COLOR_ALPHA\n#include <morphcolor_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <project_vertex>\n\n gl_PointSize = size;\n\n if (sizeMode == PNTS_SIZE_MODE_ATTENUATED) {\n bool isPerspective = isPerspectiveMatrix(projectionMatrix);\n\n if (isPerspective) {\n gl_PointSize *= scale / -mvPosition.z;\n gl_PointSize = clamp(gl_PointSize, minAttenuatedSize, maxAttenuatedSize);\n }\n }\n\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <fog_vertex>\n}\n";
4
- /* babel-plugin-inline-import './Shader/PointsFS.glsl' */
5
- const PointsFS = "#define USE_COLOR_ALPHA\n\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nuniform bool picking;\nuniform int shape;\n\nvoid main() {\n\n// Early discard (clipping planes and shape)\n#include <clipping_planes_fragment>\n if (shape == PNTS_SHAPE_CIRCLE) {\n //circular rendering in glsl\n if ((length(gl_PointCoord - 0.5) > 0.5)) {\n discard;\n }\n }\n\n#include <logdepthbuf_fragment>\n\n vec4 diffuseColor = vec4(diffuse, opacity);\n#include <map_particle_fragment>\n#include <color_fragment>\n\n#include <alphatest_fragment>\n#include <alphahash_fragment>\n\n vec3 outgoingLight = diffuseColor.rgb;\n#include <opaque_fragment> // gl_FragColor\n#include <tonemapping_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n\n}\n";
6
- import CommonMaterial from "./CommonMaterial.js";
7
- import Gradients from "../Utils/Gradients.js";
8
- export const PNTS_MODE = {
9
- COLOR: 0,
10
- INTENSITY: 1,
11
- CLASSIFICATION: 2,
12
- ELEVATION: 3,
13
- RETURN_NUMBER: 4,
14
- RETURN_TYPE: 5,
15
- RETURN_COUNT: 6,
16
- POINT_SOURCE_ID: 7,
17
- SCAN_ANGLE: 8,
18
- NORMAL: 9
19
- };
20
- export const PNTS_SHAPE = {
21
- CIRCLE: 0,
22
- SQUARE: 1
23
- };
24
- export const PNTS_SIZE_MODE = {
25
- VALUE: 0,
26
- ATTENUATED: 1
27
- };
28
- const white = new THREE.Color(1.0, 1.0, 1.0);
29
-
30
- /**
31
- * Every lidar point can have a classification assigned to it that defines
32
- * the type of object that has reflected the laser pulse. Lidar points can be
33
- * classified into a number of categories including bare earth or ground,
34
- * top of canopy, and water. The different classes are defined using numeric
35
- * integer codes in the files.
36
- *
37
- * @typedef {Object} Classification
38
- * @property {boolean} visible - category visibility,
39
- * @property {string} name - category name,
40
- * @property {THREE.Color} color - category color,
41
- * @property {number} opacity - category opacity,
42
- */
43
-
44
- export const ClassificationScheme = {
45
- DEFAULT: {
46
- 0: {
47
- visible: true,
48
- name: 'never classified',
49
- color: new THREE.Color(0.5, 0.5, 0.5),
50
- opacity: 1.0
51
- },
52
- 1: {
53
- visible: true,
54
- name: 'unclassified',
55
- color: new THREE.Color(0.5, 0.5, 0.5),
56
- opacity: 1.0
57
- },
58
- 2: {
59
- visible: true,
60
- name: 'ground',
61
- color: new THREE.Color(0.63, 0.32, 0.18),
62
- opacity: 1.0
63
- },
64
- 3: {
65
- visible: true,
66
- name: 'low vegetation',
67
- color: new THREE.Color(0.0, 1.0, 0.0),
68
- opacity: 1.0
69
- },
70
- 4: {
71
- visible: true,
72
- name: 'medium vegetation',
73
- color: new THREE.Color(0.0, 0.8, 0.0),
74
- opacity: 1.0
75
- },
76
- 5: {
77
- visible: true,
78
- name: 'high vegetation',
79
- color: new THREE.Color(0.0, 0.6, 0.0),
80
- opacity: 1.0
81
- },
82
- 6: {
83
- visible: true,
84
- name: 'building',
85
- color: new THREE.Color(1.0, 0.66, 0.0),
86
- opacity: 1.0
87
- },
88
- 7: {
89
- visible: true,
90
- name: 'low point(noise)',
91
- color: new THREE.Color(1.0, 0.0, 1.0),
92
- opacity: 1.0
93
- },
94
- 8: {
95
- visible: true,
96
- name: 'key-point',
97
- color: new THREE.Color(1.0, 0.0, 0.0),
98
- opacity: 1.0
99
- },
100
- 9: {
101
- visible: true,
102
- name: 'water',
103
- color: new THREE.Color(0.0, 0.0, 1.0),
104
- opacity: 1.0
105
- },
106
- 10: {
107
- visible: true,
108
- name: 'rail',
109
- color: new THREE.Color(0.8, 0.8, 1.0),
110
- opacity: 1.0
111
- },
112
- 11: {
113
- visible: true,
114
- name: 'road Surface',
115
- color: new THREE.Color(0.4, 0.4, 0.7),
116
- opacity: 1.0
117
- },
118
- 12: {
119
- visible: true,
120
- name: 'overlap',
121
- color: new THREE.Color(1.0, 1.0, 0.0),
122
- opacity: 1.0
123
- },
124
- DEFAULT: {
125
- visible: true,
126
- name: 'default',
127
- color: new THREE.Color(0.3, 0.6, 0.6),
128
- opacity: 1.0
129
- }
130
- }
131
- };
132
- const DiscreteScheme = {
133
- DEFAULT: {
134
- 0: {
135
- visible: true,
136
- name: '0',
137
- color: new THREE.Color('rgb(67, 99, 216)'),
138
- opacity: 1.0
139
- },
140
- 1: {
141
- visible: true,
142
- name: '1',
143
- color: new THREE.Color('rgb(60, 180, 75);'),
144
- opacity: 1.0
145
- },
146
- 2: {
147
- visible: true,
148
- name: '2',
149
- color: new THREE.Color('rgb(255, 255, 25)'),
150
- opacity: 1.0
151
- },
152
- 3: {
153
- visible: true,
154
- name: '3',
155
- color: new THREE.Color('rgb(145, 30, 180)'),
156
- opacity: 1.0
157
- },
158
- 4: {
159
- visible: true,
160
- name: '4',
161
- color: new THREE.Color('rgb(245, 130, 49)'),
162
- opacity: 1.0
163
- },
164
- 5: {
165
- visible: true,
166
- name: '5',
167
- color: new THREE.Color('rgb(230, 25, 75)'),
168
- opacity: 1.0
169
- },
170
- 6: {
171
- visible: true,
172
- name: '6',
173
- color: new THREE.Color('rgb(66, 212, 244)'),
174
- opacity: 1.0
175
- },
176
- 7: {
177
- visible: true,
178
- name: '7',
179
- color: new THREE.Color('rgb(240, 50, 230)'),
180
- opacity: 1.0
181
- },
182
- DEFAULT: {
183
- visible: true,
184
- name: 'default',
185
- color: white,
186
- opacity: 1.0
187
- }
188
- }
189
- };
190
-
191
- // Taken from Potree. Copyright (c) 2011-2020, Markus Schütz All rights reserved.
192
- // https://github.com/potree/potree/blob/develop/src/materials/PointCloudMaterial.js
193
- function generateGradientTexture(gradient) {
194
- const size = 64;
195
-
196
- // create canvas
197
- const canvas = document.createElement('canvas');
198
- canvas.width = size;
199
- canvas.height = size;
200
-
201
- // get context
202
- const context = canvas.getContext('2d');
203
-
204
- // draw gradient
205
- context.rect(0, 0, size, size);
206
- const ctxGradient = context.createLinearGradient(0, 0, size, size);
207
- for (let i = 0; i < gradient.length; i++) {
208
- const step = gradient[i];
209
- ctxGradient.addColorStop(step[0], `#${step[1].getHexString()}`);
210
- }
211
- context.fillStyle = ctxGradient;
212
- context.fill();
213
- const texture = new THREE.CanvasTexture(canvas);
214
- texture.needsUpdate = true;
215
- texture.minFilter = THREE.LinearFilter;
216
- texture.wrap = THREE.RepeatWrapping;
217
- texture.repeat = 2;
218
- return texture;
219
- }
220
- function recomputeTexture(scheme, texture, nbClass) {
221
- let needTransparency;
222
- const data = texture.image.data;
223
- const width = texture.image.width;
224
- if (!nbClass) {
225
- nbClass = Object.keys(scheme).length;
226
- }
227
- for (let i = 0; i < width; i++) {
228
- let color;
229
- let opacity;
230
- let visible = true;
231
- if (scheme[i]) {
232
- color = scheme[i].color;
233
- visible = scheme[i].visible;
234
- opacity = scheme[i].opacity;
235
- } else if (scheme[i % nbClass]) {
236
- color = scheme[i % nbClass].color;
237
- visible = scheme[i % nbClass].visible;
238
- opacity = scheme[i % nbClass].opacity;
239
- } else if (scheme.DEFAULT) {
240
- color = scheme.DEFAULT.color;
241
- visible = scheme.DEFAULT.visible;
242
- opacity = scheme.DEFAULT.opacity;
243
- } else {
244
- color = white;
245
- opacity = 1.0;
246
- }
247
- const j = 4 * i;
248
- data[j + 0] = parseInt(255 * color.r, 10);
249
- data[j + 1] = parseInt(255 * color.g, 10);
250
- data[j + 2] = parseInt(255 * color.b, 10);
251
- data[j + 3] = visible ? parseInt(255 * opacity, 10) : 0;
252
- needTransparency = needTransparency || opacity < 1 || !visible;
253
- }
254
- texture.needsUpdate = true;
255
- return needTransparency;
256
- }
257
- class PointsMaterial extends THREE.ShaderMaterial {
258
- /**
259
- * @class PointsMaterial
260
- * @param {object} [options={}] The options
261
- * @param {number} [options.size=0] size point
262
- * @param {number} [options.mode=PNTS_MODE.COLOR] display mode.
263
- * @param {number} [options.shape=PNTS_SHAPE.CIRCLE] rendered points shape.
264
- * @param {THREE.Vector4} [options.overlayColor=new THREE.Vector4(0, 0, 0, 0)] overlay color.
265
- * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range.
266
- * @param {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range.
267
- * @param {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range.
268
- * @param {Scheme} [options.classificationScheme] LUT for point classification colorization.
269
- * @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
270
- * @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
271
- * (Default value will be the 'SPECTRAL' gradient from Utils/Gradients)
272
- * @param {number} [options.sizeMode=PNTS_SIZE_MODE.VALUE] point cloud size mode. Only 'VALUE' or 'ATTENUATED' are possible. VALUE use constant size, ATTENUATED compute size depending on distance from point to camera.
273
- * @param {number} [options.minAttenuatedSize=3] minimum scale used by 'ATTENUATED' size mode
274
- * @param {number} [options.maxAttenuatedSize=10] maximum scale used by 'ATTENUATED' size mode
275
- *
276
- * @property {Scheme} classificationScheme - Color scheme for point classification values.
277
- * @property {Scheme} discreteScheme - Color scheme for all other discrete values.
278
- * @property {object} gradients - Descriptions of all available gradients.
279
- * @property {object} gradient - Description of the gradient to use for display.
280
- * @property {THREE.CanvasTexture} gradientTexture - The texture generate from the choosen gradient.
281
- *
282
- * @example
283
- * // change color category classification
284
- * const pointMaterial = new PointsMaterial();
285
- * pointMaterial.classification[3].color.setStyle('red');
286
- * pointMaterial.recomputeClassification();
287
- */
288
- constructor() {
289
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
290
- const gradients = {
291
- ...options.gradient,
292
- ...Gradients
293
- };
294
- options.gradient = Object.values(gradients)[0];
295
- const {
296
- intensityRange = new THREE.Vector2(1, 65536),
297
- elevationRange = new THREE.Vector2(0, 1000),
298
- angleRange = new THREE.Vector2(-90, 90),
299
- classificationScheme = ClassificationScheme.DEFAULT,
300
- discreteScheme = DiscreteScheme.DEFAULT,
301
- size = 1,
302
- mode = PNTS_MODE.COLOR,
303
- shape = PNTS_SHAPE.CIRCLE,
304
- sizeMode = PNTS_SIZE_MODE.ATTENUATED,
305
- minAttenuatedSize = 3,
306
- maxAttenuatedSize = 10,
307
- gradient,
308
- scale = 0.05 * 0.5 / Math.tan(1.0 / 2.0),
309
- ...materialOptions
310
- } = options;
311
- super({
312
- ...materialOptions,
313
- fog: true,
314
- precision: 'highp',
315
- vertexColors: true
316
- });
317
- this.uniforms = THREE.UniformsUtils.merge([
318
- // THREE.PointsMaterial uniforms
319
- THREE.UniformsLib.points, THREE.UniformsLib.fog]);
320
- this.vertexShader = PointsVS;
321
- this.fragmentShader = PointsFS;
322
- this.userData.needTransparency = {};
323
- this.gradients = gradients;
324
- this.gradientTexture = new THREE.CanvasTexture();
325
- CommonMaterial.setDefineMapping(this, 'PNTS_MODE', PNTS_MODE);
326
- CommonMaterial.setDefineMapping(this, 'PNTS_SHAPE', PNTS_SHAPE);
327
- CommonMaterial.setDefineMapping(this, 'PNTS_SIZE_MODE', PNTS_SIZE_MODE);
328
- this.size = size;
329
- CommonMaterial.setUniformProperty(this, 'mode', mode);
330
- CommonMaterial.setUniformProperty(this, 'shape', shape);
331
- CommonMaterial.setUniformProperty(this, 'picking', false);
332
- CommonMaterial.setUniformProperty(this, 'opacity', this.opacity);
333
- CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange);
334
- CommonMaterial.setUniformProperty(this, 'elevationRange', elevationRange);
335
- CommonMaterial.setUniformProperty(this, 'angleRange', angleRange);
336
- CommonMaterial.setUniformProperty(this, 'sizeMode', sizeMode);
337
- CommonMaterial.setUniformProperty(this, 'scale', scale);
338
- CommonMaterial.setUniformProperty(this, 'minAttenuatedSize', minAttenuatedSize);
339
- CommonMaterial.setUniformProperty(this, 'maxAttenuatedSize', maxAttenuatedSize);
340
-
341
- // add classification texture to apply classification lut.
342
- const data = new Uint8Array(256 * 4);
343
- const texture = new THREE.DataTexture(data, 256, 1, THREE.RGBAFormat);
344
- texture.needsUpdate = true;
345
- texture.magFilter = THREE.NearestFilter;
346
- CommonMaterial.setUniformProperty(this, 'classificationTexture', texture);
347
-
348
- // add texture to applying the discrete lut.
349
- const dataLUT = new Uint8Array(256 * 4);
350
- const textureLUT = new THREE.DataTexture(dataLUT, 256, 1, THREE.RGBAFormat);
351
- textureLUT.needsUpdate = true;
352
- textureLUT.magFilter = THREE.NearestFilter;
353
- CommonMaterial.setUniformProperty(this, 'discreteTexture', textureLUT);
354
-
355
- // Classification and other discrete values scheme
356
- this.classificationScheme = classificationScheme;
357
- this.discreteScheme = discreteScheme;
358
-
359
- // Update classification and discrete Texture
360
- this.recomputeClassification();
361
- this.recomputeDiscreteTexture();
362
-
363
- // Gradient texture for continuous values
364
- this.gradient = gradient;
365
- CommonMaterial.setUniformProperty(this, 'gradientTexture', this.gradientTexture);
366
- }
367
-
368
- /**
369
- * Copy the parameters from the passed material into this material.
370
- * @override
371
- * @param {THREE.PointsMaterial} source
372
- * @returns {this}
373
- */
374
- copy(source) {
375
- // Manually copy this needTransparency if source doesn't have one. Prevents losing it when copying a three
376
- // PointsMaterial into this PointsMaterial
377
- const needTransparency = source.userData.needTransparency !== undefined ? source.userData.needTransparency : this.userData.needTransparency;
378
- if (source.isShaderMaterial) {
379
- super.copy(source);
380
- } else {
381
- THREE.Material.prototype.copy.call(this, source);
382
- }
383
-
384
- // Parameters of THREE.PointsMaterial
385
- this.color.copy(source.color);
386
- this.map = source.map;
387
- this.alphaMap = source.alphaMap;
388
- this.size = source.size;
389
- this.sizeAttenuation = source.sizeAttenuation;
390
- this.fog = source.fog;
391
- this.userData.needTransparency = needTransparency;
392
- return this;
393
- }
394
-
395
- /** @returns {THREE.Color} */
396
- get color() {
397
- return this.uniforms.diffuse.value;
398
- }
399
-
400
- /** @param {THREE.Color} color */
401
- set color(color) {
402
- this.uniforms.diffuse.value.copy(color);
403
- }
404
-
405
- /** @returns {THREE.Texture | null} */
406
- get map() {
407
- return this.uniforms.map.value;
408
- }
409
-
410
- /** @param {THREE.Texture | null} map */
411
- set map(map) {
412
- this.uniforms.map.value = map;
413
- if (!map) {
414
- return;
415
- }
416
- if (map.matrixAutoUpdate) {
417
- map.updateMatrix();
418
- }
419
- this.uniforms.uvTransform.value.copy(map.matrix);
420
- }
421
-
422
- /** @returns {THREE.Texture | null} */
423
- get alphaMap() {
424
- return this.uniforms.alphaMap.value;
425
- }
426
-
427
- /** @param {THREE.Texture | null} map */
428
- set alphaMap(map) {
429
- this.uniforms.alphaMap.value = map;
430
- if (!map) {
431
- return;
432
- }
433
- if (map.matrixAutoUpdate) {
434
- map.updateMatrix();
435
- }
436
- this.uniforms.alphaMapTransform.value.copy(map.matrix);
437
- }
438
-
439
- /** @returns {number} */
440
- get size() {
441
- return this.uniforms.size.value;
442
- }
443
-
444
- /** @param {number} size */
445
- set size(size) {
446
- this.uniforms.size.value = size;
447
- }
448
-
449
- /** @returns {boolean} */
450
- get sizeAttenuation() {
451
- return this.sizeMode !== PNTS_SIZE_MODE.VALUE;
452
- }
453
-
454
- /** @param {boolean} value */
455
- set sizeAttenuation(value) {
456
- this.sizeMode = value ? PNTS_SIZE_MODE.ATTENUATED : PNTS_SIZE_MODE.VALUE;
457
- }
458
- recomputeClassification() {
459
- const needTransparency = recomputeTexture(this.classificationScheme, this.classificationTexture, 256);
460
- this.userData.needTransparency[PNTS_MODE.CLASSIFICATION] = needTransparency;
461
- this.dispatchEvent({
462
- type: 'material_property_changed',
463
- target: this.uniforms
464
- });
465
- }
466
- recomputeDiscreteTexture() {
467
- const needTransparency = recomputeTexture(this.discreteScheme, this.discreteTexture);
468
- this.userData.needTransparency[PNTS_MODE.RETURN_NUMBER] = needTransparency;
469
- this.userData.needTransparency[PNTS_MODE.RETURN_TYPE] = needTransparency;
470
- this.userData.needTransparency[PNTS_MODE.RETURN_COUNT] = needTransparency;
471
- this.userData.needTransparency[PNTS_MODE.POINT_SOURCE_ID] = needTransparency;
472
- this.dispatchEvent({
473
- type: 'material_property_changed',
474
- target: this.uniforms
475
- });
476
- }
477
- enablePicking(picking) {
478
- this.picking = picking;
479
- this.blending = picking ? THREE.NoBlending : THREE.NormalBlending;
480
- }
481
- set gradient(value) {
482
- this.gradientTexture = generateGradientTexture(value);
483
- }
484
- }
485
- export default PointsMaterial;
@@ -1,209 +0,0 @@
1
- import * as THREE from 'three';
2
- import { ELEVATION_MODES } from "./LayeredMaterial.js";
3
- import { checkNodeElevationTextureValidity, insertSignificantValuesFromParent, computeMinMaxElevation } from "../Parser/XbilParser.js";
4
- import CRS from "../Core/Geographic/Crs.js";
5
- export const EMPTY_TEXTURE_ZOOM = -1;
6
- const pitch = new THREE.Vector4();
7
- function getIndiceWithPitch(i, pitch, w) {
8
- // Return corresponding indice in parent tile using pitch
9
- // normalized
10
- const currentY = Math.floor(i / w) / w; // normalized
11
- const newX = pitch.x + i % w / w * pitch.z;
12
- const newY = pitch.y + currentY * pitch.w;
13
- const newIndice = Math.floor(newY * w) * w + Math.floor(newX * w);
14
- return newIndice;
15
- }
16
-
17
- /**
18
- * A `RasterTile` is part of raster {@link Layer} data.
19
- * This part is a spatial subdivision of the extent of a layer.
20
- * In the `RasterTile`, The data are converted on three.js textures.
21
- * This `RasterTile` textures are assigned to a `LayeredMaterial`.
22
- * This material is applied on terrain (TileMesh).
23
- * The color textures are mapped to color the terrain.
24
- * The elevation textures are used to displace vertex terrain.
25
- *
26
- * @class RasterTile
27
- */
28
- class RasterTile extends THREE.EventDispatcher {
29
- constructor(material, layer) {
30
- super();
31
- this.layer = layer;
32
- this.crs = layer.parent.tileMatrixSets.indexOf(CRS.formatToTms(layer.crs));
33
- if (this.crs == -1) {
34
- console.error('Unknown crs:', layer.crs);
35
- }
36
- this.textures = [];
37
- this.offsetScales = [];
38
- this.level = EMPTY_TEXTURE_ZOOM;
39
- this.material = material;
40
- this._handlerCBEvent = () => {
41
- this.material.layersNeedUpdate = true;
42
- };
43
- layer.addEventListener('visible-property-changed', this._handlerCBEvent);
44
- layer.addEventListener('opacity-property-changed', this._handlerCBEvent);
45
- }
46
- get id() {
47
- return this.layer.id;
48
- }
49
- get opacity() {
50
- return this.layer.opacity;
51
- }
52
- get visible() {
53
- return this.layer.visible;
54
- }
55
- initFromParent(parent, extents) {
56
- if (parent && parent.level > this.level) {
57
- let index = 0;
58
- for (const c of extents) {
59
- for (const texture of parent.textures) {
60
- if (c.isInside(texture.extent)) {
61
- this.setTexture(index++, texture, c.offsetToParent(texture.extent));
62
- break;
63
- }
64
- }
65
- }
66
- }
67
- }
68
- dispose() {
69
- let removeEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
70
- if (removeEvent) {
71
- this.layer.removeEventListener('visible-property-changed', this._handlerCBEvent);
72
- this.layer.removeEventListener('opacity-property-changed', this._handlerCBEvent);
73
- // dispose all events
74
- this._listeners = {};
75
- }
76
- // TODO: WARNING verify if textures to dispose aren't attached with ancestor
77
- for (const texture of this.textures) {
78
- if (texture.isTexture) {
79
- texture.dispose();
80
- }
81
- }
82
- this.level = EMPTY_TEXTURE_ZOOM;
83
- this.textures = [];
84
- this.offsetScales = [];
85
- this.material.layersNeedUpdate = true;
86
- }
87
- setTexture(index, texture, offsetScale) {
88
- this.level = texture && texture.extent && index == 0 ? texture.extent.zoom : this.level;
89
- this.textures[index] = texture || null;
90
- this.offsetScales[index] = offsetScale;
91
- this.material.layersNeedUpdate = true;
92
- }
93
- setTextures(textures, pitchs) {
94
- this.dispose(false);
95
- for (let i = 0, il = textures.length; i < il; ++i) {
96
- this.setTexture(i, textures[i], pitchs[i]);
97
- }
98
- }
99
- }
100
- export default RasterTile;
101
- export class RasterColorTile extends RasterTile {
102
- get effect_type() {
103
- return this.layer.effect_type;
104
- }
105
- get effect_parameter() {
106
- return this.layer.effect_parameter;
107
- }
108
- get transparent() {
109
- return this.layer.transparent;
110
- }
111
- }
112
- export class RasterElevationTile extends RasterTile {
113
- constructor(material, layer) {
114
- super(material, layer);
115
- const defaultEle = {
116
- bias: 0,
117
- mode: ELEVATION_MODES.DATA,
118
- zmin: -Infinity,
119
- zmax: Infinity
120
- };
121
- this.scaleFactor = 1.0;
122
-
123
- // Define elevation properties
124
- if (layer.useRgbaTextureElevation) {
125
- defaultEle.mode = ELEVATION_MODES.RGBA;
126
- defaultEle.zmax = 5000;
127
- throw new Error('Restore this feature');
128
- } else if (layer.useColorTextureElevation) {
129
- this.scaleFactor = layer.colorTextureElevationMaxZ - layer.colorTextureElevationMinZ;
130
- defaultEle.mode = ELEVATION_MODES.COLOR;
131
- defaultEle.bias = layer.colorTextureElevationMinZ;
132
- this.min = this.layer.colorTextureElevationMinZ;
133
- this.max = this.layer.colorTextureElevationMaxZ;
134
- } else {
135
- this.min = 0;
136
- this.max = 0;
137
- }
138
- this.bias = layer.bias ?? defaultEle.bias;
139
- this.mode = layer.mode ?? defaultEle.mode;
140
- this.zmin = layer.zmin ?? defaultEle.zmin;
141
- this.zmax = layer.zmax ?? defaultEle.zmax;
142
- layer.addEventListener('scale-property-changed', this._handlerCBEvent);
143
- }
144
- get scale() {
145
- return this.layer.scale * this.scaleFactor;
146
- }
147
- dispose(removeEvent) {
148
- super.dispose(removeEvent);
149
- if (removeEvent) {
150
- this.layer.removeEventListener('scale-property-changed', this._handlerCBEvent);
151
- }
152
- }
153
- initFromParent(parent, extents) {
154
- const currentLevel = this.level;
155
- super.initFromParent(parent, extents);
156
- this.updateMinMaxElevation();
157
- if (currentLevel !== this.level) {
158
- this.dispatchEvent({
159
- type: 'rasterElevationLevelChanged',
160
- node: this
161
- });
162
- }
163
- }
164
- setTextures(textures, offsetScales) {
165
- const currentLevel = this.level;
166
- this.replaceNoDataValueFromTexture(textures[0]);
167
- super.setTextures(textures, offsetScales);
168
- this.updateMinMaxElevation();
169
- if (currentLevel !== this.level) {
170
- this.dispatchEvent({
171
- type: 'rasterElevationLevelChanged',
172
- node: this
173
- });
174
- }
175
- }
176
- updateMinMaxElevation() {
177
- if (this.textures[0] && !this.layer.useColorTextureElevation) {
178
- const {
179
- min,
180
- max
181
- } = computeMinMaxElevation(this.textures[0], this.offsetScales[0], {
182
- noDataValue: this.layer.noDataValue,
183
- zmin: this.layer.zmin,
184
- zmax: this.layer.zmax
185
- });
186
- if (this.min != min || this.max != max) {
187
- this.min = min;
188
- this.max = max;
189
- }
190
- }
191
- }
192
- replaceNoDataValueFromTexture(texture) {
193
- const nodatavalue = this.layer.noDataValue;
194
- if (nodatavalue == undefined) {
195
- return;
196
- }
197
- // replace no data value with parent texture value or 0 (if no significant value found).
198
- const parentTexture = this.textures[0];
199
- const parentDataElevation = parentTexture && parentTexture.image && parentTexture.image.data;
200
- const dataElevation = texture.image && texture.image.data;
201
- if (dataElevation && !checkNodeElevationTextureValidity(dataElevation, nodatavalue)) {
202
- insertSignificantValuesFromParent(dataElevation, parentDataElevation && dataParent(texture, parentTexture, parentDataElevation, pitch), nodatavalue);
203
- }
204
- }
205
- }
206
- function dataParent(texture, parentTexture, parentDataElevation, pitch) {
207
- texture.extent.offsetToParent(parentTexture.extent, pitch);
208
- return i => parentDataElevation[getIndiceWithPitch(i, pitch, 256)];
209
- }