mirror of
https://github.com/nvms/prsm.git
synced 2025-12-16 08:00:53 +00:00
adjust fps calc
This commit is contained in:
parent
a05a3810a2
commit
74bc7163a2
@ -146,22 +146,28 @@ export const createWorld = () => {
|
|||||||
* Fake requestAnimationFrame and cancelAnimationFrame
|
* Fake requestAnimationFrame and cancelAnimationFrame
|
||||||
* so that we can run tests for this in node.
|
* so that we can run tests for this in node.
|
||||||
*/
|
*/
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
raf = requestAnimationFrame;
|
let now = performance.now();
|
||||||
craf = cancelAnimationFrame;
|
raf = (cb: FrameRequestCallback): number => {
|
||||||
} else {
|
return requestAnimationFrame((timestamp) => {
|
||||||
let now = 0;
|
now = timestamp;
|
||||||
raf = (cb: FrameRequestCallback): number => {
|
cb(now);
|
||||||
return setTimeout(() => {
|
});
|
||||||
now += 16.67;
|
};
|
||||||
cb(now);
|
craf = cancelAnimationFrame;
|
||||||
}, 16.67) as unknown as number;
|
} else {
|
||||||
};
|
let now = 0;
|
||||||
|
raf = (cb: FrameRequestCallback): number => {
|
||||||
|
return setTimeout(() => {
|
||||||
|
now += 16.67;
|
||||||
|
cb(now);
|
||||||
|
}, 16.67) as unknown as number;
|
||||||
|
};
|
||||||
|
|
||||||
craf = (id: number) => {
|
craf = (id: number) => {
|
||||||
clearTimeout(id);
|
clearTimeout(id);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let xfps = 1;
|
let xfps = 1;
|
||||||
const xtimes = [];
|
const xtimes = [];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user