Skip to content

Commit

Permalink
fix(types): remove use of ambient three (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Jan 23, 2025
1 parent eb0d5fb commit d9164b8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/EffectComposer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TextureDataType } from 'three'
import type { Camera, Scene, TextureDataType } from 'three'
import { HalfFloatType, NoToneMapping } from 'three'
import React, {
forwardRef,
Expand Down Expand Up @@ -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!)

Expand All @@ -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 =>
Expand Down
2 changes: 1 addition & 1 deletion src/effects/ASCII.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 29 additions & 19 deletions src/effects/SelectiveBloom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit d9164b8

Please sign in to comment.