itowns 2.43.2-next.1 → 2.43.2-next.11

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 (60) hide show
  1. package/README.md +2 -0
  2. package/dist/debug.js +1 -1
  3. package/dist/debug.js.map +1 -1
  4. package/dist/itowns.js +1 -1
  5. package/dist/itowns.js.map +1 -1
  6. package/dist/itowns_widgets.js +1 -1
  7. package/dist/itowns_widgets.js.map +1 -1
  8. package/examples/3dtiles_25d.html +1 -1
  9. package/examples/3dtiles_basic.html +2 -2
  10. package/examples/3dtiles_batch_table.html +1 -3
  11. package/examples/3dtiles_pointcloud.html +9 -15
  12. package/examples/copc_simple_loader.html +1 -1
  13. package/examples/entwine_3d_loader.html +1 -1
  14. package/examples/entwine_simple_loader.html +1 -1
  15. package/examples/js/plugins/COGParser.js +84 -50
  16. package/examples/js/plugins/COGSource.js +7 -4
  17. package/examples/layers/JSONLayers/OPENSM.json +1 -1
  18. package/examples/potree_25d_map.html +1 -1
  19. package/examples/potree_3d_map.html +1 -1
  20. package/examples/source_file_cog.html +22 -5
  21. package/lib/Controls/FirstPersonControls.js +0 -1
  22. package/lib/Controls/FlyControls.js +0 -1
  23. package/lib/Converter/Feature2Mesh.js +2 -4
  24. package/lib/Converter/textureConverter.js +1 -1
  25. package/lib/Core/3DTiles/C3DTBatchTable.js +1 -1
  26. package/lib/Core/3DTiles/C3DTFeature.js +0 -1
  27. package/lib/Core/Feature.js +1 -2
  28. package/lib/Core/Geographic/CoordStars.js +0 -1
  29. package/lib/Core/Label.js +0 -1
  30. package/lib/Core/MainLoop.js +0 -1
  31. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -4
  32. package/lib/Core/Prefab/Globe/GlobeLayer.js +3 -3
  33. package/lib/Core/Style.js +2 -4
  34. package/lib/Core/View.js +2 -4
  35. package/lib/Layer/C3DTilesLayer.js +3 -1
  36. package/lib/Layer/ElevationLayer.js +2 -3
  37. package/lib/Layer/GeoidLayer.js +1 -2
  38. package/lib/Layer/LabelLayer.js +8 -17
  39. package/lib/Layer/Layer.js +4 -2
  40. package/lib/Layer/PointCloudLayer.js +4 -7
  41. package/lib/Layer/ReferencingLayerProperties.js +3 -3
  42. package/lib/Layer/TiledGeometryLayer.js +2 -3
  43. package/lib/Parser/GeoJsonParser.js +2 -3
  44. package/lib/Parser/LASParser.js +2 -3
  45. package/lib/Parser/deprecated/LegacyGLTFLoader.js +1 -2
  46. package/lib/Process/FeatureProcessing.js +1 -2
  47. package/lib/Process/LayeredMaterialNodeProcessing.js +3 -9
  48. package/lib/Process/ObjectRemovalHelper.js +1 -2
  49. package/lib/Provider/3dTilesProvider.js +1 -0
  50. package/lib/Renderer/ColorLayersOrdering.js +1 -2
  51. package/lib/Renderer/Label2DRenderer.js +1 -4
  52. package/lib/Renderer/PointsMaterial.js +14 -9
  53. package/lib/Renderer/RenderMode.js +0 -1
  54. package/lib/ThreeExtended/loaders/DDSLoader.js +11 -1
  55. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -1
  56. package/lib/ThreeExtended/loaders/GLTFLoader.js +1 -0
  57. package/lib/Utils/DEMUtils.js +2 -2
  58. package/lib/Utils/OrientationUtils.js +0 -1
  59. package/lib/Utils/gui/Searchbar.js +1 -2
  60. package/package.json +8 -7
