@playcanvas/web-components 0.1.7 → 0.1.9
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/dist/app.d.ts +10 -1
- package/dist/asset.d.ts +3 -1
- package/dist/async-element.d.ts +2 -1
- package/dist/components/camera-component.d.ts +4 -4
- package/dist/components/collision-component.d.ts +4 -4
- package/dist/components/component.d.ts +3 -1
- package/dist/components/element-component.d.ts +4 -1
- package/dist/components/gsplat-component.d.ts +4 -1
- package/dist/components/light-component.d.ts +16 -4
- package/dist/components/listener-component.d.ts +4 -1
- package/dist/components/render-component.d.ts +4 -1
- package/dist/components/rigidbody-component.d.ts +4 -4
- package/dist/components/screen-component.d.ts +4 -1
- package/dist/components/script-component.d.ts +4 -1
- package/dist/components/script.d.ts +3 -1
- package/dist/components/sound-component.d.ts +4 -1
- package/dist/components/sound-slot.d.ts +3 -1
- package/dist/entity.d.ts +7 -3
- package/dist/material.d.ts +3 -1
- package/dist/model.d.ts +3 -1
- package/dist/module.d.ts +6 -0
- package/dist/pwc.cjs +195 -75
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +195 -75
- 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 +196 -76
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +3 -1
- package/dist/sky.d.ts +4 -2
- package/package.json +15 -13
- package/src/app.ts +28 -1
- package/src/asset.ts +3 -1
- package/src/async-element.ts +2 -1
- package/src/components/camera-component.ts +4 -4
- package/src/components/collision-component.ts +4 -4
- package/src/components/component.ts +3 -1
- package/src/components/element-component.ts +4 -2
- package/src/components/gsplat-component.ts +4 -1
- package/src/components/light-component.ts +30 -4
- package/src/components/listener-component.ts +4 -1
- package/src/components/render-component.ts +4 -1
- package/src/components/rigidbody-component.ts +4 -4
- package/src/components/screen-component.ts +4 -1
- package/src/components/script-component.ts +15 -1
- package/src/components/script.ts +3 -1
- package/src/components/sound-component.ts +4 -1
- package/src/components/sound-slot.ts +3 -1
- package/src/entity.ts +59 -27
- package/src/material.ts +3 -1
- package/src/model.ts +3 -1
- package/src/module.ts +6 -0
- package/src/scene.ts +13 -11
- package/src/sky.ts +5 -2
package/dist/pwc.cjs
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
var playcanvas = require('playcanvas');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Base class for all PlayCanvas
|
|
6
|
+
* Base class for all PlayCanvas Web Components that initialize asynchronously.
|
|
7
7
|
*/
|
|
8
8
|
class AsyncElement extends HTMLElement {
|
|
9
|
+
/** @ignore */
|
|
9
10
|
constructor() {
|
|
10
11
|
super();
|
|
11
12
|
this._readyPromise = new Promise((resolve) => {
|
|
@@ -37,7 +38,13 @@ class AsyncElement extends HTMLElement {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* The ModuleElement interface provides properties and methods for manipulating
|
|
43
|
+
* `<pc-module>` elements. The ModuleElement interface also inherits the properties and
|
|
44
|
+
* methods of the {@link HTMLElement} interface.
|
|
45
|
+
*/
|
|
40
46
|
class ModuleElement extends HTMLElement {
|
|
47
|
+
/** @ignore */
|
|
41
48
|
constructor() {
|
|
42
49
|
super();
|
|
43
50
|
this.loadPromise = this.loadModule();
|
|
@@ -76,7 +83,9 @@ customElements.define('pc-module', ModuleElement);
|
|
|
76
83
|
*/
|
|
77
84
|
class AppElement extends AsyncElement {
|
|
78
85
|
/**
|
|
79
|
-
* Creates a new AppElement.
|
|
86
|
+
* Creates a new AppElement instance.
|
|
87
|
+
*
|
|
88
|
+
* @ignore
|
|
80
89
|
*/
|
|
81
90
|
constructor() {
|
|
82
91
|
super();
|
|
@@ -89,6 +98,7 @@ class AppElement extends AsyncElement {
|
|
|
89
98
|
this._depth = true;
|
|
90
99
|
this._stencil = true;
|
|
91
100
|
this._highResolution = false;
|
|
101
|
+
this._hierarchyReady = false;
|
|
92
102
|
/**
|
|
93
103
|
* The PlayCanvas application instance.
|
|
94
104
|
*/
|
|
@@ -132,6 +142,16 @@ class AppElement extends AsyncElement {
|
|
|
132
142
|
Array.from(materialElements).forEach((materialElement) => {
|
|
133
143
|
materialElement.createMaterial();
|
|
134
144
|
});
|
|
145
|
+
// Create all entities
|
|
146
|
+
const entityElements = this.querySelectorAll('pc-entity');
|
|
147
|
+
Array.from(entityElements).forEach((entityElement) => {
|
|
148
|
+
entityElement.createEntity(this.app);
|
|
149
|
+
});
|
|
150
|
+
// Build hierarchy
|
|
151
|
+
entityElements.forEach((entityElement) => {
|
|
152
|
+
entityElement.buildHierarchy(this.app);
|
|
153
|
+
});
|
|
154
|
+
this._hierarchyReady = true;
|
|
135
155
|
// Load assets before starting the application
|
|
136
156
|
this.app.preload(() => {
|
|
137
157
|
// Start the application
|
|
@@ -202,6 +222,14 @@ class AppElement extends AsyncElement {
|
|
|
202
222
|
get depth() {
|
|
203
223
|
return this._depth;
|
|
204
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Gets the hierarchy ready flag.
|
|
227
|
+
* @returns The hierarchy ready flag.
|
|
228
|
+
* @ignore
|
|
229
|
+
*/
|
|
230
|
+
get hierarchyReady() {
|
|
231
|
+
return this._hierarchyReady;
|
|
232
|
+
}
|
|
205
233
|
/**
|
|
206
234
|
* Sets the high resolution flag. When true, the application will render at the device's
|
|
207
235
|
* physical resolution. When false, the application will render at CSS resolution.
|
|
@@ -473,7 +501,9 @@ const parseVec4 = (value) => {
|
|
|
473
501
|
};
|
|
474
502
|
|
|
475
503
|
/**
|
|
476
|
-
*
|
|
504
|
+
* The EntityElement interface provides properties and methods for manipulating
|
|
505
|
+
* `<pc-entity>` elements. The EntityElement interface also inherits the properties and
|
|
506
|
+
* methods of the {@link HTMLElement} interface.
|
|
477
507
|
*/
|
|
478
508
|
class EntityElement extends AsyncElement {
|
|
479
509
|
constructor() {
|
|
@@ -507,41 +537,60 @@ class EntityElement extends AsyncElement {
|
|
|
507
537
|
*/
|
|
508
538
|
this.entity = null;
|
|
509
539
|
}
|
|
510
|
-
|
|
511
|
-
const closestApp = this.closestApp;
|
|
512
|
-
if (!closestApp)
|
|
513
|
-
return;
|
|
514
|
-
// Wait for the app to complete initialization
|
|
515
|
-
await closestApp.ready();
|
|
516
|
-
const app = closestApp.app;
|
|
540
|
+
createEntity(app) {
|
|
517
541
|
// Create a new entity
|
|
518
|
-
this.entity = new playcanvas.Entity(this._name, app);
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
542
|
+
this.entity = new playcanvas.Entity(this.getAttribute('name') || this._name, app);
|
|
543
|
+
const enabled = this.getAttribute('enabled');
|
|
544
|
+
if (enabled) {
|
|
545
|
+
this.entity.enabled = enabled !== 'false';
|
|
546
|
+
}
|
|
547
|
+
const position = this.getAttribute('position');
|
|
548
|
+
if (position) {
|
|
549
|
+
this.entity.setLocalPosition(parseVec3(position));
|
|
550
|
+
}
|
|
551
|
+
const rotation = this.getAttribute('rotation');
|
|
552
|
+
if (rotation) {
|
|
553
|
+
this.entity.setLocalEulerAngles(parseVec3(rotation));
|
|
554
|
+
}
|
|
555
|
+
const scale = this.getAttribute('scale');
|
|
556
|
+
if (scale) {
|
|
557
|
+
this.entity.setLocalScale(parseVec3(scale));
|
|
558
|
+
}
|
|
559
|
+
const tags = this.getAttribute('tags');
|
|
560
|
+
if (tags) {
|
|
561
|
+
this.entity.tags.add(tags.split(',').map(tag => tag.trim()));
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
buildHierarchy(app) {
|
|
565
|
+
if (!this.entity)
|
|
566
|
+
return;
|
|
535
567
|
const closestEntity = this.closestEntity;
|
|
536
|
-
if (closestEntity) {
|
|
537
|
-
closestEntity.
|
|
538
|
-
closestEntity.entity.addChild(this.entity);
|
|
539
|
-
this._onReady();
|
|
540
|
-
});
|
|
568
|
+
if (closestEntity === null || closestEntity === void 0 ? void 0 : closestEntity.entity) {
|
|
569
|
+
closestEntity.entity.addChild(this.entity);
|
|
541
570
|
}
|
|
542
571
|
else {
|
|
543
572
|
app.root.addChild(this.entity);
|
|
544
|
-
|
|
573
|
+
}
|
|
574
|
+
this._onReady();
|
|
575
|
+
}
|
|
576
|
+
connectedCallback() {
|
|
577
|
+
// Wait for app to be ready
|
|
578
|
+
const closestApp = this.closestApp;
|
|
579
|
+
if (!closestApp)
|
|
580
|
+
return;
|
|
581
|
+
// If app is already running, create entity immediately
|
|
582
|
+
if (closestApp.hierarchyReady) {
|
|
583
|
+
const app = closestApp.app;
|
|
584
|
+
this.createEntity(app);
|
|
585
|
+
this.buildHierarchy(app);
|
|
586
|
+
// Handle any child entities that might exist
|
|
587
|
+
const childEntities = this.querySelectorAll('pc-entity');
|
|
588
|
+
childEntities.forEach((child) => {
|
|
589
|
+
child.createEntity(app);
|
|
590
|
+
});
|
|
591
|
+
childEntities.forEach((child) => {
|
|
592
|
+
child.buildHierarchy(app);
|
|
593
|
+
});
|
|
545
594
|
}
|
|
546
595
|
}
|
|
547
596
|
disconnectedCallback() {
|
|
@@ -551,6 +600,7 @@ class EntityElement extends AsyncElement {
|
|
|
551
600
|
children.forEach((child) => {
|
|
552
601
|
child.entity = null;
|
|
553
602
|
});
|
|
603
|
+
// Destroy the entity
|
|
554
604
|
this.entity.destroy();
|
|
555
605
|
this.entity = null;
|
|
556
606
|
}
|
|
@@ -706,7 +756,9 @@ const extToType = new Map([
|
|
|
706
756
|
['webp', 'texture']
|
|
707
757
|
]);
|
|
708
758
|
/**
|
|
709
|
-
*
|
|
759
|
+
* The AssetElement interface provides properties and methods for manipulating
|
|
760
|
+
* `<pc-asset>` elements. The AssetElement interface also inherits the properties and
|
|
761
|
+
* methods of the {@link HTMLElement} interface.
|
|
710
762
|
*/
|
|
711
763
|
class AssetElement extends HTMLElement {
|
|
712
764
|
constructor() {
|
|
@@ -782,8 +834,10 @@ customElements.define('pc-asset', AssetElement);
|
|
|
782
834
|
*/
|
|
783
835
|
class ComponentElement extends AsyncElement {
|
|
784
836
|
/**
|
|
785
|
-
*
|
|
837
|
+
* Creates a new ComponentElement instance.
|
|
838
|
+
*
|
|
786
839
|
* @param componentName - The name of the component.
|
|
840
|
+
* @ignore
|
|
787
841
|
*/
|
|
788
842
|
constructor(componentName) {
|
|
789
843
|
super();
|
|
@@ -852,11 +906,14 @@ class ComponentElement extends AsyncElement {
|
|
|
852
906
|
}
|
|
853
907
|
|
|
854
908
|
/**
|
|
855
|
-
*
|
|
909
|
+
* The ListenerComponentElement interface provides properties and methods for manipulating
|
|
910
|
+
* `<pc-listener>` elements. The ListenerComponentElement interface also inherits the properties
|
|
911
|
+
* and methods of the {@link HTMLElement} interface.
|
|
856
912
|
*
|
|
857
913
|
* @category Components
|
|
858
914
|
*/
|
|
859
915
|
class ListenerComponentElement extends ComponentElement {
|
|
916
|
+
/** @ignore */
|
|
860
917
|
constructor() {
|
|
861
918
|
super('audiolistener');
|
|
862
919
|
}
|
|
@@ -871,14 +928,14 @@ class ListenerComponentElement extends ComponentElement {
|
|
|
871
928
|
customElements.define('pc-listener', ListenerComponentElement);
|
|
872
929
|
|
|
873
930
|
/**
|
|
874
|
-
*
|
|
931
|
+
* The CameraComponentElement interface provides properties and methods for manipulating
|
|
932
|
+
* `<pc-camera>` elements. The CameraComponentElement interface also inherits the properties and
|
|
933
|
+
* methods of the {@link HTMLElement} interface.
|
|
875
934
|
*
|
|
876
935
|
* @category Components
|
|
877
936
|
*/
|
|
878
937
|
class CameraComponentElement extends ComponentElement {
|
|
879
|
-
/**
|
|
880
|
-
* Creates a new CameraComponentElement.
|
|
881
|
-
*/
|
|
938
|
+
/** @ignore */
|
|
882
939
|
constructor() {
|
|
883
940
|
super('camera');
|
|
884
941
|
this._clearColor = new playcanvas.Color(0.75, 0.75, 0.75, 1);
|
|
@@ -1272,14 +1329,14 @@ class CameraComponentElement extends ComponentElement {
|
|
|
1272
1329
|
customElements.define('pc-camera', CameraComponentElement);
|
|
1273
1330
|
|
|
1274
1331
|
/**
|
|
1275
|
-
*
|
|
1332
|
+
* The CollisionComponentElement interface provides properties and methods for manipulating
|
|
1333
|
+
* `<pc-collision>` elements. The CollisionComponentElement interface also inherits the properties
|
|
1334
|
+
* and methods of the {@link HTMLElement} interface.
|
|
1276
1335
|
*
|
|
1277
1336
|
* @category Components
|
|
1278
1337
|
*/
|
|
1279
1338
|
class CollisionComponentElement extends ComponentElement {
|
|
1280
|
-
/**
|
|
1281
|
-
* Creates a new CollisionComponentElement.
|
|
1282
|
-
*/
|
|
1339
|
+
/** @ignore */
|
|
1283
1340
|
constructor() {
|
|
1284
1341
|
super('collision');
|
|
1285
1342
|
this._angularOffset = new playcanvas.Quat();
|
|
@@ -1418,11 +1475,14 @@ class CollisionComponentElement extends ComponentElement {
|
|
|
1418
1475
|
customElements.define('pc-collision', CollisionComponentElement);
|
|
1419
1476
|
|
|
1420
1477
|
/**
|
|
1421
|
-
*
|
|
1478
|
+
* The ElementComponentElement interface provides properties and methods for manipulating
|
|
1479
|
+
* `<pc-element>` elements. The ElementComponentElement interface also inherits the properties and
|
|
1480
|
+
* methods of the {@link HTMLElement} interface.
|
|
1422
1481
|
*
|
|
1423
1482
|
* @category Components
|
|
1424
1483
|
*/
|
|
1425
1484
|
class ElementComponentElement extends ComponentElement {
|
|
1485
|
+
/** @ignore */
|
|
1426
1486
|
constructor() {
|
|
1427
1487
|
super('element');
|
|
1428
1488
|
this._anchor = new playcanvas.Vec4(0.5, 0.5, 0.5, 0.5);
|
|
@@ -1628,11 +1688,14 @@ class ElementComponentElement extends ComponentElement {
|
|
|
1628
1688
|
customElements.define('pc-element', ElementComponentElement);
|
|
1629
1689
|
|
|
1630
1690
|
/**
|
|
1631
|
-
*
|
|
1691
|
+
* The GSplatComponentElement interface provides properties and methods for manipulating
|
|
1692
|
+
* `<pc-splat>` elements. The GSplatComponentElement interface also inherits the properties and
|
|
1693
|
+
* methods of the {@link HTMLElement} interface.
|
|
1632
1694
|
*
|
|
1633
1695
|
* @category Components
|
|
1634
1696
|
*/
|
|
1635
1697
|
class GSplatComponentElement extends ComponentElement {
|
|
1698
|
+
/** @ignore */
|
|
1636
1699
|
constructor() {
|
|
1637
1700
|
super('gsplat');
|
|
1638
1701
|
this._asset = '';
|
|
@@ -1674,14 +1737,14 @@ class GSplatComponentElement extends ComponentElement {
|
|
|
1674
1737
|
customElements.define('pc-splat', GSplatComponentElement);
|
|
1675
1738
|
|
|
1676
1739
|
/**
|
|
1677
|
-
*
|
|
1740
|
+
* The LightComponentElement interface provides properties and methods for manipulating
|
|
1741
|
+
* `<pc-light>` elements. The LightComponentElement interface also inherits the properties and
|
|
1742
|
+
* methods of the {@link HTMLElement} interface.
|
|
1678
1743
|
*
|
|
1679
1744
|
* @category Components
|
|
1680
1745
|
*/
|
|
1681
1746
|
class LightComponentElement extends ComponentElement {
|
|
1682
|
-
/**
|
|
1683
|
-
* Creates a new LightComponentElement.
|
|
1684
|
-
*/
|
|
1747
|
+
/** @ignore */
|
|
1685
1748
|
constructor() {
|
|
1686
1749
|
super('light');
|
|
1687
1750
|
this._castShadows = false;
|
|
@@ -1693,6 +1756,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
1693
1756
|
this._range = 10;
|
|
1694
1757
|
this._shadowBias = 0.2;
|
|
1695
1758
|
this._shadowDistance = 16;
|
|
1759
|
+
this._shadowResolution = 1024;
|
|
1696
1760
|
this._type = 'directional';
|
|
1697
1761
|
}
|
|
1698
1762
|
getInitialComponentData() {
|
|
@@ -1706,6 +1770,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
1706
1770
|
range: this._range,
|
|
1707
1771
|
shadowBias: this._shadowBias,
|
|
1708
1772
|
shadowDistance: this._shadowDistance,
|
|
1773
|
+
shadowResolution: this._shadowResolution,
|
|
1709
1774
|
type: this._type
|
|
1710
1775
|
};
|
|
1711
1776
|
}
|
|
@@ -1869,6 +1934,23 @@ class LightComponentElement extends ComponentElement {
|
|
|
1869
1934
|
get shadowDistance() {
|
|
1870
1935
|
return this._shadowDistance;
|
|
1871
1936
|
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Sets the shadow resolution of the light.
|
|
1939
|
+
* @param value - The shadow resolution.
|
|
1940
|
+
*/
|
|
1941
|
+
set shadowResolution(value) {
|
|
1942
|
+
this._shadowResolution = value;
|
|
1943
|
+
if (this.component) {
|
|
1944
|
+
this.component.shadowResolution = value;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Gets the shadow resolution of the light.
|
|
1949
|
+
* @returns The shadow resolution.
|
|
1950
|
+
*/
|
|
1951
|
+
get shadowResolution() {
|
|
1952
|
+
return this._shadowResolution;
|
|
1953
|
+
}
|
|
1872
1954
|
/**
|
|
1873
1955
|
* Sets the type of the light.
|
|
1874
1956
|
* @param value - The type.
|
|
@@ -1902,6 +1984,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
1902
1984
|
'range',
|
|
1903
1985
|
'shadow-bias',
|
|
1904
1986
|
'shadow-distance',
|
|
1987
|
+
'shadow-resolution',
|
|
1905
1988
|
'type'
|
|
1906
1989
|
];
|
|
1907
1990
|
}
|
|
@@ -1935,6 +2018,9 @@ class LightComponentElement extends ComponentElement {
|
|
|
1935
2018
|
case 'shadow-distance':
|
|
1936
2019
|
this.shadowDistance = Number(newValue);
|
|
1937
2020
|
break;
|
|
2021
|
+
case 'shadow-resolution':
|
|
2022
|
+
this.shadowResolution = Number(newValue);
|
|
2023
|
+
break;
|
|
1938
2024
|
case 'type':
|
|
1939
2025
|
this.type = newValue;
|
|
1940
2026
|
break;
|
|
@@ -1944,7 +2030,9 @@ class LightComponentElement extends ComponentElement {
|
|
|
1944
2030
|
customElements.define('pc-light', LightComponentElement);
|
|
1945
2031
|
|
|
1946
2032
|
/**
|
|
1947
|
-
*
|
|
2033
|
+
* The MaterialElement interface provides properties and methods for manipulating
|
|
2034
|
+
* `<pc-material>` elements. The MaterialElement interface also inherits the properties and
|
|
2035
|
+
* methods of the {@link HTMLElement} interface.
|
|
1948
2036
|
*/
|
|
1949
2037
|
class MaterialElement extends HTMLElement {
|
|
1950
2038
|
constructor() {
|
|
@@ -2058,11 +2146,14 @@ class MaterialElement extends HTMLElement {
|
|
|
2058
2146
|
customElements.define('pc-material', MaterialElement);
|
|
2059
2147
|
|
|
2060
2148
|
/**
|
|
2061
|
-
*
|
|
2149
|
+
* The RenderComponentElement interface provides properties and methods for manipulating
|
|
2150
|
+
* `<pc-render>` elements. The RenderComponentElement interface also inherits the properties and
|
|
2151
|
+
* methods of the {@link HTMLElement} interface.
|
|
2062
2152
|
*
|
|
2063
2153
|
* @category Components
|
|
2064
2154
|
*/
|
|
2065
2155
|
class RenderComponentElement extends ComponentElement {
|
|
2156
|
+
/** @ignore */
|
|
2066
2157
|
constructor() {
|
|
2067
2158
|
super('render');
|
|
2068
2159
|
this._castShadows = true;
|
|
@@ -2177,14 +2268,14 @@ class RenderComponentElement extends ComponentElement {
|
|
|
2177
2268
|
customElements.define('pc-render', RenderComponentElement);
|
|
2178
2269
|
|
|
2179
2270
|
/**
|
|
2180
|
-
*
|
|
2271
|
+
* The RigidBodyComponentElement interface provides properties and methods for manipulating
|
|
2272
|
+
* `<pc-rigidbody>` elements. The RigidBodyComponentElement interface also inherits the properties
|
|
2273
|
+
* and methods of the {@link HTMLElement} interface.
|
|
2181
2274
|
*
|
|
2182
2275
|
* @category Components
|
|
2183
2276
|
*/
|
|
2184
2277
|
class RigidBodyComponentElement extends ComponentElement {
|
|
2185
|
-
/**
|
|
2186
|
-
* Creates a new RigidBodyComponentElement.
|
|
2187
|
-
*/
|
|
2278
|
+
/** @ignore */
|
|
2188
2279
|
constructor() {
|
|
2189
2280
|
super('rigidbody');
|
|
2190
2281
|
/**
|
|
@@ -2364,11 +2455,14 @@ class RigidBodyComponentElement extends ComponentElement {
|
|
|
2364
2455
|
customElements.define('pc-rigidbody', RigidBodyComponentElement);
|
|
2365
2456
|
|
|
2366
2457
|
/**
|
|
2367
|
-
*
|
|
2458
|
+
* The ScreenComponentElement interface provides properties and methods for manipulating
|
|
2459
|
+
* `<pc-screen>` elements. The ScreenComponentElement interface also inherits the properties and
|
|
2460
|
+
* methods of the {@link HTMLElement} interface.
|
|
2368
2461
|
*
|
|
2369
2462
|
* @category Components
|
|
2370
2463
|
*/
|
|
2371
2464
|
class ScreenComponentElement extends ComponentElement {
|
|
2465
|
+
/** @ignore */
|
|
2372
2466
|
constructor() {
|
|
2373
2467
|
super('screen');
|
|
2374
2468
|
this._screenSpace = false;
|
|
@@ -2490,11 +2584,14 @@ const tmpV2 = new playcanvas.Vec2();
|
|
|
2490
2584
|
const tmpV3 = new playcanvas.Vec3();
|
|
2491
2585
|
const tmpV4 = new playcanvas.Vec4();
|
|
2492
2586
|
/**
|
|
2493
|
-
*
|
|
2587
|
+
* The ScriptComponentElement interface provides properties and methods for manipulating
|
|
2588
|
+
* `<pc-scripts>` elements. The ScriptComponentElement interface also inherits the properties and
|
|
2589
|
+
* methods of the {@link HTMLElement} interface.
|
|
2494
2590
|
*
|
|
2495
2591
|
* @category Components
|
|
2496
2592
|
*/
|
|
2497
2593
|
class ScriptComponentElement extends ComponentElement {
|
|
2594
|
+
/** @ignore */
|
|
2498
2595
|
constructor() {
|
|
2499
2596
|
super('script');
|
|
2500
2597
|
// Create mutation observer to watch for child script elements
|
|
@@ -2520,6 +2617,15 @@ class ScriptComponentElement extends ComponentElement {
|
|
|
2520
2617
|
try {
|
|
2521
2618
|
const attributesObject = attributes ? JSON.parse(attributes) : {};
|
|
2522
2619
|
const applyValue = (target, key, value) => {
|
|
2620
|
+
// Handle asset references
|
|
2621
|
+
if (typeof value === 'string' && value.startsWith('asset:')) {
|
|
2622
|
+
const assetId = value.slice(6);
|
|
2623
|
+
const assetElement = document.querySelector(`pc-asset#${assetId}`);
|
|
2624
|
+
if (assetElement) {
|
|
2625
|
+
target[key] = assetElement.asset;
|
|
2626
|
+
return;
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2523
2629
|
// Handle vectors
|
|
2524
2630
|
if (Array.isArray(value)) {
|
|
2525
2631
|
if (target[key] instanceof playcanvas.Vec2) {
|
|
@@ -2628,7 +2734,9 @@ class ScriptComponentElement extends ComponentElement {
|
|
|
2628
2734
|
customElements.define('pc-scripts', ScriptComponentElement);
|
|
2629
2735
|
|
|
2630
2736
|
/**
|
|
2631
|
-
*
|
|
2737
|
+
* The ScriptElement interface provides properties and methods for manipulating
|
|
2738
|
+
* `<pc-script>` elements. The ScriptElement interface also inherits the properties and
|
|
2739
|
+
* methods of the {@link HTMLElement} interface.
|
|
2632
2740
|
*/
|
|
2633
2741
|
class ScriptElement extends HTMLElement {
|
|
2634
2742
|
constructor() {
|
|
@@ -2707,11 +2815,14 @@ class ScriptElement extends HTMLElement {
|
|
|
2707
2815
|
customElements.define('pc-script', ScriptElement);
|
|
2708
2816
|
|
|
2709
2817
|
/**
|
|
2710
|
-
*
|
|
2818
|
+
* The SoundComponentElement interface provides properties and methods for manipulating
|
|
2819
|
+
* `<pc-sounds>` elements. The SoundComponentElement interface also inherits the properties and
|
|
2820
|
+
* methods of the {@link HTMLElement} interface.
|
|
2711
2821
|
*
|
|
2712
2822
|
* @category Components
|
|
2713
2823
|
*/
|
|
2714
2824
|
class SoundComponentElement extends ComponentElement {
|
|
2825
|
+
/** @ignore */
|
|
2715
2826
|
constructor() {
|
|
2716
2827
|
super('sound');
|
|
2717
2828
|
this._distanceModel = 'linear';
|
|
@@ -2901,7 +3012,9 @@ class SoundComponentElement extends ComponentElement {
|
|
|
2901
3012
|
customElements.define('pc-sounds', SoundComponentElement);
|
|
2902
3013
|
|
|
2903
3014
|
/**
|
|
2904
|
-
*
|
|
3015
|
+
* The SoundSlotElement interface provides properties and methods for manipulating
|
|
3016
|
+
* `<pc-sound>` elements. The SoundSlotElement interface also inherits the properties and
|
|
3017
|
+
* methods of the {@link AsyncElement} interface.
|
|
2905
3018
|
*/
|
|
2906
3019
|
class SoundSlotElement extends AsyncElement {
|
|
2907
3020
|
constructor() {
|
|
@@ -3142,7 +3255,9 @@ class SoundSlotElement extends AsyncElement {
|
|
|
3142
3255
|
customElements.define('pc-sound', SoundSlotElement);
|
|
3143
3256
|
|
|
3144
3257
|
/**
|
|
3145
|
-
*
|
|
3258
|
+
* The ModelElement interface provides properties and methods for manipulating
|
|
3259
|
+
* `<pc-model>` elements. The ModelElement interface also inherits the properties and
|
|
3260
|
+
* methods of the {@link HTMLElement} interface.
|
|
3146
3261
|
*/
|
|
3147
3262
|
class ModelElement extends AsyncElement {
|
|
3148
3263
|
constructor() {
|
|
@@ -3235,7 +3350,9 @@ class ModelElement extends AsyncElement {
|
|
|
3235
3350
|
customElements.define('pc-model', ModelElement);
|
|
3236
3351
|
|
|
3237
3352
|
/**
|
|
3238
|
-
*
|
|
3353
|
+
* The SceneElement interface provides properties and methods for manipulating
|
|
3354
|
+
* `<pc-scene>` elements. The SceneElement interface also inherits the properties and
|
|
3355
|
+
* methods of the {@link HTMLElement} interface.
|
|
3239
3356
|
*/
|
|
3240
3357
|
class SceneElement extends AsyncElement {
|
|
3241
3358
|
constructor() {
|
|
@@ -3274,11 +3391,11 @@ class SceneElement extends AsyncElement {
|
|
|
3274
3391
|
}
|
|
3275
3392
|
updateSceneSettings() {
|
|
3276
3393
|
if (this.scene) {
|
|
3277
|
-
this.scene.
|
|
3278
|
-
this.scene.
|
|
3279
|
-
this.scene.
|
|
3280
|
-
this.scene.
|
|
3281
|
-
this.scene.
|
|
3394
|
+
this.scene.fog.type = this._fog;
|
|
3395
|
+
this.scene.fog.color = this._fogColor;
|
|
3396
|
+
this.scene.fog.density = this._fogDensity;
|
|
3397
|
+
this.scene.fog.start = this._fogStart;
|
|
3398
|
+
this.scene.fog.end = this._fogEnd;
|
|
3282
3399
|
// ... set other properties on the scene as well
|
|
3283
3400
|
}
|
|
3284
3401
|
}
|
|
@@ -3289,7 +3406,7 @@ class SceneElement extends AsyncElement {
|
|
|
3289
3406
|
set fog(value) {
|
|
3290
3407
|
this._fog = value;
|
|
3291
3408
|
if (this.scene) {
|
|
3292
|
-
this.scene.
|
|
3409
|
+
this.scene.fog.type = value;
|
|
3293
3410
|
}
|
|
3294
3411
|
}
|
|
3295
3412
|
/**
|
|
@@ -3306,7 +3423,7 @@ class SceneElement extends AsyncElement {
|
|
|
3306
3423
|
set fogColor(value) {
|
|
3307
3424
|
this._fogColor = value;
|
|
3308
3425
|
if (this.scene) {
|
|
3309
|
-
this.scene.
|
|
3426
|
+
this.scene.fog.color = value;
|
|
3310
3427
|
}
|
|
3311
3428
|
}
|
|
3312
3429
|
/**
|
|
@@ -3323,7 +3440,7 @@ class SceneElement extends AsyncElement {
|
|
|
3323
3440
|
set fogDensity(value) {
|
|
3324
3441
|
this._fogDensity = value;
|
|
3325
3442
|
if (this.scene) {
|
|
3326
|
-
this.scene.
|
|
3443
|
+
this.scene.fog.density = value;
|
|
3327
3444
|
}
|
|
3328
3445
|
}
|
|
3329
3446
|
/**
|
|
@@ -3340,7 +3457,7 @@ class SceneElement extends AsyncElement {
|
|
|
3340
3457
|
set fogStart(value) {
|
|
3341
3458
|
this._fogStart = value;
|
|
3342
3459
|
if (this.scene) {
|
|
3343
|
-
this.scene.
|
|
3460
|
+
this.scene.fog.start = value;
|
|
3344
3461
|
}
|
|
3345
3462
|
}
|
|
3346
3463
|
/**
|
|
@@ -3357,7 +3474,7 @@ class SceneElement extends AsyncElement {
|
|
|
3357
3474
|
set fogEnd(value) {
|
|
3358
3475
|
this._fogEnd = value;
|
|
3359
3476
|
if (this.scene) {
|
|
3360
|
-
this.scene.
|
|
3477
|
+
this.scene.fog.end = value;
|
|
3361
3478
|
}
|
|
3362
3479
|
}
|
|
3363
3480
|
/**
|
|
@@ -3394,7 +3511,9 @@ class SceneElement extends AsyncElement {
|
|
|
3394
3511
|
customElements.define('pc-scene', SceneElement);
|
|
3395
3512
|
|
|
3396
3513
|
/**
|
|
3397
|
-
*
|
|
3514
|
+
* The SkyElement interface provides properties and methods for manipulating
|
|
3515
|
+
* `<pc-sky>` elements. The SkyElement interface also inherits the properties and
|
|
3516
|
+
* methods of the {@link HTMLElement} interface.
|
|
3398
3517
|
*/
|
|
3399
3518
|
class SkyElement extends AsyncElement {
|
|
3400
3519
|
constructor() {
|
|
@@ -3420,8 +3539,8 @@ class SkyElement extends AsyncElement {
|
|
|
3420
3539
|
if (!this._scene)
|
|
3421
3540
|
return;
|
|
3422
3541
|
const source = asset.resource;
|
|
3423
|
-
source.anisotropy = 4;
|
|
3424
3542
|
const skybox = playcanvas.EnvLighting.generateSkyboxCubemap(source);
|
|
3543
|
+
skybox.anisotropy = 4;
|
|
3425
3544
|
this._scene.skybox = skybox;
|
|
3426
3545
|
if (this._lighting) {
|
|
3427
3546
|
const lighting = playcanvas.EnvLighting.generateLightingSource(source);
|
|
@@ -3435,6 +3554,7 @@ class SkyElement extends AsyncElement {
|
|
|
3435
3554
|
this._scene.sky.type = this._type;
|
|
3436
3555
|
this._scene.sky.node.setLocalScale(this._scale);
|
|
3437
3556
|
this._scene.sky.center = this._center;
|
|
3557
|
+
this._scene.skyboxIntensity = this._intensity;
|
|
3438
3558
|
}
|
|
3439
3559
|
async _loadSkybox() {
|
|
3440
3560
|
var _a;
|