@playcanvas/web-components 0.10.1 → 0.11.1

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 (78) hide show
  1. package/README.md +1 -1
  2. package/dist/app.d.ts +102 -51
  3. package/dist/asset.d.ts +8 -7
  4. package/dist/async-element.d.ts +21 -5
  5. package/dist/components/button-component.d.ts +3 -7
  6. package/dist/components/camera-component.d.ts +16 -20
  7. package/dist/components/collision-component.d.ts +3 -7
  8. package/dist/components/component.d.ts +22 -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 +28 -11
  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 +9 -11
  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 +5191 -10695
  26. package/dist/entity.d.ts +16 -9
  27. package/dist/index.d.ts +37 -0
  28. package/dist/material.d.ts +12 -12
  29. package/dist/model.d.ts +21 -5
  30. package/dist/module.d.ts +0 -6
  31. package/dist/parse.d.ts +6 -3
  32. package/dist/pwc.cjs +799 -287
  33. package/dist/pwc.cjs.map +1 -1
  34. package/dist/pwc.js +799 -287
  35. package/dist/pwc.js.map +1 -1
  36. package/dist/pwc.min.js +1 -1
  37. package/dist/pwc.min.js.map +1 -1
  38. package/dist/pwc.min.mjs +1 -1
  39. package/dist/pwc.min.mjs.map +1 -1
  40. package/dist/pwc.mjs +800 -288
  41. package/dist/pwc.mjs.map +1 -1
  42. package/dist/scene.d.ts +4 -7
  43. package/dist/sky.d.ts +25 -16
  44. package/dist/vscode.html-custom-data.json +65 -45
  45. package/dist/web-types.json +585 -557
  46. package/package.json +8 -7
  47. package/src/app.ts +326 -144
  48. package/src/asset.ts +34 -28
  49. package/src/async-element.ts +34 -8
  50. package/src/components/button-component.ts +5 -9
  51. package/src/components/camera-component.ts +55 -36
  52. package/src/components/collision-component.ts +26 -15
  53. package/src/components/component.ts +58 -8
  54. package/src/components/element-component.ts +26 -30
  55. package/src/components/gsplat-component.ts +4 -9
  56. package/src/components/layoutchild-component.ts +4 -9
  57. package/src/components/layoutgroup-component.ts +14 -9
  58. package/src/components/light-component.ts +42 -12
  59. package/src/components/listener-component.ts +1 -7
  60. package/src/components/particlesystem-component.ts +7 -15
  61. package/src/components/render-component.ts +5 -10
  62. package/src/components/rigidbody-component.ts +23 -16
  63. package/src/components/screen-component.ts +46 -20
  64. package/src/components/script-component.ts +108 -46
  65. package/src/components/script.ts +38 -33
  66. package/src/components/scrollbar-component.ts +6 -16
  67. package/src/components/scrollview-component.ts +22 -15
  68. package/src/components/sound-component.ts +10 -15
  69. package/src/components/sound-slot.ts +30 -20
  70. package/src/entity.ts +75 -34
  71. package/src/index.ts +45 -1
  72. package/src/loading-bar.ts +8 -8
  73. package/src/material.ts +63 -37
  74. package/src/model.ts +69 -14
  75. package/src/module.ts +8 -7
  76. package/src/parse.ts +67 -20
  77. package/src/scene.ts +12 -9
  78. package/src/sky.ts +76 -34
@@ -1,4 +1,4 @@
1
- import { RenderComponent, StandardMaterial } from 'playcanvas';
1
+ import type { RenderComponent, StandardMaterial } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
3
  /**
4
4
  * The RenderComponentElement interface provides properties and methods for manipulating
@@ -19,7 +19,7 @@ declare class RenderComponentElement extends ComponentElement {
19
19
  private _type;
20
20
  /** @ignore */
21
21
  constructor();
