@playcanvas/web-components 0.1.6 → 0.1.8
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/README.md +22 -22
- package/dist/colors.d.ts +1 -0
- package/dist/components/light-component.d.ts +12 -0
- package/dist/model.d.ts +6 -2
- package/dist/pwc.cjs +358 -97
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +358 -97
- 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 +359 -98
- package/dist/pwc.mjs.map +1 -1
- package/dist/sky.d.ts +12 -6
- package/package.json +12 -10
- package/src/colors.ts +150 -0
- package/src/components/light-component.ts +26 -0
- package/src/components/script-component.ts +40 -13
- package/src/entity.ts +2 -0
- package/src/model.ts +47 -19
- package/src/sky.ts +103 -64
- package/src/utils.ts +13 -5
package/README.md
CHANGED
|
@@ -11,10 +11,10 @@ PlayCanvas Web Components are a set of custom HTML elements for building 3D inte
|
|
|
11
11
|
<!-- A lit sphere -->
|
|
12
12
|
<pc-app>
|
|
13
13
|
<pc-scene>
|
|
14
|
-
<pc-entity name="camera" position="0
|
|
14
|
+
<pc-entity name="camera" position="0 0 3">
|
|
15
15
|
<pc-camera></pc-camera>
|
|
16
16
|
</pc-entity>
|
|
17
|
-
<pc-entity name="light" rotation="45
|
|
17
|
+
<pc-entity name="light" rotation="45 45 0">
|
|
18
18
|
<pc-light></pc-light>
|
|
19
19
|
</pc-entity>
|
|
20
20
|
<pc-entity name="ball">
|
|
@@ -26,7 +26,7 @@ PlayCanvas Web Components are a set of custom HTML elements for building 3D inte
|
|
|
26
26
|
|
|
27
27
|
## Examples
|
|
28
28
|
|
|
29
|
-
[](https://playcanvas.github.io/web-components/examples)
|
|
30
30
|
|
|
31
31
|
See PlayCanvas Web Components in action here: https://playcanvas.github.io/web-components/examples
|
|
32
32
|
|
|
@@ -105,7 +105,7 @@ The `pc-camera` tag is used to define a camera component. It must be a direct ch
|
|
|
105
105
|
|
|
106
106
|
| Attribute | Description |
|
|
107
107
|
| --- | --- |
|
|
108
|
-
| `clear-color` | The background color of the camera. Can be a
|
|
108
|
+
| `clear-color` | The background color of the camera. Can be a space-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. |
|
|
109
109
|
| `clear-color-buffer` | Boolean attribute. Controls whether the camera clears the color buffer. If unspecified, the color buffer is cleared. |
|
|
110
110
|
| `clear-depth-buffer` | Boolean attribute. Controls whether the camera clears the depth buffer. If unspecified, the depth buffer is cleared. |
|
|
111
111
|
| `clear-stencil-buffer` | Boolean attribute. Controls whether the camera clears the stencil buffer. If unspecified, the stencil buffer is cleared. |
|
|
@@ -118,8 +118,8 @@ The `pc-camera` tag is used to define a camera component. It must be a direct ch
|
|
|
118
118
|
| `orthographic` | Valueless attribute. If present, the camera uses an orthographic projection. If unspecified, the camera uses a perspective projection. |
|
|
119
119
|
| `ortho-height` | The height of the orthographic projection. If unspecified, `10` is used. |
|
|
120
120
|
| `priority` | The priority of the camera. If unspecified, `0` is used. |
|
|
121
|
-
| `rect` | The viewport rectangle of the camera. Specified as a
|
|
122
|
-
| `scissor-rect` | The scissor rectangle of the camera. Specified as a
|
|
121
|
+
| `rect` | The viewport rectangle of the camera. Specified as a space-separated list of X, Y, Width, and Height values. If unspecified, `0 0 1 1` is used. |
|
|
122
|
+
| `scissor-rect` | The scissor rectangle of the camera. Specified as a space-separated list of X, Y, Width, and Height values. If not specified, `0 0 1 1` is used. |
|
|
123
123
|
|
|
124
124
|
### pc-collision
|
|
125
125
|
|
|
@@ -130,7 +130,7 @@ The `pc-collision` tag is used to define a collision component. It must be a dir
|
|
|
130
130
|
| `axis` | The axis of the collision component. If not specified, `1` is used (Y-axis). |
|
|
131
131
|
| `convex-hull` | Valueless attribute. If present, the collision component uses a convex hull. |
|
|
132
132
|
| `enabled` | Enabled state of the collision component. If not specified, `true` is used. |
|
|
133
|
-
| `half-extents` | The half-extents of the collision component. Specified as a
|
|
133
|
+
| `half-extents` | The half-extents of the collision component. Specified as a space-separated list of X, Y, and Z values. If not specified, `0.5 0.5 0.5` is used. |
|
|
134
134
|
| `height` | The height of the collision component. If not specified, `2` is used. |
|
|
135
135
|
| `radius` | The radius of the collision component. If not specified, `0.5` is used. |
|
|
136
136
|
| `type` | The type of collision component. Can be `box`, `capsule`, `cone`, `cylinder` or `sphere`. |
|
|
@@ -141,13 +141,13 @@ The `pc-element` tag is used to define an element component. It must be a direct
|
|
|
141
141
|
|
|
142
142
|
| Attribute | Description |
|
|
143
143
|
| --- | --- |
|
|
144
|
-
| `anchor` | The anchor of the element component. Specified as a
|
|
144
|
+
| `anchor` | The anchor of the element component. Specified as a space-separated list of X, Y, Z, and W values. If not specified, `0 0 0 1` is used. |
|
|
145
145
|
| `asset` | A string that should match the `id` of a `pc-asset` tag that has a type of `font`. |
|
|
146
146
|
| `auto-width` | Valueless attribute. If present, the element component automatically adjusts its width. |
|
|
147
|
-
| `color` | The color of the element component. Can be a
|
|
147
|
+
| `color` | The color of the element component. Can be a space-separated list of R, G, B, and A values or a hex color code. If not specified, `1 1 1 1` is used. |
|
|
148
148
|
| `font-size` | The font size of the element component. If not specified, `16` is used. |
|
|
149
149
|
| `line-height` | The line height of the element component. If not specified, `1.2` is used. |
|
|
150
|
-
| `pivot` | The pivot of the element component. Specified as a
|
|
150
|
+
| `pivot` | The pivot of the element component. Specified as a space-separated list of X and Y values. If not specified, `0.5 0.5` is used. |
|
|
151
151
|
| `text` | The text of the element component. |
|
|
152
152
|
| `type` | The type of element component. Can be `group`, `image` or `text`. If not specified, `group` is used. |
|
|
153
153
|
| `width` | The width of the element component. If not specified, `0` is used. |
|
|
@@ -161,10 +161,10 @@ The `pc-entity` tag is used to define an entity. It must be a direct child of `p
|
|
|
161
161
|
| --- | --- |
|
|
162
162
|
| `enabled` | Enabled state of the entity. If not specified, `true` is used. |
|
|
163
163
|
| `name` | The name of the entity. |
|
|
164
|
-
| `position` | The position of the entity. Specified as a
|
|
165
|
-
| `rotation` | The rotation of the entity. Specified as a
|
|
166
|
-
| `scale` | The scale of the entity. Specified as a
|
|
167
|
-
| `tags` | A
|
|
164
|
+
| `position` | The position of the entity. Specified as a space-separated list of X, Y, and Z values. If not specified, `0 0 0` is used. |
|
|
165
|
+
| `rotation` | The rotation of the entity. Specified as a space-separated list of X, Y, and Z Euler angles in degrees. If not specified, `0 0 0` is used. |
|
|
166
|
+
| `scale` | The scale of the entity. Specified as a space-separated list of X, Y, and Z values. If not specified, `1 1 1` is used. |
|
|
167
|
+
| `tags` | A space-separated list of tags for the entity. |
|
|
168
168
|
|
|
169
169
|
### pc-light
|
|
170
170
|
|
|
@@ -172,7 +172,7 @@ The `pc-light` tag is used to define a light component. It must be a direct chil
|
|
|
172
172
|
|
|
173
173
|
| Attribute | Description |
|
|
174
174
|
| --- | --- |
|
|
175
|
-
| `color` | The color of the light. Can be a
|
|
175
|
+
| `color` | The color of the light. Can be a space-separated list of R, G, B values or a hex color code. If not specified, `1 1 1` is used. |
|
|
176
176
|
| `cast-shadows` | Valueless attribute. If present, the light casts shadows. |
|
|
177
177
|
| `inner-cone-angle` | The angle of the light's inner cone. If not specified, `40` is used. |
|
|
178
178
|
| `intensity` | The intensity of the light. If not specified, `1` is used. |
|
|
@@ -215,10 +215,10 @@ The `pc-rigidbody` tag is used to define a rigidbody component. It must be a dir
|
|
|
215
215
|
| Attribute | Description |
|
|
216
216
|
| --- | --- |
|
|
217
217
|
| `angular-damping` | The angular damping of the rigidbody. If not specified, `0` is used. |
|
|
218
|
-
| `angular-factor` | The angular factor of the rigidbody. Specified as a
|
|
218
|
+
| `angular-factor` | The angular factor of the rigidbody. Specified as a space-separated list of X, Y, and Z values. If not specified, `1 1 1` is used. |
|
|
219
219
|
| `friction` | The friction of the rigidbody. If not specified, `0.5` is used. |
|
|
220
220
|
| `linear-damping` | The linear damping of the rigidbody. If not specified, `0` is used. |
|
|
221
|
-
| `linear-factor` | The linear factor of the rigidbody. Specified as a
|
|
221
|
+
| `linear-factor` | The linear factor of the rigidbody. Specified as a space-separated list of X, Y, and Z values. If not specified, `1 1 1` is used. |
|
|
222
222
|
| `mass` | The mass of the rigidbody. If not specified, `1` is used. |
|
|
223
223
|
| `restitution` | The restitution of the rigidbody. If not specified, `0` is used. |
|
|
224
224
|
| `rolling-friction` | The rolling friction of the rigidbody. If not specified, `0` is used. |
|
|
@@ -244,8 +244,8 @@ The `pc-screen` tag is used to define a screen component. It must be a direct ch
|
|
|
244
244
|
| --- | --- |
|
|
245
245
|
| `blend` | Valueless attribute. If present, the screen component blends. |
|
|
246
246
|
| `priority` | The priority of the screen component. Must be an integer between `0` and `255`. If not specified, `0` is used. |
|
|
247
|
-
| `reference-resolution` | The reference resolution of the screen component. Specified as a
|
|
248
|
-
| `resolution` | The resolution of the screen component. Specified as a
|
|
247
|
+
| `reference-resolution` | The reference resolution of the screen component. Specified as a space-separated list of Width and Height values. If not specified, `640 320` is used. |
|
|
248
|
+
| `resolution` | The resolution of the screen component. Specified as a space-separated list of Width and Height values. If not specified, `640 320` is used. |
|
|
249
249
|
| `scale-blend` | The scale blend of the screen component. Must be a number between `0` and `1`. If not specified, `0.5` is used. |
|
|
250
250
|
| `screen-space` | Valueless attribute. If present, the screen component is in screen space. |
|
|
251
251
|
|
|
@@ -275,11 +275,11 @@ The `pc-sky` tag is used to define a sky component. It must be a direct child of
|
|
|
275
275
|
| Attribute | Description |
|
|
276
276
|
| --- | --- |
|
|
277
277
|
| `asset` | A string that should match the `id` of a `pc-asset` tag that has a type of `texture`. |
|
|
278
|
-
| `center` | The center of the sky. Specified as a
|
|
278
|
+
| `center` | The center of the sky. Specified as a space-separated list of X, Y, and Z values in the range 0 to 1. If not specified, `0 0.01 0` is used. |
|
|
279
279
|
| `intensity` | The intensity of the sky. If not specified, `1` is used. |
|
|
280
280
|
| `level` | The mipmap level used to render the sky. If not specified, `0` is used (base mip level). |
|
|
281
|
-
| `rotation` | The rotation of the sky. Specified as a
|
|
282
|
-
| `scale` | The scale of the sky. Specified as a
|
|
281
|
+
| `rotation` | The rotation of the sky. Specified as a space-separated list of X, Y, and Z values. If not specified, `0 0 0` is used. |
|
|
282
|
+
| `scale` | The scale of the sky. Specified as a space-separated list of X, Y, and Z values. If not specified, `100 100 100` is used. |
|
|
283
283
|
| `type` | The type of sky component. Can be `box`, `dome`, `infinite` or `none`. |
|
|
284
284
|
|
|
285
285
|
### pc-sound
|
package/dist/colors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CSS_COLORS: Record<string, string>;
|
|
@@ -15,6 +15,7 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
15
15
|
private _range;
|
|
16
16
|
private _shadowBias;
|
|
17
17
|
private _shadowDistance;
|
|
18
|
+
private _shadowResolution;
|
|
18
19
|
private _type;
|
|
19
20
|
/**
|
|
20
21
|
* Creates a new LightComponentElement.
|
|
@@ -30,6 +31,7 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
30
31
|
range: number;
|
|
31
32
|
shadowBias: number;
|
|
32
33
|
shadowDistance: number;
|
|
34
|
+
shadowResolution: number;
|
|
33
35
|
type: string;
|
|
34
36
|
};
|
|
35
37
|
/**
|
|
@@ -127,6 +129,16 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
127
129
|
* @returns The shadow distance.
|
|
128
130
|
*/
|
|
129
131
|
get shadowDistance(): number;
|
|
132
|
+
/**
|
|
133
|
+
* Sets the shadow resolution of the light.
|
|
134
|
+
* @param value - The shadow resolution.
|
|
135
|
+
*/
|
|
136
|
+
set shadowResolution(value: number);
|
|
137
|
+
/**
|
|
138
|
+
* Gets the shadow resolution of the light.
|
|
139
|
+
* @returns The shadow resolution.
|
|
140
|
+
*/
|
|
141
|
+
get shadowResolution(): number;
|
|
130
142
|
/**
|
|
131
143
|
* Sets the type of the light.
|
|
132
144
|
* @param value - The type.
|
package/dist/model.d.ts
CHANGED
|
@@ -4,8 +4,12 @@ import { AsyncElement } from './async-element';
|
|
|
4
4
|
*/
|
|
5
5
|
declare class ModelElement extends AsyncElement {
|
|
6
6
|
private _asset;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
private _entity;
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
disconnectedCallback(): void;
|
|
10
|
+
private _instantiate;
|
|
11
|
+
private _loadModel;
|
|
12
|
+
private _unloadModel;
|
|
9
13
|
/**
|
|
10
14
|
* Sets the asset ID of the model.
|
|
11
15
|
* @param value - The asset ID.
|