itowns 2.44.3-next.3 → 2.44.3-next.31

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 (95) hide show
  1. package/CODING.md +1 -1
  2. package/CONTRIBUTORS.md +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.LICENSE.txt +0 -2
  7. package/dist/itowns.js.map +1 -1
  8. package/dist/itowns_widgets.js +1 -1
  9. package/dist/itowns_widgets.js.map +1 -1
  10. package/examples/3dtiles_loader.html +109 -45
  11. package/examples/config.json +3 -10
  12. package/examples/entwine_3d_loader.html +3 -1
  13. package/examples/entwine_simple_loader.html +1 -1
  14. package/examples/images/itowns_logo.svg +123 -0
  15. package/examples/js/plugins/COGParser.js +1 -1
  16. package/examples/jsm/OGC3DTilesHelper.js +1 -1
  17. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  18. package/examples/source_file_geojson_3d.html +0 -1
  19. package/examples/source_file_kml_raster_usgs.html +0 -1
  20. package/examples/source_stream_wfs_raster.html +0 -7
  21. package/examples/vector_tile_mapbox_raster.html +91 -0
  22. package/lib/Controls/GlobeControls.js +45 -28
  23. package/lib/Controls/StateControl.js +5 -2
  24. package/lib/Converter/Feature2Mesh.js +10 -4
  25. package/lib/Converter/Feature2Texture.js +6 -1
  26. package/lib/Converter/convertToTile.js +3 -8
  27. package/lib/Converter/textureConverter.js +3 -4
  28. package/lib/Core/Deprecated/Undeprecator.js +0 -1
  29. package/lib/Core/Feature.js +1 -2
  30. package/lib/Core/Geographic/Coordinates.js +143 -132
  31. package/lib/Core/Geographic/Crs.js +140 -145
  32. package/lib/Core/Geographic/Extent.js +72 -267
  33. package/lib/Core/Geographic/GeoidGrid.js +1 -1
  34. package/lib/Core/Math/Ellipsoid.js +62 -21
  35. package/lib/Core/Prefab/Globe/Atmosphere.js +4 -8
  36. package/lib/Core/Prefab/Globe/GlobeLayer.js +22 -15
  37. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +111 -0
  38. package/lib/Core/Prefab/GlobeView.js +2 -7
  39. package/lib/Core/Prefab/Planar/PlanarLayer.js +17 -11
  40. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +43 -43
  41. package/lib/Core/Prefab/TileBuilder.js +27 -32
  42. package/lib/Core/Prefab/computeBufferTileGeometry.js +189 -130
  43. package/lib/Core/Style.js +60 -42
  44. package/lib/Core/Tile/Tile.js +219 -0
  45. package/lib/Core/Tile/TileGrid.js +43 -0
  46. package/lib/Core/TileGeometry.js +112 -28
  47. package/lib/Core/TileMesh.js +3 -3
  48. package/lib/Core/View.js +15 -8
  49. package/lib/Layer/C3DTilesLayer.js +20 -16
  50. package/lib/Layer/ColorLayer.js +35 -9
  51. package/lib/Layer/CopcLayer.js +5 -0
  52. package/lib/Layer/ElevationLayer.js +39 -7
  53. package/lib/Layer/EntwinePointTileLayer.js +12 -5
  54. package/lib/Layer/FeatureGeometryLayer.js +20 -6
  55. package/lib/Layer/GeometryLayer.js +42 -11
  56. package/lib/Layer/LabelLayer.js +45 -27
  57. package/lib/Layer/Layer.js +83 -57
  58. package/lib/Layer/OGC3DTilesLayer.js +81 -30
  59. package/lib/Layer/OrientedImageLayer.js +11 -5
  60. package/lib/Layer/PointCloudLayer.js +74 -30
  61. package/lib/Layer/Potree2Layer.js +7 -2
  62. package/lib/Layer/PotreeLayer.js +8 -3
  63. package/lib/Layer/RasterLayer.js +12 -2
  64. package/lib/Layer/TiledGeometryLayer.js +69 -13
  65. package/lib/Main.js +2 -2
  66. package/lib/Parser/GeoJsonParser.js +1 -1
  67. package/lib/Parser/VectorTileParser.js +42 -29
  68. package/lib/Parser/XbilParser.js +14 -2
  69. package/lib/Provider/Fetcher.js +5 -1
  70. package/lib/Provider/URLBuilder.js +22 -11
  71. package/lib/Renderer/Camera.js +1 -1
  72. package/lib/Renderer/Label2DRenderer.js +9 -7
  73. package/lib/Renderer/OBB.js +11 -13
  74. package/lib/Renderer/PointsMaterial.js +1 -1
  75. package/lib/Renderer/RasterTile.js +1 -2
  76. package/lib/Renderer/SphereHelper.js +0 -6
  77. package/lib/Source/CopcSource.js +13 -2
  78. package/lib/Source/EntwinePointTileSource.js +14 -4
  79. package/lib/Source/FileSource.js +1 -4
  80. package/lib/Source/Source.js +1 -4
  81. package/lib/Source/TMSSource.js +10 -9
  82. package/lib/Source/VectorTilesSource.js +32 -22
  83. package/lib/Source/WFSSource.js +15 -10
  84. package/lib/Source/WMSSource.js +56 -18
  85. package/lib/Source/WMTSSource.js +13 -7
  86. package/lib/Utils/CameraUtils.js +1 -1
  87. package/lib/Utils/gui/C3DTilesStyle.js +2 -3
  88. package/lib/Utils/placeObjectOnGround.js +0 -1
  89. package/package.json +13 -6
  90. package/examples/3dtiles_25d.html +0 -120
  91. package/examples/3dtiles_basic.html +0 -94
  92. package/examples/3dtiles_batch_table.html +0 -86
  93. package/examples/3dtiles_ion.html +0 -126
  94. package/examples/3dtiles_pointcloud.html +0 -95
  95. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
