itowns 2.44.3-next.22 → 2.44.3-next.24

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 (37) hide show
  1. package/dist/debug.js +1 -1
  2. package/dist/debug.js.map +1 -1
  3. package/dist/itowns.js +1 -1
  4. package/dist/itowns.js.map +1 -1
  5. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  6. package/examples/source_file_geojson_3d.html +0 -1
  7. package/examples/source_stream_wfs_raster.html +0 -7
  8. package/lib/Converter/Feature2Texture.js +3 -1
  9. package/lib/Converter/convertToTile.js +3 -3
  10. package/lib/Core/Prefab/Globe/Atmosphere.js +4 -2
  11. package/lib/Core/Prefab/Globe/GlobeLayer.js +19 -11
  12. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +111 -0
  13. package/lib/Core/Prefab/Planar/PlanarLayer.js +15 -8
  14. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +43 -43
  15. package/lib/Core/Prefab/TileBuilder.js +27 -32
  16. package/lib/Core/Prefab/computeBufferTileGeometry.js +189 -130
  17. package/lib/Core/TileGeometry.js +112 -28
  18. package/lib/Layer/C3DTilesLayer.js +7 -4
  19. package/lib/Layer/ColorLayer.js +35 -9
  20. package/lib/Layer/CopcLayer.js +5 -0
  21. package/lib/Layer/ElevationLayer.js +39 -7
  22. package/lib/Layer/EntwinePointTileLayer.js +12 -5
  23. package/lib/Layer/FeatureGeometryLayer.js +20 -6
  24. package/lib/Layer/GeometryLayer.js +42 -11
  25. package/lib/Layer/LabelLayer.js +11 -5
  26. package/lib/Layer/Layer.js +83 -57
  27. package/lib/Layer/OGC3DTilesLayer.js +3 -2
  28. package/lib/Layer/OrientedImageLayer.js +12 -4
  29. package/lib/Layer/PointCloudLayer.js +69 -23
  30. package/lib/Layer/Potree2Layer.js +7 -2
  31. package/lib/Layer/PotreeLayer.js +8 -3
  32. package/lib/Layer/RasterLayer.js +12 -2
  33. package/lib/Layer/TiledGeometryLayer.js +69 -13
  34. package/lib/Provider/Fetcher.js +5 -1
  35. package/lib/Renderer/OBB.js +9 -11
  36. package/package.json +1 -1
  37. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
@@ -10,13 +10,13 @@ bboxMesh.geometry.boundingBox = box3;
10
10
  * @property {boolean} isPotreeLayer - Used to checkout whether this layer
11
11
  * is a PotreeLayer. Default is `true`. You should not change this, as it is
12
12
  * used internally for optimisation.
13
+ *
14
+ * @extends PointCloudLayer
13
15
  */
