@playcanvas/web-components 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/dist/app.d.ts +31 -49
  3. package/dist/asset.d.ts +152 -12
  4. package/dist/async-element.d.ts +26 -9
  5. package/dist/components/button-component.d.ts +3 -7
  6. package/dist/components/camera-component.d.ts +3 -7
  7. package/dist/components/collision-component.d.ts +19 -7
  8. package/dist/components/component.d.ts +41 -4
  9. package/dist/components/element-component.d.ts +4 -8
  10. package/dist/components/gsplat-component.d.ts +2 -7
  11. package/dist/components/layoutchild-component.d.ts +2 -7
  12. package/dist/components/layoutgroup-component.d.ts +3 -7
  13. package/dist/components/light-component.d.ts +3 -7
  14. package/dist/components/listener-component.d.ts +1 -6
  15. package/dist/components/particlesystem-component.d.ts +2 -7
  16. package/dist/components/render-component.d.ts +2 -7
  17. package/dist/components/rigidbody-component.d.ts +3 -7
  18. package/dist/components/screen-component.d.ts +3 -7
  19. package/dist/components/script-component.d.ts +8 -20
  20. package/dist/components/script.d.ts +2 -22
  21. package/dist/components/scrollbar-component.d.ts +2 -7
  22. package/dist/components/scrollview-component.d.ts +3 -7
  23. package/dist/components/sound-component.d.ts +2 -7
  24. package/dist/components/sound-slot.d.ts +8 -6
  25. package/dist/custom-elements.json +5824 -10581
  26. package/dist/entity-base.d.ts +67 -0
  27. package/dist/entity.d.ts +7 -48
  28. package/dist/index.d.ts +41 -1
  29. package/dist/material.d.ts +14 -13
  30. package/dist/model.d.ts +43 -5
  31. package/dist/module.d.ts +0 -6
  32. package/dist/node.d.ts +253 -0
  33. package/dist/parse.d.ts +2 -1
  34. package/dist/pwc.cjs +1830 -274
  35. package/dist/pwc.cjs.map +1 -1
  36. package/dist/pwc.js +1830 -274
  37. package/dist/pwc.js.map +1 -1
  38. package/dist/pwc.min.js +1 -1
  39. package/dist/pwc.min.js.map +1 -1
  40. package/dist/pwc.min.mjs +1 -1
  41. package/dist/pwc.min.mjs.map +1 -1
  42. package/dist/pwc.mjs +1830 -276
  43. package/dist/pwc.mjs.map +1 -1
  44. package/dist/scene.d.ts +4 -7
  45. package/dist/sky.d.ts +13 -5
  46. package/dist/vscode.html-custom-data.json +148 -26
  47. package/dist/web-types.json +894 -581
  48. package/package.json +9 -8
  49. package/src/app.ts +163 -88
  50. package/src/asset.ts +472 -36
  51. package/src/async-element.ts +39 -12
  52. package/src/components/button-component.ts +5 -9
  53. package/src/components/camera-component.ts +24 -10
  54. package/src/components/collision-component.ts +61 -15
  55. package/src/components/component.ts +151 -11
  56. package/src/components/element-component.ts +26 -30
  57. package/src/components/gsplat-component.ts +4 -9
  58. package/src/components/layoutchild-component.ts +4 -9
  59. package/src/components/layoutgroup-component.ts +14 -9
  60. package/src/components/light-component.ts +42 -12
  61. package/src/components/listener-component.ts +1 -7
  62. package/src/components/particlesystem-component.ts +7 -15
  63. package/src/components/render-component.ts +5 -10
  64. package/src/components/rigidbody-component.ts +23 -16
  65. package/src/components/screen-component.ts +5 -9
  66. package/src/components/script-component.ts +108 -46
  67. package/src/components/script.ts +38 -33
  68. package/src/components/scrollbar-component.ts +6 -16
  69. package/src/components/scrollview-component.ts +16 -11
  70. package/src/components/sound-component.ts +10 -15
  71. package/src/components/sound-slot.ts +30 -20
  72. package/src/entity-base.ts +136 -0
  73. package/src/entity.ts +47 -118
  74. package/src/index.ts +50 -1
  75. package/src/loading-bar.ts +8 -8
  76. package/src/material.ts +65 -39
  77. package/src/model.ts +140 -17
  78. package/src/module.ts +8 -7
  79. package/src/node.ts +715 -0
  80. package/src/parse.ts +62 -17
  81. package/src/scene.ts +12 -9
  82. package/src/sky.ts +50 -10
