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,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=1] point size
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 {Scheme} [options.classificationScheme] LUT for point classification colorization.
266
- * @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
267
- * @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
268
- * (Default value will be the 'SPECTRAL' gradient from Utils/Gradients)
269
- * @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.
270
- * @param {number} [options.minAttenuatedSize=3] minimum scale used by 'ATTENUATED' size mode
271
- * @param {number} [options.maxAttenuatedSize=10] maximum scale used by 'ATTENUATED' size mode
272
- *
273
- * @property {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range (default value will be [1, 65536] if not defined at Layer level).
274
- * @property {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range (default value will be [0, 1000] if not defined at Layer level).
275
- * @property {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range (default value will be [-90, 90] if not defined at Layer level).
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,208 +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
- export const EMPTY_TEXTURE_ZOOM = -1;
5
- const pitch = new THREE.Vector4();
6
- function getIndiceWithPitch(i, pitch, w) {
7
- // Return corresponding indice in parent tile using pitch
8
- // normalized
9
- const currentY = Math.floor(i / w) / w; // normalized
10
- const newX = pitch.x + i % w / w * pitch.z;
11
- const newY = pitch.y + currentY * pitch.w;
12
- const newIndice = Math.floor(newY * w) * w + Math.floor(newX * w);
13
- return newIndice;
14
- }
15
-
16
- /**
17
- * A `RasterTile` is part of raster {@link Layer} data.
18
- * This part is a spatial subdivision of the extent of a layer.
19
- * In the `RasterTile`, The data are converted on three.js textures.
20
- * This `RasterTile` textures are assigned to a `LayeredMaterial`.
21
- * This material is applied on terrain (TileMesh).
22
- * The color textures are mapped to color the terrain.
23
- * The elevation textures are used to displace vertex terrain.
24
- *
25
- * @class RasterTile
26
- */
27
- class RasterTile extends THREE.EventDispatcher {
28
- constructor(material, layer) {
29
- super();
30
- this.layer = layer;
31
- this.crs = layer.parent.tileMatrixSets.indexOf(layer.crs);
32
- if (this.crs == -1) {
33
- console.error('Unknown crs:', layer.crs);
34
- }
35
- this.textures = [];
36
- this.offsetScales = [];
37
- this.level = EMPTY_TEXTURE_ZOOM;
38
- this.material = material;
39
- this._handlerCBEvent = () => {
40
- this.material.layersNeedUpdate = true;
41
- };
42
- layer.addEventListener('visible-property-changed', this._handlerCBEvent);
43
- layer.addEventListener('opacity-property-changed', this._handlerCBEvent);
44
- }
45
- get id() {
46
- return this.layer.id;
47
- }
48
- get opacity() {
49
- return this.layer.opacity;
50
- }
51
- get visible() {
52
- return this.layer.visible;
53
- }
54
- initFromParent(parent, extents) {
55
- if (parent && parent.level > this.level) {
56
- let index = 0;
57
- for (const c of extents) {
58
- for (const texture of parent.textures) {
59
- if (c.isInside(texture.extent)) {
60
- this.setTexture(index++, texture, c.offsetToParent(texture.extent));
61
- break;
62
- }
63
- }
64
- }
65
- }
66
- }
67
- dispose() {
68
- let removeEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
69
- if (removeEvent) {
70
- this.layer.removeEventListener('visible-property-changed', this._handlerCBEvent);
71
- this.layer.removeEventListener('opacity-property-changed', this._handlerCBEvent);
72
- // dispose all events
73
- this._listeners = {};
74
- }
75
- // TODO: WARNING verify if textures to dispose aren't attached with ancestor
76
- for (const texture of this.textures) {
77
- if (texture.isTexture) {
78
- texture.dispose();
79
- }
80
- }
81
- this.level = EMPTY_TEXTURE_ZOOM;
82
- this.textures = [];
83
- this.offsetScales = [];
84
- this.material.layersNeedUpdate = true;
85
- }
86
- setTexture(index, texture, offsetScale) {
87
- this.level = texture && texture.extent && index == 0 ? texture.extent.zoom : this.level;
88
- this.textures[index] = texture || null;
89
- this.offsetScales[index] = offsetScale;
90
- this.material.layersNeedUpdate = true;
91
- }
92
- setTextures(textures, pitchs) {
93
- this.dispose(false);
94
- for (let i = 0, il = textures.length; i < il; ++i) {
95
- this.setTexture(i, textures[i], pitchs[i]);
96
- }
97
- }
98
- }
99
- export default RasterTile;
100
- export class RasterColorTile extends RasterTile {
101
- get effect_type() {
102
- return this.layer.effect_type;
103
- }
104
- get effect_parameter() {
105
- return this.layer.effect_parameter;
106
- }
107
- get transparent() {
108
- return this.layer.transparent;
109
- }
110
- }
111
- export class RasterElevationTile extends RasterTile {
112
- constructor(material, layer) {
113
- super(material, layer);
114
- const defaultEle = {
115
- bias: 0,
116
- mode: ELEVATION_MODES.DATA,
117
- zmin: -Infinity,
118
- zmax: Infinity
119
- };
120
- this.scaleFactor = 1.0;
121
-
122
- // Define elevation properties
123
- if (layer.useRgbaTextureElevation) {
124
- defaultEle.mode = ELEVATION_MODES.RGBA;
125
- defaultEle.zmax = 5000;
126
- throw new Error('Restore this feature');
127
- } else if (layer.useColorTextureElevation) {
128
- this.scaleFactor = layer.colorTextureElevationMaxZ - layer.colorTextureElevationMinZ;
129
- defaultEle.mode = ELEVATION_MODES.COLOR;
130
- defaultEle.bias = layer.colorTextureElevationMinZ;
131
- this.min = this.layer.colorTextureElevationMinZ;
132
- this.max = this.layer.colorTextureElevationMaxZ;
133
- } else {
134
- this.min = 0;
135
- this.max = 0;
136
- }
137
- this.bias = layer.bias ?? defaultEle.bias;
138
- this.mode = layer.mode ?? defaultEle.mode;
139
- this.zmin = layer.zmin ?? defaultEle.zmin;
140
- this.zmax = layer.zmax ?? defaultEle.zmax;
141
- layer.addEventListener('scale-property-changed', this._handlerCBEvent);
142
- }
143
- get scale() {
144
- return this.layer.scale * this.scaleFactor;
145
- }
146
- dispose(removeEvent) {
147
- super.dispose(removeEvent);
148
- if (removeEvent) {
149
- this.layer.removeEventListener('scale-property-changed', this._handlerCBEvent);
150
- }
151
- }
152
- initFromParent(parent, extents) {
153
- const currentLevel = this.level;
154
- super.initFromParent(parent, extents);
155
- this.updateMinMaxElevation();
156
- if (currentLevel !== this.level) {
157
- this.dispatchEvent({
158
- type: 'rasterElevationLevelChanged',
159
- node: this
160
- });
161
- }
162
- }
163
- setTextures(textures, offsetScales) {
164
- const currentLevel = this.level;
165
- this.replaceNoDataValueFromTexture(textures[0]);
166
- super.setTextures(textures, offsetScales);
167
- this.updateMinMaxElevation();
168
- if (currentLevel !== this.level) {
169
- this.dispatchEvent({
170
- type: 'rasterElevationLevelChanged',
171
- node: this
172
- });
173
- }
174
- }
175
- updateMinMaxElevation() {
176
- if (this.textures[0] && !this.layer.useColorTextureElevation) {
177
- const {
178
- min,
179
- max
180
- } = computeMinMaxElevation(this.textures[0], this.offsetScales[0], {
181
- noDataValue: this.layer.noDataValue,
182
- zmin: this.layer.zmin,
183
- zmax: this.layer.zmax
184
- });
185
- if (this.min != min || this.max != max) {
186
- this.min = min;
187
- this.max = max;
188
- }
189
- }
190
- }
191
- replaceNoDataValueFromTexture(texture) {
192
- const nodatavalue = this.layer.noDataValue;
193
- if (nodatavalue == undefined) {
194
- return;
195
- }
196
- // replace no data value with parent texture value or 0 (if no significant value found).
197
- const parentTexture = this.textures[0];
198
- const parentDataElevation = parentTexture && parentTexture.image && parentTexture.image.data;
199
- const dataElevation = texture.image && texture.image.data;
200
- if (dataElevation && !checkNodeElevationTextureValidity(dataElevation, nodatavalue)) {
201
- insertSignificantValuesFromParent(dataElevation, parentDataElevation && dataParent(texture, parentTexture, parentDataElevation, pitch), nodatavalue);
202
- }
203
- }
204
- }
205
- function dataParent(texture, parentTexture, parentDataElevation, pitch) {
206
- texture.extent.offsetToParent(parentTexture.extent, pitch);
207
- return i => parentDataElevation[getIndiceWithPitch(i, pitch, 256)];
208
- }