14
16
  class PotreeLayer extends PointCloudLayer {
15
17
  /**
16
18
  * Constructs a new instance of Potree layer.
17
19
  *
18
- * @extends PointCloudLayer
19
- *
20
20
  * @example
21
21
  * // Create a new point cloud layer
22
22
  * const points = new PotreeLayer('points',
@@ -37,12 +37,17 @@ class PotreeLayer extends PointCloudLayer {
37
37
  * contains three elements `name, protocol, extent`, these elements will be
38
38
  * available using `layer.name` or something else depending on the property
39
39
  * name. See the list of properties to know which one can be specified.
40
- * @param {string} [config.crs=ESPG:4326] - The CRS of the {@link View} this
40
+ * @param {string} [config.crs='ESPG:4326'] - The CRS of the {@link View} this
41
41
  * layer will be attached to. This is used to determine the extent of this
42
42
  * layer. Default to `EPSG:4326`.
43
43
  */
44
44
  constructor(id, config) {
45
45
  super(id, config);
46
+
47
+ /**
48
+ * @type {boolean}
49
+ * @readonly
50
+ */
46
51
  this.isPotreeLayer = true;
47
52
  const resolve = this.addInitializationStep();
48
53
  this.source.whenReady.then(cloud => {
@@ -4,8 +4,18 @@ import textureConverter from "../Converter/textureConverter.js";
4
4
  import { CACHE_POLICIES } from "../Core/Scheduler/Cache.js";
5
5
  class RasterLayer extends Layer {
6
6
  constructor(id, config) {
7
- config.cacheLifeTime = config.cacheLifeTime ?? CACHE_POLICIES.TEXTURE;
8
- super(id, config);
7
+ const {
8
+ cacheLifeTime = CACHE_POLICIES.TEXTURE,
9
+ minFilter,
10
+ magFilter,
11
+ ...layerConfig
12
+ } = config;
13
+ super(id, {
14
+ ...layerConfig,
15
+ cacheLifeTime
16
+ });
17
+ this.minFilter = minFilter;
18
+ this.magFilter = magFilter;
9
19
  }
10
20
  convert(data, extentDestination) {
11
21
  return textureConverter.convert(data, extentDestination, this);
@@ -16,6 +16,8 @@ const boundingSphereCenter = new THREE.Vector3();
16
16
  * as it is used internally for optimisation.
17
17
  * @property {boolean} hideSkirt (default false) - Used to hide the skirt (tile borders).
18
18
  * Useful when the layer opacity < 1
19
+ *
20
+ * @extends GeometryLayer
19
21
  */
20
22
  class TiledGeometryLayer extends GeometryLayer {
21
23
  /**
@@ -38,12 +40,10 @@ class TiledGeometryLayer extends GeometryLayer {
38
40
  * It corresponds at meters by pixel. If the projection tile exceeds a certain pixel size (on screen)
39
41
  * then it is subdivided into 4 tiles with a zoom greater than 1.
40
42
  *
41
- * @extends GeometryLayer
42
- *
43
43
  * @param {string} id - The id of the layer, that should be unique. It is
44
44
  * not mandatory, but an error will be emitted if this layer is added a
45
45
  * {@link View} that already has a layer going by that id.
46
- * @param {THREE.Object3d} object3d - The object3d used to contain the
46
+ * @param {THREE.Object3D} object3d - The object3d used to contain the
47
47
  * geometry of the TiledGeometryLayer. It is usually a `THREE.Group`, but it
48
48
  * can be anything inheriting from a `THREE.Object3d`.
49
49
  * @param {Array} schemeTile - extents Array of root tiles
@@ -58,16 +58,63 @@ class TiledGeometryLayer extends GeometryLayer {
58
58
  * @throws {Error} `object3d` must be a valid `THREE.Object3d`.
59
59
  */
60
60
  constructor(id, object3d, schemeTile, builder, config) {
61
- // cacheLifeTime = CACHE_POLICIES.INFINITE because the cache is handled by the builder
62
- config.cacheLifeTime = CACHE_POLICIES.INFINITE;
63
- config.source = false;
64
- super(id, object3d, config);
61
+ const {
62
+ sseSubdivisionThreshold = 1.0,
63
+ minSubdivisionLevel,
64
+ maxSubdivisionLevel,
65
+ maxDeltaElevationLevel,
66
+ tileMatrixSets,
67
+ diffuse,
68
+ showOutline = false,
69
+ segments,
70
+ disableSkirt = false,
71
+ materialOptions,
72
+ ...configGeometryLayer
73
+ } = config;
74
+ super(id, object3d, {
75
+ ...configGeometryLayer,
76
+ // cacheLifeTime = CACHE_POLICIES.INFINITE because the cache is handled by the builder
77
+ cacheLifeTime: CACHE_POLICIES.INFINITE,
78
+ source: false
79
+ });
80
+
81
+ /**
82
+ * @type {boolean}
83
+ * @readonly
84
+ */
65
85
  this.isTiledGeometryLayer = true;
86
+ this.protocol = 'tile';
87
+
66
88
  // TODO : this should be add in a preprocess method specific to GeoidLayer.
67
89
  this.object3d.geoidHeight = 0;
68
- this.protocol = 'tile';
90
+
91
+ /**
92
+ * @type {boolean}
93
+ */
94
+ this.disableSkirt = disableSkirt;
69
95
  this._hideSkirt = !!config.hideSkirt;
70
- this.sseSubdivisionThreshold = this.sseSubdivisionThreshold || 1.0;
96
+
97
+ /**
98
+ * @type {number}
99
+ */
100
+ this.sseSubdivisionThreshold = sseSubdivisionThreshold;
101
+
102
+ /**
103
+ * @type {number}
104
+ */
105
+ this.minSubdivisionLevel = minSubdivisionLevel;
106
+
107
+ /**
108
+ * @type {number}
109
+ */
110
+ this.maxSubdivisionLevel = maxSubdivisionLevel;
111
+
112
+ /**
113
+ * @type {number}
114
+ * @deprecated
115
+ */
116
+ this.maxDeltaElevationLevel = maxDeltaElevationLevel;
117
+ this.segments = segments;
71
118
  this.schemeTile = schemeTile;
72
119
  this.builder = builder;
73
120
  this.info = new InfoTiledGeometryLayer(this);
@@ -77,9 +124,19 @@ class TiledGeometryLayer extends GeometryLayer {
77
124
  if (!this.builder) {
78
125
  throw new Error(`Cannot init tiled layer without builder for layer ${this.id}`);
79
126
  }
80
- if (config.maxDeltaElevationLevel) {
81
- console.warn('Config using maxDeltaElevationLevel is deprecated. The parameter maxDeltaElevationLevel is not longer used');
82
- }
127
+ this.maxScreenSizeNode = this.sseSubdivisionThreshold * (this.sizeDiagonalTexture * 2);
128
+ this.tileMatrixSets = tileMatrixSets;
129
+ this.materialOptions = materialOptions;
130
+
131
+ /*
132
+ * @type {boolean}
133
+ */
134
+ this.showOutline = showOutline;
135
+
136
+ /**
137
+ * @type {THREE.Vector3 | undefined}
138
+ */
139
+ this.diffuse = diffuse;
83
140
  this.level0Nodes = [];
84
141
  const promises = [];
85
142
  for (const root of this.schemeTile) {
@@ -90,7 +147,6 @@ class TiledGeometryLayer extends GeometryLayer {
90
147
  this.object3d.add(...level0s);
91
148
  this.object3d.updateMatrixWorld();
92
149
  }));
93
- this.maxScreenSizeNode = this.sseSubdivisionThreshold * (this.sizeDiagonalTexture * 2);
94
150
  }
95
151
  get hideSkirt() {
96
152
  return this._hideSkirt;
@@ -102,7 +102,11 @@ export default {
102
102
  res = resolve;
103
103
  rej = reject;
104
104
  });
105
- textureLoader.load(url, res, () => {}, rej);
105
+ textureLoader.load(url, res, () => {}, event => {
106
+ const error = new Error(`Failed to load texture from URL: \`${url}\``);
107
+ error.originalEvent = event;
108
+ rej(error);
109
+ });
106
110
  return promise;
107
111
  },
108
112
  /**
@@ -1,12 +1,11 @@
1
1
  import * as THREE from 'three';
2
2
  import * as CRS from "../Core/Geographic/Crs.js";
3
- import TileGeometry from "../Core/TileGeometry.js";
4
- import BuilderEllipsoidTile from "../Core/Prefab/Globe/BuilderEllipsoidTile.js";
3
+ import { TileGeometry } from "../Core/TileGeometry.js";
4
+ import { GlobeTileBuilder } from "../Core/Prefab/Globe/GlobeTileBuilder.js";
5
5
  import Coordinates from "../Core/Geographic/Coordinates.js";
6
6
 
7
7
  // get oriented bounding box of tile
8
- const builder = new BuilderEllipsoidTile({
9
- crs: 'EPSG:4978',
8
+ const builder = new GlobeTileBuilder({
10
9
  uvCount: 1
11
10
  });
12
11
  const size = new THREE.Vector3();
@@ -114,18 +113,17 @@ class OBB extends THREE.Object3D {
114
113
  let maxHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extent.max || 0;
115
114
  if (extent.crs == 'EPSG:4326') {
116
115
  const {
117
- sharableExtent,
116
+ shareableExtent,
118
117
  quaternion,
119
118
  position
120
- } = builder.computeSharableExtent(extent);
119
+ } = builder.computeShareableExtent(extent);
121
120
  // Compute the minimum count of segment to build tile
122
- const segments = Math.max(Math.floor(sharableExtent.planarDimensions(dimension).x / 90 + 1), 2);
123
- const geometry = new TileGeometry({
124
- extent: sharableExtent,
121
+ const segments = Math.max(Math.floor(shareableExtent.planarDimensions(dimension).x / 90 + 1), 2);
122
+ const geometry = new TileGeometry(builder, {
123
+ extent: shareableExtent,
125
124
  level: 0,
126
125
  segments,
127
- disableSkirt: true,
128
- builder
126
+ disableSkirt: true
129
127
  });
130
128
  obb.box3D.copy(geometry.boundingBox);
131
129
  obb.natBox.copy(geometry.boundingBox);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.44.3-next.22",
3
+ "version": "2.44.3-next.24",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",
@@ -1,110 +0,0 @@
1
- import * as THREE from 'three';
2
- import Coordinates from "../../Geographic/Coordinates.js";
3
- import Extent from "../../Geographic/Extent.js";
4
- const PI_OV_FOUR = Math.PI / 4;
5
- const INV_TWO_PI = 1.0 / (Math.PI * 2);
6
- const axisZ = new THREE.Vector3(0, 0, 1);
7
- const axisY = new THREE.Vector3(0, 1, 0);
8
- const quatToAlignLongitude = new THREE.Quaternion();
9
- const quatToAlignLatitude = new THREE.Quaternion();
10
- const quatNormalToZ = new THREE.Quaternion();
11
- function WGS84ToOneSubY(latitude) {
12
- return 1.0 - (0.5 - Math.log(Math.tan(PI_OV_FOUR + THREE.MathUtils.degToRad(latitude) * 0.5)) * INV_TWO_PI);
13
- }
14
- class BuilderEllipsoidTile {
15
- constructor() {
16
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17
- this.tmp = {
18
- coords: [new Coordinates('EPSG:4326', 0, 0), new Coordinates('EPSG:4326', 0, 0)],
19
- position: new THREE.Vector3(),
20
- dimension: new THREE.Vector2()
21
- };
22
- this.crs = options.crs;
23
- // Order crs projection on tiles
24
- this.uvCount = options.uvCount;
25
- this.computeUvs = [
26
- // Normalized coordinates (from degree) on the entire tile
27
- // EPSG:4326
28
- () => {},
29
- // Float row coordinate from Pseudo mercator coordinates
30
- // EPSG:3857
31
- params => {
32
- const t = WGS84ToOneSubY(params.projected.latitude) * params.nbRow;
33
- return (!isFinite(t) ? 0 : t) - params.deltaUV1;
34
- }];
35
- }
36
- // prepare params
37
- // init projected object -> params.projected
38
- prepare(params) {
39
- params.nbRow = 2 ** (params.level + 1.0);
40
- let st1 = WGS84ToOneSubY(params.extent.south);
41
- if (!isFinite(st1)) {
42
- st1 = 0;
43
- }
44
- const sizeTexture = 1.0 / params.nbRow;
45
- const start = st1 % sizeTexture;
46
- params.deltaUV1 = (st1 - start) * params.nbRow;
47
-
48
- // transformation to align tile's normal to z axis
49
- params.quatNormalToZ = quatNormalToZ.setFromAxisAngle(axisY, -(Math.PI * 0.5 - THREE.MathUtils.degToRad(params.extent.center().latitude)));
50
-
51
- // let's avoid building too much temp objects
52
- params.projected = {
53
- longitude: 0,
54
- latitude: 0
55
- };
56
- params.extent.planarDimensions(this.tmp.dimension);
57
- }
58
-
59
- // get center tile in cartesian 3D
60
- center(extent) {
61
- return extent.center(this.tmp.coords[0]).as(this.crs, this.tmp.coords[1]).toVector3();
62
- }
63
-
64
- // get position 3D cartesian
65
- vertexPosition(params) {
66
- this.tmp.coords[0].setFromValues(params.projected.longitude, params.projected.latitude);
67
- this.tmp.coords[0].as(this.crs, this.tmp.coords[1]).toVector3(this.tmp.position);
68
- return this.tmp.position;
69
- }
70
-
71
- // get normal for last vertex
72
- vertexNormal() {
73
- return this.tmp.coords[1].geodesicNormal;
74
- }
75
-
76
- // coord u tile to projected
77
- uProjecte(u, params) {
78
- params.projected.longitude = params.extent.west + u * this.tmp.dimension.x;
79
- }
80
-
81
- // coord v tile to projected
82
- vProjecte(v, params) {
83
- params.projected.latitude = params.extent.south + v * this.tmp.dimension.y;
84
- }
85
- computeSharableExtent(extent) {
86
- // Compute sharable extent to pool the geometries
87
- // the geometry in common extent is identical to the existing input
88
- // with a transformation (translation, rotation)
89
-
90
- // TODO: It should be possible to use equatorial plan symetrie,
91
- // but we should be reverse UV on tile
92
- // Common geometry is looking for only on longitude
93
- const sizeLongitude = Math.abs(extent.west - extent.east) / 2;
94
- const sharableExtent = new Extent(extent.crs, -sizeLongitude, sizeLongitude, extent.south, extent.north);
95
-
96
- // compute rotation to transform tile to position it on ellipsoid
97
- // this transformation take into account the transformation of the parents
98
- const rotLon = THREE.MathUtils.degToRad(extent.west - sharableExtent.west);
99
- const rotLat = THREE.MathUtils.degToRad(90 - extent.center(this.tmp.coords[0]).latitude);
100
- quatToAlignLongitude.setFromAxisAngle(axisZ, rotLon);
101
- quatToAlignLatitude.setFromAxisAngle(axisY, rotLat);
102
- quatToAlignLongitude.multiply(quatToAlignLatitude);
103
- return {
104
- sharableExtent,
105
- quaternion: quatToAlignLongitude.clone(),
106
- position: this.center(extent)
107
- };
108
- }
109
- }
110
- export default BuilderEllipsoidTile;