# Different turning speed playground

**URL:** <https://forum.babylonjs.com/t/different-turning-speed-playground/52151>\
**Category:** Questions\
**Created:** [July 18, 2024, 12:06am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151 "2024-07-18T00:06:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [July 18, 2024, 12:06am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/1 "2024-07-18T00:06:57Z")

</div>

Yo @Deltakosh or @sebavan … I got a funny timing thing happening in the playground between platform versions…

I have a javascript and typescript playgrounds that are the same code, But for some reason they turn at different rates… Like one of them is spinning fast, but the both have the same get delta time calculation.

[Javascript Playground](https://playground.babylonjs.com/index.html?BabylonToolkit#TLH1QP#1)

And the [Typescript Playground](https://playground.babylonjs.com/index.html?BabylonToolkit#5QY67Y#1)

Can you please take a look at why that could be happening

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 18, 2024, 1:23am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/2 "2024-07-18T01:23:12Z")

</div>

They are the exact same for me ☹ Can you try in incognito mode to be sure you have no cache

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 18, 2024, 5:25am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/3 "2024-07-18T05:25:04Z")

</div>

Javascript version rotates faster on my rig.

EDIT: closed the tabs, reopened and the issue is gone… wtf 🙂

EDIT2: did the same again, javascript version is faster…

---

<div class="post-metadata">

**Author:** ![11128](https://avatars.discourse-cdn.com/v4/letter/1/d07c76/32.png) [@11128](https://forum.babylonjs.com/u/11128)\
**Post date:** [July 18, 2024, 5:48am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/4 "2024-07-18T05:48:03Z")

</div>

It seems to be an issue between js and ts, as the class is not initialized and is applied additionally. (If you run them simultaneously, the boxes running after them seem to run at twice the speed.)

There seems to be a difference when discarding or initializing pg in js and pg in ts. Is it related?  
(speed is maintained correctly in multiple executions of ts + ts, js + js)

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 18, 2024, 6:52am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/5 "2024-07-18T06:52:59Z")

</div>

To be sure the issue is not comming from the base class, here are two PGs without external dependencies:

Start this first:  
TS: [https://playground.babylonjs.com/#5QY67Y#4](https://playground.babylonjs.com/#5QY67Y#4)

Second:  
JS: [https://playground.babylonjs.com/#TLH1QP#5](https://playground.babylonjs.com/#TLH1QP#5)

You get different rotation speeds.

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [July 18, 2024, 8:38am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/6 "2024-07-18T08:38:13Z")

</div>

Yeah… its weird… sometimes they are the same and sometimes one rotates faster.

---

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [July 18, 2024, 9:16am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/7 "2024-07-18T09:16:25Z")

</div>

Indeed this is very weird. In fact on my side, it’s random in JS side. Launching the same JS on 2 different tabs doesn’t have the same result.

I have done a [Playground with some UI to debug](https://playground.babylonjs.com/index.html?BabylonToolkit#TLH1QP#7)

What is weird is that I’m computing the REAL delta using `Date.now()` (just to make sure) and it seems that one cube is turning two times faster while the figures (deltaTime, etc) are exctly the same. I’m computing the real speed in Degrees/Second, and on both sides it’s about 80°/s :

![Screencast from 18-07-2024 11:12:36](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/3/e310b6600867598a11cff64eb864562c7456bde9.gif)

[EDIT] : It’s not exactly random in fact. Like @roland said, it seems that JS turns 2 times faster only when opened just after TS version. But, opening another JS after, is ok then. So you can end up with 2 JS versions running at differnent speed (GIF above), the one opened just after TS is 2 times faster

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 18, 2024, 9:50am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/8 "2024-07-18T09:50:15Z")

</div>

Open TS PG:

> **[Babylon.js Playground](https://playground.babylonjs.com/#5QY67Y%235)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Open JS PG 3 times:

> **[Babylon.js Playground](https://playground.babylonjs.com/#TLH1QP%2311)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Only the first one runs faster. The second and the third are OK!

Open more JS PGs. All will be ok.

Open another TS PG:

Open multiple JS PGs. Again, only the first one opened after opening the TS PG rotates the cube faster…

🙈

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 18, 2024, 3:40pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/9 "2024-07-18T15:40:36Z")

</div>

No PG works for me. They all crashed

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/a/4ac7b2d6b6b3f0eca779a37bb81bbaf3ed55897d.png)

Do we have a version without the toolkit? We need to understand if this is a problem with the PG or with the toolkit

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 18, 2024, 4:00pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/10 "2024-07-18T16:00:56Z")

</div>

EDIT:

> **[Babylon.js Playground](https://playground.babylonjs.com/#5QY67Y%235)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

> **[Babylon.js Playground](https://playground.babylonjs.com/#TLH1QP%2311)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [July 18, 2024, 4:05pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/11 "2024-07-18T16:05:40Z")

</div>

both are running at the same speed on my device

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 18, 2024, 4:13pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/12 "2024-07-18T16:13:31Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#5QY67Y%236)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

> **[Babylon.js Playground](https://playground.babylonjs.com/#TLH1QP%2313)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

These are rotating at the same speed. Using `getAnimationRatio()`

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 18, 2024, 4:23pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/13 "2024-07-18T16:23:23Z")

</div>

@RaananW @Deltakosh

All links at one place:

With toolkit:

> **[Babylon.js Playground](https://playground.babylonjs.com/index.html?BabylonToolkit#TLH1QP%235)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

> **[Babylon.js Playground](https://playground.babylonjs.com/index.html?BabylonToolkit#5QY67Y%234)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

JS runs faster on my machine.

Without toolkit:

> **[Babylon.js Playground](https://playground.babylonjs.com/#5QY67Y%235)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

> **[Babylon.js Playground](https://playground.babylonjs.com/#TLH1QP%2311)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Same speed.

Without toolkit using `animationRatio`:

> **[Babylon.js Playground](https://playground.babylonjs.com/#5QY67Y%236)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

> **[Babylon.js Playground](https://playground.babylonjs.com/#TLH1QP%2313)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Same speed.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 18, 2024, 4:34pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/14 "2024-07-18T16:34:39Z")

</div>

ok so it is related to @MackeyK24 toolkit 🙂

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [July 18, 2024, 8:46pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/15 "2024-07-18T20:46:53Z")

</div>

> [@roland](#):
>
> [Babylon.js Playground](https://playground.babylonjs.com/#5QY67Y%235)

Yo @Deltakosh … I still get different speeds:

[Demo Playground One Without Toolkit](https://playground.babylonjs.com/#TLH1QP#11)

 ![Screenshot 2024-07-18 at 10.31.38 AM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/8/68aa71d61716b35a7637d7c35de1104c306f3622.jpeg)

AND

[Demo Playground Two Without Toolkit](https://playground.babylonjs.com/#5QY67Y#5)

 ![Screenshot 2024-07-18 at 10.31.48 AM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/6/36e82b9ba0864109a059a076beebcb2123a06907.jpeg)

AND (Without GetAnimationRatio)

[https://www.babylontoolkit.com/videos/ShowDiffSpeed.mp4](https://www.babylontoolkit.com/videos/ShowDiffSpeed.mp4)

AND (With GetAnimationRatio)

[https://www.babylontoolkit.com/videos/ShowDiffSpeed2.mp4](https://www.babylontoolkit.com/videos/ShowDiffSpeed2.mp4)

They **STILL** run at diff speeds ☹

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [July 18, 2024, 9:00pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/16 "2024-07-18T21:00:07Z")

</div>

Yo @roland , @RaananW and @Deltakosh … can you please test the playgrounds above again. You may have to try a few times. But I took a couple snapshots of the DOM console. No BABYLON.Toolkit stuff loaded at all. I made videos of both WITH and WITHOUT using GetAnimationRatio… It still rotates at different speeds

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 18, 2024, 9:01pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/17 "2024-07-18T21:01:06Z")

</div>

wait wait wait!

Something is fishy

I have 2 animation requests per frame on TS:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/d/5d0953f25a53699c034d659e0ac6f78663940fe0.png)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 18, 2024, 10:34pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/18 "2024-07-18T22:34:59Z")

</div>

Ok I think we found it with @sebavan

[Fix race condition by deltakosh · Pull Request #15303 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/15303)

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [July 18, 2024, 10:50pm UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/19 "2024-07-18T22:50:15Z")

</div>

Thank you so much to everyone for looking into this issue 🙂

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 19, 2024, 1:05am UTC](https://forum.babylonjs.com/t/different-turning-speed-playground/52151/20 "2024-07-19T01:05:54Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/7/f/7ff0a2fa62b3cb3982d8e08e927f25479e548469.jpeg)
