# \#requestanimationframe

**URL:** https://discourse.threejs.org/tag/requestanimationframe/1053.md

[Latest](https://discourse.threejs.org/latest.md) · [Categories](https://discourse.threejs.org/categories.md) · [Tags](https://discourse.threejs.org/tags.md)

---

## [Timer’s code example: Why call requestAnimationFrame() first?](https://discourse.threejs.org/t/timer-s-code-example-why-call-requestanimationframe-first/87516)

<div class="topic-metadata">

**Author:** [@Zearin](https://discourse.threejs.org/u/Zearin)\
**Replies:** 9\
**Last updated:** [October 15, 2025, 7:51pm UTC](https://discourse.threejs.org/t/timer-s-code-example-why-call-requestanimationframe-first/87516 "2025-10-15T19:51:19Z")

</div>

NOTE: This question is more about requestAnimationFrame than Three.js, but it was an example from the Three.js docs that caused me to scratch my head. Maybe this will be useful to others starting out in this area, too. …

---

## [How do I wait for the \<canvas\> to update? All three.js FPS counters are inaccurate without this ability](https://discourse.threejs.org/t/how-do-i-wait-for-the-canvas-to-update-all-three-js-fps-counters-are-inaccurate-without-this-ability/87381)

<div class="topic-metadata">

**Author:** [@torrent](https://discourse.threejs.org/u/torrent)\
**Replies:** 3\
**Last updated:** [October 6, 2025, 7:50pm UTC](https://discourse.threejs.org/t/how-do-i-wait-for-the-canvas-to-update-all-three-js-fps-counters-are-inaccurate-without-this-ability/87381 "2025-10-06T19:50:42Z")

</div>

Calling renderer.render() in a requestAnimationFrame() loop will often fire faster than the \<canvas\> element can update its image, making any “true” FPS measurement inaccurate. In three.js, how can I block each iteratio…

---

## [It is impossible to get an accurate FPS measurement without using await renderer.waitForGPU(). Why doesn't renderer.renderAsync() already do this internally?](https://discourse.threejs.org/t/it-is-impossible-to-get-an-accurate-fps-measurement-without-using-await-renderer-waitforgpu-why-doesnt-renderer-renderasync-already-do-this-internally/87297)

<div class="topic-metadata">

**Author:** [@torrent](https://discourse.threejs.org/u/torrent)\
**Replies:** 0\
**Last updated:** [October 2, 2025, 1:38am UTC](https://discourse.threejs.org/t/it-is-impossible-to-get-an-accurate-fps-measurement-without-using-await-renderer-waitforgpu-why-doesnt-renderer-renderasync-already-do-this-internally/87297 "2025-10-02T01:38:27Z")

</div>

Here I have a simple FPS counter that displays the current frame and the FPS counted from the last second: let globalFrames = 0; let intervalFrames = 0; let lastTimestamp = performance.now(); requestAnimationFrame(stepA…

---

## [How to control a particle morph (custom shader) with mouse scroll instead of automatic animation?](https://discourse.threejs.org/t/how-to-control-a-particle-morph-custom-shader-with-mouse-scroll-instead-of-automatic-animation/86338)

<div class="topic-metadata">

**Author:** [@Parisa\_Shahbazi](https://discourse.threejs.org/u/Parisa_Shahbazi)\
**Replies:** 2\
**Last updated:** [August 18, 2025, 8:23pm UTC](https://discourse.threejs.org/t/how-to-control-a-particle-morph-custom-shader-with-mouse-scroll-instead-of-automatic-animation/86338 "2025-08-18T20:23:09Z")

</div>

I have a Three.js project where I use particles + morphing with a custom shader. Right now, the morph animation plays automatically (e.g., particles transform from a circle into an image, and from one image into another…

---

## [Many objects caused low fps, can we optimize it without losing control over individual Mesh](https://discourse.threejs.org/t/many-objects-caused-low-fps-can-we-optimize-it-without-losing-control-over-individual-mesh/76837)

<div class="topic-metadata">

**Author:** [@Guliver\_Potsangbam](https://discourse.threejs.org/u/Guliver_Potsangbam)\
**Replies:** 6\
**Last updated:** [January 29, 2025, 8:51am UTC](https://discourse.threejs.org/t/many-objects-caused-low-fps-can-we-optimize-it-without-losing-control-over-individual-mesh/76837 "2025-01-29T08:51:44Z")

</div>

In my three.js project. I need to render thousands of individual meshes(e.g. 10k or more). From some sources, I realized that rendering a large number of objects(THREE.Mesh) increases draw calls and therefore, drops FPS …

---

## [\[Violation\] 'requestAnimationFrame' handler took \<N\>ms](https://discourse.threejs.org/t/violation-requestanimationframe-handler-took-n-ms/76506)

<div class="topic-metadata">

**Author:** [@Guliver\_Potsangbam](https://discourse.threejs.org/u/Guliver_Potsangbam)\
**Replies:** 2\
**Last updated:** [January 17, 2025, 5:34am UTC](https://discourse.threejs.org/t/violation-requestanimationframe-handler-took-n-ms/76506 "2025-01-17T05:34:49Z")

</div>

import \* as THREE from 'three'; import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'; import Stats from 'three/examples/jsm/l…

---

## [Stop render function(requestanimationframe or setAnimationLoop)](https://discourse.threejs.org/t/stop-render-function-requestanimationframe-or-setanimationloop/68930)

<div class="topic-metadata">

**Author:** [@Parisa\_Shahbazi](https://discourse.threejs.org/u/Parisa_Shahbazi)\
**Replies:** 6\
**Last updated:** [August 4, 2024, 4:41pm UTC](https://discourse.threejs.org/t/stop-render-function-requestanimationframe-or-setanimationloop/68930 "2024-08-04T16:41:20Z")

</div>

Hi I want to rotate my model but because of some axes problems(I have 3d model and some other decal geometries in my scene). I decided to rotate the orbit and it worked better. Now I need help in stopping orbitcontrol …

---

## [Request Animation frame sometimes stucks or jerks in between the game](https://discourse.threejs.org/t/request-animation-frame-sometimes-stucks-or-jerks-in-between-the-game/68698)

<div class="topic-metadata">

**Author:** [@Deepak\_Saini\_VT](https://discourse.threejs.org/u/Deepak_Saini_VT)\
**Replies:** 3\
**Last updated:** [July 29, 2024, 6:15am UTC](https://discourse.threejs.org/t/request-animation-frame-sometimes-stucks-or-jerks-in-between-the-game/68698 "2024-07-29T06:15:09Z")

</div>

I am creating a replica of a 2D game i.e. Browser Dino Game. The Strange thing happening here is that, am running the obstacles from right to left by decreasing there x position in requestAnimationFrame() loop. But craz…

---

## [I got requestAnimationFrame handler took \<N\> s](https://discourse.threejs.org/t/i-got-requestanimationframe-handler-took-n-s/67819)

<div class="topic-metadata">

**Author:** [@AMJAD](https://discourse.threejs.org/u/AMJAD)\
**Replies:** 7\
**Last updated:** [July 10, 2024, 11:18am UTC](https://discourse.threejs.org/t/i-got-requestanimationframe-handler-took-n-s/67819 "2024-07-10T11:18:11Z")

</div>

\*\*My problem is \*\* I render 100 sphere in the same time but the component still rerender and I got requestAnimationFrame error and the component as in photo render many times and some times don’t happen what and I want t…

---

## [Frame rate throttle](https://discourse.threejs.org/t/frame-rate-throttle/54076)

<div class="topic-metadata">

**Author:** [@Tibi](https://discourse.threejs.org/u/Tibi)\
**Replies:** 3\
**Last updated:** [August 16, 2023, 8:46am UTC](https://discourse.threejs.org/t/frame-rate-throttle/54076 "2023-08-16T08:46:59Z")

</div>

Hi. I am working on a project and I want to keep the frame rate at maximum 60fps, now sometimes it running at 170 + frames on my computer. What is the best approach for this using requestanimationframe? https://webdes…

---

## [Violation requestAnimationFrame handeler took 'xx' ms](https://discourse.threejs.org/t/violation-requestanimationframe-handeler-took-xx-ms/49567)

<div class="topic-metadata">

**Author:** [@Sion](https://discourse.threejs.org/u/Sion)\
**Replies:** 1\
**Last updated:** [March 25, 2023, 12:54pm UTC](https://discourse.threejs.org/t/violation-requestanimationframe-handeler-took-xx-ms/49567 "2023-03-25T12:54:31Z")

</div>

I have been getting an issue with receiving several of the above ‘Violation’ messages causing my website to eventually freeze and for the whole browser to close as if all resources are being maxed out after approx. 5000 …

---

## [Replacing requestAnimationFrame with setAnimationLoop](https://discourse.threejs.org/t/replacing-requestanimationframe-with-setanimationloop/33314)

<div class="topic-metadata">

**Author:** [@orion\_prime](https://discourse.threejs.org/u/orion_prime)\
**Replies:** 3\
**Last updated:** [October 31, 2022, 8:32am UTC](https://discourse.threejs.org/t/replacing-requestanimationframe-with-setanimationloop/33314 "2022-10-31T08:32:31Z")

</div>

apart from webxr is there any disadvantage/advantage by changing from requestAnimationFrame to renderer.setAnimationLoop() ? my old project was done with requestAnimationFrame and after adding webxr AR support i have…

---

## [How does the rendering loop work?](https://discourse.threejs.org/t/how-does-the-rendering-loop-work/43581)

<div class="topic-metadata">

**Author:** [@stoex](https://discourse.threejs.org/u/stoex)\
**Replies:** 0\
**Last updated:** [October 13, 2022, 8:53am UTC](https://discourse.threejs.org/t/how-does-the-rendering-loop-work/43581 "2022-10-13T08:53:52Z")

</div>

Hey there, I have another question to threejs. This time the question is about the rendering loop. But first here is a part of my code: function main() { const canvas = document.querySelector( "#machin…

---

## [Calling requestAnimationFrame recomendations](https://discourse.threejs.org/t/calling-requestanimationframe-recomendations/42033)

<div class="topic-metadata">

**Author:** [@AdarkSt](https://discourse.threejs.org/u/AdarkSt)\
**Replies:** 4\
**Last updated:** [August 31, 2022, 7:46am UTC](https://discourse.threejs.org/t/calling-requestanimationframe-recomendations/42033 "2022-08-31T07:46:03Z")

</div>

Is it recomended call requestAnimationFrame without stoping if i want to animate my scene only when has mouse click. Or that is good practice fire it’ after event click and after that stop it ? I think that may overset d…

---

## [If I use React, after Build , the page performance degradation](https://discourse.threejs.org/t/if-i-use-react-after-build-the-page-performance-degradation/32228)

<div class="topic-metadata">

**Author:** [@seanin](https://discourse.threejs.org/u/seanin)\
**Replies:** 1\
**Last updated:** [June 26, 2022, 1:10pm UTC](https://discourse.threejs.org/t/if-i-use-react-after-build-the-page-performance-degradation/32228 "2022-06-26T13:10:58Z")

</div>

I just created the code framework with this command today . npx create-react-app my-app cd my-app npm start In development mode, my code, page performance is OK . Average 50 FPS . There are only a few requestAnimation…

---

## [Is there a performance difference between requestAnimationFrame() and setAnimationLoop()?](https://discourse.threejs.org/t/is-there-a-performance-difference-between-requestanimationframe-and-setanimationloop/27771)

<div class="topic-metadata">

**Author:** [@dllb](https://discourse.threejs.org/u/dllb)\
**Replies:** 2\
**Last updated:** [July 4, 2021, 2:42pm UTC](https://discourse.threejs.org/t/is-there-a-performance-difference-between-requestanimationframe-and-setanimationloop/27771 "2021-07-04T14:42:08Z")

</div>

We know we have two options for creating a render loop: a): animate(); function animate() { requestAnimationFrame( animate ); render(); } function render(){ . . . . } b): renderer.setAnimationLoop( render ); f…
