itowns 2.43.2-next.2 → 2.43.2-next.20

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 (83) hide show
  1. package/dist/558.js +2 -0
  2. package/dist/558.js.map +1 -0
  3. package/dist/debug.js +1 -1
  4. package/dist/debug.js.map +1 -1
  5. package/dist/itowns.js +1 -1
  6. package/dist/itowns.js.map +1 -1
  7. package/dist/itowns_lasparser.js +2 -0
  8. package/dist/itowns_lasparser.js.map +1 -0
  9. package/dist/itowns_lasworker.js +2 -0
  10. package/dist/itowns_lasworker.js.map +1 -0
  11. package/dist/itowns_potree2worker.js +2 -0
  12. package/dist/itowns_potree2worker.js.map +1 -0
  13. package/dist/itowns_widgets.js +1 -1
  14. package/dist/itowns_widgets.js.map +1 -1
  15. package/examples/3dtiles_25d.html +1 -1
  16. package/examples/3dtiles_basic.html +2 -2
  17. package/examples/3dtiles_batch_table.html +1 -3
  18. package/examples/3dtiles_pointcloud.html +9 -15
  19. package/examples/config.json +1 -0
  20. package/examples/copc_simple_loader.html +1 -1
  21. package/examples/entwine_3d_loader.html +1 -1
  22. package/examples/entwine_simple_loader.html +1 -1
  23. package/examples/js/plugins/COGParser.js +84 -50
  24. package/examples/js/plugins/COGSource.js +7 -4
  25. package/examples/layers/JSONLayers/OPENSM.json +1 -1
  26. package/examples/potree2_25d_map.html +127 -0
  27. package/examples/potree_25d_map.html +1 -1
  28. package/examples/potree_3d_map.html +1 -1
  29. package/examples/source_file_cog.html +22 -5
  30. package/lib/Controls/FirstPersonControls.js +0 -1
  31. package/lib/Controls/FlyControls.js +0 -1
  32. package/lib/Converter/Feature2Mesh.js +2 -4
  33. package/lib/Converter/textureConverter.js +1 -1
  34. package/lib/Core/3DTiles/C3DTBatchTable.js +1 -1
  35. package/lib/Core/3DTiles/C3DTFeature.js +6 -7
  36. package/lib/Core/Feature.js +1 -2
  37. package/lib/Core/Geographic/CoordStars.js +0 -1
  38. package/lib/Core/Label.js +0 -1
  39. package/lib/Core/MainLoop.js +0 -1
  40. package/lib/Core/Potree2Node.js +206 -0
  41. package/lib/Core/Potree2PointAttributes.js +139 -0
  42. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -4
  43. package/lib/Core/Prefab/Globe/GlobeLayer.js +3 -3
  44. package/lib/Core/Scheduler/Scheduler.js +1 -1
  45. package/lib/Core/Style.js +54 -53
  46. package/lib/Core/View.js +2 -4
  47. package/lib/Layer/C3DTilesLayer.js +8 -6
  48. package/lib/Layer/ElevationLayer.js +2 -3
  49. package/lib/Layer/GeoidLayer.js +1 -2
  50. package/lib/Layer/LabelLayer.js +8 -17
  51. package/lib/Layer/Layer.js +4 -2
  52. package/lib/Layer/PointCloudLayer.js +5 -8
  53. package/lib/Layer/Potree2Layer.js +165 -0
  54. package/lib/Layer/ReferencingLayerProperties.js +8 -3
  55. package/lib/Layer/TiledGeometryLayer.js +6 -4
  56. package/lib/Loader/Potree2BrotliLoader.js +261 -0
  57. package/lib/Loader/Potree2Loader.js +207 -0
  58. package/lib/Main.js +2 -0
  59. package/lib/Parser/GeoJsonParser.js +2 -3
  60. package/lib/Parser/LASParser.js +49 -18
  61. package/lib/Parser/Potree2BinParser.js +92 -0
  62. package/lib/Parser/deprecated/LegacyGLTFLoader.js +1 -2
  63. package/lib/Process/3dTilesProcessing.js +2 -1
  64. package/lib/Process/FeatureProcessing.js +1 -2
  65. package/lib/Process/LayeredMaterialNodeProcessing.js +3 -9
  66. package/lib/Process/ObjectRemovalHelper.js +1 -2
  67. package/lib/Provider/3dTilesProvider.js +3 -2
  68. package/lib/Renderer/ColorLayersOrdering.js +1 -2
  69. package/lib/Renderer/Label2DRenderer.js +1 -4
  70. package/lib/Renderer/PointsMaterial.js +135 -100
  71. package/lib/Renderer/RenderMode.js +0 -1
  72. package/lib/Source/FileSource.js +1 -1
  73. package/lib/Source/Potree2Source.js +172 -0
  74. package/lib/ThreeExtended/loaders/DDSLoader.js +11 -1
  75. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -1
  76. package/lib/ThreeExtended/loaders/GLTFLoader.js +1 -0
  77. package/lib/Utils/DEMUtils.js +2 -2
  78. package/lib/Utils/OrientationUtils.js +0 -1
  79. package/lib/Utils/gui/Searchbar.js +1 -2
  80. package/lib/Worker/LASLoaderWorker.js +19 -0
  81. package/lib/Worker/Potree2Worker.js +21 -0
  82. package/package.json +11 -8
  83. /package/lib/{Parser → Loader}/LASLoader.js +0 -0
