Skip to content

Commit

Permalink
fix: stop importing sRGBEncoding constant (#1037)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
usefulthink authored Apr 26, 2024
1 parent d6d8601 commit 86dc909
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/three.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
RaycasterParameters,
REVISION,
Scene,
sRGBEncoding,
Vector2,
Vector3,
WebGLRenderer,
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 86dc909

Please sign in to comment.