@playcanvas/inspector 0.1.0
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/LICENSE +19 -0
- package/README.md +110 -0
- package/package.json +62 -0
- package/src/asset-usage.js +108 -0
- package/src/asset-view.js +370 -0
- package/src/camera-view.js +128 -0
- package/src/debug.js +31 -0
- package/src/describe.js +302 -0
- package/src/entity-inspector-script.js +130 -0
- package/src/frame-graph-view.js +767 -0
- package/src/hierarchy-view.js +475 -0
- package/src/index.js +4 -0
- package/src/input/fly-controller.js +116 -0
- package/src/input/input.js +299 -0
- package/src/input/math.js +8 -0
- package/src/input/orbit-controller.js +158 -0
- package/src/input/pose.js +207 -0
- package/src/inspector.js +3293 -0
- package/src/instance-survey.js +50 -0
- package/src/list-view.js +410 -0
- package/src/material-view.js +197 -0
- package/src/memory-view.js +344 -0
- package/src/mesh-view.js +235 -0
- package/src/model.js +170 -0
- package/src/node-model.js +404 -0
- package/src/physics-debug.js +527 -0
- package/src/physics-view.js +314 -0
- package/src/picker/picker.js +545 -0
- package/src/picker/render-pass-picker.js +206 -0
- package/src/property-view.js +628 -0
- package/src/render-target-view.js +288 -0
- package/src/renderers/texture-renderer-shaders.js +139 -0
- package/src/renderers/texture-renderer.js +430 -0
- package/src/renderers/wire-renderer.js +954 -0
- package/src/script-view.js +288 -0
- package/src/shader-view.js +287 -0
- package/src/styles.js +918 -0
- package/src/texture-view.js +186 -0
- package/src/tooltip.js +72 -0
- package/src/viewport-tools.js +695 -0
- package/types/asset-usage.d.ts +23 -0
- package/types/asset-view.d.ts +94 -0
- package/types/camera-view.d.ts +45 -0
- package/types/debug.d.ts +14 -0
- package/types/describe.d.ts +43 -0
- package/types/entity-inspector-script.d.ts +87 -0
- package/types/frame-graph-view.d.ts +155 -0
- package/types/hierarchy-view.d.ts +172 -0
- package/types/index.d.ts +3 -0
- package/types/input/fly-controller.d.ts +42 -0
- package/types/input/input.d.ts +192 -0
- package/types/input/math.d.ts +1 -0
- package/types/input/orbit-controller.d.ts +63 -0
- package/types/input/pose.d.ts +126 -0
- package/types/inspector.d.ts +1304 -0
- package/types/instance-survey.d.ts +35 -0
- package/types/list-view.d.ts +151 -0
- package/types/material-view.d.ts +63 -0
- package/types/memory-view.d.ts +95 -0
- package/types/mesh-view.d.ts +89 -0
- package/types/model.d.ts +104 -0
- package/types/node-model.d.ts +54 -0
- package/types/physics-debug.d.ts +254 -0
- package/types/physics-view.d.ts +81 -0
- package/types/picker/picker.d.ts +255 -0
- package/types/picker/render-pass-picker.d.ts +47 -0
- package/types/property-view.d.ts +189 -0
- package/types/render-target-view.d.ts +98 -0
- package/types/renderers/texture-renderer-shaders.d.ts +9 -0
- package/types/renderers/texture-renderer.d.ts +231 -0
- package/types/renderers/wire-renderer.d.ts +347 -0
- package/types/script-view.d.ts +56 -0
- package/types/shader-view.d.ts +46 -0
- package/types/styles.d.ts +22 -0
- package/types/texture-view.d.ts +30 -0
- package/types/tooltip.d.ts +17 -0
- package/types/viewport-tools.d.ts +237 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds to the Used by section of an asset what uses its resource directly, and for a container,
|
|
3
|
+
* which of its contents are in use: a container itself is rarely referenced, while the renders,
|
|
4
|
+
* materials and animations made of its file are.
|
|
5
|
+
*
|
|
6
|
+
* @param {PropertySection} section - The asset's Used by section.
|
|
7
|
+
* @param {Asset} asset - The asset.
|
|
8
|
+
* @param {AppBase} app - The app.
|
|
9
|
+
*/
|
|
10
|
+
export function pushResourceUsage(section: PropertySection, asset: Asset, app: AppBase): void;
|
|
11
|
+
/**
|
|
12
|
+
* What uses an asset's resource directly, handed over without the asset: the anim layers playing
|
|
13
|
+
* an animation's track, the mesh instances drawing with a material, and the materials sampling a
|
|
14
|
+
* texture. The components referencing the asset itself are found separately, by
|
|
15
|
+
* {@link assetUsers}.
|
|
16
|
+
*
|
|
17
|
+
* @param {AppBase} app - The app.
|
|
18
|
+
* @param {Asset} asset - The asset.
|
|
19
|
+
* @returns {Described[]} One entry per user.
|
|
20
|
+
*/
|
|
21
|
+
export function resourceUsers(app: AppBase, asset: Asset): Described[];
|
|
22
|
+
import type { PropertySection } from './model.js';
|
|
23
|
+
import type { Described } from './describe.js';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** The orders the list can be sorted in, as selector options. */
|
|
2
|
+
export const ASSET_SORTS: string[][];
|
|
3
|
+
/**
|
|
4
|
+
* One row per asset in the registry, dimmed while it is not loaded. The sub-assets of a container
|
|
5
|
+
* follow it, indented and bracketed with it, in the order the container keeps them, whatever the
|
|
6
|
+
* sort; the rest of the list is sorted as asked.
|
|
7
|
+
*
|
|
8
|
+
* @param {AssetRegistry|null} registry - The registry.
|
|
9
|
+
* @param {string} sort - The order to list them in.
|
|
10
|
+
* @returns {ListRow[]} The rows.
|
|
11
|
+
*/
|
|
12
|
+
export function assetRows(registry: Asset | null, sort: string): ListRow[];
|
|
13
|
+
/**
|
|
14
|
+
* The components referencing an asset, found by walking the scene: neither the asset nor the
|
|
15
|
+
* registry tracks who uses it.
|
|
16
|
+
*
|
|
17
|
+
* @param {AppBase} app - The app.
|
|
18
|
+
* @param {Asset} asset - The asset.
|
|
19
|
+
* @returns {{ entity: Entity, name: string, property: string }[]} One entry per referencing property.
|
|
20
|
+
*/
|
|
21
|
+
export function assetUsers(app: Asset, asset: Asset): {
|
|
22
|
+
entity: Asset;
|
|
23
|
+
name: string;
|
|
24
|
+
property: string;
|
|
25
|
+
}[];
|
|
26
|
+
/**
|
|
27
|
+
* Everything the property view shows for an asset: where it came from, the resources it loaded
|
|
28
|
+
* into (linked), the components using it (linked), and every other public property.
|
|
29
|
+
*
|
|
30
|
+
* @param {Asset} asset - The asset.
|
|
31
|
+
* @param {{ app: AppBase }} ctx - The app, to find the asset's users.
|
|
32
|
+
* @returns {PropertySection[]} The sections.
|
|
33
|
+
*/
|
|
34
|
+
export function buildAssetModel(asset: Asset, ctx: {
|
|
35
|
+
app: Asset;
|
|
36
|
+
}): PropertySection[];
|
|
37
|
+
/**
|
|
38
|
+
* Every asset in the registry, in the requested order. Assets with no file sort last by size, and
|
|
39
|
+
* ties fall back to the name so the list does not jitter between refreshes.
|
|
40
|
+
*
|
|
41
|
+
* @param {AssetRegistry|null} registry - The registry.
|
|
42
|
+
* @param {string} [sort] - One of {@link ASSET_SORTS}.
|
|
43
|
+
* @returns {Asset[]} The assets.
|
|
44
|
+
*/
|
|
45
|
+
export function collectAssets(registry: Asset | null, sort?: string): Asset[];
|
|
46
|
+
/**
|
|
47
|
+
* The sub-assets of the loaded containers in a registry. A container asset adds the render,
|
|
48
|
+
* material, animation and gsplat assets it creates to the registry and keeps them on its resource,
|
|
49
|
+
* along with the texture assets it loads, and the model asset once something has asked for it. So
|
|
50
|
+
* the link from a sub-asset to its container is read from the container, not guessed from names,
|
|
51
|
+
* which the textures do not carry. A sub-asset shared by several containers belongs to the first.
|
|
52
|
+
*
|
|
53
|
+
* @param {AssetRegistry|null} registry - The registry.
|
|
54
|
+
* @returns {{ parentOf: Map<Asset, Asset>, parts: Map<Asset, [string, Asset[]][]> }} The container of
|
|
55
|
+
* each sub-asset, and the sub-assets of each container by kind.
|
|
56
|
+
*/
|
|
57
|
+
export function containerParts(registry: Asset | null): {
|
|
58
|
+
parentOf: Map<Asset, Asset>;
|
|
59
|
+
parts: Map<Asset, [string, Asset[]][]>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Describes the value of an asset-referencing property, resolving ids through the registry so the
|
|
63
|
+
* row links to the asset rather than showing a bare number. Arrays are expanded entry by entry.
|
|
64
|
+
*
|
|
65
|
+
* @param {*} value - An asset, an id, an array of either, or nothing.
|
|
66
|
+
* @param {AssetRegistry|null} registry - The registry to resolve ids in.
|
|
67
|
+
* @returns {Described} The described value.
|
|
68
|
+
*/
|
|
69
|
+
export function describeAssetValue(value: any, registry: Asset | null): Described;
|
|
70
|
+
/**
|
|
71
|
+
* Appends one row per asset-referencing property of a component, with ids resolved to the assets
|
|
72
|
+
* they name.
|
|
73
|
+
*
|
|
74
|
+
* @param {PropertySection} section - The section to append to.
|
|
75
|
+
* @param {Component} component - The component.
|
|
76
|
+
* @returns {string[]} The property names handled, to leave out of the reflected rows.
|
|
77
|
+
*/
|
|
78
|
+
export function pushAssetRows(section: PropertySection, component: Asset): string[];
|
|
79
|
+
/**
|
|
80
|
+
* The asset each loaded resource came from, so a panel showing a resource can name its source.
|
|
81
|
+
* An asset can produce several resources, such as the faces of a cubemap.
|
|
82
|
+
*
|
|
83
|
+
* @param {AssetRegistry|null} registry - The registry.
|
|
84
|
+
* @returns {Map<object, Asset>} The asset by resource.
|
|
85
|
+
*/
|
|
86
|
+
export function resourceAssets(registry: Asset | null): Map<object, Asset>;
|
|
87
|
+
/**
|
|
88
|
+
* @param {Asset} asset - An asset.
|
|
89
|
+
* @returns {string} Its load state.
|
|
90
|
+
*/
|
|
91
|
+
export function stateName(asset: Asset): string;
|
|
92
|
+
import type { ListRow } from './list-view.js';
|
|
93
|
+
import type { PropertySection } from './model.js';
|
|
94
|
+
import type { Described } from './describe.js';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the Cameras tab offers on a camera, supplied by the inspector.
|
|
3
|
+
*/
|
|
4
|
+
export type CameraActions = {
|
|
5
|
+
/**
|
|
6
|
+
* - Flies the camera.
|
|
7
|
+
*/
|
|
8
|
+
fly: (camera: PROJECTION_ORTHOGRAPHIC) => void;
|
|
9
|
+
/**
|
|
10
|
+
* - The camera being flown, if any.
|
|
11
|
+
*/
|
|
12
|
+
flying: PROJECTION_ORTHOGRAPHIC | null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Everything the property view shows for a camera: where and how it draws, the layers it renders,
|
|
16
|
+
* its render mode, and a button to fly it.
|
|
17
|
+
*
|
|
18
|
+
* @param {CameraComponent} camera - The camera.
|
|
19
|
+
* @param {{ app: AppBase, cameraActions: CameraActions }} ctx - The app, and what the tab offers.
|
|
20
|
+
* @returns {PropertySection[]} The sections.
|
|
21
|
+
*/
|
|
22
|
+
export function buildCameraModel(camera: PROJECTION_ORTHOGRAPHIC, ctx: {
|
|
23
|
+
app: PROJECTION_ORTHOGRAPHIC;
|
|
24
|
+
cameraActions: CameraActions;
|
|
25
|
+
}): PropertySection[];
|
|
26
|
+
/**
|
|
27
|
+
* One row per camera, in render order, dimmed when it does not render.
|
|
28
|
+
*
|
|
29
|
+
* @param {AppBase} app - The app.
|
|
30
|
+
* @param {CameraComponent|null} flying - The camera being flown, if any.
|
|
31
|
+
* @returns {ListRow[]} The rows.
|
|
32
|
+
*/
|
|
33
|
+
export function cameraRows(app: PROJECTION_ORTHOGRAPHIC, flying: PROJECTION_ORTHOGRAPHIC | null): ListRow[];
|
|
34
|
+
/**
|
|
35
|
+
* Every camera component of the hierarchy, disabled ones included, in the order they render: by
|
|
36
|
+
* priority, then in hierarchy order.
|
|
37
|
+
*
|
|
38
|
+
* @param {AppBase} app - The app.
|
|
39
|
+
* @returns {CameraComponent[]} The cameras.
|
|
40
|
+
*/
|
|
41
|
+
export function collectCameras(app: PROJECTION_ORTHOGRAPHIC): PROJECTION_ORTHOGRAPHIC[];
|
|
42
|
+
import { isScreenCamera } from './viewport-tools.js';
|
|
43
|
+
import type { PropertySection } from './model.js';
|
|
44
|
+
import type { ListRow } from './list-view.js';
|
|
45
|
+
export { isScreenCamera };
|
package/types/debug.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export namespace Debug {
|
|
2
|
+
export function assert(): void;
|
|
3
|
+
export { warnOnce };
|
|
4
|
+
export { warnOnce as errorOnce };
|
|
5
|
+
}
|
|
6
|
+
export namespace DebugGraphics {
|
|
7
|
+
function pushGpuMarker(): void;
|
|
8
|
+
function popGpuMarker(): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} message - The message.
|
|
12
|
+
*/
|
|
13
|
+
declare function warnOnce(message: string): void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A value rendered by the property view.
|
|
3
|
+
*/
|
|
4
|
+
export type Described = object;
|
|
5
|
+
/**
|
|
6
|
+
* Lists the public properties of an object: accessors with a getter found on its prototype chain
|
|
7
|
+
* (most derived class first, in declaration order), followed by its own enumerable data fields.
|
|
8
|
+
* Names starting with an underscore, methods and anything in `skip` are left out.
|
|
9
|
+
*
|
|
10
|
+
* @param {object} obj - The object to reflect on.
|
|
11
|
+
* @param {object[]} stopPrototypes - Prototypes at which to stop walking the chain. These and
|
|
12
|
+
* anything above them are not searched.
|
|
13
|
+
* @param {string[]} [skip] - Property names to leave out.
|
|
14
|
+
* @returns {string[]} The property names.
|
|
15
|
+
*/
|
|
16
|
+
export function collectProperties(obj: object, stopPrototypes: object[], skip?: string[]): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Summarizes a value for display. Engine types get a purpose-built one-line summary; nodes come
|
|
19
|
+
* back with a `target` so the UI can link to them; arrays, sets and maps expand their first
|
|
20
|
+
* entries into `items` at the top level only.
|
|
21
|
+
*
|
|
22
|
+
* @param {*} value - The value to describe.
|
|
23
|
+
* @param {number} [depth] - The nesting depth. Nested values are kept to a short type name.
|
|
24
|
+
* @returns {Described} The description.
|
|
25
|
+
*/
|
|
26
|
+
export function describeValue(value: any, depth?: number): Described;
|
|
27
|
+
/**
|
|
28
|
+
* Formats a number compactly: integers as they are, everything else to four decimals with the
|
|
29
|
+
* trailing zeros removed (so float noise like 1.8e-15 reads as 0), and huge magnitudes in
|
|
30
|
+
* exponent form.
|
|
31
|
+
*
|
|
32
|
+
* @param {number} n - The number.
|
|
33
|
+
* @returns {string} The formatted number.
|
|
34
|
+
*/
|
|
35
|
+
export function formatNumber(n: number): string;
|
|
36
|
+
/**
|
|
37
|
+
* The engine does not export `UniformBuffer`, so a uniform buffer is recognized by its shape: a
|
|
38
|
+
* uniform buffer format, and the persistent flag only uniform buffers carry.
|
|
39
|
+
*
|
|
40
|
+
* @param {*} value - A value.
|
|
41
|
+
* @returns {boolean} Whether it is a uniform buffer.
|
|
42
|
+
*/
|
|
43
|
+
export function isUniformBuffer(value: any): boolean;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosts an {@link Inspector} on an entity, so the debug panel can be added to a project from the
|
|
3
|
+
* Editor like any other script. Attach it to a dedicated entity at the root; the panel appears
|
|
4
|
+
* when the script initializes and goes away with it.
|
|
5
|
+
*
|
|
6
|
+
* ```javascript
|
|
7
|
+
* import { EntityInspector } from '@playcanvas/inspector';
|
|
8
|
+
*
|
|
9
|
+
* const entity = new Entity('inspector');
|
|
10
|
+
* entity.addComponent('script');
|
|
11
|
+
* entity.script.create(EntityInspector, {
|
|
12
|
+
* properties: { dock: 'left', visible: false }
|
|
13
|
+
* });
|
|
14
|
+
* app.root.addChild(entity);
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The hosting entity and its ancestors get no enabled checkbox in the hierarchy, so the panel
|
|
18
|
+
* cannot switch itself off. Everything else is the {@link Inspector} API, reachable through
|
|
19
|
+
* {@link EntityInspector#inspector}.
|
|
20
|
+
*/
|
|
21
|
+
export class EntityInspector {
|
|
22
|
+
static scriptName: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the panel is shown. Toggled by {@link toggleKey}.
|
|
25
|
+
*
|
|
26
|
+
* @attribute
|
|
27
|
+
* @type {boolean}
|
|
28
|
+
*/
|
|
29
|
+
visible: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The side of the viewport the panel docks to.
|
|
32
|
+
*
|
|
33
|
+
* @attribute
|
|
34
|
+
* @type {'left'|'right'}
|
|
35
|
+
*/
|
|
36
|
+
dock: "left" | "right";
|
|
37
|
+
/**
|
|
38
|
+
* The width of the docked panel in CSS pixels.
|
|
39
|
+
*
|
|
40
|
+
* @attribute
|
|
41
|
+
* @type {number}
|
|
42
|
+
* @range [240, 1600]
|
|
43
|
+
*/
|
|
44
|
+
width: number;
|
|
45
|
+
/**
|
|
46
|
+
* A gap left above the panel in CSS pixels, to keep it clear of other overlays.
|
|
47
|
+
*
|
|
48
|
+
* @attribute
|
|
49
|
+
* @type {number}
|
|
50
|
+
* @range [0, 400]
|
|
51
|
+
*/
|
|
52
|
+
top: number;
|
|
53
|
+
/**
|
|
54
|
+
* The `KeyboardEvent.code` or `key` that shows and hides the panel. Empty disables the key.
|
|
55
|
+
*
|
|
56
|
+
* @attribute
|
|
57
|
+
* @type {string}
|
|
58
|
+
*/
|
|
59
|
+
toggleKey: string;
|
|
60
|
+
/**
|
|
61
|
+
* The key that pauses and resumes the app. Empty disables the key.
|
|
62
|
+
*
|
|
63
|
+
* @attribute
|
|
64
|
+
* @type {string}
|
|
65
|
+
*/
|
|
66
|
+
pauseKey: string;
|
|
67
|
+
/**
|
|
68
|
+
* The key that advances one frame while paused. Empty disables the key.
|
|
69
|
+
*
|
|
70
|
+
* @attribute
|
|
71
|
+
* @type {string}
|
|
72
|
+
*/
|
|
73
|
+
stepKey: string;
|
|
74
|
+
/**
|
|
75
|
+
* @type {Inspector|null}
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
private _inspector;
|
|
79
|
+
/**
|
|
80
|
+
* The inspector this script hosts, or null before the script initializes.
|
|
81
|
+
*
|
|
82
|
+
* @type {Inspector|null}
|
|
83
|
+
*/
|
|
84
|
+
get inspector(): Inspector | null;
|
|
85
|
+
initialize(): void;
|
|
86
|
+
}
|
|
87
|
+
import { Inspector } from './inspector.js';
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One pass of a captured frame.
|
|
3
|
+
*/
|
|
4
|
+
export type PassEntry = object;
|
|
5
|
+
/**
|
|
6
|
+
* The frame graph of one frame, flattened.
|
|
7
|
+
*/
|
|
8
|
+
export type FrameSnapshot = object;
|
|
9
|
+
/**
|
|
10
|
+
* The mesh instances a layer step submitted in one frame, in draw order.
|
|
11
|
+
*/
|
|
12
|
+
export type VisibleList = object;
|
|
13
|
+
/**
|
|
14
|
+
* The context the pass model needs besides the pass.
|
|
15
|
+
*/
|
|
16
|
+
export type PassModelContext = object;
|
|
17
|
+
/**
|
|
18
|
+
* What the pass and step models need to show a debug frame: the draw it stops at, and how to
|
|
19
|
+
* choose another.
|
|
20
|
+
*/
|
|
21
|
+
export type DebugFrameContext = object;
|
|
22
|
+
/** How many mesh instances a page of a layer step shows. */
|
|
23
|
+
export const INSTANCES_PER_PAGE: 200;
|
|
24
|
+
/** @import { AppBase } from 'playcanvas' */
|
|
25
|
+
/** @import { GraphicsDevice } from 'playcanvas' */
|
|
26
|
+
/** @import { RenderTarget } from 'playcanvas' */
|
|
27
|
+
/** @import { Described } from './describe.js' */
|
|
28
|
+
/** @import { ListRow } from './list-view.js' */
|
|
29
|
+
/** @import { PropertyRow, PropertySection } from './model.js' */
|
|
30
|
+
/** @import { MeshInstance } from 'playcanvas' */
|
|
31
|
+
/**
|
|
32
|
+
* One pass of a captured frame.
|
|
33
|
+
*
|
|
34
|
+
* @typedef {object} PassEntry
|
|
35
|
+
* @ignore
|
|
36
|
+
* @property {FramePass} pass - The pass.
|
|
37
|
+
* @property {number} index - The position in execution order.
|
|
38
|
+
* @property {string} key - A key stable across frames for passes that are recreated each frame.
|
|
39
|
+
* @property {number} depth - How many passes own this one, through their before and after passes or
|
|
40
|
+
* as the children of a multi-view pass.
|
|
41
|
+
* @property {FramePass|null} parent - The pass owning this one, if any.
|
|
42
|
+
* @property {number} children - The number of passes this one owns directly.
|
|
43
|
+
* @property {number} views - The XR views the pass is replicated for, or 0 outside multi-view.
|
|
44
|
+
* @property {RenderTarget|null|undefined} renderTarget - The target the pass renders to, with the
|
|
45
|
+
* backbuffer resolved to the device's backbuffer object; undefined for passes that render nothing.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* The frame graph of one frame, flattened.
|
|
49
|
+
*
|
|
50
|
+
* @typedef {object} FrameSnapshot
|
|
51
|
+
* @ignore
|
|
52
|
+
* @property {PassEntry[]} entries - The passes in execution order.
|
|
53
|
+
* @property {Map<RenderTarget, PassEntry[]>} usage - The passes rendering into each target.
|
|
54
|
+
* @property {Map<string, number>} nameCounts - How many passes share each profiler name.
|
|
55
|
+
* @property {Map<string, number>|null} timings - GPU time per profiler name, when profiling is on.
|
|
56
|
+
* @property {number|undefined} frameTime - The GPU time of the whole frame, when known.
|
|
57
|
+
* @property {Map<object, VisibleList|null>} visible - What each layer step of a forward pass drew,
|
|
58
|
+
* by step, or null when its camera has not culled the layer.
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* The mesh instances a layer step submitted in one frame, in draw order.
|
|
62
|
+
*
|
|
63
|
+
* @typedef {object} VisibleList
|
|
64
|
+
* @ignore
|
|
65
|
+
* @property {MeshInstance[]} instances - The instances, after culling, the transparency split and
|
|
66
|
+
* sorting, including any debug lines the immediate renderer added.
|
|
67
|
+
* @property {number} drawn - How many were actually drawn, leaving out {@link skipped}.
|
|
68
|
+
* @property {Set<MeshInstance>} skipped - Instances the forward renderer passes over: masked out of
|
|
69
|
+
* the step's shader pass, or instanced with no instances and no draw commands.
|
|
70
|
+
* @property {Set<MeshInstance>} debugLines - Instances that are batches of debug lines.
|
|
71
|
+
*/
|
|
72
|
+
/**
|
|
73
|
+
* The context the pass model needs besides the pass.
|
|
74
|
+
*
|
|
75
|
+
* @typedef {object} PassModelContext
|
|
76
|
+
* @ignore
|
|
77
|
+
* @property {GraphicsDevice} device - The device.
|
|
78
|
+
* @property {FrameSnapshot|null} frame - The captured frame.
|
|
79
|
+
* @property {string|null} [passKey] - The list key of the pass, to keep its pages apart from others.
|
|
80
|
+
* @property {Map<string, number>} [pages] - The page shown for each layer step, kept across refreshes.
|
|
81
|
+
* @property {string} [filter] - A lower-cased filter the listed instances must match by node name.
|
|
82
|
+
* @property {boolean} [stable] - Whether the app is paused or the frame frozen, so pages hold still.
|
|
83
|
+
* @property {DebugFrameContext|null} [debug] - The debug frame, when it is on.
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* What the pass and step models need to show a debug frame: the draw it stops at, and how to
|
|
87
|
+
* choose another.
|
|
88
|
+
*
|
|
89
|
+
* @typedef {object} DebugFrameContext
|
|
90
|
+
* @ignore
|
|
91
|
+
* @property {string|null} stepKey - The list key of the layer step the frame stops in.
|
|
92
|
+
* @property {number} index - The draw it stops at, in that step's list.
|
|
93
|
+
* @property {MeshInstance|null} instance - The instance drawn last.
|
|
94
|
+
* @property {(stepKey: string, index: number, instance: MeshInstance) => void} choose - Makes an
|
|
95
|
+
* instance the last one drawn.
|
|
96
|
+
*/
|
|
97
|
+
/**
|
|
98
|
+
* What a layer step row of the pass list selects: one step of a forward pass, rather than the pass.
|
|
99
|
+
*
|
|
100
|
+
* @ignore
|
|
101
|
+
*/
|
|
102
|
+
export class LayerStepSelection {
|
|
103
|
+
/**
|
|
104
|
+
* @param {RenderPassForward} pass - The forward pass the step belongs to.
|
|
105
|
+
* @param {*} step - The layer render step.
|
|
106
|
+
* @param {number} index - The step's index within the pass.
|
|
107
|
+
*/
|
|
108
|
+
constructor(pass: RenderPassForward, step: any, index: number);
|
|
109
|
+
pass: RenderPassForward;
|
|
110
|
+
step: any;
|
|
111
|
+
index: number;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Everything the property view shows for a pass: identity and structure, the render target and
|
|
115
|
+
* its attachment ops as the trace prints them, the layer steps of a forward pass, and every other
|
|
116
|
+
* public property the pass class exposes.
|
|
117
|
+
*
|
|
118
|
+
* @param {FramePass} pass - The pass.
|
|
119
|
+
* @param {PassModelContext} ctx - The device, the frame the pass was captured in, and the paging
|
|
120
|
+
* state of its layer steps.
|
|
121
|
+
* @returns {PropertySection[]} The sections.
|
|
122
|
+
*/
|
|
123
|
+
export function buildPassModel(pass: FramePass, ctx: PassModelContext): PropertySection[];
|
|
124
|
+
/**
|
|
125
|
+
* Everything the property view shows for one layer step of a forward pass: the camera and layer it
|
|
126
|
+
* renders, what it clears, and the instances it drew in draw order, listed straight away and paged
|
|
127
|
+
* the same way as under the pass, sharing the page.
|
|
128
|
+
*
|
|
129
|
+
* @param {LayerStepSelection} selection - The step and its pass.
|
|
130
|
+
* @param {PassModelContext} ctx - The frame the step was captured in, and the paging state, where
|
|
131
|
+
* `passKey` is the key of the step's own row.
|
|
132
|
+
* @returns {PropertySection[]} The sections.
|
|
133
|
+
*/
|
|
134
|
+
export function buildStepModel(selection: LayerStepSelection, ctx: PassModelContext): PropertySection[];
|
|
135
|
+
/**
|
|
136
|
+
* Walks the frame graph the app rendered last and flattens it into execution order, the same
|
|
137
|
+
* order the render pass trace prints. Wrapper passes are recognized through their before, after and
|
|
138
|
+
* multi-view child lists so their members can be indented.
|
|
139
|
+
*
|
|
140
|
+
* @param {AppBase} app - The app.
|
|
141
|
+
* @returns {FrameSnapshot} The snapshot.
|
|
142
|
+
*/
|
|
143
|
+
export function captureFrameGraph(app: FramePass): FrameSnapshot;
|
|
144
|
+
/**
|
|
145
|
+
* Turns a snapshot into list rows: one per pass, plus one per layer step of a forward pass and one
|
|
146
|
+
* naming the light of a shadow pass. Render target cells link to the target, camera and light
|
|
147
|
+
* cells link to their entities.
|
|
148
|
+
*
|
|
149
|
+
* @param {FrameSnapshot} frame - The snapshot.
|
|
150
|
+
* @param {GraphicsDevice} device - The device.
|
|
151
|
+
* @returns {ListRow[]} The rows.
|
|
152
|
+
*/
|
|
153
|
+
export function passRows(frame: FrameSnapshot, device: FramePass): ListRow[];
|
|
154
|
+
import type { PropertySection } from './model.js';
|
|
155
|
+
import type { ListRow } from './list-view.js';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the hierarchy filter matches its text against: a node's name, the type of one of its
|
|
3
|
+
* components, or the name of one of its scripts.
|
|
4
|
+
*/
|
|
5
|
+
export type FilterBy = "name" | "component" | "script";
|
|
6
|
+
export type HierarchyEntry = object;
|
|
7
|
+
/**
|
|
8
|
+
* A tree view over a {@link GraphNode} hierarchy. Rows are keyed by node and reconciled in place on
|
|
9
|
+
* every refresh, so the expansion state, the selection and the scroll position survive the scene
|
|
10
|
+
* changing underneath. Collapsed subtrees are not materialized, which keeps large scenes cheap.
|
|
11
|
+
*
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
export class HierarchyView {
|
|
15
|
+
/**
|
|
16
|
+
* @param {HTMLElement} container - The element to render into.
|
|
17
|
+
* @param {(node: GraphNode|null) => void} onSelect - The selection callback.
|
|
18
|
+
*/
|
|
19
|
+
constructor(container: HTMLElement, onSelect: (node: Entity | null) => void);
|
|
20
|
+
/**
|
|
21
|
+
* The element the tree is rendered into.
|
|
22
|
+
*
|
|
23
|
+
* @type {HTMLElement}
|
|
24
|
+
*/
|
|
25
|
+
container: HTMLElement;
|
|
26
|
+
/**
|
|
27
|
+
* Called with the newly selected node, or null when the selection is cleared.
|
|
28
|
+
*
|
|
29
|
+
* @type {(node: GraphNode|null) => void}
|
|
30
|
+
*/
|
|
31
|
+
onSelect: (node: Entity | null) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Called after a node's enabled flag was flipped from its checkbox.
|
|
34
|
+
*
|
|
35
|
+
* @type {((node: GraphNode) => void)|undefined}
|
|
36
|
+
*/
|
|
37
|
+
onToggle: ((node: Entity) => void) | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Decides which nodes get no enabled checkbox. Defaults to none.
|
|
40
|
+
*
|
|
41
|
+
* @type {(node: GraphNode) => boolean}
|
|
42
|
+
*/
|
|
43
|
+
isLocked: (node: Entity) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The root of the rendered hierarchy.
|
|
46
|
+
*
|
|
47
|
+
* @type {GraphNode|null}
|
|
48
|
+
*/
|
|
49
|
+
root: Entity | null;
|
|
50
|
+
/**
|
|
51
|
+
* The selected node.
|
|
52
|
+
*
|
|
53
|
+
* @type {GraphNode|null}
|
|
54
|
+
*/
|
|
55
|
+
selected: Entity | null;
|
|
56
|
+
/**
|
|
57
|
+
* Case-insensitive filter text. Nodes that match, and their ancestors, stay visible.
|
|
58
|
+
*
|
|
59
|
+
* @type {string}
|
|
60
|
+
*/
|
|
61
|
+
filter: string;
|
|
62
|
+
/**
|
|
63
|
+
* What the filter text matches: node names, component types or script names.
|
|
64
|
+
*
|
|
65
|
+
* @type {FilterBy}
|
|
66
|
+
*/
|
|
67
|
+
filterBy: FilterBy;
|
|
68
|
+
/**
|
|
69
|
+
* The number of nodes in the hierarchy as of the last refresh.
|
|
70
|
+
*
|
|
71
|
+
* @type {number}
|
|
72
|
+
*/
|
|
73
|
+
nodeCount: number;
|
|
74
|
+
/**
|
|
75
|
+
* The number of entities in the hierarchy as of the last refresh.
|
|
76
|
+
*
|
|
77
|
+
* @type {number}
|
|
78
|
+
*/
|
|
79
|
+
entityCount: number;
|
|
80
|
+
/**
|
|
81
|
+
* @type {Map<GraphNode, HierarchyEntry>}
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
private _entries;
|
|
85
|
+
/**
|
|
86
|
+
* @type {WeakSet<GraphNode>}
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
private _expanded;
|
|
90
|
+
/**
|
|
91
|
+
* @type {Set<GraphNode>}
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
private _seen;
|
|
95
|
+
/**
|
|
96
|
+
* The number of nodes below each node, counted on every refresh.
|
|
97
|
+
*
|
|
98
|
+
* @type {Map<GraphNode, number>}
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
private _descendants;
|
|
102
|
+
/**
|
|
103
|
+
* Replaces the hierarchy being shown.
|
|
104
|
+
*
|
|
105
|
+
* @param {GraphNode|null} root - The new root.
|
|
106
|
+
*/
|
|
107
|
+
setRoot(root: Entity | null): void;
|
|
108
|
+
/**
|
|
109
|
+
* Counts the nodes of a subtree, recording for each node how many are below it, and totals
|
|
110
|
+
* the nodes and entities of the hierarchy on the way.
|
|
111
|
+
*
|
|
112
|
+
* @param {GraphNode} node - The root of the subtree.
|
|
113
|
+
* @returns {number} The number of nodes below it.
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
private _countSubtree;
|
|
117
|
+
/**
|
|
118
|
+
* Synchronizes the rendered tree with the hierarchy.
|
|
119
|
+
*/
|
|
120
|
+
refresh(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Selects a node, expanding its ancestors and scrolling it into view.
|
|
123
|
+
*
|
|
124
|
+
* @param {GraphNode|null} node - The node, or null to clear the selection.
|
|
125
|
+
*/
|
|
126
|
+
select(node: Entity | null): void;
|
|
127
|
+
/**
|
|
128
|
+
* Toggles the expansion of a node.
|
|
129
|
+
*
|
|
130
|
+
* @param {GraphNode} node - The node.
|
|
131
|
+
* @param {boolean} [recursive] - Apply the new state to the whole subtree.
|
|
132
|
+
*/
|
|
133
|
+
toggle(node: Entity, recursive?: boolean): void;
|
|
134
|
+
/**
|
|
135
|
+
* Renders a node and, when expanded or filtering, its subtree.
|
|
136
|
+
*
|
|
137
|
+
* @param {GraphNode} node - The node.
|
|
138
|
+
* @param {number} depth - The depth of the node below the root.
|
|
139
|
+
* @param {string} filter - The lower-cased filter text, empty for none.
|
|
140
|
+
* @returns {boolean} Whether the node or one of its descendants matches the filter.
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
private _visit;
|
|
144
|
+
/**
|
|
145
|
+
* @param {HTMLElement} element - The element.
|
|
146
|
+
* @param {boolean} shown - Whether it is shown.
|
|
147
|
+
* @private
|
|
148
|
+
*/
|
|
149
|
+
private _setDisplay;
|
|
150
|
+
/**
|
|
151
|
+
* @param {GraphNode} node - The node.
|
|
152
|
+
* @returns {HierarchyEntry} The new entry.
|
|
153
|
+
* @private
|
|
154
|
+
*/
|
|
155
|
+
private _createEntry;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The distinct component types or script names in a hierarchy, sorted, to suggest while filtering
|
|
159
|
+
* by them.
|
|
160
|
+
*
|
|
161
|
+
* @param {GraphNode|null} root - The root of the hierarchy.
|
|
162
|
+
* @param {FilterBy} by - What to collect: 'component' or 'script'.
|
|
163
|
+
* @returns {string[]} The values, empty when filtering by name.
|
|
164
|
+
*/
|
|
165
|
+
export function filterSuggestions(root: Entity | null, by: FilterBy): string[];
|
|
166
|
+
/**
|
|
167
|
+
* @param {GraphNode} node - A node.
|
|
168
|
+
* @param {string} text - The lower-cased filter text.
|
|
169
|
+
* @param {FilterBy} by - What the text matches.
|
|
170
|
+
* @returns {boolean} Whether the node matches.
|
|
171
|
+
*/
|
|
172
|
+
export function matchesFilter(node: Entity, text: string, by: FilterBy): boolean;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fly controller. Free flight: `rotate` deltas turn the pose about yaw and pitch, limited by
|
|
3
|
+
* {@link yawRange} and {@link pitchRange}, and `move` deltas translate it along its own right, up
|
|
4
|
+
* and forward axes, so movement follows where the camera looks. Motion is smoothed with
|
|
5
|
+
* {@link rotateDamping} and {@link moveDamping}.
|
|
6
|
+
*
|
|
7
|
+
* @category Input
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export class FlyController extends InputController {
|
|
11
|
+
/**
|
|
12
|
+
* @type {Pose}
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
private _targetPose;
|
|
16
|
+
/**
|
|
17
|
+
* The rotation damping. In the range 0 to 1, where a value of 0 means no damping and 1 means
|
|
18
|
+
* full damping. Default is 0.98.
|
|
19
|
+
*/
|
|
20
|
+
rotateDamping: number;
|
|
21
|
+
/**
|
|
22
|
+
* The movement damping. In the range 0 to 1, where a value of 0 means no damping and 1 means
|
|
23
|
+
* full damping. Default is 0.98.
|
|
24
|
+
*/
|
|
25
|
+
moveDamping: number;
|
|
26
|
+
set pitchRange(value: any);
|
|
27
|
+
get pitchRange(): any;
|
|
28
|
+
set yawRange(value: any);
|
|
29
|
+
get yawRange(): any;
|
|
30
|
+
/**
|
|
31
|
+
* @param {InputFrame<{ move: number[], rotate: number[] }>} frame - The input frame.
|
|
32
|
+
* @param {number} dt - The delta time.
|
|
33
|
+
* @returns {Pose} - The controller pose.
|
|
34
|
+
*/
|
|
35
|
+
update(frame: InputFrame<{
|
|
36
|
+
move: number[];
|
|
37
|
+
rotate: number[];
|
|
38
|
+
}>, dt: number): Pose;
|
|
39
|
+
}
|
|
40
|
+
import { InputController } from './input.js';
|
|
41
|
+
import type { InputFrame } from './input.js';
|
|
42
|
+
import { Pose } from './pose.js';
|