round render fps

This commit is contained in:
esterTion 2021-12-15 01:52:55 +08:00
parent 6954f8b714
commit 432257e88d
1 changed files with 8 additions and 0 deletions

View File

@ -488,6 +488,7 @@ function parseNotesFromText(text) {noteList = [];
const drawCount = {
frame: 0,
actualFrame: 0,
guessedFps: 0,
}
let currentSectionDiv = stats.parentNode.insertBefore(document.createElement('div'), stats)
toggle_ui.addEventListener('input', () => {
@ -500,6 +501,7 @@ setInterval(() => {
stats.textContent = [
`frame draw: ${drawCount.frame}`,
`frame actual draw: ${drawCount.actualFrame}`,
`guess fps: ${drawCount.guessedFps}`,
].join('\n')
drawCount.frame = 0
drawCount.actualFrame = 0
@ -589,7 +591,13 @@ function render(now) {
sfl = sflTsList[sflOffset].sfl
}
currentTs = now - startTs
let diffTs = currentTs - previousTs
let calcBaseTs = currentTs
if (diffTs < 30) {
let guessedFps = Math.round((1000/diffTs)/12)*12
calcBaseTs = Math.round(calcBaseTs / 1000 * guessedFps) / guessedFps * 1000
drawCount.guessedFps = guessedFps
}
for (let i=0; i<reverseSection.length; i++) {
if (calcBaseTs > reverseSection[i][0] && calcBaseTs < reverseSection[i][1]) {
calcBaseTs = reverseSection[i][1] + (reverseSection[i][1] - calcBaseTs) * (reverseSection[i][2] - reverseSection[i][1]) / (reverseSection[i][1] - reverseSection[i][0])