@galacean/effects-plugin-stats 2.5.0-alpha.0 → 2.5.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +115 -22
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +116 -23
- package/dist/index.mjs.map +1 -1
- package/dist/monitor.d.ts +29 -2
- package/dist/stats-component.d.ts +10 -0
- package/dist/stats.d.ts +47 -2
- package/package.json +2 -2
package/dist/monitor.d.ts
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import type { Disposable } from '@galacean/effects';
|
|
2
|
+
import { EventEmitter } from '@galacean/effects';
|
|
3
|
+
import type { PerformanceData } from './core';
|
|
4
|
+
import { Core } from './core';
|
|
2
5
|
import type { StatsOptions } from './stats';
|
|
3
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Performance monitor event type.
|
|
8
|
+
*/
|
|
9
|
+
export type MonitorEvent = {
|
|
10
|
+
['update']: [data: PerformanceData];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Performance monitor.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Monitor extends EventEmitter<MonitorEvent> implements Disposable {
|
|
4
16
|
private readonly options;
|
|
5
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The core of the monitor, which handles the performance data collection.
|
|
19
|
+
*/
|
|
20
|
+
core: Core;
|
|
6
21
|
private doms;
|
|
7
22
|
private container;
|
|
8
23
|
private readonly items;
|
|
24
|
+
private visible;
|
|
9
25
|
private data;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new Monitor instance.
|
|
28
|
+
* @param gl
|
|
29
|
+
* @param options
|
|
30
|
+
*/
|
|
10
31
|
constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, options: Required<StatsOptions>);
|
|
11
32
|
private createContainer;
|
|
12
33
|
private createStyle;
|
|
@@ -14,7 +35,13 @@ export declare class Monitor implements Disposable {
|
|
|
14
35
|
* Update per frame
|
|
15
36
|
*/
|
|
16
37
|
update(dt: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Hide the monitor
|
|
40
|
+
*/
|
|
17
41
|
hide(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Show the monitor
|
|
44
|
+
*/
|
|
18
45
|
show(): void;
|
|
19
46
|
/**
|
|
20
47
|
* reset all hooks
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { Behaviour } from '@galacean/effects';
|
|
2
2
|
import { Monitor } from './monitor';
|
|
3
3
|
import type { StatsOptions } from './stats';
|
|
4
|
+
/**
|
|
5
|
+
* Stats 组件,用于监控渲染性能
|
|
6
|
+
*/
|
|
4
7
|
export declare class StatsComponent extends Behaviour {
|
|
5
8
|
/**
|
|
6
9
|
* 监控对象
|
|
7
10
|
*/
|
|
8
11
|
monitor: Monitor;
|
|
9
12
|
init(options: Required<StatsOptions>): void;
|
|
13
|
+
/**
|
|
14
|
+
* 每帧更新
|
|
15
|
+
* @param dt
|
|
16
|
+
*/
|
|
10
17
|
onUpdate(dt: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* 释放资源
|
|
20
|
+
*/
|
|
11
21
|
dispose(): void;
|
|
12
22
|
}
|
package/dist/stats.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Player, Disposable } from '@galacean/effects';
|
|
2
|
+
import { Deferred } from '@galacean/effects';
|
|
3
|
+
import { StatsComponent } from './stats-component';
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
5
|
+
* Options for the Stats plugin.
|
|
4
6
|
*/
|
|
5
7
|
export interface StatsOptions {
|
|
6
8
|
/**
|
|
@@ -17,21 +19,64 @@ export interface StatsOptions {
|
|
|
17
19
|
container?: HTMLElement;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
22
|
+
* Stats plugin for the Player.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // Simple usage of Stats plugin
|
|
27
|
+
* import { Stats } from '@galacean/effects-plugin-stats';
|
|
28
|
+
*
|
|
29
|
+
* const stats = new Stats(player);
|
|
30
|
+
* // Hide the stats monitor
|
|
31
|
+
* stats.hide();
|
|
32
|
+
* // Show the stats monitor
|
|
33
|
+
* stats.show();
|
|
34
|
+
* ```
|
|
20
35
|
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* // 自定义 Stats 组件的 onUpdate 方法
|
|
39
|
+
* // 可用于在每帧更新时获取性能数据
|
|
40
|
+
* const stats = new Stats(player, { visible: false });
|
|
41
|
+
* const [_, component] = await Promise.all([
|
|
42
|
+
* player.loadScene(json),
|
|
43
|
+
* stats.getComponent(),
|
|
44
|
+
* ]);
|
|
45
|
+
*
|
|
46
|
+
* component?.monitor.on('update', data => {
|
|
47
|
+
* console.info(data);
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
21
50
|
*/
|
|
22
51
|
export declare class Stats implements Disposable {
|
|
23
52
|
readonly player: Player;
|
|
24
53
|
private readonly options?;
|
|
25
54
|
private component?;
|
|
26
55
|
private disposed;
|
|
56
|
+
protected readonly initialized: Deferred<void>;
|
|
27
57
|
/**
|
|
28
|
-
*
|
|
58
|
+
* Create a new Stats instance.
|
|
29
59
|
* @param player
|
|
30
60
|
* @param options
|
|
31
61
|
*/
|
|
32
62
|
constructor(player: Player, options?: StatsOptions | undefined);
|
|
33
63
|
init(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Get the stats component.
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
getComponent(): Promise<StatsComponent | undefined>;
|
|
69
|
+
/**
|
|
70
|
+
* Hide the stats monitor.
|
|
71
|
+
*/
|
|
34
72
|
hide(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Show the stats monitor.
|
|
75
|
+
*/
|
|
35
76
|
show(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Dispose the stats component and release resources.
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
36
81
|
dispose(): void;
|
|
37
82
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/effects-plugin-stats",
|
|
3
|
-
"version": "2.5.0-alpha.
|
|
3
|
+
"version": "2.5.0-alpha.1",
|
|
4
4
|
"description": "Galacean Effects runtime stats for the web",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"registry": "https://registry.npmjs.org"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@galacean/effects": "2.5.0-alpha.
|
|
31
|
+
"@galacean/effects": "2.5.0-alpha.1"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"dev": "vite",
|