(time)
| 1809 | } |
| 1810 | |
| 1811 | update(time) { |
| 1812 | if (!Number.isFinite(time)) return; |
| 1813 | if (this.lastTimestamp === 0) { |
| 1814 | this.lastTimestamp = time; |
| 1815 | this.lastFrameTimestamp = time; |
| 1816 | return; |
| 1817 | } |
| 1818 | const delta = time - this.lastTimestamp; |
| 1819 | this.lastTimestamp = time; |
| 1820 | if (delta < 0) return; |
| 1821 | |
| 1822 | this.accumulatedTime += delta; |
| 1823 | this.frameCount += 1; |
| 1824 | this.lastFrameTimestamp = time; |
| 1825 | |
| 1826 | if (this.accumulatedTime >= 250) { |
| 1827 | const fps = Math.round((this.frameCount * 1000) / this.accumulatedTime); |
| 1828 | this.currentFps = fps; |
| 1829 | this.accumulatedTime = 0; |
| 1830 | this.frameCount = 0; |
| 1831 | this.refreshDisplay(); |
| 1832 | } |
| 1833 | } |
| 1834 | |
| 1835 | refreshDisplay() { |
| 1836 | const now = typeof performance !== "undefined" ? performance.now() : Date.now(); |
no test coverage detected