@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.
- package/README.md +176 -3
- package/package.json +8 -6
- package/src/asset-view.js +66 -3
- package/src/camera-view.js +1 -1
- package/src/copy-json.js +48 -9
- package/src/describe.js +1 -1
- package/src/frame-graph-view.js +4 -4
- package/src/image-capture.js +387 -0
- package/src/inspector.js +700 -57
- package/src/layer-view.js +235 -0
- package/src/list-view.js +2 -0
- package/src/log-capture.js +225 -0
- package/src/material-view.js +1 -1
- package/src/mcp-tools.js +1149 -0
- package/src/memory-view.js +60 -4
- package/src/mesh-view.js +51 -2
- package/src/perf-copy.js +1 -1
- package/src/physics-view.js +2 -2
- package/src/ref-registry.js +136 -0
- package/src/render-target-view.js +86 -9
- package/src/shader-view.js +33 -2
- package/src/snapshot-view.js +268 -0
- package/src/styles.js +283 -0
- package/src/texture-view.js +2 -2
- package/src/treemap-view.js +837 -0
- package/types/asset-view.d.ts +10 -0
- package/types/image-capture.d.ts +136 -0
- package/types/inspector.d.ts +291 -11
- package/types/layer-view.d.ts +80 -0
- package/types/log-capture.d.ts +104 -0
- package/types/mcp-tools.d.ts +855 -0
- package/types/memory-view.d.ts +11 -0
- package/types/mesh-view.d.ts +13 -0
- package/types/perf-copy.d.ts +22 -0
- package/types/ref-registry.d.ts +75 -0
- package/types/render-target-view.d.ts +17 -4
- 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**.
|
|
@@ -193,6 +242,97 @@ per frame, as JSON or as CSV for a spreadsheet; both cover the frames selected t
|
|
|
193
242
|
are any. Right-click a frame in the charts to copy it, inside the frames selected together to copy
|
|
194
243
|
their figures, and the timeline to copy its bars.
|
|
195
244
|
|
|
245
|
+
### AI agents (MCP)
|
|
246
|
+
|
|
247
|
+
Click **MCP** at the right end of the status bar to let AI agents read the app and profile it on
|
|
248
|
+
the Performance tab. It turns orange
|
|
249
|
+
while on, is remembered with the other settings, and keeps working while the panel is hidden. Or
|
|
250
|
+
turn it on from code:
|
|
251
|
+
|
|
252
|
+
```javascript
|
|
253
|
+
const inspector = new Inspector(app, { mcp: true });
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
No tool changes the app. These only read it:
|
|
257
|
+
|
|
258
|
+
| Tool | What it returns |
|
|
259
|
+
| --- | --- |
|
|
260
|
+
| `playcanvas_app_summary` | The engine version, graphics device and video memory, entity and asset counts, frame stats |
|
|
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 |
|
|
262
|
+
| `playcanvas_find_entities` | Entities by name, component type, script name and tag |
|
|
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` |
|
|
264
|
+
| `playcanvas_get` | Any object by id, as its tab shows it |
|
|
265
|
+
|
|
266
|
+
Every object returned carries an `$id`, such as `material:12`, which `playcanvas_get` takes, so an
|
|
267
|
+
agent follows links from one object to the next: an entity to its mesh instances, their material,
|
|
268
|
+
its shader, and back through the materials using that shader. `depth` copies linked objects in place,
|
|
269
|
+
up to 4 links away. Shader sources are left out unless `sources` is true. Ids stay the same for the
|
|
270
|
+
life of the inspector.
|
|
271
|
+
|
|
272
|
+
These record frames on the Performance tab, as its Record button does, and read what was recorded.
|
|
273
|
+
Only `playcanvas_perf_record` and `playcanvas_perf_stop` change anything, and that is the
|
|
274
|
+
inspector's capture and its timing switches:
|
|
275
|
+
|
|
276
|
+
| Tool | What it does |
|
|
277
|
+
| --- | --- |
|
|
278
|
+
| `playcanvas_perf_record` | Starts recording, optionally with GPU and script timing. With `frames`, stops after that many and returns their summary, or gives up after `timeout` seconds, as frames stop while the page is hidden |
|
|
279
|
+
| `playcanvas_perf_stop` | Stops recording and returns the summary |
|
|
280
|
+
| `playcanvas_perf_status` | Whether it is recording, the frames kept, the timings on and whether the page is visible |
|
|
281
|
+
| `playcanvas_perf_summary` | A few KB: the min, average, 95th percentile and max of frame time, CPU update and render, scripts, GPU, draw calls and memory, the slowest GPU passes and script types, the hitches, what loaded and the shader compiles |
|
|
282
|
+
| `playcanvas_perf_frame` | One frame in full, as right-clicking it copies it |
|
|
283
|
+
| `playcanvas_perf_series` | One series a row per frame, as JSON or CSV, 300 rows at a time |
|
|
284
|
+
|
|
285
|
+
```javascript
|
|
286
|
+
const { summary } = await inspector.executeTool('playcanvas_perf_record', { frames: 120, gpuTimings: true, scriptTiming: true });
|
|
287
|
+
const slowest = await inspector.executeTool('playcanvas_perf_frame', { frame: summary.hitches.longest[0]?.frame ?? 1 });
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The summary's CPU figures leave out the inspector's own time, and say how much it was;
|
|
291
|
+
`includeInspector` counts it. A capture the user recorded is not discarded unless `clear` is true;
|
|
292
|
+
`clear: false` adds to it.
|
|
293
|
+
|
|
294
|
+
These show the app and what it logs, and hold it still:
|
|
295
|
+
|
|
296
|
+
| Tool | What it does |
|
|
297
|
+
| --- | --- |
|
|
298
|
+
| `playcanvas_screenshot` | A PNG image: what the canvas shows, or with the id of a texture or a render target, that texture or an attachment of the target, as its preview shows it: sRGB, HDR and encoded textures decoded, depth and single channels as grayscale. `channels` shows stored channels instead, such as `aaa` for alpha |
|
|
299
|
+
| `playcanvas_logs` | What the page logged to the console since MCP was turned on, and the errors nothing caught: the engine's warnings in a debug build, shader errors, the app's own messages. Repeats in a row are counted, and `since` returns only what is new |
|
|
300
|
+
| `playcanvas_pause` | Pauses or resumes the app, as the Pause button does |
|
|
301
|
+
| `playcanvas_step` | Runs a number of frames with time moving, then holds the app paused |
|
|
302
|
+
|
|
303
|
+
A texture is captured by drawing it with the preview's shaders into an 8-bit target the size of the
|
|
304
|
+
image, then reading that back, so it comes out the way the panel previews it. WebGL2 cannot capture a
|
|
305
|
+
comparison depth texture, such as a shadow map, or a depth renderbuffer; WebGPU captures shadow maps.
|
|
306
|
+
HDR values above 1 clip to white, as in the preview. Through WebMCP a screenshot is an image the agent
|
|
307
|
+
sees; through `executeTool` it is base64 PNG data under `$image`.
|
|
308
|
+
|
|
309
|
+
Messages are kept while MCP is on, the last 1000 of them. The console methods are wrapped meanwhile,
|
|
310
|
+
so DevTools names the wrapper as where a message came from until MCP is turned off.
|
|
311
|
+
|
|
312
|
+
Each tool describes itself with a description and a JSON schema of its arguments, which is all an
|
|
313
|
+
agent needs to use it. While MCP is on, the tools are offered two ways:
|
|
314
|
+
|
|
315
|
+
- **WebMCP**, where the browser has it (Chrome 150+ with `--enable-features=WebMCP`): the tools are
|
|
316
|
+
registered with `document.modelContext`, where agents running in the browser find them. To use
|
|
317
|
+
them from Claude Code or another MCP client, add
|
|
318
|
+
[chrome-devtools-mcp](https://github.com/ChromeDevTools/chrome-devtools-mcp) with its WebMCP tools
|
|
319
|
+
on, which launches Chrome with the flag:
|
|
320
|
+
|
|
321
|
+
```sh
|
|
322
|
+
claude mcp add chrome-devtools -- npx -y chrome-devtools-mcp@latest --categoryExperimentalWebmcp --chromeArg=--enable-features=WebMCP
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Then ask the agent to open the page, click **MCP**, and use `list_webmcp_tools` and
|
|
326
|
+
`execute_webmcp_tool`.
|
|
327
|
+
- **From the page**, in any browser, for agents driving it, such as through Puppeteer:
|
|
328
|
+
|
|
329
|
+
```javascript
|
|
330
|
+
inspector.mcp = true;
|
|
331
|
+
const tools = inspector.getTools();
|
|
332
|
+
const { entities } = await inspector.executeTool('playcanvas_find_entities', { component: 'render' });
|
|
333
|
+
const entity = await inspector.executeTool('playcanvas_get', { id: entities[0].$id });
|
|
334
|
+
```
|
|
335
|
+
|
|
196
336
|
## Engine versions
|
|
197
337
|
|
|
198
338
|
Each inspector release names the engine versions it supports in its `playcanvas` peer dependency.
|
|
@@ -228,6 +368,39 @@ npm run test:types # compiles a TypeScript usage of the package against them
|
|
|
228
368
|
npm run publint # checks the package is publishable
|
|
229
369
|
```
|
|
230
370
|
|
|
371
|
+
`npm run test:webmcp` calls the MCP tools through Chrome's own WebMCP: it launches system Chrome with
|
|
372
|
+
WebMCP on, opens the inspector example of the engine's examples browser on port 5620, clicks **MCP**
|
|
373
|
+
and runs a chain of calls. `node e2e/webmcp.mjs --url <page> --calls '<json>'` runs other calls on
|
|
374
|
+
another page; see the top of `e2e/webmcp.mjs`.
|
|
375
|
+
|
|
376
|
+
`node e2e/webmcp.mjs --dump <dir>` writes everything the app holds to files, for an agent to search
|
|
377
|
+
rather than read: `index.json`, then a file per kind (`entities.json`, `materials.json`,
|
|
378
|
+
`shaders.json` with their sources, `meshInstances.json` and so on) holding every object as
|
|
379
|
+
`playcanvas_get` returns it, keyed by its `$id`, so the links between objects resolve across the
|
|
380
|
+
files. A `README.md` in the directory describes them.
|
|
381
|
+
|
|
382
|
+
The driver writes every screenshot it gets to a PNG file in `--images <dir>` (default
|
|
383
|
+
`screenshots`), so `--calls` can capture textures and render targets to look at.
|
|
384
|
+
|
|
385
|
+
`node e2e/webmcp.mjs --perf <frames> [dir]` records that many frames through the perf tools, with GPU
|
|
386
|
+
and script timing where the app has them, prints the summary and writes `capture.json` (every frame,
|
|
387
|
+
as copying the capture gives it), `summary.json` and a CSV per series (`series-cpu.csv`,
|
|
388
|
+
`series-gpu.csv` and so on) into the directory, or into the `--dump` directory.
|
|
389
|
+
|
|
390
|
+
`--perf-dump [dir]` writes the same files from the capture the Performance tab already holds, without
|
|
391
|
+
recording, such as one recorded with its Record button. As the script otherwise opens a page of its
|
|
392
|
+
own, record in one of these:
|
|
393
|
+
|
|
394
|
+
- `--wait` opens a window and waits for Enter in the terminal, so you can record there first.
|
|
395
|
+
- `--connect <url>` uses a Chrome you already run, started with
|
|
396
|
+
`--remote-debugging-port=9222 --user-data-dir=<dir> --enable-features=WebMCP`, given as
|
|
397
|
+
`http://127.0.0.1:9222`. It picks the tab with the inspector (or the one whose URL contains
|
|
398
|
+
`--url`'s value) and leaves Chrome running.
|
|
399
|
+
|
|
400
|
+
```sh
|
|
401
|
+
node e2e/webmcp.mjs --connect http://127.0.0.1:9222 --perf-dump ./capture
|
|
402
|
+
```
|
|
403
|
+
|
|
231
404
|
The tests run against the `playcanvas` version in `devDependencies`, on the engine's null graphics
|
|
232
405
|
device under jsdom.
|
|
233
406
|
|
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": {
|
|
@@ -44,18 +44,19 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"lint": "eslint src test",
|
|
48
|
-
"lint:fix": "eslint --fix src test",
|
|
47
|
+
"lint": "eslint src test e2e",
|
|
48
|
+
"lint:fix": "eslint --fix src test e2e",
|
|
49
49
|
"publint": "publint",
|
|
50
50
|
"test": "mocha --recursive test --timeout 5000",
|
|
51
51
|
"build:types": "tsc",
|
|
52
|
-
"test:types": "tsc -p test/types"
|
|
52
|
+
"test:types": "tsc -p test/types",
|
|
53
|
+
"test:webmcp": "node e2e/webmcp.mjs --headless"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
56
|
"playcanvas": "^2.23.0"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
|
-
"@playcanvas/eslint-config": "3.0.0
|
|
59
|
+
"@playcanvas/eslint-config": "3.0.0",
|
|
59
60
|
"chai": "6.2.2",
|
|
60
61
|
"eslint": "9.39.5",
|
|
61
62
|
"globals": "17.12.0",
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
"mocha": "12.0.2",
|
|
64
65
|
"playcanvas": "2.23.0",
|
|
65
66
|
"publint": "0.3.24",
|
|
67
|
+
"puppeteer-core": "25.11.0",
|
|
66
68
|
"typescript": "5.9.3"
|
|
67
69
|
}
|
|
68
70
|
}
|
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 = [
|
|
@@ -248,7 +250,7 @@ function assetRows(registry, sort) {
|
|
|
248
250
|
cells.push({ text: asset.type, cls: 'pci-cell-tag pci-cell-tag-info' });
|
|
249
251
|
if (!asset.loaded) cells.push({ text: stateName(asset), cls: 'pci-cell-tag' });
|
|
250
252
|
cells.push({ text: size, cls: 'pci-cell-info' });
|
|
251
|
-
cells.push({ text: `#${asset.id}`, cls: 'pci-cell-info pci-cell-right' });
|
|
253
|
+
cells.push({ text: `#${asset.id}`, cls: 'pci-cell-info pci-cell-right', field: 'id' });
|
|
252
254
|
const title = `${name}\n${asset.type}, ${stateName(asset)}, ${size}` +
|
|
253
255
|
`${parent ? `\nin container "${parent.name}"` : asset.file?.url ? `\n${asset.file.url}` : ''}`;
|
|
254
256
|
return { key: `asset${asset.id}`, item: asset, name, dim: !asset.loaded, title, cells };
|
|
@@ -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/copy-json.js
CHANGED
|
@@ -24,6 +24,13 @@ import { collectProperties, describeValue } from './describe.js';
|
|
|
24
24
|
* referenced, so that copying a huge scene cannot stall the page for long.
|
|
25
25
|
* @property {(object: object) => boolean} [exclude] - Whether a child node belongs to the panel
|
|
26
26
|
* rather than the app, such as the entity of its gizmo, and is left out with everything below it.
|
|
27
|
+
* @property {(object: object) => string} [idOf] - Gives every object copied, in full or as a
|
|
28
|
+
* reference, an id under `$id`, by which it can be looked up again later.
|
|
29
|
+
* @property {boolean} [code] - Whether to copy the source code of the object copied, such as the
|
|
30
|
+
* sources of a shader, rather than its summary. Defaults to true.
|
|
31
|
+
* @property {boolean} [backlinks] - Whether to keep what refers back to the objects copied, such
|
|
32
|
+
* as a node's parent and the lists of what uses an object, as references that are never followed.
|
|
33
|
+
* Defaults to false, which leaves them out.
|
|
27
34
|
*/
|
|
28
35
|
|
|
29
36
|
/**
|
|
@@ -183,6 +190,24 @@ class JsonCopy {
|
|
|
183
190
|
*/
|
|
184
191
|
_exclude;
|
|
185
192
|
|
|
193
|
+
/**
|
|
194
|
+
* @type {((object: object) => string)|null}
|
|
195
|
+
* @private
|
|
196
|
+
*/
|
|
197
|
+
_idOf;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @type {boolean}
|
|
201
|
+
* @private
|
|
202
|
+
*/
|
|
203
|
+
_backlinks;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @type {boolean}
|
|
207
|
+
* @private
|
|
208
|
+
*/
|
|
209
|
+
_code;
|
|
210
|
+
|
|
186
211
|
/**
|
|
187
212
|
* The objects copied in full so far, so that the next mention of one is a reference.
|
|
188
213
|
*
|
|
@@ -222,6 +247,19 @@ class JsonCopy {
|
|
|
222
247
|
this._opaque = options.opaque ?? (() => false);
|
|
223
248
|
this._maxObjects = options.maxObjects ?? MAX_OBJECTS;
|
|
224
249
|
this._exclude = options.exclude ?? (() => false);
|
|
250
|
+
this._idOf = options.idOf ?? null;
|
|
251
|
+
this._backlinks = options.backlinks ?? false;
|
|
252
|
+
this._code = options.code ?? true;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @param {object} obj - An object being copied.
|
|
257
|
+
* @returns {object} The start of its copy: its type, and its id when ids are given.
|
|
258
|
+
*/
|
|
259
|
+
head(obj) {
|
|
260
|
+
const out = { $type: typeName(obj) };
|
|
261
|
+
if (this._idOf) out.$id = this._idOf(obj);
|
|
262
|
+
return out;
|
|
225
263
|
}
|
|
226
264
|
|
|
227
265
|
/**
|
|
@@ -269,7 +307,7 @@ class JsonCopy {
|
|
|
269
307
|
this._copied.add(obj);
|
|
270
308
|
this.objects++;
|
|
271
309
|
|
|
272
|
-
const out =
|
|
310
|
+
const out = this.head(obj);
|
|
273
311
|
if (!content) {
|
|
274
312
|
Object.assign(out, this.reflect(obj, level));
|
|
275
313
|
} else if (isSections(content)) {
|
|
@@ -290,7 +328,7 @@ class JsonCopy {
|
|
|
290
328
|
* @returns {object} What tells the object apart.
|
|
291
329
|
*/
|
|
292
330
|
reference(obj, flag) {
|
|
293
|
-
const out =
|
|
331
|
+
const out = this.head(obj);
|
|
294
332
|
for (const name of IDENTITY) {
|
|
295
333
|
let value;
|
|
296
334
|
try {
|
|
@@ -301,7 +339,7 @@ class JsonCopy {
|
|
|
301
339
|
if (typeof value === 'string' || typeof value === 'number') out[name] = value;
|
|
302
340
|
}
|
|
303
341
|
// an object without a name of its own is told apart by its summary in the panel
|
|
304
|
-
if (Object.keys(out).length === 1) {
|
|
342
|
+
if (Object.keys(out).length === (this._idOf ? 2 : 1)) {
|
|
305
343
|
const summary = describeValue(obj, 1).text;
|
|
306
344
|
if (summary !== out.$type) out.$summary = summary;
|
|
307
345
|
}
|
|
@@ -317,8 +355,9 @@ class JsonCopy {
|
|
|
317
355
|
sections(sections, level) {
|
|
318
356
|
const out = {};
|
|
319
357
|
for (const section of sections) {
|
|
320
|
-
if (section.backlink) continue;
|
|
321
|
-
|
|
358
|
+
if (section.backlink && !this._backlinks) continue;
|
|
359
|
+
// what refers back is never followed, only referenced
|
|
360
|
+
out[uniqueKey(out, section.title)] = this.rows(section.rows, section.backlink ? Infinity : level);
|
|
322
361
|
}
|
|
323
362
|
return out;
|
|
324
363
|
}
|
|
@@ -332,8 +371,8 @@ class JsonCopy {
|
|
|
332
371
|
const out = {};
|
|
333
372
|
for (const row of rows) {
|
|
334
373
|
// the entries of a collection follow its row, which copies them from its value
|
|
335
|
-
if (row.depth || row.value.backlink) continue;
|
|
336
|
-
out[uniqueKey(out, row.label || row.key)] = this.described(row.value, level);
|
|
374
|
+
if (row.depth || (row.value.backlink && !this._backlinks)) continue;
|
|
375
|
+
out[uniqueKey(out, row.label || row.key)] = this.described(row.value, row.value.backlink ? Infinity : level);
|
|
337
376
|
}
|
|
338
377
|
return out;
|
|
339
378
|
}
|
|
@@ -359,7 +398,7 @@ class JsonCopy {
|
|
|
359
398
|
if (described.items) return this.items(described.items, level);
|
|
360
399
|
if (obj) return this.link(obj, level + 1);
|
|
361
400
|
// source code only for the object copied, as the sources of everything it reaches would bury it
|
|
362
|
-
if (typeof described.code === 'string' && level <= 0) return described.code;
|
|
401
|
+
if (typeof described.code === 'string' && level <= 0 && this._code) return described.code;
|
|
363
402
|
return described.text;
|
|
364
403
|
}
|
|
365
404
|
|
|
@@ -557,7 +596,7 @@ class JsonCopy {
|
|
|
557
596
|
row.cells.forEach((cell, index) => {
|
|
558
597
|
const value = cell.toggle ? !!cell.checked : cell.text;
|
|
559
598
|
if (value === '') return;
|
|
560
|
-
const key = cell.cls?.match(/\bpci-cell-([a-z]+)/)?.[1] ?? String(index);
|
|
599
|
+
const key = cell.field ?? cell.cls?.match(/\bpci-cell-([a-z]+)/)?.[1] ?? String(index);
|
|
561
600
|
if (key === 'name' && !named) return;
|
|
562
601
|
out[uniqueKey(out, key)] = value;
|
|
563
602
|
});
|
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
|
package/src/frame-graph-view.js
CHANGED
|
@@ -516,8 +516,8 @@ function passRows(frame, device) {
|
|
|
516
516
|
dim: !enabled,
|
|
517
517
|
cells: [
|
|
518
518
|
{ text: '', cls: 'pci-cell-index' },
|
|
519
|
-
{ text: camera?.name ?? '-', cls: 'pci-cell-info', target: camera ?? undefined, title: 'Camera' },
|
|
520
|
-
{ text: `· ${layer.name} · ${step.transparent ? 'transparent' : 'opaque'} · ${drawnText(lists[i], layer)}${flags}`, cls: 'pci-cell-info' }
|
|
519
|
+
{ text: camera?.name ?? '-', cls: 'pci-cell-info', target: camera ?? undefined, title: 'Camera', field: 'camera' },
|
|
520
|
+
{ text: `· ${layer.name} · ${step.transparent ? 'transparent' : 'opaque'} · ${drawnText(lists[i], layer)}${flags}`, cls: 'pci-cell-info', field: 'layer' }
|
|
521
521
|
]
|
|
522
522
|
});
|
|
523
523
|
});
|
|
@@ -532,8 +532,8 @@ function passRows(frame, device) {
|
|
|
532
532
|
indent: 1,
|
|
533
533
|
cells: [
|
|
534
534
|
{ text: '', cls: 'pci-cell-index' },
|
|
535
|
-
{ text: 'light', cls: 'pci-cell-info' },
|
|
536
|
-
{ text: lightNode.name, cls: 'pci-cell-info', target: lightNode }
|
|
535
|
+
{ text: 'light', cls: 'pci-cell-info', field: 'kind' },
|
|
536
|
+
{ text: lightNode.name, cls: 'pci-cell-info', target: lightNode, field: 'light' }
|
|
537
537
|
]
|
|
538
538
|
});
|
|
539
539
|
}
|