@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.
- package/README.md +147 -5
- package/package.json +1 -1
- package/src/asset-view.js +24 -17
- package/src/camera-view.js +5 -3
- package/src/context-menu.js +231 -0
- package/src/copy-json.js +692 -0
- package/src/describe.js +20 -1
- package/src/entity-inspector-script.js +10 -0
- package/src/frame-graph-view.js +41 -9
- package/src/hierarchy-view.js +29 -3
- package/src/inspector.js +958 -80
- package/src/list-view.js +118 -12
- package/src/material-view.js +7 -6
- package/src/memory-view.js +224 -66
- package/src/mesh-view.js +6 -5
- package/src/model.js +24 -2
- package/src/node-model.js +81 -11
- package/src/perf-capture.js +2034 -0
- package/src/perf-chart.js +3989 -0
- package/src/perf-copy.js +367 -0
- package/src/perf-view.js +1224 -0
- package/src/property-view.js +162 -5
- package/src/render-target-view.js +3 -3
- package/src/script-view.js +21 -12
- package/src/styles.js +374 -2
- package/src/texture-view.js +4 -4
- package/src/transform-tool.js +185 -0
- package/types/asset-view.d.ts +3 -1
- package/types/camera-view.d.ts +4 -0
- package/types/context-menu.d.ts +90 -0
- package/types/copy-json.d.ts +69 -0
- package/types/describe.d.ts +1 -1
- package/types/entity-inspector-script.d.ts +8 -0
- package/types/frame-graph-view.d.ts +7 -0
- package/types/hierarchy-view.d.ts +13 -0
- package/types/inspector.d.ts +339 -25
- package/types/list-view.d.ts +44 -3
- package/types/material-view.d.ts +3 -1
- package/types/memory-view.d.ts +24 -25
- package/types/mesh-view.d.ts +3 -1
- package/types/model.d.ts +16 -1
- package/types/node-model.d.ts +17 -1
- package/types/perf-capture.d.ts +871 -0
- package/types/perf-chart.d.ts +1407 -0
- package/types/perf-copy.d.ts +61 -0
- package/types/perf-view.d.ts +231 -0
- package/types/property-view.d.ts +41 -0
- package/types/script-view.d.ts +3 -1
- package/types/transform-tool.d.ts +92 -0
package/src/describe.js
CHANGED
|
@@ -25,6 +25,14 @@ import {
|
|
|
25
25
|
* reads the live object rather than a snapshot.
|
|
26
26
|
* @property {Described[]} [items] - Expanded entries of a collection, each carrying a `label`.
|
|
27
27
|
* @property {string} [label] - The label of an expanded collection entry.
|
|
28
|
+
* @property {*} [raw] - The value described, when the text was made from one. A copy of the row
|
|
29
|
+
* is made from it rather than from the text, which rounds numbers and cuts strings and lists short.
|
|
30
|
+
* @property {boolean} [backlink] - Whether the value refers back to what holds or uses the
|
|
31
|
+
* subject, such as a node's parent. Copies leave it out, so copying an object never climbs out of it.
|
|
32
|
+
* @property {{ text: string, apply: (text: string) => boolean }} [edit] - Makes the value
|
|
33
|
+
* editable: clicking it opens a text field holding `text`, and Enter or leaving the field hands the
|
|
34
|
+
* new text to `apply`, which changes the subject and returns whether it could. Escape leaves the
|
|
35
|
+
* value as it was.
|
|
28
36
|
*/
|
|
29
37
|
|
|
30
38
|
/** The number of collection entries expanded into their own rows. */
|
|
@@ -106,9 +114,20 @@ function expandItems(entries, count) {
|
|
|
106
114
|
*
|
|
107
115
|
* @param {*} value - The value to describe.
|
|
108
116
|
* @param {number} [depth] - The nesting depth. Nested values are kept to a short type name.
|
|
109
|
-
* @returns {Described} The description
|
|
117
|
+
* @returns {Described} The description, carrying the value as `raw`.
|
|
110
118
|
*/
|
|
111
119
|
function describeValue(value, depth = 0) {
|
|
120
|
+
const described = describeOne(value, depth);
|
|
121
|
+
described.raw = value;
|
|
122
|
+
return described;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {*} value - The value to describe.
|
|
127
|
+
* @param {number} depth - The nesting depth.
|
|
128
|
+
* @returns {Described} The description, see {@link describeValue}.
|
|
129
|
+
*/
|
|
130
|
+
function describeOne(value, depth) {
|
|
112
131
|
if (value === null) return { text: 'null', cls: 'null' };
|
|
113
132
|
if (value === undefined) return { text: 'undefined', cls: 'null' };
|
|
114
133
|
|
|
@@ -83,6 +83,15 @@ class EntityInspector extends Script {
|
|
|
83
83
|
*/
|
|
84
84
|
stepKey = 'F10';
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Whether to start recording frames for the Performance tab as soon as the panel is created,
|
|
88
|
+
* capturing the first frames of the scene.
|
|
89
|
+
*
|
|
90
|
+
* @attribute
|
|
91
|
+
* @type {boolean}
|
|
92
|
+
*/
|
|
93
|
+
record = false;
|
|
94
|
+
|
|
86
95
|
/**
|
|
87
96
|
* @type {Inspector|null}
|
|
88
97
|
* @private
|
|
@@ -107,6 +116,7 @@ class EntityInspector extends Script {
|
|
|
107
116
|
toggleKey: this.toggleKey,
|
|
108
117
|
pauseKey: this.pauseKey,
|
|
109
118
|
stepKey: this.stepKey,
|
|
119
|
+
record: this.record,
|
|
110
120
|
lockedNode: this.entity
|
|
111
121
|
});
|
|
112
122
|
|
package/src/frame-graph-view.js
CHANGED
|
@@ -238,6 +238,7 @@ function instancePage(list, key, ctx) {
|
|
|
238
238
|
text: `${instanceName(instance, list)} · ${material} · ${instance.mesh?.vertexBuffer?.numVertices ?? 0} verts` +
|
|
239
239
|
`${skipped ? ' · not drawn in this pass' : ''}`,
|
|
240
240
|
cls: skipped ? 'null' : 'obj',
|
|
241
|
+
raw: instance,
|
|
241
242
|
expand: () => meshInstanceRows(instance),
|
|
242
243
|
select: debug ? () => debug.choose(key, index, instance) : undefined,
|
|
243
244
|
active: !!debug && debug.stepKey === key && debug.instance === instance
|
|
@@ -253,7 +254,8 @@ function instancePage(list, key, ctx) {
|
|
|
253
254
|
// pass properties the model shows explicitly, or that are plumbing
|
|
254
255
|
const SKIP_PASS = [
|
|
255
256
|
'name', 'enabled', 'executeEnabled', 'requiresCubemaps', 'device', 'renderTarget', 'colorOps',
|
|
256
|
-
'colorArrayOps', 'depthStencilOps', 'beforePasses', 'afterPasses', 'children', 'samples',
|
|
257
|
+
'colorArrayOps', 'depthStencilOps', 'internalBeforePasses', 'beforePasses', 'afterPasses', 'children', 'samples',
|
|
258
|
+
'firstCameraUse', 'lastCameraUse',
|
|
257
259
|
'scaleX', 'scaleY', 'options', 'fullSizeClearRect', 'layerRenderSteps', 'renderer', 'scene',
|
|
258
260
|
'shadowRenderer'
|
|
259
261
|
];
|
|
@@ -325,12 +327,15 @@ function colorFormat(rt, index, device) {
|
|
|
325
327
|
*/
|
|
326
328
|
function captureFrameGraph(app) {
|
|
327
329
|
const device = app.graphicsDevice;
|
|
328
|
-
|
|
330
|
+
// engines before 2.24 name the list renderPasses
|
|
331
|
+
const passes = app.frameGraph?.passes ?? app.frameGraph?.renderPasses ?? [];
|
|
329
332
|
|
|
330
333
|
/** @type {Map<FramePass, FramePass>} */
|
|
331
334
|
const parentOf = new Map();
|
|
332
335
|
const mark = (pass) => {
|
|
333
|
-
|
|
336
|
+
// the internal before-passes, which engines before 2.24 do not have, execute ahead of the
|
|
337
|
+
// before-passes
|
|
338
|
+
const children = [...pass.internalBeforePasses ?? [], ...pass.beforePasses, ...pass.afterPasses, ...(Array.isArray(pass.children) ? pass.children : [])];
|
|
334
339
|
for (const child of children) {
|
|
335
340
|
parentOf.set(child, pass);
|
|
336
341
|
mark(child);
|
|
@@ -499,7 +504,8 @@ function passRows(frame, device) {
|
|
|
499
504
|
const layer = step.layer;
|
|
500
505
|
const enabled = layer.enabled && (pass.layerComposition?.isEnabled(layer, step.transparent) ?? true);
|
|
501
506
|
const camera = step.cameraComponent?.entity;
|
|
502
|
-
const
|
|
507
|
+
const use = cameraUse(step, i, pass);
|
|
508
|
+
const flags = `${use.first ? ' · first' : ''}${use.last ? ' · last' : ''}${enabled ? '' : ' · disabled'}`;
|
|
503
509
|
rows.push({
|
|
504
510
|
key: `${entry.key}/${i}`,
|
|
505
511
|
item: new LayerStepSelection(pass, step, i),
|
|
@@ -636,11 +642,14 @@ function buildPassModel(pass, ctx) {
|
|
|
636
642
|
const runs = Array.isArray(/** @type {any} */ (entry.parent).children) && /** @type {any} */ (entry.parent).children.includes(pass);
|
|
637
643
|
push(general, runs ? 'run by' : 'owned by', { text: passDisplayName(entry.parent), cls: 'ref', target: entry.parent });
|
|
638
644
|
}
|
|
645
|
+
const internalBeforePasses = /** @type {any} */ (pass).internalBeforePasses;
|
|
646
|
+
if (internalBeforePasses?.length) push(general, 'internal before passes', passList(internalBeforePasses));
|
|
639
647
|
if (pass.beforePasses.length) push(general, 'before passes', passList(pass.beforePasses));
|
|
640
648
|
if (pass.afterPasses.length) push(general, 'after passes', passList(pass.afterPasses));
|
|
641
649
|
const children = /** @type {any} */ (pass).children;
|
|
642
650
|
if (Array.isArray(children) && children.length) push(general, 'per-view passes', passList(children));
|
|
643
|
-
|
|
651
|
+
// engines from 2.24 no longer have the property
|
|
652
|
+
if (/** @type {any} */ (pass).requiresCubemaps !== undefined) push(general, 'requires cubemaps', read(pass, 'requiresCubemaps'));
|
|
644
653
|
sections.push(general);
|
|
645
654
|
|
|
646
655
|
const rt = entry ? entry.renderTarget : (pass.renderTarget === undefined ? undefined : (pass.renderTarget ?? device.backBuffer));
|
|
@@ -693,9 +702,10 @@ function buildPassModel(pass, ctx) {
|
|
|
693
702
|
push(section, `[${i}] camera`, describeValue(step.cameraComponent?.entity ?? null));
|
|
694
703
|
push(section, `[${i}] layer`, describeValue(layer));
|
|
695
704
|
const list = ctx.frame?.visible?.get(step) ?? null;
|
|
705
|
+
const use = cameraUse(step, i, pass);
|
|
696
706
|
push(section, `[${i}] draws`, {
|
|
697
707
|
text: `${step.transparent ? 'transparent' : 'opaque'}, ${drawnText(list, layer)}` +
|
|
698
|
-
`${enabled ? '' : ', disabled'}${
|
|
708
|
+
`${enabled ? '' : ', disabled'}${use.first ? ', first camera use' : ''}${use.last ? ', last camera use' : ''}`,
|
|
699
709
|
cls: 'obj',
|
|
700
710
|
expand: list ? () => instancePage(list, `${ctx.passKey ?? ''}/${i}`, ctx) : undefined
|
|
701
711
|
});
|
|
@@ -720,6 +730,27 @@ function stepEnabled(step, pass) {
|
|
|
720
730
|
return step.layer.enabled && (pass.layerComposition?.isEnabled(step.layer, step.transparent) ?? true);
|
|
721
731
|
}
|
|
722
732
|
|
|
733
|
+
/**
|
|
734
|
+
* Whether a layer render step of a forward pass is the first to render its camera in the frame,
|
|
735
|
+
* and whether it is the last. Engines before 2.24 keep these flags on each step. Later ones keep
|
|
736
|
+
* them on the pass, which renders a single camera, so they belong to its first and its last step.
|
|
737
|
+
*
|
|
738
|
+
* @param {*} step - A layer render step.
|
|
739
|
+
* @param {number} index - The index of the step in its pass.
|
|
740
|
+
* @param {RenderPassForward} pass - The pass it belongs to.
|
|
741
|
+
* @returns {{ first: boolean, last: boolean }} The flags.
|
|
742
|
+
*/
|
|
743
|
+
function cameraUse(step, index, pass) {
|
|
744
|
+
const forward = /** @type {any} */ (pass);
|
|
745
|
+
if (forward.firstCameraUse === undefined) {
|
|
746
|
+
return { first: !!step.firstCameraUse, last: !!step.lastCameraUse };
|
|
747
|
+
}
|
|
748
|
+
return {
|
|
749
|
+
first: !!forward.firstCameraUse && index === 0,
|
|
750
|
+
last: !!forward.lastCameraUse && index === pass.layerRenderSteps.length - 1
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
|
|
723
754
|
/**
|
|
724
755
|
* Everything the property view shows for one layer step of a forward pass: the camera and layer it
|
|
725
756
|
* renders, what it clears, and the instances it drew in draw order, listed straight away and paged
|
|
@@ -746,8 +777,9 @@ function buildStepModel(selection, ctx) {
|
|
|
746
777
|
push(general, 'draws', { text: drawnText(list, layer), cls: list ? 'num' : 'null' });
|
|
747
778
|
push(general, 'enabled', describeValue(enabled));
|
|
748
779
|
push(general, 'clears', { text: clears || 'nothing', cls: clears ? 'obj' : 'null' });
|
|
749
|
-
|
|
750
|
-
if (
|
|
780
|
+
const use = cameraUse(step, index, pass);
|
|
781
|
+
if (use.first) push(general, 'first camera use', describeValue(true));
|
|
782
|
+
if (use.last) push(general, 'last camera use', describeValue(true));
|
|
751
783
|
if (ctx.debug?.stepKey === ctx.passKey && list) {
|
|
752
784
|
push(general, 'debug frame', { text: `stops after draw ${ctx.debug.index} of ${list.instances.length}`, cls: 'num' });
|
|
753
785
|
}
|
|
@@ -764,4 +796,4 @@ function buildStepModel(selection, ctx) {
|
|
|
764
796
|
return sections;
|
|
765
797
|
}
|
|
766
798
|
|
|
767
|
-
export { INSTANCES_PER_PAGE, LayerStepSelection, buildPassModel, buildStepModel, captureFrameGraph, passRows };
|
|
799
|
+
export { INSTANCES_PER_PAGE, LayerStepSelection, buildPassModel, buildStepModel, captureFrameGraph, passRows, profilerName };
|
package/src/hierarchy-view.js
CHANGED
|
@@ -125,6 +125,14 @@ class HierarchyView {
|
|
|
125
125
|
*/
|
|
126
126
|
isLocked = () => false;
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Decides which nodes are left out of the tree, with everything below them, such as the
|
|
130
|
+
* entity of a gizmo the panel adds to the hierarchy. Defaults to none.
|
|
131
|
+
*
|
|
132
|
+
* @type {(node: GraphNode) => boolean}
|
|
133
|
+
*/
|
|
134
|
+
isHidden = () => false;
|
|
135
|
+
|
|
128
136
|
/**
|
|
129
137
|
* The root of the rendered hierarchy.
|
|
130
138
|
*
|
|
@@ -230,7 +238,9 @@ class HierarchyView {
|
|
|
230
238
|
this.nodeCount++;
|
|
231
239
|
if (node instanceof Entity) this.entityCount++;
|
|
232
240
|
let below = 0;
|
|
233
|
-
for (const child of node.children)
|
|
241
|
+
for (const child of node.children) {
|
|
242
|
+
if (!this.isHidden(child)) below += 1 + this._countSubtree(child);
|
|
243
|
+
}
|
|
234
244
|
this._descendants.set(node, below);
|
|
235
245
|
return below;
|
|
236
246
|
}
|
|
@@ -276,6 +286,18 @@ class HierarchyView {
|
|
|
276
286
|
}
|
|
277
287
|
}
|
|
278
288
|
|
|
289
|
+
/**
|
|
290
|
+
* @param {Node} element - An element, such as the target of a context menu event.
|
|
291
|
+
* @returns {GraphNode|null} The node whose row it is in, or null when it is in none. The rows
|
|
292
|
+
* of a node's children are nested under its element, so only the row itself is matched.
|
|
293
|
+
*/
|
|
294
|
+
nodeAt(element) {
|
|
295
|
+
for (const [node, entry] of this._entries) {
|
|
296
|
+
if (entry.row.contains(element)) return node;
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
|
|
279
301
|
/**
|
|
280
302
|
* Selects a node, expanding its ancestors and scrolling it into view.
|
|
281
303
|
*
|
|
@@ -369,14 +391,18 @@ class HierarchyView {
|
|
|
369
391
|
|
|
370
392
|
// children are materialized only when shown, or when a filter needs to match them
|
|
371
393
|
const children = node.children;
|
|
372
|
-
|
|
394
|
+
let childCount = 0;
|
|
395
|
+
for (const child of children) {
|
|
396
|
+
if (!this.isHidden(child)) childCount++;
|
|
397
|
+
}
|
|
373
398
|
const expanded = this._expanded.has(node);
|
|
374
399
|
let anyChildMatch = false;
|
|
375
400
|
|
|
376
401
|
if (childCount > 0 && (expanded || filter)) {
|
|
377
402
|
let cursor = entry.childrenEl.firstChild;
|
|
378
|
-
for (let i = 0; i <
|
|
403
|
+
for (let i = 0; i < children.length; i++) {
|
|
379
404
|
const child = children[i];
|
|
405
|
+
if (this.isHidden(child)) continue;
|
|
380
406
|
if (this._visit(child, depth + 1, filter)) anyChildMatch = true;
|
|
381
407
|
const childEl = this._entries.get(child).el;
|
|
382
408
|
if (childEl !== cursor) {
|