You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { useRef } from "react";
import * as THREE from "three";
import { useFrame } from "@react-three/fiber";
import {
Bloom,
EffectComposer,
N8AO,
TiltShift2,
ChromaticAberration,
} from "@react-three/postprocessing";
import { ChromaticAberrationEffect, BlendFunction } from "postprocessing";
import { easing } from "maath";
export default function Effects() {
const chromaRef = useRef<ChromaticAberrationEffect>(null);
useFrame((state, delta) => {
easing.damp3(
state.camera.position,
[
Math.sin(-state.pointer.x) * 5,
state.pointer.y * 2,
0.5 + Math.cos(state.pointer.x) * 5,
],
0.1,
delta,
);
state.camera.lookAt(0, 0, 0);
if (!chromaRef.current) return;
const x = Math.sin(-state.pointer.x) / 100;
const y = state.pointer.y / 100;
const newOffset = new THREE.Vector2(x, y);
chromaRef.current.offset = newOffset;
});
return (
<EffectComposer enableNormalPass={true}>
<ChromaticAberration
ref={chromaRef}
blendFunction={BlendFunction.NORMAL}
offset={new THREE.Vector2(0.01, 0.01)}
radialModulation={false}
modulationOffset={1.0}
/>
<Bloom mipmapBlur luminanceThreshold={0.8} intensity={2} levels={8} />
<TiltShift2 blur={0.2} />
</EffectComposer>
);
}
I'm trying to animate the chromatic aberration offset.
However, I get the following error:
Type 'RefObject<ChromaticAberrationEffect>' is not assignable to type 'RefObject<typeof ChromaticAberrationEffect>'.
Property 'prototype' is missing in type 'ChromaticAberrationEffect' but required in type 'typeof ChromaticAberrationEffect'.
I believe this is because the type is exported as typeof ChromaticAberrationEffect in react-three/postprocessing
instead of just ChromaticAberrationEffect
When I changed this in my node modules folder the issue is resolved
The text was updated successfully, but these errors were encountered:
The PR doesn't work. My goal is basically to animate the offset of chromatic aberration based on mouse position. But with strict type checking enabled, I can't
Hi,
I have the below code:
I'm trying to animate the chromatic aberration offset.
However, I get the following error:
I believe this is because the type is exported as
typeof ChromaticAberrationEffect
inreact-three/postprocessing
instead of just
ChromaticAberrationEffect
When I changed this in my node modules folder the issue is resolved
The text was updated successfully, but these errors were encountered: