@playcanvas/inspector 0.4.0 → 0.6.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.
@@ -10,6 +10,15 @@ export const ASSET_SORTS: string[][];
10
10
  * @returns {ListRow[]} The rows.
11
11
  */
12
12
  export function assetRows(registry: AssetRegistry | null, sort: string): ListRow[];
13
+ /**
14
+ * What the Assets tab measures in a snapshot: the file of every asset whose size is known, by type.
15
+ * A descriptor from a project manifest gives the size; for a file loaded from a plain url, it is
16
+ * the size the browser timed downloading. The sub-assets of a container are part of its file.
17
+ *
18
+ * @param {AssetRegistry|null} registry - The registry.
19
+ * @returns {SnapshotContent} The files measured.
20
+ */
21
+ export function assetSnapshot(registry: AssetRegistry | null): SnapshotContent;
13
22
  /**
14
23
  * The components referencing an asset, found by walking the scene: neither the asset nor the
15
24
  * registry tracks who uses it.
@@ -93,6 +102,7 @@ export function resourceAssets(registry: AssetRegistry | null): Map<object, Asse
93
102
  export function stateName(asset: Asset): string;
94
103
  import type { AssetRegistry } from 'playcanvas';
95
104
  import type { ListRow } from './list-view.js';
105
+ import type { SnapshotContent } from './snapshot-view.js';
96
106
  import type { AppBase } from 'playcanvas';
97
107
  import { Asset } from 'playcanvas';
98
108
  import type { Entity } from 'playcanvas';
@@ -0,0 +1,136 @@
1
+ /**
2
+ * An image captured from the app, ready to hand to an agent.
3
+ */
4
+ export type CapturedImage = object;
5
+ export type CaptureJob = object;
6
+ /**
7
+ * Captures textures, render target attachments and the canvas into PNG images. A texture is drawn
8
+ * with the shaders of the texture previews into an 8-bit render target the size of the image, and
9
+ * read back, so an encoded or HDR texture, a depth buffer or a float target comes out as the
10
+ * preview shows it. Each capture waits for the next frame: a texture is drawn once the app has
11
+ * rendered it, inside the frame, and the canvas read once the frame is done.
12
+ *
13
+ * @ignore
14
+ */
15
+ export class ImageCapture {
16
+ /**
17
+ * @param {AppBase} app - The app.
18
+ */
19
+ constructor(app: AppBase);
20
+ /**
21
+ * @type {AppBase|null}
22
+ * @private
23
+ */
24
+ private _app;
25
+ /**
26
+ * @type {CaptureJob[]}
27
+ * @private
28
+ */
29
+ private _jobs;
30
+ /**
31
+ * The capture shaders, by mode and encoding.
32
+ *
33
+ * @type {Map<string, Shader>}
34
+ * @private
35
+ */
36
+ private _shaders;
37
+ destroy(): void;
38
+ /**
39
+ * Captures a texture as its preview shows it.
40
+ *
41
+ * @param {Texture} texture - The texture.
42
+ * @param {object} [options] - The options.
43
+ * @param {number} [options.maxSize] - The longest side of the image, at most. Defaults to 512.
44
+ * @param {string} [options.channels] - Three of r, g, b and a, to show stored channels; 'rgb'
45
+ * decodes the texture's encoding. Defaults to 'rgb'.
46
+ * @returns {Promise<CapturedImage>} The image.
47
+ */
48
+ texture(texture: Texture, { maxSize, channels }?: {
49
+ maxSize?: number;
50
+ channels?: string;
51
+ }): Promise<CapturedImage>;
52
+ /**
53
+ * Captures what the canvas shows at the end of the next frame.
54
+ *
55
+ * @param {object} [options] - The options.
56
+ * @param {number} [options.maxSize] - The longest side of the image, at most. Defaults to 1024.
57
+ * @returns {Promise<CapturedImage>} The image.
58
+ */
59
+ canvas({ maxSize }?: {
60
+ maxSize?: number;
61
+ }): Promise<CapturedImage>;
62
+ /**
63
+ * @param {'texture'|'canvas'} kind - What is captured.
64
+ * @param {Texture|null} texture - The texture, for a texture.
65
+ * @param {number} maxSize - The longest side of the image.
66
+ * @param {string} channels - The channels shown.
67
+ * @returns {Promise<CapturedImage>} The image.
68
+ * @private
69
+ */
70
+ private _queue;
71
+ /**
72
+ * @param {CaptureJob} job - A job.
73
+ * @param {Error} error - Why it failed.
74
+ * @private
75
+ */
76
+ private _fail;
77
+ /**
78
+ * @param {CaptureJob} job - A job.
79
+ * @param {CapturedImage} image - The image.
80
+ * @private
81
+ */
82
+ private _done;
83
+ /**
84
+ * @param {string} mode - The sampling mode.
85
+ * @param {string} encoding - The encoding.
86
+ * @returns {Shader} The shader drawing a texture with them over the full-screen quad.
87
+ * @private
88
+ */
89
+ private _shader;
90
+ /**
91
+ * Draws the textures waiting to be captured, once the app has rendered them.
92
+ *
93
+ * @private
94
+ */
95
+ private _onPostRender;
96
+ /**
97
+ * @param {CaptureJob} job - A texture job.
98
+ * @private
99
+ */
100
+ private _captureTexture;
101
+ /**
102
+ * Reads the canvas for the captures waiting for it, now that the frame is done.
103
+ *
104
+ * @private
105
+ */
106
+ private _onFrameEnd;
107
+ }
108
+ /**
109
+ * @param {number} width - The width of the source.
110
+ * @param {number} height - The height of the source.
111
+ * @param {number} maxSize - The longest side wanted, at most.
112
+ * @returns {{ width: number, height: number }} The size of the image: the source's, scaled down to
113
+ * fit, never up.
114
+ */
115
+ export function fitSize(width: number, height: number, maxSize: number): {
116
+ width: number;
117
+ height: number;
118
+ };
119
+ /**
120
+ * How a texture is sampled to show it, the way the texture previews choose, see
121
+ * TextureRenderer#draw, which this follows so a capture looks like the preview.
122
+ *
123
+ * @param {Texture} texture - The texture.
124
+ * @param {GraphicsDevice} device - The device.
125
+ * @param {string} channels - Three of r, g, b and a; 'rgb' decodes the texture's encoding.
126
+ * @returns {{ mode: string, encoding: string, channelIndices: Int32Array }|string} How to sample
127
+ * it, or why it cannot be captured.
128
+ */
129
+ export function textureSampling(texture: Texture, device: GraphicsDevice, channels: string): {
130
+ mode: string;
131
+ encoding: string;
132
+ channelIndices: Int32Array;
133
+ } | string;
134
+ import { Texture } from 'playcanvas';
135
+ import type { AppBase } from 'playcanvas';
136
+ import type { GraphicsDevice } from 'playcanvas';
@@ -45,6 +45,12 @@ export type InspectorOptions = {
45
45
  * the inspector is created. Defaults to false. See {@link Inspector#recording}.
46
46
  */
47
47
  record?: boolean;
48
+ /**
49
+ * - Whether to offer the inspector's tools to AI agents right
50
+ * away, as if the MCP button was pressed. Defaults to false. A setting stored by the button takes
51
+ * precedence. See {@link Inspector#mcp}.
52
+ */
53
+ mcp?: boolean;
48
54
  /**
49
55
  * - Called with the new visibility
50
56
  * whenever the panel is shown or hidden, whether through {@link Inspector#visible}, the toggle key
@@ -54,8 +60,8 @@ export type InspectorOptions = {
54
60
  /**
55
61
  * - The local storage key the panel's settings are kept
56
62
  * under, so they survive a reload or a restart of the app: the physics drawing switch and options,
57
- * the bodies excluded from it (by entity path), the active tab, the panel width, the GPU
58
- * timings switch, and on the Performance tab the script timing switch, whether the CPU chart
63
+ * the bodies excluded from it (by entity path), the active tab, the panel width, the MCP switch,
64
+ * the GPU timings switch, and on the Performance tab the script timing switch, whether the CPU chart
59
65
  * includes the inspector's time, the charts collapsed and lines hidden, and the script types the
60
66
  * Scripts chart shows. Stored settings take
61
67
  * precedence over the defaults given here. Defaults to
@@ -178,6 +184,14 @@ export type InspectorPhysicsDrawOptions = {
178
184
  * @category Debug
179
185
  */
180
186
  export class Inspector {
187
+ /**
188
+ * Whether the browser has WebMCP, through which agents running in the browser find the tools
189
+ * of {@link Inspector#mcp}. Without it, the tools are still offered through
190
+ * {@link Inspector#executeTool}.
191
+ *
192
+ * @type {boolean}
193
+ */
194
+ static get webMcpSupported(): boolean;
181
195
  /**
182
196
  * @returns {Storage|null} The window's local storage, or null where there is none or reading
183
197
  * it throws, as in some sandboxed frames.
@@ -356,7 +370,9 @@ export class Inspector {
356
370
  /** @private */
357
371
  private _nextPropertyRefresh;
358
372
  /**
359
- * @type {'hierarchy'|'cameras'|'assets'|'passes'|'perf'|'targets'|'textures'|'meshes'|'materials'|'scripts'|'memory'|'shaders'|'physics'}
373
+ * The tab shown: one of the fixed tabs, or a treemap tab, by its id.
374
+ *
375
+ * @type {'hierarchy'|'cameras'|'layers'|'assets'|'passes'|'perf'|'targets'|'textures'|'meshes'|'materials'|'scripts'|'memory'|'shaders'|'physics'|`treemap${number}`}
360
376
  * @private
361
377
  */
362
378
  private _tab;
@@ -567,6 +583,70 @@ export class Inspector {
567
583
  * @private
568
584
  */
569
585
  private _cameraList;
586
+ /**
587
+ * @type {ListView}
588
+ * @private
589
+ */
590
+ private _layerList;
591
+ /**
592
+ * The layers hidden from the Layers tab, each turned off until shown again, reset or the panel
593
+ * closes. A layer the app turns back on itself meanwhile is left to it.
594
+ *
595
+ * @type {Set<Layer>}
596
+ * @private
597
+ */
598
+ private _hiddenLayers;
599
+ /**
600
+ * The snapshots captured on each tab that takes them, kept here rather than with the panel's
601
+ * elements, which are built again when the panel docks back from its own window.
602
+ *
603
+ * @type {Map<string, SnapshotList>}
604
+ * @private
605
+ */
606
+ private _snapshots;
607
+ /**
608
+ * The snapshots section of each tab that takes them, by tab.
609
+ *
610
+ * @type {Record<string, SnapshotPanel>}
611
+ * @private
612
+ */
613
+ private _snapshotPanels;
614
+ /**
615
+ * The treemap tabs open, by id, each showing a snapshot or two compared, with the tab the
616
+ * snapshots came from. Kept here, so the tabs are built again with the panel.
617
+ *
618
+ * @type {Map<string, { source: string, key: string, data: TreemapData, view: TreemapView|null }>}
619
+ * @private
620
+ */
621
+ private _treemapTabs;
622
+ /**
623
+ * The number the id of the next treemap tab takes.
624
+ *
625
+ * @type {number}
626
+ * @private
627
+ */
628
+ private _nextTreemap;
629
+ /**
630
+ * The tab bar.
631
+ *
632
+ * @type {HTMLElement}
633
+ * @private
634
+ */
635
+ private _tabsEl;
636
+ /**
637
+ * The body of the panel: the tabs over the properties.
638
+ *
639
+ * @type {HTMLElement}
640
+ * @private
641
+ */
642
+ private _bodyEl;
643
+ /**
644
+ * The button on the Layers tab that shows the hidden layers again.
645
+ *
646
+ * @type {HTMLButtonElement}
647
+ * @private
648
+ */
649
+ private _showLayersBtn;
570
650
  /**
571
651
  * The render mode applied from the Cameras tab.
572
652
  *
@@ -750,6 +830,14 @@ export class Inspector {
750
830
  * @private
751
831
  */
752
832
  private _cameraModel;
833
+ /**
834
+ * Model builder for the property view when a layer is selected.
835
+ *
836
+ * @param {Layer} layer - The layer.
837
+ * @returns {PropertySection[]} The sections.
838
+ * @private
839
+ */
840
+ private _layerModel;
753
841
  /**
754
842
  * Model builder for the property view when a script class is selected.
755
843
  *
@@ -874,6 +962,66 @@ export class Inspector {
874
962
  * @private
875
963
  */
876
964
  private _storageKey;
965
+ /**
966
+ * Whether the tools are offered to agents, see {@link Inspector#mcp}.
967
+ *
968
+ * @type {boolean}
969
+ * @private
970
+ */
971
+ private _mcp;
972
+ /**
973
+ * Aborted to withdraw the tools registered with WebMCP.
974
+ *
975
+ * @type {AbortController|null}
976
+ * @private
977
+ */
978
+ private _mcpAbort;
979
+ /**
980
+ * @type {HTMLButtonElement}
981
+ * @private
982
+ */
983
+ private _mcpBtn;
984
+ /**
985
+ * The ids of the objects the tools return, which stay the same for the life of the inspector.
986
+ *
987
+ * @type {RefRegistry}
988
+ * @private
989
+ */
990
+ private _refs;
991
+ /**
992
+ * What the tools read the app through.
993
+ *
994
+ * @type {McpHost}
995
+ * @private
996
+ */
997
+ private _mcpHost;
998
+ /**
999
+ * Whether the app is paused. Pausing sets {@link AppBase#timeScale} to zero and suspends the
1000
+ * sound manager; resuming restores the time scale that was in effect.
1001
+ *
1002
+ * @type {boolean}
1003
+ */
1004
+ set paused(value: boolean);
1005
+ get paused(): boolean;
1006
+ /**
1007
+ * Captures images for the screenshot tool, made on first use.
1008
+ *
1009
+ * @type {ImageCapture|null}
1010
+ * @private
1011
+ */
1012
+ private _images;
1013
+ /**
1014
+ * The frame graph and the app's own objects, found once per tool call.
1015
+ *
1016
+ * @type {*}
1017
+ * @private
1018
+ */
1019
+ private _mcpFrame;
1020
+ /**
1021
+ * @type {Set<object>|null}
1022
+ * @private
1023
+ */
1024
+ private _mcpOpaque;
877
1025
  /**
878
1026
  * True while the panel is being built and restored, when nothing should be saved.
879
1027
  *
@@ -942,20 +1090,65 @@ export class Inspector {
942
1090
  */
943
1091
  destroy(): void;
944
1092
  /**
945
- * Whether the app is paused. Pausing sets {@link AppBase#timeScale} to zero and suspends the
946
- * sound manager; resuming restores the time scale that was in effect.
1093
+ * Whether the panel is shown. Toggled by the toggle key.
947
1094
  *
948
1095
  * @type {boolean}
949
1096
  */
950
- set paused(value: boolean);
951
- get paused(): boolean;
1097
+ set visible(value: boolean);
1098
+ get visible(): boolean;
952
1099
  /**
953
- * Whether the panel is shown. Toggled by the toggle key.
1100
+ * Whether the inspector offers its tools to AI agents: tools that read the app as the panel
1101
+ * shows it, the hierarchy, the lists of its tabs and any object by id, and tools that record
1102
+ * frames on the Performance tab and read what they recorded. None of them changes the app;
1103
+ * the recording tools change only the inspector's capture and its timing switches. Toggled by
1104
+ * the MCP button of the toolbar, and kept on while the panel is hidden.
1105
+ *
1106
+ * While on, the tools are registered with WebMCP (`document.modelContext`) where the browser
1107
+ * has it, for agents running in the browser, and can be called from the page through
1108
+ * {@link Inspector#getTools} and {@link Inspector#executeTool}, for agents driving the page,
1109
+ * such as through Puppeteer.
954
1110
  *
955
1111
  * @type {boolean}
956
1112
  */
957
- set visible(value: boolean);
958
- get visible(): boolean;
1113
+ set mcp(value: boolean);
1114
+ get mcp(): boolean;
1115
+ /**
1116
+ * The tools offered while {@link Inspector#mcp} is on, described the way MCP describes them.
1117
+ *
1118
+ * @returns {McpTool[]} The tools, none while it is off.
1119
+ */
1120
+ getTools(): McpTool[];
1121
+ /**
1122
+ * Calls one of the tools of {@link Inspector#getTools}.
1123
+ *
1124
+ * @param {string} name - The name of the tool.
1125
+ * @param {object} [args] - Its arguments, as its input schema describes them.
1126
+ * @returns {Promise<*>} The result, as JSON-ready data. Rejects when the tools are off, the tool
1127
+ * is unknown or the arguments are wrong.
1128
+ * @example
1129
+ * inspector.mcp = true;
1130
+ * const { entities } = await inspector.executeTool('playcanvas_find_entities', { name: 'Robot' });
1131
+ * const robot = await inspector.executeTool('playcanvas_get', { id: entities[0].$id });
1132
+ */
1133
+ executeTool(name: string, args?: object): Promise<any>;
1134
+ /**
1135
+ * Registers the tools with WebMCP while {@link Inspector#mcp} is on, withdraws them while it is
1136
+ * off, and shows the state on the toolbar button.
1137
+ *
1138
+ * @private
1139
+ */
1140
+ private _applyMcp;
1141
+ /**
1142
+ * The model the tools show an object with: for the object asked for, what its tab shows,
1143
+ * with the lists of what uses it; for an object reached through a link, what a copy follows,
1144
+ * see {@link Inspector#_copyModel}. Neither narrows to the filter of the panel.
1145
+ *
1146
+ * @param {object} obj - The object.
1147
+ * @param {boolean} subject - Whether it is the object asked for.
1148
+ * @returns {PropertySection[]|PropertyRow[]|null} The model, or null for an object no tab shows.
1149
+ * @private
1150
+ */
1151
+ private _mcpModel;
959
1152
  /**
960
1153
  * Whether frames are being recorded for the Performance tab, as its Record button shows. Set it
961
1154
  * to start or stop a capture from code, such as around a part of the app to profile. Starting
@@ -973,6 +1166,16 @@ export class Inspector {
973
1166
  * Advances the app by one frame. Only meaningful while paused.
974
1167
  */
975
1168
  step(): void;
1169
+ /**
1170
+ * Pauses the app if it is not, then runs frames with time moving, as pressing Step that many
1171
+ * times does, and holds it paused again.
1172
+ *
1173
+ * @param {number} frames - How many frames to run.
1174
+ * @param {number} timeout - How long to wait for them, in milliseconds.
1175
+ * @returns {Promise<number>} How many frames ran: fewer when the timeout came first.
1176
+ * @private
1177
+ */
1178
+ private _stepFrames;
976
1179
  /**
977
1180
  * Refreshes the active list and the property view immediately.
978
1181
  *
@@ -1218,6 +1421,42 @@ export class Inspector {
1218
1421
  * @private
1219
1422
  */
1220
1423
  private _updateFilterHint;
1424
+ /**
1425
+ * Builds the snapshots section of a tab, over the snapshots the tab already has.
1426
+ *
1427
+ * @param {string} tab - The tab.
1428
+ * @param {string} title - Its name.
1429
+ * @param {() => SnapshotContent} measure - Measures what the tab shows, now.
1430
+ * @returns {HTMLElement} The section.
1431
+ * @private
1432
+ */
1433
+ private _snapshotSection;
1434
+ /**
1435
+ * Shows a treemap of snapshots in a tab of its own, added at the end of the tab bar, or switches
1436
+ * to the tab already showing them. Several can be open at once.
1437
+ *
1438
+ * @param {string} source - The tab the snapshots were captured on.
1439
+ * @param {TreemapData} data - The snapshots.
1440
+ * @returns {string} The id of the treemap's tab.
1441
+ * @private
1442
+ */
1443
+ private _showTreemap;
1444
+ /**
1445
+ * Builds the button and the panel of a treemap tab. The button's cross closes the tab, as does
1446
+ * a middle click on it.
1447
+ *
1448
+ * @param {string} id - The tab's id.
1449
+ * @param {{ data: TreemapData, view: TreemapView|null }} tab - The tab.
1450
+ * @private
1451
+ */
1452
+ private _addTreemapTab;
1453
+ /**
1454
+ * Closes a treemap tab, going back to the tab its snapshots came from when it was shown.
1455
+ *
1456
+ * @param {string} id - The tab's id.
1457
+ * @private
1458
+ */
1459
+ private _closeTreemap;
1221
1460
  /**
1222
1461
  * @param {HTMLElement} parent - The bar to add the toggle to.
1223
1462
  * @param {string} label - The label.
@@ -1286,7 +1525,7 @@ export class Inspector {
1286
1525
  /**
1287
1526
  * Switches the list tab and points the property view at that tab's selection.
1288
1527
  *
1289
- * @param {'hierarchy'|'cameras'|'assets'|'passes'|'perf'|'targets'|'textures'|'meshes'|'materials'|'scripts'|'memory'|'shaders'|'physics'} tab - The tab.
1528
+ * @param {'hierarchy'|'cameras'|'layers'|'assets'|'passes'|'perf'|'targets'|'textures'|'meshes'|'materials'|'scripts'|'memory'|'shaders'|'physics'|`treemap${number}`} tab - The tab.
1290
1529
  * @private
1291
1530
  */
1292
1531
  private _setTab;
@@ -1387,6 +1626,11 @@ export class Inspector {
1387
1626
  * @private
1388
1627
  */
1389
1628
  private _perfCopy;
1629
+ /**
1630
+ * @returns {object} What a copy of a capture says about the device: its type and size.
1631
+ * @private
1632
+ */
1633
+ private _deviceInfo;
1390
1634
  /**
1391
1635
  * @returns {Set<object>} The app's own objects, which a copy never follows, as through them it
1392
1636
  * would reach everything else.
@@ -1413,11 +1657,20 @@ export class Inspector {
1413
1657
  * @private
1414
1658
  */
1415
1659
  private _showPass;
1660
+ /**
1661
+ * @param {*} target - An object.
1662
+ * @returns {'hierarchy'|'targets'|'passes'|'textures'|'shaders'|'assets'|'scripts'|'layers'|'materials'|'meshes'|'memory'|null}
1663
+ * The tab that lists objects of its kind, or null when none does.
1664
+ * @private
1665
+ */
1666
+ private _tabOf;
1416
1667
  /**
1417
1668
  * Reveals a linked object in the tab that lists it: nodes in the hierarchy, passes in the frame
1418
1669
  * graph, render targets in their list.
1419
1670
  *
1420
1671
  * @param {*} target - The object.
1672
+ * @returns {boolean} Whether the tab lists it, as one listing what is on the device does not
1673
+ * once the object is destroyed.
1421
1674
  * @private
1422
1675
  */
1423
1676
  private _selectAny;
@@ -1537,6 +1790,32 @@ export class Inspector {
1537
1790
  * @private
1538
1791
  */
1539
1792
  private _endViewportModes;
1793
+ /**
1794
+ * Hides a layer from the view by turning it off, or turns a layer hidden here back on. Only a
1795
+ * layer the app has on can be hidden, so showing it again restores what the app had.
1796
+ *
1797
+ * @param {Layer} layer - The layer.
1798
+ * @param {boolean} hidden - Whether to hide it.
1799
+ * @private
1800
+ */
1801
+ private _hideLayer;
1802
+ /**
1803
+ * Turns every layer hidden here back on.
1804
+ *
1805
+ * @private
1806
+ */
1807
+ private _showHiddenLayers;
1808
+ /**
1809
+ * Forgets the hidden layers the app has turned back on itself, or taken out of the composition,
1810
+ * so the panel never turns on a layer it no longer hides.
1811
+ *
1812
+ * @private
1813
+ */
1814
+ private _pruneHiddenLayers;
1815
+ /**
1816
+ * @private
1817
+ */
1818
+ private _afterLayersChanged;
1540
1819
  /**
1541
1820
  * Puts back the shader pass each camera had before the panel changed it, and turns wireframe
1542
1821
  * off.
@@ -1617,4 +1896,5 @@ export class Inspector {
1617
1896
  private _highlightSize;
1618
1897
  }
1619
1898
  import { GraphNode } from 'playcanvas';
1899
+ import type { McpTool } from './mcp-tools.js';
1620
1900
  import type { AppBase } from 'playcanvas';
@@ -0,0 +1,80 @@
1
+ /**
2
+ * One entry of the composition: a layer's opaque or transparent half, which the composition orders
3
+ * on its own, so a layer's halves can render far apart.
4
+ */
5
+ export type SubLayer = {
6
+ /**
7
+ * - The layer.
8
+ */
9
+ layer: Layer;
10
+ /**
11
+ * - Whether it is the transparent half.
12
+ */
13
+ transparent: boolean;
14
+ /**
15
+ * - Whether the composition renders it: the layer and the half enabled.
16
+ */
17
+ enabled: boolean;
18
+ /**
19
+ * - Its place in the composition.
20
+ */
21
+ index: number;
22
+ };
23
+ /**
24
+ * What the Layers tab offers on a layer, supplied by the inspector.
25
+ */
26
+ export type LayerActions = {
27
+ /**
28
+ * - Hides the layer from the view, or shows
29
+ * it again.
30
+ */
31
+ hide: (layer: Layer, hidden: boolean) => void;
32
+ /**
33
+ * - Whether the inspector hides the layer.
34
+ */
35
+ hidden: (layer: Layer) => boolean;
36
+ };
37
+ /**
38
+ * Everything the property view shows for a layer: where its halves render in the composition, how
39
+ * each sorts, the cameras rendering it with what each drew of it last frame, its lights and its mesh
40
+ * instances, and a way to hide it from the view.
41
+ *
42
+ * @param {Layer} layer - The layer.
43
+ * @param {{ app: AppBase, layerActions: LayerActions }} ctx - The app, and what the tab offers.
44
+ * @returns {PropertySection[]} The sections.
45
+ */
46
+ export function buildLayerModel(layer: Layer, ctx: {
47
+ app: AppBase;
48
+ layerActions: LayerActions;
49
+ }): PropertySection[];
50
+ /**
51
+ * One entry of the composition: a layer's opaque or transparent half, which the composition orders
52
+ * on its own, so a layer's halves can render far apart.
53
+ *
54
+ * @typedef {object} SubLayer
55
+ * @property {Layer} layer - The layer.
56
+ * @property {boolean} transparent - Whether it is the transparent half.
57
+ * @property {boolean} enabled - Whether the composition renders it: the layer and the half enabled.
58
+ * @property {number} index - Its place in the composition.
59
+ * @ignore
60
+ */
61
+ /**
62
+ * The entries of the composition, in the order it renders them.
63
+ *
64
+ * @param {LayerComposition|null|undefined} composition - The scene's composition.
65
+ * @returns {SubLayer[]} The entries.
66
+ */
67
+ export function collectSubLayers(composition: LayerComposition | null | undefined): SubLayer[];
68
+ /**
69
+ * One row per entry of the composition, in render order, dimmed when it does not render.
70
+ *
71
+ * @param {AppBase} app - The app.
72
+ * @param {(layer: Layer) => boolean} [hidden] - Whether the inspector hides a layer.
73
+ * @returns {ListRow[]} The rows.
74
+ */
75
+ export function layerRows(app: AppBase, hidden?: (layer: Layer) => boolean): ListRow[];
76
+ import type { Layer } from 'playcanvas';
77
+ import type { AppBase } from 'playcanvas';
78
+ import type { PropertySection } from './model.js';
79
+ import type { LayerComposition } from 'playcanvas';
80
+ import type { ListRow } from './list-view.js';