@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/styles.js
CHANGED
|
@@ -29,7 +29,14 @@ 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"/>',
|
|
36
|
+
// recording, as the browser's own profiler shows it: a ring around a dot to record, red while
|
|
37
|
+
// recording, and the sign for none to clear
|
|
38
|
+
record: '<circle cx="12" cy="12" r="8.5"/><circle cx="12" cy="12" r="4" fill="black" stroke="none"/>',
|
|
39
|
+
clear: '<circle cx="12" cy="12" r="8.5"/><path d="M18 6 6 18"/>'
|
|
33
40
|
};
|
|
34
41
|
|
|
35
42
|
/**
|
|
@@ -368,7 +375,8 @@ ${ICON_RULES}
|
|
|
368
375
|
.pci-tip {
|
|
369
376
|
display: none;
|
|
370
377
|
position: fixed;
|
|
371
|
-
|
|
378
|
+
/* above the menu, whose entries have tooltips */
|
|
379
|
+
z-index: 3;
|
|
372
380
|
max-width: 320px;
|
|
373
381
|
padding: 5px 8px;
|
|
374
382
|
background: var(--pci-raised);
|
|
@@ -381,6 +389,93 @@ ${ICON_RULES}
|
|
|
381
389
|
pointer-events: none;
|
|
382
390
|
}
|
|
383
391
|
|
|
392
|
+
.pci-menu {
|
|
393
|
+
display: none;
|
|
394
|
+
position: fixed;
|
|
395
|
+
z-index: 2;
|
|
396
|
+
min-width: 200px;
|
|
397
|
+
max-width: 320px;
|
|
398
|
+
padding: 4px 0;
|
|
399
|
+
background: var(--pci-raised);
|
|
400
|
+
color: var(--pci-text);
|
|
401
|
+
border: 1px solid var(--pci-border-strong);
|
|
402
|
+
border-radius: 6px;
|
|
403
|
+
box-shadow: var(--pci-shadow);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.pci-menu-title {
|
|
407
|
+
padding: 2px 10px 5px;
|
|
408
|
+
margin-bottom: 4px;
|
|
409
|
+
color: var(--pci-text-muted);
|
|
410
|
+
border-bottom: 1px solid var(--pci-border);
|
|
411
|
+
overflow: hidden;
|
|
412
|
+
text-overflow: ellipsis;
|
|
413
|
+
white-space: nowrap;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.pci-menu-item {
|
|
417
|
+
display: flex;
|
|
418
|
+
align-items: center;
|
|
419
|
+
gap: 8px;
|
|
420
|
+
padding: 3px 10px;
|
|
421
|
+
cursor: pointer;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.pci-menu-item:hover {
|
|
425
|
+
background: var(--pci-selected);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.pci-menu-label {
|
|
429
|
+
flex: 1 1 auto;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.pci-menu-buttons {
|
|
433
|
+
display: flex;
|
|
434
|
+
gap: 2px;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.pci-menu-button {
|
|
438
|
+
font: inherit;
|
|
439
|
+
line-height: 16px;
|
|
440
|
+
min-width: 20px;
|
|
441
|
+
padding: 0 4px;
|
|
442
|
+
color: var(--pci-text-secondary);
|
|
443
|
+
background: rgba(255, 255, 255, 0.07);
|
|
444
|
+
border: none;
|
|
445
|
+
border-radius: 4px;
|
|
446
|
+
cursor: pointer;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.pci-menu-button:not(:disabled):hover {
|
|
450
|
+
color: #ffffff;
|
|
451
|
+
background: var(--pci-accent-strong);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
.pci-menu-button:disabled {
|
|
455
|
+
opacity: 0.35;
|
|
456
|
+
cursor: default;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
.pci-toast {
|
|
460
|
+
display: none;
|
|
461
|
+
position: absolute;
|
|
462
|
+
z-index: 2;
|
|
463
|
+
left: 50%;
|
|
464
|
+
bottom: 36px;
|
|
465
|
+
transform: translateX(-50%);
|
|
466
|
+
max-width: calc(100% - 24px);
|
|
467
|
+
padding: 5px 10px;
|
|
468
|
+
background: var(--pci-raised);
|
|
469
|
+
color: var(--pci-text);
|
|
470
|
+
border: 1px solid var(--pci-border-strong);
|
|
471
|
+
border-radius: 6px;
|
|
472
|
+
box-shadow: var(--pci-shadow);
|
|
473
|
+
white-space: nowrap;
|
|
474
|
+
overflow: hidden;
|
|
475
|
+
text-overflow: ellipsis;
|
|
476
|
+
pointer-events: none;
|
|
477
|
+
}
|
|
478
|
+
|
|
384
479
|
.pci-check {
|
|
385
480
|
display: inline-flex;
|
|
386
481
|
align-items: center;
|
|
@@ -462,6 +557,177 @@ ${ICON_RULES}
|
|
|
462
557
|
opacity: 0.45;
|
|
463
558
|
}
|
|
464
559
|
|
|
560
|
+
/* the charts of the Performance tab want more room than a list, until the splitter is dragged */
|
|
561
|
+
.pci-hierarchy.pci-tall {
|
|
562
|
+
flex-basis: 68%;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.pci-group {
|
|
566
|
+
display: inline-flex;
|
|
567
|
+
align-items: center;
|
|
568
|
+
gap: 4px;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/* an icon button the size of the text buttons beside it, with their backing */
|
|
572
|
+
.pci-icon-btn.pci-small {
|
|
573
|
+
width: 26px;
|
|
574
|
+
height: 22px;
|
|
575
|
+
border-radius: 6px;
|
|
576
|
+
background: rgba(255, 255, 255, 0.07);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
.pci-icon-btn.pci-small::before {
|
|
580
|
+
width: 14px;
|
|
581
|
+
height: 14px;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.pci-btn.pci-record.pci-active,
|
|
585
|
+
.pci-btn.pci-record.pci-active:not(:disabled):hover {
|
|
586
|
+
background: rgba(241, 76, 76, 0.18);
|
|
587
|
+
color: #ff5a52;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/* shrinks with the part above the splitter, scrolling its charts */
|
|
591
|
+
.pci-perf-charts {
|
|
592
|
+
flex: 1 1 auto;
|
|
593
|
+
position: relative;
|
|
594
|
+
min-height: 60px;
|
|
595
|
+
margin: 6px 8px 0;
|
|
596
|
+
overflow-x: hidden;
|
|
597
|
+
overflow-y: auto;
|
|
598
|
+
cursor: crosshair;
|
|
599
|
+
touch-action: none;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/* the Performance tab, which places the hover box of its charts */
|
|
603
|
+
.pci-perf {
|
|
604
|
+
position: relative;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/* the frames in view while zoomed in, under the plot */
|
|
608
|
+
.pci-perf-hscroll {
|
|
609
|
+
flex: 0 0 auto;
|
|
610
|
+
position: relative;
|
|
611
|
+
height: 8px;
|
|
612
|
+
margin: 4px 8px 0;
|
|
613
|
+
background: rgba(255, 255, 255, 0.05);
|
|
614
|
+
border-radius: 4px;
|
|
615
|
+
cursor: pointer;
|
|
616
|
+
touch-action: none;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
.pci-perf-hscroll-thumb {
|
|
620
|
+
position: absolute;
|
|
621
|
+
top: 0;
|
|
622
|
+
bottom: 0;
|
|
623
|
+
min-width: 12px;
|
|
624
|
+
background: rgba(255, 255, 255, 0.3);
|
|
625
|
+
border-radius: 4px;
|
|
626
|
+
cursor: grab;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.pci-perf-hscroll-thumb:hover {
|
|
630
|
+
background: rgba(255, 255, 255, 0.45);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.pci-perf-hscroll.pci-inactive,
|
|
634
|
+
.pci-perf-hscroll.pci-inactive .pci-perf-hscroll-thumb {
|
|
635
|
+
cursor: default;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.pci-perf-hscroll.pci-inactive .pci-perf-hscroll-thumb {
|
|
639
|
+
background: rgba(255, 255, 255, 0.08);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.pci-perf-timeline {
|
|
643
|
+
flex: 0 0 auto;
|
|
644
|
+
position: relative;
|
|
645
|
+
margin: 6px 8px;
|
|
646
|
+
border-top: 1px solid var(--pci-border);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.pci-perf-charts canvas,
|
|
650
|
+
.pci-perf-timeline canvas {
|
|
651
|
+
position: absolute;
|
|
652
|
+
top: 0;
|
|
653
|
+
left: 0;
|
|
654
|
+
width: 100%;
|
|
655
|
+
height: 100%;
|
|
656
|
+
display: block;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/* the marks over the charts, redrawn alone as the pointer moves; the charts below take the pointer */
|
|
660
|
+
.pci-perf-charts canvas.pci-perf-overlay {
|
|
661
|
+
pointer-events: none;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/* what the pointer is over in the charts, beside it */
|
|
665
|
+
.pci-perf-hover {
|
|
666
|
+
display: none;
|
|
667
|
+
position: absolute;
|
|
668
|
+
z-index: 2;
|
|
669
|
+
max-width: 320px;
|
|
670
|
+
padding: 5px 8px;
|
|
671
|
+
background: var(--pci-raised);
|
|
672
|
+
color: var(--pci-text);
|
|
673
|
+
border: 1px solid var(--pci-border-strong);
|
|
674
|
+
border-radius: 6px;
|
|
675
|
+
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
|
|
676
|
+
font-size: 11px;
|
|
677
|
+
line-height: 1.45;
|
|
678
|
+
pointer-events: none;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.pci-perf-hover-line {
|
|
682
|
+
display: flex;
|
|
683
|
+
align-items: center;
|
|
684
|
+
white-space: nowrap;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.pci-perf-hover-line.pci-indent {
|
|
688
|
+
padding-left: 10px;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
.pci-perf-hover-line.pci-strong {
|
|
692
|
+
margin: 0 -4px;
|
|
693
|
+
padding-right: 4px;
|
|
694
|
+
border-radius: 3px;
|
|
695
|
+
background: rgba(255, 255, 255, 0.1);
|
|
696
|
+
color: #ffffff;
|
|
697
|
+
font-weight: 600;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
.pci-perf-hover-line.pci-nested {
|
|
701
|
+
padding-left: 25px;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
.pci-perf-hover-line.pci-muted {
|
|
705
|
+
color: #93a2a6;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.pci-perf-hover-line.pci-indent.pci-strong {
|
|
709
|
+
padding-left: 14px;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
.pci-perf-hover-line.pci-wrap {
|
|
713
|
+
white-space: normal;
|
|
714
|
+
overflow-wrap: anywhere;
|
|
715
|
+
width: 280px;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.pci-perf-hover-line.pci-wrap .pci-perf-swatch {
|
|
719
|
+
align-self: flex-start;
|
|
720
|
+
margin-top: 4px;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.pci-perf-swatch {
|
|
724
|
+
flex: 0 0 auto;
|
|
725
|
+
width: 9px;
|
|
726
|
+
height: 9px;
|
|
727
|
+
margin-right: 6px;
|
|
728
|
+
border-radius: 2px;
|
|
729
|
+
}
|
|
730
|
+
|
|
465
731
|
.pci-cell-toggle {
|
|
466
732
|
flex: 0 0 auto;
|
|
467
733
|
width: 12px;
|
|
@@ -509,6 +775,70 @@ ${ICON_RULES}
|
|
|
509
775
|
opacity: 0.45;
|
|
510
776
|
}
|
|
511
777
|
|
|
778
|
+
/* the head of a group of rows, which opens and closes it */
|
|
779
|
+
.pci-lrow.pci-lrow-header {
|
|
780
|
+
background-color: var(--pci-raised);
|
|
781
|
+
color: var(--pci-text);
|
|
782
|
+
font-weight: 600;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.pci-lrow.pci-lrow-header ~ .pci-lrow.pci-lrow-header {
|
|
786
|
+
border-top: 1px solid var(--pci-border);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.pci-lrow.pci-lrow-header::before {
|
|
790
|
+
content: "▸";
|
|
791
|
+
flex: 0 0 10px;
|
|
792
|
+
color: var(--pci-text-label);
|
|
793
|
+
font-size: 12px;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
.pci-lrow.pci-lrow-header.pci-open::before {
|
|
797
|
+
content: "▾";
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
.pci-lrow.pci-lrow-header.pci-leaf::before {
|
|
801
|
+
content: "";
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
.pci-lrow.pci-lrow-header:hover {
|
|
805
|
+
background-color: #263133;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/* rows that only show figures, and headers with nothing to open */
|
|
809
|
+
.pci-lrow.pci-inert,
|
|
810
|
+
.pci-lrow.pci-lrow-header.pci-leaf {
|
|
811
|
+
cursor: default;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
.pci-lrow.pci-inert:hover {
|
|
815
|
+
background-color: transparent;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
.pci-lrow.pci-lrow-header.pci-leaf:hover {
|
|
819
|
+
background-color: var(--pci-raised);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/* a count and a size in columns of their own, lining up from row to row */
|
|
823
|
+
.pci-cell-count {
|
|
824
|
+
flex-shrink: 0;
|
|
825
|
+
margin-left: auto;
|
|
826
|
+
min-width: 5ch;
|
|
827
|
+
text-align: right;
|
|
828
|
+
color: var(--pci-text-label);
|
|
829
|
+
font-family: var(--pci-mono);
|
|
830
|
+
font-size: 10.5px;
|
|
831
|
+
font-weight: normal;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
.pci-cell-size {
|
|
835
|
+
flex-shrink: 0;
|
|
836
|
+
min-width: 11ch;
|
|
837
|
+
text-align: right;
|
|
838
|
+
font-family: var(--pci-mono);
|
|
839
|
+
font-size: 10.5px;
|
|
840
|
+
}
|
|
841
|
+
|
|
512
842
|
.pci-cell {
|
|
513
843
|
flex: 0 1 auto;
|
|
514
844
|
min-width: 0;
|
|
@@ -672,7 +1002,10 @@ ${ICON_RULES}
|
|
|
672
1002
|
color: var(--pci-text-faint);
|
|
673
1003
|
}
|
|
674
1004
|
|
|
1005
|
+
/* above anything of the part over it that overflows, so it can always be dragged back */
|
|
675
1006
|
.pci-splitter {
|
|
1007
|
+
position: relative;
|
|
1008
|
+
z-index: 2;
|
|
676
1009
|
flex: 0 0 5px;
|
|
677
1010
|
background: var(--pci-raised);
|
|
678
1011
|
border-top: 1px solid var(--pci-border-strong);
|
|
@@ -782,6 +1115,45 @@ ${ICON_RULES}
|
|
|
782
1115
|
.pci-v-ref { color: #4fc1ff; }
|
|
783
1116
|
.pci-v-err { color: #f14c4c; }
|
|
784
1117
|
|
|
1118
|
+
/* an editable value reads as a text field, and its editor opens in the same place at the same size */
|
|
1119
|
+
.pci-prop.pci-editable .pci-value {
|
|
1120
|
+
box-sizing: border-box;
|
|
1121
|
+
margin: -1px 0;
|
|
1122
|
+
padding: 0 4px;
|
|
1123
|
+
cursor: text;
|
|
1124
|
+
background: var(--pci-input);
|
|
1125
|
+
border: 1px solid var(--pci-border-strong);
|
|
1126
|
+
border-radius: 3px;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
.pci-prop.pci-editable .pci-value:hover {
|
|
1130
|
+
border-color: var(--pci-text-muted);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
.pci-prop.pci-editing .pci-value {
|
|
1134
|
+
margin: 0;
|
|
1135
|
+
padding: 0;
|
|
1136
|
+
background: none;
|
|
1137
|
+
border: none;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
.pci-edit {
|
|
1141
|
+
box-sizing: border-box;
|
|
1142
|
+
width: 100%;
|
|
1143
|
+
margin: -1px 0;
|
|
1144
|
+
padding: 0 4px;
|
|
1145
|
+
font: inherit;
|
|
1146
|
+
color: var(--pci-text);
|
|
1147
|
+
background: var(--pci-input);
|
|
1148
|
+
border: 1px solid var(--pci-accent);
|
|
1149
|
+
border-radius: 3px;
|
|
1150
|
+
outline: none;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
.pci-edit.pci-invalid {
|
|
1154
|
+
border-color: #f14c4c;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
785
1157
|
.pci-link {
|
|
786
1158
|
cursor: pointer;
|
|
787
1159
|
text-decoration: underline dotted;
|
package/src/texture-view.js
CHANGED
|
@@ -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 };
|
package/types/asset-view.d.ts
CHANGED
|
@@ -28,11 +28,13 @@ export function assetUsers(app: AppBase, 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
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
|
package/types/camera-view.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export type CameraActions = {
|
|
|
10
10
|
* - The camera being flown, if any.
|
|
11
11
|
*/
|
|
12
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,
|