@playcanvas/web-components 0.1.9 → 0.1.11
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/LICENSE +1 -1
- package/README.md +38 -6
- package/dist/app.d.ts +11 -0
- package/dist/components/camera-component.d.ts +37 -0
- package/dist/components/light-component.d.ts +46 -0
- package/dist/components/sound-component.d.ts +1 -1
- package/dist/entity.d.ts +7 -0
- package/dist/fog.d.ts +28 -0
- package/dist/pwc.cjs +451 -38
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +451 -38
- 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 +452 -39
- package/dist/pwc.mjs.map +1 -1
- package/package.json +16 -15
- package/src/app.ts +180 -1
- package/src/components/camera-component.ts +92 -3
- package/src/components/light-component.ts +103 -3
- package/src/components/script-component.ts +22 -13
- package/src/entity.ts +88 -1
- package/src/fog.ts +121 -0
- package/src/material.ts +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
[](https://github.com/playcanvas/web-components/blob/main/LICENSE)
|
|
6
6
|
[](https://github.com/playcanvas/web-components/actions/workflows/deploy.yml)
|
|
7
7
|
|
|
8
|
+
| [Examples](https://playcanvas.github.io/web-components/examples) | [API Reference](https://api.playcanvas.com/modules/EngineWebComponents.html) | [Forum](https://forum.playcanvas.com/) | [Discord](https://discord.gg/RSaMRzg) |
|
|
9
|
+
|
|
8
10
|
PlayCanvas Web Components are a set of custom HTML elements for building 3D interactive web apps. Using the declarative nature of HTML makes it both easy and fun to incorporate 3D into your website.
|
|
9
11
|
|
|
10
12
|
```html
|
|
@@ -32,24 +34,53 @@ See PlayCanvas Web Components in action here: https://playcanvas.github.io/web-c
|
|
|
32
34
|
|
|
33
35
|
## Usage 🚧
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
### Installing from NPM
|
|
38
|
+
|
|
39
|
+
PlayCanvas Web Components is available as a package on [NPM](https://www.npmjs.com/package/@playcanvas/web-components).
|
|
40
|
+
You can install it (and the PlayCanvas Engine) as follows:
|
|
36
41
|
|
|
37
42
|
```bash
|
|
38
43
|
npm install playcanvas @playcanvas/web-components --save-dev
|
|
39
44
|
```
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
Next, in your HTML file, you will need an import map because the web components need to be able to find the PlayCanvas Engine (which is an external dependency):
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<script type="importmap">
|
|
50
|
+
{
|
|
51
|
+
"imports": {
|
|
52
|
+
"playcanvas": "/node_modules/playcanvas/build/playcanvas.mjs"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
You can then import the components as follows:
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<script type="module" src="/node_modules/@playcanvas/web-components/dist/pwc.mjs"></script>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
You can now incorporate any of the PlayCanvas Web Components elements into your HTML!
|
|
65
|
+
|
|
66
|
+
### Using a CDN
|
|
42
67
|
|
|
43
|
-
|
|
68
|
+
Instead of loading the library from a local package, you can instead opt to load it from a CDN (such as jsDelivr). In this case, you would update the import map:
|
|
44
69
|
|
|
45
70
|
```html
|
|
46
|
-
<script type="
|
|
71
|
+
<script type="importmap">
|
|
72
|
+
{
|
|
73
|
+
"imports": {
|
|
74
|
+
"playcanvas": "https://cdn.jsdelivr.net/npm/playcanvas@2.3.3/build/playcanvas.mjs"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
47
78
|
```
|
|
48
79
|
|
|
49
|
-
|
|
80
|
+
And the components would now be imported as follows:
|
|
50
81
|
|
|
51
82
|
```html
|
|
52
|
-
<script src="https://cdn.jsdelivr.net/npm/@playcanvas/web-components@0.1.
|
|
83
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@playcanvas/web-components@0.1.10/dist/pwc.mjs"></script>
|
|
53
84
|
```
|
|
54
85
|
|
|
55
86
|
## Tag Reference 📖
|
|
@@ -114,6 +145,7 @@ The `pc-camera` tag is used to define a camera component. It must be a direct ch
|
|
|
114
145
|
| `flip-faces` | Boolean attribute. Controls whether the camera flips faces. If unspecified, faces are not flipped. |
|
|
115
146
|
| `fov` | The field of view of the camera. If unspecified, `45` is used. |
|
|
116
147
|
| `frustum-culling` | Boolean attribute. Controls whether the camera uses frustum culling. If unspecified, frustum culling is used. |
|
|
148
|
+
| `horizontal-fov` | Valueless attribute. If present, the camera uses a horizontal field of view. If unspecified, the camera uses a vertical field of view. |
|
|
117
149
|
| `near-clip` | The near clipping plane of the camera. If unspecified, `0.1` is used. |
|
|
118
150
|
| `orthographic` | Valueless attribute. If present, the camera uses an orthographic projection. If unspecified, the camera uses a perspective projection. |
|
|
119
151
|
| `ortho-height` | The height of the orthographic projection. If unspecified, `10` is used. |
|
package/dist/app.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ declare class AppElement extends AsyncElement {
|
|
|
14
14
|
private _stencil;
|
|
15
15
|
private _highResolution;
|
|
16
16
|
private _hierarchyReady;
|
|
17
|
+
private _picker;
|
|
18
|
+
private _hasPointerListeners;
|
|
19
|
+
private _hoveredEntity;
|
|
20
|
+
private _pointerHandlers;
|
|
17
21
|
/**
|
|
18
22
|
* The PlayCanvas application instance.
|
|
19
23
|
*/
|
|
@@ -27,6 +31,13 @@ declare class AppElement extends AsyncElement {
|
|
|
27
31
|
connectedCallback(): Promise<void>;
|
|
28
32
|
disconnectedCallback(): void;
|
|
29
33
|
_onWindowResize(): void;
|
|
34
|
+
_pickerCreate(): void;
|
|
35
|
+
_pickerDestroy(): void;
|
|
36
|
+
_onPointerMove(event: PointerEvent): void;
|
|
37
|
+
_onPointerDown(event: PointerEvent): void;
|
|
38
|
+
_onPointerUp(event: PointerEvent): void;
|
|
39
|
+
_onPointerListenerAdded(type: string): void;
|
|
40
|
+
_onPointerListenerRemoved(type: string): void;
|
|
30
41
|
/**
|
|
31
42
|
* Sets the alpha flag.
|
|
32
43
|
* @param value - The alpha flag.
|
|
@@ -17,12 +17,15 @@ declare class CameraComponentElement extends ComponentElement {
|
|
|
17
17
|
private _flipFaces;
|
|
18
18
|
private _fov;
|
|
19
19
|
private _frustumCulling;
|
|
20
|
+
private _gamma;
|
|
21
|
+
private _horizontalFov;
|
|
20
22
|
private _nearClip;
|
|
21
23
|
private _orthographic;
|
|
22
24
|
private _orthoHeight;
|
|
23
25
|
private _priority;
|
|
24
26
|
private _rect;
|
|
25
27
|
private _scissorRect;
|
|
28
|
+
private _tonemap;
|
|
26
29
|
/** @ignore */
|
|
27
30
|
constructor();
|
|
28
31
|
getInitialComponentData(): {
|
|
@@ -35,12 +38,15 @@ declare class CameraComponentElement extends ComponentElement {
|
|
|
35
38
|
flipFaces: boolean;
|
|
36
39
|
fov: number;
|
|
37
40
|
frustumCulling: boolean;
|
|
41
|
+
gammaCorrection: number;
|
|
42
|
+
horizontalFov: boolean;
|
|
38
43
|
nearClip: number;
|
|
39
44
|
orthographic: boolean;
|
|
40
45
|
orthoHeight: number;
|
|
41
46
|
priority: number;
|
|
42
47
|
rect: Vec4;
|
|
43
48
|
scissorRect: Vec4;
|
|
49
|
+
toneMapping: number | undefined;
|
|
44
50
|
};
|
|
45
51
|
get xrAvailable(): boolean | null | undefined;
|
|
46
52
|
startXr(type: 'immersive-ar' | 'immersive-vr', space: 'bounded-floor' | 'local' | 'local-floor' | 'unbounded' | 'viewer'): void;
|
|
@@ -140,6 +146,27 @@ declare class CameraComponentElement extends ComponentElement {
|
|
|
140
146
|
* @returns The frustum culling.
|
|
141
147
|
*/
|
|
142
148
|
get frustumCulling(): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Sets the gamma correction of the camera.
|
|
151
|
+
* @param value - The gamma correction.
|
|
152
|
+
*/
|
|
153
|
+
set gamma(value: 'none' | 'srgb');
|
|
154
|
+
/**
|
|
155
|
+
* Gets the gamma correction of the camera.
|
|
156
|
+
* @returns The gamma correction.
|
|
157
|
+
*/
|
|
158
|
+
get gamma(): 'none' | 'srgb';
|
|
159
|
+
/**
|
|
160
|
+
* Sets whether the camera's field of view (fov) is horizontal or vertical. Defaults to false
|
|
161
|
+
* (meaning it is vertical be default).
|
|
162
|
+
* @param value - Whether the camera's field of view is horizontal.
|
|
163
|
+
*/
|
|
164
|
+
set horizontalFov(value: boolean);
|
|
165
|
+
/**
|
|
166
|
+
* Gets whether the camera's field of view (fov) is horizontal or vertical.
|
|
167
|
+
* @returns Whether the camera's field of view is horizontal.
|
|
168
|
+
*/
|
|
169
|
+
get horizontalFov(): boolean;
|
|
143
170
|
/**
|
|
144
171
|
* Sets the near clip distance of the camera.
|
|
145
172
|
* @param value - The near clip distance.
|
|
@@ -200,6 +227,16 @@ declare class CameraComponentElement extends ComponentElement {
|
|
|
200
227
|
* @returns The scissor rect.
|
|
201
228
|
*/
|
|
202
229
|
get scissorRect(): Vec4;
|
|
230
|
+
/**
|
|
231
|
+
* Sets the tone mapping of the camera.
|
|
232
|
+
* @param value - The tone mapping.
|
|
233
|
+
*/
|
|
234
|
+
set tonemap(value: 'none' | 'linear' | 'filmic' | 'hejl' | 'aces' | 'aces2' | 'neutral');
|
|
235
|
+
/**
|
|
236
|
+
* Gets the tone mapping of the camera.
|
|
237
|
+
* @returns The tone mapping.
|
|
238
|
+
*/
|
|
239
|
+
get tonemap(): 'none' | 'linear' | 'filmic' | 'hejl' | 'aces' | 'aces2' | 'neutral';
|
|
203
240
|
static get observedAttributes(): string[];
|
|
204
241
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
205
242
|
}
|
|
@@ -17,8 +17,11 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
17
17
|
private _range;
|
|
18
18
|
private _shadowBias;
|
|
19
19
|
private _shadowDistance;
|
|
20
|
+
private _shadowIntensity;
|
|
20
21
|
private _shadowResolution;
|
|
22
|
+
private _shadowType;
|
|
21
23
|
private _type;
|
|
24
|
+
private _vsmBias;
|
|
22
25
|
/** @ignore */
|
|
23
26
|
constructor();
|
|
24
27
|
getInitialComponentData(): {
|
|
@@ -31,8 +34,11 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
31
34
|
range: number;
|
|
32
35
|
shadowBias: number;
|
|
33
36
|
shadowDistance: number;
|
|
37
|
+
shadowIntensity: number;
|
|
34
38
|
shadowResolution: number;
|
|
39
|
+
shadowType: number | undefined;
|
|
35
40
|
type: string;
|
|
41
|
+
vsmBias: number;
|
|
36
42
|
};
|
|
37
43
|
/**
|
|
38
44
|
* Gets the light component.
|
|
@@ -129,6 +135,16 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
129
135
|
* @returns The shadow distance.
|
|
130
136
|
*/
|
|
131
137
|
get shadowDistance(): number;
|
|
138
|
+
/**
|
|
139
|
+
* Sets the shadow intensity of the light.
|
|
140
|
+
* @param value - The shadow intensity.
|
|
141
|
+
*/
|
|
142
|
+
set shadowIntensity(value: number);
|
|
143
|
+
/**
|
|
144
|
+
* Gets the shadow intensity of the light.
|
|
145
|
+
* @returns The shadow intensity.
|
|
146
|
+
*/
|
|
147
|
+
get shadowIntensity(): number;
|
|
132
148
|
/**
|
|
133
149
|
* Sets the shadow resolution of the light.
|
|
134
150
|
* @param value - The shadow resolution.
|
|
@@ -139,6 +155,26 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
139
155
|
* @returns The shadow resolution.
|
|
140
156
|
*/
|
|
141
157
|
get shadowResolution(): number;
|
|
158
|
+
/**
|
|
159
|
+
* Sets the shadow type of the light.
|
|
160
|
+
* @param value - The shadow type. Can be:
|
|
161
|
+
*
|
|
162
|
+
* - `pcf1-16f` - 1-tap percentage-closer filtered shadow map with 16-bit depth.
|
|
163
|
+
* - `pcf1-32f` - 1-tap percentage-closer filtered shadow map with 32-bit depth.
|
|
164
|
+
* - `pcf3-16f` - 3-tap percentage-closer filtered shadow map with 16-bit depth.
|
|
165
|
+
* - `pcf3-32f` - 3-tap percentage-closer filtered shadow map with 32-bit depth.
|
|
166
|
+
* - `pcf5-16f` - 5-tap percentage-closer filtered shadow map with 16-bit depth.
|
|
167
|
+
* - `pcf5-32f` - 5-tap percentage-closer filtered shadow map with 32-bit depth.
|
|
168
|
+
* - `vsm-16f` - Variance shadow map with 16-bit depth.
|
|
169
|
+
* - `vsm-32f` - Variance shadow map with 32-bit depth.
|
|
170
|
+
* - `pcss-32f` - Percentage-closer soft shadow with 32-bit depth.
|
|
171
|
+
*/
|
|
172
|
+
set shadowType(value: 'pcf1-16f' | 'pcf1-32f' | 'pcf3-16f' | 'pcf3-32f' | 'pcf5-16f' | 'pcf5-32f' | 'vsm-16f' | 'vsm-32f' | 'pcss-32f');
|
|
173
|
+
/**
|
|
174
|
+
* Gets the shadow type of the light.
|
|
175
|
+
* @returns The shadow type.
|
|
176
|
+
*/
|
|
177
|
+
get shadowType(): "pcf1-16f" | "pcf1-32f" | "pcf3-16f" | "pcf3-32f" | "pcf5-16f" | "pcf5-32f" | "vsm-16f" | "vsm-32f" | "pcss-32f";
|
|
142
178
|
/**
|
|
143
179
|
* Sets the type of the light.
|
|
144
180
|
* @param value - The type.
|
|
@@ -149,6 +185,16 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
149
185
|
* @returns The type.
|
|
150
186
|
*/
|
|
151
187
|
get type(): string;
|
|
188
|
+
/**
|
|
189
|
+
* Sets the VSM bias of the light.
|
|
190
|
+
* @param value - The VSM bias.
|
|
191
|
+
*/
|
|
192
|
+
set vsmBias(value: number);
|
|
193
|
+
/**
|
|
194
|
+
* Gets the VSM bias of the light.
|
|
195
|
+
* @returns The VSM bias.
|
|
196
|
+
*/
|
|
197
|
+
get vsmBias(): number;
|
|
152
198
|
static get observedAttributes(): string[];
|
|
153
199
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
154
200
|
}
|
|
@@ -18,7 +18,7 @@ declare class SoundComponentElement extends ComponentElement {
|
|
|
18
18
|
/** @ignore */
|
|
19
19
|
constructor();
|
|
20
20
|
getInitialComponentData(): {
|
|
21
|
-
distanceModel: "
|
|
21
|
+
distanceModel: "linear" | "exponential" | "inverse";
|
|
22
22
|
maxDistance: number;
|
|
23
23
|
pitch: number;
|
|
24
24
|
positional: boolean;
|
package/dist/entity.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ declare class EntityElement extends AsyncElement {
|
|
|
30
30
|
* The tags of the entity.
|
|
31
31
|
*/
|
|
32
32
|
private _tags;
|
|
33
|
+
/**
|
|
34
|
+
* The pointer event listeners for the entity.
|
|
35
|
+
*/
|
|
36
|
+
private _listeners;
|
|
33
37
|
/**
|
|
34
38
|
* The PlayCanvas entity instance.
|
|
35
39
|
*/
|
|
@@ -100,5 +104,8 @@ declare class EntityElement extends AsyncElement {
|
|
|
100
104
|
get tags(): string[];
|
|
101
105
|
static get observedAttributes(): string[];
|
|
102
106
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
107
|
+
addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
|
|
108
|
+
removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void;
|
|
109
|
+
hasListeners(type: string): boolean;
|
|
103
110
|
}
|
|
104
111
|
export { EntityElement };
|
package/dist/fog.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Color } from 'playcanvas';
|
|
2
|
+
/**
|
|
3
|
+
* The FogElement interface provides properties and methods for manipulating
|
|
4
|
+
* `<pc-fog>` elements. The FogElement interface also inherits the properties and
|
|
5
|
+
* methods of the {@link HTMLElement} interface.
|
|
6
|
+
*/
|
|
7
|
+
declare class FogElement extends HTMLElement {
|
|
8
|
+
private _color;
|
|
9
|
+
private _density;
|
|
10
|
+
private _end;
|
|
11
|
+
private _start;
|
|
12
|
+
private _type;
|
|
13
|
+
private dispatchFogUpdate;
|
|
14
|
+
set color(value: Color);
|
|
15
|
+
get color(): Color;
|
|
16
|
+
set density(value: number);
|
|
17
|
+
get density(): number;
|
|
18
|
+
set end(value: number);
|
|
19
|
+
get end(): number;
|
|
20
|
+
set start(value: number);
|
|
21
|
+
get start(): number;
|
|
22
|
+
set type(value: 'linear' | 'exp' | 'exp2');
|
|
23
|
+
get type(): 'linear' | 'exp' | 'exp2';
|
|
24
|
+
static get observedAttributes(): string[];
|
|
25
|
+
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
26
|
+
constructor();
|
|
27
|
+
}
|
|
28
|
+
export { FogElement };
|