itowns 2.44.3-next.1 → 2.44.3-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 (58) hide show
  1. package/CODING.md +1 -1
  2. package/dist/455.js +1 -1
  3. package/dist/455.js.map +1 -1
  4. package/dist/debug.js +1 -1
  5. package/dist/debug.js.LICENSE.txt +1 -1
  6. package/dist/debug.js.map +1 -1
  7. package/dist/itowns.js +1 -1
  8. package/dist/itowns.js.map +1 -1
  9. package/dist/itowns_lasworker.js +1 -1
  10. package/dist/itowns_lasworker.js.map +1 -1
  11. package/dist/itowns_widgets.js +1 -1
  12. package/dist/itowns_widgets.js.map +1 -1
  13. package/examples/3dtiles_loader.html +104 -43
  14. package/examples/config.json +2 -10
  15. package/examples/images/itowns_logo.svg +123 -0
  16. package/lib/Controls/GlobeControls.js +41 -22
  17. package/lib/Controls/StateControl.js +4 -1
  18. package/lib/Controls/StreetControls.js +5 -2
  19. package/lib/Converter/Feature2Mesh.js +11 -4
  20. package/lib/Converter/textureConverter.js +3 -3
  21. package/lib/Core/Feature.js +2 -2
  22. package/lib/Core/Geographic/Extent.js +74 -266
  23. package/lib/Core/Prefab/Globe/GlobeLayer.js +1 -1
  24. package/lib/Core/Prefab/Planar/PlanarLayer.js +1 -1
  25. package/lib/Core/Style.js +2 -2
  26. package/lib/Core/Tile/Tile.js +219 -0
  27. package/lib/Core/Tile/TileGrid.js +46 -0
  28. package/lib/Core/TileMesh.js +3 -2
  29. package/lib/Core/View.js +1 -1
  30. package/lib/Layer/C3DTilesLayer.js +15 -14
  31. package/lib/Layer/CopcLayer.js +1 -1
  32. package/lib/Layer/LabelLayer.js +9 -5
  33. package/lib/Layer/OGC3DTilesLayer.js +36 -9
  34. package/lib/Parser/GeoJsonParser.js +1 -1
  35. package/lib/Parser/LASParser.js +1 -1
  36. package/lib/Parser/Potree2BinParser.js +1 -1
  37. package/lib/Parser/VectorTileParser.js +1 -1
  38. package/lib/Parser/XbilParser.js +15 -4
  39. package/lib/Provider/URLBuilder.js +22 -11
  40. package/lib/Renderer/Camera.js +1 -1
  41. package/lib/Renderer/LayeredMaterial.js +1 -1
  42. package/lib/Renderer/PointsMaterial.js +1 -1
  43. package/lib/Source/CopcSource.js +1 -1
  44. package/lib/Source/TMSSource.js +9 -7
  45. package/lib/Source/VectorTilesSource.js +2 -2
  46. package/lib/Source/WFSSource.js +4 -1
  47. package/lib/Source/WMSSource.js +4 -1
  48. package/lib/ThreeExtended/capabilities/WebGL.js +16 -11
  49. package/lib/ThreeExtended/loaders/GLTFLoader.js +10 -6
  50. package/lib/ThreeExtended/loaders/KTX2Loader.js +14 -7
  51. package/lib/Utils/CameraUtils.js +5 -4
  52. package/lib/Utils/gui/C3DTilesStyle.js +2 -3
  53. package/package.json +33 -28
  54. package/examples/3dtiles_25d.html +0 -120
  55. package/examples/3dtiles_basic.html +0 -94
  56. package/examples/3dtiles_batch_table.html +0 -86
  57. package/examples/3dtiles_ion.html +0 -126
  58. package/examples/3dtiles_pointcloud.html +0 -95
@@ -1,8 +1,10 @@
1
1
  import Source from "./Source.js";
2
2
  import URLBuilder from "../Provider/URLBuilder.js";
