@playcanvas/web-components 0.1.1 → 0.1.3
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 +260 -1
- package/dist/asset.d.ts +1 -0
- package/dist/components/camera-component.d.ts +110 -2
- package/dist/components/element-component.d.ts +0 -1
- package/dist/components/gsplat-component.d.ts +1 -2
- package/dist/components/render-component.d.ts +13 -1
- package/dist/components/screen-component.d.ts +44 -0
- package/dist/components/script-component.d.ts +25 -0
- package/dist/components/script.d.ts +12 -6
- package/dist/components/sound-slot.d.ts +0 -1
- package/dist/index.d.ts +3 -1
- package/dist/material.d.ts +29 -0
- package/dist/model.d.ts +0 -1
- package/dist/pwc.cjs +620 -91
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +620 -91
- package/dist/pwc.js.map +1 -1
- package/dist/pwc.min.js +1 -1
- package/dist/pwc.min.js.map +1 -1
- package/dist/pwc.mjs +620 -93
- package/dist/pwc.mjs.map +1 -1
- package/dist/sky.d.ts +0 -1
- package/package.json +4 -4
- package/src/app.ts +7 -0
- package/src/asset.ts +5 -0
- package/src/components/camera-component.ts +248 -6
- package/src/components/element-component.ts +2 -7
- package/src/components/gsplat-component.ts +2 -7
- package/src/components/render-component.ts +38 -7
- package/src/components/screen-component.ts +153 -0
- package/src/components/script-component.ts +120 -1
- package/src/components/script.ts +23 -65
- package/src/components/sound-component.ts +1 -1
- package/src/components/sound-slot.ts +2 -7
- package/src/entity.ts +1 -1
- package/src/index.ts +4 -0
- package/src/material.ts +138 -0
- package/src/model.ts +1 -6
- package/src/sky.ts +1 -6
package/dist/pwc.cjs
CHANGED
|
@@ -78,6 +78,11 @@ class AppElement extends HTMLElement {
|
|
|
78
78
|
this.app.assets.add(asset);
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
+
// Get all pc-material elements that are direct children of the pc-app element
|
|
82
|
+
const materialElements = this.querySelectorAll(':scope > pc-material');
|
|
83
|
+
Array.from(materialElements).forEach((materialElement) => {
|
|
84
|
+
materialElement.createMaterial();
|
|
85
|
+
});
|
|
81
86
|
// Load assets before starting the application
|
|
82
87
|
this.app.preload(() => {
|
|
83
88
|
// Start the application
|
|
@@ -222,7 +227,7 @@ class EntityElement extends HTMLElement {
|
|
|
222
227
|
const app = await appElement.getApplication();
|
|
223
228
|
// Create a new entity
|
|
224
229
|
this.entity = new playcanvas.Entity(this._name, app);
|
|
225
|
-
if (this.parentElement && this.parentElement.tagName === 'pc-entity' && this.parentElement.entity) {
|
|
230
|
+
if (this.parentElement && this.parentElement.tagName.toLowerCase() === 'pc-entity' && this.parentElement.entity) {
|
|
226
231
|
this.parentElement.entity.addChild(this.entity);
|
|
227
232
|
}
|
|
228
233
|
else {
|
|
@@ -457,6 +462,10 @@ class AssetElement extends HTMLElement {
|
|
|
457
462
|
get preload() {
|
|
458
463
|
return this._preload;
|
|
459
464
|
}
|
|
465
|
+
static get(id) {
|
|
466
|
+
const assetElement = document.querySelector(`pc-asset[id="${id}"]`);
|
|
467
|
+
return assetElement === null || assetElement === void 0 ? void 0 : assetElement.asset;
|
|
468
|
+
}
|
|
460
469
|
static get observedAttributes() {
|
|
461
470
|
return ['preload'];
|
|
462
471
|
}
|
|
@@ -578,21 +587,39 @@ class CameraComponentElement extends ComponentElement {
|
|
|
578
587
|
*/
|
|
579
588
|
constructor() {
|
|
580
589
|
super('camera');
|
|
581
|
-
this._clearColor = new playcanvas.Color(
|
|
590
|
+
this._clearColor = new playcanvas.Color(0.75, 0.75, 0.75, 1);
|
|
591
|
+
this._clearColorBuffer = true;
|
|
592
|
+
this._clearDepthBuffer = true;
|
|
593
|
+
this._clearStencilBuffer = false;
|
|
594
|
+
this._cullFaces = true;
|
|
582
595
|
this._farClip = 1000;
|
|
596
|
+
this._flipFaces = false;
|
|
583
597
|
this._fov = 45;
|
|
598
|
+
this._frustumCulling = true;
|
|
584
599
|
this._nearClip = 0.1;
|
|
585
600
|
this._orthographic = false;
|
|
586
601
|
this._orthoHeight = 10;
|
|
602
|
+
this._priority = 0;
|
|
603
|
+
this._rect = new playcanvas.Vec4(0, 0, 1, 1);
|
|
604
|
+
this._scissorRect = new playcanvas.Vec4(0, 0, 1, 1);
|
|
587
605
|
}
|
|
588
606
|
getInitialComponentData() {
|
|
589
607
|
return {
|
|
590
608
|
clearColor: this._clearColor,
|
|
609
|
+
clearColorBuffer: this._clearColorBuffer,
|
|
610
|
+
clearDepthBuffer: this._clearDepthBuffer,
|
|
611
|
+
clearStencilBuffer: this._clearStencilBuffer,
|
|
612
|
+
cullFaces: this._cullFaces,
|
|
591
613
|
farClip: this._farClip,
|
|
614
|
+
flipFaces: this._flipFaces,
|
|
592
615
|
fov: this._fov,
|
|
616
|
+
frustumCulling: this._frustumCulling,
|
|
593
617
|
nearClip: this._nearClip,
|
|
594
|
-
|
|
595
|
-
orthoHeight: this._orthoHeight
|
|
618
|
+
orthographic: this._orthographic,
|
|
619
|
+
orthoHeight: this._orthoHeight,
|
|
620
|
+
priority: this._priority,
|
|
621
|
+
rect: this._rect,
|
|
622
|
+
scissorRect: this._scissorRect
|
|
596
623
|
};
|
|
597
624
|
}
|
|
598
625
|
/**
|
|
@@ -619,6 +646,74 @@ class CameraComponentElement extends ComponentElement {
|
|
|
619
646
|
get clearColor() {
|
|
620
647
|
return this._clearColor;
|
|
621
648
|
}
|
|
649
|
+
/**
|
|
650
|
+
* Sets the clear color buffer of the camera.
|
|
651
|
+
* @param value - The clear color buffer.
|
|
652
|
+
*/
|
|
653
|
+
set clearColorBuffer(value) {
|
|
654
|
+
this._clearColorBuffer = value;
|
|
655
|
+
if (this.component) {
|
|
656
|
+
this.component.clearColorBuffer = value;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Gets the clear color buffer of the camera.
|
|
661
|
+
* @returns The clear color buffer.
|
|
662
|
+
*/
|
|
663
|
+
get clearColorBuffer() {
|
|
664
|
+
return this._clearColorBuffer;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Sets the clear depth buffer of the camera.
|
|
668
|
+
* @param value - The clear depth buffer.
|
|
669
|
+
*/
|
|
670
|
+
set clearDepthBuffer(value) {
|
|
671
|
+
this._clearDepthBuffer = value;
|
|
672
|
+
if (this.component) {
|
|
673
|
+
this.component.clearDepthBuffer = value;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Gets the clear depth buffer of the camera.
|
|
678
|
+
* @returns The clear depth buffer.
|
|
679
|
+
*/
|
|
680
|
+
get clearDepthBuffer() {
|
|
681
|
+
return this._clearDepthBuffer;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Sets the clear stencil buffer of the camera.
|
|
685
|
+
* @param value - The clear stencil buffer.
|
|
686
|
+
*/
|
|
687
|
+
set clearStencilBuffer(value) {
|
|
688
|
+
this._clearStencilBuffer = value;
|
|
689
|
+
if (this.component) {
|
|
690
|
+
this.component.clearStencilBuffer = value;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Gets the clear stencil buffer of the camera.
|
|
695
|
+
* @returns The clear stencil buffer.
|
|
696
|
+
*/
|
|
697
|
+
get clearStencilBuffer() {
|
|
698
|
+
return this._clearStencilBuffer;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Sets the cull faces of the camera.
|
|
702
|
+
* @param value - The cull faces.
|
|
703
|
+
*/
|
|
704
|
+
set cullFaces(value) {
|
|
705
|
+
this._cullFaces = value;
|
|
706
|
+
if (this.component) {
|
|
707
|
+
this.component.cullFaces = value;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Gets the cull faces of the camera.
|
|
712
|
+
* @returns The cull faces.
|
|
713
|
+
*/
|
|
714
|
+
get cullFaces() {
|
|
715
|
+
return this._cullFaces;
|
|
716
|
+
}
|
|
622
717
|
/**
|
|
623
718
|
* Sets the far clip distance of the camera.
|
|
624
719
|
* @param value - The far clip distance.
|
|
@@ -636,6 +731,23 @@ class CameraComponentElement extends ComponentElement {
|
|
|
636
731
|
get farClip() {
|
|
637
732
|
return this._farClip;
|
|
638
733
|
}
|
|
734
|
+
/**
|
|
735
|
+
* Sets the flip faces of the camera.
|
|
736
|
+
* @param value - The flip faces.
|
|
737
|
+
*/
|
|
738
|
+
set flipFaces(value) {
|
|
739
|
+
this._flipFaces = value;
|
|
740
|
+
if (this.component) {
|
|
741
|
+
this.component.flipFaces = value;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Gets the flip faces of the camera.
|
|
746
|
+
* @returns The flip faces.
|
|
747
|
+
*/
|
|
748
|
+
get flipFaces() {
|
|
749
|
+
return this._flipFaces;
|
|
750
|
+
}
|
|
639
751
|
/**
|
|
640
752
|
* Sets the field of view of the camera.
|
|
641
753
|
* @param value - The field of view.
|
|
@@ -653,6 +765,23 @@ class CameraComponentElement extends ComponentElement {
|
|
|
653
765
|
get fov() {
|
|
654
766
|
return this._fov;
|
|
655
767
|
}
|
|
768
|
+
/**
|
|
769
|
+
* Sets the frustum culling of the camera.
|
|
770
|
+
* @param value - The frustum culling.
|
|
771
|
+
*/
|
|
772
|
+
set frustumCulling(value) {
|
|
773
|
+
this._frustumCulling = value;
|
|
774
|
+
if (this.component) {
|
|
775
|
+
this.component.frustumCulling = value;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Gets the frustum culling of the camera.
|
|
780
|
+
* @returns The frustum culling.
|
|
781
|
+
*/
|
|
782
|
+
get frustumCulling() {
|
|
783
|
+
return this._frustumCulling;
|
|
784
|
+
}
|
|
656
785
|
/**
|
|
657
786
|
* Sets the near clip distance of the camera.
|
|
658
787
|
* @param value - The near clip distance.
|
|
@@ -704,8 +833,76 @@ class CameraComponentElement extends ComponentElement {
|
|
|
704
833
|
get orthoHeight() {
|
|
705
834
|
return this._orthoHeight;
|
|
706
835
|
}
|
|
836
|
+
/**
|
|
837
|
+
* Sets the priority of the camera.
|
|
838
|
+
* @param value - The priority.
|
|
839
|
+
*/
|
|
840
|
+
set priority(value) {
|
|
841
|
+
this._priority = value;
|
|
842
|
+
if (this.component) {
|
|
843
|
+
this.component.priority = value;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Gets the priority of the camera.
|
|
848
|
+
* @returns The priority.
|
|
849
|
+
*/
|
|
850
|
+
get priority() {
|
|
851
|
+
return this._priority;
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Sets the rect of the camera.
|
|
855
|
+
* @param value - The rect.
|
|
856
|
+
*/
|
|
857
|
+
set rect(value) {
|
|
858
|
+
this._rect = value;
|
|
859
|
+
if (this.component) {
|
|
860
|
+
this.component.rect = value;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Gets the rect of the camera.
|
|
865
|
+
* @returns The rect.
|
|
866
|
+
*/
|
|
867
|
+
get rect() {
|
|
868
|
+
return this._rect;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Sets the scissor rect of the camera.
|
|
872
|
+
* @param value - The scissor rect.
|
|
873
|
+
*/
|
|
874
|
+
set scissorRect(value) {
|
|
875
|
+
this._scissorRect = value;
|
|
876
|
+
if (this.component) {
|
|
877
|
+
this.component.scissorRect = value;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Gets the scissor rect of the camera.
|
|
882
|
+
* @returns The scissor rect.
|
|
883
|
+
*/
|
|
884
|
+
get scissorRect() {
|
|
885
|
+
return this._scissorRect;
|
|
886
|
+
}
|
|
707
887
|
static get observedAttributes() {
|
|
708
|
-
return [
|
|
888
|
+
return [
|
|
889
|
+
...super.observedAttributes,
|
|
890
|
+
'clear-color',
|
|
891
|
+
'clear-color-buffer',
|
|
892
|
+
'clear-depth-buffer',
|
|
893
|
+
'clear-stencil-buffer',
|
|
894
|
+
'cull-faces',
|
|
895
|
+
'far-clip',
|
|
896
|
+
'flip-faces',
|
|
897
|
+
'fov',
|
|
898
|
+
'frustum-culling',
|
|
899
|
+
'near-clip',
|
|
900
|
+
'orthographic',
|
|
901
|
+
'ortho-height',
|
|
902
|
+
'priority',
|
|
903
|
+
'rect',
|
|
904
|
+
'scissor-rect'
|
|
905
|
+
];
|
|
709
906
|
}
|
|
710
907
|
attributeChangedCallback(name, _oldValue, newValue) {
|
|
711
908
|
super.attributeChangedCallback(name, _oldValue, newValue);
|
|
@@ -713,12 +910,30 @@ class CameraComponentElement extends ComponentElement {
|
|
|
713
910
|
case 'clear-color':
|
|
714
911
|
this.clearColor = parseColor(newValue);
|
|
715
912
|
break;
|
|
913
|
+
case 'clear-color-buffer':
|
|
914
|
+
this.clearColorBuffer = newValue !== 'false';
|
|
915
|
+
break;
|
|
916
|
+
case 'clear-depth-buffer':
|
|
917
|
+
this.clearDepthBuffer = newValue !== 'false';
|
|
918
|
+
break;
|
|
919
|
+
case 'clear-stencil-buffer':
|
|
920
|
+
this.clearStencilBuffer = newValue !== 'false';
|
|
921
|
+
break;
|
|
922
|
+
case 'cull-faces':
|
|
923
|
+
this.cullFaces = newValue !== 'false';
|
|
924
|
+
break;
|
|
716
925
|
case 'far-clip':
|
|
717
926
|
this.farClip = parseFloat(newValue);
|
|
718
927
|
break;
|
|
928
|
+
case 'flip-faces':
|
|
929
|
+
this.flipFaces = newValue !== 'true';
|
|
930
|
+
break;
|
|
719
931
|
case 'fov':
|
|
720
932
|
this.fov = parseFloat(newValue);
|
|
721
933
|
break;
|
|
934
|
+
case 'frustum-culling':
|
|
935
|
+
this.frustumCulling = newValue !== 'false';
|
|
936
|
+
break;
|
|
722
937
|
case 'near-clip':
|
|
723
938
|
this.nearClip = parseFloat(newValue);
|
|
724
939
|
break;
|
|
@@ -728,6 +943,15 @@ class CameraComponentElement extends ComponentElement {
|
|
|
728
943
|
case 'ortho-height':
|
|
729
944
|
this.orthoHeight = parseFloat(newValue);
|
|
730
945
|
break;
|
|
946
|
+
case 'priority':
|
|
947
|
+
this.priority = parseFloat(newValue);
|
|
948
|
+
break;
|
|
949
|
+
case 'rect':
|
|
950
|
+
this.rect = parseVec4(newValue);
|
|
951
|
+
break;
|
|
952
|
+
case 'scissor-rect':
|
|
953
|
+
this.scissorRect = parseVec4(newValue);
|
|
954
|
+
break;
|
|
731
955
|
}
|
|
732
956
|
}
|
|
733
957
|
}
|
|
@@ -875,16 +1099,12 @@ class ElementComponentElement extends ComponentElement {
|
|
|
875
1099
|
await super.connectedCallback();
|
|
876
1100
|
this.component._text._material.useFog = true;
|
|
877
1101
|
}
|
|
878
|
-
getAsset() {
|
|
879
|
-
const assetElement = document.querySelector(`pc-asset[id="${this._asset}"]`);
|
|
880
|
-
return assetElement.asset;
|
|
881
|
-
}
|
|
882
1102
|
getInitialComponentData() {
|
|
883
1103
|
return {
|
|
884
1104
|
anchor: this._anchor,
|
|
885
1105
|
autoWidth: this._autoWidth,
|
|
886
1106
|
color: this._color,
|
|
887
|
-
fontAsset: this.
|
|
1107
|
+
fontAsset: AssetElement.get(this._asset).id,
|
|
888
1108
|
fontSize: this._fontSize,
|
|
889
1109
|
lineHeight: this._lineHeight,
|
|
890
1110
|
pivot: this._pivot,
|
|
@@ -912,7 +1132,7 @@ class ElementComponentElement extends ComponentElement {
|
|
|
912
1132
|
}
|
|
913
1133
|
set asset(value) {
|
|
914
1134
|
this._asset = value;
|
|
915
|
-
const asset =
|
|
1135
|
+
const asset = AssetElement.get(value);
|
|
916
1136
|
if (this.component && asset) {
|
|
917
1137
|
this.component.fontAsset = asset.id;
|
|
918
1138
|
}
|
|
@@ -1063,13 +1283,9 @@ class GSplatComponentElement extends ComponentElement {
|
|
|
1063
1283
|
super('gsplat');
|
|
1064
1284
|
this._asset = '';
|
|
1065
1285
|
}
|
|
1066
|
-
getAsset() {
|
|
1067
|
-
const assetElement = document.querySelector(`pc-asset[id="${this._asset}"]`);
|
|
1068
|
-
return assetElement.asset;
|
|
1069
|
-
}
|
|
1070
1286
|
getInitialComponentData() {
|
|
1071
1287
|
return {
|
|
1072
|
-
asset: this.
|
|
1288
|
+
asset: AssetElement.get(this._asset)
|
|
1073
1289
|
};
|
|
1074
1290
|
}
|
|
1075
1291
|
/**
|
|
@@ -1081,7 +1297,7 @@ class GSplatComponentElement extends ComponentElement {
|
|
|
1081
1297
|
}
|
|
1082
1298
|
set asset(value) {
|
|
1083
1299
|
this._asset = value;
|
|
1084
|
-
const asset =
|
|
1300
|
+
const asset = AssetElement.get(value);
|
|
1085
1301
|
if (this.component && asset) {
|
|
1086
1302
|
this.component.asset = asset;
|
|
1087
1303
|
}
|
|
@@ -1373,6 +1589,120 @@ class LightComponentElement extends ComponentElement {
|
|
|
1373
1589
|
}
|
|
1374
1590
|
customElements.define('pc-light', LightComponentElement);
|
|
1375
1591
|
|
|
1592
|
+
/**
|
|
1593
|
+
* Represents a material in the PlayCanvas engine.
|
|
1594
|
+
*/
|
|
1595
|
+
class MaterialElement extends HTMLElement {
|
|
1596
|
+
constructor() {
|
|
1597
|
+
super(...arguments);
|
|
1598
|
+
this._diffuse = new playcanvas.Color(1, 1, 1);
|
|
1599
|
+
this._diffuseMap = '';
|
|
1600
|
+
this._metalnessMap = '';
|
|
1601
|
+
this._normalMap = '';
|
|
1602
|
+
this._roughnessMap = '';
|
|
1603
|
+
this.material = null;
|
|
1604
|
+
}
|
|
1605
|
+
createMaterial() {
|
|
1606
|
+
this.material = new playcanvas.StandardMaterial();
|
|
1607
|
+
this.material.glossInvert = true;
|
|
1608
|
+
this.material.useMetalness = true;
|
|
1609
|
+
this.material.diffuse = this._diffuse;
|
|
1610
|
+
this.diffuseMap = this._diffuseMap;
|
|
1611
|
+
this.metalnessMap = this._metalnessMap;
|
|
1612
|
+
this.normalMap = this._normalMap;
|
|
1613
|
+
this.roughnessMap = this._roughnessMap;
|
|
1614
|
+
this.material.update();
|
|
1615
|
+
}
|
|
1616
|
+
disconnectedCallback() {
|
|
1617
|
+
if (this.material) {
|
|
1618
|
+
this.material.destroy();
|
|
1619
|
+
this.material = null;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
setMap(map, property) {
|
|
1623
|
+
if (this.material) {
|
|
1624
|
+
const asset = AssetElement.get(map);
|
|
1625
|
+
if (asset) {
|
|
1626
|
+
if (asset.loaded) {
|
|
1627
|
+
this.material[property] = asset.resource;
|
|
1628
|
+
this.material[property].anisotropy = 4;
|
|
1629
|
+
}
|
|
1630
|
+
else {
|
|
1631
|
+
asset.once('load', () => {
|
|
1632
|
+
this.material[property] = asset.resource;
|
|
1633
|
+
this.material[property].anisotropy = 4;
|
|
1634
|
+
this.material.update();
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
set diffuse(value) {
|
|
1641
|
+
this._diffuse = value;
|
|
1642
|
+
if (this.material) {
|
|
1643
|
+
this.material.diffuse = value;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
get diffuse() {
|
|
1647
|
+
return this._diffuse;
|
|
1648
|
+
}
|
|
1649
|
+
set diffuseMap(value) {
|
|
1650
|
+
this._diffuseMap = value;
|
|
1651
|
+
this.setMap(value, 'diffuseMap');
|
|
1652
|
+
}
|
|
1653
|
+
get diffuseMap() {
|
|
1654
|
+
return this._diffuseMap;
|
|
1655
|
+
}
|
|
1656
|
+
set metalnessMap(value) {
|
|
1657
|
+
this._metalnessMap = value;
|
|
1658
|
+
this.setMap(value, 'metalnessMap');
|
|
1659
|
+
}
|
|
1660
|
+
get metalnessMap() {
|
|
1661
|
+
return this._metalnessMap;
|
|
1662
|
+
}
|
|
1663
|
+
set normalMap(value) {
|
|
1664
|
+
this._normalMap = value;
|
|
1665
|
+
this.setMap(value, 'normalMap');
|
|
1666
|
+
}
|
|
1667
|
+
get normalMap() {
|
|
1668
|
+
return this._normalMap;
|
|
1669
|
+
}
|
|
1670
|
+
set roughnessMap(value) {
|
|
1671
|
+
this._roughnessMap = value;
|
|
1672
|
+
this.setMap(value, 'glossMap');
|
|
1673
|
+
}
|
|
1674
|
+
get roughnessMap() {
|
|
1675
|
+
return this._roughnessMap;
|
|
1676
|
+
}
|
|
1677
|
+
static get(id) {
|
|
1678
|
+
const materialElement = document.querySelector(`pc-material[id="${id}"]`);
|
|
1679
|
+
return materialElement === null || materialElement === void 0 ? void 0 : materialElement.material;
|
|
1680
|
+
}
|
|
1681
|
+
static get observedAttributes() {
|
|
1682
|
+
return ['diffuse', 'diffuse-map', 'metalness-map', 'normal-map', 'roughness-map'];
|
|
1683
|
+
}
|
|
1684
|
+
attributeChangedCallback(name, _oldValue, newValue) {
|
|
1685
|
+
switch (name) {
|
|
1686
|
+
case 'diffuse':
|
|
1687
|
+
this.diffuse = parseColor(newValue);
|
|
1688
|
+
break;
|
|
1689
|
+
case 'diffuse-map':
|
|
1690
|
+
this.diffuseMap = newValue;
|
|
1691
|
+
break;
|
|
1692
|
+
case 'metalness-map':
|
|
1693
|
+
this.metalnessMap = newValue;
|
|
1694
|
+
break;
|
|
1695
|
+
case 'normal-map':
|
|
1696
|
+
this.normalMap = newValue;
|
|
1697
|
+
break;
|
|
1698
|
+
case 'roughness-map':
|
|
1699
|
+
this.roughnessMap = newValue;
|
|
1700
|
+
break;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
customElements.define('pc-material', MaterialElement);
|
|
1705
|
+
|
|
1376
1706
|
/**
|
|
1377
1707
|
* Represents a render component in the PlayCanvas engine.
|
|
1378
1708
|
*
|
|
@@ -1381,9 +1711,14 @@ customElements.define('pc-light', LightComponentElement);
|
|
|
1381
1711
|
class RenderComponentElement extends ComponentElement {
|
|
1382
1712
|
constructor() {
|
|
1383
1713
|
super('render');
|
|
1384
|
-
this._type = 'asset';
|
|
1385
1714
|
this._castShadows = true;
|
|
1715
|
+
this._material = '';
|
|
1386
1716
|
this._receiveShadows = true;
|
|
1717
|
+
this._type = 'asset';
|
|
1718
|
+
}
|
|
1719
|
+
async connectedCallback() {
|
|
1720
|
+
await super.connectedCallback();
|
|
1721
|
+
this.material = this._material;
|
|
1387
1722
|
}
|
|
1388
1723
|
getInitialComponentData() {
|
|
1389
1724
|
return {
|
|
@@ -1433,6 +1768,23 @@ class RenderComponentElement extends ComponentElement {
|
|
|
1433
1768
|
get castShadows() {
|
|
1434
1769
|
return this._castShadows;
|
|
1435
1770
|
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Sets the material of the render component.
|
|
1773
|
+
* @param value - The id of the material asset to use.
|
|
1774
|
+
*/
|
|
1775
|
+
set material(value) {
|
|
1776
|
+
this._material = value;
|
|
1777
|
+
if (this.component) {
|
|
1778
|
+
this.component.material = MaterialElement.get(value);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Gets the id of the material asset used by the render component.
|
|
1783
|
+
* @returns The id of the material asset.
|
|
1784
|
+
*/
|
|
1785
|
+
get material() {
|
|
1786
|
+
return this._material;
|
|
1787
|
+
}
|
|
1436
1788
|
/**
|
|
1437
1789
|
* Sets the receive shadows flag of the render component.
|
|
1438
1790
|
* @param value - The receive shadows flag.
|
|
@@ -1451,20 +1803,23 @@ class RenderComponentElement extends ComponentElement {
|
|
|
1451
1803
|
return this._receiveShadows;
|
|
1452
1804
|
}
|
|
1453
1805
|
static get observedAttributes() {
|
|
1454
|
-
return [...super.observedAttributes, 'cast-shadows', 'receive-shadows', 'type'];
|
|
1806
|
+
return [...super.observedAttributes, 'cast-shadows', 'material', 'receive-shadows', 'type'];
|
|
1455
1807
|
}
|
|
1456
1808
|
attributeChangedCallback(name, _oldValue, newValue) {
|
|
1457
1809
|
super.attributeChangedCallback(name, _oldValue, newValue);
|
|
1458
1810
|
switch (name) {
|
|
1459
|
-
case 'type':
|
|
1460
|
-
this.type = newValue;
|
|
1461
|
-
break;
|
|
1462
1811
|
case 'cast-shadows':
|
|
1463
1812
|
this.castShadows = newValue !== 'false';
|
|
1464
1813
|
break;
|
|
1814
|
+
case 'material':
|
|
1815
|
+
this.material = newValue;
|
|
1816
|
+
break;
|
|
1465
1817
|
case 'receive-shadows':
|
|
1466
1818
|
this.receiveShadows = newValue !== 'false';
|
|
1467
1819
|
break;
|
|
1820
|
+
case 'type':
|
|
1821
|
+
this.type = newValue;
|
|
1822
|
+
break;
|
|
1468
1823
|
}
|
|
1469
1824
|
}
|
|
1470
1825
|
}
|
|
@@ -1658,91 +2013,275 @@ class RigidBodyComponentElement extends ComponentElement {
|
|
|
1658
2013
|
customElements.define('pc-rigidbody', RigidBodyComponentElement);
|
|
1659
2014
|
|
|
1660
2015
|
/**
|
|
1661
|
-
* Represents a
|
|
2016
|
+
* Represents a screen component in the PlayCanvas engine.
|
|
1662
2017
|
*
|
|
1663
2018
|
* @category Components
|
|
1664
2019
|
*/
|
|
1665
|
-
class
|
|
2020
|
+
class ScreenComponentElement extends ComponentElement {
|
|
1666
2021
|
constructor() {
|
|
1667
|
-
super('
|
|
2022
|
+
super('screen');
|
|
2023
|
+
this._screenSpace = false;
|
|
2024
|
+
this._resolution = new playcanvas.Vec2(640, 320);
|
|
2025
|
+
this._referenceResolution = new playcanvas.Vec2(640, 320);
|
|
2026
|
+
this._priority = 0;
|
|
2027
|
+
this._blend = false;
|
|
2028
|
+
this._scaleBlend = 0.5;
|
|
2029
|
+
}
|
|
2030
|
+
getInitialComponentData() {
|
|
2031
|
+
return {
|
|
2032
|
+
priority: this._priority,
|
|
2033
|
+
referenceResolution: this._referenceResolution,
|
|
2034
|
+
resolution: this._resolution,
|
|
2035
|
+
scaleBlend: this._scaleBlend,
|
|
2036
|
+
scaleMode: this._blend ? playcanvas.SCALEMODE_BLEND : playcanvas.SCALEMODE_NONE,
|
|
2037
|
+
screenSpace: this._screenSpace
|
|
2038
|
+
};
|
|
1668
2039
|
}
|
|
1669
2040
|
/**
|
|
1670
|
-
* Gets the
|
|
1671
|
-
* @returns The
|
|
2041
|
+
* Gets the screen component.
|
|
2042
|
+
* @returns The screen component.
|
|
1672
2043
|
*/
|
|
1673
2044
|
get component() {
|
|
1674
2045
|
return super.component;
|
|
1675
2046
|
}
|
|
2047
|
+
set priority(value) {
|
|
2048
|
+
this._priority = value;
|
|
2049
|
+
if (this.component) {
|
|
2050
|
+
this.component.priority = this._priority;
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
get priority() {
|
|
2054
|
+
return this._priority;
|
|
2055
|
+
}
|
|
2056
|
+
set referenceResolution(value) {
|
|
2057
|
+
this._referenceResolution = value;
|
|
2058
|
+
if (this.component) {
|
|
2059
|
+
this.component.referenceResolution = this._referenceResolution;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
get referenceResolution() {
|
|
2063
|
+
return this._referenceResolution;
|
|
2064
|
+
}
|
|
2065
|
+
set resolution(value) {
|
|
2066
|
+
this._resolution = value;
|
|
2067
|
+
if (this.component) {
|
|
2068
|
+
this.component.resolution = this._resolution;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
get resolution() {
|
|
2072
|
+
return this._resolution;
|
|
2073
|
+
}
|
|
2074
|
+
set scaleBlend(value) {
|
|
2075
|
+
this._scaleBlend = value;
|
|
2076
|
+
if (this.component) {
|
|
2077
|
+
this.component.scaleBlend = this._scaleBlend;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
get scaleBlend() {
|
|
2081
|
+
return this._scaleBlend;
|
|
2082
|
+
}
|
|
2083
|
+
set blend(value) {
|
|
2084
|
+
this._blend = value;
|
|
2085
|
+
if (this.component) {
|
|
2086
|
+
this.component.scaleMode = this._blend ? playcanvas.SCALEMODE_BLEND : playcanvas.SCALEMODE_NONE;
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
get blend() {
|
|
2090
|
+
return this._blend;
|
|
2091
|
+
}
|
|
2092
|
+
set screenSpace(value) {
|
|
2093
|
+
this._screenSpace = value;
|
|
2094
|
+
if (this.component) {
|
|
2095
|
+
this.component.screenSpace = this._screenSpace;
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
get screenSpace() {
|
|
2099
|
+
return this._screenSpace;
|
|
2100
|
+
}
|
|
2101
|
+
static get observedAttributes() {
|
|
2102
|
+
return [
|
|
2103
|
+
...super.observedAttributes,
|
|
2104
|
+
'blend',
|
|
2105
|
+
'screen-space',
|
|
2106
|
+
'resolution',
|
|
2107
|
+
'reference-resolution',
|
|
2108
|
+
'priority',
|
|
2109
|
+
'scale-blend'
|
|
2110
|
+
];
|
|
2111
|
+
}
|
|
2112
|
+
attributeChangedCallback(name, _oldValue, newValue) {
|
|
2113
|
+
super.attributeChangedCallback(name, _oldValue, newValue);
|
|
2114
|
+
switch (name) {
|
|
2115
|
+
case 'priority':
|
|
2116
|
+
this.priority = parseInt(newValue);
|
|
2117
|
+
break;
|
|
2118
|
+
case 'reference-resolution':
|
|
2119
|
+
this.referenceResolution = parseVec2(newValue);
|
|
2120
|
+
break;
|
|
2121
|
+
case 'resolution':
|
|
2122
|
+
this.resolution = parseVec2(newValue);
|
|
2123
|
+
break;
|
|
2124
|
+
case 'scale-blend':
|
|
2125
|
+
this.scaleBlend = parseFloat(newValue);
|
|
2126
|
+
break;
|
|
2127
|
+
case 'blend':
|
|
2128
|
+
this.blend = this.hasAttribute('blend');
|
|
2129
|
+
break;
|
|
2130
|
+
case 'screen-space':
|
|
2131
|
+
this.screenSpace = this.hasAttribute('screen-space');
|
|
2132
|
+
break;
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
1676
2135
|
}
|
|
1677
|
-
customElements.define('pc-
|
|
2136
|
+
customElements.define('pc-screen', ScreenComponentElement);
|
|
1678
2137
|
|
|
1679
2138
|
/**
|
|
1680
|
-
* Represents a script in the PlayCanvas engine.
|
|
2139
|
+
* Represents a script component in the PlayCanvas engine.
|
|
2140
|
+
*
|
|
2141
|
+
* @category Components
|
|
1681
2142
|
*/
|
|
1682
|
-
class
|
|
2143
|
+
class ScriptComponentElement extends ComponentElement {
|
|
1683
2144
|
constructor() {
|
|
1684
|
-
super(
|
|
1685
|
-
|
|
1686
|
-
this.
|
|
1687
|
-
this.
|
|
1688
|
-
|
|
2145
|
+
super('script');
|
|
2146
|
+
// Create mutation observer to watch for child script elements
|
|
2147
|
+
this.observer = new MutationObserver(this.handleMutations.bind(this));
|
|
2148
|
+
this.observer.observe(this, {
|
|
2149
|
+
childList: true
|
|
2150
|
+
});
|
|
2151
|
+
// Listen for script attribute and enable changes
|
|
2152
|
+
this.addEventListener('scriptattributeschange', this.handleScriptAttributesChange.bind(this));
|
|
2153
|
+
this.addEventListener('scriptenablechange', this.handleScriptEnableChange.bind(this));
|
|
1689
2154
|
}
|
|
1690
2155
|
async connectedCallback() {
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
2156
|
+
await super.connectedCallback();
|
|
2157
|
+
// Handle initial script elements
|
|
2158
|
+
this.querySelectorAll(':scope > pc-script').forEach((scriptElement) => {
|
|
2159
|
+
const scriptName = scriptElement.getAttribute('name');
|
|
2160
|
+
const attributes = scriptElement.getAttribute('attributes');
|
|
2161
|
+
if (scriptName) {
|
|
2162
|
+
this.createScript(scriptName, attributes);
|
|
2163
|
+
}
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
applyAttributes(script, attributes) {
|
|
2167
|
+
try {
|
|
2168
|
+
// Parse the attributes string into an object and set them on the script
|
|
2169
|
+
const attributesObject = attributes ? JSON.parse(attributes) : {};
|
|
2170
|
+
Object.assign(script, attributesObject);
|
|
2171
|
+
}
|
|
2172
|
+
catch (error) {
|
|
2173
|
+
console.error(`Error parsing attributes JSON string ${attributes}:`, error);
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
handleScriptAttributesChange(event) {
|
|
2177
|
+
const scriptElement = event.target;
|
|
2178
|
+
const scriptName = scriptElement.getAttribute('name');
|
|
2179
|
+
if (!scriptName || !this.component)
|
|
1695
2180
|
return;
|
|
2181
|
+
const script = this.component.get(scriptName);
|
|
2182
|
+
if (script) {
|
|
2183
|
+
this.applyAttributes(script, event.detail.attributes);
|
|
1696
2184
|
}
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
2185
|
+
}
|
|
2186
|
+
handleScriptEnableChange(event) {
|
|
2187
|
+
const scriptElement = event.target;
|
|
2188
|
+
const scriptName = scriptElement.getAttribute('name');
|
|
2189
|
+
if (!scriptName || !this.component)
|
|
2190
|
+
return;
|
|
2191
|
+
const script = this.component.get(scriptName);
|
|
2192
|
+
if (script) {
|
|
2193
|
+
script.enabled = event.detail.enabled;
|
|
1706
2194
|
}
|
|
1707
|
-
// When the script is created, initialize it with the necessary attributes
|
|
1708
|
-
(_a = this.scriptsElement) === null || _a === void 0 ? void 0 : _a.component.on(`create:${this._name}`, (scriptInstance) => {
|
|
1709
|
-
Object.assign(scriptInstance, this._attributes);
|
|
1710
|
-
});
|
|
1711
|
-
this._script = (_c = (_b = this.scriptsElement) === null || _b === void 0 ? void 0 : _b.component.create(this._name, { preloading: false })) !== null && _c !== void 0 ? _c : null;
|
|
1712
2195
|
}
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
2196
|
+
createScript(name, attributes) {
|
|
2197
|
+
if (!this.component)
|
|
2198
|
+
return null;
|
|
2199
|
+
this.component.on(`create:${name}`, (script) => {
|
|
2200
|
+
this.applyAttributes(script, attributes);
|
|
2201
|
+
});
|
|
2202
|
+
return this.component.create(name);
|
|
1716
2203
|
}
|
|
1717
|
-
|
|
1718
|
-
if (this.
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
2204
|
+
destroyScript(name) {
|
|
2205
|
+
if (!this.component)
|
|
2206
|
+
return;
|
|
2207
|
+
this.component.destroy(name);
|
|
2208
|
+
}
|
|
2209
|
+
handleMutations(mutations) {
|
|
2210
|
+
for (const mutation of mutations) {
|
|
2211
|
+
// Handle added nodes
|
|
2212
|
+
mutation.addedNodes.forEach((node) => {
|
|
2213
|
+
if (node instanceof HTMLElement && node.tagName.toLowerCase() === 'pc-script') {
|
|
2214
|
+
const scriptName = node.getAttribute('name');
|
|
2215
|
+
const attributes = node.getAttribute('attributes');
|
|
2216
|
+
if (scriptName) {
|
|
2217
|
+
this.createScript(scriptName, attributes);
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2221
|
+
// Handle removed nodes
|
|
2222
|
+
mutation.removedNodes.forEach((node) => {
|
|
2223
|
+
if (node instanceof HTMLElement && node.tagName.toLowerCase() === 'pc-script') {
|
|
2224
|
+
const scriptName = node.getAttribute('name');
|
|
2225
|
+
if (scriptName) {
|
|
2226
|
+
this.destroyScript(scriptName);
|
|
2227
|
+
}
|
|
1722
2228
|
}
|
|
1723
2229
|
});
|
|
1724
2230
|
}
|
|
1725
2231
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
return null;
|
|
1731
|
-
}
|
|
1732
|
-
return scriptsElement;
|
|
2232
|
+
disconnectedCallback() {
|
|
2233
|
+
var _a;
|
|
2234
|
+
this.observer.disconnect();
|
|
2235
|
+
(_a = super.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
1733
2236
|
}
|
|
2237
|
+
/**
|
|
2238
|
+
* Gets the script component.
|
|
2239
|
+
* @returns The script component.
|
|
2240
|
+
*/
|
|
2241
|
+
get component() {
|
|
2242
|
+
return super.component;
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
customElements.define('pc-scripts', ScriptComponentElement);
|
|
2246
|
+
|
|
2247
|
+
/**
|
|
2248
|
+
* Represents a script in the PlayCanvas engine.
|
|
2249
|
+
*/
|
|
2250
|
+
class ScriptElement extends HTMLElement {
|
|
2251
|
+
constructor() {
|
|
2252
|
+
super(...arguments);
|
|
2253
|
+
this._attributes = '{}';
|
|
2254
|
+
this._enabled = true;
|
|
2255
|
+
this._name = '';
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2258
|
+
* Sets the attributes of the script.
|
|
2259
|
+
* @param value - The attributes of the script.
|
|
2260
|
+
*/
|
|
1734
2261
|
set scriptAttributes(value) {
|
|
1735
|
-
this._attributes =
|
|
1736
|
-
this.
|
|
2262
|
+
this._attributes = value;
|
|
2263
|
+
this.dispatchEvent(new CustomEvent('scriptattributeschange', {
|
|
2264
|
+
detail: { attributes: value },
|
|
2265
|
+
bubbles: true
|
|
2266
|
+
}));
|
|
1737
2267
|
}
|
|
2268
|
+
/**
|
|
2269
|
+
* Gets the attributes of the script.
|
|
2270
|
+
* @returns The attributes of the script.
|
|
2271
|
+
*/
|
|
1738
2272
|
get scriptAttributes() {
|
|
1739
|
-
return
|
|
2273
|
+
return this._attributes;
|
|
1740
2274
|
}
|
|
2275
|
+
/**
|
|
2276
|
+
* Sets the enabled state of the script.
|
|
2277
|
+
* @param value - The enabled state of the script.
|
|
2278
|
+
*/
|
|
1741
2279
|
set enabled(value) {
|
|
1742
2280
|
this._enabled = value;
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
2281
|
+
this.dispatchEvent(new CustomEvent('scriptenablechange', {
|
|
2282
|
+
detail: { enabled: value },
|
|
2283
|
+
bubbles: true
|
|
2284
|
+
}));
|
|
1746
2285
|
}
|
|
1747
2286
|
/**
|
|
1748
2287
|
* Gets the enabled state of the script.
|
|
@@ -1879,7 +2418,7 @@ class SoundComponentElement extends ComponentElement {
|
|
|
1879
2418
|
}
|
|
1880
2419
|
}
|
|
1881
2420
|
}
|
|
1882
|
-
customElements.define('pc-
|
|
2421
|
+
customElements.define('pc-sounds', SoundComponentElement);
|
|
1883
2422
|
|
|
1884
2423
|
/**
|
|
1885
2424
|
* Represents a sound slot in the PlayCanvas engine.
|
|
@@ -1901,10 +2440,6 @@ class SoundSlotElement extends HTMLElement {
|
|
|
1901
2440
|
*/
|
|
1902
2441
|
this.soundSlot = null;
|
|
1903
2442
|
}
|
|
1904
|
-
getAsset() {
|
|
1905
|
-
const assetElement = document.querySelector(`pc-asset[id="${this._asset}"]`);
|
|
1906
|
-
return assetElement.asset;
|
|
1907
|
-
}
|
|
1908
2443
|
async connectedCallback() {
|
|
1909
2444
|
const appElement = this.closest('pc-app');
|
|
1910
2445
|
if (!appElement) {
|
|
@@ -1946,7 +2481,7 @@ class SoundSlotElement extends HTMLElement {
|
|
|
1946
2481
|
var _a;
|
|
1947
2482
|
this._asset = value;
|
|
1948
2483
|
if (this.soundSlot) {
|
|
1949
|
-
const id = (_a =
|
|
2484
|
+
const id = (_a = AssetElement.get(value)) === null || _a === void 0 ? void 0 : _a.id;
|
|
1950
2485
|
if (id) {
|
|
1951
2486
|
this.soundSlot.asset = id;
|
|
1952
2487
|
}
|
|
@@ -2127,7 +2662,7 @@ class SoundSlotElement extends HTMLElement {
|
|
|
2127
2662
|
}
|
|
2128
2663
|
}
|
|
2129
2664
|
}
|
|
2130
|
-
customElements.define('pc-sound
|
|
2665
|
+
customElements.define('pc-sound', SoundSlotElement);
|
|
2131
2666
|
|
|
2132
2667
|
/**
|
|
2133
2668
|
* Represents a model in the PlayCanvas engine.
|
|
@@ -2150,12 +2685,8 @@ class ModelElement extends HTMLElement {
|
|
|
2150
2685
|
this.asset = asset;
|
|
2151
2686
|
}
|
|
2152
2687
|
}
|
|
2153
|
-
getAsset() {
|
|
2154
|
-
const assetElement = document.querySelector(`pc-asset[id="${this._asset}"]`);
|
|
2155
|
-
return assetElement.asset;
|
|
2156
|
-
}
|
|
2157
2688
|
_loadModel() {
|
|
2158
|
-
const asset = this.
|
|
2689
|
+
const asset = AssetElement.get(this._asset);
|
|
2159
2690
|
if (!asset) {
|
|
2160
2691
|
return;
|
|
2161
2692
|
}
|
|
@@ -2383,10 +2914,6 @@ class SkyElement extends HTMLElement {
|
|
|
2383
2914
|
this.asset = this.getAttribute('asset') || '';
|
|
2384
2915
|
this.solidColor = this.hasAttribute('solid-color');
|
|
2385
2916
|
}
|
|
2386
|
-
getAsset() {
|
|
2387
|
-
const assetElement = document.querySelector(`pc-asset[id="${this._asset}"]`);
|
|
2388
|
-
return assetElement.asset;
|
|
2389
|
-
}
|
|
2390
2917
|
getScene() {
|
|
2391
2918
|
const appElement = this.closest('pc-app');
|
|
2392
2919
|
if (!appElement) {
|
|
@@ -2402,7 +2929,7 @@ class SkyElement extends HTMLElement {
|
|
|
2402
2929
|
this._asset = value;
|
|
2403
2930
|
const scene = this.getScene();
|
|
2404
2931
|
if (scene) {
|
|
2405
|
-
const asset =
|
|
2932
|
+
const asset = AssetElement.get(value);
|
|
2406
2933
|
if (asset) {
|
|
2407
2934
|
if (asset.resource) {
|
|
2408
2935
|
scene.envAtlas = asset.resource;
|
|
@@ -2496,11 +3023,13 @@ exports.EntityElement = EntityElement;
|
|
|
2496
3023
|
exports.GSplatComponentElement = GSplatComponentElement;
|
|
2497
3024
|
exports.LightComponentElement = LightComponentElement;
|
|
2498
3025
|
exports.ListenerComponentElement = ListenerComponentElement;
|
|
3026
|
+
exports.MaterialElement = MaterialElement;
|
|
2499
3027
|
exports.ModelElement = ModelElement;
|
|
2500
3028
|
exports.ModuleElement = ModuleElement;
|
|
2501
3029
|
exports.RenderComponentElement = RenderComponentElement;
|
|
2502
3030
|
exports.RigidBodyComponentElement = RigidBodyComponentElement;
|
|
2503
3031
|
exports.SceneElement = SceneElement;
|
|
3032
|
+
exports.ScreenComponentElement = ScreenComponentElement;
|
|
2504
3033
|
exports.ScriptComponentElement = ScriptComponentElement;
|
|
2505
3034
|
exports.ScriptElement = ScriptElement;
|
|
2506
3035
|
exports.SkyElement = SkyElement;
|