-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from CodyJasonBennett/fix/chromatic-offset
fix(ChromaticAbberation): offset prop
- Loading branch information
Showing
1 changed file
with
3 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,5 @@ | ||
import React, { Ref, forwardRef, useMemo } from 'react' | ||
import { ChromaticAberrationEffect } from 'postprocessing' | ||
import { ReactThreeFiber } from '@react-three/fiber' | ||
import { useVector2 } from '../util' | ||
import { type EffectProps, wrapEffect } from '../util' | ||
|
||
// type for function args should use constructor args | ||
export type ChromaticAberrationProps = ConstructorParameters<typeof ChromaticAberrationEffect>[0] & | ||
Partial<{ | ||
offset: ReactThreeFiber.Vector2 | ||
}> | ||
|
||
export const ChromaticAberration = forwardRef(function ChromaticAberration( | ||
props: ChromaticAberrationProps, | ||
ref: Ref<ChromaticAberrationEffect> | ||
) { | ||
const offset = useVector2(props, 'offset') | ||
const effect = useMemo(() => new ChromaticAberrationEffect({ ...props, offset }), [offset, props]) | ||
return <primitive ref={ref} object={effect} dispose={null} /> | ||
}) | ||
export type ChromaticAberrationProps = EffectProps<typeof ChromaticAberrationEffect> | ||
export const ChromaticAberration = wrapEffect(ChromaticAberrationEffect) |