Merge pull request #21662 from danvk/update-statsjs

Update stats.js typings to r17 and add Stats.Panel
This commit is contained in:
Armando Aguirre
2017-12-01 14:26:28 -08:00
committed by GitHub
2 changed files with 23 additions and 6 deletions
+16 -3
View File
@@ -1,9 +1,12 @@
// Type definitions for Stats.js 0.16.0
// Type definitions for Stats.js 0.17.0
// Project: https://github.com/mrdoob/stats.js
// Definitions by: Gregory Dalton <https://github.com/gregolai>, Harm Berntsen <https://github.com/hberntsen>
// Definitions by: Gregory Dalton <https://github.com/gregolai>,
// Harm Berntsen <https://github.com/hberntsen>,
// Dan Vanderkam <https://github.com/danvk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Stats {
constructor();
REVISION: number;
dom: HTMLDivElement;
@@ -14,8 +17,18 @@ declare class Stats {
begin(): void;
end(): number;
update(): void;
addPanel(panel: Stats.Panel): Stats.Panel;
}
declare module "stats.js" {
declare namespace Stats {
class Panel {
constructor(name: string, foregroundColor: string, backgroundColor: string);
dom: HTMLCanvasElement;
update(value: number, maxValue: number): void;
}
}
declare module 'stats.js' {
export = Stats;
}
+7 -3
View File
@@ -1,17 +1,21 @@
var stats = new Stats();
const stats = new Stats();
stats.showPanel( 1 ); // 0: fps, 1: ms, 2: mb, 3+: custom
document.body.appendChild( stats.dom );
const panel = stats.addPanel(
new Stats.Panel('custom', 'red', 'pink'));
function animate() {
stats.begin();
// monitored code goes here
// $ExpectType number
stats.end();
panel.update(40, 100);
requestAnimationFrame( animate );
}