@@ -149,7 +149,7 @@ let previous;
149
149
  * @param {object} [options] An object with one or more configuration properties. Any property of GlobeControls
150
150
  * can be passed in this object.
151
151
  * @property {number} zoomFactor The factor the scale is multiplied by when dollying (zooming) in or
152
- * divided by when dollying out. Default is 2.
152
+ * divided by when dollying out. Default is 1.1.
153
153
  * @property {number} rotateSpeed Speed camera rotation in orbit and panoramic mode. Default is 0.25.
154
154
  * @property {number} minDistance Minimum distance between ground and camera in meters (Perspective Camera only).
155
155
  * Default is 250.
@@ -199,7 +199,7 @@ class GlobeControls extends THREE.EventDispatcher {
199
199
  console.warn('Controls zoomSpeed parameter is deprecated. Use zoomFactor instead.');
200
200
  options.zoomFactor = options.zoomFactor || options.zoomSpeed;
201
201
  }
202
- this.zoomFactor = options.zoomFactor || 1.25;
202
+ this.zoomFactor = options.zoomFactor || 1.1;
203
203
 
204
204
  // Limits to how far you can dolly in and out ( PerspectiveCamera only )
205
205
  this.minDistance = options.minDistance || 250;
@@ -293,10 +293,10 @@ class GlobeControls extends THREE.EventDispatcher {
293
293
  this.lookAtCoordinate(placement, false);
294
294
  coordCameraTarget.crs = this.view.referenceCrs;
295
295
  }