3
- import Extent, { globalExtentTMS } from "../Core/Geographic/Extent.js";
3
+ import Extent from "../Core/Geographic/Extent.js";
4
+ import Tile from "../Core/Tile/Tile.js";
5
+ import { globalExtentTMS } from "../Core/Tile/TileGrid.js";
4
6
  import CRS from "../Core/Geographic/Crs.js";
5
- const extent = new Extent(CRS.tms_4326, 0, 0, 0);
7
+ const _tile = new Tile(CRS.tms_4326, 0, 0, 0);
6
8
 
7
9
  /**
8
10
  * An object defining the source of resources to get from a
@@ -107,8 +109,8 @@ class TMSSource extends Source {
107
109
  }
108
110
  }
109
111
  }
110
- urlFromExtent(extent) {
111
- return URLBuilder.xyz(extent, this);
112
+ urlFromExtent(tile) {
113
+ return URLBuilder.xyz(tile, this);
112
114
  }
113
115
  onLayerAdded(options) {
114
116
  super.onLayerAdded(options);
@@ -118,17 +120,17 @@ class TMSSource extends Source {
118
120
  const crs = parent ? parent.extent.crs : options.out.crs;
119
121
  if (this.tileMatrixSetLimits && !this.extentSetlimits[crs]) {
120
122
  this.extentSetlimits[crs] = {};
121
- extent.crs = this.crs;
123
+ _tile.crs = this.crs;
122
124
  for (let i = this.zoom.max; i >= this.zoom.min; i--) {
123
125
  const tmsl = this.tileMatrixSetLimits[i];
124
126
  const {
125
127
  west,
126
128
  north
127
- } = extent.set(i, tmsl.minTileRow, tmsl.minTileCol).as(crs);
129
+ } = _tile.set(i, tmsl.minTileRow, tmsl.minTileCol).toExtent(crs);
128
130
  const {
129
131
  east,
130
132
  south
131
- } = extent.set(i, tmsl.maxTileRow, tmsl.maxTileCol).as(crs);
133
+ } = _tile.set(i, tmsl.maxTileRow, tmsl.maxTileCol).toExtent(crs);
132
134
  this.extentSetlimits[crs][i] = new Extent(crs, west, east, south, north);
133
135
  }
134
136
  }
@@ -135,8 +135,8 @@ class VectorTilesSource extends TMSSource {
135
135
  this.urls = Array.from(new Set(TMSUrlList));
136
136
  });
137
137
  }
138
- urlFromExtent(extent, url) {
139
- return URLBuilder.xyz(extent, {
138
+ urlFromExtent(tile, url) {
139
+ return URLBuilder.xyz(tile, {
140
140
  tileMatrixCallback: this.tileMatrixCallback,
141
141
  url
142
142
  });
@@ -1,6 +1,8 @@
1
1
  import Source from "./Source.js";
2
2
  import URLBuilder from "../Provider/URLBuilder.js";
3
3
  import CRS from "../Core/Geographic/Crs.js";
4
+ import Extent from "../Core/Geographic/Extent.js";
5
+ const _extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
4
6
 
5
7
  /**
6
8
  * An object defining the source of resources to get from a
@@ -155,7 +157,8 @@ class WFSSource extends Source {
155
157
  return [extent.zoom, extent.south, extent.west];
156
158
  }
157
159
  }
158
- urlFromExtent(extent) {
160
+ urlFromExtent(extentOrTile) {
161
+ const extent = extentOrTile.isExtent ? extentOrTile.as(this.crs, _extent) : extentOrTile.toExtent(this.crs, _extent);
159
162
  return URLBuilder.bbox(extent, this);
160
163
  }
161
164
  extentInsideLimit(extent) {
@@ -1,5 +1,7 @@
1
1
  import Source from "./Source.js";
2
2
  import URLBuilder from "../Provider/URLBuilder.js";
3
+ import Extent from "../Core/Geographic/Extent.js";
4
+ const _extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
3
5
 
4
6
  /**
5
7
  * An object defining the source of images to get from a
@@ -120,7 +122,8 @@ class WMSSource extends Source {
120
122
  }
121
123
  }
122
124
  }
123
- urlFromExtent(extent) {
125
+ urlFromExtent(extentOrTile) {
126
+ const extent = extentOrTile.isExtent ? extentOrTile.as(this.crs, _extent) : extentOrTile.toExtent(this.crs, _extent);
124
127
  return URLBuilder.bbox(extent, this);
125
128
  }
126
129
  extentInsideLimit(extent) {
@@ -1,12 +1,4 @@
1
1
  class WebGL {
2
- static isWebGLAvailable() {
3
- try {
4
- const canvas = document.createElement('canvas');
5
- return !!(window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')));
6
- } catch (e) {
7
- return false;
8
- }
9
- }
10
2
  static isWebGL2Available() {
11
3
  try {
12
4
  const canvas = document.createElement('canvas');
@@ -25,9 +17,6 @@ class WebGL {
25
17
  return false;
26
18
  }
27
19
  }
28
- static getWebGLErrorMessage() {
29
- return this.getErrorMessage(1);
30
- }
31
20
  static getWebGL2ErrorMessage() {
32
21
  return this.getErrorMessage(2);
33
22
  }
@@ -60,5 +49,21 @@ class WebGL {
60
49
  element.innerHTML = message;
61
50
  return element;
62
51
  }
52
+
53
+ // @deprecated, r168
54
+
55
+ static isWebGLAvailable() {
56
+ console.warn('isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.');
57
+ try {
58
+ const canvas = document.createElement('canvas');
59
+ return !!(window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')));
60
+ } catch (e) {
61
+ return false;
62
+ }
63
+ }
64
+ static getWebGLErrorMessage() {
65
+ console.warn('getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead.');
66
+ return this.getErrorMessage(1);
67
+ }
63
68
  }
64
69
  export default WebGL;
@@ -1564,14 +1564,18 @@ class GLTFParser {
1564
1564
  // expensive work of uploading a texture to the GPU off the main thread.
1565
1565
 
1566
1566
  let isSafari = false;
1567
+ let safariVersion = -1;
1567
1568
  let isFirefox = false;
1568
1569
  let firefoxVersion = -1;
1569
1570
  if (typeof navigator !== 'undefined') {
1570
- isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) === true;
1571
- isFirefox = navigator.userAgent.indexOf('Firefox') > -1;
1572
- firefoxVersion = isFirefox ? navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1;
1573
- }
1574
- if (typeof createImageBitmap === 'undefined' || isSafari || isFirefox && firefoxVersion < 98) {
1571
+ const userAgent = navigator.userAgent;
1572
+ isSafari = /^((?!chrome|android).)*safari/i.test(userAgent) === true;
1573
+ const safariMatch = userAgent.match(/Version\/(\d+)/);
1574
+ safariVersion = isSafari && safariMatch ? parseInt(safariMatch[1], 10) : -1;
1575
+ isFirefox = userAgent.indexOf('Firefox') > -1;
1576
+ firefoxVersion = isFirefox ? userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1;
1577
+ }
1578
+ if (typeof createImageBitmap === 'undefined' || isSafari && safariVersion < 17 || isFirefox && firefoxVersion < 98) {
1575
1579
  this.textureLoader = new TextureLoader(this.options.manager);
1576
1580
  } else {
1577
1581
  this.textureLoader = new ImageBitmapLoader(this.options.manager);
@@ -2135,7 +2139,7 @@ class GLTFParser {
2135
2139
  }
2136
2140
  mesh.material = material;
2137
2141
  }
2138
- getMaterialType( /* materialIndex */
2142
+ getMaterialType(/* materialIndex */
2139
2143
  ) {
2140
2144
  return MeshStandardMaterial;
2141
2145
  }
