@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/mesh-view.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Mesh, VertexBuffer } from 'playcanvas';
|
|
|
3
3
|
import { describeValue } from './describe.js';
|
|
4
4
|
import { collectMeshInstances } from './instance-survey.js';
|
|
5
5
|
import { nodeLabel } from './memory-view.js';
|
|
6
|
-
import { formatBytes, makeSection, push } from './model.js';
|
|
6
|
+
import { formatBytes, makeSection, makeUsageSection, push } from './model.js';
|
|
7
7
|
import { meshInstanceRows, meshRows } from './node-model.js';
|
|
8
8
|
|
|
9
9
|
/** @import { AppBase } from 'playcanvas' */
|
|
@@ -200,17 +200,18 @@ function meshNote(survey) {
|
|
|
200
200
|
* format, and what uses it, with each mesh instance opening in place.
|
|
201
201
|
*
|
|
202
202
|
* @param {Mesh} mesh - The mesh.
|
|
203
|
-
* @param {{ app: AppBase }} ctx - The app, to find the mesh's users
|
|
203
|
+
* @param {{ app: AppBase, backlinks?: boolean }} ctx - The app, to find the mesh's users, and
|
|
204
|
+
* whether to find them at all, which a copy has no use for.
|
|
204
205
|
* @returns {PropertySection[]} The sections.
|
|
205
206
|
*/
|
|
206
207
|
function buildMeshModel(mesh, ctx) {
|
|
207
|
-
const users = surveyMeshes(ctx.app).users.get(mesh) ?? [];
|
|
208
|
-
|
|
209
208
|
const general = makeSection('mesh', `Mesh #${mesh.id}`);
|
|
210
209
|
push(general, 'size', { text: formatBytes(meshBytes(mesh)), cls: 'num' });
|
|
211
210
|
general.rows.push(...meshRows(mesh));
|
|
211
|
+
if (ctx.backlinks === false) return [general];
|
|
212
212
|
|
|
213
|
-
const
|
|
213
|
+
const users = surveyMeshes(ctx.app).users.get(mesh) ?? [];
|
|
214
|
+
const usage = makeUsageSection('users', 'Used by');
|
|
214
215
|
const instances = instanceCount(users);
|
|
215
216
|
push(usage, 'users', {
|
|
216
217
|
text: users.length ?
|
package/src/model.js
CHANGED
|
@@ -25,6 +25,8 @@ import { collectProperties, describeValue } from './describe.js';
|
|
|
25
25
|
* @property {string} title - The title.
|
|
26
26
|
* @property {PropertyRow[]} rows - The rows.
|
|
27
27
|
* @property {boolean} [collapsed] - Whether the section starts out collapsed.
|
|
28
|
+
* @property {boolean} [backlink] - Whether the section lists what uses the subject, which copies
|
|
29
|
+
* leave out, see {@link Described#backlink}.
|
|
28
30
|
*/
|
|
29
31
|
|
|
30
32
|
/**
|
|
@@ -37,6 +39,26 @@ function makeSection(key, title, collapsed = false) {
|
|
|
37
39
|
return { key, title, rows: [], collapsed };
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} key - The section key.
|
|
44
|
+
* @param {string} title - The section title.
|
|
45
|
+
* @returns {PropertySection} An empty section listing what uses the subject, which copies leave out.
|
|
46
|
+
*/
|
|
47
|
+
function makeUsageSection(key, title) {
|
|
48
|
+
return { key, title, rows: [], collapsed: false, backlink: true };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Marks a value as referring back to what holds or uses the subject, which copies leave out.
|
|
53
|
+
*
|
|
54
|
+
* @param {Described} value - The value.
|
|
55
|
+
* @returns {Described} The same value.
|
|
56
|
+
*/
|
|
57
|
+
function backlink(value) {
|
|
58
|
+
value.backlink = true;
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
|
|
40
62
|
/**
|
|
41
63
|
* Reads a property, turning a throwing getter into an error value rather than a broken panel.
|
|
42
64
|
*
|
|
@@ -165,6 +187,6 @@ function renderTargetSummary(rt, device) {
|
|
|
165
187
|
}
|
|
166
188
|
|
|
167
189
|
export {
|
|
168
|
-
attachmentsText, formatBytes, formatName, makeSection, passDisplayName, push, pushRow,
|
|
169
|
-
reflectRows, renderTargetSummary
|
|
190
|
+
attachmentsText, backlink, formatBytes, formatName, makeSection, makeUsageSection, passDisplayName, push, pushRow,
|
|
191
|
+
read, reflectInto, reflectRows, renderTargetSummary
|
|
170
192
|
};
|
package/src/node-model.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
import { pushAssetRows } from './asset-view.js';
|
|
6
6
|
import { collectProperties, describeValue } from './describe.js';
|
|
7
|
-
import { formatBytes, makeSection, push, pushRow, read, reflectInto, reflectRows } from './model.js';
|
|
7
|
+
import { backlink, formatBytes, makeSection, push, pushRow, read, reflectInto, reflectRows } from './model.js';
|
|
8
8
|
|
|
9
9
|
/** @import { LayerComposition } from 'playcanvas' */
|
|
10
10
|
/** @import { Material } from 'playcanvas' */
|
|
@@ -68,24 +68,76 @@ function nodeSection(node) {
|
|
|
68
68
|
push(section, 'enabled in hierarchy', describeValue(node.enabled));
|
|
69
69
|
push(section, 'tags', describeValue(node.tags.list()));
|
|
70
70
|
push(section, 'path', describeValue(node.path));
|
|
71
|
-
push(section, 'parent', describeValue(node.parent));
|
|
71
|
+
push(section, 'parent', backlink(describeValue(node.parent)));
|
|
72
72
|
push(section, 'children', describeValue(node.children.length));
|
|
73
73
|
|
|
74
74
|
return section;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
+
* @param {string} text - Numbers, separated by commas or spaces, optionally in brackets.
|
|
79
|
+
* @returns {number[]|null} The numbers, or null when any of them is not a finite number.
|
|
80
|
+
*/
|
|
81
|
+
function parseNumbers(text) {
|
|
82
|
+
const numbers = text.split(/[\s,;()[\]]+/).filter(Boolean).map(Number);
|
|
83
|
+
return numbers.every(Number.isFinite) ? numbers : null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Moves the physics body of a node to where the node now is. A dynamic or kinematic body would
|
|
88
|
+
* otherwise put the node back where the body is on the next step of the simulation.
|
|
89
|
+
*
|
|
90
|
+
* @param {GraphNode} node - A node whose transform was changed.
|
|
91
|
+
*/
|
|
92
|
+
function syncBody(node) {
|
|
93
|
+
const body = /** @type {any} */ (node).c?.rigidbody;
|
|
94
|
+
if (body?.enabled && body.body) body.teleport(node.getPosition(), node.getRotation());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Makes a vector of a node's transform editable as its components, separated by commas. The text
|
|
99
|
+
* holds every digit of each, so a component that is not touched is set back exactly as it was.
|
|
100
|
+
*
|
|
101
|
+
* @param {Described} value - The described vector.
|
|
78
102
|
* @param {GraphNode} node - The node.
|
|
79
|
-
* @
|
|
103
|
+
* @param {import('playcanvas').Vec3} vector - The vector.
|
|
104
|
+
* @param {(x: number, y: number, z: number) => void} set - Sets it on the node.
|
|
105
|
+
* @param {boolean} [uniform] - Whether a single number sets all three components, as for a scale.
|
|
106
|
+
* @returns {Described} The value, editable.
|
|
107
|
+
*/
|
|
108
|
+
function editVector(value, node, vector, set, uniform = false) {
|
|
109
|
+
value.edit = {
|
|
110
|
+
text: `${vector.x}, ${vector.y}, ${vector.z}`,
|
|
111
|
+
apply: (text) => {
|
|
112
|
+
const numbers = parseNumbers(text);
|
|
113
|
+
if (uniform && numbers?.length === 1) numbers.push(numbers[0], numbers[0]);
|
|
114
|
+
if (numbers?.length !== 3) return false;
|
|
115
|
+
set(numbers[0], numbers[1], numbers[2]);
|
|
116
|
+
syncBody(node);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param {GraphNode} node - The node.
|
|
125
|
+
* @returns {PropertySection} The transform section. Its positions, rotations and local scale are
|
|
126
|
+
* editable; the world scale only follows from the scales of the node and its ancestors.
|
|
80
127
|
*/
|
|
81
128
|
function transformSection(node) {
|
|
82
129
|
const section = makeSection('transform', 'Transform');
|
|
83
130
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
131
|
+
const localPosition = node.getLocalPosition();
|
|
132
|
+
const localRotation = node.getLocalEulerAngles();
|
|
133
|
+
const localScale = node.getLocalScale();
|
|
134
|
+
const position = node.getPosition();
|
|
135
|
+
const rotation = node.getEulerAngles();
|
|
136
|
+
push(section, 'local position', editVector(describeValue(localPosition), node, localPosition, (x, y, z) => node.setLocalPosition(x, y, z)));
|
|
137
|
+
push(section, 'local rotation', editVector(describeValue(localRotation), node, localRotation, (x, y, z) => node.setLocalEulerAngles(x, y, z)));
|
|
138
|
+
push(section, 'local scale', editVector(describeValue(localScale), node, localScale, (x, y, z) => node.setLocalScale(x, y, z), true));
|
|
139
|
+
push(section, 'world position', editVector(describeValue(position), node, position, (x, y, z) => node.setPosition(x, y, z)));
|
|
140
|
+
push(section, 'world rotation', editVector(describeValue(rotation), node, rotation, (x, y, z) => node.setEulerAngles(x, y, z)));
|
|
89
141
|
push(section, 'world scale', describeValue(node.getScale()));
|
|
90
142
|
push(section, 'forward', describeValue(node.forward));
|
|
91
143
|
|
|
@@ -105,9 +157,10 @@ function componentSection(name, component) {
|
|
|
105
157
|
|
|
106
158
|
const handled = [...SKIP_COMPONENT, ...assetProperties];
|
|
107
159
|
|
|
108
|
-
// layer ids, named from the composition they belong to
|
|
160
|
+
// layer ids, named from the composition they belong to. Other lists called layers, such as the
|
|
161
|
+
// animation layers of an anim component, are shown like any other property
|
|
109
162
|
const layers = /** @type {any} */ (component).layers;
|
|
110
|
-
if (Array.isArray(layers)) {
|
|
163
|
+
if (Array.isArray(layers) && layers.every(id => typeof id === 'number')) {
|
|
111
164
|
const composition = /** @type {any} */ (component).system?.app?.scene?.layers ?? null;
|
|
112
165
|
push(section, 'layers', layersValue(layers, composition));
|
|
113
166
|
handled.push('layers');
|
|
@@ -401,4 +454,21 @@ function buildNodeModel(node) {
|
|
|
401
454
|
return sections;
|
|
402
455
|
}
|
|
403
456
|
|
|
404
|
-
|
|
457
|
+
/**
|
|
458
|
+
* The sections a component shows under its entity, for a component reached on its own, such as
|
|
459
|
+
* through a link.
|
|
460
|
+
*
|
|
461
|
+
* @param {Component} component - The component.
|
|
462
|
+
* @returns {PropertySection[]} Its section, followed by one per script instance of a script component.
|
|
463
|
+
*/
|
|
464
|
+
function buildComponentModel(component) {
|
|
465
|
+
const name = /** @type {any} */ (component).system?.id ?? component.constructor.name;
|
|
466
|
+
const sections = [componentSection(name, component)];
|
|
467
|
+
if (name === 'script') sections.push(...scriptSections(/** @type {any} */ (component)));
|
|
468
|
+
return sections;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export {
|
|
472
|
+
buildComponentModel, buildNodeModel, layersValue, materialRows, materialTextures, meshInstanceRows, meshRows,
|
|
473
|
+
scriptInstanceRows, syncBody, vertexFormatValue
|
|
474
|
+
};
|