#Is update() the smoothest animate loop?

1 messages · Page 1 of 1 (latest)

sweet wedge
#

I'm using the ocean plugin from this example https://threejs.org/examples/webgl_shaders_ocean.html

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;
        }
    }
#

That script attached can be added to an empty in your scene to spawn the water

minor saddle
#

You should use this.context.time.deltaTime to update time uniforms

#

or you can set this.context.time.time directly

#

Otherwise you'll see different water speeds depending on the framerate your scene runs on (e.g. on mobile vs desktop)

#

btw you can use ?stats in your url to show the framerate and memory

sweet wedge
#

Somehow it still isn't smooth, stats shows 2ms too it just jutters at a regular interval