@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.
Files changed (57) hide show
  1. package/README.md +47 -26
  2. package/package.json +12 -6
  3. package/src/asset-view.js +24 -17
  4. package/src/camera-view.js +5 -3
  5. package/src/context-menu.js +231 -0
  6. package/src/copy-json.js +692 -0
  7. package/src/describe.js +51 -2
  8. package/src/frame-graph-view.js +1 -0
  9. package/src/hierarchy-view.js +29 -3
  10. package/src/inspector.js +406 -59
  11. package/src/list-view.js +118 -12
  12. package/src/material-view.js +7 -6
  13. package/src/memory-view.js +224 -66
  14. package/src/mesh-view.js +6 -5
  15. package/src/model.js +24 -2
  16. package/src/node-model.js +78 -9
  17. package/src/property-view.js +159 -5
  18. package/src/render-target-view.js +3 -3
  19. package/src/script-view.js +21 -12
  20. package/src/styles.js +196 -2
  21. package/src/texture-view.js +4 -4
  22. package/src/transform-tool.js +185 -0
  23. package/types/asset-usage.d.ts +2 -0
  24. package/types/asset-view.d.ts +17 -10
  25. package/types/camera-view.d.ts +12 -6
  26. package/types/context-menu.d.ts +90 -0
  27. package/types/copy-json.d.ts +69 -0
  28. package/types/describe.d.ts +3 -2
  29. package/types/entity-inspector-script.d.ts +2 -2
  30. package/types/frame-graph-view.d.ts +6 -2
  31. package/types/hierarchy-view.d.ts +25 -11
  32. package/types/input/fly-controller.d.ts +4 -4
  33. package/types/input/input.d.ts +2 -2
  34. package/types/input/orbit-controller.d.ts +6 -6
  35. package/types/input/pose.d.ts +9 -7
  36. package/types/inspector.d.ts +144 -22
  37. package/types/instance-survey.d.ts +3 -1
  38. package/types/list-view.d.ts +44 -3
  39. package/types/material-view.d.ts +13 -6
  40. package/types/memory-view.d.ts +37 -30
  41. package/types/mesh-view.d.ts +12 -5
  42. package/types/model.d.ts +21 -3
  43. package/types/node-model.d.ts +30 -6
  44. package/types/physics-debug.d.ts +9 -5
  45. package/types/physics-view.d.ts +8 -6
  46. package/types/picker/picker.d.ts +15 -6
  47. package/types/picker/render-pass-picker.d.ts +16 -10
  48. package/types/property-view.d.ts +41 -0
  49. package/types/render-target-view.d.ts +10 -7
  50. package/types/renderers/texture-renderer-shaders.d.ts +1 -1
  51. package/types/renderers/texture-renderer.d.ts +11 -5
  52. package/types/renderers/wire-renderer.d.ts +14 -5
  53. package/types/script-view.d.ts +10 -4
  54. package/types/shader-view.d.ts +10 -6
  55. package/types/texture-view.d.ts +8 -5
  56. package/types/transform-tool.d.ts +92 -0
  57. package/types/viewport-tools.d.ts +25 -18
package/src/styles.js CHANGED
@@ -29,7 +29,10 @@ const ICONS = {
29
29
  fly: '<path d="m16 13 5.22 3.48a.5.5 0 0 0 .78-.42V7.87a.5.5 0 0 0-.75-.43L16 10.5"/><rect x="2" y="6" width="14" height="12" rx="2"/>',
30
30
  popout: '<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',
31
31
  dock: '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M15 3v18"/>',
32
- close: '<path d="M18 6 6 18M6 6l12 12"/>'
32
+ close: '<path d="M18 6 6 18M6 6l12 12"/>',
33
+ translate: '<path d="M12 3v18M3 12h18"/><path d="m9 6 3-3 3 3"/><path d="m9 18 3 3 3-3"/><path d="m6 9-3 3 3 3"/><path d="m18 9 3 3-3 3"/>',
34
+ rotate: '<path d="M20 12a8 8 0 1 1-2.34-5.66"/><path d="M20 3v4h-4"/>',
35
+ scale: '<rect x="3" y="11" width="10" height="10" rx="1"/><path d="m13 11 8-8"/><path d="M15 3h6v6"/>'
33
36
  };
