From a881ac8aef8a0454d7eb1fdf2dabf660d8dd3380 Mon Sep 17 00:00:00 2001 From: Bouillaguet Quentin Date: Mon, 11 Sep 2023 15:02:51 +0200 Subject: [PATCH 1/2] docs(WebGL1): Remove tutorial "Getting Started - WebGL 1.0/2.0" --- docs/tutorials/list.json | 3 --- docs/tutorials/webgl.md | 32 -------------------------------- 2 files changed, 35 deletions(-) delete mode 100644 docs/tutorials/webgl.md diff --git a/docs/tutorials/list.json b/docs/tutorials/list.json index 8b05a0bcde..c76d891777 100644 --- a/docs/tutorials/list.json +++ b/docs/tutorials/list.json @@ -2,9 +2,6 @@ "Fundamentals": { "title": "Fundamentals" }, - "webgl": { - "title": "WebGL 1.0/2.0" - }, "Raster-data-Lambert93": { "title": "Lambert conformal conic" }, diff --git a/docs/tutorials/webgl.md b/docs/tutorials/webgl.md deleted file mode 100644 index 205f82512f..0000000000 --- a/docs/tutorials/webgl.md +++ /dev/null @@ -1,32 +0,0 @@ -**iTowns** supports **WebGL 2.0** and is enabled by default. -If you want instance instance with **WebGL 1.0** use option **`renderer: { isWebGL2: false }`** to instance the viewer. - -### Example to instance viewer in WebGL 2.0. -```js -// for GlobeView -const gView = new GlobeView(viewerDiv, placement); - -// for PlanarView -const pView = new PlanarView(viewerDiv, extent); - -// for View -const view = new View(crs, viewerDiv); - -// is version webgl 2.0 after instance? -const isWebGL2 = view.mainLoop.gfxEngine.renderer.capabilities.isWebGL2; // true -``` - -### Example to instance viewer in WebGL 1.0. -```js -// for GlobeView -const gView = new GlobeView(viewerDiv, placement, { renderer: { isWebGL2: false } }); - -// for PlanarView -const pView = new PlanarView(viewerDiv, extent, { renderer: { isWebGL2: false } }); - -// for View -const view = new View(crs, viewerDiv, { renderer: { isWebGL2: false } }); - -// is version webgl 1.0 after instance? -const isWebGL2 = view.mainLoop.gfxEngine.renderer.capabilities.isWebGL2; // false -``` \ No newline at end of file From a56415fa2655214d0ee68340ed109242764fe6f6 Mon Sep 17 00:00:00 2001 From: Bouillaguet Quentin Date: Mon, 11 Sep 2023 15:22:49 +0200 Subject: [PATCH 2/2] refactor(View): Deprecate WebGL 1.0 support --- src/Core/Deprecated/Undeprecator.js | 6 ++++++ src/Core/View.js | 6 ------ src/Renderer/c3DEngine.js | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Core/Deprecated/Undeprecator.js b/src/Core/Deprecated/Undeprecator.js index c69a3adcc1..8008b5e829 100644 --- a/src/Core/Deprecated/Undeprecator.js +++ b/src/Core/Deprecated/Undeprecator.js @@ -74,4 +74,10 @@ export const deprecatedFeature2MeshOptions = (options) => { } }; +export const deprecatedC3DEngineWebGLOptions = (options) => { + if (options.isWebGL2 === false) { + console.warn('WebGL1 support (isWebGL2=false) is deprecated and will be removed in iTowns 2.43. This follows its deprecation by three.js. If you are impacted by this change, please discuss in the following issue: https://github.com/iTowns/itowns/issues/2152.'); + } +}; + export default {}; diff --git a/src/Core/View.js b/src/Core/View.js index f10f53df2f..639fa670a0 100644 --- a/src/Core/View.js +++ b/src/Core/View.js @@ -131,11 +131,6 @@ class View extends THREE.EventDispatcher { * var view = itowns.View('EPSG:4326', viewerDiv, { camera: { type: itowns.CAMERA_TYPE.ORTHOGRAPHIC } }); * var customControls = itowns.THREE.OrbitControls(view.camera.camera3D, viewerDiv); * - * @example Enable WebGl 1.0 instead of WebGl 2.0. - * var viewerDiv = document.getElementById('viewerDiv'); - * const extent = new Extent('EPSG:3946', 1837816.94334, 1847692.32501, 5170036.4587, 5178412.82698); - * var view = new itowns.View('EPSG:4326', viewerDiv, { renderer: { isWebGL2: false } }); - * * @param {string} crs - The default CRS of Three.js coordinates. Should be a cartesian CRS. * @param {HTMLElement} viewerDiv - Where to instanciate the Three.js scene in the DOM * @param {Object=} options - Optional properties. @@ -145,7 +140,6 @@ class View extends THREE.EventDispatcher { * a default one will be constructed. In this case, if options.renderer is an object, it will be used to * configure the renderer (see {@link c3DEngine}. If not present, a new <canvas> will be created and * added to viewerDiv (mutually exclusive with mainLoop) - * @param {boolean} [options.renderer.isWebGL2=true] - enable webgl 2.0 for THREE.js. * @param {?Scene} [options.scene3D] - [THREE.Scene](https://threejs.org/docs/#api/en/scenes/Scene) instance to use, otherwise a default one will be constructed * @param {?Color} options.diffuse - [THREE.Color](https://threejs.org/docs/?q=color#api/en/math/Color) Diffuse color terrain material. * This color is applied to terrain if there isn't color layer on terrain extent (by example on pole). diff --git a/src/Renderer/c3DEngine.js b/src/Renderer/c3DEngine.js index 669a0cc1ad..cb1faf5904 100644 --- a/src/Renderer/c3DEngine.js +++ b/src/Renderer/c3DEngine.js @@ -9,10 +9,13 @@ import Capabilities from 'Core/System/Capabilities'; import { unpack1K } from 'Renderer/LayeredMaterial'; import WEBGL from 'ThreeExtended/capabilities/WebGL'; import Label2DRenderer from 'Renderer/Label2DRenderer'; +import { deprecatedC3DEngineWebGLOptions } from 'Core/Deprecated/Undeprecator'; const depthRGBA = new THREE.Vector4(); class c3DEngine { constructor(rendererOrDiv, options = {}) { + deprecatedC3DEngineWebGLOptions(options); + const NOIE = !Capabilities.isInternetExplorer(); // pick sensible default options if (options.antialias === undefined) {