itowns 2.44.3-next.2 → 2.44.3-next.21

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 (44) 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.map +1 -1
  7. package/dist/itowns_widgets.js +1 -1
  8. package/dist/itowns_widgets.js.map +1 -1
  9. package/examples/3dtiles_loader.html +105 -44
  10. package/examples/config.json +2 -10
  11. package/examples/images/itowns_logo.svg +123 -0
  12. package/examples/js/plugins/COGParser.js +1 -1
  13. package/lib/Controls/GlobeControls.js +38 -21
  14. package/lib/Controls/StateControl.js +5 -2
  15. package/lib/Converter/Feature2Mesh.js +9 -2
  16. package/lib/Converter/textureConverter.js +3 -3
  17. package/lib/Core/Geographic/Extent.js +74 -266
  18. package/lib/Core/Prefab/Globe/GlobeLayer.js +1 -1
  19. package/lib/Core/Prefab/GlobeView.js +0 -4
  20. package/lib/Core/Prefab/Planar/PlanarLayer.js +1 -1
  21. package/lib/Core/Tile/Tile.js +219 -0
  22. package/lib/Core/Tile/TileGrid.js +46 -0
  23. package/lib/Core/TileMesh.js +2 -1
  24. package/lib/Core/View.js +13 -6
  25. package/lib/Layer/C3DTilesLayer.js +15 -14
  26. package/lib/Layer/LabelLayer.js +8 -4
  27. package/lib/Layer/OGC3DTilesLayer.js +62 -31
  28. package/lib/Parser/GeoJsonParser.js +1 -1
  29. package/lib/Parser/VectorTileParser.js +1 -1
  30. package/lib/Parser/XbilParser.js +14 -2
  31. package/lib/Provider/URLBuilder.js +22 -11
  32. package/lib/Renderer/PointsMaterial.js +1 -1
  33. package/lib/Source/TMSSource.js +9 -7
  34. package/lib/Source/VectorTilesSource.js +2 -2
  35. package/lib/Source/WFSSource.js +14 -8
  36. package/lib/Source/WMSSource.js +20 -10
  37. package/lib/Source/WMTSSource.js +13 -7
  38. package/lib/Utils/gui/C3DTilesStyle.js +2 -3
  39. package/package.json +9 -3
  40. package/examples/3dtiles_25d.html +0 -120
  41. package/examples/3dtiles_basic.html +0 -94
  42. package/examples/3dtiles_batch_table.html +0 -86
  43. package/examples/3dtiles_ion.html +0 -126
  44. package/examples/3dtiles_pointcloud.html +0 -95
@@ -11,7 +11,15 @@
11
11
  <style type="text/css">
12
12
  #description {
13
13
  z-index: 2;
14
- right: 10px;
14
+ left: 10px;
15
+ }
16
+
17
+ #featureInfoText {
18
+ font-size: small;
19
+ }
20
+
21
+ #description .marg {
22
+ margin: 10px;
15
23
  }
16
24
  </style>
17
25
 
@@ -21,12 +29,17 @@
21
29
  <div id="viewerDiv"></div>
22
30
  <div id="description">Specify the URL of a tileset to load:
23
31
  <input type="text" id="url" />
24
- <button onclick="setURL(document.getElementById('url').value)">
25
- Load
26
- </button>
32
+ <button onclick="readURL()">Load</button>
33
+ <div class="marg">
34
+ <button onClick="loadLyon()">Load Lyon 1 (Mesh)</button>
35
+ <button onClick="loadSete()">Load Sete (Point Cloud)</button>
36
+ <button onClick="loadLille()">Load Lille (Mesh)</button>
37
+ <div id="share"></div>
38
+ </div>
27
39
  <hr />
40
+ <p id="featureInfoText" class="marg"><em>Display feature information by clicking on it</em></p>
28
41
  <p><b>Feature Information:</b></p>
