Skip to content

Commit

Permalink
fix(types): remove reference to THREE.TextureEncoding (#1866)
Browse files Browse the repository at this point in the history
Another reference to TextureEncoding snuck in through #1850. Since now there's more than one, I created a shared typed.
  • Loading branch information
Methuselah96 authored Mar 12, 2024
1 parent 73830fe commit 73d29e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/core/Effects.tsx
Original file line number Diff line number Diff line change
@@ -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<EffectComposer, typeof EffectComposer> & {
multisamping?: number
Expand Down
7 changes: 2 additions & 5 deletions src/core/useEnvironment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
8 changes: 8 additions & 0 deletions src/helpers/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 73d29e5

Please sign in to comment.