Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
40fb74b
fix(sunLightLayer): new shadow box size computation
airnez Jun 8, 2026
06023c4
fix(debug): remove references to old atmosphere
airnez Jun 8, 2026
0b00f7a
fix(tilemesh): matte material for 3d tiles meshes
airnez Jun 8, 2026
6eb1d82
fix(3dtilesloader): notify camera update for date widget
airnez Jun 8, 2026
aeecdcf
refactor(skymanager): skycontroller and simplesky
airnez Jun 8, 2026
a11184d
feat(sunlightlayer): forceDaytime, shadows and sunlight cutoff
airnez Jun 8, 2026
b60a6ab
fix(debug): make debug camera run without sky effects
airnez Jun 8, 2026
ca58567
fix(skycontroller): use the right parameter interface
airnez Jun 9, 2026
5c9b3e2
doc(realisticsky): fix typo
airnez Jun 9, 2026
6ad2146
fix(realisticsky): tune aerial perspective
airnez Jun 9, 2026
062fb6b
chore(linting): fix linting
airnez Jun 9, 2026
79c957f
fix(example): do not init realistic lighting by default
airnez Jun 9, 2026
cc7df3a
fix(example): remove buggy layer visibility code
airnez Jun 16, 2026
489684d
fix(skyController): move clipping update from sky to view
airnez Jun 17, 2026
30e9a04
fix(example): disable realistic lighting by default
airnez Jun 18, 2026
337cbdf
fix(example): smaller sse by default
airnez Jul 2, 2026
b641ba0
fix(example): disable realistic lighting by default for 3d tiles viewer
airnez Jul 2, 2026
3108941
feat(sunlight): add an ambient light when sunlight is disabled
airnez Jul 2, 2026
34ed4b9
feat(example): uniform realistic lighting ui
airnez Jul 2, 2026
18f0de9
fix(example): declare crl
airnez Jul 7, 2026
0c8bff4
fix(example): use crl hide for folder
airnez Jul 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions examples/3dtiles_loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
const isEmbedded = window.self !== window.top;

window.gui = new dat.GUI();


// ---- Create a GlobeView ----

Expand All @@ -96,7 +96,6 @@

