I’m using the ocean plugin from this example three.js webgl - shaders - ocean
and in Update we are animating the water uniforms over time but the effect is not always smooth even in a pretty much empty scene, it occasionally judders as if update is not constant.
update(){
{
//@ts-ignore
this.water.material.uniforms[ 'time' ].value += 1.0 / 60.0;
}
}
Original Post on Discord
by user 103054507105067008
That script attached can be added to an empty in your scene to spawn the water
by user 103054507105067008
marwie1
(marwi)
October 26, 2022, 12:00am
3
You should use this.context.time.deltaTime
to update time uniforms
marwie1
(marwi)
October 26, 2022, 12:00am
4
or you can set this.context.time.time
directly
marwie1
(marwi)
October 26, 2022, 12:00am
5
Otherwise you’ll see different water speeds depending on the framerate your scene runs on (e.g. on mobile vs desktop)
marwie1
(marwi)
October 26, 2022, 12:00am
6
btw you can use ?stats
in your url to show the framerate and memory
Somehow it still isn’t smooth, stats shows 2ms too it just jutters at a regular interval
by user 103054507105067008
Swapped update to
update(){
{
//@ts-ignore
this.water.material.uniforms[ 'time' ].value += this.context.time.deltaTime;
}
}
It’s only me that notices it so far so might just leave it lol
by user 103054507105067008