Camera shake along with orbitcontrols & tween js

i would like to use this type of shake Camera Shake or "Much Damage, Such WoW" (i tried using the code from this but it did not work as intended)

along with orbitcontrols and tween js

so tween js moves the camera position and orbitcontrols target to specified points ( the onUpdate callback is used to update both the values)
orbitcontrols.update() in the render loop keeps the camera following the target

is there a way to add simple repeatable noise to the movement ?

i have simplex and improved noise imported but adding noise at each frame just seems to be jittering the movement and not moving smoothly

fiddle coming soon

there’s a fully configurable camshake that works with any kind of control here: GitHub - pmndrs/drei: 🌭 useful helpers for react-three-fiber it lets you set pitch roll and yaw as well as frequency and intensity. it also has decay so you can use it to “bounce” the camera, like when a bomb goes off, etc.

<CameraShake />
<OrbitControls makeDefault />

demo: Camera shake - CodeSandbox

camshake code: drei/CameraShake.tsx at 92ee23da2355426a39dd76596c3b996eea20e415 · pmndrs/drei · GitHub

when you need that in vanilla, useEffect is ran once, set up your events. useFrame is the same as your frameloop.

1 Like


will use drei/CameraShake.tsx at 92ee23da2355426a39dd76596c3b996eea20e415 · pmndrs/drei · GitHub as another refernce

since orbit controls looks at target i cant use rotation

this is my current simple approch

camTween.onUpdate(() => {
  camera.position.lerpVectors(forTween.start, forTween.end, forTween.val);, forTween.tarEnd, forTween.val);
    simplex.noise(camera.position.x, 1),
    simplex.noise(camera.position.y, 1),
    simplex.noise(camera.position.z, 1)