 | Time Based Movement |  |
Instead of just hardcoding an arbirary value for movement each frame - you calculate how much time has elapsed since the last call. This means, as the frame rate increases and decreases the movements don't become jittery and unnatural - they remain consistent and smooooooth.
Functions Used: peformance.now(), setVertexBuffer(), setIndexBuffer(), drawIndexed(), createBuffer(), getMappedRange(), getContext(), requestAdapter(), getPreferredCanvasFormat(), createCommandEncoder(), beginRenderPass(), setPipeline(), draw(), end(), submit(), getCurrentTexture(), createView(), createShaderModule()
We can use the peformance.now() function to get timing information and calculation dt (time in milliseconds since the last frame update).
|