mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #21662 from danvk/update-statsjs
Update stats.js typings to r17 and add Stats.Panel
This commit is contained in:
Vendored
+16
-3
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user