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
@@ -1,126 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Itowns - 3d-tiles from Cesium ion example</title>
5
-
6
- <meta charset="UTF-8">
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
-
9
- <link rel="stylesheet" type="text/css" href="css/example.css">
10
- <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
11
-
12
- <style type="text/css">
13
- #description {
14
- z-index: 2;
15
- left: 10px;
16
- width: 30%;
17
- }
18
- </style>
19
-
20
-
21
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
22
- </head>
23
- <body>
24
- <div id="description">
25
- <p><b>This example displays a dataset representing extruded OSM buildings from Cesium ion
26
- with Cesium default access token. Zoom to any place in the world to see the buildings. <br>
27
- Buildings may appear to "fly" above the ground in some places, this is due to the combination
28
- of precision errors of this dataset and of the 3D terrain we use in this example. </b>
29
- </p>
30
- </div>
31
- <div id="attribution"></div>
32
- <div id="viewerDiv"></div>
33
-
34
- <!-- Import iTowns source code -->
35
- <script src="../dist/itowns.js"></script>
36
- <!-- Import iTowns LoadingScreen plugin -->
37
- <script src="js/GUI/LoadingScreen.js"></script>
38
-
39
- <script type="text/javascript">
40
-
41
- // ---------- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION : ----------
42
-
43
- // Define camera initial position
44
- const placement = {
45
- coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712),
46
- range: 25000000,
47
- }
48
- // `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
49
- var viewerDiv = document.getElementById('viewerDiv');
50
-
51
- // Create a GlobeView
52
- var viewOptions = {
53
- diffuse: new itowns.THREE.Color(0xa0d5fc)
54
- };
55
- var view = new itowns.GlobeView(viewerDiv, placement, viewOptions);
56
-
57
- // Setup loading screen
58
- setupLoadingScreen(viewerDiv, view);
59
-
60
- // ---------- ADD A BASEMAP: ----------
61
-
62
- // Add one imagery layer to the scene. This layer's properties are defined in a json file, but it could be
63
- // defined as a plain js object. See `Layer` documentation for more info.
64
- itowns.Fetcher.json('./layers/JSONLayers/OPENSM.json').then(function _(config) {
65
- config.source = new itowns.TMSSource(config.source);
66
- var layer = new itowns.ColorLayer('Ortho', config);
67
- view.addLayer(layer);
68
- });
69
-
70
- // ---------- ADD DIGITAL ELEVATION MODELS : ----------
71
-
72
- // Add two elevation layers, each with a different level of detail. Here again, each layer's properties are
73
- // defined in a json file.
74
- function addElevationLayerFromConfig(config) {
75
- config.source = new itowns.WMTSSource(config.source);
76
- view.addLayer(
77
- new itowns.ElevationLayer(config.id, config),
78
- );
79
- }
80
- itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig);
81
- itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig);
82
-
83
- // ---------- ADD 3D TILES MODEL FROM CESIUM ION SERVER : ----------
84
-
85
- // Enable draco compression (used by this tileset)
86
- itowns.enableDracoLoader('./libs/draco/');
87
-
88
- // Create a new 3D Tiles batch table hierarchy extension manager and add it to the tileset since this tileset
89
- // uses this extension
90
- const extensions = new itowns.C3DTExtensions();
91
- extensions.registerExtension("3DTILES_batch_table_hierarchy",
92
- { [itowns.C3DTilesTypes.batchtable]:
93
- itowns.C3DTBatchTableHierarchyExtension });
94
-
95
- // Create a 3D Tiles layer from Cesium ion server with Cesium default access token and assetId of the
96
- // OSM buildings dataset.
97
- var threeDTilesIonSource = new itowns.C3DTilesIonSource({
98
- accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzOTkxZjY3NS0yNDU4LTQ3MTAtOGQ2NC1lOGI4YmY5ODhhYjQiLCJpZCI6Mzg4OTQsImlhdCI6MTYwNjkyMDkwOH0.aVrPA4xnpbSUlqfJ9RkSWmZtms_hnSRz7m596h1R7ew',
99
- assetId: 96188
100
- });
101
- threeDTilesIonSource.whenReady.then(displayAttributions); // Add attributions returned by cesium ion server
102
- var threeDTilesIonLayer = new itowns.C3DTilesLayer('3d-tiles-cesium-ion', {
103
- name: '3D Tiles from Cesium Ion',
104
- source: threeDTilesIonSource,
105
- registeredExtensions: extensions,
106
- }, view);
107
-
108
- itowns.View.prototype.addLayer.call(view, threeDTilesIonLayer);
109
-
110
- // Automatically convert cesium html attributions into html node elements and append them to the
111
- // attributions div
112
- function displayAttributions() {
113
- var attribDiv = document.getElementById('attribution');
114
- for (attrib of threeDTilesIonSource.attribution) {
115
- var attribElt = document.createElement('template');
116
- attribElt.innerHTML = attrib.html;
117
- attribDiv.appendChild(attribElt.content.firstChild);
118
- }
119
- }
120
-
121
- // ---------- ADD LIGHTS: ----------
122
- var ambLight = new itowns.THREE.AmbientLight(0xffffff, 1);
123
- view.scene.add( ambLight );
124
- </script>
125
- </body>
126
- </html>
@@ -1,95 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Itowns - Pointcloud classification</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="description">
14
- Pointcloud classification
15
- <ul>
16
- <li>Display your pointcloud</li>
17
- <li>Use classification to assign colour to each points</li>
18
- <li>Switch between mode on the left panel</li>
19
- </ul>
20
- </div>
21
- <div id="viewerDiv"></div>
22
- <script src="js/GUI/GuiTools.js"></script>
23
- <script src="../dist/itowns.js"></script>
24
- <script src="js/GUI/LoadingScreen.js"></script>
25
- <script src="../dist/debug.js"></script>
26
- <script src="js/3dTilesHelper.js"></script>
27
- <script type="text/javascript">
28
- /* global itowns,document,GuiTools*/
29
-
30
-
31
- var placement = {
32
- coord: new itowns.Coordinates('EPSG:4326', 3.695885, 43.397379, 0),
33
-
34
- range: 3000,
35
- tilt: 55,
36
- heading: 180
37
- }
38
- // iTowns namespace defined here
39
- var viewerDiv = document.getElementById('viewerDiv');
40
-
41
- var view = new itowns.GlobeView(viewerDiv, placement);
42
- view.camera3D.near = 5;
43
- setupLoadingScreen(viewerDiv, view);
44
-
45
- var menuGlobe = new GuiTools('menuDiv', view, 300);
46
-
47
- itowns.Fetcher.json('./layers/JSONLayers/OPENSM.json').then(function _(config) {
48
- config.source = new itowns.TMSSource(config.source);
49
- var layer = new itowns.ColorLayer('Ortho', config);
50
- view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
51
- });
52
- function updatePointCloudSize({tileContent}) {
53
- tileContent.traverse(function (obj) {
54
- if (obj.isPoints) {
55
- obj.material.size = 2.0;
56
- }
57
- });
58
- }
59
- // Create a new Layer 3d-tiles For Pointcloud
60
- // -------------------------------------------
61
- var $3dTilesSource = new itowns.C3DTilesSource({
62
- url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/pnts-sete-2021-0756_6256/tileset.json',
63
- });
64
- var $3dTilesLayerSetePC = new itowns.C3DTilesLayer('3d-tiles-sete', {
65
- name: 'SetePC',
66
- sseThreshold: 5,
67
- pntsMode: itowns.PNTS_MODE.CLASSIFICATION,
68
- pntsShape : itowns.PNTS_SHAPE.CIRCLE,
69
- source: $3dTilesSource,
70
- }, view);
71
-
72
- $3dTilesLayerSetePC.addEventListener(
73
- itowns.C3DTILES_LAYER_EVENTS.ON_TILE_CONTENT_LOADED,
74
- updatePointCloudSize,
75
- );
76
-
77
- itowns.View.prototype.addLayer.call(view, $3dTilesLayerSetePC);
78
- function switchMode(){
79
- let pntsLayer = view.getLayerById("3d-tiles-sete");
80
- if(pntsLayer){
81
- pntsLayer.pntsMode = pntsLayer.pntsMode === itowns.PNTS_MODE.COLOR ? itowns.PNTS_MODE.CLASSIFICATION : itowns.PNTS_MODE.COLOR;
82
- view.notifyChange(view.camera3D);
83
- }
84
- }
85
-
86
- // Add the UI Debug
87
- var d = new debug.Debug(view, menuGlobe.gui);
88
- $3dTilesLayerSetePC.whenReady
89
- .then(() => {
90
- debug.createTileDebugUI(menuGlobe.gui, view, view.tileLayer, d);
91
- debug.create3dTilesDebugUI(menuGlobe.gui, view, $3dTilesLayerSetePC);
92
- });
93
- </script>
94
- </body>
95
- </html>
@@ -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;