@playcanvas/web-components 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +260 -1
  2. package/dist/asset.d.ts +1 -0
  3. package/dist/components/camera-component.d.ts +110 -2
  4. package/dist/components/element-component.d.ts +0 -1
  5. package/dist/components/gsplat-component.d.ts +1 -2
  6. package/dist/components/render-component.d.ts +13 -1
  7. package/dist/components/screen-component.d.ts +44 -0
  8. package/dist/components/script-component.d.ts +25 -0
  9. package/dist/components/script.d.ts +12 -6
  10. package/dist/components/sound-slot.d.ts +0 -1
  11. package/dist/index.d.ts +3 -1
  12. package/dist/material.d.ts +29 -0
  13. package/dist/model.d.ts +0 -1
  14. package/dist/pwc.cjs +620 -91
  15. package/dist/pwc.cjs.map +1 -1
  16. package/dist/pwc.js +620 -91
  17. package/dist/pwc.js.map +1 -1
  18. package/dist/pwc.min.js +1 -1
  19. package/dist/pwc.min.js.map +1 -1
  20. package/dist/pwc.mjs +620 -93
  21. package/dist/pwc.mjs.map +1 -1
  22. package/dist/sky.d.ts +0 -1
  23. package/package.json +4 -4
  24. package/src/app.ts +7 -0
  25. package/src/asset.ts +5 -0
  26. package/src/components/camera-component.ts +248 -6
  27. package/src/components/element-component.ts +2 -7
  28. package/src/components/gsplat-component.ts +2 -7
  29. package/src/components/render-component.ts +38 -7
  30. package/src/components/screen-component.ts +153 -0
  31. package/src/components/script-component.ts +120 -1
  32. package/src/components/script.ts +23 -65
  33. package/src/components/sound-component.ts +1 -1
  34. package/src/components/sound-slot.ts +2 -7
  35. package/src/entity.ts +1 -1
  36. package/src/index.ts +4 -0
  37. package/src/material.ts +138 -0
  38. package/src/model.ts +1 -6
  39. package/src/sky.ts +1 -6
package/README.md CHANGED
@@ -24,7 +24,266 @@ UMD:
24
24
  <script src="https://cdn.jsdelivr.net/npm/@playcanvas/web-components@0.1.0"></script>