@@ -1,9 +1,8 @@
1
1
  import * as THREE from 'three';
2
2
  /* babel-plugin-inline-import './Shader/PointsVS.glsl' */
3
- const PointsVS = "#include <itowns/precision_qualifier>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_vertex>\n#endif\n#include <common>\n#include <logdepthbuf_pars_vertex>\n\n#define NB_CLASS 8.\n\nuniform float size;\nuniform float scale;\n\nuniform bool picking;\nuniform int mode;\nuniform float opacity;\nuniform vec4 overlayColor;\n\nuniform vec2 elevationRange;\nuniform vec2 intensityRange;\nuniform vec2 angleRange;\n\nuniform bool applyOpacityClassication;\n\nuniform sampler2D classificationTexture;\nuniform sampler2D discreteTexture;\nuniform sampler2D gradientTexture;\nuniform int sizeMode;\nuniform float minAttenuatedSize;\nuniform float maxAttenuatedSize;\n\nattribute vec3 color;\nattribute vec2 range;\nattribute vec4 unique_id;\nattribute float intensity;\nattribute float classification;\nattribute float pointSourceID;\n\nattribute float returnNumber;\nattribute float numberOfReturns;\nattribute float scanAngle;\n\n#if defined(NORMAL_OCT16)\nattribute vec2 oct16Normal;\n#elif defined(NORMAL_SPHEREMAPPED)\nattribute vec2 sphereMappedNormal;\n#endif\n\nvarying vec4 vColor;\n\n// see https://web.archive.org/web/20150303053317/http://lgdv.cs.fau.de/get/1602\n// and implementation in PotreeConverter (BINPointReader.cpp) and potree (BinaryDecoderWorker.js)\n#if defined(NORMAL_OCT16)\nvec3 decodeOct16Normal(vec2 encodedNormal) {\n vec2 nNorm = 2. * (encodedNormal / 255.) - 1.;\n vec3 n;\n n.z = 1. - abs(nNorm.x) - abs(nNorm.y);\n if (n.z >= 0.) {\n n.x = nNorm.x;\n n.y = nNorm.y;\n } else {\n n.x = sign(nNorm.x) - sign(nNorm.x) * sign(nNorm.y) * nNorm.y;\n n.y = sign(nNorm.y) - sign(nNorm.y) * sign(nNorm.x) * nNorm.x;\n }\n return normalize(n);\n}\n#elif defined(NORMAL_SPHEREMAPPED)\n// see http://aras-p.info/texts/CompactNormalStorage.html method #4\n// or see potree's implementation in BINPointReader.cpp\nvec3 decodeSphereMappedNormal(vec2 encodedNormal) {\n vec2 fenc = 2. * encodedNormal / 255. - 1.;\n float f = dot(fenc,fenc);\n float g = 2. * sqrt(1. - f);\n vec3 n;\n n.xy = fenc * g;\n n.z = 1. - 2. * f;\n return n;\n}\n#endif\n\nvoid main() {\n\n#if defined(NORMAL_OCT16)\n vec3 normal = decodeOct16Normal(oct16Normal);\n#elif defined(NORMAL_SPHEREMAPPED)\n vec3 normal = decodeSphereMappedNormal(sphereMappedNormal);\n#elif defined(NORMAL)\n // nothing to do\n#else\n // default to color\n vec3 normal = color;\n#endif\n\n if (picking) {\n vColor = unique_id;\n } else {\n vColor.a = opacity;\n if (applyOpacityClassication || mode == PNTS_MODE_CLASSIFICATION) {\n vec2 uv = vec2(classification/255., 0.5);\n vColor = texture2D(classificationTexture, uv);\n vColor.a *= opacity;\n }\n\n if (mode == PNTS_MODE_NORMAL) {\n vColor.rgb = abs(normal);\n } else if (mode == PNTS_MODE_COLOR) {\n // default to color mode\n vColor.rgb = mix(color, overlayColor.rgb, overlayColor.a);\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 i = (position.z - elevationRange.x) / (elevationRange.y - elevationRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n }\n }\n\n #include <begin_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#if defined(USE_TEXTURES_PROJECTIVE)\n #include <itowns/projective_texturing_vertex>\n#endif\n #include <logdepthbuf_vertex>\n}\n";
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
4
  /* babel-plugin-inline-import './Shader/PointsFS.glsl' */