22
- getInitialComponentData(): {
22
+ protected getInitialComponentData(): {
23
23
  type: "box" | "capsule" | "cone" | "cylinder" | "sphere" | "plane";
24
24
  castShadows: boolean;
25
25
  material: StandardMaterial | null | undefined;
@@ -73,9 +73,4 @@ declare class RenderComponentElement extends ComponentElement {
73
73
  static get observedAttributes(): string[];
74
74
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
75
75
  }
76
- declare global {
77
- interface HTMLElementTagNameMap {
78
- 'pc-render': RenderComponentElement;
79
- }
80
- }
81
76
  export { RenderComponentElement };
@@ -1,4 +1,5 @@
1
- import { RigidBodyComponent, Vec3 } from 'playcanvas';
1
+ import type { RigidBodyComponent } from 'playcanvas';
2
+ import { Vec3 } from 'playcanvas';
2
3
  import { ComponentElement } from './component';
3
4
  /**
4
5
  * The RigidBodyComponentElement interface provides properties and methods for manipulating
@@ -47,7 +48,7 @@ declare class RigidBodyComponentElement extends ComponentElement {
47
48
  private _type;
48
49
  /** @ignore */
49
50
  constructor();
50
- getInitialComponentData(): {
51
+ protected getInitialComponentData(): {
51
52
  angularDamping: number;
52
53
  angularFactor: Vec3;
53
54
  friction: number;
@@ -84,9 +85,4 @@ declare class RigidBodyComponentElement extends ComponentElement {
84
85
  static get observedAttributes(): string[];
85
86
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
86
87
  }
87
- declare global {
88
- interface HTMLElementTagNameMap {
89
- 'pc-rigidbody': RigidBodyComponentElement;
90
- }
91
- }
92
88
  export { RigidBodyComponentElement };
@@ -1,4 +1,5 @@
1
- import { ScreenComponent, Vec2 } from 'playcanvas';
1
+ import type { ScreenComponent } from 'playcanvas';
2
+ import { Vec2 } from 'playcanvas';
2
3
  import { ComponentElement } from './component';
3
4
  /**
4
5
  * The ScreenComponentElement interface provides properties and methods for manipulating
@@ -13,16 +14,16 @@ declare class ScreenComponentElement extends ComponentElement {
13
14
  private _resolution;
14
15
  private _referenceResolution;
15
16
  private _priority;
16
- private _blend;
17
+ private _scaleMode;
17
18
  private _scaleBlend;
18
19
  /** @ignore */
19
20
  constructor();
20
- getInitialComponentData(): {
21
+ protected getInitialComponentData(): {
21
22
  priority: number;
22
23
  referenceResolution: Vec2;
23
24
  resolution: Vec2;
24
25
  scaleBlend: number;
25
- scaleMode: "none" | "blend";
26
+ scaleMode: string;
26
27
  screenSpace: boolean;
27
28
  };
28
29
  /**
@@ -36,18 +37,34 @@ declare class ScreenComponentElement extends ComponentElement {
36
37
  get referenceResolution(): Vec2;
37
38
  set resolution(value: Vec2);
38
39
  get resolution(): Vec2;
40
+ /**
41
+ * Sets how the screen's `resolution` and `referenceResolution` are weighted against each other
42
+ * when `scaleMode` is `blend`, from 0 (follow the resolution) to 1 (follow the reference
43
+ * resolution). Ignored while `scaleMode` is `none`.
44
+ * @param value - The scale blend factor.
45
+ */
39
46
  set scaleBlend(value: number);
47
+ /**
48
+ * Gets how the screen's resolutions are weighted against each other.
49
+ * @returns The scale blend factor.
50
+ */
40
51
  get scaleBlend(): number;
41
- set blend(value: boolean);
42
- get blend(): boolean;
52
+ /**
53
+ * Sets how the screen scales its contents. `none` renders at `resolution` and ignores
54
+ * `referenceResolution`; `blend` scales between the two, weighted by `scaleBlend`, which is what
55
+ * keeps a UI laid out at one resolution usable at another. Requires `screenSpace` - the engine
56
+ * forces `none` on a world-space screen, which does not support scaling.
57
+ * @param value - The scale mode ('none' or 'blend').
58
+ */
59
+ set scaleMode(value: 'none' | 'blend');
60
+ /**
61
+ * Gets how the screen scales its contents.
62
+ * @returns The scale mode.
63
+ */
64
+ get scaleMode(): "none" | "blend";
43
65
  set screenSpace(value: boolean);
44
66
  get screenSpace(): boolean;
45
67
  static get observedAttributes(): string[];
46
68
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
47
69
  }
48
- declare global {
49
- interface HTMLElementTagNameMap {
50
- 'pc-screen': ScreenComponentElement;
51
- }
52
- }
53
70
  export { ScreenComponentElement };
@@ -1,28 +1,21 @@
1
- import { ScriptComponent } from 'playcanvas';
1
+ import type { ScriptComponent } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
- interface ScriptAttributesChangeEvent extends CustomEvent {
3
+ export type ScriptAttributesChangeEvent = {
4
4
  detail: {
5
5
  attributes: Record<string, any>;
6
6
  };
7
- }
8
- interface ScriptEnableChangeEvent extends CustomEvent {
7
+ } & CustomEvent;
8
+ export type ScriptEnableChangeEvent = {
9
9
  detail: {
10
10
  enabled: boolean;
11
11
  };
12
- }
13
- interface ScriptNameChangeEvent extends CustomEvent {
12
+ } & CustomEvent;
13
+ export type ScriptNameChangeEvent = {
14
14
  detail: {
15
15
  oldName: string;
16
16
  newName: string;
17
17
  };
18
- }
19
- declare global {
20
- interface HTMLElementEventMap {
21
- 'scriptattributeschange': ScriptAttributesChangeEvent;
22
- 'scriptenablechange': ScriptEnableChangeEvent;
23
- 'scriptnamechange': ScriptNameChangeEvent;
24
- }
25
- }
18
+ } & CustomEvent;
26
19
  /**
27
20
  * The ScriptComponentElement interface provides properties and methods for manipulating
28
21
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scripts/ | `<pc-scripts>`} elements.
@@ -36,7 +29,7 @@ declare class ScriptComponentElement extends ComponentElement {
36
29
  /** @ignore */
37
30
  constructor();
38
31
  connectedCallback(): Promise<void>;
39
- initComponent(): void;
32
+ protected initComponent(): void;
40
33
  /**
41
34
  * Recursively converts raw attribute data into proper PlayCanvas types. Supported conversions:
42
35
  * - "asset:id" → the Asset created by the `pc-asset` element with that id
@@ -167,9 +160,4 @@ declare class ScriptComponentElement extends ComponentElement {
167
160
  */
168
161
  get component(): ScriptComponent;
169
162
  }
170
- declare global {
171
- interface HTMLElementTagNameMap {
172
- 'pc-scripts': ScriptComponentElement;
173
- }
174
- }
175
163
  export { ScriptComponentElement };
@@ -1,4 +1,4 @@
1
- import { Script } from 'playcanvas';
1
+ import type { Script } from 'playcanvas';
2
2
  import { AsyncElement } from '../async-element';
3
3
  /**
4
4
  * The ScriptElement interface provides properties and methods for manipulating
@@ -36,17 +36,6 @@ import { AsyncElement } from '../async-element';
36
36
  declare class ScriptElement extends AsyncElement {
37
37
  private _attributes;
38
38
  private _enabled;
39
- /**
40
- * Whether readiness has been signalled. Creation can happen more than once over an
41
- * element's life (a runtime `name` change recreates the instance), but `ready` is a
42
- * one-shot signal, so only the first successful creation fires it.
43
- */
44
- private _readySignalled;
45
- /**
46
- * The Script instance created for this element by its parent `<pc-scripts>` element.
47
- * @ignore
48
- */
49
- _script: Script | null;
50
39
  /**
51
40
  * Sets the attributes of the script as an object. Values are converted with the same rules
52
41
  * as the `attributes` attribute: `asset:`/`entity:` references and `vec2:`/`vec3:`/`vec4:`/
@@ -98,17 +87,8 @@ declare class ScriptElement extends AsyncElement {
98
87
  */
99
88
  get script(): Script | null;
100
89
  connectedCallback(): void;
101
- /**
102
- * Called by the parent `<pc-scripts>` element when the script instance has been created.
103
- * @ignore
104
- */
105
- _onScriptCreated(): void;
90
+ disconnectedCallback(): void;
106
91
  static get observedAttributes(): string[];
107
92
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
108
93
  }
109
- declare global {
110
- interface HTMLElementTagNameMap {
111
- 'pc-script': ScriptElement;
112
- }
113
- }
114
94
  export { ScriptElement };
@@ -1,4 +1,4 @@
1
- import { ScrollbarComponent } from 'playcanvas';
1
+ import type { ScrollbarComponent } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
3
  /**
4
4
  * The ScrollbarComponentElement interface provides properties and methods for manipulating
@@ -15,7 +15,7 @@ declare class ScrollbarComponentElement extends ComponentElement {
15
15
  private _handle;
16
16
  /** @ignore */
17
17
  constructor();
18
- getInitialComponentData(): Record<string, any>;
18
+ protected getInitialComponentData(): Record<string, any>;
19
19
  /**
20
20
  * Gets the underlying PlayCanvas scrollbar component.
21
21
  * @returns The scrollbar component.
@@ -66,9 +66,4 @@ declare class ScrollbarComponentElement extends ComponentElement {
66
66
  static get observedAttributes(): string[];
67
67
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
68
68
  }
69
- declare global {
70
- interface HTMLElementTagNameMap {
71
- 'pc-scrollbar': ScrollbarComponentElement;
72
- }
73
- }
74
69
  export { ScrollbarComponentElement };
@@ -1,4 +1,5 @@
1
- import { ScrollViewComponent, Vec2 } from 'playcanvas';
1
+ import type { ScrollViewComponent } from 'playcanvas';
2
+ import { Vec2 } from 'playcanvas';
2
3
  import { ComponentElement } from './component';
3
4
  /**
4
5
  * The ScrollViewComponentElement interface provides properties and methods for manipulating
@@ -24,29 +25,31 @@ declare class ScrollViewComponentElement extends ComponentElement {
24
25
  private _verticalScrollbar;
25
26
  /** @ignore */
26
27
  constructor();
27
- getInitialComponentData(): Record<string, any>;
28
+ protected getInitialComponentData(): Record<string, any>;
28
29
  /**
29
30
  * Gets the underlying PlayCanvas scroll view component.
30
31
  * @returns The scroll view component.
31
32
  */
32
33
  get component(): ScrollViewComponent;
33
34
  /**
34
- * Sets whether horizontal scrolling is enabled.
35
+ * Sets whether scrolling along the horizontal axis is enabled. This is a toggle, unlike the
36
+ * `orientation` of a `<pc-scrollbar>`, for which `horizontal` is one of the accepted values.
35
37
  * @param value - Whether horizontal scrolling is enabled.
36
38
  */
37
39
  set horizontal(value: boolean);
38
40
  /**
39
- * Gets whether horizontal scrolling is enabled.
41
+ * Gets whether scrolling along the horizontal axis is enabled.
40
42
  * @returns Whether horizontal scrolling is enabled.
41
43
  */
42
44
  get horizontal(): boolean;
43
45
  /**
44
- * Sets whether vertical scrolling is enabled.
46
+ * Sets whether scrolling along the vertical axis is enabled. This is a toggle, unlike the
47
+ * `orientation` of a `<pc-scrollbar>`, for which `vertical` is one of the accepted values.
45
48
  * @param value - Whether vertical scrolling is enabled.
46
49
  */
47
50
  set vertical(value: boolean);
48
51
  /**
49
- * Gets whether vertical scrolling is enabled.
52
+ * Gets whether scrolling along the vertical axis is enabled.
50
53
  * @returns Whether vertical scrolling is enabled.
51
54
  */
52
55
  get vertical(): boolean;
@@ -172,9 +175,4 @@ declare class ScrollViewComponentElement extends ComponentElement {
172
175
  static get observedAttributes(): string[];
173
176
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
174
177
  }
175
- declare global {
176
- interface HTMLElementTagNameMap {
177
- 'pc-scrollview': ScrollViewComponentElement;
178
- }
179
- }
180
178
  export { ScrollViewComponentElement };
@@ -1,4 +1,4 @@
1
- import { SoundComponent } from 'playcanvas';
1
+ import type { SoundComponent } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
3
  /**
4
4
  * The SoundComponentElement interface provides properties and methods for manipulating
@@ -18,7 +18,7 @@ declare class SoundComponentElement extends ComponentElement {
18
18
  private _volume;
19
19
  /** @ignore */
20
20
  constructor();
21
- getInitialComponentData(): {
21
+ protected getInitialComponentData(): {
22
22
  distanceModel: "linear" | "exponential" | "inverse";
23
23
  maxDistance: number;
24
24
  pitch: number;
@@ -105,9 +105,4 @@ declare class SoundComponentElement extends ComponentElement {
105
105
  static get observedAttributes(): string[];
106
106
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
107
107
  }
108
- declare global {
109
- interface HTMLElementTagNameMap {
110
- 'pc-sounds': SoundComponentElement;
111
- }
112
- }
113
108
  export { SoundComponentElement };
@@ -1,4 +1,4 @@
1
- import { SoundSlot } from 'playcanvas';
1
+ import type { SoundSlot } from 'playcanvas';
2
2
  import { AsyncElement } from '../async-element';
3
3
  import { SoundComponentElement } from './sound-component';
4
4
  /**
@@ -24,6 +24,13 @@ declare class SoundSlotElement extends AsyncElement {
24
24
  * emit a misleading "must be a direct child" warning for what is an ordinary removal.
25
25
  */
26
26
  private _soundElement;
27
+ /**
28
+ * Incremented on every connect and disconnect, and captured by connectedCallback on entry —
29
+ * a resume from an await abandons itself if the value has moved on, so a stale callback can
30
+ * neither act on a torn-down tree nor add its slot alongside a re-inserted element's own
31
+ * callback.
32
+ */
33
+ private _connectionGeneration;
27
34
  /**
28
35
  * The sound slot.
29
36
  */
@@ -124,9 +131,4 @@ declare class SoundSlotElement extends AsyncElement {
124
131
  static get observedAttributes(): string[];
125
132
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
126
133
  }
127
- declare global {
128
- interface HTMLElementTagNameMap {
129
- 'pc-sound': SoundSlotElement;
130
- }
131
- }
132
134
  export { SoundSlotElement };