chore: default tabs

This commit is contained in:
Nathan Walker
2020-07-09 23:46:02 -07:00
parent 8100cf7089
commit 41f0573d8e
353 changed files with 55344 additions and 55344 deletions

View File

@@ -3,7 +3,7 @@
* @argument time Time of the current frame in milliseconds
*/
export interface FrameRequestCallback {
(time: number): void;
(time: number): void;
}
/**

View File

@@ -2,7 +2,7 @@ import { FPSCallback } from '../fps-meter/fps-native';
import { getTimeInFrameBase } from './animation-native';
export interface FrameRequestCallback {
(time: number): void;
(time: number): void;
}
let animationId = 0;
@@ -13,50 +13,50 @@ let fpsCallback: FPSCallback;
let lastFrameTime = 0;
function getNewId() {
return animationId++;
return animationId++;
}
function ensureNative() {
if (fpsCallback) {
return;
}
fpsCallback = new FPSCallback(doFrame);
if (fpsCallback) {
return;
}
fpsCallback = new FPSCallback(doFrame);
}
function doFrame(currentTimeMillis: number) {
lastFrameTime = currentTimeMillis;
shouldStop = true;
const thisFrameCbs = nextFrameAnimationCallbacks;
nextFrameAnimationCallbacks = {};
inAnimationFrame = true;
for (const animationId in thisFrameCbs) {
if (thisFrameCbs[animationId]) {
thisFrameCbs[animationId](lastFrameTime);
}
}
inAnimationFrame = false;
if (shouldStop) {
fpsCallback.stop(); // TODO: check performance without stopping to allow consistent frame times
}
lastFrameTime = currentTimeMillis;
shouldStop = true;
const thisFrameCbs = nextFrameAnimationCallbacks;
nextFrameAnimationCallbacks = {};
inAnimationFrame = true;
for (const animationId in thisFrameCbs) {
if (thisFrameCbs[animationId]) {
thisFrameCbs[animationId](lastFrameTime);
}
}
inAnimationFrame = false;
if (shouldStop) {
fpsCallback.stop(); // TODO: check performance without stopping to allow consistent frame times
}
}
export function requestAnimationFrame(cb: FrameRequestCallback): number {
if (!inAnimationFrame) {
inAnimationFrame = true;
zonedCallback(cb)(getTimeInFrameBase()); // TODO: store and use lastFrameTime
inAnimationFrame = false;
if (!inAnimationFrame) {
inAnimationFrame = true;
zonedCallback(cb)(getTimeInFrameBase()); // TODO: store and use lastFrameTime
inAnimationFrame = false;
return getNewId();
}
ensureNative();
const animId = getNewId();
nextFrameAnimationCallbacks[animId] = zonedCallback(cb) as FrameRequestCallback;
shouldStop = false;
fpsCallback.start();
return getNewId();
}
ensureNative();
const animId = getNewId();
nextFrameAnimationCallbacks[animId] = zonedCallback(cb) as FrameRequestCallback;
shouldStop = false;
fpsCallback.start();
return animId;
return animId;
}
export function cancelAnimationFrame(id: number) {
delete nextFrameAnimationCallbacks[id];
delete nextFrameAnimationCallbacks[id];
}

View File

@@ -1,3 +1,3 @@
export function getTimeInFrameBase(): number {
return java.lang.System.nanoTime() / 1000000;
return java.lang.System.nanoTime() / 1000000;
}