34
37
 
35
38
  /**
@@ -368,7 +371,8 @@ ${ICON_RULES}
368
371
  .pci-tip {
369
372
  display: none;
370
373
  position: fixed;
371
- z-index: 2;
374
+ /* above the menu, whose entries have tooltips */
375
+ z-index: 3;
372
376
  max-width: 320px;
373
377
  padding: 5px 8px;
374
378
  background: var(--pci-raised);
@@ -381,6 +385,93 @@ ${ICON_RULES}
381
385
  pointer-events: none;
382
386
  }
383
387
 
388
+ .pci-menu {
389
+ display: none;
390
+ position: fixed;
391
+ z-index: 2;
392
+ min-width: 200px;
393
+ max-width: 320px;
394
+ padding: 4px 0;
395
+ background: var(--pci-raised);
396
+ color: var(--pci-text);
397
+ border: 1px solid var(--pci-border-strong);
398
+ border-radius: 6px;
399
+ box-shadow: var(--pci-shadow);
400
+ }
401
+
402
+ .pci-menu-title {
403
+ padding: 2px 10px 5px;
404
+ margin-bottom: 4px;
405
+ color: var(--pci-text-muted);
406
+ border-bottom: 1px solid var(--pci-border);
407
+ overflow: hidden;
408
+ text-overflow: ellipsis;
409
+ white-space: nowrap;
410
+ }
411
+
412
+ .pci-menu-item {
413
+ display: flex;
414
+ align-items: center;
415
+ gap: 8px;
416
+ padding: 3px 10px;
417
+ cursor: pointer;
418
+ }
419
+
420
+ .pci-menu-item:hover {
421
+ background: var(--pci-selected);
422
+ }
423
+
424
+ .pci-menu-label {
425
+ flex: 1 1 auto;
426
+ }
427
+
428
+ .pci-menu-buttons {
429
+ display: flex;
430
+ gap: 2px;
431
+ }
432
+
433
+ .pci-menu-button {
434
+ font: inherit;
435
+ line-height: 16px;
436
+ min-width: 20px;
437
+ padding: 0 4px;
438
+ color: var(--pci-text-secondary);
439
+ background: rgba(255, 255, 255, 0.07);
440
+ border: none;
441
+ border-radius: 4px;
442
+ cursor: pointer;
443
+ }
444
+
445
+ .pci-menu-button:not(:disabled):hover {
446
+ color: #ffffff;
447
+ background: var(--pci-accent-strong);
448
+ }
449
+
450
+ .pci-menu-button:disabled {
451
+ opacity: 0.35;
452
+ cursor: default;
453
+ }
454
+
455
+ .pci-toast {
456
+ display: none;
457
+ position: absolute;
458
+ z-index: 2;
459
+ left: 50%;
460
+ bottom: 36px;
461
+ transform: translateX(-50%);
462
+ max-width: calc(100% - 24px);
463
+ padding: 5px 10px;
464
+ background: var(--pci-raised);
465
+ color: var(--pci-text);
466
+ border: 1px solid var(--pci-border-strong);
467
+ border-radius: 6px;
468
+ box-shadow: var(--pci-shadow);
469
+ white-space: nowrap;
470
+ overflow: hidden;
471
+ text-overflow: ellipsis;
472
+ pointer-events: none;
473
+ }
474
+
384
475
  .pci-check {
385
476
  display: inline-flex;
386
477
  align-items: center;
@@ -509,6 +600,70 @@ ${ICON_RULES}
509
600
  opacity: 0.45;
510
601
  }
511
602
 
