settings.TARGET_FPMS is supposed to set a limit for how many MS elapse each frame. By default, it equals 0.06, which roughly translates to a cap of 16 MS per frame.
But on line 390 of Ticker.js TARGET_FPMS is a direct part of the deltaTime calculation:
this.deltaTime = elapsedMS * settings.TARGET_FPMS * this.speed;
This takes elapsedMS which is generally around 16 MS, and multiplies it by 0.06, setting deltaTime to an average value of 1 MS, causing Ticker to claim an update rate of around 1000 FPS.
TARGET_FPMS is already used to calculate this._maxElapsedMS, so I believe it's already doing it's job. We should be able to remove it from the deltaTime calculation:
this.deltaTime = elapsedMS * this.speed;
deltaTime===1 corresponds to 1 frame, its working as intended. TARGET_FPMS is how many frames are elapsed per milliseconds. Yes, its strange, we should name it deltaFrame
That way if user writes element.x += 5 and it works fine on 60FPS, he cant just add * deltaTime to make smooth animations.
Ah, I see! The documentation's explanation of "a scalar time value" was a bit confusing. I still need deltaTime to be in fractional seconds, because my physics engine expects it that way. But I can just divide by TARGET_FPMS for that.
Thanks for your help! I'll leave this issue open in case people want to treat it as a documentation issue. Otherwise, feel free to close it!
You can write your own ticker with same interface and use it in your custom application class, and even assign PIXI.tickers.shared to it. or ticker.shared, i dont remember.
Make sure that AnimatedSprite and other things that you add in it, like your own tween manager, understand what exactly do you pass in.
Should at least fix this in v5, both documentation and variable name
This is really confusing, I have wasted my time on this.
const ms = deltaTime / PIXI.settings.TARGET_FPMS;
emmm.... I think this can be closed.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
deltaTime===1corresponds to 1 frame, its working as intended.TARGET_FPMSis how many frames are elapsed per milliseconds. Yes, its strange, we should name itdeltaFrameThat way if user writes
element.x += 5and it works fine on 60FPS, he cant just add* deltaTimeto make smooth animations.