From a56415fa2655214d0ee68340ed109242764fe6f6 Mon Sep 17 00:00:00 2001 From: Bouillaguet Quentin Date: Mon, 11 Sep 2023 15:22:49 +0200 Subject: [PATCH] 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) {