@playcanvas/inspector 0.1.0 → 0.3.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 +47 -26
- package/package.json +12 -6
- 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 +51 -2
- package/src/frame-graph-view.js +1 -0
- package/src/hierarchy-view.js +29 -3
- package/src/inspector.js +406 -59
- 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 +78 -9
- package/src/property-view.js +159 -5
- package/src/render-target-view.js +3 -3
- package/src/script-view.js +21 -12
- package/src/styles.js +196 -2
- package/src/texture-view.js +4 -4
- package/src/transform-tool.js +185 -0
- package/types/asset-usage.d.ts +2 -0
- package/types/asset-view.d.ts +17 -10
- package/types/camera-view.d.ts +12 -6
- package/types/context-menu.d.ts +90 -0
- package/types/copy-json.d.ts +69 -0
- package/types/describe.d.ts +3 -2
- package/types/entity-inspector-script.d.ts +2 -2
- package/types/frame-graph-view.d.ts +6 -2
- package/types/hierarchy-view.d.ts +25 -11
- package/types/input/fly-controller.d.ts +4 -4
- package/types/input/input.d.ts +2 -2
- package/types/input/orbit-controller.d.ts +6 -6
- package/types/input/pose.d.ts +9 -7
- package/types/inspector.d.ts +144 -22
- package/types/instance-survey.d.ts +3 -1
- package/types/list-view.d.ts +44 -3
- package/types/material-view.d.ts +13 -6
- package/types/memory-view.d.ts +37 -30
- package/types/mesh-view.d.ts +12 -5
- package/types/model.d.ts +21 -3
- package/types/node-model.d.ts +30 -6
- package/types/physics-debug.d.ts +9 -5
- package/types/physics-view.d.ts +8 -6
- package/types/picker/picker.d.ts +15 -6
- package/types/picker/render-pass-picker.d.ts +16 -10
- package/types/property-view.d.ts +41 -0
- package/types/render-target-view.d.ts +10 -7
- package/types/renderers/texture-renderer-shaders.d.ts +1 -1
- package/types/renderers/texture-renderer.d.ts +11 -5
- package/types/renderers/wire-renderer.d.ts +14 -5
- package/types/script-view.d.ts +10 -4
- package/types/shader-view.d.ts +10 -6
- package/types/texture-view.d.ts +8 -5
- package/types/transform-tool.d.ts +92 -0
- package/types/viewport-tools.d.ts +25 -18
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
|
|
|
@@ -253,10 +272,39 @@ function describeValue(value, depth = 0) {
|
|
|
253
272
|
};
|
|
254
273
|
}
|
|
255
274
|
|
|
275
|
+
// a call of the engine's deprecation and removal notices, which a debug build keeps in the source
|
|
276
|
+
const DEPRECATION_CALL = /\bDebug\.(?:deprecated|removed)\(/;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Whether a getter of each accessor is a deprecated or removed API, keyed by the getter.
|
|
280
|
+
*
|
|
281
|
+
* @type {WeakMap<Function, boolean>}
|
|
282
|
+
*/
|
|
283
|
+
const deprecatedGetters = new WeakMap();
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Whether a getter is a deprecated or removed engine API, which warns when read. Told from its
|
|
287
|
+
* source, so the getter is never called: reading it would print the notice, which is meant for the
|
|
288
|
+
* app's developer. Release builds strip the notices, and with them the warnings, so there such a
|
|
289
|
+
* getter is listed like any other.
|
|
290
|
+
*
|
|
291
|
+
* @param {Function} getter - The getter.
|
|
292
|
+
* @returns {boolean} Whether it is deprecated or removed.
|
|
293
|
+
*/
|
|
294
|
+
function isDeprecatedGetter(getter) {
|
|
295
|
+
let deprecated = deprecatedGetters.get(getter);
|
|
296
|
+
if (deprecated === undefined) {
|
|
297
|
+
deprecated = DEPRECATION_CALL.test(Function.prototype.toString.call(getter));
|
|
298
|
+
deprecatedGetters.set(getter, deprecated);
|
|
299
|
+
}
|
|
300
|
+
return deprecated;
|
|
301
|
+
}
|
|
302
|
+
|
|
256
303
|
/**
|
|
257
304
|
* Lists the public properties of an object: accessors with a getter found on its prototype chain
|
|
258
305
|
* (most derived class first, in declaration order), followed by its own enumerable data fields.
|
|
259
|
-
* Names starting with an underscore, methods
|
|
306
|
+
* Names starting with an underscore, methods, getters of deprecated or removed engine APIs and
|
|
307
|
+
* anything in `skip` are left out.
|
|
260
308
|
*
|
|
261
309
|
* @param {object} obj - The object to reflect on.
|
|
262
310
|
* @param {object[]} stopPrototypes - Prototypes at which to stop walking the chain. These and
|
|
@@ -275,6 +323,7 @@ function collectProperties(obj, stopPrototypes, skip = []) {
|
|
|
275
323
|
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
276
324
|
if (!descriptor?.get) continue;
|
|
277
325
|
seen.add(name);
|
|
326
|
+
if (isDeprecatedGetter(descriptor.get)) continue;
|
|
278
327
|
names.push(name);
|
|
279
328
|
}
|
|
280
329
|
}
|
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
|
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) {
|