From d9164b861ced661c48b05f82cd89ac73e174ca91 Mon Sep 17 00:00:00 2001 From: Cody Bennett Date: Wed, 22 Jan 2025 23:36:34 -0600 Subject: [PATCH] fix(types): remove use of ambient three (#321) --- src/EffectComposer.tsx | 10 +++---- src/effects/ASCII.tsx | 2 +- src/effects/SelectiveBloom.tsx | 48 ++++++++++++++++++++-------------- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/EffectComposer.tsx b/src/EffectComposer.tsx index d3011a5..256419d 100644 --- a/src/EffectComposer.tsx +++ b/src/EffectComposer.tsx @@ -1,4 +1,4 @@ -import type { TextureDataType } from 'three' +import type { Camera, Scene, TextureDataType } from 'three' import { HalfFloatType, NoToneMapping } from 'three' import React, { forwardRef, @@ -27,8 +27,8 @@ export const EffectComposerContext = createContext<{ composer: EffectComposerImpl normalPass: NormalPass | null downSamplingPass: DepthDownsamplingPass | null - camera: THREE.Camera - scene: THREE.Scene + camera: Camera + scene: Scene resolutionScale?: number }>(null!) @@ -44,8 +44,8 @@ export type EffectComposerProps = { multisampling?: number frameBufferType?: TextureDataType renderPriority?: number - camera?: THREE.Camera - scene?: THREE.Scene + camera?: Camera + scene?: Scene } const isConvolution = (effect: Effect): boolean => diff --git a/src/effects/ASCII.tsx b/src/effects/ASCII.tsx index 6eec07d..4da1059 100644 --- a/src/effects/ASCII.tsx +++ b/src/effects/ASCII.tsx @@ -82,7 +82,7 @@ class ASCIIEffect extends Effect { } /** Draws the characters on a Canvas and returns a texture */ - public createCharactersTexture(characters: string, font: string, fontSize: number): THREE.Texture { + public createCharactersTexture(characters: string, font: string, fontSize: number): Texture { const canvas = document.createElement('canvas') const SIZE = 1024 const MAX_PER_ROW = 16 diff --git a/src/effects/SelectiveBloom.tsx b/src/effects/SelectiveBloom.tsx index 0e75505..03ea8e3 100644 --- a/src/effects/SelectiveBloom.tsx +++ b/src/effects/SelectiveBloom.tsx @@ -46,25 +46,35 @@ export const SelectiveBloom = forwardRef(function SelectiveBloom( const invalidate = useThree((state) => state.invalidate) const { scene, camera } = useContext(EffectComposerContext) - const effect = useMemo( - () => { - const effect = new SelectiveBloomEffect(scene, camera, { - blendFunction: BlendFunction.ADD, - luminanceThreshold, - luminanceSmoothing, - intensity, - width, - height, - kernelSize, - mipmapBlur, - ...props, - }); - effect.inverted = inverted; - effect.ignoreBackground = ignoreBackground; - return effect; - }, - [scene, camera, luminanceThreshold, luminanceSmoothing, intensity, width, height, kernelSize, mipmapBlur, inverted, ignoreBackground, props] - ) + const effect = useMemo(() => { + const effect = new SelectiveBloomEffect(scene, camera, { + blendFunction: BlendFunction.ADD, + luminanceThreshold, + luminanceSmoothing, + intensity, + width, + height, + kernelSize, + mipmapBlur, + ...props, + }) + effect.inverted = inverted + effect.ignoreBackground = ignoreBackground + return effect + }, [ + scene, + camera, + luminanceThreshold, + luminanceSmoothing, + intensity, + width, + height, + kernelSize, + mipmapBlur, + inverted, + ignoreBackground, + props, + ]) const api = useContext(selectionContext)