@@ -1,9 +1,10 @@
1
- import { GSplatComponent } from 'playcanvas';
1
+ import type { GSplatComponent } from 'playcanvas';
2
2
 
3
- import { ComponentElement } from './component';
4
3
  import { AssetElement } from '../asset';
5
4
  import { parseBool, parseNumber } from '../parse';
6
5
 
6
+ import { ComponentElement } from './component';
7
+
7
8
  /**
8
9
  * The GSplatComponentElement interface provides properties and methods for manipulating
9
10
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-gsplat/ | `<pc-gsplat>`} elements.
@@ -30,7 +31,7 @@ class GSplatComponentElement extends ComponentElement {
30
31
  super('gsplat');
31
32
  }
32
33
 
33
- getInitialComponentData() {
34
+ protected getInitialComponentData() {
34
35
  return {
35
36
  asset: AssetElement.get(this._asset),
36
37
  castShadows: this._castShadows,
@@ -216,10 +217,4 @@ class GSplatComponentElement extends ComponentElement {
216
217
 
217
218
  customElements.define('pc-gsplat', GSplatComponentElement);
218
219
 
219
- declare global {
220
- interface HTMLElementTagNameMap {
221
- 'pc-gsplat': GSplatComponentElement;
222
- }
223
- }
224
-
225
220
  export { GSplatComponentElement };
@@ -1,8 +1,9 @@
1
- import { LayoutChildComponent } from 'playcanvas';
1
+ import type { LayoutChildComponent } from 'playcanvas';
2
2
 
3
- import { ComponentElement } from './component';
4
3
  import { parseBool, parseNumber } from '../parse';
5
4
 
5
+ import { ComponentElement } from './component';
6
+
6
7
  /**
7
8
  * The LayoutChildComponentElement interface provides properties and methods for manipulating
8
9
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-layoutchild/ | `<pc-layoutchild>`} elements.
@@ -31,7 +32,7 @@ class LayoutChildComponentElement extends ComponentElement {
31
32
  super('layoutchild');
32
33
  }
33
34
 
34
- getInitialComponentData() {
35
+ protected getInitialComponentData() {
35
36
  return {
36
37
  minWidth: this._minWidth,
37
38
  minHeight: this._minHeight,
@@ -230,10 +231,4 @@ class LayoutChildComponentElement extends ComponentElement {
230
231
 
231
232
  customElements.define('pc-layoutchild', LayoutChildComponentElement);
232
233
 
233
- declare global {
234
- interface HTMLElementTagNameMap {
235
- 'pc-layoutchild': LayoutChildComponentElement;
236
- }
237
- }
238
-
239
234
  export { LayoutChildComponentElement };
@@ -1,8 +1,19 @@
1
- import { FITTING_NONE, FITTING_STRETCH, FITTING_SHRINK, FITTING_BOTH, LayoutGroupComponent, ORIENTATION_HORIZONTAL, ORIENTATION_VERTICAL, Vec2, Vec4 } from 'playcanvas';
1
+ import type { LayoutGroupComponent } from 'playcanvas';
2
+ import {
3
+ FITTING_NONE,
4
+ FITTING_STRETCH,
5
+ FITTING_SHRINK,
6
+ FITTING_BOTH,
7
+ ORIENTATION_HORIZONTAL,
8
+ ORIENTATION_VERTICAL,
9
+ Vec2,
10
+ Vec4
11
+ } from 'playcanvas';
2
12
 
3
- import { ComponentElement } from './component';
4
13
  import { parseBool, parseEnum, parseVec2, parseVec4 } from '../parse';
5
14
 
15
+ import { ComponentElement } from './component';
16
+
6
17
  const orientations = new Map<'horizontal' | 'vertical', number>([
7
18
  ['horizontal', ORIENTATION_HORIZONTAL],
8
19
  ['vertical', ORIENTATION_VERTICAL]
@@ -47,7 +58,7 @@ class LayoutGroupComponentElement extends ComponentElement {
47
58
  super('layoutgroup');
48
59
  }
49
60
 
50
- getInitialComponentData() {
61
+ protected getInitialComponentData() {
51
62
  return {
52
63
  orientation: orientations.get(this._orientation),
53
64
  reverseX: this._reverseX,
@@ -295,10 +306,4 @@ class LayoutGroupComponentElement extends ComponentElement {
295
306
 
296
307
  customElements.define('pc-layoutgroup', LayoutGroupComponentElement);
297
308
 
298
- declare global {
299
- interface HTMLElementTagNameMap {
300
- 'pc-layoutgroup': LayoutGroupComponentElement;
301
- }
302
- }
303
-
304
309
  export { LayoutGroupComponentElement };
@@ -1,9 +1,25 @@
1
- import { Color, LightComponent, SHADOW_PCF1_16F, SHADOW_PCF1_32F, SHADOW_PCF3_16F, SHADOW_PCF3_32F, SHADOW_PCF5_16F, SHADOW_PCF5_32F, SHADOW_PCSS_32F, SHADOW_VSM_16F, SHADOW_VSM_32F } from 'playcanvas';
1
+ import type { LightComponent } from 'playcanvas';
2
+ import {
3
+ Color,
4
+ SHADOW_PCF1_16F,
5
+ SHADOW_PCF1_32F,
6
+ SHADOW_PCF3_16F,
7
+ SHADOW_PCF3_32F,
8
+ SHADOW_PCF5_16F,
9
+ SHADOW_PCF5_32F,
10
+ SHADOW_PCSS_32F,
11
+ SHADOW_VSM_16F,
12
+ SHADOW_VSM_32F
13
+ } from 'playcanvas';
2
14
 
3
- import { ComponentElement } from './component';
4
15
  import { parseBool, parseColor, parseEnum, parseNumber } from '../parse';
5
16
 
6
- const shadowTypes = new Map<'pcf1-16f' | 'pcf1-32f' | 'pcf3-16f' | 'pcf3-32f' | 'pcf5-16f' | 'pcf5-32f' | 'vsm-16f' | 'vsm-32f' | 'pcss-32f', number>([
17
+ import { ComponentElement } from './component';
18
+
19
+ const shadowTypes = new Map<
20
+ 'pcf1-16f' | 'pcf1-32f' | 'pcf3-16f' | 'pcf3-32f' | 'pcf5-16f' | 'pcf5-32f' | 'vsm-16f' | 'vsm-32f' | 'pcss-32f',
21
+ number
22
+ >([
7
23
  ['pcf1-16f', SHADOW_PCF1_16F],
8
24
  ['pcf1-32f', SHADOW_PCF1_32F],
9
25
  ['pcf3-16f', SHADOW_PCF3_16F],
@@ -46,7 +62,16 @@ class LightComponentElement extends ComponentElement {
46
62
 
47
63
  private _shadowResolution = 1024;
48
64
 
49
- private _shadowType: 'pcf1-16f' | 'pcf1-32f' | 'pcf3-16f' | 'pcf3-32f' | 'pcf5-16f' | 'pcf5-32f' | 'vsm-16f' | 'vsm-32f' | 'pcss-32f' = 'pcf3-32f';
65
+ private _shadowType:
66
+ | 'pcf1-16f'
67
+ | 'pcf1-32f'
68
+ | 'pcf3-16f'
69
+ | 'pcf3-32f'
70
+ | 'pcf5-16f'
71
+ | 'pcf5-32f'
72
+ | 'vsm-16f'
73
+ | 'vsm-32f'
74
+ | 'pcss-32f' = 'pcf3-32f';
50
75
 
51
76
  private _type: 'directional' | 'omni' | 'spot' = 'directional';
52
77
 
@@ -67,7 +92,7 @@ class LightComponentElement extends ComponentElement {
67
92
  super('light');
68
93
  }
69
94
 
70
- getInitialComponentData() {
95
+ protected getInitialComponentData() {
71
96
  return {
72
97
  castShadows: this._castShadows,
73
98
  color: this._color,
@@ -322,7 +347,18 @@ class LightComponentElement extends ComponentElement {
322
347
  * - `vsm-32f` - Variance shadow map with 32-bit depth.
323
348
  * - `pcss-32f` - Percentage-closer soft shadow with 32-bit depth.
324
349
  */