25
25
  ```
26
26
 
27
- ## Example 📖
27
+ ## Tag Reference 📖
28
+
29
+ Table of contents:
30
+
31
+ - [pc-app](#pc-app)
32
+ - [pc-asset](#pc-asset)
33
+ - [pc-camera](#pc-camera)
34
+ - [pc-collision](#pc-collision)
35
+ - [pc-element](#pc-element)
36
+ - [pc-entity](#pc-entity)
37
+ - [pc-light](#pc-light)
38
+ - [pc-listener](#pc-listener)
39
+ - [pc-module](#pc-module)
40
+ - [pc-render](#pc-render)
41
+ - [pc-rigidbody](#pc-rigidbody)
42
+ - [pc-scene](#pc-scene)
43
+ - [pc-script](#pc-script)
44
+ - [pc-scripts](#pc-scripts)
45
+ - [pc-sky](#pc-sky)
46
+ - [pc-screen](#pc-screen)
47
+ - [pc-sound](#pc-sound)
48
+ - [pc-sounds](#pc-sounds)
49
+ - [pc-splat](#pc-splat)
50
+
51
+ ### pc-app
52
+
53
+ The `pc-app` tag is the root element for your PlayCanvas application. It is used to initialize the PlayCanvas application and provide a container for your scene.
54
+
55
+ | Attribute | Description |
56
+ | --- | --- |
57
+ | `high-resolution` | Valueless attribute. If present, enables high-resolution mode. |
58
+
59
+ ### pc-asset
60
+
61
+ The `pc-asset` tag is used to define an asset. It must be a direct child of `pc-app`.
62
+
63
+ | Attribute | Description |
64
+ | --- | --- |
65
+ | `id` | The ID of the asset. This is used to reference the asset in scripts. |
66
+ | `src` | The path to the asset. |
67
+ | `preload` | Valueless attribute. If present, the asset is loaded immediately. |
68
+ | `type` | The type of asset. If not specified, the type is inferred from the file extension. Can be: `audio`, `binary`, `css`, `container`, `gsplat`, `html`, `json`, `script`, `shader`, `text`, `texture`. |
69
+
70
+ ### pc-camera
71
+
72
+ The `pc-camera` tag is used to define a camera component. It must be a direct child of an `pc-entity`.
73
+
74
+ | Attribute | Description |
75
+ | --- | --- |
76
+ | `clear-color` | The background color of the camera. Can be a comma-separated list of R, G, B, and A values or a hex color code. If unspecified, `0.75,0.75,0.75,1` is used. |
77
+ | `clear-color-buffer` | Boolean attribute. Controls whether the camera clears the color buffer. If unspecified, the color buffer is cleared. |
78
+ | `clear-depth-buffer` | Boolean attribute. Controls whether the camera clears the depth buffer. If unspecified, the depth buffer is cleared. |
79
+ | `clear-stencil-buffer` | Boolean attribute. Controls whether the camera clears the stencil buffer. If unspecified, the stencil buffer is cleared. |
80
+ | `cull-faces` | Boolean attribute. Controls whether the camera culls faces. If unspecified, faces are culled. |
81
+ | `far-clip` | The far clipping plane of the camera. If unspecified, `1000` is used. |
82
+ | `flip-faces` | Boolean attribute. Controls whether the camera flips faces. If unspecified, faces are not flipped. |
83
+ | `fov` | The field of view of the camera. If unspecified, `45` is used. |
84
+ | `frustum-culling` | Boolean attribute. Controls whether the camera uses frustum culling. If unspecified, frustum culling is used. |
85
+ | `near-clip` | The near clipping plane of the camera. If unspecified, `0.1` is used. |
86
+ | `orthographic` | Valueless attribute. If present, the camera uses an orthographic projection. If unspecified, the camera uses a perspective projection. |
87
+ | `ortho-height` | The height of the orthographic projection. If unspecified, `10` is used. |
88
+ | `priority` | The priority of the camera. If unspecified, `0` is used. |
89
+ | `rect` | The viewport rectangle of the camera. Specified as a comma-separated list of X, Y, Width, and Height values. If unspecified, `0,0,1,1` is used. |
90
+ | `scissor-rect` | The scissor rectangle of the camera. Specified as a comma-separated list of X, Y, Width, and Height values. If not specified, `0,0,1,1` is used. |
91
+
92
+ ### pc-collision
93
+
94
+ The `pc-collision` tag is used to define a collision component. It must be a direct child of a `pc-entity`.
95
+
96
+ | Attribute | Description |
97
+ | --- | --- |
98
+ | `axis` | The axis of the collision component. If not specified, `1` is used (Y-axis). |
99
+ | `convex-hull` | Valueless attribute. If present, the collision component uses a convex hull. |
100
+ | `enabled` | Enabled state of the collision component. If not specified, `true` is used. |
101
+ | `half-extents` | The half-extents of the collision component. Specified as a comma-separated list of X, Y, and Z values. If not specified, `0.5,0.5,0.5` is used. |
102
+ | `height` | The height of the collision component. If not specified, `2` is used. |
103
+ | `radius` | The radius of the collision component. If not specified, `0.5` is used. |
104
+ | `type` | The type of collision component. Can be `box`, `capsule`, `cone`, `cylinder` or `sphere`. |
105
+
106
+ ### pc-element
107
+
108
+ The `pc-element` tag is used to define an element component. It must be a direct child of a `pc-entity`.
109
+
110
+ | Attribute | Description |
111
+ | --- | --- |
112
+ | `anchor` | The anchor of the element component. Specified as a comma-separated list of X, Y, Z, and W values. If not specified, `0,0,0,1` is used. |
113
+ | `asset` | A string that should match the `id` of a `pc-asset` tag that has a type of `font`. |
114
+ | `auto-width` | Valueless attribute. If present, the element component automatically adjusts its width. |
115
+ | `color` | The color of the element component. Can be a comma-separated list of R, G, B, and A values or a hex color code. If not specified, `1,1,1,1` is used. |
116
+ | `font-size` | The font size of the element component. If not specified, `16` is used. |
117
+ | `line-height` | The line height of the element component. If not specified, `1.2` is used. |
118
+ | `pivot` | The pivot of the element component. Specified as a comma-separated list of X and Y values. If not specified, `0.5,0.5` is used. |
119
+ | `text` | The text of the element component. |
120
+ | `type` | The type of element component. Can be `group`, `image` or `text`. If not specified, `group` is used. |
121
+ | `width` | The width of the element component. If not specified, `0` is used. |
122
+ | `wrap-lines` | Valueless attribute. If present, the element component wraps lines. |
123
+
124
+ ### pc-entity
125
+
126
+ The `pc-entity` tag is used to define an entity. It must be a direct child of `pc-scene` or another `pc-entity`.
127
+
128
+ | Attribute | Description |
129
+ | --- | --- |
130
+ | `enabled` | Enabled state of the entity. If not specified, `true` is used. |
131
+ | `name` | The name of the entity. |
132
+ | `position` | The position of the entity. Specified as a comma-separated list of X, Y, and Z values. If not specified, `0,0,0` is used. |
133
+ | `rotation` | The rotation of the entity. Specified as a comma-separated list of X, Y, and Z Euler angles in degrees. If not specified, `0,0,0` is used. |
134
+ | `scale` | The scale of the entity. Specified as a comma-separated list of X, Y, and Z values. If not specified, `1,1,1` is used. |
135
+ | `tags` | A comma-separated list of tags for the entity. |
136
+
137
+ ### pc-light
138
+
139
+ The `pc-light` tag is used to define a light component. It must be a direct child of a `pc-entity`.
140
+
141
+ | Attribute | Description |
142
+ | --- | --- |
143
+ | `color` | The color of the light. Can be a comma-separated list of R, G, B values or a hex color code. If not specified, `1,1,1` is used. |
144
+ | `cast-shadows` | Valueless attribute. If present, the light casts shadows. |
145
+ | `inner-cone-angle` | The angle of the light's inner cone. If not specified, `40` is used. |
146
+ | `intensity` | The intensity of the light. If not specified, `1` is used. |
147
+ | `normal-offset-bias` | The bias of the light's normal offset. If not specified, `0.05` is used. |
148
+ | `outer-cone-angle` | The angle of the light's outer cone. If not specified, `45` is used. |
149
+ | `range` | The range of the light. If not specified, `10` is used. |
150
+ | `shadow-bias` | The bias of the light's shadows. If not specified, `0.2` is used. |
151
+ | `shadow-distance` | The distance at which the light's shadows are no longer rendered. If not specified, `16` is used. |
152
+ | `type` | The type of light. Can be `directional`, `point` or `omni`. |
153
+
154
+ ### pc-listener
155
+
156
+ The `pc-listener` tag is used to define a listener component. It must be a direct child of a `pc-entity`. It has no attributes.
157
+
158
+ ### pc-module
159
+
160
+ The `pc-module` tag is used to define a WASM module. It must be a direct child of `pc-app`.
161
+
162
+ | Attribute | Description |
163
+ | --- | --- |
164
+ | `name` | The name of the module. This is used to reference the module in scripts. |
165
+ | `glue` | The path to the glue code for the module. |
166
+ | `wasm` | The path to the WASM file for the module. |
167
+ | `fallback` | The path to the fallback (asm.js) code for the module. |
168
+
169
+ ### pc-render
170
+
171
+ The `pc-render` tag is used to define a render component that render a 3D primitive. It must be a direct child of a `pc-entity`.
172
+
173
+ | Attribute | Description |
174
+ | --- | --- |
175
+ | `type` | The type of render component. Can be `box`, `capsule`, `cone`, `cylinder`, `plane` or `sphere`. |
176
+ | `cast-shadows` | Valueless attribute. If present, the render component casts shadows. |
177
+ | `receive-shadows` | Valueless attribute. If present, the render component receives shadows. |
178
+
179
+ ### pc-rigidbody
180
+
181
+ The `pc-rigidbody` tag is used to define a rigidbody component. It must be a direct child of a `pc-entity`.
182
+
183
+ | Attribute | Description |
184
+ | --- | --- |
185
+ | `angular-damping` | The angular damping of the rigidbody. If not specified, `0` is used. |
186
+ | `angular-factor` | The angular factor of the rigidbody. Specified as a comma-separated list of X, Y, and Z values. If not specified, `1,1,1` is used. |
187
+ | `friction` | The friction of the rigidbody. If not specified, `0.5` is used. |
188
+ | `linear-damping` | The linear damping of the rigidbody. If not specified, `0` is used. |
189
+ | `linear-factor` | The linear factor of the rigidbody. Specified as a comma-separated list of X, Y, and Z values. If not specified, `1,1,1` is used. |
190
+ | `mass` | The mass of the rigidbody. If not specified, `1` is used. |
191
+ | `restitution` | The restitution of the rigidbody. If not specified, `0` is used. |
192
+ | `rolling-friction` | The rolling friction of the rigidbody. If not specified, `0` is used. |
193
+ | `type` | The type of rigidbody component. Can be `static`, `kinematic` or `dynamic`. |
194
+
195
+ ### pc-scene
196
+
197
+ The `pc-scene` tag is used to define the scene. It must be a direct child of `pc-app`.
198
+
199
+ | Attribute | Description |
200
+ | --- | --- |
201
+ | `fog` | The type of fog to use. Can be `linear`, `exp`, or `exp2`. |
202
+ | `fog-color` | The color of the fog. Can be a CSS color string or a hex color code. |
203
+ | `fog-start` | The start distance of the fog. |
204
+ | `fog-end` | The end distance of the fog. |
205
+ | `fog-density` | The density of the fog. |
206
+
207
+ ### pc-screen
208
+
209
+ The `pc-screen` tag is used to define a screen component. It must be a direct child of a `pc-entity`.
210
+
211
+ | Attribute | Description |
212
+ | --- | --- |
213
+ | `blend` | Valueless attribute. If present, the screen component blends. |
214
+ | `priority` | The priority of the screen component. Must be an integer between `0` and `255`. If not specified, `0` is used. |
215
+ | `reference-resolution` | The reference resolution of the screen component. Specified as a comma-separated list of Width and Height values. If not specified, `640,320` is used. |
216
+ | `resolution` | The resolution of the screen component. Specified as a comma-separated list of Width and Height values. If not specified, `640,320` is used. |
217
+ | `scale-blend` | The scale blend of the screen component. Must be a number between `0` and `1`. If not specified, `0.5` is used. |
218
+ | `screen-space` | Valueless attribute. If present, the screen component is in screen space. |
219
+
220
+
221
+ ### pc-script
222
+
223
+ The `pc-script` tag is used to define a script. It must be a direct child of a `pc-scripts` component.
224
+
225
+ | Attribute | Description |
226
+ | --- | --- |
227
+ | `attributes` | A JSON string of attributes for the script. |
228
+ | `enabled` | Enabled state of the script. If not specified, `true` is used. |
229
+ | `name` | The name of the script. |
230
+
231
+ ### pc-scripts
232
+
233
+ The `pc-scripts` tag is used to define a scripts component. It must be a direct child of a `pc-entity`.
234
+
235
+ | Attribute | Description |
236
+ | --- | --- |
237
+ | `enabled` | Enabled state of the scripts component. If not specified, `true` is used. |
238
+
239
+ ### pc-sky
240
+
241
+ The `pc-sky` tag is used to define a sky component. It must be a direct child of a `pc-scene`.
242
+
243
+ | Attribute | Description |
244
+ | --- | --- |
245
+ | `asset` | A string that should match the `id` of a `pc-asset` tag that has a type of `texture`. |
246
+ | `intensity` | The intensity of the sky. If not specified, `1` is used. |
247
+ | `level` | The mipmap level used to render the sky. If not specified, `0` is used (base mip level). |
248
+ | `rotation` | The rotation of the sky. Specified as a comma-separated list of X, Y, and Z values. If not specified, `0,0,0` is used. |
249
+ | `solid-color` | Valueless attribute. If present, the skybox itself is not rendered but is still used for environment lighting. |
250
+
251
+ ### pc-sound
252
+
253
+ The `pc-sound` tag is used to define a sound. It must be a direct child of a `pc-sounds`.
254
+
255
+ | Attribute | Description |
256
+ | --- | --- |
257
+ | `asset` | A string that should match the `id` of a `pc-asset` tag that has a type of `audio`. |
258
+ | `auto-play` | Valueless attribute. If present, the sound slot plays automatically. |
259
+ | `duration` | The duration of the sound slot. |
260
+ | `loop` | Valueless attribute. If present, the sound slot loops. |
261
+ | `name` | The name of the sound slot. |
262
+ | `overlap` | Valueless attribute. If present, the sound slot overlaps. |
263
+ | `pitch` | The pitch of the sound slot. If not specified, `1` is used. |
264
+ | `start-time` | The start time of the sound slot. If not specified, `0` is used. |
265
+ | `volume` | The volume of the sound slot. If not specified, `1` is used. |
266
+
267
+ ### pc-sounds
268
+
269
+ The `pc-sounds` tag is used to define a sound component. It must be a direct child of a `pc-entity`.
270
+
271
+ | Attribute | Description |
272
+ | --- | --- |
273
+ | `pitch` | The pitch of the sound. If not specified, `1` is used. |
274
+ | `positional` | Valueless attribute. If present, the sound is positional. |
275
+ | `volume` | The volume of the sound. If not specified, `1` is used. |
276
+
277
+ ### pc-splat
278
+
279
+ The `pc-splat` tag is used to define a splat component. It must be a direct child of a `pc-entity`.
280
+
281
+ | Attribute | Description |
282
+ | --- | --- |
283
+ | `asset` | A string that should match the `id` of a `pc-asset` tag that has a type of `gsplat`. |
284
+ | `enabled` | Enabled state of the splat component. If not specified, `true` is used. |
285
+
286
+ ## Example
28
287
 
29
288
  Below is a basic example of how to use PlayCanvas Web Components to create a simple 3D scene (a spinning cube):
30
289
 
package/dist/asset.d.ts CHANGED
@@ -22,6 +22,7 @@ declare class AssetElement extends HTMLElement {
22
22
  * @returns The preload flag.
23
23
  */
24
24
  get preload(): boolean;
25
+ static get(id: string): Asset | null | undefined;
25
26
  static get observedAttributes(): string[];
26
27
  attributeChangedCallback(name: string, _oldValue: string, _newValue: string): void;
27
28
  }
@@ -1,4 +1,4 @@
1
- import { CameraComponent, Color } from 'playcanvas';
1
+ import { CameraComponent, Color, Vec4 } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
3
  /**
4
4
  * Represents a camera component in the PlayCanvas engine.
@@ -7,22 +7,40 @@ import { ComponentElement } from './component';
7
7
  */
8
8
  declare class CameraComponentElement extends ComponentElement {
9
9
  private _clearColor;
10
+ private _clearColorBuffer;
11
+ private _clearDepthBuffer;
12
+ private _clearStencilBuffer;
13
+ private _cullFaces;
10
14
  private _farClip;
15
+ private _flipFaces;
11
16
  private _fov;
17
+ private _frustumCulling;
12
18
  private _nearClip;
13
19
  private _orthographic;
14
20
  private _orthoHeight;
21
+ private _priority;
22
+ private _rect;
23
+ private _scissorRect;
15
24
  /**
16
25
  * Creates a new CameraComponentElement.
17
26
  */
18
27
  constructor();
19
28
  getInitialComponentData(): {
20
29
  clearColor: Color;
30
+ clearColorBuffer: boolean;
31
+ clearDepthBuffer: boolean;
32
+ clearStencilBuffer: boolean;
33
+ cullFaces: boolean;
21
34
  farClip: number;
35
+ flipFaces: boolean;
22
36
  fov: number;
37
+ frustumCulling: boolean;
23
38
  nearClip: number;
24
- projection: number;
39
+ orthographic: boolean;
25
40
  orthoHeight: number;
41
+ priority: number;
42
+ rect: Vec4;
43
+ scissorRect: Vec4;
26
44
  };
27
45
  /**
28
46
  * Gets the camera component.
@@ -39,6 +57,46 @@ declare class CameraComponentElement extends ComponentElement {
39
57
  * @returns The clear color.
40
58
  */
41
59
  get clearColor(): Color;
60
+ /**
61
+ * Sets the clear color buffer of the camera.
62
+ * @param value - The clear color buffer.
63
+ */
64
+ set clearColorBuffer(value: boolean);
65
+ /**
66
+ * Gets the clear color buffer of the camera.
67
+ * @returns The clear color buffer.
68
+ */
69
+ get clearColorBuffer(): boolean;
70
+ /**
71
+ * Sets the clear depth buffer of the camera.
72
+ * @param value - The clear depth buffer.
73
+ */
74
+ set clearDepthBuffer(value: boolean);
75
+ /**
76
+ * Gets the clear depth buffer of the camera.
77
+ * @returns The clear depth buffer.
78
+ */
79
+ get clearDepthBuffer(): boolean;
80
+ /**
81
+ * Sets the clear stencil buffer of the camera.
82
+ * @param value - The clear stencil buffer.
83
+ */
84
+ set clearStencilBuffer(value: boolean);
85
+ /**
86
+ * Gets the clear stencil buffer of the camera.
87
+ * @returns The clear stencil buffer.
88
+ */
89
+ get clearStencilBuffer(): boolean;
90
+ /**
91
+ * Sets the cull faces of the camera.
92
+ * @param value - The cull faces.
93
+ */
94
+ set cullFaces(value: boolean);
95
+ /**
96
+ * Gets the cull faces of the camera.
97
+ * @returns The cull faces.
98
+ */
99
+ get cullFaces(): boolean;
42
100
  /**
43
101
  * Sets the far clip distance of the camera.
44
102
  * @param value - The far clip distance.
@@ -49,6 +107,16 @@ declare class CameraComponentElement extends ComponentElement {
49
107
  * @returns The far clip distance.
50
108
  */
51
109
  get farClip(): number;
110
+ /**
111
+ * Sets the flip faces of the camera.
112
+ * @param value - The flip faces.
113
+ */
114
+ set flipFaces(value: boolean);
115
+ /**
116
+ * Gets the flip faces of the camera.
117
+ * @returns The flip faces.
118
+ */
119
+ get flipFaces(): boolean;
52
120
  /**
53
121
  * Sets the field of view of the camera.
54
122
  * @param value - The field of view.
@@ -59,6 +127,16 @@ declare class CameraComponentElement extends ComponentElement {
59
127
  * @returns The field of view.
60
128
  */
61
129
  get fov(): number;
130
+ /**
131
+ * Sets the frustum culling of the camera.
132
+ * @param value - The frustum culling.
133
+ */
134
+ set frustumCulling(value: boolean);
135
+ /**
136
+ * Gets the frustum culling of the camera.
137
+ * @returns The frustum culling.
138
+ */
139
+ get frustumCulling(): boolean;
62
140
  /**
63
141
  * Sets the near clip distance of the camera.
64
142
  * @param value - The near clip distance.
@@ -89,6 +167,36 @@ declare class CameraComponentElement extends ComponentElement {
89
167
  * @returns The orthographic height.
90
168
  */
91
169
  get orthoHeight(): number;
170
+ /**
171
+ * Sets the priority of the camera.
172
+ * @param value - The priority.
173
+ */
174
+ set priority(value: number);
175
+ /**
176
+ * Gets the priority of the camera.
177
+ * @returns The priority.
178
+ */
179
+ get priority(): number;
180
+ /**
181
+ * Sets the rect of the camera.
182
+ * @param value - The rect.
183
+ */
184
+ set rect(value: Vec4);
185
+ /**
186
+ * Gets the rect of the camera.
187
+ * @returns The rect.
188
+ */
189
+ get rect(): Vec4;
190
+ /**
191
+ * Sets the scissor rect of the camera.
192
+ * @param value - The scissor rect.
193
+ */
194
+ set scissorRect(value: Vec4);
195
+ /**
196
+ * Gets the scissor rect of the camera.
197
+ * @returns The scissor rect.
198
+ */
199
+ get scissorRect(): Vec4;
92
200
  static get observedAttributes(): string[];
93
201
  attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
94
202
  }
@@ -19,7 +19,6 @@ declare class ElementComponentElement extends ComponentElement {
19
19
  private _wrapLines;
20
20
  constructor();
21
21
  connectedCallback(): Promise<void>;
22
- getAsset(): import("playcanvas").Asset | null;
23
22
  getInitialComponentData(): {
24
23
  anchor: Vec4;
25
24
  autoWidth: boolean;
@@ -8,9 +8,8 @@ import { ComponentElement } from './component';
8
8
  declare class GSplatComponentElement extends ComponentElement {
9
9
  private _asset;
10
10
  constructor();
11
- getAsset(): import("playcanvas").Asset | null;
12
11
  getInitialComponentData(): {
13
- asset: import("playcanvas").Asset | null;
12
+ asset: import("playcanvas").Asset | null | undefined;
14
13
  };
15
14
  /**
16
15
  * Gets the gsplat component.
@@ -6,10 +6,12 @@ import { ComponentElement } from './component';
6
6
  * @category Components
7
7
  */
8
8
  declare class RenderComponentElement extends ComponentElement {
9
- private _type;
10
9
  private _castShadows;
10
+ private _material;
11
11
  private _receiveShadows;
12
+ private _type;
12
13
  constructor();
14
+ connectedCallback(): Promise<void>;
13
15
  getInitialComponentData(): {
14
16
  type: "box" | "asset" | "capsule" | "cone" | "cylinder" | "plane" | "sphere";
15
17
  castShadows: boolean;
@@ -40,6 +42,16 @@ declare class RenderComponentElement extends ComponentElement {
40
42
  * @returns The cast shadows flag.
41
43
  */
42
44
  get castShadows(): boolean;
45
+ /**
46
+ * Sets the material of the render component.
47
+ * @param value - The id of the material asset to use.
48
+ */
49
+ set material(value: string);
50
+ /**
51
+ * Gets the id of the material asset used by the render component.
52
+ * @returns The id of the material asset.
53
+ */
54
+ get material(): string;
43
55
  /**
44
56
  * Sets the receive shadows flag of the render component.
45
57
  * @param value - The receive shadows flag.
@@ -0,0 +1,44 @@
1
+ import { ScreenComponent, Vec2 } from 'playcanvas';
2
+ import { ComponentElement } from './component';
3
+ /**
4
+ * Represents a screen component in the PlayCanvas engine.
5
+ *
6
+ * @category Components
7
+ */
8
+ declare class ScreenComponentElement extends ComponentElement {
9
+ private _screenSpace;
10
+ private _resolution;
11
+ private _referenceResolution;
12
+ private _priority;
13
+ private _blend;
14
+ private _scaleBlend;
15
+ constructor();
16
+ getInitialComponentData(): {
17
+ priority: number;
18
+ referenceResolution: Vec2;
19
+ resolution: Vec2;
20
+ scaleBlend: number;
21
+ scaleMode: string;
22
+ screenSpace: boolean;
23
+ };
24
+ /**
25
+ * Gets the screen component.
26
+ * @returns The screen component.
27
+ */
28
+ get component(): ScreenComponent | null;
29
+ set priority(value: number);
30
+ get priority(): number;
31
+ set referenceResolution(value: Vec2);
32
+ get referenceResolution(): Vec2;
33
+ set resolution(value: Vec2);
34
+ get resolution(): Vec2;
35
+ set scaleBlend(value: number);
36
+ get scaleBlend(): number;
37
+ set blend(value: boolean);
38
+ get blend(): boolean;
39
+ set screenSpace(value: boolean);
40
+ get screenSpace(): boolean;
41
+ static get observedAttributes(): string[];
42
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
43
+ }
44
+ export { ScreenComponentElement };
@@ -1,12 +1,37 @@
1
1
  import { ScriptComponent } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
+ interface ScriptAttributesChangeEvent extends CustomEvent {
4
+ detail: {
5
+ attributes: any;
6
+ };
7
+ }
8
+ interface ScriptEnableChangeEvent extends CustomEvent {
9
+ detail: {
10
+ enabled: boolean;
11
+ };
12
+ }
13
+ declare global {
14
+ interface HTMLElementEventMap {
15
+ 'scriptattributeschange': ScriptAttributesChangeEvent;
16
+ 'scriptenablechange': ScriptEnableChangeEvent;
17
+ }
18
+ }
3
19
  /**
4
20
  * Represents a script component in the PlayCanvas engine.
5
21
  *
6
22
  * @category Components
7
23
  */
8
24
  declare class ScriptComponentElement extends ComponentElement {
25
+ private observer;
9
26
  constructor();
27
+ connectedCallback(): Promise<void>;
28
+ private applyAttributes;
29
+ private handleScriptAttributesChange;
30
+ private handleScriptEnableChange;
31
+ private createScript;
32
+ private destroyScript;
33
+ private handleMutations;
34
+ disconnectedCallback(): void;
10
35
  /**
11
36
  * Gets the script component.
12
37
  * @returns The script component.
@@ -1,4 +1,3 @@
1
- import { ScriptComponentElement } from './script-component';
2
1
  /**
3
2
  * Represents a script in the PlayCanvas engine.
4
3
  */
@@ -6,13 +5,20 @@ declare class ScriptElement extends HTMLElement {
6
5
  private _attributes;
7
6
  private _enabled;
8
7
  private _name;
9
- private _script;
10
- connectedCallback(): Promise<void>;
11
- disconnectedCallback(): void;
12
- refreshAttributes(): void;
13
- protected get scriptsElement(): ScriptComponentElement | null;
8
+ /**
9
+ * Sets the attributes of the script.
10
+ * @param value - The attributes of the script.
11
+ */
14
12
  set scriptAttributes(value: string);
13
+ /**
14
+ * Gets the attributes of the script.
15
+ * @returns The attributes of the script.
16
+ */
15
17
  get scriptAttributes(): string;
18
+ /**
19
+ * Sets the enabled state of the script.
20
+ * @param value - The enabled state of the script.
21
+ */
16
22
  set enabled(value: boolean);
17
23
  /**
18
24
  * Gets the enabled state of the script.
@@ -17,7 +17,6 @@ declare class SoundSlotElement extends HTMLElement {
17
17
  * The sound slot.
18
18
  */
19
19
  soundSlot: SoundSlot | null;
20
- getAsset(): import("playcanvas").Asset | null;
21
20
  connectedCallback(): Promise<void>;
22
21
  disconnectedCallback(): void;
23
22
  protected get soundElement(): SoundComponentElement | null;
package/dist/index.d.ts CHANGED
@@ -11,11 +11,13 @@ import { GSplatComponentElement } from './components/gsplat-component';
11
11
  import { LightComponentElement } from './components/light-component';
12
12
  import { RenderComponentElement } from './components/render-component';
13
13
  import { RigidBodyComponentElement } from './components/rigidbody-component';
14
+ import { ScreenComponentElement } from './components/screen-component';
14
15
  import { ScriptComponentElement } from './components/script-component';
15
16
  import { ScriptElement } from './components/script';
16
17
  import { SoundComponentElement } from './components/sound-component';
17
18
  import { SoundSlotElement } from './components/sound-slot';
19
+ import { MaterialElement } from './material';
18
20
  import { ModelElement } from './model';
19
21
  import { SceneElement } from './scene';
20
22
  import { SkyElement } from './sky';
21
- export { ModuleElement, AppElement, EntityElement, AssetElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, GSplatComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, ModelElement, SceneElement, SkyElement };
23
+ export { ModuleElement, AppElement, EntityElement, AssetElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, GSplatComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, MaterialElement, ModelElement, SceneElement, SkyElement };
@@ -0,0 +1,29 @@
1
+ import { Color, StandardMaterial } from 'playcanvas';
2
+ /**
3
+ * Represents a material in the PlayCanvas engine.
4
+ */
5
+ declare class MaterialElement extends HTMLElement {
6
+ private _diffuse;
7
+ private _diffuseMap;
8
+ private _metalnessMap;
9
+ private _normalMap;
10
+ private _roughnessMap;
11
+ material: StandardMaterial | null;
12
+ createMaterial(): void;
13
+ disconnectedCallback(): void;
14
+ setMap(map: string, property: 'diffuseMap' | 'metalnessMap' | 'normalMap' | 'glossMap'): void;
15
+ set diffuse(value: Color);
16
+ get diffuse(): Color;
17
+ set diffuseMap(value: string);
18
+ get diffuseMap(): string;
19
+ set metalnessMap(value: string);
20
+ get metalnessMap(): string;
21
+ set normalMap(value: string);
22
+ get normalMap(): string;
23
+ set roughnessMap(value: string);
24
+ get roughnessMap(): string;
25
+ static get(id: string): StandardMaterial | null | undefined;
26
+ static get observedAttributes(): string[];
27
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
28
+ }
29
+ export { MaterialElement };
package/dist/model.d.ts CHANGED
@@ -4,7 +4,6 @@
4
4
  declare class ModelElement extends HTMLElement {
5
5
  private _asset;
6
6
  connectedCallback(): Promise<void>;
7
- getAsset(): import("playcanvas").Asset | null;
8
7
  _loadModel(): void;
9
8
  /**
10
9
  * Sets the asset ID of the model.