@playcanvas/inspector 0.2.0 → 0.4.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.
Files changed (49) hide show
  1. package/README.md +147 -5
  2. package/package.json +1 -1
  3. package/src/asset-view.js +24 -17
  4. package/src/camera-view.js +5 -3
  5. package/src/context-menu.js +231 -0
  6. package/src/copy-json.js +692 -0
  7. package/src/describe.js +20 -1
  8. package/src/entity-inspector-script.js +10 -0
  9. package/src/frame-graph-view.js +41 -9
  10. package/src/hierarchy-view.js +29 -3
  11. package/src/inspector.js +958 -80
  12. package/src/list-view.js +118 -12
  13. package/src/material-view.js +7 -6
  14. package/src/memory-view.js +224 -66
  15. package/src/mesh-view.js +6 -5
  16. package/src/model.js +24 -2
  17. package/src/node-model.js +81 -11
  18. package/src/perf-capture.js +2034 -0
  19. package/src/perf-chart.js +3989 -0
  20. package/src/perf-copy.js +367 -0
  21. package/src/perf-view.js +1224 -0
  22. package/src/property-view.js +162 -5
  23. package/src/render-target-view.js +3 -3
  24. package/src/script-view.js +21 -12
  25. package/src/styles.js +374 -2
  26. package/src/texture-view.js +4 -4
  27. package/src/transform-tool.js +185 -0
  28. package/types/asset-view.d.ts +3 -1
  29. package/types/camera-view.d.ts +4 -0
  30. package/types/context-menu.d.ts +90 -0
  31. package/types/copy-json.d.ts +69 -0
  32. package/types/describe.d.ts +1 -1
  33. package/types/entity-inspector-script.d.ts +8 -0
  34. package/types/frame-graph-view.d.ts +7 -0
  35. package/types/hierarchy-view.d.ts +13 -0
  36. package/types/inspector.d.ts +339 -25
  37. package/types/list-view.d.ts +44 -3
  38. package/types/material-view.d.ts +3 -1
  39. package/types/memory-view.d.ts +24 -25
  40. package/types/mesh-view.d.ts +3 -1
  41. package/types/model.d.ts +16 -1
  42. package/types/node-model.d.ts +17 -1
  43. package/types/perf-capture.d.ts +871 -0
  44. package/types/perf-chart.d.ts +1407 -0
  45. package/types/perf-copy.d.ts +61 -0
  46. package/types/perf-view.d.ts +231 -0
  47. package/types/property-view.d.ts +41 -0
  48. package/types/script-view.d.ts +3 -1
  49. package/types/transform-tool.d.ts +92 -0