@@ -66,6 +66,7 @@ class Layer extends THREE.EventDispatcher {
66
66
  * @param {boolean} [config.addLabelLayer.performance=false] - In case label layer adding, so remove labels that have no chance of being visible.
67
67
  * Indeed, even in the best case, labels will never be displayed. By example, if there's many labels.
68
68
  * @param {boolean} [config.addLabelLayer.forceClampToTerrain=false] - use elevation layer to clamp label on terrain.
69
+ * @param {number} [config.subdivisionThreshold=256] - set the texture size and, if applied to the globe, affects the tile subdivision.
69
70
  *
70
71
  * @example
71
72
  * // Add and create a new Layer
@@ -100,8 +101,7 @@ class Layer extends THREE.EventDispatcher {
100
101
  super();
101
102
  this.isLayer = true;
102
103
  if (config.style && !(config.style instanceof Style)) {
103
- var _config$style$fill;
104
- if (typeof ((_config$style$fill = config.style.fill) === null || _config$style$fill === void 0 ? void 0 : _config$style$fill.pattern) === 'string') {
104
+ if (typeof config.style.fill?.pattern === 'string') {
105
105
  console.warn('Using style.fill.pattern = { source: Img|url } is adviced');
106
106
  config.style.fill.pattern = {
107
107
  source: config.style.fill.pattern
@@ -110,6 +110,8 @@ class Layer extends THREE.EventDispatcher {
110
110
  config.style = new Style(config.style);
111
111
  }
112
112
  this.style = config.style || new Style();
113
+ this.subdivisionThreshold = config.subdivisionThreshold || 256;
114
+ this.sizeDiagonalTexture = (2 * (this.subdivisionThreshold * this.subdivisionThreshold)) ** 0.5;
113
115
  Object.assign(this, config);
114
116
  Object.defineProperty(this, 'id', {
115
117
  value: id,
@@ -73,16 +73,13 @@ function markForDeletion(elt) {
73
73
  }
74
74
  }
75
75
  function changeIntensityRange(layer) {
76
- var _layer$material$inten;
77
- (_layer$material$inten = layer.material.intensityRange) === null || _layer$material$inten === void 0 ? void 0 : _layer$material$inten.set(layer.minIntensityRange, layer.maxIntensityRange);
76
+ layer.material.intensityRange?.set(layer.minIntensityRange, layer.maxIntensityRange);
78
77
  }
79
78
  function changeElevationRange(layer) {
80
- var _layer$material$eleva;
81
- (_layer$material$eleva = layer.material.elevationRange) === null || _layer$material$eleva === void 0 ? void 0 : _layer$material$eleva.set(layer.minElevationRange, layer.maxElevationRange);
79
+ layer.material.elevationRange?.set(layer.minElevationRange, layer.maxElevationRange);
82
80
  }
83
81
  function changeAngleRange(layer) {
84
- var _layer$material$angle;
85
- (_layer$material$angle = layer.material.angleRange) === null || _layer$material$angle === void 0 ? void 0 : _layer$material$angle.set(layer.minAngleRange, layer.maxAngleRange);
82
+ layer.material.angleRange?.set(layer.minAngleRange, layer.maxAngleRange);
86
83
  }
87
84
 
88
85
  /**
@@ -176,7 +173,7 @@ class PointCloudLayer extends GeometryLayer {
176
173
  if (this.material) {
177
174
  this.material.visible = this.visible;
178
175
  this.material.opacity = this.opacity;
179
- this.material.transparent = this.opacity < 1;
176
+ this.material.transparent = this.opacity < 1 || this.material.userData.needTransparency[this.material.mode];
180
177
  this.material.size = this.pointSize;
181
178
  this.material.scale = context.camera.preSSE;
182
179
  if (this.material.updateUniforms) {
@@ -1,6 +1,5 @@
1
1
  // next step is move these properties to Style class
2
2
  // and hide transparent mechanism
3
-
4
3
  function ReferLayerProperties(material, layer) {
5
4
  if (layer && layer.isGeometryLayer) {
6
5
  let transparent = material.transparent;
@@ -44,9 +43,10 @@ function ReferLayerProperties(material, layer) {
44
43
  });
45
44
  Object.defineProperty(material, 'transparent', {
46
45
  get: () => {
47
- if (transparent != material.layer.opacity < 1.0) {
46
+ const needTransparency = material.userData.needTransparency?.[material.mode] || material.layer.opacity < 1.0;
47
+ if (transparent != needTransparency) {
48
48
  material.needsUpdate = true;
49
- transparent = material.layer.opacity < 1.0;
49
+ transparent = needTransparency;
50
50
  }
51
51
  return transparent;
52
52
  }
@@ -4,7 +4,6 @@ import { InfoTiledGeometryLayer } from "./InfoLayer.js";
4
4
  import Picking from "../Core/Picking.js";
5
5
  import convertToTile from "../Converter/convertToTile.js";
6
6
  import ObjectRemovalHelper from "../Process/ObjectRemovalHelper.js";
7
- import { SIZE_DIAGONAL_TEXTURE } from "../Process/LayeredMaterialNodeProcessing.js";
8
7
  import { ImageryLayers } from "./Layer.js";
9
8
  import { CACHE_POLICIES } from "../Core/Scheduler/Cache.js";
10
9
  const subdivisionVector = new THREE.Vector3();
@@ -89,7 +88,7 @@ class TiledGeometryLayer extends GeometryLayer {
89
88
  this.object3d.add(...level0s);
90
89
  this.object3d.updateMatrixWorld();
91
90
  }));
92
- this.maxScreenSizeNode = this.sseSubdivisionThreshold * (SIZE_DIAGONAL_TEXTURE * 2);
91
+ this.maxScreenSizeNode = this.sseSubdivisionThreshold * (this.sizeDiagonalTexture * 2);
93
92
  }
94
93
  get hideSkirt() {
95
94
  return this._hideSkirt;
@@ -408,7 +407,7 @@ class TiledGeometryLayer extends GeometryLayer {
408
407
 
409
408
  // The screen space error is calculated to have a correct texture display.
410
409
  // For the projection of a texture's texel to be less than or equal to one pixel
411
- const sse = node.screenSize / (SIZE_DIAGONAL_TEXTURE * 2);
410
+ const sse = node.screenSize / (this.sizeDiagonalTexture * 2);
412
411
  return this.sseSubdivisionThreshold < sse;
413
412
  }
414
413
  }
@@ -132,8 +132,7 @@ function toFeatureType(jsonType) {
132
132
  const keyProperties = ['type', 'geometry', 'properties'];
133
133
  const firstCoordinates = a => a === undefined || Array.isArray(a) && !isNaN(a[0]) ? a : firstCoordinates(a[0]);
134
134
  function jsonFeatureToFeature(crsIn, json, collection) {
135
- var _json$geometry, _firstCoordinates;
136
- if (!((_json$geometry = json.geometry) !== null && _json$geometry !== void 0 && _json$geometry.type)) {
135
+ if (!json.geometry?.type) {
137
136
  console.warn('No geometry provided');
138
137
  return null;
139
138
  }
@@ -142,7 +141,7 @@ function jsonFeatureToFeature(crsIn, json, collection) {
142
141
  const feature = collection.requestFeatureByType(featureType);
143
142
  const coordinates = jsonType != 'point' ? json.geometry.coordinates : [json.geometry.coordinates];
144
143
  const properties = json.properties || {};
145
- feature.hasRawElevationData = ((_firstCoordinates = firstCoordinates(coordinates)) === null || _firstCoordinates === void 0 ? void 0 : _firstCoordinates.length) === 3;
144
+ feature.hasRawElevationData = firstCoordinates(coordinates)?.length === 3;
146
145
 
147
146
  // copy other properties
148
147
  for (const key of Object.keys(json)) {
@@ -89,13 +89,12 @@ export default {
89
89
  * header of the file is contained in `userData`.
90
90
  */
91
91
  parse(data) {
92
- var _options$out, _options$in;
93
92
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
94
- if ((_options$out = options.out) !== null && _options$out !== void 0 && _options$out.skip) {
93
+ if (options.out?.skip) {
95
94
  console.warn("Warning: options 'skip' not supported anymore");
96
95
  }
97
96
  return lasLoader.parseFile(data, {
98
- colorDepth: (_options$in = options.in) === null || _options$in === void 0 ? void 0 : _options$in.colorDepth
97
+ colorDepth: options.in?.colorDepth
99
98
  }).then(parsedData => {
100
99
  const geometry = buildBufferGeometry(parsedData.attributes);
101
100
  geometry.userData.header = parsedData.header;
@@ -321,7 +321,6 @@ threeExamples.LegacyGLTFLoader = function () {
321
321
  1029: THREE.FrontSide // Culling back
322
322
  //1032: THREE.NoSide // Culling front and back, what to do?
323
323
  };
324
-
325
324
  var WEBGL_DEPTH_FUNCS = {
326
325
  512: THREE.NeverDepth,
327
326
  513: THREE.LessDepth,
@@ -355,7 +354,6 @@ threeExamples.LegacyGLTFLoader = function () {
355
354
  //32771: CONSTANT_ALPHA,
356
355
  //32772: ONE_MINUS_CONSTANT_COLOR
357
356
  };
358
-
359
357
  var WEBGL_TYPE_SIZES = {
360
358
  'SCALAR': 1,
361
359
  'VEC2': 2,
@@ -1116,6 +1114,7 @@ threeExamples.LegacyGLTFLoader = function () {
1116
1114
 
1117
1115
  // According to COLLADA spec...
1118
1116
  // aspectRatio = xfov / yfov
1117
+
1119
1118
  var _camera = new THREE.PerspectiveCamera(THREE.MathUtils.radToDeg(yfov * aspectRatio), aspectRatio, camera.perspective.znear || 1, camera.perspective.zfar || 2e6);
1120
1119
  if (camera.name !== undefined) _camera.name = camera.name;
1121
1120
  if (camera.extras) _camera.userData = camera.extras;
@@ -17,9 +17,8 @@ export default {
17
17
  if (node.layerUpdateState[layer.id] === undefined) {
18
18
  node.layerUpdateState[layer.id] = new LayerUpdateState();
19
19
  } else if (!node.layerUpdateState[layer.id].canTryUpdate()) {
20
- var _node$link$layer$id;
21
20
  // toggle visibility features
22
- (_node$link$layer$id = node.link[layer.id]) === null || _node$link$layer$id === void 0 ? void 0 : _node$link$layer$id.forEach(f => {
21
+ node.link[layer.id]?.forEach(f => {
23
22
  f.layer.object3d.add(f);
24
23
  f.meshes.position.z = geoidLayerIsVisible(layer.parent) ? node.geoidHeight : 0;
25
24
  f.meshes.updateMatrixWorld();
@@ -1,8 +1,6 @@
1
1
  import { chooseNextLevelToFetch } from "../Layer/LayerUpdateStrategy.js";
2
2
  import LayerUpdateState from "../Layer/LayerUpdateState.js";
3
3
  import handlingError from "./handlerNodeError.js";
4
- export const SIZE_TEXTURE_TILE = 256;
5
- export const SIZE_DIAGONAL_TEXTURE = (2 * (SIZE_TEXTURE_TILE * SIZE_TEXTURE_TILE)) ** 0.5;
6
4
  function materialCommandQueuePriorityFunction(material) {
7
5
  // We know that 'node' is visible because commands can only be
8
6
  // issued for visible nodes.
@@ -62,14 +60,12 @@ export function updateLayeredMaterialNodeImagery(context, layer, node, parent) {
62
60
  return;
63
61
  } // ok, we're going to inherit our parent's texture
64
62
  }
65
-
66
63
  if (!nodeLayer) {
67
- var _parent$material;
68
64
  // Create new raster node
69
65
  nodeLayer = layer.setupRasterNode(node);
70
66
 
71
67
  // Init the node by parent
72
- const parentLayer = (_parent$material = parent.material) === null || _parent$material === void 0 ? void 0 : _parent$material.getLayer(layer.id);
68
+ const parentLayer = parent.material?.getLayer(layer.id);
73
69
  nodeLayer.initFromParent(parentLayer, extentsDestination);
74
70
  }
75
71
 
@@ -158,9 +154,8 @@ export function updateLayeredMaterialNodeElevation(context, layer, node, parent)
158
154
  nodeLayer = layer.setupRasterNode(node);
159
155
  }
160
156
  if (node.layerUpdateState[layer.id] === undefined) {
161
- var _parent$material2;
162
157
  node.layerUpdateState[layer.id] = new LayerUpdateState();
163
- const parentLayer = (_parent$material2 = parent.material) === null || _parent$material2 === void 0 ? void 0 : _parent$material2.getLayer(layer.id);
158
+ const parentLayer = parent.material?.getLayer(layer.id);
164
159
  nodeLayer.initFromParent(parentLayer, extentsDestination);
165
160
  if (nodeLayer.level >= layer.source.zoom.min) {
166
161
  context.view.notifyChange(node, false);
@@ -210,8 +205,7 @@ export function removeLayeredMaterialNodeLayer(layerId) {
210
205
  * @param {TileMesh} node - The node to udpate.
211
206
  */
212
207
  return function (node) {
213
- var _node$material;
214
- if ((_node$material = node.material) !== null && _node$material !== void 0 && _node$material.removeLayer) {
208
+ if (node.material?.removeLayer) {
215
209
  if (node.material.elevationLayerIds.indexOf(layerId) > -1) {
216
210
  node.setBBoxZ({
217
211
  min: 0,
@@ -28,7 +28,6 @@ export default {
28
28
  // see https://github.com/iTowns/itowns/issues/869
29
29
  // obj.geometry = null;
30
30
  }
31
-
32
31
  if (obj.material) {
33
32
  if (Array.isArray(obj.material)) {
34
33
  for (const material of obj.material) {
@@ -82,7 +81,7 @@ export default {
82
81
  // of the objects which have their own removal logic
83
82
  let toRemove = obj.children.filter(c => c.layer && c.layer.id === layer.id);
84
83
  const linked = obj.link && obj.link[layer.id];
85
- if (linked !== null && linked !== void 0 && linked.children.length) {
84
+ if (linked?.children.length) {
86
85
  toRemove = toRemove.concat(linked.children);
87
86
  delete obj.link[layer.id];
88
87
  }
@@ -114,6 +114,7 @@ function executeCommand(command) {
114
114
  } else if (magic == 'b3dm') {
115
115
  func = supportedFormats.b3dm;
116
116
  } else if (magic == 'pnts') {
117
+ layer.hasPnts = true;
117
118
  func = supportedFormats.pnts;
118
119
  } else if (magic == 'glTF') {
119
120
  func = supportedFormats.gltf;
@@ -2,8 +2,7 @@ import { ImageryLayers } from "../Layer/Layer.js";
2
2
  function updateLayersOrdering(geometryLayer, imageryLayers) {
3
3
  const sequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers);
4
4
  const cO = function (object) {
5
- var _object$material;
6
- if ((_object$material = object.material) !== null && _object$material !== void 0 && _object$material.setSequence) {
5
+ if (object.material?.setSequence) {
7
6
  object.material.setSequence(sequence);
8
7
  }
9
8
  };
@@ -157,10 +157,7 @@ class Label2DRenderer {
157
157
  }
158
158
  });
159
159
  labelLayers.forEach(labelLayer => {
160
- labelLayer.toHide.children.forEach(labelsNode => {
161
- var _labelsNode$domElemen;
162
- return (_labelsNode$domElemen = labelsNode.domElements) === null || _labelsNode$domElemen === void 0 ? void 0 : _labelsNode$domElemen.labels.hide();
163
- });
160
+ labelLayer.toHide.children.forEach(labelsNode => labelsNode.domElements?.labels.hide());
164
161
  labelLayer.toHide.clear();
165
162
  });
166
163
  }
@@ -1,6 +1,6 @@
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 <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 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 = 1.0;\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 // 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 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 vColor.a *= opacity;\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";
4
4
  /* babel-plugin-inline-import './Shader/PointsFS.glsl' */
5
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
6
  import ShaderUtils from "./Shader/ShaderUtils.js";
@@ -127,7 +127,7 @@ export const ClassificationScheme = {
127
127
  visible: true,
128
128
  name: 'default',
129
129
  color: new THREE.Color(0.3, 0.6, 0.6),
130
- opacity: 0.5
130
+ opacity: 1.0
131
131
  }
132
132
  }
133
133
  };
@@ -185,7 +185,7 @@ const DiscreteScheme = {
185
185
  visible: true,
186
186
  name: 'default',
187
187
  color: white,
188
- opacity: 0.5
188
+ opacity: 1.0
189
189
  }
190
190
  }
191
191
  };
@@ -220,6 +220,7 @@ function generateGradientTexture(gradient) {
220
220
  return texture;
221
221
  }
222
222
  function recomputeTexture(scheme, texture, nbClass) {
223
+ let needTransparency;
223
224
  const data = texture.image.data;
224
225
  const width = texture.image.width;
225
226
  if (!nbClass) {
@@ -250,8 +251,10 @@ function recomputeTexture(scheme, texture, nbClass) {
250
251
  data[j + 1] = parseInt(255 * color.g, 10);
251
252
  data[j + 2] = parseInt(255 * color.b, 10);
252
253
  data[j + 3] = visible ? parseInt(255 * opacity, 10) : 0;
254
+ needTransparency = needTransparency || opacity < 1;
253
255
  }
254
256
  texture.needsUpdate = true;
257
+ return needTransparency;
255
258
  }
256
259
  class PointsMaterial extends THREE.ShaderMaterial {
257
260
  /**
@@ -264,7 +267,6 @@ class PointsMaterial extends THREE.ShaderMaterial {
264
267
  * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range.
265
268
  * @param {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range.
266
269
  * @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
270
  * @param {Scheme} [options.classification] LUT for point classification colorization.
269
271
  * @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
270
272
  * @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
@@ -293,7 +295,6 @@ class PointsMaterial extends THREE.ShaderMaterial {
293
295
  const oiMaterial = options.orientedImageMaterial;
294
296
  const classificationScheme = options.classification || ClassificationScheme.DEFAULT;
295
297
  const discreteScheme = options.discreteScheme || DiscreteScheme.DEFAULT;
296
- const applyOpacityClassication = options.applyOpacityClassication == undefined ? false : options.applyOpacityClassication;
297
298
  const size = options.size || 0;
298
299
  const mode = options.mode || PNTS_MODE.COLOR;
299
300
  const shape = options.shape || PNTS_SHAPE.CIRCLE;
@@ -313,7 +314,6 @@ class PointsMaterial extends THREE.ShaderMaterial {
313
314
  delete options.orientedImageMaterial;
314
315
  delete options.classification;
315
316
  delete options.discreteScheme;
316
- delete options.applyOpacityClassication;
317
317
  delete options.size;
318
318
  delete options.mode;
319
319
  delete options.shape;
@@ -322,6 +322,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
322
322
  delete options.maxAttenuatedSize;
323
323
  delete options.gradient;
324
324
  super(options);
325
+ this.userData.needTransparency = {};
325
326
  this.gradients = gradients;
326
327
  this.gradientTexture = new THREE.CanvasTexture();
327
328
  this.vertexShader = PointsVS;
@@ -339,7 +340,6 @@ class PointsMaterial extends THREE.ShaderMaterial {
339
340
  CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange);
340
341
  CommonMaterial.setUniformProperty(this, 'elevationRange', elevationRange);
341
342
  CommonMaterial.setUniformProperty(this, 'angleRange', angleRange);
342
- CommonMaterial.setUniformProperty(this, 'applyOpacityClassication', applyOpacityClassication);
343
343
  CommonMaterial.setUniformProperty(this, 'sizeMode', sizeMode);
344
344
  CommonMaterial.setUniformProperty(this, 'scale', scale);
345
345
  CommonMaterial.setUniformProperty(this, 'minAttenuatedSize', minAttenuatedSize);
@@ -390,14 +390,19 @@ class PointsMaterial extends THREE.ShaderMaterial {
390
390
  }
391
391
  }
392
392
  recomputeClassification() {
393
- recomputeTexture(this.classificationScheme, this.classificationTexture, 32);
393
+ const needTransparency = recomputeTexture(this.classificationScheme, this.classificationTexture, 256);
394
+ this.userData.needTransparency[PNTS_MODE.CLASSIFICATION] = needTransparency;
394
395
  this.dispatchEvent({
395
396
  type: 'material_property_changed',
396
397
  target: this.uniforms
397
398
  });
398
399
  }
399
400
  recomputeDiscreteTexture() {
400
- recomputeTexture(this.discreteScheme, this.discreteTexture);
401
+ const needTransparency = recomputeTexture(this.discreteScheme, this.discreteTexture);
402
+ this.userData.needTransparency[PNTS_MODE.RETURN_NUMBER] = needTransparency;
403
+ this.userData.needTransparency[PNTS_MODE.RETURN_TYPE] = needTransparency;
404
+ this.userData.needTransparency[PNTS_MODE.RETURN_COUNT] = needTransparency;
405
+ this.userData.needTransparency[PNTS_MODE.POINT_SOURCE_ID] = needTransparency;
401
406
  this.dispatchEvent({
402
407
  type: 'material_property_changed',
403
408
  target: this.uniforms
@@ -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) {
@@ -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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.43.2-next.1",
3
+ "version": "2.43.2-next.11",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",
@@ -72,10 +72,11 @@
72
72
  "three": "^0.159.0"
73
73
  },
74
74
  "devDependencies": {
75
- "@babel/cli": "^7.22.5",
76
- "@babel/plugin-transform-runtime": "^7.22.5",
77
- "@babel/preset-env": "^7.22.5",
78
- "@babel/register": "^7.22.5",
75
+ "@babel/cli": "^7.24.6",
76
+ "@babel/core": "^7.24.6",
77
+ "@babel/plugin-transform-runtime": "^7.24.6",
78
+ "@babel/preset-env": "^7.24.6",
79
+ "@babel/register": "^7.24.6",
79
80
  "@types/three": "^0.159.0",
80
81
  "@xmldom/xmldom": "^0.8.10",
81
82
  "babel-inline-import-loader": "^1.0.1",
@@ -96,7 +97,7 @@
96
97
  "cross-env": "^7.0.3",
97
98
  "eslint": "^8.55.0",
98
99
  "eslint-config-airbnb-base": "^15.0.0",
99
- "eslint-import-resolver-webpack": "^0.13.8",
100
+ "eslint-import-resolver-babel-module": "^5.3.2",
100
101
  "eslint-plugin-import": "^2.29.0",
101
102
  "eslint-webpack-plugin": "^4.0.1",
102
103
  "github-url-from-git": "^1.5.0",
@@ -108,7 +109,7 @@
108
109
  "mocha": "^10.2.0",
109
110
  "node-fetch": "^2.7.0",
110
111
  "proj4": "^2.9.2",
111
- "puppeteer": "^21.6.0",
112
+ "puppeteer": "^22.11.2",
112
113
  "q": "^1.5.1",
113
114
  "replace-in-file": "^7.0.2",
114
115
  "sinon": "^17.0.1",