603
+ /* the head of a group of rows, which opens and closes it */
604
+ .pci-lrow.pci-lrow-header {
605
+ background-color: var(--pci-raised);
606
+ color: var(--pci-text);
607
+ font-weight: 600;
608
+ }
609
+
610
+ .pci-lrow.pci-lrow-header ~ .pci-lrow.pci-lrow-header {
611
+ border-top: 1px solid var(--pci-border);
612
+ }
613
+
614
+ .pci-lrow.pci-lrow-header::before {
615
+ content: "▸";
616
+ flex: 0 0 10px;
617
+ color: var(--pci-text-label);
618
+ font-size: 12px;
619
+ }
620
+
621
+ .pci-lrow.pci-lrow-header.pci-open::before {
622
+ content: "▾";
623
+ }
624
+
625
+ .pci-lrow.pci-lrow-header.pci-leaf::before {
626
+ content: "";
627
+ }
628
+
629
+ .pci-lrow.pci-lrow-header:hover {
630
+ background-color: #263133;
631
+ }
632
+
633
+ /* rows that only show figures, and headers with nothing to open */
634
+ .pci-lrow.pci-inert,
635
+ .pci-lrow.pci-lrow-header.pci-leaf {
636
+ cursor: default;
637
+ }
638
+
639
+ .pci-lrow.pci-inert:hover {
640
+ background-color: transparent;
641
+ }
642
+
643
+ .pci-lrow.pci-lrow-header.pci-leaf:hover {
644
+ background-color: var(--pci-raised);
645
+ }
646
+
647
+ /* a count and a size in columns of their own, lining up from row to row */
648
+ .pci-cell-count {
649
+ flex-shrink: 0;
650
+ margin-left: auto;
651
+ min-width: 5ch;
652
+ text-align: right;
653
+ color: var(--pci-text-label);
654
+ font-family: var(--pci-mono);
655
+ font-size: 10.5px;
656
+ font-weight: normal;
657
+ }
658
+
659
+ .pci-cell-size {
660
+ flex-shrink: 0;
661
+ min-width: 11ch;
662
+ text-align: right;
663
+ font-family: var(--pci-mono);
664
+ font-size: 10.5px;
665
+ }
666
+
512
667
  .pci-cell {
513
668
  flex: 0 1 auto;
514
669
  min-width: 0;
@@ -782,6 +937,45 @@ ${ICON_RULES}
782
937
  .pci-v-ref { color: #4fc1ff; }
783
938
  .pci-v-err { color: #f14c4c; }
784
939
 
940
+ /* an editable value reads as a text field, and its editor opens in the same place at the same size */
941
+ .pci-prop.pci-editable .pci-value {
942
+ box-sizing: border-box;
943
+ margin: -1px 0;
944
+ padding: 0 4px;
945
+ cursor: text;
946
+ background: var(--pci-input);
947
+ border: 1px solid var(--pci-border-strong);
948
+ border-radius: 3px;
949
+ }
950
+
951
+ .pci-prop.pci-editable .pci-value:hover {
952
+ border-color: var(--pci-text-muted);
953
+ }
954
+
955
+ .pci-prop.pci-editing .pci-value {
956
+ margin: 0;
957
+ padding: 0;
958
+ background: none;
959
+ border: none;
960
+ }
961
+
962
+ .pci-edit {
963
+ box-sizing: border-box;
964
+ width: 100%;
965
+ margin: -1px 0;
966
+ padding: 0 4px;
967
+ font: inherit;
968
+ color: var(--pci-text);
969
+ background: var(--pci-input);
970
+ border: 1px solid var(--pci-accent);
971
+ border-radius: 3px;
972
+ outline: none;
973
+ }
974
+
975
+ .pci-edit.pci-invalid {
976
+ border-color: #f14c4c;
977
+ }
978
+
785
979
  .pci-link {
786
980
  cursor: pointer;
787
981
  text-decoration: underline dotted;
@@ -4,7 +4,7 @@ import {
4
4
 
5
5
  import { containerParts, resourceAssets } from './asset-view.js';
6
6
  import { describeValue } from './describe.js';
7
- import { formatBytes, formatName, makeSection, push, read, reflectRows } from './model.js';
7
+ import { backlink, formatBytes, formatName, makeSection, push, read, reflectRows } from './model.js';
8
8
 
9
9
  /** @import { AppBase } from 'playcanvas' */
10
10
  /** @import { GraphicsDevice } from 'playcanvas' */
@@ -154,15 +154,15 @@ function buildTextureModel(texture, ctx) {
154
154
  push(general, 'from asset', describeValue(asset));
155
155
  // a texture a glb carries comes from the container that loaded it
156
156
  const container = containerParts(registry).parentOf.get(asset);
157
- if (container) push(general, 'from container', describeValue(container));
157
+ if (container) push(general, 'from container', backlink(describeValue(container)));
158
158
  }
159
159
 
160
160
  const owners = attachmentTargets(ctx.device).get(texture) ?? [];
161
- push(general, 'attached to', {
161
+ push(general, 'attached to', backlink({
162
162
  text: owners.length ? `${owners.length} render target${owners.length === 1 ? '' : 's'}` : 'no render target',
163
163
  cls: owners.length ? 'obj' : 'null',
164
164
  items: owners.map(rt => ({ label: '', text: rt.name || '(unnamed)', cls: 'ref', target: rt }))
165
- });
165
+ }));
166
166
  sections.push(general);
167
167
 
168
168
  const sampling = makeSection('sampling', 'Sampling');
@@ -0,0 +1,185 @@
1
+ import { Gizmo, RotateGizmo, ScaleGizmo, TransformGizmo, TranslateGizmo } from 'playcanvas';
2
+
3
+ import { syncBody } from './node-model.js';
4
+
5
+ /** @import { AppBase } from 'playcanvas' */
6
+ /** @import { CameraComponent } from 'playcanvas' */
7
+ /** @import { Entity } from 'playcanvas' */
8
+ /** @import { GraphNode } from 'playcanvas' */
9
+ /** @import { Layer } from 'playcanvas' */
10
+
11
+ /**
12
+ * @typedef {'translate'|'rotate'|'scale'} TransformMode
13
+ * @ignore
14
+ */
15
+
16
+ /** @type {Record<TransformMode, typeof TranslateGizmo|typeof RotateGizmo|typeof ScaleGizmo>} */
17
+ const GIZMOS = { translate: TranslateGizmo, rotate: RotateGizmo, scale: ScaleGizmo };
18
+
19
+ // the input the tool sees first, ahead of the app, so a handle being dragged keeps it to itself
20
+ const POINTER_EVENTS = [
21
+ 'pointerdown', 'pointermove', 'pointerup', 'pointercancel', 'mousedown', 'mousemove', 'mouseup', 'click',
22
+ 'dblclick', 'wheel', 'contextmenu', 'touchstart', 'touchmove', 'touchend'
23
+ ];
24
+
25
+ /**
26
+ * Moves, rotates or scales a node in the view with one of the engine's transform gizmos, drawn on
27
+ * a layer of its own over the view of a camera. The gizmo listens to the canvas itself, after the
28
+ * app's own listeners, so a drag of its handles would also reach the app and move its camera too.
29
+ * The tool takes those listeners away and hands the gizmo the pointer itself: a press on a handle
30
+ * and the drag that follows go to the gizmo alone, and everything else to the app as usual.
31
+ *
32
+ * The gizmo has no public way to be handed input, so it is handed its own pointer handlers. Engines
33
+ * whose gizmos lack them get no tool, see {@link TransformTool.supported}.
34
+ *
35
+ * @ignore
36
+ */
37
+ class TransformTool {
38
+ /**
39
+ * Whether the engine's gizmos can be driven by the tool.
40
+ *
41
+ * @type {boolean}
42
+ */
43
+ static get supported() {
44
+ const proto = /** @type {any} */ (Gizmo.prototype);
45
+ return ['_onPointerDown', '_onPointerMove', '_onPointerUp'].every(name => typeof proto[name] === 'function');
46
+ }
47
+
48
+ /**
49
+ * What the tool does to the node.
50
+ *
51
+ * @type {TransformMode}
52
+ */
53
+ mode;
54
+
55
+ /**
56
+ * @type {AppBase}
57
+ * @private
58
+ */
59
+ _app;
60
+
61
+ /**
62
+ * @type {Layer}
63
+ * @private
64
+ */
65
+ _layer;
66
+
67
+ /**
68
+ * @type {any}
69
+ * @private
70
+ */
71
+ _gizmo;
72
+
73
+ /**
74
+ * Whether a handle is being dragged, which keeps the pointer from the app until it is let go.
75
+ *
76
+ * @type {boolean}
77
+ * @private
78
+ */
79
+ _dragging = false;
80
+
81
+ /**
82
+ * Whether the click that follows the end of a drag is still to come, to keep it from the app.
83
+ *
84
+ * @type {boolean}
85
+ * @private
86
+ */
87
+ _endingDrag = false;
88
+
89
+ /**
90
+ * @param {AppBase} app - The app.
91
+ * @param {TransformMode} mode - What the tool does to the node.
92
+ * @param {CameraComponent} camera - The camera whose view the gizmo is drawn and used in.
93
+ * @param {() => void} [onTransform] - Called whenever the gizmo changes the node.
94
+ */
95
+ constructor(app, mode, camera, onTransform) {
96
+ this._app = app;
97
+ this.mode = mode;
98
+ this._layer = Gizmo.createLayer(app, 'Inspector gizmo');
99
+ const gizmo = new GIZMOS[mode](camera, this._layer);
100
+ this._gizmo = gizmo;
101
+
102
+ const canvas = app.graphicsDevice.canvas;
103
+ canvas.removeEventListener('pointerdown', gizmo._onPointerDown);
104
+ canvas.removeEventListener('pointermove', gizmo._onPointerMove);
105
+ canvas.removeEventListener('pointerup', gizmo._onPointerUp);
106
+
107
+ gizmo.on(Gizmo.EVENT_POINTERDOWN, (x, y, meshInstance) => {
108
+ this._dragging = !!meshInstance;
109
+ });
110
+ gizmo.on(TransformGizmo.EVENT_TRANSFORMMOVE, () => {
111
+ for (const node of gizmo.nodes) syncBody(node);
112
+ onTransform?.();
113
+ });
114
+ }
115
+
116
+ /**
117
+ * The entity of the gizmo, which the app's hierarchy holds while the tool is on.
118
+ *
119
+ * @type {Entity}
120
+ */
121
+ get root() {
122
+ return this._gizmo.root;
123
+ }
124
+
125
+ /**
126
+ * Puts the gizmo on a node, or takes it off.
127
+ *
128
+ * @param {GraphNode|null} node - The node, or null for none.
129
+ */
130
+ attach(node) {
131
+ this._gizmo.detach();
132
+ this._dragging = false;
133
+ if (node) this._gizmo.attach([node]);
134
+ }
135
+
136
+ /**
137
+ * Hands the gizmo a pointer event on the canvas, ahead of everything else listening to it.
138
+ *
139
+ * @param {Event} e - The event.
140
+ * @returns {boolean} Whether the gizmo keeps the event, which nothing else is then to see.
141
+ */
142
+ handle(e) {
143
+ const gizmo = this._gizmo;
144
+ const onCanvas = e.target === this._app.graphicsDevice.canvas;
145
+ switch (e.type) {
146
+ case 'pointerdown':
147
+ if (!onCanvas) return false;
148
+ this._endingDrag = false;
149
+ gizmo._onPointerDown(e);
150
+ return this._dragging;
151
+ case 'pointermove':
152
+ // the gizmo lights up the handle under the pointer, whether it keeps the event or not
153
+ if (onCanvas || this._dragging) gizmo._onPointerMove(e);
154
+ return this._dragging;
155
+ case 'pointerup':
156
+ case 'pointercancel': {
157
+ if (onCanvas || this._dragging) gizmo._onPointerUp(e);
158
+ const dragged = this._dragging;
159
+ this._dragging = false;
160
+ this._endingDrag = dragged;
161
+ return dragged;
162
+ }
163
+ case 'click':
164
+ case 'dblclick': {
165
+ const ending = this._endingDrag;
166
+ this._endingDrag = false;
167
+ return ending;
168
+ }
169
+ default:
170
+ return this._dragging;
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Takes the gizmo, its layer and its entity out of the app.
176
+ */
177
+ destroy() {
178
+ const camera = this._gizmo.camera;
179
+ this._gizmo.destroy();
180
+ camera.layers = camera.layers.filter(id => id !== this._layer.id);
181
+ this._app.scene.layers.remove(this._layer);
182
+ }
183
+ }
184
+
185
+ export { POINTER_EVENTS as TRANSFORM_POINTER_EVENTS, TransformTool };
@@ -20,4 +20,6 @@ export function pushResourceUsage(section: PropertySection, asset: Asset, app: A
20
20
  */
21
21
  export function resourceUsers(app: AppBase, asset: Asset): Described[];
22
22
  import type { PropertySection } from './model.js';
23
+ import type { Asset } from 'playcanvas';
24
+ import type { AppBase } from 'playcanvas';
23
25
  import type { Described } from './describe.js';
@@ -9,7 +9,7 @@ export const ASSET_SORTS: string[][];
9
9
  * @param {string} sort - The order to list them in.
10
10
  * @returns {ListRow[]} The rows.
11
11
  */
12
- export function assetRows(registry: Asset | null, sort: string): ListRow[];
12
+ export function assetRows(registry: AssetRegistry | null, sort: string): ListRow[];
13
13
  /**
14
14
  * The components referencing an asset, found by walking the scene: neither the asset nor the
15
15
  * registry tracks who uses it.
@@ -18,8 +18,8 @@ export function assetRows(registry: Asset | null, sort: string): ListRow[];
18
18
  * @param {Asset} asset - The asset.
19
19
  * @returns {{ entity: Entity, name: string, property: string }[]} One entry per referencing property.
20
20
  */
21
- export function assetUsers(app: Asset, asset: Asset): {
22
- entity: Asset;
21
+ export function assetUsers(app: AppBase, asset: Asset): {
22
+ entity: Entity;
23
23
  name: string;
24
24
  property: string;
25
25
  }[];
@@ -28,11 +28,13 @@ export function assetUsers(app: Asset, asset: Asset): {
28
28
  * into (linked), the components using it (linked), and every other public property.
29
29
  *
30
30
  * @param {Asset} asset - The asset.
31
- * @param {{ app: AppBase }} ctx - The app, to find the asset's users.
31
+ * @param {{ app: AppBase, backlinks?: boolean }} ctx - The app, to find the asset's users, and
32
+ * whether to find them at all, which a copy has no use for.
32
33
  * @returns {PropertySection[]} The sections.
33
34
  */
34
35
  export function buildAssetModel(asset: Asset, ctx: {
35
- app: Asset;
36
+ app: AppBase;
37
+ backlinks?: boolean;
36
38
  }): PropertySection[];
37
39
  /**
38
40
  * Every asset in the registry, in the requested order. Assets with no file sort last by size, and
@@ -42,7 +44,7 @@ export function buildAssetModel(asset: Asset, ctx: {
42
44
  * @param {string} [sort] - One of {@link ASSET_SORTS}.
43
45
  * @returns {Asset[]} The assets.
44
46
  */
45
- export function collectAssets(registry: Asset | null, sort?: string): Asset[];
47
+ export function collectAssets(registry: AssetRegistry | null, sort?: string): Asset[];
46
48
  /**
47
49
  * The sub-assets of the loaded containers in a registry. A container asset adds the render,
48
50
  * material, animation and gsplat assets it creates to the registry and keeps them on its resource,
@@ -54,7 +56,7 @@ export function collectAssets(registry: Asset | null, sort?: string): Asset[];
54
56
  * @returns {{ parentOf: Map<Asset, Asset>, parts: Map<Asset, [string, Asset[]][]> }} The container of
55
57
  * each sub-asset, and the sub-assets of each container by kind.
56
58
  */
57
- export function containerParts(registry: Asset | null): {
59
+ export function containerParts(registry: AssetRegistry | null): {
58
60
  parentOf: Map<Asset, Asset>;
59
61
  parts: Map<Asset, [string, Asset[]][]>;
60
62
  };
@@ -66,7 +68,7 @@ export function containerParts(registry: Asset | null): {
66
68
  * @param {AssetRegistry|null} registry - The registry to resolve ids in.
67
69
  * @returns {Described} The described value.
68
70
  */
69
- export function describeAssetValue(value: any, registry: Asset | null): Described;
71
+ export function describeAssetValue(value: any, registry: AssetRegistry | null): Described;
70
72
  /**
71
73
  * Appends one row per asset-referencing property of a component, with ids resolved to the assets
72
74
  * they name.
@@ -75,7 +77,7 @@ export function describeAssetValue(value: any, registry: Asset | null): Describe
75
77
  * @param {Component} component - The component.
76
78
  * @returns {string[]} The property names handled, to leave out of the reflected rows.
77
79
  */
78
- export function pushAssetRows(section: PropertySection, component: Asset): string[];
80
+ export function pushAssetRows(section: PropertySection, component: Component): string[];
79
81
  /**
80
82
  * The asset each loaded resource came from, so a panel showing a resource can name its source.
81
83
  * An asset can produce several resources, such as the faces of a cubemap.
@@ -83,12 +85,17 @@ export function pushAssetRows(section: PropertySection, component: Asset): strin
83
85
  * @param {AssetRegistry|null} registry - The registry.
84
86
  * @returns {Map<object, Asset>} The asset by resource.
85
87
  */
86
- export function resourceAssets(registry: Asset | null): Map<object, Asset>;
88
+ export function resourceAssets(registry: AssetRegistry | null): Map<object, Asset>;
87
89
  /**
88
90
  * @param {Asset} asset - An asset.
89
91
  * @returns {string} Its load state.
90
92
  */
91
93
  export function stateName(asset: Asset): string;
94
+ import type { AssetRegistry } from 'playcanvas';
92
95
  import type { ListRow } from './list-view.js';
96
+ import type { AppBase } from 'playcanvas';
97
+ import { Asset } from 'playcanvas';
98
+ import type { Entity } from 'playcanvas';
93
99
  import type { PropertySection } from './model.js';
94
100
  import type { Described } from './describe.js';
101
+ import type { Component } from 'playcanvas';
@@ -5,11 +5,15 @@ export type CameraActions = {
5
5
  /**
6
6
  * - Flies the camera.
7
7
  */
8
- fly: (camera: PROJECTION_ORTHOGRAPHIC) => void;
8
+ fly: (camera: CameraComponent) => void;
9
9
  /**
10
10
  * - The camera being flown, if any.
11
11
  */
12
- flying: PROJECTION_ORTHOGRAPHIC | null;
12
+ flying: CameraComponent | null;
13
+ /**
14
+ * - Why no camera can be flown now, such as a gizmo being on.
15
+ */
16
+ unavailable?: string | null;
13
17
  };
14
18
  /**
15
19
  * Everything the property view shows for a camera: where and how it draws, the layers it renders,
@@ -19,8 +23,8 @@ export type CameraActions = {
19
23
  * @param {{ app: AppBase, cameraActions: CameraActions }} ctx - The app, and what the tab offers.
20
24
  * @returns {PropertySection[]} The sections.
21
25
  */
22
- export function buildCameraModel(camera: PROJECTION_ORTHOGRAPHIC, ctx: {
23
- app: PROJECTION_ORTHOGRAPHIC;
26
+ export function buildCameraModel(camera: CameraComponent, ctx: {
27
+ app: AppBase;
24
28
  cameraActions: CameraActions;
25
29
  }): PropertySection[];
26
30
  /**
@@ -30,7 +34,7 @@ export function buildCameraModel(camera: PROJECTION_ORTHOGRAPHIC, ctx: {
30
34
  * @param {CameraComponent|null} flying - The camera being flown, if any.
31
35
  * @returns {ListRow[]} The rows.
32
36
  */
33
- export function cameraRows(app: PROJECTION_ORTHOGRAPHIC, flying: PROJECTION_ORTHOGRAPHIC | null): ListRow[];
37
+ export function cameraRows(app: AppBase, flying: CameraComponent | null): ListRow[];
34
38
  /**
35
39
  * Every camera component of the hierarchy, disabled ones included, in the order they render: by
36
40
  * priority, then in hierarchy order.
@@ -38,8 +42,10 @@ export function cameraRows(app: PROJECTION_ORTHOGRAPHIC, flying: PROJECTION_ORTH
38
42
  * @param {AppBase} app - The app.
39
43
  * @returns {CameraComponent[]} The cameras.
40
44
  */
41
- export function collectCameras(app: PROJECTION_ORTHOGRAPHIC): PROJECTION_ORTHOGRAPHIC[];
45
+ export function collectCameras(app: AppBase): CameraComponent[];
42
46
  import { isScreenCamera } from './viewport-tools.js';
47
+ import type { CameraComponent } from 'playcanvas';
48
+ import type { AppBase } from 'playcanvas';
43
49
  import type { PropertySection } from './model.js';
44
50
  import type { ListRow } from './list-view.js';
45
51
  export { isScreenCamera };
@@ -0,0 +1,90 @@
1
+ /**
2
+ * An entry of a context menu.
3
+ */
4
+ export type MenuItem = object;
5
+ export type MenuButton = object;
6
+ /**
7
+ * A menu opened where the pointer is, and a note shown briefly at the bottom of the panel, such as
8
+ * for what was copied. Both live in the panel, so they move with it into a popped-out window. The
9
+ * menu closes on a choice, a press anywhere outside it, Escape, scrolling and leaving the window.
10
+ *
11
+ * @ignore
12
+ */
13
+ export class ContextMenu {
14
+ /**
15
+ * @param {HTMLElement} panel - The panel to show the menu and notes in.
16
+ */
17
+ constructor(panel: HTMLElement);
18
+ /**
19
+ * @type {HTMLElement}
20
+ * @private
21
+ */
22
+ private _panel;
23
+ /**
24
+ * @type {HTMLElement}
25
+ * @private
26
+ */
27
+ private _menu;
28
+ /**
29
+ * @type {HTMLElement}
30
+ * @private
31
+ */
32
+ private _note;
33
+ /**
34
+ * @type {number}
35
+ * @private
36
+ */
37
+ private _noteTimer;
38
+ /**
39
+ * The document the closing listeners are on while the menu is open.
40
+ *
41
+ * @type {Document|null}
42
+ * @private
43
+ */
44
+ private _doc;
45
+ /**
46
+ * Whether the menu is open.
47
+ *
48
+ * @type {boolean}
49
+ */
50
+ get open(): boolean;
51
+ /**
52
+ * Opens the menu at a point, in place of any menu already open.
53
+ *
54
+ * @param {number} x - The point, in client pixels.
55
+ * @param {number} y - The point, in client pixels.
56
+ * @param {string} title - What the menu acts on.
57
+ * @param {MenuItem[]} items - The entries.
58
+ */
59
+ show(x: number, y: number, title: string, items: MenuItem[]): void;
60
+ /**
61
+ * Closes the menu, if it is open.
62
+ */
63
+ hide: () => void;
64
+ /**
65
+ * Shows a note at the bottom of the panel for a moment.
66
+ *
67
+ * @param {string} text - The note.
68
+ */
69
+ note(text: string): void;
70
+ /**
71
+ * Closes the menu and removes its elements.
72
+ */
73
+ destroy(): void;
74
+ /**
75
+ * @param {MenuItem} item - An entry.
76
+ * @returns {HTMLElement} Its element.
77
+ * @private
78
+ */
79
+ private _entry;
80
+ /**
81
+ * @param {PointerEvent} e - The event.
82
+ * @private
83
+ */
84
+ private _onPointerDown;
85
+ /**
86
+ * @param {KeyboardEvent} e - The event.
87
+ * @private
88
+ */
89
+ private _onKeyDown;
90
+ }