Slow down clock time / bullet time

I’m trying to slow down the scene globally - animations/physics/transformations, etc. As it is done in F.E.A.R., max payne or nfs, for example, with a smooth transition from/to slowdown when you press the button. But so far I don’t see any way to implement this through threejs api. What can be done in this situation? What threejs or webgl api’s should be used? Maybe there’s some hidden global multiplier?

Hello! Three.js use delta time for animations. For 60 fps delta time is 0.016 second or 16 miliseconds.

var slow_down=0;
var slow_up=0;
var slow_v=0.016;


function loop(){

requestAnimationFrame(loop);
delta=clock.getDelta(); // 0.016ms

if(slow_down==1){
if(slow_v>0.002){ slow_v-=0.0001; }
delta=slow_v;
}

if(slow_up==1){
slow_down=0; // set it in function of keypress
if(slow_v<0.016){ slow_v+=0.0001; }
if(slow_v>0.015){ slow_v=0.016; slow_up=0; }
delta=slow_v;
}

controls.update(delta);

var max=mixers.length;
for(var n=0;n<max;n++){
mixers[n].update(delta);
}

}

Good test into “Silent Hill”.

Hi there!
Thank you so much for reply.
But i do scenes in react three fiber and i have custom fps controls, and no access to ‘controls’ in frame loop. And player camera is physics based (cannonjs via use-cannon)

Could you please look into my sandbox?

?

I dont know react three fiber . In example found only this:
clock.getElapsedTime()
but for slowdown need calculate like this also:
delta=clock.getDelta();

i can alter delta but this results in choppy motion (like 10 fps)
how can i lerp it right in 60 fps?

Only who know what is “react three fiber” can help.

Maybe by adjusting some time delta multiplicators and multiplying them with current delta

export function Updater() {
  const timeDeltaModificator: number = useSelector(selectTimeDeltaModificator);

  useFrame((state: RootState, delta: number) => {
    yourUpdateFunction({ delta: delta * timeDeltaModificator });
  });

  return ( <mesh /> );
}

This way you will still have your N (60?) fps, but with slowed-down physics, animations, etc.