29
- <div id="featureInfo"></div>
42
+ <div id="featureInfo" class="marg"></div>
30
43
  </div>
31
44
 
32
45
  <script src="js/GUI/GuiTools.js"></script>
@@ -52,28 +65,17 @@
52
65
 
53
66
  const {
54
67
  TMSSource, WMTSSource, OGC3DTilesSource,
55
- ColorLayer, ElevationLayer, OGC3DTilesLayer,
68
+ ColorLayer, ElevationLayer, OGC3DTilesLayer, PNTS_SIZE_MODE,
56
69
  GlobeView, Coordinates, Fetcher,
57
70
  } = itowns;
58
71
 
59
- const uri = new URL(location);
60
- const state = {
61
- // URL to tileset JSON
62
- tileset: uri.searchParams.get('tileset'),
63
- // Cesium ION /
64
- assetId: uri.searchParams.get('assetId'),
65
- };
66
-
67
- function setURL(url) {
68
- if (!url) return;
72
+ window.layer = null; // 3D Tiles layer
69
73
 
70
- uri.searchParams.set('tileset', url);
71
- history.pushState(null, '', `?${uri.searchParams.toString()}`);
74
+ const uri = new URL(location);
72
75
 
73
- location.reload();
74
- }
76
+ window.gui = new dat.GUI();
75
77
 
76
- // ---- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION ----
78
+ // ---- Create a GlobeView ----
77
79
 
78
80
  // Define camera initial position