@@ -120,15 +120,22 @@ class KTX2Loader extends Loader {
120
120
  loader.setResponseType('arraybuffer');
121
121
  loader.setWithCredentials(this.withCredentials);
122
122
  loader.load(url, buffer => {
123
- // Check for an existing task using this buffer. A transferred buffer cannot be transferred
124
- // again from this thread.
125
- if (_taskCache.has(buffer)) {
126
- const cachedTask = _taskCache.get(buffer);
127
- return cachedTask.promise.then(onLoad).catch(onError);
128
- }
129
- this._createTexture(buffer).then(texture => onLoad ? onLoad(texture) : null).catch(onError);
123
+ this.parse(buffer, onLoad, onError);
130
124
  }, onProgress, onError);
131
125
  }
126
+ parse(buffer, onLoad, onError) {
127
+ if (this.workerConfig === null) {
128
+ throw new Error('THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.');
129
+ }
130
+
131
+ // Check for an existing task using this buffer. A transferred buffer cannot be transferred
132
+ // again from this thread.
133
+ if (_taskCache.has(buffer)) {
134
+ const cachedTask = _taskCache.get(buffer);
135
+ return cachedTask.promise.then(onLoad).catch(onError);
136
+ }
137
+ this._createTexture(buffer).then(texture => onLoad ? onLoad(texture) : null).catch(onError);
138
+ }
132
139
  _createTextureFrom(transcodeResult, container) {
133
140
  const {
134
141
  faces,
@@ -231,7 +231,7 @@ class CameraRig extends THREE.Object3D {
231
231
  if (Math.abs(difference) > Math.PI) {
232
232
  this.end.target.rotation.z = this.start.target.rotation.z + difference - Math.sign(difference) * 2 * Math.PI;
233
233
  }
234
- animations.push(new TWEEN.Tween(factor, tweenGroup).to({
234
+ animations.push(new TWEEN.Tween(factor).to({
235
235
  t: 1
236
236
  }, time).easing(params.easing).onUpdate(d => {
237
237
  // rotate to coord destination in geocentric projection
@@ -248,14 +248,15 @@ class CameraRig extends THREE.Object3D {
248
248
 
249
249
  // translate to coordinate destination in planar projection
250
250
  if (view.referenceCrs != 'EPSG:4978') {
251
- animations.push(new TWEEN.Tween(this.position, tweenGroup).to(this.end.position, time).easing(params.easing));
251
+ animations.push(new TWEEN.Tween(this.position).to(this.end.position, time).easing(params.easing));
252
252
  }
253
253
 
254
254
  // translate to altitude zero
255
- animations.push(new TWEEN.Tween(this.seaLevel.position, tweenGroup).to(this.end.seaLevel.position, time).easing(params.easing));
255
+ animations.push(new TWEEN.Tween(this.seaLevel.position).to(this.end.seaLevel.position, time).easing(params.easing));
256
256
 
257
257
  // translate camera position
258
- animations.push(new TWEEN.Tween(this.camera.position, tweenGroup).to(this.end.camera.position, time).easing(params.easing));
258
+ animations.push(new TWEEN.Tween(this.camera.position).to(this.end.camera.position, time).easing(params.easing));
259
+ tweenGroup.add(...animations);
259
260
 
260
261
  // update animations, transformation and view
261
262
  this.animationFrameRequester = () => {
@@ -1,4 +1,3 @@
1
- import Style from "../../Core/Style.js";
2
1
  import { C3DTILES_LAYER_EVENTS } from "../../Layer/C3DTilesLayer.js";
3
2
  import Widget from "./Widget.js";
4
3
  const DEFAULT_OPTIONS = {
@@ -187,7 +186,7 @@ class C3DTilesStyle extends Widget {
187
186
  }
188
187
 
189
188
  // set style
190
- c3DTilesLayer.style = new Style({
189
+ c3DTilesLayer.style = {
191
190
  fill: {
192
191
  color: c3DTileFeature => {
193
192
  let result = null;
@@ -204,7 +203,7 @@ class C3DTilesStyle extends Widget {
204
203
  return result;
205
204
  }
206
205
  }
207
- });
206
+ };
208
207
  });
209
208
  });
210
209
  updateSelectedLayer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.44.3-next.1",
3
+ "version": "2.44.3-next.11",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",
@@ -9,7 +9,7 @@
9
9
  "./widgets": "./lib/Utils/gui/Main.js"
10
10
  },
11
11
  "scripts": {
12
- "lint": "eslint \"src/**/*.js\" \"test/**/*.js\" \"examples/**/*.js\" \"docs/*.js\"",
12
+ "lint": "eslint \"src/**/*.{js,ts,tsx}\" \"test/**/*.js\" \"examples/**/*.js\" \"docs/*.js\"",
13
13
  "doc": "jsdoc --readme docs/HOMEPAGE.md -c docs/config.json",
14
14
  "doclint": "npm run doc -- -t templates/silent",
15
15
  "test": "npm run lint -- --max-warnings=0 && npm run build && npm run test-with-coverage && npm run test-functional",
@@ -60,30 +60,35 @@
60
60
  "@mapbox/mapbox-gl-style-spec": "^13.28.0",
61
61
  "@mapbox/vector-tile": "^2.0.3",
62
62
  "@tmcw/togeojson": "^5.8.1",
63
- "@tweenjs/tween.js": "^23.1.2",
64
- "3d-tiles-renderer": "^0.3.37",
63
+ "@tweenjs/tween.js": "^25.0.0",
64
+ "3d-tiles-renderer": "^0.3.38",
65
65
  "brotli-compress": "^1.3.3",
66
66
  "copc": "^0.0.6",
67
67
  "earcut": "^3.0.0",
68
68
  "js-priority-queue": "^0.1.5",
69
69
  "pbf": "^4.0.1",
70
- "shpjs": "^6.0.1",
70
+ "shpjs": "^6.1.0",
71
71
  "threads": "^1.7.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "proj4": "^2.11.0",
75
- "three": "^0.165.0"
74
+ "proj4": "^2.12.1",
75
+ "three": "^0.168.0"
76
76
  },
77
77
  "devDependencies": {
78
- "@babel/cli": "^7.24.8",
79
- "@babel/core": "^7.24.9",
80
- "@babel/plugin-transform-runtime": "^7.24.7",
81
- "@babel/preset-env": "^7.24.8",
78
+ "@babel/cli": "^7.25.6",
79
+ "@babel/core": "^7.25.2",
80
+ "@babel/plugin-transform-runtime": "^7.25.4",
81
+ "@babel/preset-env": "^7.25.4",
82
+ "@babel/preset-typescript": "^7.24.7",
82
83
  "@babel/register": "^7.24.6",
83
- "@types/three": "^0.165.0",
84
- "@xmldom/xmldom": "^0.8.10",
84
+ "@stylistic/eslint-plugin": "^2.8.0",
85
+ "@types/proj4": "^2.5.5",
86
+ "@types/three": "^0.168.0",
87
+ "@typescript-eslint/eslint-plugin": "^8.5.0",
88
+ "@typescript-eslint/parser": "^8.5.0",
89
+ "@xmldom/xmldom": "^0.9.2",
85
90
  "babel-inline-import-loader": "^1.0.1",
86
- "babel-loader": "^9.1.3",
91
+ "babel-loader": "^9.2.1",
87
92
  "babel-plugin-inline-import": "^3.0.0",
88
93
  "babel-plugin-minify-dead-code-elimination": "^0.5.2",
89
94
  "babel-plugin-minify-replace": "^0.5.0",
@@ -91,34 +96,34 @@
91
96
  "babel-plugin-module-resolver": "^5.0.2",
92
97
  "c8": "^10.1.2",
93
98
  "chalk": "^5.3.0",
94
- "chart.js": "^4.4.3",
99
+ "chart.js": "^4.4.4",
95
100
  "compare-func": "^2.0.0",
96
101
  "conventional-changelog-cli": "^4.1.0",
97
102
  "copyfiles": "^2.4.1",
98
- "core-js": "^3.37.1",
103
+ "core-js": "^3.38.1",
99
104
  "cross-env": "^7.0.3",
100
105
  "eslint": "^8.55.0",
101
106
  "eslint-config-airbnb-base": "^15.0.0",
102
107
  "eslint-import-resolver-babel-module": "^5.3.2",
103
- "eslint-plugin-import": "^2.29.0",
104
- "eslint-webpack-plugin": "^4.0.1",
108
+ "eslint-plugin-import": "^2.30.0",
109
+ "eslint-plugin-tsdoc": "^0.3.0",
110
+ "eslint-webpack-plugin": "^4.2.0",
105
111
  "github-url-from-git": "^1.5.0",
106
112
  "grunt": "^1.6.1",
107
113
  "grunt-bump": "^0.8.0",
108
114
  "https-proxy-agent": "^7.0.5",
109
115
  "jsdoc": "^4.0.3",
110
- "mocha": "^10.2.0",
111
- "node-fetch": "^2.7.0",
112
- "proj4": "^2.11.0",
113
- "puppeteer": "^22.13.1",
116
+ "mocha": "^10.7.3",
117
+ "proj4": "^2.12.1",
118
+ "puppeteer": "^23.3.1",
114
119
  "q": "^1.5.1",
115
- "replace-in-file": "^7.2.0",
116
- "sinon": "^18.0.0",
117
- "three": "^0.165.0",
118
- "typescript": "^5.5.2",
120
+ "replace-in-file": "^8.1.0",
121
+ "sinon": "^19.0.2",
122
+ "three": "^0.168.0",
123
+ "typescript": "^5.6.2",
119
124
  "webgl-mock": "^0.1.7",
120
- "webpack": "^5.93.0",
125
+ "webpack": "^5.94.0",
121
126
  "webpack-cli": "^5.1.4",
122
- "webpack-dev-server": "^5.0.4"
127
+ "webpack-dev-server": "^5.1.0"
123
128
  }
124
129
  }
@@ -1,120 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Itowns - 3D Tiles on 2.5D map example</title>
4
-
5
- <meta charset="UTF-8">
6
- <link rel="stylesheet" type="text/css" href="css/example.css">
7
- <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
8
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
9
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
10
- </head>
11
- <body>
12
- <div id="viewerDiv" class="viewer"></div>
13
- <script src="../dist/itowns.js"></script>
14
- <script src="js/GUI/LoadingScreen.js"></script>
15
- <script src="../dist/debug.js"></script>
16
- <script src="js/GUI/GuiTools.js"></script>
17
- <script src="js/3dTilesHelper.js"></script>
18
- <script type="text/javascript">
19
- // Define crs projection that we will use (taken from https://epsg.io/3946, Proj4js section)
20
- itowns.proj4.defs('EPSG:3946', '+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
21
-
22
- // Define geographic extent: CRS, min/max X, min/max Y
23
- var extent = new itowns.Extent( 'EPSG:3946',
24
- 1837816.94334, 1847692.32501,
25
- 5170036.4587, 5178412.82698);
26
-
27
- // `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
28
- var viewerDiv = document.getElementById('viewerDiv');
29
-
30
- // Instanciate PlanarView*
31
- var cameraCoord = new itowns.Coordinates('EPSG:3946', 1841980,
32
- 5175682, 3000)
33
- var view = new itowns.PlanarView(viewerDiv, extent, { placement: {
34
- coord: cameraCoord, heading: 30, range: 4000, tilt: 30 } });
35
-
36
- setupLoadingScreen(viewerDiv, view);
37
-
38
- // Add a WMS imagery source
39
- var wmsImagerySource = new itowns.WMSSource({
40
- extent: extent,
41
- name: 'ortho_latest',
42
- url: 'https://imagerie.data.grandlyon.com/wms/grandlyon',
43
- version: '1.3.0',
44
- crs: 'EPSG:3946',
45
- format: 'image/jpeg',
46
- });
47
-
48
- // Add a WMS imagery layer
49
- var wmsImageryLayer = new itowns.ColorLayer('wms_imagery', {
50
- updateStrategy: {
51
- type: itowns.STRATEGY_DICHOTOMY,
52
- options: {},
53
- },
54
- source: wmsImagerySource,
55
- });
56
-
57
- view.addLayer(wmsImageryLayer);
58
-
59
- // Add a WMS elevation source
60
- var wmsElevationSource = new itowns.WMSSource({
61
- extent: extent,
62
- url: 'https://imagerie.data.grandlyon.com/wms/grandlyon',
63
- name: 'MNT2018_Altitude_2m',
64
- crs: 'EPSG:3946',
65
- width: 256,
66
- format: 'image/jpeg',
67
- });
68
-
69
- // Add a WMS elevation layer
70
- var wmsElevationLayer = new itowns.ElevationLayer('wms_elevation', {
71
- useColorTextureElevation: true,
72
- colorTextureElevationMinZ: 144,
73
- colorTextureElevationMaxZ: 622,
74
- source: wmsElevationSource,
75
- });
76
-
77
- view.addLayer(wmsElevationLayer);
78
-
79
- // Add 3D Tiles layer
80
- // This 3D Tiles tileset uses the draco compression that is an
81
- // extension of gltf. We need to enable it.
82
- itowns.enableDracoLoader('./libs/draco/');
83
-
84
- var $3dTilesLayer = new itowns.C3DTilesLayer(
85
- '3d-tiles-layer-building', {
86
- name: 'Lyon-2015-building',
87
- source: new itowns.C3DTilesSource({
88
- url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/' +
89
- '3DTiles/lyon_1_3946_textured_draco/tileset.json',
90
- }),
91
- }, view);
92
-
93
- // Lights
94
- var dirLight = new itowns.THREE.DirectionalLight(0xffffff, 1);
95
- dirLight.position.set(-0.9, 0.3, 1);
96
- dirLight.updateMatrixWorld();
97
- view.scene.add( dirLight );
98
-
99
- var ambLight = new itowns.THREE.AmbientLight(0xffffff, 0.2);
100
- view.scene.add( ambLight );
101
-
102
- // Pick 3D Tiles features when hovering them with the mouse and
103
- // display their semantic information in an html div
104
- var pickingArgs = {};
105
- pickingArgs.htmlDiv = document.getElementById('featureInfo');
106
- pickingArgs.view = view;
107
- pickingArgs.layer = $3dTilesLayer;
108
- itowns.View.prototype.addLayer.call(view, $3dTilesLayer);
109
-
110
- // Request redraw
111
- view.notifyChange();
112
-
113
- // Add a debug UI
114
- var menu = new GuiTools('menuDiv', view);
115
- var d = new debug.Debug(view, menu.gui);
116
- debug.createTileDebugUI(menu.gui, view, view.tileLayer, d);
117
- debug.create3dTilesDebugUI(menu.gui, view, $3dTilesLayer);
118
- </script>
119
- </body>
120
- </html>
@@ -1,94 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Itowns - 3d-tiles example</title>
5
-
6
- <meta charset="UTF-8">
7
- <link rel="stylesheet" type="text/css" href="css/example.css">
8
- <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
9
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
11
- </head>
12
- <body>
13
- <div id="viewerDiv"></div>
14
- <div id="description">
15
- <p><b>Feature Information:</b></p>
16
- <div id="featureInfo"></div>
17
- </div>
18
- <script src="js/GUI/GuiTools.js"></script>
19
- <script src="../dist/itowns.js"></script>
20
- <script src="js/GUI/LoadingScreen.js"></script>
21
- <script src="../dist/debug.js"></script>
22
- <script src="js/3dTilesHelper.js"></script>
23
- <script type="text/javascript">
24
- /* global itowns,document,GuiTools*/
25
- var placement = {
26
- coord: new itowns.Coordinates('EPSG:4326', -75.6114, 40.03428, 0),
27
- range: 4000,
28
- tilt: 22,
29
- heading: 180
30
- }
31
- // iTowns namespace defined here
32
- var viewerDiv = document.getElementById('viewerDiv');
33
-
34
- var view = new itowns.GlobeView(viewerDiv, placement);
35
- view.camera3D.near = 5;
36
- setupLoadingScreen(viewerDiv, view);
37
-
38
- var menuGlobe = new GuiTools('menuDiv', view, 300);
39
-
40
- itowns.Fetcher.json('./layers/JSONLayers/OPENSM.json').then(function _(config) {
41
- config.source = new itowns.TMSSource(config.source);
42
- var layer = new itowns.ColorLayer('Ortho', config);
43
- view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
44
- });
45
-
46
- // Create a new Layer 3d-tiles For DiscreteLOD
47
- // -------------------------------------------
48
- var $3dTilesLayerDiscreteLOD = new itowns.C3DTilesLayer('3d-tiles-discrete-lod', {
49
- name: 'DiscreteLOD',
50
- sseThreshold: 0.05,
51
- source: new itowns.C3DTilesSource({
52
- url: 'https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/master/1.0/TilesetWithDiscreteLOD/tileset.json',
53
- }),
54
- }, view);
55
-
56
- itowns.View.prototype.addLayer.call(view, $3dTilesLayerDiscreteLOD);
57
-
58
- // Create a new Layer 3d-tiles For Viewer Request Volume
59
- // -----------------------------------------------------
60
-
61
- var $3dTilesLayerRequestVolume = new itowns.C3DTilesLayer('3d-tiles-request-volume', {
62
- name: 'RequestVolume',
63
- source: new itowns.C3DTilesSource({
64
- url: 'https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/master/1.0/TilesetWithRequestVolume/tileset.json',
65
- }),
66
- sseThreshold: 1,
67
- }, view);
68
-
69
- // add an event for picking the 3D Tiles layer and displaying
70
- // information about the picked feature in an html div
71
- var pickingArgs = {};
72
- pickingArgs.htmlDiv = document.getElementById('featureInfo');
73
- pickingArgs.view = view;
74
- pickingArgs.layer = $3dTilesLayerRequestVolume;
75
- itowns.View.prototype.addLayer.call(view,
76
- $3dTilesLayerRequestVolume).then(function _() {
77
- window.addEventListener('mousemove',
78
- (event) => fillHTMLWithPickingInfo(event, pickingArgs),false);
79
- });
80
-
81
- // Add the UI Debug
82
- var d = new debug.Debug(view, menuGlobe.gui);
83
- debug.createTileDebugUI(menuGlobe.gui, view, view.tileLayer, d);
84
- debug.create3dTilesDebugUI(menuGlobe.gui, view, $3dTilesLayerDiscreteLOD);
85
- debug.create3dTilesDebugUI(menuGlobe.gui, view, $3dTilesLayerRequestVolume);
86
- d.zoom = function() {
87
- view.camera3D.position.set(1215013.9, -4736315.5, 4081597.5);
88
- view.camera3D.quaternion.set(0.9108514448729665, 0.13456816437801225, 0.1107206134840362, 0.3741416847378546);
89
- view.notifyChange(view.camera3D);
90
- }
91
- menuGlobe.gui.add(d, 'zoom').name('Go to point cloud');
92
- </script>
93
- </body>
94
- </html>