@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.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { basisInitialize, WasmModule, Application,
|
|
1
|
+
import { basisInitialize, WasmModule, Application, Keyboard, Mouse, FILLMODE_FILL_WINDOW, RESOLUTION_AUTO, Color, Quat, Vec2, Vec3, Vec4, Entity, Asset, XRTYPE_VR, PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE, StandardMaterial, SCALEMODE_BLEND, SCALEMODE_NONE, EnvLighting, LAYERID_SKYBOX } from 'playcanvas';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Base class for all PlayCanvas
|
|
4
|
+
* Base class for all PlayCanvas Web Components that initialize asynchronously.
|
|
5
5
|
*/
|
|
6
6
|
class AsyncElement extends HTMLElement {
|
|
7
|
+
/** @ignore */
|
|
7
8
|
constructor() {
|
|
8
9
|
super();
|
|
9
10
|
this._readyPromise = new Promise((resolve) => {
|
|
@@ -35,7 +36,13 @@ class AsyncElement extends HTMLElement {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
/**
|
|
40
|
+
* The ModuleElement interface provides properties and methods for manipulating
|
|
41
|
+
* `<pc-module>` elements. The ModuleElement interface also inherits the properties and
|
|
42
|
+
* methods of the {@link HTMLElement} interface.
|
|
43
|
+
*/
|
|
38
44
|
class ModuleElement extends HTMLElement {
|
|
45
|
+
/** @ignore */
|
|
39
46
|
constructor() {
|
|
40
47
|
super();
|
|
41
48
|
this.loadPromise = this.loadModule();
|
|
@@ -74,7 +81,9 @@ customElements.define('pc-module', ModuleElement);
|
|
|
74
81
|
*/
|
|
75
82
|
class AppElement extends AsyncElement {
|
|
76
83
|
/**
|
|
77
|
-
* Creates a new AppElement.
|
|
84
|
+
* Creates a new AppElement instance.
|
|
85
|
+
*
|
|
86
|
+
* @ignore
|
|
78
87
|
*/
|
|
79
88
|
constructor() {
|
|
80
89
|
super();
|
|
@@ -87,6 +96,7 @@ class AppElement extends AsyncElement {
|
|
|
87
96
|
this._depth = true;
|
|
88
97
|
this._stencil = true;
|
|
89
98
|
this._highResolution = false;
|
|
99
|
+
this._hierarchyReady = false;
|
|
90
100
|
/**
|
|
91
101
|
* The PlayCanvas application instance.
|
|
92
102
|
*/
|
|
@@ -130,6 +140,16 @@ class AppElement extends AsyncElement {
|
|
|
130
140
|
Array.from(materialElements).forEach((materialElement) => {
|
|
131
141
|
materialElement.createMaterial();
|
|
132
142
|
});
|
|
143
|
+
// Create all entities
|
|
144
|
+
const entityElements = this.querySelectorAll('pc-entity');
|
|
145
|
+
Array.from(entityElements).forEach((entityElement) => {
|
|
146
|
+
entityElement.createEntity(this.app);
|
|
147
|
+
});
|
|
148
|
+
// Build hierarchy
|
|
149
|
+
entityElements.forEach((entityElement) => {
|
|
150
|
+
entityElement.buildHierarchy(this.app);
|
|
151
|
+
});
|
|
152
|
+
this._hierarchyReady = true;
|
|
133
153
|
// Load assets before starting the application
|
|
134
154
|
this.app.preload(() => {
|
|
135
155
|
// Start the application
|
|
@@ -200,6 +220,14 @@ class AppElement extends AsyncElement {
|
|
|
200
220
|
get depth() {
|
|
201
221
|
return this._depth;
|
|
202
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Gets the hierarchy ready flag.
|
|
225
|
+
* @returns The hierarchy ready flag.
|
|
226
|
+
* @ignore
|
|
227
|
+
*/
|
|
228
|
+
get hierarchyReady() {
|
|
229
|
+
return this._hierarchyReady;
|
|
230
|
+
}
|
|
203
231
|
/**
|
|
204
232
|
* Sets the high resolution flag. When true, the application will render at the device's
|
|
205
233
|
* physical resolution. When false, the application will render at CSS resolution.
|
|
@@ -471,7 +499,9 @@ const parseVec4 = (value) => {
|
|
|
471
499
|
};
|
|
472
500
|
|
|
473
501
|
/**
|
|
474
|
-
*
|
|
502
|
+
* The EntityElement interface provides properties and methods for manipulating
|
|
503
|
+
* `<pc-entity>` elements. The EntityElement interface also inherits the properties and
|
|
504
|
+
* methods of the {@link HTMLElement} interface.
|
|
475
505
|
*/
|
|
476
506
|
class EntityElement extends AsyncElement {
|
|
477
507
|
constructor() {
|
|
@@ -505,41 +535,60 @@ class EntityElement extends AsyncElement {
|
|
|
505
535
|
*/
|
|
506
536
|
this.entity = null;
|
|
507
537
|
}
|
|
508
|
-
|
|
509
|
-
const closestApp = this.closestApp;
|
|
510
|
-
if (!closestApp)
|
|
511
|
-
return;
|
|
512
|
-
// Wait for the app to complete initialization
|
|
513
|
-
await closestApp.ready();
|
|
514
|
-
const app = closestApp.app;
|
|
538
|
+
createEntity(app) {
|
|
515
539
|
// Create a new entity
|
|
516
|
-
this.entity = new Entity(this._name, app);
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
540
|
+
this.entity = new Entity(this.getAttribute('name') || this._name, app);
|
|
541
|
+
const enabled = this.getAttribute('enabled');
|
|
542
|
+
if (enabled) {
|
|
543
|
+
this.entity.enabled = enabled !== 'false';
|
|
544
|
+
}
|
|
545
|
+
const position = this.getAttribute('position');
|
|
546
|
+
if (position) {
|
|
547
|
+
this.entity.setLocalPosition(parseVec3(position));
|
|
548
|
+
}
|
|
549
|
+
const rotation = this.getAttribute('rotation');
|
|
550
|
+
if (rotation) {
|
|
551
|
+
this.entity.setLocalEulerAngles(parseVec3(rotation));
|
|
552
|
+
}
|
|
553
|
+
const scale = this.getAttribute('scale');
|
|
554
|
+
if (scale) {
|
|
555
|
+
this.entity.setLocalScale(parseVec3(scale));
|
|
556
|
+
}
|
|
557
|
+
const tags = this.getAttribute('tags');
|
|
558
|
+
if (tags) {
|
|
559
|
+
this.entity.tags.add(tags.split(',').map(tag => tag.trim()));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
buildHierarchy(app) {
|
|
563
|
+
if (!this.entity)
|
|
564
|
+
return;
|
|
533
565
|
const closestEntity = this.closestEntity;
|
|
534
|
-
if (closestEntity) {
|
|
535
|
-
closestEntity.
|
|
536
|
-
closestEntity.entity.addChild(this.entity);
|
|
537
|
-
this._onReady();
|
|
538
|
-
});
|
|
566
|
+
if (closestEntity === null || closestEntity === void 0 ? void 0 : closestEntity.entity) {
|
|
567
|
+
closestEntity.entity.addChild(this.entity);
|
|
539
568
|
}
|
|
540
569
|
else {
|
|
541
570
|
app.root.addChild(this.entity);
|
|
542
|
-
|
|
571
|
+
}
|
|
572
|
+
this._onReady();
|
|
573
|
+
}
|
|
574
|
+
connectedCallback() {
|
|
575
|
+
// Wait for app to be ready
|
|
576
|
+
const closestApp = this.closestApp;
|
|
577
|
+
if (!closestApp)
|
|
578
|
+
return;
|
|
579
|
+
// If app is already running, create entity immediately
|
|
580
|
+
if (closestApp.hierarchyReady) {
|
|
581
|
+
const app = closestApp.app;
|
|
582
|
+
this.createEntity(app);
|
|
583
|
+
this.buildHierarchy(app);
|
|
584
|
+
// Handle any child entities that might exist
|
|
585
|
+
const childEntities = this.querySelectorAll('pc-entity');
|
|
586
|
+
childEntities.forEach((child) => {
|
|
587
|
+
child.createEntity(app);
|
|
588
|
+
});
|
|
589
|
+
childEntities.forEach((child) => {
|
|
590
|
+
child.buildHierarchy(app);
|
|
591
|
+
});
|
|
543
592
|
}
|
|
544
593
|
}
|
|
545
594
|
disconnectedCallback() {
|
|
@@ -549,6 +598,7 @@ class EntityElement extends AsyncElement {
|
|
|
549
598
|
children.forEach((child) => {
|
|
550
599
|
child.entity = null;
|
|
551
600
|
});
|
|
601
|
+
// Destroy the entity
|
|
552
602
|
this.entity.destroy();
|
|
553
603
|
this.entity = null;
|
|
554
604
|
}
|
|
@@ -704,7 +754,9 @@ const extToType = new Map([
|
|
|
704
754
|
['webp', 'texture']
|
|
705
755
|
]);
|
|
706
756
|
/**
|
|
707
|
-
*
|
|
757
|
+
* The AssetElement interface provides properties and methods for manipulating
|
|
758
|
+
* `<pc-asset>` elements. The AssetElement interface also inherits the properties and
|
|
759
|
+
* methods of the {@link HTMLElement} interface.
|
|
708
760
|
*/
|
|
709
761
|
class AssetElement extends HTMLElement {
|
|
710
762
|
constructor() {
|
|
@@ -780,8 +832,10 @@ customElements.define('pc-asset', AssetElement);
|
|
|
780
832
|
*/
|
|
781
833
|
class ComponentElement extends AsyncElement {
|
|
782
834
|
/**
|
|
783
|
-
*
|
|
835
|
+
* Creates a new ComponentElement instance.
|
|
836
|
+
*
|
|
784
837
|
* @param componentName - The name of the component.
|
|
838
|
+
* @ignore
|
|
785
839
|
*/
|
|
786
840
|
constructor(componentName) {
|
|
787
841
|
super();
|
|
@@ -850,11 +904,14 @@ class ComponentElement extends AsyncElement {
|
|
|
850
904
|
}
|
|
851
905
|
|
|
852
906
|
/**
|
|
853
|
-
*
|
|
907
|
+
* The ListenerComponentElement interface provides properties and methods for manipulating
|
|
908
|
+
* `<pc-listener>` elements. The ListenerComponentElement interface also inherits the properties
|
|
909
|
+
* and methods of the {@link HTMLElement} interface.
|
|
854
910
|
*
|
|
855
911
|
* @category Components
|
|
856
912
|
*/
|
|
857
913
|
class ListenerComponentElement extends ComponentElement {
|
|
914
|
+
/** @ignore */
|
|
858
915
|
constructor() {
|
|
859
916
|
super('audiolistener');
|
|
860
917
|
}
|
|
@@ -869,14 +926,14 @@ class ListenerComponentElement extends ComponentElement {
|
|
|
869
926
|
customElements.define('pc-listener', ListenerComponentElement);
|
|
870
927
|
|
|
871
928
|
/**
|
|
872
|
-
*
|
|
929
|
+
* The CameraComponentElement interface provides properties and methods for manipulating
|
|
930
|
+
* `<pc-camera>` elements. The CameraComponentElement interface also inherits the properties and
|
|
931
|
+
* methods of the {@link HTMLElement} interface.
|
|
873
932
|
*
|
|
874
933
|
* @category Components
|
|
875
934
|
*/
|
|
876
935
|
class CameraComponentElement extends ComponentElement {
|
|
877
|
-
/**
|
|
878
|
-
* Creates a new CameraComponentElement.
|
|
879
|
-
*/
|
|
936
|
+
/** @ignore */
|
|
880
937
|
constructor() {
|
|
881
938
|
super('camera');
|
|
882
939
|
this._clearColor = new Color(0.75, 0.75, 0.75, 1);
|
|
@@ -1270,14 +1327,14 @@ class CameraComponentElement extends ComponentElement {
|
|
|
1270
1327
|
customElements.define('pc-camera', CameraComponentElement);
|
|
1271
1328
|
|
|
1272
1329
|
/**
|
|
1273
|
-
*
|
|
1330
|
+
* The CollisionComponentElement interface provides properties and methods for manipulating
|
|
1331
|
+
* `<pc-collision>` elements. The CollisionComponentElement interface also inherits the properties
|
|
1332
|
+
* and methods of the {@link HTMLElement} interface.
|
|
1274
1333
|
*
|
|
1275
1334
|
* @category Components
|
|
1276
1335
|
*/
|
|
1277
1336
|
class CollisionComponentElement extends ComponentElement {
|
|
1278
|
-
/**
|
|
1279
|
-
* Creates a new CollisionComponentElement.
|
|
1280
|
-
*/
|
|
1337
|
+
/** @ignore */
|
|
1281
1338
|
constructor() {
|
|
1282
1339
|
super('collision');
|
|
1283
1340
|
this._angularOffset = new Quat();
|
|
@@ -1416,11 +1473,14 @@ class CollisionComponentElement extends ComponentElement {
|
|
|
1416
1473
|
customElements.define('pc-collision', CollisionComponentElement);
|
|
1417
1474
|
|
|
1418
1475
|
/**
|
|
1419
|
-
*
|
|
1476
|
+
* The ElementComponentElement interface provides properties and methods for manipulating
|
|
1477
|
+
* `<pc-element>` elements. The ElementComponentElement interface also inherits the properties and
|
|
1478
|
+
* methods of the {@link HTMLElement} interface.
|
|
1420
1479
|
*
|
|
1421
1480
|
* @category Components
|
|
1422
1481
|
*/
|
|
1423
1482
|
class ElementComponentElement extends ComponentElement {
|
|
1483
|
+
/** @ignore */
|
|
1424
1484
|
constructor() {
|
|
1425
1485
|
super('element');
|
|
1426
1486
|
this._anchor = new Vec4(0.5, 0.5, 0.5, 0.5);
|
|
@@ -1626,11 +1686,14 @@ class ElementComponentElement extends ComponentElement {
|
|
|
1626
1686
|
customElements.define('pc-element', ElementComponentElement);
|
|
1627
1687
|
|
|
1628
1688
|
/**
|
|
1629
|
-
*
|
|
1689
|
+
* The GSplatComponentElement interface provides properties and methods for manipulating
|
|
1690
|
+
* `<pc-splat>` elements. The GSplatComponentElement interface also inherits the properties and
|
|
1691
|
+
* methods of the {@link HTMLElement} interface.
|
|
1630
1692
|
*
|
|
1631
1693
|
* @category Components
|
|
1632
1694
|
*/
|
|
1633
1695
|
class GSplatComponentElement extends ComponentElement {
|
|
1696
|
+
/** @ignore */
|
|
1634
1697
|
constructor() {
|
|
1635
1698
|
super('gsplat');
|
|
1636
1699
|
this._asset = '';
|
|
@@ -1672,14 +1735,14 @@ class GSplatComponentElement extends ComponentElement {
|
|
|
1672
1735
|
customElements.define('pc-splat', GSplatComponentElement);
|
|
1673
1736
|
|
|
1674
1737
|
/**
|
|
1675
|
-
*
|
|
1738
|
+
* The LightComponentElement interface provides properties and methods for manipulating
|
|
1739
|
+
* `<pc-light>` elements. The LightComponentElement interface also inherits the properties and
|
|
1740
|
+
* methods of the {@link HTMLElement} interface.
|
|
1676
1741
|
*
|
|
1677
1742
|
* @category Components
|
|
1678
1743
|
*/
|
|
1679
1744
|
class LightComponentElement extends ComponentElement {
|
|
1680
|
-
/**
|
|
1681
|
-
* Creates a new LightComponentElement.
|
|
1682
|
-
*/
|
|
1745
|
+
/** @ignore */
|
|
1683
1746
|
constructor() {
|
|
1684
1747
|
super('light');
|
|
1685
1748
|
this._castShadows = false;
|
|
@@ -1691,6 +1754,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
1691
1754
|
this._range = 10;
|
|
1692
1755
|
this._shadowBias = 0.2;
|
|
1693
1756
|
this._shadowDistance = 16;
|
|
1757
|
+
this._shadowResolution = 1024;
|
|
1694
1758
|
this._type = 'directional';
|
|
1695
1759
|
}
|
|
1696
1760
|
getInitialComponentData() {
|
|
@@ -1704,6 +1768,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
1704
1768
|
range: this._range,
|
|
1705
1769
|
shadowBias: this._shadowBias,
|
|
1706
1770
|
shadowDistance: this._shadowDistance,
|
|
1771
|
+
shadowResolution: this._shadowResolution,
|
|
1707
1772
|
type: this._type
|
|
1708
1773
|
};
|
|
1709
1774
|
}
|
|
@@ -1867,6 +1932,23 @@ class LightComponentElement extends ComponentElement {
|
|
|
1867
1932
|
get shadowDistance() {
|
|
1868
1933
|
return this._shadowDistance;
|
|
1869
1934
|
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Sets the shadow resolution of the light.
|
|
1937
|
+
* @param value - The shadow resolution.
|
|
1938
|
+
*/
|
|
1939
|
+
set shadowResolution(value) {
|
|
1940
|
+
this._shadowResolution = value;
|
|
1941
|
+
if (this.component) {
|
|
1942
|
+
this.component.shadowResolution = value;
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
/**
|
|
1946
|
+
* Gets the shadow resolution of the light.
|
|
1947
|
+
* @returns The shadow resolution.
|
|
1948
|
+
*/
|
|
1949
|
+
get shadowResolution() {
|
|
1950
|
+
return this._shadowResolution;
|
|
1951
|
+
}
|
|
1870
1952
|
/**
|
|
1871
1953
|
* Sets the type of the light.
|
|
1872
1954
|
* @param value - The type.
|
|
@@ -1900,6 +1982,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
1900
1982
|
'range',
|
|
1901
1983
|
'shadow-bias',
|
|
1902
1984
|
'shadow-distance',
|
|
1985
|
+
'shadow-resolution',
|
|
1903
1986
|
'type'
|
|
1904
1987
|
];
|
|
1905
1988
|
}
|
|
@@ -1933,6 +2016,9 @@ class LightComponentElement extends ComponentElement {
|
|
|
1933
2016
|
case 'shadow-distance':
|
|
1934
2017
|
this.shadowDistance = Number(newValue);
|
|
1935
2018
|
break;
|
|
2019
|
+
case 'shadow-resolution':
|
|
2020
|
+
this.shadowResolution = Number(newValue);
|
|
2021
|
+
break;
|
|
1936
2022
|
case 'type':
|
|
1937
2023
|
this.type = newValue;
|
|
1938
2024
|
break;
|
|
@@ -1942,7 +2028,9 @@ class LightComponentElement extends ComponentElement {
|
|
|
1942
2028
|
customElements.define('pc-light', LightComponentElement);
|
|
1943
2029
|
|
|
1944
2030
|
/**
|
|
1945
|
-
*
|
|
2031
|
+
* The MaterialElement interface provides properties and methods for manipulating
|
|
2032
|
+
* `<pc-material>` elements. The MaterialElement interface also inherits the properties and
|
|
2033
|
+
* methods of the {@link HTMLElement} interface.
|
|
1946
2034
|
*/
|
|
1947
2035
|
class MaterialElement extends HTMLElement {
|
|
1948
2036
|
constructor() {
|
|
@@ -2056,11 +2144,14 @@ class MaterialElement extends HTMLElement {
|
|
|
2056
2144
|
customElements.define('pc-material', MaterialElement);
|
|
2057
2145
|
|
|
2058
2146
|
/**
|
|
2059
|
-
*
|
|
2147
|
+
* The RenderComponentElement interface provides properties and methods for manipulating
|
|
2148
|
+
* `<pc-render>` elements. The RenderComponentElement interface also inherits the properties and
|
|
2149
|
+
* methods of the {@link HTMLElement} interface.
|
|
2060
2150
|
*
|
|
2061
2151
|
* @category Components
|
|
2062
2152
|
*/
|
|
2063
2153
|
class RenderComponentElement extends ComponentElement {
|
|
2154
|
+
/** @ignore */
|
|
2064
2155
|
constructor() {
|
|
2065
2156
|
super('render');
|
|
2066
2157
|
this._castShadows = true;
|
|
@@ -2175,14 +2266,14 @@ class RenderComponentElement extends ComponentElement {
|
|
|
2175
2266
|
customElements.define('pc-render', RenderComponentElement);
|
|
2176
2267
|
|
|
2177
2268
|
/**
|
|
2178
|
-
*
|
|
2269
|
+
* The RigidBodyComponentElement interface provides properties and methods for manipulating
|
|
2270
|
+
* `<pc-rigidbody>` elements. The RigidBodyComponentElement interface also inherits the properties
|
|
2271
|
+
* and methods of the {@link HTMLElement} interface.
|
|
2179
2272
|
*
|
|
2180
2273
|
* @category Components
|
|
2181
2274
|
*/
|
|
2182
2275
|
class RigidBodyComponentElement extends ComponentElement {
|
|
2183
|
-
/**
|
|
2184
|
-
* Creates a new RigidBodyComponentElement.
|
|
2185
|
-
*/
|
|
2276
|
+
/** @ignore */
|
|
2186
2277
|
constructor() {
|
|
2187
2278
|
super('rigidbody');
|
|
2188
2279
|
/**
|
|
@@ -2362,11 +2453,14 @@ class RigidBodyComponentElement extends ComponentElement {
|
|
|
2362
2453
|
customElements.define('pc-rigidbody', RigidBodyComponentElement);
|
|
2363
2454
|
|
|
2364
2455
|
/**
|
|
2365
|
-
*
|
|
2456
|
+
* The ScreenComponentElement interface provides properties and methods for manipulating
|
|
2457
|
+
* `<pc-screen>` elements. The ScreenComponentElement interface also inherits the properties and
|
|
2458
|
+
* methods of the {@link HTMLElement} interface.
|
|
2366
2459
|
*
|
|
2367
2460
|
* @category Components
|
|
2368
2461
|
*/
|
|
2369
2462
|
class ScreenComponentElement extends ComponentElement {
|
|
2463
|
+
/** @ignore */
|
|
2370
2464
|
constructor() {
|
|
2371
2465
|
super('screen');
|
|
2372
2466
|
this._screenSpace = false;
|
|
@@ -2488,11 +2582,14 @@ const tmpV2 = new Vec2();
|
|
|
2488
2582
|
const tmpV3 = new Vec3();
|
|
2489
2583
|
const tmpV4 = new Vec4();
|
|
2490
2584
|
/**
|
|
2491
|
-
*
|
|
2585
|
+
* The ScriptComponentElement interface provides properties and methods for manipulating
|
|
2586
|
+
* `<pc-scripts>` elements. The ScriptComponentElement interface also inherits the properties and
|
|
2587
|
+
* methods of the {@link HTMLElement} interface.
|
|
2492
2588
|
*
|
|
2493
2589
|
* @category Components
|
|
2494
2590
|
*/
|
|
2495
2591
|
class ScriptComponentElement extends ComponentElement {
|
|
2592
|
+
/** @ignore */
|
|
2496
2593
|
constructor() {
|
|
2497
2594
|
super('script');
|
|
2498
2595
|
// Create mutation observer to watch for child script elements
|
|
@@ -2518,6 +2615,15 @@ class ScriptComponentElement extends ComponentElement {
|
|
|
2518
2615
|
try {
|
|
2519
2616
|
const attributesObject = attributes ? JSON.parse(attributes) : {};
|
|
2520
2617
|
const applyValue = (target, key, value) => {
|
|
2618
|
+
// Handle asset references
|
|
2619
|
+
if (typeof value === 'string' && value.startsWith('asset:')) {
|
|
2620
|
+
const assetId = value.slice(6);
|
|
2621
|
+
const assetElement = document.querySelector(`pc-asset#${assetId}`);
|
|
2622
|
+
if (assetElement) {
|
|
2623
|
+
target[key] = assetElement.asset;
|
|
2624
|
+
return;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2521
2627
|
// Handle vectors
|
|
2522
2628
|
if (Array.isArray(value)) {
|
|
2523
2629
|
if (target[key] instanceof Vec2) {
|
|
@@ -2626,7 +2732,9 @@ class ScriptComponentElement extends ComponentElement {
|
|
|
2626
2732
|
customElements.define('pc-scripts', ScriptComponentElement);
|
|
2627
2733
|
|
|
2628
2734
|
/**
|
|
2629
|
-
*
|
|
2735
|
+
* The ScriptElement interface provides properties and methods for manipulating
|
|
2736
|
+
* `<pc-script>` elements. The ScriptElement interface also inherits the properties and
|
|
2737
|
+
* methods of the {@link HTMLElement} interface.
|
|
2630
2738
|
*/
|
|
2631
2739
|
class ScriptElement extends HTMLElement {
|
|
2632
2740
|
constructor() {
|
|
@@ -2705,11 +2813,14 @@ class ScriptElement extends HTMLElement {
|
|
|
2705
2813
|
customElements.define('pc-script', ScriptElement);
|
|
2706
2814
|
|
|
2707
2815
|
/**
|
|
2708
|
-
*
|
|
2816
|
+
* The SoundComponentElement interface provides properties and methods for manipulating
|
|
2817
|
+
* `<pc-sounds>` elements. The SoundComponentElement interface also inherits the properties and
|
|
2818
|
+
* methods of the {@link HTMLElement} interface.
|
|
2709
2819
|
*
|
|
2710
2820
|
* @category Components
|
|
2711
2821
|
*/
|
|
2712
2822
|
class SoundComponentElement extends ComponentElement {
|
|
2823
|
+
/** @ignore */
|
|
2713
2824
|
constructor() {
|
|
2714
2825
|
super('sound');
|
|
2715
2826
|
this._distanceModel = 'linear';
|
|
@@ -2899,7 +3010,9 @@ class SoundComponentElement extends ComponentElement {
|
|
|
2899
3010
|
customElements.define('pc-sounds', SoundComponentElement);
|
|
2900
3011
|
|
|
2901
3012
|
/**
|
|
2902
|
-
*
|
|
3013
|
+
* The SoundSlotElement interface provides properties and methods for manipulating
|
|
3014
|
+
* `<pc-sound>` elements. The SoundSlotElement interface also inherits the properties and
|
|
3015
|
+
* methods of the {@link AsyncElement} interface.
|
|
2903
3016
|
*/
|
|
2904
3017
|
class SoundSlotElement extends AsyncElement {
|
|
2905
3018
|
constructor() {
|
|
@@ -3140,7 +3253,9 @@ class SoundSlotElement extends AsyncElement {
|
|
|
3140
3253
|
customElements.define('pc-sound', SoundSlotElement);
|
|
3141
3254
|
|
|
3142
3255
|
/**
|
|
3143
|
-
*
|
|
3256
|
+
* The ModelElement interface provides properties and methods for manipulating
|
|
3257
|
+
* `<pc-model>` elements. The ModelElement interface also inherits the properties and
|
|
3258
|
+
* methods of the {@link HTMLElement} interface.
|
|
3144
3259
|
*/
|
|
3145
3260
|
class ModelElement extends AsyncElement {
|
|
3146
3261
|
constructor() {
|
|
@@ -3233,7 +3348,9 @@ class ModelElement extends AsyncElement {
|
|
|
3233
3348
|
customElements.define('pc-model', ModelElement);
|
|
3234
3349
|
|
|
3235
3350
|
/**
|
|
3236
|
-
*
|
|
3351
|
+
* The SceneElement interface provides properties and methods for manipulating
|
|
3352
|
+
* `<pc-scene>` elements. The SceneElement interface also inherits the properties and
|
|
3353
|
+
* methods of the {@link HTMLElement} interface.
|
|
3237
3354
|
*/
|
|
3238
3355
|
class SceneElement extends AsyncElement {
|
|
3239
3356
|
constructor() {
|
|
@@ -3272,11 +3389,11 @@ class SceneElement extends AsyncElement {
|
|
|
3272
3389
|
}
|
|
3273
3390
|
updateSceneSettings() {
|
|
3274
3391
|
if (this.scene) {
|
|
3275
|
-
this.scene.
|
|
3276
|
-
this.scene.
|
|
3277
|
-
this.scene.
|
|
3278
|
-
this.scene.
|
|
3279
|
-
this.scene.
|
|
3392
|
+
this.scene.fog.type = this._fog;
|
|
3393
|
+
this.scene.fog.color = this._fogColor;
|
|
3394
|
+
this.scene.fog.density = this._fogDensity;
|
|
3395
|
+
this.scene.fog.start = this._fogStart;
|
|
3396
|
+
this.scene.fog.end = this._fogEnd;
|
|
3280
3397
|
// ... set other properties on the scene as well
|
|
3281
3398
|
}
|
|
3282
3399
|
}
|
|
@@ -3287,7 +3404,7 @@ class SceneElement extends AsyncElement {
|
|
|
3287
3404
|
set fog(value) {
|
|
3288
3405
|
this._fog = value;
|
|
3289
3406
|
if (this.scene) {
|
|
3290
|
-
this.scene.
|
|
3407
|
+
this.scene.fog.type = value;
|
|
3291
3408
|
}
|
|
3292
3409
|
}
|
|
3293
3410
|
/**
|
|
@@ -3304,7 +3421,7 @@ class SceneElement extends AsyncElement {
|
|
|
3304
3421
|
set fogColor(value) {
|
|
3305
3422
|
this._fogColor = value;
|
|
3306
3423
|
if (this.scene) {
|
|
3307
|
-
this.scene.
|
|
3424
|
+
this.scene.fog.color = value;
|
|
3308
3425
|
}
|
|
3309
3426
|
}
|
|
3310
3427
|
/**
|
|
@@ -3321,7 +3438,7 @@ class SceneElement extends AsyncElement {
|
|
|
3321
3438
|
set fogDensity(value) {
|
|
3322
3439
|
this._fogDensity = value;
|
|
3323
3440
|
if (this.scene) {
|
|
3324
|
-
this.scene.
|
|
3441
|
+
this.scene.fog.density = value;
|
|
3325
3442
|
}
|
|
3326
3443
|
}
|
|
3327
3444
|
/**
|
|
@@ -3338,7 +3455,7 @@ class SceneElement extends AsyncElement {
|
|
|
3338
3455
|
set fogStart(value) {
|
|
3339
3456
|
this._fogStart = value;
|
|
3340
3457
|
if (this.scene) {
|
|
3341
|
-
this.scene.
|
|
3458
|
+
this.scene.fog.start = value;
|
|
3342
3459
|
}
|
|
3343
3460
|
}
|
|
3344
3461
|
/**
|
|
@@ -3355,7 +3472,7 @@ class SceneElement extends AsyncElement {
|
|
|
3355
3472
|
set fogEnd(value) {
|
|
3356
3473
|
this._fogEnd = value;
|
|
3357
3474
|
if (this.scene) {
|
|
3358
|
-
this.scene.
|
|
3475
|
+
this.scene.fog.end = value;
|
|
3359
3476
|
}
|
|
3360
3477
|
}
|
|
3361
3478
|
/**
|
|
@@ -3392,7 +3509,9 @@ class SceneElement extends AsyncElement {
|
|
|
3392
3509
|
customElements.define('pc-scene', SceneElement);
|
|
3393
3510
|
|
|
3394
3511
|
/**
|
|
3395
|
-
*
|
|
3512
|
+
* The SkyElement interface provides properties and methods for manipulating
|
|
3513
|
+
* `<pc-sky>` elements. The SkyElement interface also inherits the properties and
|
|
3514
|
+
* methods of the {@link HTMLElement} interface.
|
|
3396
3515
|
*/
|
|
3397
3516
|
class SkyElement extends AsyncElement {
|
|
3398
3517
|
constructor() {
|
|
@@ -3418,8 +3537,8 @@ class SkyElement extends AsyncElement {
|
|
|
3418
3537
|
if (!this._scene)
|
|
3419
3538
|
return;
|
|
3420
3539
|
const source = asset.resource;
|
|
3421
|
-
source.anisotropy = 4;
|
|
3422
3540
|
const skybox = EnvLighting.generateSkyboxCubemap(source);
|
|
3541
|
+
skybox.anisotropy = 4;
|
|
3423
3542
|
this._scene.skybox = skybox;
|
|
3424
3543
|
if (this._lighting) {
|
|
3425
3544
|
const lighting = EnvLighting.generateLightingSource(source);
|
|
@@ -3433,6 +3552,7 @@ class SkyElement extends AsyncElement {
|
|
|
3433
3552
|
this._scene.sky.type = this._type;
|
|
3434
3553
|
this._scene.sky.node.setLocalScale(this._scale);
|
|
3435
3554
|
this._scene.sky.center = this._center;
|
|
3555
|
+
this._scene.skyboxIntensity = this._intensity;
|
|
3436
3556
|
}
|
|
3437
3557
|
async _loadSkybox() {
|
|
3438
3558
|
var _a;
|