79
81
  const placement = {
@@ -85,45 +87,87 @@
85
87
  const viewerDiv = document.getElementById('viewerDiv');
86
88
 
87
89
  // Create a GlobeView
88
- const view = new GlobeView(viewerDiv, placement, {});
90
+ const view = new GlobeView(viewerDiv, placement, {
91
+ controls: {
92
+ minDistance: 100,
93
+ }
94
+ });
95
+
96
+ // Enable various compression support for 3D Tiles tileset:
97
+ // - `KHR_draco_mesh_compression` mesh compression extension
98
+ // - `KHR_texture_basisu` texture compresion extension
99
+ itowns.enableDracoLoader('./libs/draco/');
100
+ itowns.enableKtx2Loader('./lib/basis/', view.renderer);
89
101
 
90
102
  // Add ambient light to globally illuminates all objects
91
- const light = new AmbientLight(0x404040, 15);
103
+ const light = new AmbientLight(0x404040, 40);
92
104
  view.scene.add(light);
93
105
 
94
106
  // Setup loading screen
95
107
  setupLoadingScreen(viewerDiv, view);
96
108
 
97
- // Setup debug menu
98
- const menuGlobe = new GuiTools('menuDiv', view, 300);
99
- debug.createTileDebugUI(menuGlobe.gui, view, view.tileLayer);
100
-
101
-
102
- // ---- ADD A BASEMAP ----
109
+ // ---- Add a basemap ----
103
110
 
104
111
  // Add one imagery layer to the scene. This layer's properties are
105
112
  // defined in a json file, but it cou ld be defined as a plain js
106
113
  // object. See `Layer` documentation for more info.
107
114
  Fetcher.json('./layers/JSONLayers/OPENSM.json').then((config) => {
108
- const layer = new ColorLayer('Ortho', {
115
+ const colorLayer = new ColorLayer('Ortho', {
109
116
  ...config,
110
117
  source: new TMSSource(config.source),
111
118
  });
112
- view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
119
+ view.addLayer(colorLayer);
113
120
  });
114
121
 
115
- // ---- ADD 3D TILES TILESET ----
122
+ // ---- Add 3D terrain ----
116
123
 
117
- // Enable various compression support for 3D Tiles tileset:
118
- // - `KHR_draco_mesh_compression` mesh compression extension
119
- // - `KHR_texture_basisu` texture compresion extension
120
- itowns.enableDracoLoader('./libs/draco/');
121
- itowns.enableKtx2Loader('./lib/basis/', view.renderer);
124
+ // Add two elevation layers: world terrain and a more precise terrain for france
125
+ // These will deform iTowns globe geometry to represent terrain elevation.
126
+ function addElevationLayerFromConfig(config) {
127
+ config.source = new itowns.WMTSSource(config.source);
128
+ var elevationLayer = new itowns.ElevationLayer(config.id, config);
129
+ view.addLayer(elevationLayer);
130
+ }
131
+ itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig);
132
+ itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig);
133
+
134
+ // ---------- 3D Tiles loading
135
+
136
+ function readURL() {
137
+ const url = document.getElementById('url').value;
138
+
139
+ if (url) {
140
+ setUrl(url);
141
+ }
142
+ }
143
+
144
+ function setUrl(url) {
145
+ if (!url) return;
146
+
147
+ const input_url = document.getElementById('url');
148
+ if (!input_url) return;
149
+
150
+ uri.searchParams.set('copc', url);
151
+ history.replaceState(null, null, `?${uri.searchParams.toString()}`);
152
+
153
+ input_url.value = url;
154
+ load(url);
155
+ }
156
+
157
+
158
+ function load(url) {
159
+ const source = new OGC3DTilesSource({ url });
122
160
 
123
- if (state.tileset) {
124
- const source = new OGC3DTilesSource({ url: state.tileset });
125
- const layer = new OGC3DTilesLayer('3DTiles', {
161
+ if (window.layer) {
162
+ gui.removeFolder('Layer 3DTiles');
163
+ view.removeLayer('3DTiles');
164
+ view.notifyChange();
165
+ window.layer.delete();
166
+ }
167
+
168
+ window.layer = new OGC3DTilesLayer('3DTiles', {
126
169
  source,
170
+ pntsSizeMode: PNTS_SIZE_MODE.ATTENUATED,
127
171
  });
128
172
 
129
173
  // Add an event for picking the 3D Tiles layer and displaying
@@ -131,20 +175,37 @@
131
175
  const pickingArgs = {
132
176
  htmlDiv: document.getElementById('featureInfo'),
133
177
  view,
134
- layer,
178
+ layer: window.layer,
135
179
  };
136
180
 
137
181
  // Add the layer to our view
138
- view.addLayer(layer).then((layer) => {
182
+ view.addLayer(window.layer).then((layer) => {
139
183
  zoomToLayer(view, layer);
140
184
  window.addEventListener('click',
141
185
  (event) => fillHTMLWithPickingInfo(event, pickingArgs), false);
142
186
  });
143
187
 
144
- debug.createOGC3DTilesDebugUI(menuGlobe.gui, view, layer);
188
+ window.layer.whenReady
189
+ .then(() => debug.createOGC3DTilesDebugUI(gui, view, window.layer));
190
+ }
191
+
192
+ function loadLyon() {
193
+ setUrl("https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/refs/heads/master/3DTiles/lyon1-4978/tileset.json");
194
+ }
195
+
196
+ function loadSete() {
197
+ setUrl("https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/pnts-sete-2021-0756_6256/tileset.json");
145
198
  }
146
199
 
147
- window.setURL = setURL;
200
+ function loadLille() {
201
+ setUrl("https://webimaging.lillemetropole.fr/externe/maillage/2020_mel_5cm/tileset.json");
202
+ }
203
+
204
+ window.readURL = readURL;
205
+ window.loadLyon = loadLyon;
206
+ window.loadSete = loadSete;
207
+ window.loadLille = loadLille;
208
+
148
209
  </script>
149
210
  </body>
150
211
  </html>
@@ -14,16 +14,8 @@
14
14
  "geoid_geoidLayer": "Display geoid heights"
15
15
  },
16
16
 
17
- "3d Tiles": {
18
- "3dtiles_basic": "on 3D map",
19
- "3dtiles_25d": "On 2.5D map",
20
- "3dtiles_batch_table": "Batch table Hierarchy extension",
21
- "3dtiles_ion": "From Cesium ion",
22
- "3dtiles_pointcloud": "Pointcloud classification"
23
- },
24
-
25
- "3D Tiles (new)": {
26
- "3dtiles_loader": "3D Tiles tileset loader"
17
+ "3D Tiles": {
18
+ "3dtiles_loader": "3D Tiles loader"
27
19
  },
28
20
 
29
21
  "Pointcloud": {
@@ -0,0 +1,123 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ width="2123.8423"
4
+ height="504"
5
+ viewBox="0 0 2123.8423 504"
6
+ version="1.1"
7
+ id="svg91"
8
+ sodipodi:docname="logo.svg"
9
+ inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
10
+ inkscape:label="layer_i"
11
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
13
+ xmlns:xlink="http://www.w3.org/1999/xlink"
14
+ xmlns="http://www.w3.org/2000/svg"
15
+ xmlns:svg="http://www.w3.org/2000/svg">
16
+ <sodipodi:namedview
17
+ id="namedview93"
18
+ pagecolor="#ffffff"
19
+ bordercolor="#666666"
20
+ borderopacity="1.0"
21
+ inkscape:pageshadow="2"
22
+ inkscape:pageopacity="0.0"
23
+ inkscape:pagecheckerboard="0"
24
+ showgrid="false"
25
+ inkscape:zoom="0.21100549"
26
+ inkscape:cx="1390.9591"
27
+ inkscape:cy="1049.7357"
28
+ inkscape:window-width="1850"
29
+ inkscape:window-height="1016"
30
+ inkscape:window-x="70"
31
+ inkscape:window-y="1107"
32
+ inkscape:window-maximized="1"
33
+ inkscape:current-layer="svg91"
34
+ showguides="true"
35
+ inkscape:guide-bbox="true">
36
+ <sodipodi:guide
37
+ position="303,12"
38
+ orientation="0,-1"
39
+ id="guide149742" />
40
+ <sodipodi:guide
41
+ position="922.7708,353.293"
42
+ orientation="0,-1"
43
+ id="guide161704" />
44
+ <sodipodi:guide
45
+ position="1076.0872,118.0449"
46
+ orientation="0,-1"
47
+ id="guide161710" />
48
+ <sodipodi:guide
49
+ position="1172.7675,246.6387"
50
+ orientation="0,-1"
51
+ id="guide161712" />
52
+ </sodipodi:namedview>
53
+ <defs
54
+ id="defs85">
55
+ <linearGradient
56
+ inkscape:collect="always"
57
+ id="linearGradient124706">
58
+ <stop
59
+ style="stop-color:#7ea8c5;stop-opacity:1"
60
+ offset="0"
61
+ id="stop124702" />
62
+ <stop
63
+ style="stop-color:#404e73;stop-opacity:1"
64
+ offset="1"
65
+ id="stop124704" />
66
+ </linearGradient>
67
+ <style
68
+ id="style83">
69
+ .cls-1 {
70
+ opacity: 0.4;
71
+ }
72
+ </style>
73
+ <linearGradient
74
+ inkscape:collect="always"
75
+ xlink:href="#linearGradient124706"
76
+ id="linearGradient124708"
77
+ x1="1129.2401"
78
+ y1="606.47083"
79
+ x2="1401.899"
80
+ y2="774.6546"
81
+ gradientUnits="userSpaceOnUse" />
82
+ </defs>
83
+ <g
84
+ id="g149219"
85
+ inkscape:label="Globe"
86
+ transform="translate(-523,-390)">
87
+ <ellipse
88
+ style="display:inline;fill:#c8d3da;fill-opacity:1;fill-rule:evenodd"
89
+ id="path1259"
90
+ cx="1227.5"
91
+ cy="692"
92
+ rx="202.5"
93
+ ry="202"
94
+ inkscape:label="Circle" />
95
+ <g
96
+ id="g124715"
97
+ style="display:inline;stroke:#355c77;stroke-opacity:1"
98
+ inkscape:label="Arrows">
99
+ <g
100
+ id="g124711"
101
+ style="stroke:#355c77;stroke-opacity:1"
102
+ inkscape:label="g124711">
103
+ <path
104
+ style="fill:url(#linearGradient124708);fill-opacity:1;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
105
+ d="m 1330,681 61,-12 c 3.02,7.842 4.076,15.87 6.019,24 0.623,2.608 1.725,6.621 4.931,7.079 3.39,0.484 5.145,-4.756 6.294,-7.079 4.368,-8.837 7.681,-18.455 10.126,-28 6.613,-25.808 -5.85,-43.846 -20.997,-64 -5.472,-7.282 -12.303,-17.758 -20.354,-22.338 -4.273,-2.4306 -5.13,2.0092 -4.714,5.3388 0.586,4.6919 7.851,20.6632 3.171,23.9322 -2.895,2.022 -10.95,0.067 -14.476,0.067 -10.657,-10e-4 -21.347,-0.246 -32,0.015 -4.325,0.106 -9.726,2.094 -13.892,0.382 -5.397,-2.219 -7.556,-13.418 -9.687,-18.397 -7.301,-17.0598 -16.733,-32.6765 -25.421,-49 5.562,-1.763 24.398,-1.5626 26.824,-7.2245 2.682,-6.2591 -15.778,-11.6544 -19.824,-13.3511 -16.725,-7.013 -34.232,-12.7414 -52,-16.4213 -6.905,-1.4301 -15.602,-3.9163 -21.535,1.4267 -9.584,8.6288 -15.545,24.2163 -21.218,35.5702 -1.756,3.5154 -6.626,10.6646 -1.928,13.821 8.653,5.8139 20.931,-6.3429 29.576,-1.7786 4.537,2.3953 6.205,9.4776 7.761,13.9576 4.228,12.1783 8.181,24.53 11.46,37 1.02,3.88 4.614,11.885 2.683,15.697 -2.377,4.69 -15.124,5.832 -19.799,7.163 -16.494,4.695 -32.732,10.384 -49,15.807 -4.374,1.458 -13.407,6.621 -17.891,4.977 -7.289,-2.674 -4.547,-35.284 -17.019,-27.036 -5.418,3.583 -8.841,11.197 -12.514,16.392 -10.2548,14.501 -20.0164,29.506 -28.7149,45 -3.9849,7.098 -10.3602,15.972 -4.2083,23.815 3.6295,4.627 10.3443,6.941 15.3472,9.761 13.8979,7.833 28.591,14.399 43,21.205 4.886,2.308 14.588,9.972 19.566,4.897 7.959,-8.114 -7.807,-22.054 -1.784,-30.399 3.34,-4.629 13.088,-4.493 18.218,-5.476 17.25,-3.306 34.664,-5.608 52,-8.393 4.543,-0.729 16.572,-4.766 20.411,-1.637 3.876,3.159 4.049,14.529 4.989,19.227 3.19,15.949 5.824,31.89 8.024,48 0.723,5.296 3.474,14.919 0.548,19.775 -5.411,8.981 -25.656,0.601 -29.171,11.33 -1.841,5.617 6.874,11.422 10.109,14.895 8.451,9.072 17.016,17.641 26.09,26.09 4.394,4.091 8.431,9.791 15,9.823 7.581,0.036 13.971,-7.022 19,-11.928 12.818,-12.503 24.842,-25.974 35.996,-39.985 3.543,-4.45 12.487,-12.805 12.176,-18.891 -0.593,-11.601 -26.368,5.893 -29.399,-4.168 -2.107,-6.995 0.227,-18.497 0.227,-25.941 0,-21.005 0.853,-42.26 -3,-63"
106
+ id="path1080"
107
+ sodipodi:nodetypes="ccsscccssscscccscsccsscsccscscsscsscccscscccscccscsc"
108
+ inkscape:label="path1080" />
109
+ </g>
110
+ </g>
111
+ </g>
112
+ <path
113
+ id="path952"
114
+ style="display:inline;fill:#404e73;fill-opacity:1"
115
+ inkscape:label="T wns"
116
+ d="M 177.03906,0 176.91602,93.58398 303,94 V 492 H 409.99414 L 410.5,94.5 538.5,93.5 539.0195,0 Z M 2011.0176,134.28125 c -13.0632,0.12998 -25.5667,1.33054 -36.8633,3.63281 -29.4349,5.99891 -57.9681,21.05292 -73.8867,38.98047 -12.3465,13.90461 -21.0569,31.08151 -24.6992,48.71485 -2.306,11.16435 -2.1202,33.20565 0.3613,42.9082 3.8861,15.19442 12.6728,29.33206 26.4336,42.5332 17.1315,16.43468 37.8519,27.767 72.9277,39.88477 26.8743,9.28436 38.5632,16.26831 43.2481,25.84375 2.4031,4.91179 2.6657,6.40755 2.2519,12.78711 -0.5206,8.02613 -2.1474,11.92677 -6.998,16.77734 -7.1349,7.1349 -19.3393,10.38075 -38.793,10.31445 -24.4588,-0.0833 -56.8353,-8.26242 -81.3359,-20.54687 -4.31,-2.161 -8.34,-3.76166 -8.9551,-3.55664 -1.2952,0.43175 -19.849,73.70135 -19.0078,75.0625 0.3086,0.4992 3.8636,2.41232 7.9004,4.25195 21.9315,9.99451 50.5827,16.99204 79.4902,19.41406 12.4848,1.04603 43.0849,0.48063 54.9082,-1.01367 38.4999,-4.86586 68.3037,-18.04186 88.5781,-39.16015 14.0553,-14.64031 22.6133,-31.44619 26.0528,-51.16797 2.1158,-12.13186 1.3753,-33.68965 -1.5606,-45.46875 -5.6685,-22.74204 -19.5206,-41.66585 -41.0273,-56.04688 -15.1873,-10.15539 -26.2884,-15.30705 -58.543,-27.16992 -36.0413,-13.25557 -46.6692,-22.13625 -45.248,-37.80859 0.83,-9.1535 5.475,-15.93482 13.8339,-20.19922 17.7737,-9.06744 56.359,-5.47043 87.0977,8.11914 11.915,5.26763 13.4655,5.6248 14.1797,3.27148 2.9956,-9.87087 17.6841,-68.85641 17.4472,-70.06445 -0.4198,-2.14067 -16.4538,-8.45661 -30.8222,-12.14063 -21.8739,-5.60839 -45.1988,-8.36897 -66.9707,-8.15234 z m -328.5235,8.21094 c -20.9646,0 -40.1175,4.76669 -57.4609,14.30078 -17.3434,9.33124 -33.7343,23.93681 -49.1719,43.81641 V 150.70703 H 1473.5156 V 491.5 h 102.3457 V 323.8418 c 0,-31.03651 6.0974,-55.27731 18.2949,-72.72266 12.1976,-17.64821 28.9707,-26.47266 50.3165,-26.47266 8.767,0 16.5802,2.02888 23.4414,6.08594 6.8612,3.85422 12.2926,9.3318 16.2949,16.43164 3.0494,5.27419 5.1455,13.48958 6.289,24.64649 1.3341,11.15691 2.002,31.44178 2.002,60.85547 V 457.72461 491.5 h 102.916 V 283.98047 c 0,-46.04763 -9.6238,-81.13979 -28.873,-105.2793 -19.0587,-24.1395 -47.0751,-36.20898 -84.0489,-36.20898 z M 922.7715,150.70703 1007.1504,492 h 111.8398 L 1172.7676,257.36133 1226.8262,492 h 111.8418 l 84.3808,-341.29297 h -99.541 l -54.0605,232.81055 -53.7735,-232.81055 h -85.5273 l -54.0586,235.24805 -53.7774,-235.24805 z" />
117
+ <path
118
+ id="path41630"
119
+ style="display:inline;fill:#7ea8c5;fill-opacity:1"
120
+ d="M 56.2207,0 C 25.17087,2e-5 2e-5,25.17087 0,56.2207 c 1e-5,31.04983 25.17087,56.22069 56.2207,56.22071 31.04984,-1e-5 56.2207,-25.17087 56.22071,-56.22071 C 112.44139,25.17087 87.27053,10e-6 56.2207,0 Z M 4.20703,151.33203 C 3.98701,264.88792 3.91235,378.44395 3.82849,492 c 34.67057,0 69.34114,0 104.01172,0 -0.29968,-113.55583 -0.46282,-227.11189 -0.63318,-340.66797 -34.33333,0 -68.66667,0 -103,0 z"
121
+ inkscape:label="i"
122
+ sodipodi:nodetypes="sssssccccc" />
123
+ </svg>
@@ -235,7 +235,7 @@ const COGParser = (function _() {
235
235
  */
236
236
  parse: async function _(data, options) {
237
237
  const source = options.in;
238
- const tileExtent = options.extent.as(source.crs);
238
+ const tileExtent = options.extent.isExtent ? options.extent.as(source.crs) : options.extent.toExtent(source.crs);
239
239
 
240
240
  const level = selectLevel(source, tileExtent, source.tileWidth, source.tileHeight);
241
241
  const viewport = makeWindowFromExtent(source, tileExtent, level.resolution);
@@ -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) {
@@ -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);
@@ -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
  }
@@ -55,8 +55,15 @@ class FeatureMesh extends THREE.Group {
55
55
  // calculate the scale transformation to transform the feature.extent
56
56
  // to feature.extent.as(crs)
57
57
  coord.crs = Crs.formatToEPSG(this.#originalCrs);
58
- extent.copy(this.extent).applyMatrix4(this.#collection.matrix);
59
- extent.as(coord.crs, extent);
58
+ // TODO: An extent here could be either a geographic extent (for
59
+ // features from WFS) or a tiled extent (for features from MVT).
60
+ // Unify both behavior.
61
+ if (this.extent.isExtent) {
62
+ extent.copy(this.extent).applyMatrix4(this.#collection.matrix);
63
+ extent.as(coord.crs, extent);
64
+ } else {
65
+ this.extent.toExtent(coord.crs, extent);
66
+ }
60
67
  extent.spatialEuclideanDimensions(dim_ref);
61
68
  extent.planarDimensions(dim);
62
69
  if (dim.x && dim.y) {
@@ -15,15 +15,15 @@ function textureColorLayer(texture, layer) {
15
15
  return textureLayer(texture, layer);
16
16
  }
17
17
  export default {
18
- convert(data, extentDestination, layer) {
18
+ convert(data, destinationTile, layer) {
19
19
  let texture;
20
20
  if (data.isFeatureCollection) {
21
21
  const backgroundLayer = layer.source.backgroundLayer;
22
22
  const backgroundColor = backgroundLayer && backgroundLayer.paint ? new THREE.Color(backgroundLayer.paint['background-color']) : undefined;
23
- extentDestination.as(CRS.formatToEPSG(layer.crs), extentTexture);
23
+ destinationTile.toExtent(CRS.formatToEPSG(layer.crs), extentTexture);
24
24
  texture = Feature2Texture.createTextureFromFeature(data, extentTexture, layer.subdivisionThreshold, layer.style, backgroundColor);
25
25
  texture.features = data;
26
- texture.extent = extentDestination;
26
+ texture.extent = destinationTile;
27
27
  } else if (data.isTexture) {
28
28
  texture = data;
29
29
  } else {