@playcanvas/inspector 0.5.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.
- package/README.md +53 -4
- package/package.json +2 -2
- package/src/asset-view.js +65 -2
- package/src/camera-view.js +1 -1
- package/src/describe.js +1 -1
- package/src/inspector.js +368 -48
- package/src/layer-view.js +235 -0
- package/src/mcp-tools.js +6 -3
- package/src/memory-view.js +59 -3
- package/src/mesh-view.js +50 -1
- package/src/ref-registry.js +2 -1
- package/src/render-target-view.js +75 -1
- package/src/shader-view.js +32 -1
- package/src/snapshot-view.js +268 -0
- package/src/styles.js +261 -0
- package/src/texture-view.js +1 -1
- package/src/treemap-view.js +837 -0
- package/types/asset-view.d.ts +10 -0
- package/types/inspector.d.ts +147 -2
- package/types/layer-view.d.ts +80 -0
- package/types/memory-view.d.ts +11 -0
- package/types/mesh-view.d.ts +13 -0
- package/types/render-target-view.d.ts +12 -0
- package/types/shader-view.d.ts +12 -0
- package/types/snapshot-view.d.ts +166 -0
- package/types/texture-view.d.ts +12 -1
- package/types/treemap-view.d.ts +379 -0
package/README.md
CHANGED
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
| [User Manual](https://developer.playcanvas.com) | [Blog](https://blog.playcanvas.com) | [Forum](https://forum.playcanvas.com) |
|
|
11
11
|
|
|
12
12
|
A debug panel for running [PlayCanvas](https://github.com/playcanvas/engine) apps. It shows the entity
|
|
13
|
-
hierarchy and every component's properties, and tabs for the cameras, assets, frame graph,
|
|
13
|
+
hierarchy and every component's properties, and tabs for the cameras, layers, assets, frame graph,
|
|
14
14
|
performance, render targets, textures, meshes, materials, scripts, memory, shaders and physics of
|
|
15
15
|
the app, with live previews of textures and render targets, picking and flying in the view, and a
|
|
16
16
|
debug frame mode that steps through the draw calls of a render pass.
|
|
17
17
|
|
|
18
18
|
The inspector is read-only, apart from toggling entities on and off, pausing and stepping the app,
|
|
19
|
-
and view-only overrides (render modes, wireframe, a flown or orbited camera
|
|
20
|
-
closes.
|
|
19
|
+
and view-only overrides (render modes, wireframe, a flown or orbited camera, hidden layers) it
|
|
20
|
+
removes when it closes.
|
|
21
21
|
|
|
22
22
|

|
|
23
23
|
|
|
@@ -54,6 +54,55 @@ entity.script.create(EntityInspector, { properties: { dock: 'left' } });
|
|
|
54
54
|
app.root.addChild(entity);
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
### Layers
|
|
58
|
+
|
|
59
|
+
The Layers tab lists the layer composition in the order it renders. The opaque and transparent
|
|
60
|
+
halves of a layer are ordered apart, so each has a row of its own, and a layer can render its
|
|
61
|
+
halves far apart, as the World layer does around the Skybox. Each row counts the mesh instances of
|
|
62
|
+
its half and the cameras rendering it; a row is dimmed when it draws nothing, being off or rendered
|
|
63
|
+
by no camera. Select a layer for where its halves are in the composition, how each sorts, what it
|
|
64
|
+
clears, its lights and mesh instances, and each camera rendering it with how many opaque and
|
|
65
|
+
transparent instances that camera drew of it after culling, in the last frame.
|
|
66
|
+
|
|
67
|
+
**Hide** on a layer turns it off to see the view without it. **Show all**, or closing the panel,
|
|
68
|
+
turns the layers hidden this way back on. A layer the app has off cannot be hidden, and one the app
|
|
69
|
+
turns back on itself is left to it.
|
|
70
|
+
|
|
71
|
+
### Snapshots
|
|
72
|
+
|
|
73
|
+
The Assets, Render targets, Meshes, Memory and Shaders tabs have a **Snapshots** section under
|
|
74
|
+
their list. **Capture** takes a snapshot of what the tab measures at that moment, and it holds still
|
|
75
|
+
while the app runs on. Click a snapshot to open it as a treemap in a tab of its own, added at the
|
|
76
|
+
end of the tab bar and closed with its ×, or a middle click: a box per item sized by its bytes,
|
|
77
|
+
inside a box per group, such as a texture inside Textures, or a mesh inside the model file it came
|
|
78
|
+
from. Several can be open at once, and the treemap has the whole height of the panel while it
|
|
79
|
+
shows; pop the panel out for more room. Click a group's name to open it. Ctrl + wheel or a pinch
|
|
80
|
+
zooms at the pointer, drag moves around, and + and − zoom and 0 fits.
|
|
81
|
+
|
|
82
|
+
Click an item's box to show it in the tab that lists it: a texture in Textures, a buffer in Memory,
|
|
83
|
+
an attachment's render target in Render targets, and an asset, mesh or shader in its own tab.
|
|
84
|
+
Snapshots hold what they measured weakly, so they keep nothing alive; an item destroyed since is no
|
|
85
|
+
longer listed, and the treemap says so.
|
|
86
|
+
|
|
87
|
+
Tick two snapshots and **Compare** opens one treemap of both: each box is the larger of the item's
|
|
88
|
+
two sizes, with the bytes added marked red and the bytes removed striped green. **Size by change**
|
|
89
|
+
sizes the boxes by how much they changed instead, and leaves out what did not, which finds a small
|
|
90
|
+
leak among large textures. **Delete** removes the ticked snapshots and **Delete all** every one of
|
|
91
|
+
the tab's.
|
|
92
|
+
|
|
93
|
+
What each tab measures:
|
|
94
|
+
|
|
95
|
+
| Tab | Sizes | Groups |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| Assets | file sizes, from the project, or as the browser timed the download | asset type |
|
|
98
|
+
| Render targets | GPU memory of the attachments; multisampled buffers, internal depth and the swap chain estimated | render target |
|
|
99
|
+
| Meshes | vertex and index buffers | model file, or how the mesh was found |
|
|
100
|
+
| Memory | GPU memory of every texture and buffer | kind of resource |
|
|
101
|
+
| Shaders | length of the source | shader family, the name up to its first dash |
|
|
102
|
+
|
|
103
|
+
Snapshots and their treemap tabs last until the page of the app is reloaded. Deleting a snapshot
|
|
104
|
+
leaves its treemap tabs open until they are closed.
|
|
105
|
+
|
|
57
106
|
### Step through a frame
|
|
58
107
|
|
|
59
108
|
In the Frame graph tab, select a forward pass or one of its layer steps and turn on **Debug frame**.
|
|
@@ -211,7 +260,7 @@ No tool changes the app. These only read it:
|
|
|
211
260
|
| `playcanvas_app_summary` | The engine version, graphics device and video memory, entity and asset counts, frame stats |
|
|
212
261
|
| `playcanvas_index` | Everything in one call: the summary, every entity with its path and components, and every camera, material, texture, shader, mesh, render target, script, asset and pass with its figures |
|
|
213
262
|
| `playcanvas_find_entities` | Entities by name, component type, script name and tag |
|
|
214
|
-
| `playcanvas_list` | What a tab lists: `textures`, `shaders`, `materials`, `meshes`, `scripts`, `cameras`, `assets`, `renderTargets`, `passes` (the frame graph) or `memory` |
|
|
263
|
+
| `playcanvas_list` | What a tab lists: `textures`, `shaders`, `materials`, `meshes`, `scripts`, `cameras`, `layers` (the composition in render order), `assets`, `renderTargets`, `passes` (the frame graph) or `memory` |
|
|
215
264
|
| `playcanvas_get` | Any object by id, as its tab shows it |
|
|
216
265
|
|
|
217
266
|
Every object returned carries an `$id`, such as `material:12`, which `playcanvas_get` takes, so an
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcanvas/inspector",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A debug panel for PlayCanvas apps: the entity hierarchy, assets, frame graph, render targets, textures, meshes, materials, scripts, cameras, memory, shaders and physics of a running app",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "A debug panel for PlayCanvas apps: the entity hierarchy, assets, frame graph, render targets, textures, meshes, materials, scripts, cameras, layers, memory, shaders and physics of a running app",
|
|
5
5
|
"author": "PlayCanvas <support@playcanvas.com>",
|
|
6
6
|
"homepage": "https://github.com/playcanvas/inspector#readme",
|
|
7
7
|
"bugs": {
|
package/src/asset-view.js
CHANGED
|
@@ -10,6 +10,8 @@ import { backlink, formatBytes, makeSection, makeUsageSection, push, read, refle
|
|
|
10
10
|
/** @import { Described } from './describe.js' */
|
|
11
11
|
/** @import { ListRow } from './list-view.js' */
|
|
12
12
|
/** @import { PropertySection } from './model.js' */
|
|
13
|
+
/** @import { SnapshotContent } from './snapshot-view.js' */
|
|
14
|
+
/** @import { SnapshotItem } from './treemap-view.js' */
|
|
13
15
|
|
|
14
16
|
// asset properties the model shows explicitly, or that are plumbing
|
|
15
17
|
const SKIP_ASSET = [
|
|
@@ -284,6 +286,67 @@ function assetRows(registry, sort) {
|
|
|
284
286
|
return rows;
|
|
285
287
|
}
|
|
286
288
|
|
|
289
|
+
/**
|
|
290
|
+
* The sizes of the files the page downloaded, as the browser timed them, by address with and
|
|
291
|
+
* without its query. The browser keeps a limited number of these records, and records no size for
|
|
292
|
+
* a file from another origin unless that server allows it.
|
|
293
|
+
*
|
|
294
|
+
* @returns {Map<string, number>} The bytes of each file.
|
|
295
|
+
*/
|
|
296
|
+
function downloadSizes() {
|
|
297
|
+
/** @type {Map<string, number>} */
|
|
298
|
+
const sizes = new Map();
|
|
299
|
+
for (const entry of /** @type {any[]} */ (globalThis.performance?.getEntriesByType?.('resource') ?? [])) {
|
|
300
|
+
const bytes = entry.decodedBodySize || entry.encodedBodySize || entry.transferSize || 0;
|
|
301
|
+
if (!bytes) continue;
|
|
302
|
+
sizes.set(entry.name, bytes);
|
|
303
|
+
sizes.set(entry.name.split('?')[0], bytes);
|
|
304
|
+
}
|
|
305
|
+
return sizes;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* What the Assets tab measures in a snapshot: the file of every asset whose size is known, by type.
|
|
310
|
+
* A descriptor from a project manifest gives the size; for a file loaded from a plain url, it is
|
|
311
|
+
* the size the browser timed downloading. The sub-assets of a container are part of its file.
|
|
312
|
+
*
|
|
313
|
+
* @param {AssetRegistry|null} registry - The registry.
|
|
314
|
+
* @returns {SnapshotContent} The files measured.
|
|
315
|
+
*/
|
|
316
|
+
function assetSnapshot(registry) {
|
|
317
|
+
const { parentOf } = containerParts(registry);
|
|
318
|
+
const downloads = downloadSizes();
|
|
319
|
+
/** @type {SnapshotItem[]} */
|
|
320
|
+
const items = [];
|
|
321
|
+
let unknown = 0;
|
|
322
|
+
for (const asset of registry?.list() ?? []) {
|
|
323
|
+
if (parentOf.has(asset)) continue;
|
|
324
|
+
const url = asset.file?.url ? asset.getFileUrl() : null;
|
|
325
|
+
let size = asset.file?.size ?? 0;
|
|
326
|
+
let measured = '';
|
|
327
|
+
if (!size && url) {
|
|
328
|
+
const address = new URL(url, document.baseURI).href;
|
|
329
|
+
size = downloads.get(address) ?? downloads.get(address.split('?')[0]) ?? 0;
|
|
330
|
+
measured = ' · size of the download';
|
|
331
|
+
}
|
|
332
|
+
if (!size) {
|
|
333
|
+
// an asset made in memory has no file to measure
|
|
334
|
+
if (url) unknown++;
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
items.push({
|
|
338
|
+
key: `asset${asset.id}`,
|
|
339
|
+
target: new WeakRef(asset),
|
|
340
|
+
group: [asset.type],
|
|
341
|
+
name: asset.name || '(unnamed)',
|
|
342
|
+
size,
|
|
343
|
+
info: `#${asset.id} · ${stateName(asset)}${measured}${url ? ` · ${url}` : ''}`
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
const note = unknown ? `${unknown} asset file${unknown === 1 ? ' is' : 's are'} left out: the project gives no size and the browser recorded none.` : '';
|
|
347
|
+
return { measure: 'File sizes of the assets', items, note };
|
|
348
|
+
}
|
|
349
|
+
|
|
287
350
|
/**
|
|
288
351
|
* Everything the property view shows for an asset: where it came from, the resources it loaded
|
|
289
352
|
* into (linked), the components using it (linked), and every other public property.
|
|
@@ -372,6 +435,6 @@ function usersSection(asset, app) {
|
|
|
372
435
|
}
|
|
373
436
|
|
|
374
437
|
export {
|
|
375
|
-
ASSET_SORTS, assetRows, assetUsers, buildAssetModel, collectAssets, containerParts, describeAssetValue,
|
|
376
|
-
resourceAssets, stateName
|
|
438
|
+
ASSET_SORTS, assetRows, assetSnapshot, assetUsers, buildAssetModel, collectAssets, containerParts, describeAssetValue,
|
|
439
|
+
pushAssetRows, resourceAssets, stateName
|
|
377
440
|
};
|
package/src/camera-view.js
CHANGED
|
@@ -79,7 +79,7 @@ function cameraRows(app, flying) {
|
|
|
79
79
|
if (camera === flying) cells.push({ text: 'flying', cls: 'pci-cell-tag' });
|
|
80
80
|
cells.push({ text: `priority ${camera.priority} · ${camera.layers.length} layers · ${targetText(camera)}`, cls: 'pci-cell-info' });
|
|
81
81
|
const running = camera.enabled && entity.enabled;
|
|
82
|
-
return { key: `camera${entity.
|
|
82
|
+
return { key: `camera${entity.guid ?? name}`, item: camera, name, dim: !running, title: `${name}\n${targetText(camera)}`, cells };
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
|
package/src/describe.js
CHANGED
|
@@ -219,7 +219,7 @@ function describeOne(value, depth) {
|
|
|
219
219
|
target: value.node
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
|
-
if (value instanceof Layer) return { text: `Layer "${value.name}" (id ${value.id})`, cls: 'obj' };
|
|
222
|
+
if (value instanceof Layer) return { text: `Layer "${value.name}" (id ${value.id})`, cls: 'obj', target: value };
|
|
223
223
|
if (value instanceof Sprite) return { text: `Sprite ${value.frameKeys?.length ?? 0} frames`, cls: 'obj' };
|
|
224
224
|
|
|
225
225
|
// DOM
|