// Create a GlobeView
const view = new GlobeView(viewerDiv, placement, {
realisticLighting: true,
shadows: true,
controls: {
minDistance: 100,
Expand Down Expand Up @@ -179,6 +178,7 @@
window.layer = new OGC3DTilesLayer('3DTiles', {
source,
pntsSizeMode: PNTS_SIZE_MODE.ATTENUATED,
sseThreshold: 2,
});

// Add an event for picking the 3D Tiles layer and displaying
Expand All @@ -200,25 +200,8 @@
.then(() => debug.createOGC3DTilesDebugUI(gui, view, window.layer));
}

// ---------- DATE/TIME CONTROLS ----------

// Add date/time controls to adjust sun position
const dateFolder = gui.addFolder('Date/Time');
const date = view.date;
dateFolder.add(
{ month: 1 + date.getMonth() }, 'month', 1, 12, 1
).onChange((v) => {
date.setMonth(v - 1);
view.notifyChange(view.sunLightLayer);
}).name('month (1-12)');
dateFolder.add(
{ hour: date.getHours() }, 'hour', 0, 24, 0.1
).onChange((v) => {
const hours = Math.floor(v);
const minutes = (v - hours) * 60;
date.setHours(hours, minutes);
view.notifyChange(view.sunLightLayer);
}).name('hour (24h)');
// ---------- Realistic lighting & DATE/TIME CONTROLS ----------
debug.createRealisticLightingDebugUI(gui,view);

function loadLyon() {
setUrl("https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/refs/heads/master/3DTiles/lyon1-4978/tileset.json");
Expand All @@ -232,9 +215,6 @@
setUrl("https://webimaging.lillemetropole.fr/externe/maillage/2020_mel_5cm/tileset.json");
}




const readUrlButton = document.getElementById('readURLButton');

const loadLyonButton = document.getElementById('loadLyonButton');
Expand Down
6 changes: 2 additions & 4 deletions examples/demo/src/Views/ImmersiveView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ class ImmersiveView extends View {
// @ts-expect-error camera3D updateProjectionMatrix method undefined
this.view.camera3D.updateProjectionMatrix();

const view = this.view as itowns.GlobeView & { skyManager: { enabled: boolean } };
if (view.skyManager && view.skyManager.enabled) {
view.skyManager.enabled = false;
}
const view = this.view as itowns.GlobeView & { realisticLighting: boolean };
view.realisticLighting = false;

setupLoadingScreen(this.viewerDiv, view);

Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/Views/View3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class View3D extends View {
const view = this.view as itowns.GlobeView;

this.atmosphereFrameRequester = () => {
if (view.skyManager) {
view.skyManager.enabled =
if (view.skyController) {
view.realisticLighting =
view.getDistanceFromCamera() > Config.ATMOSPHERE_THRESHOLD;
}
};
Expand Down
34 changes: 20 additions & 14 deletions examples/mars.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
import * as THREE from 'three';
import * as itowns from 'itowns';
import * as debug from 'debug';

const marsRealisticParams = {
rayleighScattering: new THREE.Vector3(0.00199, 0.00092, 0.00045),
mieScattering: new THREE.Vector3(0.003, 0.002, 0.0015),
mieExtinction: new THREE.Vector3(0.0033, 0.0022, 0.00165),
miePhaseFunctionG: 0.7,
};

const marsSimpleParams = {
skyAltitude: 100000, // Closer to ground
skyColor: 0xd99b75, // Orange sky
fogColor: 0xd6ad9a, // Beige fog
}

import * as itowns_widgets from 'itowns_widgets';
// # Simple Globe viewer
// Define initial camera position
Expand All @@ -51,18 +65,13 @@

// Instanciate iTowns GlobeView*
var view = new itowns.GlobeView(viewerDiv, placement, {
atmosphere: {
Kr: 0.0025,
Km: 0.0015,
ESun: 15.0,
g: -0.950,
innerRadius: 6400000,
outerRadius: 6600000,
wavelength: [0.350, 0.470, 0.575],
scaleDepth: 0.38,
},
realisticSky: marsRealisticParams,
simpleSky: marsSimpleParams,
realisticLighting: true,
farFactor: 0.6, // Less aggressive horizon scaling for this ellipsoid-based demo
});

view.skyController.realisticSky.sky.material.moon = false;
setupLoadingScreen(viewerDiv, view);

// Add a tms imagery source
Expand Down Expand Up @@ -97,10 +106,7 @@

var menuGlobe = new GuiTools('menuDiv', view);

const cRL = menuGlobe.addGUI('RealisticLighting', true, function (v) {
view.skyManager.enabled = v;
});

debug.createRealisticLightingDebugUI(menuGlobe.gui, view);
debug.createTileDebugUI(menuGlobe.gui, view);
window.view = view;
window.itowns = itowns;
Expand Down
1 change: 0 additions & 1 deletion examples/plugins_pyramidal_tiff.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
var layer = new itowns.ElevationLayer(config.id, config);
view.addLayer(layer).then(function _(layer) {
layer.scale = 10000;
view.tileLayer.attachedLayers[0].visible = false;
menuGlobe.addLayerGUI(layer);
menuGlobe.elevationGui.open();
menuGlobe.elevationGui.__folders.GEOIDMNT.open();
Expand Down
17 changes: 2 additions & 15 deletions examples/view_3d_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

// Create a GlobeView
const view = new itowns.GlobeView(viewerDiv, placement, {
realisticLighting: true,
realisticLighting: false,
});

// Setup loading screen and debug menu
Expand Down Expand Up @@ -142,21 +142,8 @@
position: 'top-right',
});



// ---------- DISPLAY ATMOSPHERIC LIGHTING : ----------

view.skyManager.enabled = !view.isDebugMode;



// ---------- DEBUG TOOLS : ----------

// Toggle atmospheric lighting on/off.
const cRL = debugMenu.addGUI('RealisticLighting', !view.isDebugMode, function (v) {
view.skyManager.enabled = v;
});

const cRL = debug.createRealisticLightingDebugUI(debugMenu.gui, view);
debug.createTileDebugUI(debugMenu.gui, view);

window.view = view;
Expand Down
6 changes: 2 additions & 4 deletions examples/view_3d_mns_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,14 @@

// ---------- DISPLAY ATMOSPHERIC LIGHTING : ----------

view.skyManager.enabled = !view.isDebugMode;
view.realisticLighting = !view.isDebugMode;



// ---------- DEBUG TOOLS : ----------

// Toggle atmospheric lighting on/off.
const cRL = debugMenu.addGUI('RealisticLighting', !view.isDebugMode, function (v) {
view.skyManager.enabled = v;
});
debug.createRealisticLightingDebugUI(debugMenu.gui, view);

debug.createTileDebugUI(debugMenu.gui, view);

Expand Down
42 changes: 15 additions & 27 deletions packages/Debug/src/Debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ function Debug(view, datDebugTool, chartDivContainer) {
debugCamera.updateProjectionMatrix();
const g = view.mainLoop.gfxEngine;
const r = g.renderer;
let fogDistance = 10e10;
const layerAtmosphere = view.getLayerById('atmosphere');
if (layerAtmosphere) {
fogDistance = layerAtmosphere.fog.distance;
}
helper.visible = false;
view.scene.add(helper);

Expand All @@ -162,12 +157,6 @@ function Debug(view, datDebugTool, chartDivContainer) {
view.scene.add(displayedTilesObb);
view.scene.add(displayedTilesObbHelper);

function updateFogDistance(obj) {
if (obj.material && fogDistance) {
obj.material.setUniform('fogDistance', fogDistance);
}
}

const clearColor = new Color();
const lookAtCameraDebug = new Vector3();
function renderCameraDebug() {
Expand Down Expand Up @@ -206,14 +195,11 @@ function Debug(view, datDebugTool, chartDivContainer) {

helper.update();

const distToTarget = debugCamera.position.distanceTo(lookAtCameraDebug);
debugCamera.near = distToTarget * 0.01;
debugCamera.far = distToTarget * 100;

debugCamera.updateProjectionMatrix();
if (layerAtmosphere) {
layerAtmosphere.object3d.visible = false;
fogDistance = 10e10;
for (const obj of tileLayer.level0Nodes) {
obj.traverseVisible(updateFogDistance);
}
}

const deltaY = state.displayCharts ? Math.round(parseFloat(chartDivContainer.style.height.replace('%', '')) * g.height / 100) + 3 : 0;
helper.visible = true;
Expand All @@ -224,22 +210,24 @@ function Debug(view, datDebugTool, chartDivContainer) {
r.setScissorTest(true);
r.setClearColor(backgroundChartDiv);
r.clear();

const skyEnabled = view.skyController && view.skyController.enabled;
if (skyEnabled) {
view.skyController.enabled = false;
}

r.render(view.scene, debugCamera);

if (skyEnabled) {
view.skyController.enabled = true;
}

r.setScissorTest(false);
r.setClearColor(clearColor);
r.setViewport(0, 0, g.width, g.height);

helper.visible = false;
displayedTilesObbHelper.visible = false;
if (layerAtmosphere) {
layerAtmosphere.object3d.visible = true;
}
if (layerAtmosphere) {
fogDistance = layerAtmosphere.fog.distance;
for (const obj of tileLayer.level0Nodes) {
obj.traverseVisible(updateFogDistance);
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/Debug/src/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export { default as PointCloudDebug } from 'PointCloudDebug';
export { default as createTileDebugUI } from 'TileDebug';
export { default as create3dTilesDebugUI } from '3dTilesDebug';
export { default as createOGC3DTilesDebugUI } from 'OGC3DTilesDebug';
export { createRealisticLightingDebugUI, createDateTimeUI } from 'RealisticLightingDebug';
export { default as GeometryDebug } from 'GeometryDebug';
export { default as GuiTools } from 'GuiTools';
49 changes: 49 additions & 0 deletions packages/Debug/src/RealisticLightingDebug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export function createRealisticLightingDebugUI(gui, view) {
if (view.realisticLighting === undefined) {
console.error('Failed to create realistic lighting debug UI. The view does not expose realisticLighting');
return;
}
if (view.skyController === undefined) {
console.error('Failed to create debug UI. The view does not expose skyController');
return;
}
const realisticLightingFolder = gui.addFolder('Realistic lighting');
const realisticLightingProperty = realisticLightingFolder.add(view, 'realisticLighting');
const forceDayTimeProperty = realisticLightingFolder.add(view.skyController, 'forceDaytime');
const dateTimeFolder = createDateTimeUI(realisticLightingFolder, view);

function toggleDateTimeFolder() {
if (!view.realisticLighting || view.skyController.forceDaytime) {
dateTimeFolder.hide();
} else {
dateTimeFolder.show();
dateTimeFolder.open();
}
}

toggleDateTimeFolder();
forceDayTimeProperty.onChange(() => toggleDateTimeFolder());
realisticLightingProperty.onChange(() => toggleDateTimeFolder());
return realisticLightingFolder;
}

export function createDateTimeUI(gui, view) {
const date = view.date;
const dateTimeFolder = gui.addFolder('Date/Time');
dateTimeFolder.add(
{ month: 1 + date.getMonth() }, 'month', 1, 12, 1,
).onChange((v) => {
date.setMonth(v - 1);
view.notifyChange(view.camera3D);
}).name('month (1-12)');

dateTimeFolder.add(
{ hour: date.getHours() }, 'hour', 0, 24, 0.1,
).onChange((v) => {
const hours = Math.floor(v);
const minutes = (v - hours) * 60;
date.setHours(hours, minutes);
view.notifyChange(view.camera3D);
}).name('hour (24h)');
return dateTimeFolder;
}
Loading
Loading