@@ -39,6 +39,12 @@ export type InspectorOptions = {
39
39
  * cannot switch itself off. Defaults to null.
40
40
  */
41
41
  lockedNode?: GraphNode | null;
42
+ /**
43
+ * - Whether to start recording frames for the Performance tab right
44
+ * away, as if Record were pressed, so the capture begins with the first frame the app runs after
45
+ * the inspector is created. Defaults to false. See {@link Inspector#recording}.
46
+ */
47
+ record?: boolean;
42
48
  /**
43
49
  * - Called with the new visibility
44
50
  * whenever the panel is shown or hidden, whether through {@link Inspector#visible}, the toggle key
@@ -48,8 +54,11 @@ export type InspectorOptions = {
48
54
  /**
49
55
  * - The local storage key the panel's settings are kept
50
56
  * under, so they survive a reload or a restart of the app: the physics drawing switch and options,
51
- * the bodies excluded from it (by entity path), the active tab, the panel width and the GPU
52
- * timings switch. Stored settings take precedence over the defaults given here. Defaults to
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
59
+ * includes the inspector's time, the charts collapsed and lines hidden, and the script types the
60
+ * Scripts chart shows. Stored settings take
61
+ * precedence over the defaults given here. Defaults to
53
62
  * 'pc-inspector'; null keeps nothing.
54
63
  */
55
64
  storageKey?: string | null;
@@ -102,7 +111,7 @@ export type InspectorPhysicsDrawOptions = {
102
111
  range?: number;
103
112
  };
104
113
  /**
105
- * An in-page inspector for a running application. It docks a panel over the canvas with four
114
+ * An in-page inspector for a running application. It docks a panel over the canvas with thirteen
106
115
  * tabs above a live property view of whatever is selected:
107
116
  *
108
117
  * - Hierarchy: the entity tree. The property view shows the node's transform, every component it
@@ -111,9 +120,18 @@ export type InspectorPhysicsDrawOptions = {
111
120
  * - Cameras: every camera in render order, with its target, viewport, layers and render mode. The
112
121
  * render mode of a camera can be switched to a debug view of the material inputs, the whole scene
113
122
  * drawn in wireframe, and any camera flown.
123
+ * - Assets: every asset in the registry with its file, load state and the components using it.
124
+ * Asset references on a component link here, and a texture names the asset it came from.
114
125
  * - Frame graph: the render passes of the last frame in execution order, as the render pass trace
115
126
  * prints them, with the layer steps of forward passes, the light of shadow passes and optional
116
- * GPU timings. Render target cells link to the next tab.
127
+ * GPU timings. Render target cells link to the next tab. With the debug engine, the debug frame
128
+ * draws a forward pass only up to a chosen draw, stepped one draw at a time with the arrow keys.
129
+ * - Performance: frames recorded while Record is on, up to the last 1000, charted over
130
+ * the whole capture: the frame interval, the CPU time on the main thread by phase, the GPU time,
131
+ * the draw calls and video memory, and the events of each frame, such as shaders compiled and
132
+ * the main thread blocked. Clicking a frame shows it on a timeline of its own and everything
133
+ * recorded for it in the property view; dragging selects frames to compare their figures. The
134
+ * inspector's own time is told apart from the app's.
117
135
  * - Render targets: every render target on the device including the backbuffer, with its
118
136
  * attachments and the passes that rendered into it this frame, linking back to the frame graph.
119
137
  * The selected target's attachment can be previewed live in a corner of the viewport.
@@ -128,20 +146,21 @@ export type InspectorPhysicsDrawOptions = {
128
146
  * - Scripts: every script class the script registry holds or an entity uses, with the entities using
129
147
  * it, its declared attributes and its source as the browser keeps it. The script sections of an
130
148
  * entity link here.
131
- * - Memory: video memory by kind of resource, and every buffer on the device, largest first, named
132
- * after the mesh, material or asset it was found to belong to. Buffer values elsewhere link here.
149
+ * - Memory: video memory by kind of resource, each kind a group headed by its count and size that
150
+ * opens to list its buffers largest first, named after the mesh, material or asset each was found
151
+ * to belong to. Buffer values elsewhere link here.
133
152
  * - Shaders: every shader on the device with its language, state and vertex attributes. The
134
153
  * compiled variants listed on a material link here.
135
- * - Assets: every asset in the registry with its file, load state and the components using it.
136
- * Asset references on a component link here, and a texture names the asset it came from.
137
154
  * - Physics: the rigid bodies and joints of the scene, with the physics world drawn over the scene
138
155
  * through the engine's debug drawer when Ammo is loaded.
139
156
  *
140
157
  * The app can be paused and stepped a frame at a time, and the panel can be popped out into its own
141
- * window to leave the canvas unobscured.
158
+ * window to leave the canvas unobscured. In the view, an entity can be picked to select it, and the
159
+ * camera flown, or orbited around the selected entity, without moving the app's own camera.
142
160
  *
143
- * The view is read-only, with one exception: the checkbox on each hierarchy row flips the node's
144
- * enabled flag.
161
+ * The inspector is read-only, apart from the checkbox on each hierarchy row, which flips the node's
162
+ * enabled flag, pausing and stepping the app, and view-only overrides: render modes, wireframe and
163
+ * a flown or orbited camera, which it removes when it closes.
145
164
  *
146
165
  * ```javascript
147
166
  * const inspector = new Inspector(app, { dock: 'left' });
@@ -337,10 +356,77 @@ export class Inspector {
337
356
  /** @private */
338
357
  private _nextPropertyRefresh;
339
358
  /**
340
- * @type {'hierarchy'|'cameras'|'assets'|'passes'|'targets'|'textures'|'meshes'|'materials'|'scripts'|'memory'|'shaders'|'physics'}
359
+ * @type {'hierarchy'|'cameras'|'assets'|'passes'|'perf'|'targets'|'textures'|'meshes'|'materials'|'scripts'|'memory'|'shaders'|'physics'}
341
360
  * @private
342
361
  */
343
362
  private _tab;
363
+ /**
364
+ * The frames recorded for the Performance tab. Hooked into the app only while recording.
365
+ *
366
+ * @type {PerfCapture}
367
+ * @private
368
+ */
369
+ private _perf;
370
+ /**
371
+ * The charts of the Performance tab, and the frame they show.
372
+ *
373
+ * @type {PerfCharts}
374
+ * @private
375
+ */
376
+ private _perfCharts;
377
+ /**
378
+ * @type {HTMLButtonElement}
379
+ * @private
380
+ */
381
+ private _perfRecordBtn;
382
+ /**
383
+ * Shows the newest frame, and keeps following it as frames are recorded.
384
+ *
385
+ * @type {HTMLButtonElement}
386
+ * @private
387
+ */
388
+ private _perfLastBtn;
389
+ /**
390
+ * The GPU timings switch of the Performance tab, kept in step with the Frame graph's.
391
+ *
392
+ * @type {HTMLInputElement}
393
+ * @private
394
+ */
395
+ private _perfGpuToggle;
396
+ /**
397
+ * Whether the CPU chart includes the inspector's own time.
398
+ *
399
+ * @type {HTMLInputElement}
400
+ * @private
401
+ */
402
+ private _perfInspectorToggle;
403
+ /**
404
+ * Whether to time each script type while recording.
405
+ *
406
+ * @type {HTMLInputElement}
407
+ * @private
408
+ */
409
+ private _perfScriptsToggle;
410
+ /**
411
+ * @type {HTMLElement}
412
+ * @private
413
+ */
414
+ private _perfNote;
415
+ /**
416
+ * The filter bar, which the Performance tab has no list for.
417
+ *
418
+ * @type {HTMLElement}
419
+ * @private
420
+ */
421
+ private _filterEl;
422
+ /**
423
+ * Model builder for the property view on the Performance tab: the frames the charts show.
424
+ *
425
+ * @param {PerfCharts} charts - The charts.
426
+ * @returns {PropertySection[]} The sections.
427
+ * @private
428
+ */
429
+ private _perfModel;
344
430
  /**
345
431
  * @type {FrameSnapshot|null}
346
432
  * @private
@@ -375,6 +461,34 @@ export class Inspector {
375
461
  * @private
376
462
  */
377
463
  private _bodyList;
464
+ /**
465
+ * The gizmo that moves, rotates or scales the selected entity, while one of its buttons is on.
466
+ *
467
+ * @type {TransformTool|null}
468
+ * @private
469
+ */
470
+ private _transformTool;
471
+ /**
472
+ * The buttons of the gizmos, by what each does.
473
+ *
474
+ * @type {Record<TransformMode, HTMLButtonElement>}
475
+ * @private
476
+ */
477
+ private _transformBtns;
478
+ /**
479
+ * The menu opened with a right click, which copies what it was opened on.
480
+ *
481
+ * @type {ContextMenu|null}
482
+ * @private
483
+ */
484
+ private _menu;
485
+ /**
486
+ * How many links the menu's deep copy follows.
487
+ *
488
+ * @type {number}
489
+ * @private
490
+ */
491
+ private _copyDepth;
378
492
  /**
379
493
  * Draws the selected render target's texture over the canvas, straight from the GPU.
380
494
  *
@@ -604,16 +718,6 @@ export class Inspector {
604
718
  * @private
605
719
  */
606
720
  private _instancePages;
607
- /**
608
- * @type {HTMLSelectElement}
609
- * @private
610
- */
611
- private _bufferKind;
612
- /**
613
- * @type {HTMLElement}
614
- * @private
615
- */
616
- private _memoryNote;
617
721
  /**
618
722
  * Model builder for the property view when a buffer is selected.
619
723
  *
@@ -852,6 +956,19 @@ export class Inspector {
852
956
  */
853
957
  set visible(value: boolean);
854
958
  get visible(): boolean;
959
+ /**
960
+ * Whether frames are being recorded for the Performance tab, as its Record button shows. Set it
961
+ * to start or stop a capture from code, such as around a part of the app to profile. Starting
962
+ * adds to the frames kept, up to the last 1000; the tab's Clear button forgets them.
963
+ *
964
+ * @type {boolean}
965
+ * @example
966
+ * inspector.recording = true;
967
+ * await loadLevel();
968
+ * inspector.recording = false;
969
+ */
970
+ set recording(value: boolean);
971
+ get recording(): boolean;
855
972
  /**
856
973
  * Advances the app by one frame. Only meaningful while paused.
857
974
  */
@@ -876,10 +993,18 @@ export class Inspector {
876
993
  */
877
994
  private _dockBack;
878
995
  /**
996
+ * Runs the panel's work for the frame, timed so a capture can tell it apart from the app's own:
997
+ * it runs inside the app's update.
998
+ *
879
999
  * @param {number} dt - The frame delta, scaled by the app time scale.
880
1000
  * @private
881
1001
  */
882
1002
  private _onUpdate;
1003
+ /**
1004
+ * @param {number} dt - The frame delta, scaled by the app time scale.
1005
+ * @private
1006
+ */
1007
+ private _updatePanel;
883
1008
  /**
884
1009
  * Draws the physics world for this frame. Runs from the app's update event, which fires after
885
1010
  * the rigid body system has stepped, so the drawn world matches the frame being rendered.
@@ -1101,10 +1226,67 @@ export class Inspector {
1101
1226
  * @private
1102
1227
  */
1103
1228
  private _makeToggle;
1229
+ /**
1230
+ * @returns {number} The least height of the part above the splitter. The Performance tab keeps
1231
+ * room for what does not shrink, its controls and its timeline, and a little of its charts,
1232
+ * which scroll; less would spill over the splitter.
1233
+ * @private
1234
+ */
1235
+ private _topMinHeight;
1236
+ /**
1237
+ * Raises the part above the splitter to the least height of the tab now shown, where it was
1238
+ * dragged lower on another tab.
1239
+ *
1240
+ * @private
1241
+ */
1242
+ private _fitTop;
1243
+ /**
1244
+ * Turns the GPU profiler on or off, from either of the switches, which follow each other.
1245
+ *
1246
+ * @param {boolean} on - Whether to time the GPU.
1247
+ * @private
1248
+ */
1249
+ private _setGpuTimings;
1250
+ /**
1251
+ * Turns the timing of scripts on or off, which takes effect right away while recording.
1252
+ *
1253
+ * @param {boolean} on - Whether to time each script type.
1254
+ * @private
1255
+ */
1256
+ private _setScriptTiming;
1257
+ /**
1258
+ * Starts or stops recording frames for the Performance tab.
1259
+ *
1260
+ * @param {boolean} on - Whether to record.
1261
+ * @private
1262
+ */
1263
+ private _setRecording;
1264
+ /**
1265
+ * The frame shown or the frames selected on the Performance tab changed.
1266
+ *
1267
+ * @private
1268
+ */
1269
+ private _onPerfChange;
1270
+ /**
1271
+ * Brings the recording controls of the Performance tab and its note up to date.
1272
+ *
1273
+ * @private
1274
+ */
1275
+ private _updatePerfBar;
1276
+ /**
1277
+ * Steps through the frames of the Performance tab with the arrow keys, Shift taking ten at a
1278
+ * time; Home shows the first frame, End follows the newest and Escape unselects the frames
1279
+ * selected together.
1280
+ *
1281
+ * @param {KeyboardEvent} e - A key pressed while the panel has focus.
1282
+ * @returns {boolean} Whether the key was used.
1283
+ * @private
1284
+ */
1285
+ private _onPerfKey;
1104
1286
  /**
1105
1287
  * Switches the list tab and points the property view at that tab's selection.
1106
1288
  *
1107
- * @param {'hierarchy'|'cameras'|'assets'|'passes'|'targets'|'textures'|'meshes'|'materials'|'scripts'|'memory'|'shaders'|'physics'} tab - The tab.
1289
+ * @param {'hierarchy'|'cameras'|'assets'|'passes'|'perf'|'targets'|'textures'|'meshes'|'materials'|'scripts'|'memory'|'shaders'|'physics'} tab - The tab.
1108
1290
  * @private
1109
1291
  */
1110
1292
  private _setTab;
@@ -1122,6 +1304,115 @@ export class Inspector {
1122
1304
  * @private
1123
1305
  */
1124
1306
  private _applyFilter;
1307
+ /**
1308
+ * @returns {Record<string, ListView>} The list of each tab, all but the hierarchy, by tab.
1309
+ * @private
1310
+ */
1311
+ private _tabLists;
1312
+ /**
1313
+ * @returns {ListView[]} The lists of the tabs, all but the hierarchy.
1314
+ * @private
1315
+ */
1316
+ private _lists;
1317
+ /**
1318
+ * Opens the copy menu on what was right-clicked. Text fields keep the browser's own menu, to
1319
+ * paste into them.
1320
+ *
1321
+ * @param {MouseEvent} e - The event.
1322
+ * @private
1323
+ */
1324
+ private _onContextMenu;
1325
+ /**
1326
+ * What a right click copies: a row or section of the property view, or anywhere else in it
1327
+ * the subject. A row of a list or of the hierarchy is selected first, the way a click selects
1328
+ * it, and the subject it shows is copied; the header of a group copies the group, and a row
1329
+ * that selects nothing its figures. A tab is opened first, the way a click opens it, and
1330
+ * everything it lists is copied.
1331
+ *
1332
+ * @param {Node} target - What was right-clicked.
1333
+ * @param {MouseEvent} [e] - The click, for where it was on the charts of the Performance tab.
1334
+ * @returns {CopyTarget|null} What to copy, or null for a part of the panel nothing is copied
1335
+ * from, such as the toolbar.
1336
+ * @private
1337
+ */
1338
+ private _copyTargetAt;
1339
+ /**
1340
+ * @param {string} tab - A tab.
1341
+ * @returns {CopyTarget|null} A copy of everything the tab lists: the hierarchy from its root,
1342
+ * or every row of the tab's list, whatever its filter shows.
1343
+ * @private
1344
+ */
1345
+ private _tabCopyTarget;
1346
+ /**
1347
+ * @param {CopyTarget} copy - What the menu copies.
1348
+ * @returns {MenuItem[]} The entries of the menu: on its own, a
1349
+ * number of links deep, and every link there is.
1350
+ * @private
1351
+ */
1352
+ private _copyItems;
1353
+ /**
1354
+ * @param {number} depth - How many links the deep copy follows.
1355
+ * @private
1356
+ */
1357
+ private _setCopyDepth;
1358
+ /**
1359
+ * Copies to the clipboard as JSON, and notes how much was copied.
1360
+ *
1361
+ * @param {CopyTarget} copy - What to copy.
1362
+ * @param {number} depth - How many links to follow, see {@link CopyOptions#depth}.
1363
+ * @private
1364
+ */
1365
+ private _copy;
1366
+ /**
1367
+ * Copies text made on demand, such as CSV.
1368
+ *
1369
+ * @param {() => string} make - Makes the text.
1370
+ * @param {string} what - What it is, for the note saying it was copied.
1371
+ * @private
1372
+ */
1373
+ private _copyText;
1374
+ /**
1375
+ * @param {string} text - The text.
1376
+ * @param {string} note - What the menu says once it is copied.
1377
+ * @private
1378
+ */
1379
+ private _writeClipboard;
1380
+ /**
1381
+ * What a right click on the Performance tab copies, as the charts tell it: the capture, a
1382
+ * series, a frame, the frames selected together, or the timeline. A capture and a series
1383
+ * cover the frames selected together, or every frame kept.
1384
+ *
1385
+ * @param {{ kind: string, key?: string, seq?: number }} what - What to copy.
1386
+ * @returns {CopyTarget|null} The copy, or null for nothing.
1387
+ * @private
1388
+ */
1389
+ private _perfCopy;
1390
+ /**
1391
+ * @returns {Set<object>} The app's own objects, which a copy never follows, as through them it
1392
+ * would reach everything else.
1393
+ * @private
1394
+ */
1395
+ private _opaqueObjects;
1396
+ /**
1397
+ * The model a copy follows a link into: what the tab the link opens on shows, see
1398
+ * {@link Inspector#_selectAny}, without the lists of what uses the object.
1399
+ *
1400
+ * @param {object} obj - An object reached through a link.
1401
+ * @param {PassModelContext & { app: AppBase, backlinks: boolean }} ctx - What the model
1402
+ * builders need besides their subject.
1403
+ * @returns {PropertySection[]|PropertyRow[]|null} The model, or null for an object no tab shows.
1404
+ * @private
1405
+ */
1406
+ private _copyModel;
1407
+ /**
1408
+ * Shows a GPU pass of the Performance tab on the Frame graph tab: the pass of the frame graph
1409
+ * with its name it was matched to, in the frame graph as it is now, unless that is frozen.
1410
+ *
1411
+ * @param {{ name: string, occurrence: number }} pass - The pass, by its profiler name and which
1412
+ * of the passes with that name it is.
1413
+ * @private
1414
+ */
1415
+ private _showPass;
1125
1416
  /**
1126
1417
  * Reveals a linked object in the tab that lists it: nodes in the hierarchy, passes in the frame
1127
1418
  * graph, render targets in their list.
@@ -1218,11 +1509,13 @@ export class Inspector {
1218
1509
  /** @private */
1219
1510
  private _stopFly;
1220
1511
  /**
1221
- * Orbit needs a node to orbit around, so its button is off until one is selected.
1512
+ * Pick, Fly and Orbit take the view from the app, which a gizmo needs to be used in, so their
1513
+ * buttons are off while one is on. Orbit also needs a node to orbit around, so its button is off
1514
+ * until one is selected.
1222
1515
  *
1223
1516
  * @private
1224
1517
  */
1225
- private _applyOrbitState;
1518
+ private _applyViewToolState;
1226
1519
  /**
1227
1520
  * Takes the pointer on the canvas for a mode, and Esc to end it.
1228
1521
  *
@@ -1278,6 +1571,27 @@ export class Inspector {
1278
1571
  * @private
1279
1572
  */
1280
1573
  private _updateModeStatus;
1574
+ /**
1575
+ * Turns a gizmo on, in place of the one that is on, or turns it off. The gizmo is drawn and
1576
+ * used in the view of the first camera drawing to the screen, which Pick, Fly and Orbit would
1577
+ * take from the app, so they stop and stay off while it is on.
1578
+ *
1579
+ * @param {TransformMode|null} mode - What the gizmo does, or null to turn it off.
1580
+ * @private
1581
+ */
1582
+ private _setTransformMode;
1583
+ /**
1584
+ * @param {KeyboardEvent} e - A key pressed while a gizmo is on.
1585
+ * @private
1586
+ */
1587
+ private _onTransformKey;
1588
+ /**
1589
+ * Hands the pointer to the gizmo first, and keeps from everything else what it keeps.
1590
+ *
1591
+ * @param {Event} e - A pointer event anywhere in the window.
1592
+ * @private
1593
+ */
1594
+ private _onTransformPointer;
1281
1595
  /**
1282
1596
  * Outlines a node in the viewport for the current frame.
1283
1597
  *
@@ -7,9 +7,10 @@ export type ListRow = object;
7
7
  export type ListGuides = object;
8
8
  export type ListEntry = object;
9
9
  /**
10
- * A flat, selectable list of rows with cells. Rows are keyed and reconciled in place, so a list
11
- * rebuilt from scratch a couple of times a second keeps its selection and scroll position and only
12
- * touches the text that changed.
10
+ * A flat, selectable list of rows with cells, optionally in groups under headers that open and
11
+ * close them. Rows are keyed and reconciled in place, so a list rebuilt from scratch a couple of
12
+ * times a second keeps its selection, open groups and scroll position and only touches the text
13
+ * that changed.
13
14
  *
14
15
  * @ignore
15
16
  */
@@ -80,18 +81,37 @@ export class ListView {
80
81
  * @private
81
82
  */
82
83
  private _entries;
84
+ /**
85
+ * Whether each header the user opened or closed is open, by row key.
86
+ *
87
+ * @type {Map<string, boolean>}
88
+ * @private
89
+ */
90
+ private _open;
83
91
  /**
84
92
  * The number of rows before filtering.
85
93
  *
86
94
  * @type {number}
87
95
  */
88
96
  get rowCount(): number;
97
+ /**
98
+ * The rows, all of them, whatever the filter shows and whichever groups are open.
99
+ *
100
+ * @type {ListRow[]}
101
+ */
102
+ get rows(): ListRow[];
89
103
  /**
90
104
  * The item of the selected row, or null when nothing is selected or the row is gone.
91
105
  *
92
106
  * @type {*}
93
107
  */
94
108
  get selected(): any;
109
+ /**
110
+ * The selected row, or null when nothing is selected or the row is gone.
111
+ *
112
+ * @type {ListRow|null}
113
+ */
114
+ get selectedRow(): ListRow | null;
95
115
  /**
96
116
  * Replaces the rows and re-renders.
97
117
  *
@@ -111,10 +131,31 @@ export class ListView {
111
131
  * @returns {boolean} Whether a row was found.
112
132
  */
113
133
  selectItem(item: any): boolean;
134
+ /**
135
+ * @param {Node} node - An element, such as the target of a context menu event.
136
+ * @returns {ListRow|null} The row it is in, a header included, or null when it is in none.
137
+ */
138
+ rowAt(node: Node): ListRow | null;
139
+ /**
140
+ * @param {ListRow} row - A header row.
141
+ * @returns {boolean} Whether its group is open.
142
+ * @private
143
+ */
144
+ private _isOpen;
114
145
  /**
115
146
  * Synchronizes the DOM with the rows.
116
147
  */
117
148
  render(): void;
149
+ /**
150
+ * Decides which rows are shown. Without a filter, the rows of a closed group are hidden. With
151
+ * one, every matching row is shown whether its group is open or not, and a header is shown when
152
+ * any row of its group matches.
153
+ *
154
+ * @param {string} filter - The lower-cased filter, or an empty string for none.
155
+ * @returns {boolean[]} Whether each row is shown.
156
+ * @private
157
+ */
158
+ private _shownRows;
118
159
  /**
119
160
  * @param {ListEntry} entry - The row entry.
120
161
  * @param {ListCell[]} cells - The cells to show.
@@ -16,11 +16,13 @@ export type MaterialSources = {
16
16
  * properties, and what uses it, with each mesh instance opening in place.
17
17
  *
18
18
  * @param {Material} material - The material.
19
- * @param {{ app: AppBase }} ctx - The app, to find the assets and debug lines using the material.
19
+ * @param {{ app: AppBase, backlinks?: boolean }} ctx - The app, to find the assets and debug lines
20
+ * using the material, and whether to find them at all, which a copy has no use for.
20
21
  * @returns {PropertySection[]} The sections.
21
22
  */
22
23
  export function buildMaterialModel(material: Material, ctx: {
23
24
  app: AppBase;
25
+ backlinks?: boolean;
24
26
  }): PropertySection[];
25
27
  /**
26
28
  * One row per material found, the most used first, dimmed when no mesh instance uses it.
@@ -17,13 +17,6 @@ export type BufferOwner = {
17
17
  */
18
18
  target: GraphNode | Asset | Material | null;
19
19
  };
20
- /** What the list can be narrowed to, as selector options. */
21
- export const BUFFER_KINDS: string[][];
22
- /**
23
- * @param {Buffer} buffer - A buffer.
24
- * @returns {number} Its size in bytes.
25
- */
26
- export function bufferBytes(buffer: Buffer): number;
27
20
  /**
28
21
  * @param {*} buffer - A buffer.
29
22
  * @returns {'vertex'|'index'|'uniform'|'storage'|null} Its kind, or null for anything else.
@@ -42,55 +35,61 @@ export function bufferKind(buffer: any): "vertex" | "index" | "uniform" | "stora
42
35
  * @returns {Map<Buffer, BufferOwner[]>} The owners of each attributed buffer.
43
36
  */
44
37
  export function bufferOwners(app: AppBase): Map<Buffer, BufferOwner[]>;
45
- /**
46
- * One row per buffer, largest first, named after what uses it and dimmed when nothing was found.
47
- *
48
- * @param {GraphicsDevice} device - The device.
49
- * @param {Map<Buffer, BufferOwner[]>} owners - The owners of each buffer.
50
- * @param {string} kind - The kind to list, or 'all'.
51
- * @returns {ListRow[]} The rows.
52
- */
53
- export function bufferRows(device: GraphicsDevice, owners: Map<Buffer, BufferOwner[]>, kind: string): ListRow[];
54
38
  /**
55
39
  * Everything the property view shows for a buffer: its size and layout, what it was found to
56
40
  * belong to (linked), and every other public property.
57
41
  *
58
42
  * @param {Buffer} buffer - The buffer.
59
- * @param {{ app: AppBase }} ctx - The app, to find the buffer's owners.
43
+ * @param {{ app: AppBase, backlinks?: boolean }} ctx - The app, to find the buffer's owners, and
44
+ * whether to find them at all, which a copy has no use for.
60
45
  * @returns {PropertySection[]} The sections.
61
46
  */
62
47
  export function buildBufferModel(buffer: Buffer, ctx: {
63
48
  app: AppBase;
49
+ backlinks?: boolean;
64
50
  }): PropertySection[];
65
51
  /**
66
52
  * Every buffer the device tracks, largest first. Uniform buffers appear only when persistent, as
67
- * the rest are slices of the per-frame pool.
53
+ * the rest are slices of the per-draw pool.
68
54
  *
69
55
  * @param {GraphicsDevice} device - The device.
70
- * @param {string} [kind] - One of {@link BUFFER_KINDS}.
56
+ * @param {'all'|'vertex'|'index'|'uniform'|'storage'} [kind] - The kind to collect.
71
57
  * @returns {Buffer[]} The buffers.
72
58
  */
73
- export function collectBuffers(device: GraphicsDevice, kind?: string): Buffer[];
59
+ export function collectBuffers(device: GraphicsDevice, kind?: "all" | "vertex" | "index" | "uniform" | "storage"): Buffer[];
74
60
  /**
75
61
  * @param {Buffer} buffer - A buffer.
76
62
  * @returns {number} An id that stays the same for the lifetime of the buffer, since buffers carry
77
63
  * no name of their own.
78
64
  */
79
65
  export function idOf(buffer: Buffer): number;
66
+ export namespace KIND_NAMES {
67
+ let vertex: string;
68
+ let index: string;
69
+ let uniform: string;
70
+ let storage: string;
71
+ }
80
72
  /**
81
- * The totals shown above the list: video memory by kind of resource, the per-frame uniform pool,
82
- * and the counts of the device caches that grow with the variety of what is drawn.
73
+ * The rows of the memory list: one group per kind of resource, headed by its count and total size
74
+ * and closed until opened, holding its buffers largest first, named after what uses each. The
75
+ * device caches come last. Kinds with nothing on the device are left out.
83
76
  *
84
77
  * @param {GraphicsDevice} device - The device.
85
- * @returns {string} The totals, one line per group.
78
+ * @param {Map<Buffer, BufferOwner[]>} owners - The owners of each buffer.
79
+ * @returns {ListRow[]} The rows.
86
80
  */
87
- export function memorySummary(device: GraphicsDevice): string;
81
+ export function memoryRows(device: GraphicsDevice, owners: Map<Buffer, BufferOwner[]>): ListRow[];
88
82
  /**
89
83
  * @param {GraphNode|null} node - The node a mesh instance draws at.
90
84
  * @returns {string} Its name, after its parent's when it has one below the root: imported models
91
85
  * often give every mesh node the same name, and the parent tells them apart.
92
86
  */
93
87
  export function nodeLabel(node: GraphNode | null): string;
88
+ /**
89
+ * @param {GraphicsDevice} device - The device.
90
+ * @returns {number} The video memory the device counts for its textures and buffers.
91
+ */
92
+ export function videoMemory(device: GraphicsDevice): number;
94
93
  import { VertexBuffer } from 'playcanvas';
95
94
  import { IndexBuffer } from 'playcanvas';
96
95
  import { StorageBuffer } from 'playcanvas';
@@ -98,6 +97,6 @@ import type { GraphNode } from 'playcanvas';
98
97
  import type { Asset } from 'playcanvas';
99
98
  import type { Material } from 'playcanvas';
100
99
  import type { AppBase } from 'playcanvas';
100
+ import type { PropertySection } from './model.js';
101
101
  import type { GraphicsDevice } from 'playcanvas';
102
102
  import type { ListRow } from './list-view.js';
103
- import type { PropertySection } from './model.js';