5
- const PointsFS = "#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_fragment>\n#endif\n\nvarying vec4 vColor;\nuniform bool picking;\nuniform int shape;\n\nvoid main() {\n #include <logdepthbuf_fragment>\n //square shape does not require any change.\n if (shape == PNTS_SHAPE_CIRCLE) {\n //circular rendering in glsl\n if ((length(gl_PointCoord - 0.5) > 0.5) || (vColor.a == 0.0)) {\n discard;\n }\n }\n\n#if defined(USE_TEXTURES_PROJECTIVE)\n vec4 color = vColor;\n if (!picking) {\n #pragma unroll_loop\n for (int i = 0; i < ORIENTED_IMAGES_COUNT; i++) {\n color = projectiveTextureColor(projectiveTextureCoords[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTextureDistortion[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTexture[ ORIENTED_IMAGES_COUNT - 1 - i ], mask[ORIENTED_IMAGES_COUNT - 1 - i], color);\n }\n gl_FragColor = vec4(color.rgb, color.a * opacity);\n } else {\n gl_FragColor = color;\n }\n#else\n gl_FragColor = vColor;\n#endif\n}\n";
6
- import ShaderUtils from "./Shader/ShaderUtils.js";
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_pars_fragment>\n if (shape == PNTS_SHAPE_CIRCLE) {\n //circular rendering in glsl\n if ((length(gl_PointCoord - 0.5) > 0.5) || (vColor.a == 0.0)) {\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";
7
6
  import CommonMaterial from "./CommonMaterial.js";
8
7
  import Gradients from "../Utils/Gradients.js";
9
8
  export const PNTS_MODE = {
@@ -127,7 +126,7 @@ export const ClassificationScheme = {
127
126
  visible: true,
128
127
  name: 'default',
129
128
  color: new THREE.Color(0.3, 0.6, 0.6),
130
- opacity: 0.5
129
+ opacity: 1.0
131
130
  }
132
131
  }
133
132
  };
@@ -185,7 +184,7 @@ const DiscreteScheme = {
185
184
  visible: true,
186
185
  name: 'default',
187
186
  color: white,
188
- opacity: 0.5
187
+ opacity: 1.0
189
188
  }
190
189
  }
191
190
  };
@@ -220,6 +219,7 @@ function generateGradientTexture(gradient) {
220
219
  return texture;
221
220
  }