296
- get dollyInScale() {
296
+ get zoomInScale() {
297
297
  return this.zoomFactor;
298
298
  }
299
- get dollyOutScale() {
299
+ get zoomOutScale() {
300
300
  return 1 / this.zoomFactor;
301
301
  }
302
302
  get isPaused() {
@@ -355,11 +355,13 @@ class GlobeControls extends THREE.EventDispatcher {
355
355
  this.panUp(deltaY * (this.camera.top - this.camera.bottom) / gfx.height);
356
356
  }
357
357
  }
358
+
359
+ // For Mobile
358
360
  dolly(delta) {
359
361
  if (delta === 0) {
360
362
  return;
361
363
  }
362
- dollyScale = delta > 0 ? this.dollyInScale : this.dollyOutScale;
364
+ dollyScale = delta > 0 ? this.zoomInScale : this.zoomOutScale;
363
365
  if (this.camera.isPerspectiveCamera) {
364
366
  orbitScale /= dollyScale;
365
367
  } else if (this.camera.isOrthographicCamera) {
@@ -556,6 +558,7 @@ class GlobeControls extends THREE.EventDispatcher {
556
558
 
557
559
  // Initialize dolly movement.
558
560
  dollyStart.copy(event.viewCoords);
561
+ this.view.getPickingPositionFromDepth(event.viewCoords, pickedPosition); // mouse position
559
562
 
560
563
  // Initialize pan movement.
561
564
  panStart.copy(event.viewCoords);
@@ -587,9 +590,11 @@ class GlobeControls extends THREE.EventDispatcher {
587
590
  handleDolly(event) {
588
591
  dollyEnd.copy(event.viewCoords);
589
592
  dollyDelta.subVectors(dollyEnd, dollyStart);
590
- this.dolly(-dollyDelta.y);
591
593
  dollyStart.copy(dollyEnd);
592
- this.update();
594
+ event.delta = dollyDelta.y;
595
+ if (event.delta != 0) {
596
+ this.handleZoom(event);
597
+ }
593
598
  }
594
599
  handlePan(event) {
595
600
  if (event.viewCoords) {
@@ -705,7 +710,7 @@ class GlobeControls extends THREE.EventDispatcher {
705
710
  const range = this.getRange(point);
706
711
  if (point && range > this.minDistance) {
707
712
  return this.lookAtCoordinate({
708
- coord: new Coordinates('EPSG:4978', point),
713
+ coord: new Coordinates('EPSG:4978').setFromVector3(point),
709
714
  range: range * (event.direction === 'out' ? 1 / 0.6 : 0.6),
710
715
  time: 1500
711
716
  });
@@ -714,21 +719,33 @@ class GlobeControls extends THREE.EventDispatcher {
714
719
  handleZoom(event) {
715
720
  this.player.stop();
716
721
  CameraUtils.stop(this.view, this.camera);
717
- this.updateTarget();
718
- const delta = -event.delta;
719
- this.dolly(delta);
720
- const previousRange = this.getRange(pickedPosition);
721
- this.update();
722
- const newRange = this.getRange(pickedPosition);
723
- if (Math.abs(newRange - previousRange) / previousRange > 0.001) {
724
- this.dispatchEvent({
725
- type: CONTROL_EVENTS.RANGE_CHANGED,
726
- previous: previousRange,
727
- new: newRange
728
- });
722
+ const zoomScale = event.delta > 0 ? this.zoomInScale : this.zoomOutScale;
723
+ let point = event.type === 'dolly' ? pickedPosition : this.view.getPickingPositionFromDepth(event.viewCoords); // get cursor position
724
+ let range = this.getRange();
725
+ range *= zoomScale;
726
+ if (point && range > this.minDistance && range < this.maxDistance) {
727
+ // check if the zoom is in the allowed interval
728
+ const camPos = xyz.setFromVector3(cameraTarget.position).as('EPSG:4326', c).toVector3();
729
+ point = xyz.setFromVector3(point).as('EPSG:4326', c).toVector3();
730
+ if (camPos.x * point.x < 0) {
731
+ // Correct rotation at 180th meridian by using 0 <= longitude <=360 for interpolation purpose
732
+ if (camPos.x - point.x > 180) {
733
+ point.x += 360;
734
+ } else if (point.x - camPos.x > 180) {
735
+ camPos.x += 360;
736
+ }
737
+ }
738
+ point.lerp(
739
+ // point interpol between mouse cursor and cam pos
740
+ camPos, zoomScale // interpol factor
741
+ );
742
+ point = c.setFromVector3(point).as('EPSG:4978', xyz);
743
+ return this.lookAtCoordinate({
744
+ // update view to the interpolate point
745
+ coord: point,
746
+ range
747
+ }, false);
729
748
  }
730
- this.dispatchEvent(this.startEvent);
731
- this.dispatchEvent(this.endEvent);
732
749
  }
733
750
  onTouchStart(event) {
734
751
  // CameraUtils.stop(view);
@@ -961,7 +978,7 @@ class GlobeControls extends THREE.EventDispatcher {
961
978
  */
962
979
 
963
980
  getCameraCoordinate() {
964
- return new Coordinates('EPSG:4978', this.camera.position).as('EPSG:4326');
981
+ return new Coordinates('EPSG:4978').setFromVector3(this.camera.position).as('EPSG:4326');
965
982
  }
966
983
 
967
984
  /**
@@ -1018,7 +1035,7 @@ class GlobeControls extends THREE.EventDispatcher {
1018
1035
  *
1019
1036
  * @deprecated Use View#getScale instead.
1020
1037
  */
1021
- getScale(pitch) /* istanbul ignore next */{
1038
+ getScale(pitch) {
1022
1039
  console.warn('Deprecated, use View#getScale instead.');
1023
1040
  return this.view.getScale(pitch);
1024
1041
  }
@@ -1031,7 +1048,7 @@ class GlobeControls extends THREE.EventDispatcher {
1031
1048
  *
1032
1049
  * @deprecated Use `View#getPixelsToMeters` instead.
1033
1050
  */
1034
- pixelsToMeters(pixels) /* istanbul ignore next */{
1051
+ pixelsToMeters(pixels) {
1035
1052
  let pixelPitch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.28;
1036
1053
  console.warn('Deprecated use View#getPixelsToMeters instead.');
1037
1054
  const scaled = this.getScale(pixelPitch);
@@ -1047,7 +1064,7 @@ class GlobeControls extends THREE.EventDispatcher {
1047
1064
  * @deprecated Use `View#getPixelsToMeters` and `GlobeControls#metersToDegrees`
1048
1065
  * instead.
1049
1066
  */
1050
- pixelsToDegrees(pixels) /* istanbul ignore next */{
1067
+ pixelsToDegrees(pixels) {
1051
1068
  let pixelPitch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.28;
1052
1069
  console.warn('Deprecated, use View#getPixelsToMeters and GlobeControls#getMetersToDegrees instead.');
1053
1070
  const chord = this.pixelsToMeters(pixels, pixelPitch);
@@ -1062,7 +1079,7 @@ class GlobeControls extends THREE.EventDispatcher {
1062
1079
  *
1063
1080
  * @deprecated Use `View#getMetersToPixels` instead.
1064
1081
  */
1065
- metersToPixels(value) /* istanbul ignore next */{
1082
+ metersToPixels(value) {
1066
1083
  let pixelPitch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.28;
1067
1084
  console.warn('Deprecated, use View#getMetersToPixels instead.');
1068
1085
  const scaled = this.getScale(pixelPitch);
@@ -1156,7 +1173,7 @@ class GlobeControls extends THREE.EventDispatcher {
1156
1173
  if (!pickedPosition) {
1157
1174
  return;
1158
1175
  }
1159
- return new Coordinates('EPSG:4978', pickedPosition).as('EPSG:4326');
1176
+ return new Coordinates('EPSG:4978').setFromVector3(pickedPosition).as('EPSG:4326');
1160
1177
  }
1161
1178
  }
1162
1179
  export default GlobeControls;
@@ -257,7 +257,7 @@ class StateControl extends THREE.EventDispatcher {
257
257
  touchToState(finger) {
258
258
  for (const key of Object.keys(DEFAULT_STATES)) {
259
259
  const state = this[key];
260
- if (state.enable && finger == state.finger) {
260
+ if (state.enable && finger === state.finger) {
261
261
  return state;
262
262
  }
263
263
  }
@@ -376,9 +376,12 @@ class StateControl extends THREE.EventDispatcher {
376
376
  onMouseWheel(event) {
377
377
  event.preventDefault();
378
378
  if (this.enabled && this.ZOOM.enable) {
379
+ viewCoords.copy(this._view.eventToViewCoords(event));
380
+ this.currentState = this.ZOOM;
379
381
  this.dispatchEvent({
380
382
  type: this.ZOOM._event,
381
- delta: event.deltaY
383
+ delta: event.deltaY,
384
+ viewCoords
382
385
  });
383
386
  }
384
387
  }
@@ -4,7 +4,6 @@ import { FEATURE_TYPES } from "../Core/Feature.js";
4
4
  import ReferLayerProperties from "../Layer/ReferencingLayerProperties.js";
5
5
  import { deprecatedFeature2MeshOptions } from "../Core/Deprecated/Undeprecator.js";
6
6
  import Extent from "../Core/Geographic/Extent.js";
7
- import Crs from "../Core/Geographic/Crs.js";
8
7
  import OrientationUtils from "../Utils/OrientationUtils.js";
9
8
  import Coordinates from "../Core/Geographic/Coordinates.js";
10
9
  import Style, { StyleContext } from "../Core/Style.js";
@@ -54,9 +53,16 @@ class FeatureMesh extends THREE.Group {
54
53
  } else {
55
54
  // calculate the scale transformation to transform the feature.extent
56
55
  // to feature.extent.as(crs)
57
- coord.crs = Crs.formatToEPSG(this.#originalCrs);
58
- extent.copy(this.extent).applyMatrix4(this.#collection.matrix);
59
- extent.as(coord.crs, extent);
56
+ coord.crs = this.#originalCrs;
57
+ // TODO: An extent here could be either a geographic extent (for
58
+ // features from WFS) or a tiled extent (for features from MVT).
59
+ // Unify both behavior.
60
+ if (this.extent.isExtent) {
61
+ extent.copy(this.extent).applyMatrix4(this.#collection.matrix);
62
+ extent.as(coord.crs, extent);
63
+ } else {
64
+ this.extent.toExtent(coord.crs, extent);
65
+ }
60
66
  extent.spatialEuclideanDimensions(dim_ref);
61
67
  extent.planarDimensions(dim);
62
68
  if (dim.x && dim.y) {
@@ -71,6 +71,9 @@ function drawFeature(ctx, feature, extent, invCtxScale) {
71
71
  for (const geometry of feature.geometries) {
72
72
  if (Extent.intersectsExtent(geometry.extent, extent)) {
73
73
  context.setGeometry(geometry);
74
+ if (style.zoom.min > style.context.zoom || style.zoom.max <= style.context.zoom) {
75
+ return;
76
+ }
74
77
  if (feature.type === FEATURE_TYPES.POINT && style.point) {
75
78
  // cross multiplication to know in the extent system the real size of
76
79
  // the point
@@ -114,7 +117,9 @@ export default {
114
117
  coord.crs = extent.crs;
115
118
  c.width = sizeTexture;
116
119
  c.height = sizeTexture;
117
- const ctx = c.getContext('2d');
120
+ const ctx = c.getContext('2d', {
121
+ willReadFrequently: true
122
+ });
118
123
  if (backgroundColor) {
119
124
  ctx.fillStyle = backgroundColor.getStyle();
120
125
  ctx.fillRect(0, 0, sizeTexture, sizeTexture);
@@ -1,12 +1,7 @@
1
- /*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
1
  import * as THREE from 'three';
7
2
  import TileMesh from "../Core/TileMesh.js";
8
3
  import LayeredMaterial from "../Renderer/LayeredMaterial.js";
9
- import newTileGeometry from "../Core/Prefab/TileBuilder.js";
4
+ import { newTileGeometry } from "../Core/Prefab/TileBuilder.js";
10
5
  import ReferLayerProperties from "../Layer/ReferencingLayerProperties.js";
11
6
  import { geoidLayerIsVisible } from "../Layer/GeoidLayer.js";
12
7
  const dimensions = new THREE.Vector2();
@@ -42,14 +37,14 @@ export default {
42
37
  };
43
38
  return newTileGeometry(builder, paramsGeometry).then(result => {
44
39
  // build tile mesh
45
- result.geometry._count++;
40
+ result.geometry.increaseRefCount();
46
41
  const crsCount = layer.tileMatrixSets.length;
47
42
  const material = new LayeredMaterial(layer.materialOptions, crsCount);
48
43
  ReferLayerProperties(material, layer);
49
44
  const tile = new TileMesh(result.geometry, material, layer, extent, level);
50
45
  if (parent && parent.isTileMesh) {
51
46
  // get parent extent transformation
52
- const pTrans = builder.computeSharableExtent(parent.extent);
47
+ const pTrans = builder.computeShareableExtent(parent.extent);
53
48
  // place relative to his parent
54
49
  result.position.sub(pTrans.position).applyQuaternion(pTrans.quaternion.invert());
55
50
  result.quaternion.premultiply(pTrans.quaternion);
@@ -1,7 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import Feature2Texture from "./Feature2Texture.js";
3
3
  import Extent from "../Core/Geographic/Extent.js";
4
- import CRS from "../Core/Geographic/Crs.js";
5
4
  const extentTexture = new Extent('EPSG:4326', [0, 0, 0, 0]);
6
5
  const textureLayer = (texture, layer) => {
7
6
  texture.generateMipmaps = false;
@@ -15,15 +14,15 @@ function textureColorLayer(texture, layer) {
15
14
  return textureLayer(texture, layer);
16
15
  }
17
16
  export default {
18
- convert(data, extentDestination, layer) {
17
+ convert(data, destinationTile, layer) {
19
18
  let texture;
20
19
  if (data.isFeatureCollection) {
21
20
  const backgroundLayer = layer.source.backgroundLayer;
22
21
  const backgroundColor = backgroundLayer && backgroundLayer.paint ? new THREE.Color(backgroundLayer.paint['background-color']) : undefined;
23
- extentDestination.as(CRS.formatToEPSG(layer.crs), extentTexture);
22
+ destinationTile.toExtent(layer.crs, extentTexture);
24
23
  texture = Feature2Texture.createTextureFromFeature(data, extentTexture, layer.subdivisionThreshold, layer.style, backgroundColor);
25
24
  texture.features = data;
26
- texture.extent = extentDestination;
25
+ texture.extent = destinationTile;
27
26
  } else if (data.isTexture) {
28
27
  texture = data;
29
28
  } else {
@@ -13,7 +13,6 @@ export const deprecatedColorLayerOptions = options => {
13
13
  return options;
14
14
  };
15
15
  export const deprecatedParsingOptionsToNewOne = options => {
16
- /* istanbul ignore next */
17
16
  if (options.crsOut || options.crsIn) {
18
17
  console.warn('Parsing options with crsIn and crsOut are deprecated, use { in, out } structure.');
19
18
  const newOptions = {
@@ -1,7 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import Extent from "./Geographic/Extent.js";
3
3
  import Coordinates from "./Geographic/Coordinates.js";
4
- import CRS from "./Geographic/Crs.js";
5
4
  import Style from "./Style.js";
6
5
  function defaultExtent(crs) {
7
6
  return new Extent(crs, Infinity, -Infinity, Infinity, -Infinity);
@@ -340,7 +339,7 @@ export class FeatureCollection extends THREE.Object3D {
340
339
  constructor(options) {
341
340
  super();
342
341
  this.isFeatureCollection = true;
343
- this.crs = CRS.formatToEPSG(options.accurate || !options.source?.crs ? options.crs : options.source.crs);
342
+ this.crs = options.accurate || !options.source?.crs ? options.crs : options.source.crs;
344
343
  this.features = [];
345
344
  this.mergeFeatures = options.mergeFeatures === undefined ? true : options.mergeFeatures;
346
345
  this.size = options.structure == '3d' ? 3 : 2;