From ad9af87afa5a2ada1b9f995cd8c0ebad90c07b2c Mon Sep 17 00:00:00 2001 From: Ib Green Date: Wed, 13 Mar 2024 12:28:23 -0400 Subject: [PATCH] chore(webgl): Avoid WEBGL_polygon_mode extension warning --- .../device-helpers/webgl-device-features.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/webgl/src/adapter/device-helpers/webgl-device-features.ts b/modules/webgl/src/adapter/device-helpers/webgl-device-features.ts index 48507ca77f..576f920705 100644 --- a/modules/webgl/src/adapter/device-helpers/webgl-device-features.ts +++ b/modules/webgl/src/adapter/device-helpers/webgl-device-features.ts @@ -61,12 +61,8 @@ export class WebGLDeviceFeatures extends DeviceFeatures { } *[Symbol.iterator](): IterableIterator { - for (const feature of Object.keys(WEBGL_FEATURES) as DeviceFeature[]) { - if (this.has(feature)) { - yield feature; - } - } - for (const feature of Object.keys(TEXTURE_FEATURES) as DeviceFeature[]) { + const features = this.getFeatures(); + for (const feature of features) { if (this.has(feature)) { yield feature; } @@ -98,15 +94,20 @@ export class WebGLDeviceFeatures extends DeviceFeatures { // FOR DEVICE initializeFeatures() { - // @ts-expect-error - // eslint-disable-next-line @typescript-eslint/no-unused-vars - for (const feature of this) { - // WebGL extensions are initialized by requesting them + // Initialize all features by checking them. + // Except WEBGL_polygon_mode since Chrome logs ugly console warnings + const features = this.getFeatures().filter(feature => feature !== 'polygon-mode-webgl'); + for (const feature of features) { + this.has(feature); } } // IMPLEMENTATION + getFeatures() { + return [...Object.keys(WEBGL_FEATURES), ...Object.keys(TEXTURE_FEATURES)] as DeviceFeature[]; + } + /** Extract all WebGL features */ protected getWebGLFeature(feature: DeviceFeature): boolean { const featureInfo = WEBGL_FEATURES[feature];