Skip to content

Commit d9164b8

Browse files
fix(types): remove use of ambient three (#321)
1 parent eb0d5fb commit d9164b8

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

src/EffectComposer.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { TextureDataType } from 'three'
1+
import type { Camera, Scene, TextureDataType } from 'three'
22
import { HalfFloatType, NoToneMapping } from 'three'
33
import React, {
44
forwardRef,
@@ -27,8 +27,8 @@ export const EffectComposerContext = createContext<{
2727
composer: EffectComposerImpl
2828
normalPass: NormalPass | null
2929
downSamplingPass: DepthDownsamplingPass | null
30-
camera: THREE.Camera
31-
scene: THREE.Scene
30+
camera: Camera
31+
scene: Scene
3232
resolutionScale?: number
3333
}>(null!)
3434

@@ -44,8 +44,8 @@ export type EffectComposerProps = {
4444
multisampling?: number
4545
frameBufferType?: TextureDataType
4646
renderPriority?: number
47-
camera?: THREE.Camera
48-
scene?: THREE.Scene
47+
camera?: Camera
48+
scene?: Scene
4949
}
5050

5151
const isConvolution = (effect: Effect): boolean =>

src/effects/ASCII.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ASCIIEffect extends Effect {
8282
}
8383

8484
/** Draws the characters on a Canvas and returns a texture */
85-
public createCharactersTexture(characters: string, font: string, fontSize: number): THREE.Texture {
85+
public createCharactersTexture(characters: string, font: string, fontSize: number): Texture {
8686
const canvas = document.createElement('canvas')
8787
const SIZE = 1024
8888
const MAX_PER_ROW = 16

src/effects/SelectiveBloom.tsx

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,35 @@ export const SelectiveBloom = forwardRef(function SelectiveBloom(
4646

4747
const invalidate = useThree((state) => state.invalidate)
4848
const { scene, camera } = useContext(EffectComposerContext)
49-
const effect = useMemo(
50-
() => {
51-
const effect = new SelectiveBloomEffect(scene, camera, {
52-
blendFunction: BlendFunction.ADD,
53-
luminanceThreshold,
54-
luminanceSmoothing,
55-
intensity,
56-
width,
57-
height,
58-
kernelSize,
59-
mipmapBlur,
60-
...props,
61-
});
62-
effect.inverted = inverted;
63-
effect.ignoreBackground = ignoreBackground;
64-
return effect;
65-
},
66-
[scene, camera, luminanceThreshold, luminanceSmoothing, intensity, width, height, kernelSize, mipmapBlur, inverted, ignoreBackground, props]
67-
)
49+
const effect = useMemo(() => {
50+
const effect = new SelectiveBloomEffect(scene, camera, {
51+
blendFunction: BlendFunction.ADD,
52+
luminanceThreshold,
53+
luminanceSmoothing,
54+
intensity,
55+
width,
56+
height,
57+
kernelSize,
58+
mipmapBlur,
59+
...props,
60+
})
61+
effect.inverted = inverted
62+
effect.ignoreBackground = ignoreBackground
63+
return effect
64+
}, [
65+
scene,
66+
camera,
67+
luminanceThreshold,
68+
luminanceSmoothing,
69+
intensity,
70+
width,
71+
height,
72+
kernelSize,
73+
mipmapBlur,
74+
inverted,
75+
ignoreBackground,
76+
props,
77+
])
6878

6979
const api = useContext(selectionContext)
7080

0 commit comments

Comments
 (0)