Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

three.js animate object regardless screen fps

// Time 
let time = Date.now();
// Animation
const tick = () => {
    //Time 
    const currentTime = Date.now();
    const deltaTime = (currentTime - time);
    time = currentTime;
    console.log(deltaTime);
    //Update the object
    mesh.rotation.y += 0.001 * deltaTime
    //Rednder 
    renderer.render(scene, camera)
    window.requestAnimationFrame(tick)
}
tick();
 
PREVIOUS NEXT
Tagged: #animate #object #screen #fps
ADD COMMENT
Topic
Name
3+5 =