itowns 2.43.2-next.6 → 2.43.2-next.8

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.
@@ -21,7 +21,7 @@ export default {
21
21
  const backgroundLayer = layer.source.backgroundLayer;
22
22
  const backgroundColor = backgroundLayer && backgroundLayer.paint ? new THREE.Color(backgroundLayer.paint['background-color']) : undefined;
23
23
  extentDestination.as(CRS.formatToEPSG(layer.crs), extentTexture);
24
- texture = Feature2Texture.createTextureFromFeature(data, extentTexture, 256, layer.style, backgroundColor);
24
+ texture = Feature2Texture.createTextureFromFeature(data, extentTexture, layer.subdivisionThreshold, layer.style, backgroundColor);
25
25
  texture.features = data;
26
26
  texture.extent = extentDestination;
27
27
  } else if (data.isTexture) {
@@ -3,7 +3,6 @@ import TiledGeometryLayer from "../../../Layer/TiledGeometryLayer.js";
3
3
  import { ellipsoidSizes } from "../../Math/Ellipsoid.js";
4
4
  import { globalExtentTMS, schemeTiles } from "../../Geographic/Extent.js";
5
5
  import BuilderEllipsoidTile from "./BuilderEllipsoidTile.js";
6
- import { SIZE_DIAGONAL_TEXTURE } from "../../../Process/LayeredMaterialNodeProcessing.js";
7
6
  import CRS from "../../Geographic/Crs.js";
8
7
 
9
8
  // matrix to convert sphere to ellipsoid
@@ -129,7 +128,7 @@ class GlobeLayer extends TiledGeometryLayer {
129
128
  return isOccluded;
130
129
  }
131
130
  computeTileZoomFromDistanceCamera(distance, camera) {
132
- const preSinus = SIZE_DIAGONAL_TEXTURE * (this.sseSubdivisionThreshold * 0.5) / camera._preSSE / ellipsoidSizes.x;
131
+ const preSinus = this.sizeDiagonalTexture * (this.sseSubdivisionThreshold * 0.5) / camera._preSSE / ellipsoidSizes.x;
133
132
  let sinus = distance * preSinus;
134
133
  let zoom = Math.log(Math.PI / (2.0 * Math.asin(sinus))) / Math.log(2);
135
134
  const delta = Math.PI / 2 ** zoom;
@@ -143,7 +142,8 @@ class GlobeLayer extends TiledGeometryLayer {
143
142
  const delta = Math.PI / 2 ** zoom;
144
143
  const circleChord = 2.0 * ellipsoidSizes.x * Math.sin(delta * 0.5);
145
144
  const radius = circleChord * 0.5;
146
- return camera._preSSE * (radius / SIZE_DIAGONAL_TEXTURE) / (this.sseSubdivisionThreshold * 0.5) + radius;
145
+ const error = radius / this.sizeDiagonalTexture;
146
+ return camera._preSSE * error / (this.sseSubdivisionThreshold * 0.5) + radius;
147
147
  }
148
148
  }
149
149
  export default GlobeLayer;
@@ -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
@@ -109,6 +110,8 @@ class Layer extends THREE.EventDispatcher {
109
110
  config.style = new Style(config.style);
110
111
  }
111
112
  this.style = config.style || new Style();
113
+ this.subdivisionThreshold = config.subdivisionThreshold || 256;
114
+ this.sizeDiagonalTexture = (2 * (this.subdivisionThreshold * this.subdivisionThreshold)) ** 0.5;
112
115
  Object.assign(this, config);
113
116
  Object.defineProperty(this, 'id', {
114
117
  value: id,
@@ -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
  }
@@ -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.
@@ -390,7 +390,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
390
390
  }
391
391
  }
392
392
  recomputeClassification() {
393
- const needTransparency = recomputeTexture(this.classificationScheme, this.classificationTexture, 32);
393
+ const needTransparency = recomputeTexture(this.classificationScheme, this.classificationTexture, 256);
394
394
  this.userData.needTransparency[PNTS_MODE.CLASSIFICATION] = needTransparency;
395
395
  this.dispatchEvent({
396
396
  type: 'material_property_changed',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.43.2-next.6",
3
+ "version": "2.43.2-next.8",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",