From 86dc909219d41a3dfa4bec16aa930e07e09f5a31 Mon Sep 17 00:00:00 2001 From: Martin Schuhfuss Date: Fri, 26 Apr 2024 22:30:49 +0200 Subject: [PATCH] fix: stop importing sRGBEncoding constant (#1037) * fix: stop importing sRGBEncoding constant Since r162, three.js no longer exports the formerly deprecated sRGBEncoding constant. This replaces the import with the literal value to keep compatibility with older three.js versions until we release a new major version. fixes #1036 * fix: typescript fixes for compat-code --- src/three.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/three.ts b/src/three.ts index bd18194e..0acc2147 100644 --- a/src/three.ts +++ b/src/three.ts @@ -29,7 +29,6 @@ import { RaycasterParameters, REVISION, Scene, - sRGBEncoding, Vector2, Vector3, WebGLRenderer, @@ -38,6 +37,11 @@ import { latLngToVector3Relative, toLatLngAltitudeLiteral } from "./util"; import type { LatLngTypes } from "./util"; +// Since r162, the sRGBEncoding constant is no longer exported from three. +// The value is kept here to keep compatibility with older three.js versions. +// This will be removed with the next major release. +const sRGBEncoding = 3001; + const DEFAULT_UP = new Vector3(0, 0, 1); export interface RaycastOptions { @@ -394,7 +398,10 @@ export class ThreeJSOverlayView implements google.maps.WebGLOverlayView { // Since r152, default outputColorSpace is SRGB // Deprecated outputEncoding kept for backwards compatibility - if (Number(REVISION) < 152) this.renderer.outputEncoding = sRGBEncoding; + if (Number(REVISION) < 152) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this.renderer as any).outputEncoding = sRGBEncoding; + } const { width, height } = gl.canvas; this.renderer.setViewport(0, 0, width, height);