From 73d29e5414f7a2eb1f84b92adc4ea34eb5181b0b Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Tue, 12 Mar 2024 08:46:20 -0400 Subject: [PATCH] fix(types): remove reference to THREE.TextureEncoding (#1866) Another reference to TextureEncoding snuck in through https://github.com/pmndrs/drei/pull/1850. Since now there's more than one, I created a shared typed. --- src/core/Effects.tsx | 3 ++- src/core/useEnvironment.tsx | 7 ++----- src/helpers/deprecated.ts | 8 ++++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/Effects.tsx b/src/core/Effects.tsx index bc92f6865..f86bf69e4 100644 --- a/src/core/Effects.tsx +++ b/src/core/Effects.tsx @@ -1,8 +1,9 @@ import * as React from 'react' -import { RGBAFormat, HalfFloatType, WebGLRenderTarget, UnsignedByteType, TextureDataType, TextureEncoding } from 'three' +import { RGBAFormat, HalfFloatType, WebGLRenderTarget, UnsignedByteType, TextureDataType } from 'three' import { ReactThreeFiber, extend, useThree, useFrame } from '@react-three/fiber' import { EffectComposer, RenderPass, ShaderPass, GammaCorrectionShader } from 'three-stdlib' import { ForwardRefComponent } from '../helpers/ts-utils' +import { TextureEncoding } from '../helpers/deprecated' type Props = ReactThreeFiber.Node & { multisamping?: number diff --git a/src/core/useEnvironment.tsx b/src/core/useEnvironment.tsx index 3912e137f..6da57d590 100644 --- a/src/core/useEnvironment.tsx +++ b/src/core/useEnvironment.tsx @@ -9,20 +9,17 @@ import { } from 'three' import { RGBELoader, EXRLoader } from 'three-stdlib' import { presetsObj, PresetsType } from '../helpers/environment-assets' +import { LinearEncoding, sRGBEncoding, TextureEncoding } from '../helpers/deprecated' const CUBEMAP_ROOT = 'https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/' const isArray = (arr: any): arr is string[] => Array.isArray(arr) -const LinearEncoding = 3000 -const sRGBEncoding = 3001 - export type EnvironmentLoaderProps = { files?: string | string[] path?: string preset?: PresetsType extensions?: (loader: Loader) => void - // TextureEncoding was deprecated in r152, and removed in r162. - encoding?: typeof LinearEncoding | typeof sRGBEncoding + encoding?: TextureEncoding } export function useEnvironment({ diff --git a/src/helpers/deprecated.ts b/src/helpers/deprecated.ts index 87346cfac..a32c64a30 100644 --- a/src/helpers/deprecated.ts +++ b/src/helpers/deprecated.ts @@ -13,3 +13,11 @@ export const setUpdateRange = ( attribute.updateRange = updateRange } } + +export const LinearEncoding = 3000 +export const sRGBEncoding = 3001 + +/** + * TextureEncoding was deprecated in r152, and removed in r162. + */ +export type TextureEncoding = typeof LinearEncoding | typeof sRGBEncoding