325
- set shadowType(value: 'pcf1-16f' | 'pcf1-32f' | 'pcf3-16f' | 'pcf3-32f' | 'pcf5-16f' | 'pcf5-32f' | 'vsm-16f' | 'vsm-32f' | 'pcss-32f') {
350
+ set shadowType(
351
+ value:
352
+ | 'pcf1-16f'
353
+ | 'pcf1-32f'
354
+ | 'pcf3-16f'
355
+ | 'pcf3-32f'
356
+ | 'pcf5-16f'
357
+ | 'pcf5-32f'
358
+ | 'vsm-16f'
359
+ | 'vsm-32f'
360
+ | 'pcss-32f'
361
+ ) {
326
362
  this._shadowType = value;
327
363
  if (this.component) {
328
364
  this.component.shadowType = shadowTypes.get(value) ?? SHADOW_PCF3_32F;
@@ -563,10 +599,4 @@ class LightComponentElement extends ComponentElement {
563
599
 
564
600
  customElements.define('pc-light', LightComponentElement);
565
601
 
566
- declare global {
567
- interface HTMLElementTagNameMap {
568
- 'pc-light': LightComponentElement;
569
- }
570
- }
571
-
572
602
  export { LightComponentElement };
@@ -1,4 +1,4 @@
1
- import { AudioListenerComponent } from 'playcanvas';
1
+ import type { AudioListenerComponent } from 'playcanvas';
2
2
 
3
3
  import { ComponentElement } from './component';
4
4
 
@@ -27,10 +27,4 @@ class ListenerComponentElement extends ComponentElement {
27
27
 
28
28
  customElements.define('pc-listener', ListenerComponentElement);
29
29
 
30
- declare global {
31
- interface HTMLElementTagNameMap {
32
- 'pc-listener': ListenerComponentElement;
33
- }
34
- }
35
-
36
30
  export { ListenerComponentElement };
@@ -1,8 +1,9 @@
1
- import { ParticleSystemComponent } from 'playcanvas';
1
+ import type { ParticleSystemComponent } from 'playcanvas';
2
2
 
3
- import { ComponentElement } from './component';
4
3
  import { AssetElement } from '../asset';
5
4
 
5
+ import { ComponentElement } from './component';
6
+
6
7
  /**
7
8
  * The ParticleSystemComponentElement interface provides properties and methods for manipulating
8
9
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-particles/ | `<pc-particles>`} elements.
@@ -12,14 +13,14 @@ import { AssetElement } from '../asset';
12
13
  * @category Components
13
14
  */
14
15
  class ParticleSystemComponentElement extends ComponentElement {
15
- private _asset: string = '';
16
+ private _asset = '';
16
17
 
17
18
  /** @ignore */
18
19
  constructor() {
19
20
  super('particlesystem');
20
21
  }
21
22
 
22
- getInitialComponentData() {
23
+ protected getInitialComponentData() {
23
24
  const asset = AssetElement.get(this._asset);
24
25
  if (!asset) {
25
26
  return {};
@@ -51,7 +52,7 @@ class ParticleSystemComponentElement extends ComponentElement {
51
52
 
52
53
  // Set all the config properties on the component
53
54
  for (const key in resource) {
54
- if (resource.hasOwnProperty(key)) {
55
+ if (Object.hasOwn(resource, key)) {
55
56
  (this.component as any)[key] = resource[key];
56
57
  }
57
58
  }
@@ -133,10 +134,7 @@ class ParticleSystemComponentElement extends ComponentElement {
133
134
  }
134
135
 
135
136
  static get observedAttributes() {
136
- return [
137
- ...super.observedAttributes,
138
- 'asset'
139
- ];
137
+ return [...super.observedAttributes, 'asset'];
140
138
  }
141
139
 
142
140
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
@@ -152,10 +150,4 @@ class ParticleSystemComponentElement extends ComponentElement {
152
150
 
153
151
  customElements.define('pc-particles', ParticleSystemComponentElement);
154
152
 
155
- declare global {
156
- interface HTMLElementTagNameMap {
157
- 'pc-particles': ParticleSystemComponentElement;
158
- }
159
- }
160
-
161
153
  export { ParticleSystemComponentElement };
@@ -1,9 +1,10 @@
1
- import { RenderComponent, StandardMaterial } from 'playcanvas';
1
+ import type { RenderComponent, StandardMaterial } from 'playcanvas';
2
2
 
3
- import { ComponentElement } from './component';
4
3
  import { MaterialElement } from '../material';
5
4
  import { parseBool, parseEnum } from '../parse';
6
5
 
6
+ import { ComponentElement } from './component';
7
+
7
8
  /**
8
9
  * The RenderComponentElement interface provides properties and methods for manipulating
9
10
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-render/ | `<pc-render>`} elements.
@@ -19,7 +20,7 @@ import { parseBool, parseEnum } from '../parse';
19
20
  class RenderComponentElement extends ComponentElement {
20
21
  private _castShadows = true;
21
22
 
22
- private _material: string = '';
23
+ private _material = '';
23
24
 
24
25
  private _receiveShadows = true;
25
26
 
@@ -30,7 +31,7 @@ class RenderComponentElement extends ComponentElement {
30
31
  super('render');
31
32
  }
32
33
 
33
- getInitialComponentData() {
34
+ protected getInitialComponentData() {
34
35
  return {
35
36
  type: this._type,
36
37
  castShadows: this._castShadows,
@@ -154,10 +155,4 @@ class RenderComponentElement extends ComponentElement {
154
155
 
155
156
  customElements.define('pc-render', RenderComponentElement);
156
157
 
157
- declare global {
158
- interface HTMLElementTagNameMap {
159
- 'pc-render': RenderComponentElement;
160
- }
161
- }
162
-
163
158
  export { RenderComponentElement };
@@ -1,8 +1,10 @@
1
- import { RigidBodyComponent, Vec3 } from 'playcanvas';
1
+ import type { RigidBodyComponent } from 'playcanvas';
2
+ import { Vec3 } from 'playcanvas';
2
3
 
3
- import { ComponentElement } from './component';
4
4
  import { parseEnum, parseNumber, parseVec3 } from '../parse';
5
5
 
6
+ import { ComponentElement } from './component';
7
+
6
8
  /**
7
9
  * The RigidBodyComponentElement interface provides properties and methods for manipulating
8
10
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-rigidbody/ | `<pc-rigidbody>`} elements.
@@ -15,7 +17,7 @@ class RigidBodyComponentElement extends ComponentElement {
15
17
  /**
16
18
  * The angular damping of the rigidbody.
17
19
  */
18
- private _angularDamping: number = 0;
20
+ private _angularDamping = 0;
19
21
 
20
22
  /**
21
23
  * The angular factor of the rigidbody.
@@ -25,12 +27,12 @@ class RigidBodyComponentElement extends ComponentElement {
25
27
  /**
26
28
  * The friction of the rigidbody.
27
29
  */
28
- private _friction: number = 0.5;
30
+ private _friction = 0.5;
29
31
 
30
32
  /**
31
33
  * The linear damping of the rigidbody.
32
34
  */
33
- private _linearDamping: number = 0;
35
+ private _linearDamping = 0;
34
36
 
35
37
  /**
36
38
  * The linear factor of the rigidbody.
@@ -40,17 +42,17 @@ class RigidBodyComponentElement extends ComponentElement {
40
42
  /**
41
43
  * The mass of the rigidbody.
42
44
  */
43
- private _mass: number = 1;
45
+ private _mass = 1;
44
46
 
45
47
  /**
46
48
  * The restitution of the rigidbody.
47
49
  */
48
- private _restitution: number = 0;
50
+ private _restitution = 0;
49
51
 
50
52
  /**
51
53
  * The rolling friction of the rigidbody.
52
54
  */
53
- private _rollingFriction: number = 0;
55
+ private _rollingFriction = 0;
54
56
 
55
57
  /**
56
58
  * The type of the rigidbody.
@@ -62,7 +64,7 @@ class RigidBodyComponentElement extends ComponentElement {
62
64
  super('rigidbody');
63
65
  }
64
66
 
65
- getInitialComponentData() {
67
+ protected getInitialComponentData() {
66
68
  return {
67
69
  angularDamping: this._angularDamping,
68
70
  angularFactor: this._angularFactor,
@@ -184,7 +186,18 @@ class RigidBodyComponentElement extends ComponentElement {
184
186
  }
185
187
 
186
188
  static get observedAttributes() {
187
- return [...super.observedAttributes, 'angular-damping', 'angular-factor', 'friction', 'linear-damping', 'linear-factor', 'mass', 'restitution', 'rolling-friction', 'type'];
189
+ return [
190
+ ...super.observedAttributes,
191
+ 'angular-damping',
192
+ 'angular-factor',
193
+ 'friction',
194
+ 'linear-damping',
195
+ 'linear-factor',
196
+ 'mass',
197
+ 'restitution',
198
+ 'rolling-friction',
199
+ 'type'
200
+ ];
188
201
  }
189
202
 
190
203
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
@@ -224,10 +237,4 @@ class RigidBodyComponentElement extends ComponentElement {
224
237
 
225
238
  customElements.define('pc-rigidbody', RigidBodyComponentElement);
226
239
 
227
- declare global {
228
- interface HTMLElementTagNameMap {
229
- 'pc-rigidbody': RigidBodyComponentElement;
230
- }
231
- }
232
-
233
240
  export { RigidBodyComponentElement };
@@ -1,8 +1,10 @@
1
- import { SCALEMODE_BLEND, SCALEMODE_NONE, ScreenComponent, Vec2 } from 'playcanvas';
1
+ import type { ScreenComponent } from 'playcanvas';
2
+ import { SCALEMODE_BLEND, SCALEMODE_NONE, Vec2 } from 'playcanvas';
2
3
 
3
- import { ComponentElement } from './component';
4
4
  import { parseBool, parseEnum, parseNumber, parseVec2 } from '../parse';
5
5
 
6
+ import { ComponentElement } from './component';
7
+
6
8
  // The engine's SCALEMODE_* constants are the strings 'none' and 'blend', so this map happens to be
7
9
  // an identity. It is still the right shape: it supplies parseEnum's valid-name list, it is what the
8
10
  // manifest generator reads the enum values from, and it keeps the attribute vocabulary independent
@@ -38,7 +40,7 @@ class ScreenComponentElement extends ComponentElement {
38
40
  super('screen');
39
41
  }
40
42
 
41
- getInitialComponentData() {
43
+ protected getInitialComponentData() {
42
44
  return {
43
45
  priority: this._priority,
44
46
  referenceResolution: this._referenceResolution,
@@ -184,10 +186,4 @@ class ScreenComponentElement extends ComponentElement {
184
186
 
185
187
  customElements.define('pc-screen', ScreenComponentElement);
186
188
 
187
- declare global {
188
- interface HTMLElementTagNameMap {
189
- 'pc-screen': ScreenComponentElement;
190
- }
191
- }
192
-
193
189
  export { ScreenComponentElement };