diff --git a/examples/3dtiles_25d.html b/examples/3dtiles_25d.html
deleted file mode 100644
index 41cc65ad15..0000000000
--- a/examples/3dtiles_25d.html
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
- Itowns - 3D Tiles on 2.5D map example
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/3dtiles_basic.html b/examples/3dtiles_basic.html
deleted file mode 100644
index 9db050b8a3..0000000000
--- a/examples/3dtiles_basic.html
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
- Itowns - 3d-tiles example
-
-
-
-
-
-
-
-
-
-
-
Feature Information:
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/3dtiles_batch_table.html b/examples/3dtiles_batch_table.html
deleted file mode 100644
index 4471f98eb4..0000000000
--- a/examples/3dtiles_batch_table.html
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
- Itowns - 3d-tiles hierarchy example
-
-
-
-
-
-
-
-
-
-
-
Feature Information:
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/3dtiles_ion.html b/examples/3dtiles_ion.html
deleted file mode 100644
index 3ef10b4227..0000000000
--- a/examples/3dtiles_ion.html
+++ /dev/null
@@ -1,126 +0,0 @@
-
-
-
- Itowns - 3d-tiles from Cesium ion example
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
This example displays a dataset representing extruded OSM buildings from Cesium ion
- with Cesium default access token. Zoom to any place in the world to see the buildings.
- Buildings may appear to "fly" above the ground in some places, this is due to the combination
- of precision errors of this dataset and of the 3D terrain we use in this example.
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/3dtiles_loader.html b/examples/3dtiles_loader.html
index 3d701f7f60..66ac75c62f 100644
--- a/examples/3dtiles_loader.html
+++ b/examples/3dtiles_loader.html
@@ -11,7 +11,15 @@
@@ -21,12 +29,17 @@
Specify the URL of a tileset to load:
-
- Load
-
+
Load
+
+
Load Lyon 1 (Mesh)
+
Load Sete (Point Cloud)
+
Load Lille (Mesh)
+
+
+
Display feature information by clicking on it
Feature Information:
-
+
@@ -52,28 +65,17 @@
const {
TMSSource, WMTSSource, OGC3DTilesSource,
- ColorLayer, ElevationLayer, OGC3DTilesLayer,
+ ColorLayer, ElevationLayer, OGC3DTilesLayer, PNTS_SIZE_MODE,
GlobeView, Coordinates, Fetcher,
} = itowns;
- const uri = new URL(location);
- const state = {
- // URL to tileset JSON
- tileset: uri.searchParams.get('tileset'),
- // Cesium ION /
- assetId: uri.searchParams.get('assetId'),
- };
-
- function setURL(url) {
- if (!url) return;
+ window.layer = null; // 3D Tiles layer
- uri.searchParams.set('tileset', url);
- history.pushState(null, '', `?${uri.searchParams.toString()}`);
+ const uri = new URL(location);
- location.reload();
- }
+ window.gui = new dat.GUI();
- // ---- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION ----
+ // ---- Create a GlobeView ----
// Define camera initial position
const placement = {
@@ -85,7 +87,17 @@
const viewerDiv = document.getElementById('viewerDiv');
// Create a GlobeView
- const view = new GlobeView(viewerDiv, placement, {});
+ const view = new GlobeView(viewerDiv, placement, {
+ controls: {
+ minDistance: 100,
+ }
+ });
+
+ // Enable various compression support for 3D Tiles tileset:
+ // - `KHR_draco_mesh_compression` mesh compression extension
+ // - `KHR_texture_basisu` texture compresion extension
+ itowns.enableDracoLoader('./libs/draco/');
+ itowns.enableKtx2Loader('./lib/basis/', view.renderer);
// Add ambient light to globally illuminates all objects
const light = new AmbientLight(0x404040, 15);
@@ -94,36 +106,68 @@
// Setup loading screen
setupLoadingScreen(viewerDiv, view);
- // Setup debug menu
- const menuGlobe = new GuiTools('menuDiv', view, 300);
- debug.createTileDebugUI(menuGlobe.gui, view, view.tileLayer);
-
-
- // ---- ADD A BASEMAP ----
+ // ---- Add a basemap ----
// Add one imagery layer to the scene. This layer's properties are
// defined in a json file, but it cou ld be defined as a plain js
// object. See `Layer` documentation for more info.
Fetcher.json('./layers/JSONLayers/OPENSM.json').then((config) => {
- const layer = new ColorLayer('Ortho', {
+ const colorLayer = new ColorLayer('Ortho', {
...config,
source: new TMSSource(config.source),
});
- view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
+ view.addLayer(colorLayer);
});
- // ---- ADD 3D TILES TILESET ----
+ // ---- Add 3D terrain ----
- // Enable various compression support for 3D Tiles tileset:
- // - `KHR_draco_mesh_compression` mesh compression extension
- // - `KHR_texture_basisu` texture compresion extension
- itowns.enableDracoLoader('./libs/draco/');
- itowns.enableKtx2Loader('./lib/basis/', view.renderer);
+ // Add two elevation layers: world terrain and a more precise terrain for france
+ // These will deform iTowns globe geometry to represent terrain elevation.
+ function addElevationLayerFromConfig(config) {
+ config.source = new itowns.WMTSSource(config.source);
+ var elevationLayer = new itowns.ElevationLayer(config.id, config);
+ view.addLayer(elevationLayer);
+ }
+ itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig);
+ itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig);
+
+ // ---------- 3D Tiles loading
+
+ function readURL() {
+ const url = document.getElementById('url').value;
+
+ if (url) {
+ setUrl(url);
+ }
+ }
+
+ function setUrl(url) {
+ if (!url) return;
+
+ const input_url = document.getElementById('url');
+ if (!input_url) return;
+
+ uri.searchParams.set('copc', url);
+ history.replaceState(null, null, `?${uri.searchParams.toString()}`);
+
+ input_url.value = url;
+ load(url);
+ }
+
+
+ function load(url) {
+ const source = new OGC3DTilesSource({ url });
- if (state.tileset) {
- const source = new OGC3DTilesSource({ url: state.tileset });
- const layer = new OGC3DTilesLayer('3DTiles', {
+ if (window.layer) {
+ gui.removeFolder('Layer 3DTiles');
+ view.removeLayer('3DTiles');
+ view.notifyChange();
+ window.layer.delete();
+ }
+
+ window.layer = new OGC3DTilesLayer('3DTiles', {
source,
+ pntsSizeMode: PNTS_SIZE_MODE.ATTENUATED,
});
// Add an event for picking the 3D Tiles layer and displaying
@@ -131,20 +175,37 @@
const pickingArgs = {
htmlDiv: document.getElementById('featureInfo'),
view,
- layer,
+ layer: window.layer,
};
// Add the layer to our view
- view.addLayer(layer).then((layer) => {
+ view.addLayer(window.layer).then((layer) => {
zoomToLayer(view, layer);
window.addEventListener('click',
(event) => fillHTMLWithPickingInfo(event, pickingArgs), false);
});
- debug.createOGC3DTilesDebugUI(menuGlobe.gui, view, layer);
+ window.layer.whenReady
+ .then(() => debug.createOGC3DTilesDebugUI(gui, view, window.layer));
+ }
+
+ function loadLyon() {
+ setUrl("https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/refs/heads/master/3DTiles/lyon1-4978/tileset.json");
+ }
+
+ function loadSete() {
+ setUrl("https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/pnts-sete-2021-0756_6256/tileset.json");
}
- window.setURL = setURL;
+ function loadLille() {
+ setUrl("https://webimaging.lillemetropole.fr/externe/maillage/2020_mel_5cm/tileset.json");
+ }
+
+ window.readURL = readURL;
+ window.loadLyon = loadLyon;
+ window.loadSete = loadSete;
+ window.loadLille = loadLille;
+