CameraShake
A component for applying a configurable camera shake effect. Currently only supports rotational camera shake. Pass a ref to receive the ShakeController
API.
import { CameraShake } from '@react-three/drei'
const config = {
maxYaw: 0.1, // Max amount camera can yaw in either direction
maxPitch: 0.1, // Max amount camera can pitch in either direction
maxRoll: 0.1, // Max amount camera can roll in either direction
yawFrequency: 1, // Frequency of the the yaw rotation
pitchFrequency: 1, // Frequency of the pitch rotation
rollFrequency: 1, // Frequency of the roll rotation
intensity: 1, // initial intensity of the shake
decay: false, // should the intensity decay over time
decayRate: 0.65, // if decay = true this is the rate at which intensity will reduce at
additive: false, // this should be used when your scene has orbit controls
}
<CameraShake {...config} />
interface ShakeController {
getIntensity: () => number
setIntensity: (val: number) => void
}