diff --git a/types/stats.js/index.d.ts b/types/stats.js/index.d.ts index 55b655f5bc..6449d82fd5 100644 --- a/types/stats.js/index.d.ts +++ b/types/stats.js/index.d.ts @@ -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 , Harm Berntsen +// Definitions by: Gregory Dalton , +// Harm Berntsen , +// Dan Vanderkam // 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; } diff --git a/types/stats.js/stats.js-tests.ts b/types/stats.js/stats.js-tests.ts index dfaf72e8de..21e1e4b8e5 100644 --- a/types/stats.js/stats.js-tests.ts +++ b/types/stats.js/stats.js-tests.ts @@ -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 ); }