222
221
  function recomputeTexture(scheme, texture, nbClass) {
222
+ let needTransparency;
223
223
  const data = texture.image.data;
224
224
  const width = texture.image.width;
225
225
  if (!nbClass) {
@@ -250,8 +250,10 @@ function recomputeTexture(scheme, texture, nbClass) {
250
250
  data[j + 1] = parseInt(255 * color.g, 10);
251
251
  data[j + 2] = parseInt(255 * color.b, 10);
252
252
  data[j + 3] = visible ? parseInt(255 * opacity, 10) : 0;
253
+ needTransparency = needTransparency || opacity < 1;
253
254
  }
254
255
  texture.needsUpdate = true;
256
+ return needTransparency;
255
257
  }
256
258
  class PointsMaterial extends THREE.ShaderMaterial {
257
259
  /**
@@ -264,8 +266,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
264
266
  * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range.
265
267
  * @param {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range.
266
268
  * @param {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range.
267
- * @param {boolean} [options.applyOpacityClassication=false] apply opacity classification on all display mode.
268
- * @param {Scheme} [options.classification] LUT for point classification colorization.
269
+ * @param {Scheme} [options.classificationScheme] LUT for point classification colorization.
269
270
  * @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
270
271
  * @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
271
272
  * (Default value will be the 'SPECTRAL' gradient from Utils/Gradients)
@@ -287,59 +288,52 @@ class PointsMaterial extends THREE.ShaderMaterial {
287
288
  */
288
289
  constructor() {
289
290
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
290
- const intensityRange = options.intensityRange || new THREE.Vector2(1, 65536);
291
- const elevationRange = options.elevationRange || new THREE.Vector2(0, 1000);
292
- const angleRange = options.angleRange || new THREE.Vector2(-90, 90);
293
- const oiMaterial = options.orientedImageMaterial;
294
- const classificationScheme = options.classification || ClassificationScheme.DEFAULT;
295
- const discreteScheme = options.discreteScheme || DiscreteScheme.DEFAULT;
296
- const applyOpacityClassication = options.applyOpacityClassication == undefined ? false : options.applyOpacityClassication;
297
- const size = options.size || 0;
298
- const mode = options.mode || PNTS_MODE.COLOR;
299
- const shape = options.shape || PNTS_SHAPE.CIRCLE;
300
- const sizeMode = size === 0 ? PNTS_SIZE_MODE.ATTENUATED : options.sizeMode || PNTS_SIZE_MODE.VALUE;
301
- const minAttenuatedSize = options.minAttenuatedSize || 3;
302
- const maxAttenuatedSize = options.maxAttenuatedSize || 10;
303
- let gradients = Gradients;
304
- if (options.gradient) {
305
- gradients = {
306
- ...options.gradient,
307
- ...Gradients
308
- };
309
- }
310
- delete options.intensityRange;
311
- delete options.elevationRange;
312
- delete options.angleRange;
313
- delete options.orientedImageMaterial;
314
- delete options.classification;
315
- delete options.discreteScheme;
316
- delete options.applyOpacityClassication;
317
- delete options.size;
318
- delete options.mode;
319
- delete options.shape;
320
- delete options.sizeMode;
321
- delete options.minAttenuatedSize;
322
- delete options.maxAttenuatedSize;
323
- delete options.gradient;
324
- super(options);
291
+ const gradients = {
292
+ ...options.gradient,
293
+ ...Gradients
294
+ };
295
+ options.gradient = Object.values(gradients)[0];
296
+ const {
297
+ intensityRange = new THREE.Vector2(1, 65536),
298
+ elevationRange = new THREE.Vector2(0, 1000),
299
+ angleRange = new THREE.Vector2(-90, 90),
300
+ classificationScheme = ClassificationScheme.DEFAULT,
301
+ discreteScheme = DiscreteScheme.DEFAULT,
302
+ size = 1,
303
+ mode = PNTS_MODE.COLOR,
304
+ shape = PNTS_SHAPE.CIRCLE,
305
+ sizeMode = PNTS_SIZE_MODE.ATTENUATED,
306
+ minAttenuatedSize = 3,
307
+ maxAttenuatedSize = 10,
308
+ gradient,
309
+ scale = 0.05 * 0.5 / Math.tan(1.0 / 2.0),
310
+ ...materialOptions
311
+ } = options;
312
+ super({
313
+ ...materialOptions,
314
+ fog: true,
315
+ precision: 'highp',
316
+ vertexColors: true
317
+ });
318
+ this.uniforms = THREE.UniformsUtils.merge([
319
+ // THREE.PointsMaterial uniforms
320
+ THREE.UniformsLib.points, THREE.UniformsLib.fog]);
321
+ this.vertexShader = PointsVS;
322
+ this.fragmentShader = PointsFS;
323
+ this.userData.needTransparency = {};
325
324
  this.gradients = gradients;
326
325
  this.gradientTexture = new THREE.CanvasTexture();
327
- this.vertexShader = PointsVS;
328
- const scale = options.scale || 0.05 * 0.5 / Math.tan(1.0 / 2.0); // autosizing scale
329
-
330
326
  CommonMaterial.setDefineMapping(this, 'PNTS_MODE', PNTS_MODE);
331
327
  CommonMaterial.setDefineMapping(this, 'PNTS_SHAPE', PNTS_SHAPE);
332
328
  CommonMaterial.setDefineMapping(this, 'PNTS_SIZE_MODE', PNTS_SIZE_MODE);
333
- CommonMaterial.setUniformProperty(this, 'size', size);
329
+ this.size = size;
334
330
  CommonMaterial.setUniformProperty(this, 'mode', mode);
335
331
  CommonMaterial.setUniformProperty(this, 'shape', shape);
336
332
  CommonMaterial.setUniformProperty(this, 'picking', false);
337
333
  CommonMaterial.setUniformProperty(this, 'opacity', this.opacity);
338
- CommonMaterial.setUniformProperty(this, 'overlayColor', options.overlayColor || new THREE.Vector4(0, 0, 0, 0));
339
334
  CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange);
340
335
  CommonMaterial.setUniformProperty(this, 'elevationRange', elevationRange);
341
336
  CommonMaterial.setUniformProperty(this, 'angleRange', angleRange);
342
- CommonMaterial.setUniformProperty(this, 'applyOpacityClassication', applyOpacityClassication);
343
337
  CommonMaterial.setUniformProperty(this, 'sizeMode', sizeMode);
344
338
  CommonMaterial.setUniformProperty(this, 'scale', scale);
345
339
  CommonMaterial.setUniformProperty(this, 'minAttenuatedSize', minAttenuatedSize);
@@ -368,78 +362,119 @@ class PointsMaterial extends THREE.ShaderMaterial {
368
362
  this.recomputeDiscreteTexture();
369
363
 
370
364
  // Gradient texture for continuous values
371
- this.gradient = Object.values(gradients)[0];
365
+ this.gradient = gradient;
372
366
  CommonMaterial.setUniformProperty(this, 'gradientTexture', this.gradientTexture);
373
- if (oiMaterial) {
374
- this.uniforms.projectiveTextureAlphaBorder = oiMaterial.uniforms.projectiveTextureAlphaBorder;
375
- this.uniforms.projectiveTextureDistortion = oiMaterial.uniforms.projectiveTextureDistortion;
376
- this.uniforms.projectiveTextureMatrix = oiMaterial.uniforms.projectiveTextureMatrix;
377
- this.uniforms.projectiveTexture = oiMaterial.uniforms.projectiveTexture;
378
- this.uniforms.mask = oiMaterial.uniforms.mask;
379
- this.uniforms.boostLight = oiMaterial.uniforms.boostLight;
380
- this.defines.ORIENTED_IMAGES_COUNT = oiMaterial.defines.ORIENTED_IMAGES_COUNT;
381
- this.defines.USE_DISTORTION = oiMaterial.defines.USE_DISTORTION;
382
- this.defines.DEBUG_ALPHA_BORDER = oiMaterial.defines.DEBUG_ALPHA_BORDER;
383
- this.defines.USE_TEXTURES_PROJECTIVE = true;
384
- this.defines.USE_BASE_MATERIAL = true;
385
- // three loop unrolling of ShaderMaterial only supports integer
386
- // bounds, see https://github.com/mrdoob/three.js/issues/28020
387
- this.fragmentShader = ShaderUtils.unrollLoops(PointsFS, this.defines);
367
+ }
368
+
369
+ /**
370
+ * Copy the parameters from the passed material into this material.
371
+ * @override
372
+ * @param {THREE.PointsMaterial} source
373
+ * @returns {this}
374
+ */
375
+ copy(source) {
376
+ if (source.isShaderMaterial) {
377
+ super.copy(source);
388
378
  } else {
389
- this.fragmentShader = PointsFS;
379
+ THREE.Material.prototype.copy.call(this, source);
380
+ }
381
+
382
+ // Parameters of THREE.PointsMaterial
383
+ this.color.copy(source.color);
384
+ this.map = source.map;
385
+ this.alphaMap = source.alphaMap;
386
+ this.size = source.size;
387
+ this.sizeAttenuation = source.sizeAttenuation;
388
+ this.fog = source.fog;
389
+ return this;
390
+ }
391
+
392
+ /** @returns {THREE.Color} */
393
+ get color() {
394
+ return this.uniforms.diffuse.value;
395
+ }
396
+
397
+ /** @param {THREE.Color} color */
398
+ set color(color) {
399
+ this.uniforms.diffuse.value.copy(color);
400
+ }
401
+
402
+ /** @returns {THREE.Texture | null} */
403
+ get map() {
404
+ return this.uniforms.map.value;
405
+ }
406
+
407
+ /** @param {THREE.Texture | null} map */
408
+ set map(map) {
409
+ this.uniforms.map.value = map;
410
+ if (!map) {
411
+ return;
412
+ }
413
+ if (map.matrixAutoUpdate) {
414
+ map.updateMatrix();
415
+ }
416
+ this.uniforms.uvTransform.value.copy(map.matrix);
417
+ }
418
+
419
+ /** @returns {THREE.Texture | null} */
420
+ get alphaMap() {
421
+ return this.uniforms.alphaMap.value;
422
+ }
423
+
424
+ /** @param {THREE.Texture | null} map */
425
+ set alphaMap(map) {
426
+ this.uniforms.alphaMap.value = map;
427
+ if (!map) {
428
+ return;
429
+ }
430
+ if (map.matrixAutoUpdate) {
431
+ map.updateMatrix();
390
432
  }
433
+ this.uniforms.alphaMapTransform.value.copy(map.matrix);
434
+ }
435
+
436
+ /** @returns {number} */
437
+ get size() {
438
+ return this.uniforms.size.value;
439
+ }
440
+
441
+ /** @param {number} size */
442
+ set size(size) {
443
+ this.uniforms.size.value = size;
444
+ }
445
+
446
+ /** @returns {boolean} */
447
+ get sizeAttenuation() {
448
+ return this.sizeMode !== PNTS_SIZE_MODE.VALUE;
449
+ }
450
+
451
+ /** @param {boolean} value */
452
+ set sizeAttenuation(value) {
453
+ this.sizeMode = value ? PNTS_SIZE_MODE.ATTENUATED : PNTS_SIZE_MODE.VALUE;
391
454
  }
392
455
  recomputeClassification() {
393
- recomputeTexture(this.classificationScheme, this.classificationTexture, 32);
456
+ const needTransparency = recomputeTexture(this.classificationScheme, this.classificationTexture, 256);
457
+ this.userData.needTransparency[PNTS_MODE.CLASSIFICATION] = needTransparency;
394
458
  this.dispatchEvent({
395
459
  type: 'material_property_changed',
396
460
  target: this.uniforms
397
461
  });
398
462
  }
399
463
  recomputeDiscreteTexture() {
400
- recomputeTexture(this.discreteScheme, this.discreteTexture);
464
+ const needTransparency = recomputeTexture(this.discreteScheme, this.discreteTexture);
465
+ this.userData.needTransparency[PNTS_MODE.RETURN_NUMBER] = needTransparency;
466
+ this.userData.needTransparency[PNTS_MODE.RETURN_TYPE] = needTransparency;
467
+ this.userData.needTransparency[PNTS_MODE.RETURN_COUNT] = needTransparency;
468
+ this.userData.needTransparency[PNTS_MODE.POINT_SOURCE_ID] = needTransparency;
401
469
  this.dispatchEvent({
402
470
  type: 'material_property_changed',
403
471
  target: this.uniforms
404
472
  });
405
473
  }
406
- copy(source) {
407
- super.copy(source);
408
- if (source.uniforms.projectiveTextureAlphaBorder) {
409
- // Don't copy oriented image because, it's a link to oriented image material.
410
- // It needs a reference to oriented image material.
411
- this.uniforms.projectiveTextureAlphaBorder = source.uniforms.projectiveTextureAlphaBorder;
412
- this.uniforms.projectiveTextureDistortion = source.uniforms.projectiveTextureDistortion;
413
- this.uniforms.projectiveTextureMatrix = source.uniforms.projectiveTextureMatrix;
414
- this.uniforms.projectiveTexture = source.uniforms.projectiveTexture;
415
- this.uniforms.mask = source.uniforms.mask;
416
- this.uniforms.boostLight = source.uniforms.boostLight;
417
- }
418
- return this;
419
- }
420
474
  enablePicking(picking) {
421
475
  this.picking = picking;
422
476
  this.blending = picking ? THREE.NoBlending : THREE.NormalBlending;
423
477
  }
424
- update(source) {
425
- this.visible = source.visible;
426
- this.opacity = source.opacity;
427
- this.transparent = source.transparent;
428
- this.size = source.size;
429
- this.mode = source.mode;
430
- this.shape = source.shape;
431
- this.sizeMode = source.sizeMode;
432
- this.minAttenuatedSize = source.minAttenuatedSize;
433
- this.maxAttenuatedSize = source.maxAttenuatedSize;
434
- this.picking = source.picking;
435
- this.scale = source.scale;
436
- this.overlayColor.copy(source.overlayColor);
437
- this.intensityRange.copy(source.intensityRange);
438
- this.elevationRange.copy(source.elevationRange);
439
- this.angleRange.copy(source.angleRange);
440
- Object.assign(this.defines, source.defines);
441
- return this;
442
- }
443
478
  set gradient(value) {
444
479
  this.gradientTexture = generateGradientTexture(value);
445
480
  }
@@ -5,7 +5,6 @@ const MODES = {
5
5
  // depth buffer
6
6
  ID: 2 // id object
7
7
  };
8
-
9
8
  function push(object3d, mode) {
10
9
  const _mode = object3d.mode ?? MODES.FINAL;
11
10
  if (_mode == mode) {
@@ -130,7 +130,7 @@ class FileSource extends Source {
130
130
  }
131
131
 
132
132
  // the fake url is for when we use the fetchedData or features mode
133
- source.url = source.url || 'fake-file-url';
133
+ source.url = source.url || 'none';
134
134
  super(source);
135
135
  this.isFileSource = true;
136
136
  this.fetchedData = source.fetchedData;
@@ -0,0 +1,172 @@
1
+ import Source from "./Source.js";
2
+ import Fetcher from "../Provider/Fetcher.js";
3
+ import Potree2BinParser from "../Parser/Potree2BinParser.js";
4
+
5
+ /**
6
+ * @classdesc
7
+ * Potree2Source are object containing informations on how to fetch potree 2.0 points cloud resources.
8
+ *
9
+ *
10
+ */
11
+
12
+ class Potree2Source extends Source {
13
+ /**
14
+ * @param {Object} source - An object that can contain all properties of a
15
+ * Potree2Source
16
+ * @param {string} source.url - folder url.
17
+ * @param {string} source.file - metadata file name.
18
+ *
19
+ * This `metadata` file stores information about the potree cloud 2.0 in JSON format. the structure is :
20
+ *
21
+ * * __`version`__ - The metadata.json format may change over time. The version number is
22
+ * necessary so that parsers know how to interpret the data.
23
+ * * __`name`__ - Point cloud name.
24
+ * * __`description`__ - Point cloud description.
25
+ * * __`points`__ - Total number of points.
26
+ * * __`projection`__ - Point cloud geographic projection system.
27
+ * * __`hierarchy`__ - Information about point cloud hierarchy (first chunk size, step size, octree depth).
28
+ * * __`offset`__ - Position offset used to determine the global point position.
29
+ * * __`scale`__ - Point cloud scale.
30
+ * * __`spacing`__ - The minimum distance between points at root level.
31
+ * * __`boundingBox`__ - Contains the minimum and maximum of the axis aligned bounding box. This bounding box is cubic and aligned to fit to the octree root.
32
+ * * __`encoding`__ - Encoding type: BROTLI or DEFAULT (uncompressed).
33
+ * * __`attributes`__ - Array of attributes (position, intensity, return number, number of returns, classification, scan angle rank, user data, point source id, gps-time, rgb).
34
+ * ```
35
+ * {
36
+ * version: '2.0',
37
+ * name: "sample",
38
+ * description: "",
39
+ * points: 534909153,
40
+ * projection: "",
41
+ * hierarchy: {
42
+ * firstChunkSize: 1276,
43
+ * stepSize: 4,
44
+ * depth: 16
45
+ * },
46
+ * offset: [1339072.07, 7238866.339, 85.281],
47
+ * scale: [0.001, 0.001, 0.002],
48
+ * spacing: 24.476062500005355,
49
+ * boundingBox: {
50
+ * min: [1339072.07, 7238866.339, 85.281],
51
+ * max: [1342205.0060000008, 7241999.275, 3218.2170000006854]
52
+ * },
53
+ * encoding: "BROTLI",
54
+ * attributes: [
55
+ * {
56
+ * name: "position",
57
+ * description: "",
58
+ * size: 12,
59
+ * numElements: 3,
60
+ * elementSize: 4,
61
+ * type: "int32",
62
+ * min: [-0.74821299314498901, -2.7804059982299805, 2.5478212833404541],
63
+ * max: [2.4514148223438199, 1.4893437627414672, 7.1957106576508663]
64
+ * },
65
+ * {
66
+ * name: "intensity",
67
+ * description: "",
68
+ * size: 2,
69
+ * numElements: 1,
70
+ * elementSize: 2,
71
+ * type: "uint16",
72
+ * min: [0],
73
+ * max: [0]
74
+ * },{
75
+ * name: "return number",
76
+ * description: "",
77
+ * size: 1,
78
+ * numElements: 1,
79
+ * elementSize: 1,
80
+ * type: "uint8",
81
+ * min: [0],
82
+ * max: [0]
83
+ * },{
84
+ * name: "number of returns",
85
+ * description: "",
86
+ * size: 1,
87
+ * numElements: 1,
88
+ * elementSize: 1,
89
+ * type: "uint8",
90
+ * min: [0],
91
+ * max: [0]
92
+ * },{
93
+ * name: "classification",
94
+ * description: "",
95
+ * size: 1,
96
+ * numElements: 1,
97
+ * elementSize: 1,
98
+ * type: "uint8",
99
+ * min: [0],
100
+ * max: [0]
101
+ * },{
102
+ * name: "scan angle rank",
103
+ * description: "",
104
+ * size: 1,
105
+ * numElements: 1,
106
+ * elementSize: 1,
107
+ * type: "uint8",
108
+ * min: [0],
109
+ * max: [0]
110
+ * },{
111
+ * name: "user data",
112
+ * description: "",
113
+ * size: 1,
114
+ * numElements: 1,
115
+ * elementSize: 1,
116
+ * type: "uint8",
117
+ * min: [0],
118
+ * max: [0]
119
+ * },{
120
+ * name: "point source id",
121
+ * description: "",
122
+ * size: 2,
123
+ * numElements: 1,
124
+ * elementSize: 2,
125
+ * type: "uint16",
126
+ * min: [0],
127
+ * max: [0]
128
+ * },{
129
+ * name: "gps-time",
130
+ * description: "",
131
+ * size: 8,
132
+ * numElements: 1,
133
+ * elementSize: 8,
134
+ * type: "double",
135
+ * min: [0],
136
+ * max: [0]
137
+ * },{
138
+ * name: "rgb",
139
+ * description: "",
140
+ * size: 6,
141
+ * numElements: 3,
142
+ * elementSize: 2,
143
+ * type: "uint16",
144
+ * min: [5632, 5376, 4864],
145
+ * max: [65280, 65280, 65280]
146
+ * }
147
+ * ]
148
+ * }
149
+ * ```
150
+ *
151
+ * @extends Source
152
+ *
153
+ * @constructor
154
+ */
155
+ constructor(source) {
156
+ if (!source.file) {
157
+ throw new Error('New Potree2Source: file is required');
158
+ }
159
+ super(source);
160
+ this.file = source.file;
161
+ this.fetcher = Fetcher.arrayBuffer;
162
+ this.whenReady = (source.metadata ? Promise.resolve(source.metadata) : Fetcher.json(`${this.url}/${this.file}`, this.networkOptions)).then(metadata => {
163
+ this.metadata = metadata;
164
+ this.pointAttributes = metadata.attributes;
165
+ this.baseurl = `${this.url}`;
166
+ this.extension = 'bin';
167
+ this.parser = Potree2BinParser.parse;
168
+ return metadata;
169
+ });
170
+ }
171
+ }
172
+ export default Potree2Source;
@@ -17,23 +17,29 @@ class DDSLoader extends CompressedTextureLoader {
17
17
 
18
18
  // All values and structures referenced from:
19
19
  // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
20
+
20
21
  // const DDSD_CAPS = 0x1;
21
22
  // const DDSD_HEIGHT = 0x2;
22
23
  // const DDSD_WIDTH = 0x4;
23
24
  // const DDSD_PITCH = 0x8;
24
25
  // const DDSD_PIXELFORMAT = 0x1000;
26
+
25
27
  // const DDSD_LINEARSIZE = 0x80000;
26
28
  // const DDSD_DEPTH = 0x800000;
29
+
27
30
  // const DDSCAPS_COMPLEX = 0x8;
28
31
  // const DDSCAPS_MIPMAP = 0x400000;
29
32
  // const DDSCAPS_TEXTURE = 0x1000;
33
+
30
34
  // const DDSCAPS2_VOLUME = 0x200000;
35
+
31
36
  // const DDPF_ALPHAPIXELS = 0x1;
32
37
  // const DDPF_ALPHA = 0x2;
33
38
  // const DDPF_FOURCC = 0x4;
34
39
  // const DDPF_RGB = 0x40;
35
40
  // const DDPF_YUV = 0x200;
36
41
  // const DDPF_LUMINANCE = 0x20000;
42
+
37
43
  function fourCCToInt32(value) {
38
44
  return value.charCodeAt(0) + (value.charCodeAt(1) << 8) + (value.charCodeAt(2) << 16) + (value.charCodeAt(3) << 24);
39
45
  }
@@ -66,7 +72,6 @@ class DDSLoader extends CompressedTextureLoader {
66
72
  dst++; //a
67
73
  }
68
74
  }
69
-
70
75
  return byteArray;
71
76
  }
72
77
  const FOURCC_DXT1 = fourCCToInt32('DXT1');
@@ -78,11 +83,16 @@ class DDSLoader extends CompressedTextureLoader {
78
83
  const extendedHeaderLengthInt = 5; // The extended header length in 32 bit ints
79
84
 
80
85
  // Offsets into the header array
86
+
81
87
  // const off_pfFlags = 20;
88
+
82
89
  // const off_caps = 27;
90
+
83
91
  // const off_caps3 = 29;
84
92
  // const off_caps4 = 30;
93
+
85
94
  // If fourCC = DX10, the extended header starts after 32
95
+
86
96
  // Parse header
87
97
 
88
98
  const header = new Int32Array(buffer, 0, headerLengthInt);
@@ -261,7 +261,6 @@ function DRACOWorker() {
261
261
  };
262
262
  DracoDecoderModule(decoderConfig); // eslint-disable-line no-undef
263
263
  });
264
-
265
264
  break;
266
265
  case 'decode':
267
266
  const buffer = message.buffer;
@@ -2627,6 +2627,7 @@ class GLTFParser {
2627
2627
 
2628
2628
  // Removes dangling associations, associations that reference a node that
2629
2629
  // didn't make it into the scene.
2630
+
2630
2631
  parser.associations = (node => {
2631
2632
  const reducedAssociations = new Map();
2632
2633
  for (const [key, value] of parser.associations) {
@@ -255,6 +255,7 @@ function _readZCorrect(layer, texture, uv, tileDimensions, tileOwnerDimensions)
255
255
 
256
256
  // Determine if we're going to read the vertices from the top-left or lower-right triangle
257
257
  // (low-right = on the line 21-22 or under the diagonal lu = 1 - lv)
258
+
258
259
  const tri = new THREE.Triangle(new THREE.Vector3(u1, v2), new THREE.Vector3(u2, v1), lv == 1 || lu / (1 - lv) >= 1 ? new THREE.Vector3(u2, v2) : new THREE.Vector3(u1, v1));
259
260
 
260
261
  // bary holds the respective weight of each vertices of the triangles
@@ -287,11 +288,10 @@ function offsetInExtent(point, extent) {
287
288
  return target.set(originX, originY);
288
289
  }
289
290
  function _readZ(layer, method, coord, nodes, cache) {
290
- var _cache$tile;
291
291
  const pt = coord.as(layer.extent.crs, temp.coord1);
292
292
  let tileWithValidElevationTexture = null;
293
293
  // first check in cache
294
- if (cache !== null && cache !== void 0 && (_cache$tile = cache.tile) !== null && _cache$tile !== void 0 && _cache$tile.material) {
294
+ if (cache?.tile?.material) {
295
295
  tileWithValidElevationTexture = tileAt(pt, cache.tile);
296
296
  }
297
297
  for (let i = 0; !tileWithValidElevationTexture && i < nodes.length; i++) {
@@ -71,7 +71,6 @@ export default {
71
71
  // return this.setFromEuler(euler.set(pitch, roll, heading , 'ZXY')).conjugate();
72
72
  return target.setFromEuler(euler.set(-pitch, -roll, -heading, 'YXZ')); // optimized version of above
73
73
  },
74
-
75
74
  /**
76
75
  * From
77
76
  * [DocMicMac](https://github.com/micmacIGN/Documentation/raw/master/DocMicMac.pdf),
@@ -9,7 +9,6 @@ const DEFAULT_OPTIONS = {
9
9
  placeholder: 'Search location'
10
10
  };
11
11
  function addActive(htmlElements, index) {
12
- var _htmlElements$index;
13
12
  if (!htmlElements) {
14
13
  return index;
15
14
  }
@@ -19,7 +18,7 @@ function addActive(htmlElements, index) {
19
18
  } else if (index < 0) {
20
19
  index = htmlElements.length - 1;
21
20
  }
22
- (_htmlElements$index = htmlElements[index]) === null || _htmlElements$index === void 0 ? void 0 : _htmlElements$index.classList.add('active');
21
+ htmlElements[index]?.classList.add('active');
23
22
  return index;
24
23
  }
25
24
  function removeAllActives(htmlElements) {