@playcanvas/web-components 0.2.5 → 0.2.7
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 +1 -1
- package/dist/app.d.ts +14 -3
- package/dist/asset.d.ts +1 -1
- package/dist/components/camera-component.d.ts +3 -3
- package/dist/components/collision-component.d.ts +1 -1
- package/dist/components/element-component.d.ts +1 -1
- package/dist/components/light-component.d.ts +2 -2
- package/dist/components/listener-component.d.ts +1 -1
- package/dist/components/particlesystem-component.d.ts +1 -1
- package/dist/components/render-component.d.ts +1 -1
- package/dist/components/rigidbody-component.d.ts +1 -1
- package/dist/components/screen-component.d.ts +2 -2
- package/dist/components/script-component.d.ts +1 -1
- package/dist/components/sound-component.d.ts +1 -1
- package/dist/components/splat-component.d.ts +13 -1
- package/dist/entity.d.ts +4 -4
- package/dist/material.d.ts +1 -1
- package/dist/model.d.ts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/pwc.cjs +155 -46
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +155 -46
- 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 +156 -47
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +1 -1
- package/package.json +16 -16
- package/src/app.ts +170 -15
- package/src/asset.ts +2 -1
- package/src/components/camera-component.ts +1 -1
- package/src/components/collision-component.ts +1 -1
- package/src/components/element-component.ts +1 -1
- package/src/components/light-component.ts +1 -1
- package/src/components/listener-component.ts +1 -1
- package/src/components/particlesystem-component.ts +1 -1
- package/src/components/render-component.ts +1 -1
- package/src/components/rigidbody-component.ts +1 -1
- package/src/components/screen-component.ts +1 -1
- package/src/components/script-component.ts +1 -1
- package/src/components/sound-component.ts +1 -1
- package/src/components/sound-slot.ts +3 -0
- package/src/components/splat-component.ts +33 -4
- package/src/entity.ts +4 -4
- package/src/material.ts +1 -1
- package/src/model.ts +1 -1
- package/src/module.ts +7 -14
- package/src/scene.ts +1 -1
package/dist/scene.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Color, Scene, Vec3 } from 'playcanvas';
|
|
|
2
2
|
import { AsyncElement } from './async-element';
|
|
3
3
|
/**
|
|
4
4
|
* The SceneElement interface provides properties and methods for manipulating
|
|
5
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
5
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scene/ | `<pc-scene>`} elements.
|
|
6
6
|
* The SceneElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcanvas/web-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"author": "PlayCanvas <support@playcanvas.com>",
|
|
5
5
|
"homepage": "https://playcanvas.com",
|
|
6
6
|
"description": "Web Components for the PlayCanvas Engine",
|
|
@@ -38,27 +38,27 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@mediapipe/tasks-vision": "0.10.21",
|
|
41
|
-
"@playcanvas/eslint-config": "2.0
|
|
42
|
-
"@rollup/plugin-commonjs": "28.0.
|
|
41
|
+
"@playcanvas/eslint-config": "2.1.0",
|
|
42
|
+
"@rollup/plugin-commonjs": "28.0.6",
|
|
43
43
|
"@rollup/plugin-node-resolve": "16.0.1",
|
|
44
44
|
"@rollup/plugin-terser": "0.4.4",
|
|
45
|
-
"@rollup/plugin-typescript": "12.1.
|
|
45
|
+
"@rollup/plugin-typescript": "12.1.3",
|
|
46
46
|
"@tweenjs/tween.js": "25.0.0",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
48
|
-
"@typescript-eslint/parser": "8.
|
|
49
|
-
"concurrently": "9.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "8.35.0",
|
|
48
|
+
"@typescript-eslint/parser": "8.35.0",
|
|
49
|
+
"concurrently": "9.2.0",
|
|
50
50
|
"earcut": "3.0.1",
|
|
51
|
-
"eslint": "9.
|
|
52
|
-
"eslint-import-resolver-typescript": "4.
|
|
53
|
-
"globals": "16.
|
|
54
|
-
"mp4-muxer": "5.2.
|
|
51
|
+
"eslint": "9.29.0",
|
|
52
|
+
"eslint-import-resolver-typescript": "4.4.4",
|
|
53
|
+
"globals": "16.2.0",
|
|
54
|
+
"mp4-muxer": "5.2.1",
|
|
55
55
|
"opentype.js": "1.3.4",
|
|
56
|
-
"playcanvas": "2.
|
|
57
|
-
"rollup": "4.
|
|
56
|
+
"playcanvas": "2.8.2",
|
|
57
|
+
"rollup": "4.44.0",
|
|
58
58
|
"serve": "14.2.4",
|
|
59
59
|
"tslib": "2.8.1",
|
|
60
|
-
"typedoc": "0.28.
|
|
61
|
-
"typedoc-plugin-mdn-links": "5.0.
|
|
62
|
-
"typescript": "5.8.
|
|
60
|
+
"typedoc": "0.28.5",
|
|
61
|
+
"typedoc-plugin-mdn-links": "5.0.2",
|
|
62
|
+
"typescript": "5.8.3"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/src/app.ts
CHANGED
|
@@ -1,4 +1,67 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AppBase,
|
|
3
|
+
AppOptions,
|
|
4
|
+
CameraComponent,
|
|
5
|
+
createGraphicsDevice,
|
|
6
|
+
FILLMODE_FILL_WINDOW,
|
|
7
|
+
GraphNode,
|
|
8
|
+
Keyboard,
|
|
9
|
+
Mouse,
|
|
10
|
+
Picker,
|
|
11
|
+
RESOLUTION_AUTO,
|
|
12
|
+
AnimComponentSystem,
|
|
13
|
+
AnimationComponentSystem,
|
|
14
|
+
AudioListenerComponentSystem,
|
|
15
|
+
ButtonComponentSystem,
|
|
16
|
+
CameraComponentSystem,
|
|
17
|
+
CollisionComponentSystem,
|
|
18
|
+
ElementComponentSystem,
|
|
19
|
+
GSplatComponentSystem,
|
|
20
|
+
JointComponentSystem,
|
|
21
|
+
LayoutChildComponentSystem,
|
|
22
|
+
LayoutGroupComponentSystem,
|
|
23
|
+
LightComponentSystem,
|
|
24
|
+
ModelComponentSystem,
|
|
25
|
+
ParticleSystemComponentSystem,
|
|
26
|
+
RenderComponentSystem,
|
|
27
|
+
RigidBodyComponentSystem,
|
|
28
|
+
ScriptComponentSystem,
|
|
29
|
+
ScreenComponentSystem,
|
|
30
|
+
ScrollbarComponentSystem,
|
|
31
|
+
ScrollViewComponentSystem,
|
|
32
|
+
SoundComponentSystem,
|
|
33
|
+
SpriteComponentSystem,
|
|
34
|
+
ZoneComponentSystem,
|
|
35
|
+
RenderHandler,
|
|
36
|
+
AnimationHandler,
|
|
37
|
+
AnimClipHandler,
|
|
38
|
+
AnimStateGraphHandler,
|
|
39
|
+
AudioHandler,
|
|
40
|
+
BinaryHandler,
|
|
41
|
+
ContainerHandler,
|
|
42
|
+
CssHandler,
|
|
43
|
+
CubemapHandler,
|
|
44
|
+
FolderHandler,
|
|
45
|
+
FontHandler,
|
|
46
|
+
GSplatHandler,
|
|
47
|
+
HierarchyHandler,
|
|
48
|
+
HtmlHandler,
|
|
49
|
+
JsonHandler,
|
|
50
|
+
MaterialHandler,
|
|
51
|
+
ModelHandler,
|
|
52
|
+
SceneHandler,
|
|
53
|
+
ScriptHandler,
|
|
54
|
+
ShaderHandler,
|
|
55
|
+
SpriteHandler,
|
|
56
|
+
TemplateHandler,
|
|
57
|
+
TextHandler,
|
|
58
|
+
TextureHandler,
|
|
59
|
+
TextureAtlasHandler,
|
|
60
|
+
BatchManager,
|
|
61
|
+
SoundManager,
|
|
62
|
+
Lightmapper,
|
|
63
|
+
XrManager
|
|
64
|
+
} from 'playcanvas';
|
|
2
65
|
|
|
3
66
|
import { AssetElement } from './asset';
|
|
4
67
|
import { AsyncElement } from './async-element';
|
|
@@ -8,7 +71,7 @@ import { ModuleElement } from './module';
|
|
|
8
71
|
|
|
9
72
|
/**
|
|
10
73
|
* The AppElement interface provides properties and methods for manipulating
|
|
11
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
74
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-app/ | `<pc-app>`} elements.
|
|
12
75
|
* The AppElement interface also inherits the properties and methods of the
|
|
13
76
|
* {@link HTMLElement} interface.
|
|
14
77
|
*/
|
|
@@ -20,6 +83,8 @@ class AppElement extends AsyncElement {
|
|
|
20
83
|
|
|
21
84
|
private _alpha = true;
|
|
22
85
|
|
|
86
|
+
private _backend: 'webgpu' | 'webgl2' | 'null' = 'webgl2';
|
|
87
|
+
|
|
23
88
|
private _antialias = true;
|
|
24
89
|
|
|
25
90
|
private _depth = true;
|
|
@@ -51,7 +116,7 @@ class AppElement extends AsyncElement {
|
|
|
51
116
|
/**
|
|
52
117
|
* The PlayCanvas application instance.
|
|
53
118
|
*/
|
|
54
|
-
app:
|
|
119
|
+
app: AppBase | null = null;
|
|
55
120
|
|
|
56
121
|
/**
|
|
57
122
|
* Creates a new AppElement instance.
|
|
@@ -76,18 +141,87 @@ class AppElement extends AsyncElement {
|
|
|
76
141
|
this._canvas = document.createElement('canvas');
|
|
77
142
|
this.appendChild(this._canvas);
|
|
78
143
|
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
144
|
+
// Configure device types based on backend selection
|
|
145
|
+
const backendToDeviceTypes: { [key: string]: string[] } = {
|
|
146
|
+
webgpu: ['webgpu', 'webgl2'], // fallback to webgl2 if webgpu not available
|
|
147
|
+
webgl2: ['webgl2'],
|
|
148
|
+
null: ['null']
|
|
149
|
+
};
|
|
150
|
+
const deviceTypes = backendToDeviceTypes[this._backend] || [];
|
|
151
|
+
|
|
152
|
+
const device = await createGraphicsDevice(this._canvas, {
|
|
153
|
+
// @ts-ignore - alpha needs to be documented
|
|
154
|
+
alpha: this._alpha,
|
|
155
|
+
antialias: this._antialias,
|
|
156
|
+
depth: this._depth,
|
|
157
|
+
deviceTypes: deviceTypes,
|
|
158
|
+
stencil: this._stencil
|
|
89
159
|
});
|
|
90
|
-
|
|
160
|
+
device.maxPixelRatio = this._highResolution ? window.devicePixelRatio : 1;
|
|
161
|
+
|
|
162
|
+
const createOptions = new AppOptions();
|
|
163
|
+
createOptions.graphicsDevice = device;
|
|
164
|
+
createOptions.keyboard = new Keyboard(window);
|
|
165
|
+
createOptions.mouse = new Mouse(this._canvas);
|
|
166
|
+
createOptions.componentSystems = [
|
|
167
|
+
AnimComponentSystem,
|
|
168
|
+
AnimationComponentSystem,
|
|
169
|
+
AudioListenerComponentSystem,
|
|
170
|
+
ButtonComponentSystem,
|
|
171
|
+
CameraComponentSystem,
|
|
172
|
+
CollisionComponentSystem,
|
|
173
|
+
ElementComponentSystem,
|
|
174
|
+
GSplatComponentSystem,
|
|
175
|
+
JointComponentSystem,
|
|
176
|
+
LayoutChildComponentSystem,
|
|
177
|
+
LayoutGroupComponentSystem,
|
|
178
|
+
LightComponentSystem,
|
|
179
|
+
ModelComponentSystem,
|
|
180
|
+
ParticleSystemComponentSystem,
|
|
181
|
+
RenderComponentSystem,
|
|
182
|
+
RigidBodyComponentSystem,
|
|
183
|
+
ScreenComponentSystem,
|
|
184
|
+
ScriptComponentSystem,
|
|
185
|
+
ScrollbarComponentSystem,
|
|
186
|
+
ScrollViewComponentSystem,
|
|
187
|
+
SoundComponentSystem,
|
|
188
|
+
SpriteComponentSystem,
|
|
189
|
+
ZoneComponentSystem
|
|
190
|
+
];
|
|
191
|
+
createOptions.resourceHandlers = [
|
|
192
|
+
AnimClipHandler,
|
|
193
|
+
AnimationHandler,
|
|
194
|
+
AnimStateGraphHandler,
|
|
195
|
+
AudioHandler,
|
|
196
|
+
BinaryHandler,
|
|
197
|
+
CssHandler,
|
|
198
|
+
ContainerHandler,
|
|
199
|
+
CubemapHandler,
|
|
200
|
+
FolderHandler,
|
|
201
|
+
FontHandler,
|
|
202
|
+
GSplatHandler,
|
|
203
|
+
HierarchyHandler,
|
|
204
|
+
HtmlHandler,
|
|
205
|
+
JsonHandler,
|
|
206
|
+
MaterialHandler,
|
|
207
|
+
ModelHandler,
|
|
208
|
+
RenderHandler,
|
|
209
|
+
ScriptHandler,
|
|
210
|
+
SceneHandler,
|
|
211
|
+
ShaderHandler,
|
|
212
|
+
SpriteHandler,
|
|
213
|
+
TemplateHandler,
|
|
214
|
+
TextHandler,
|
|
215
|
+
TextureAtlasHandler,
|
|
216
|
+
TextureHandler
|
|
217
|
+
];
|
|
218
|
+
createOptions.soundManager = new SoundManager();
|
|
219
|
+
createOptions.lightmapper = Lightmapper;
|
|
220
|
+
createOptions.batchManager = BatchManager;
|
|
221
|
+
createOptions.xr = XrManager;
|
|
222
|
+
|
|
223
|
+
this.app = new AppBase(this._canvas);
|
|
224
|
+
this.app.init(createOptions);
|
|
91
225
|
|
|
92
226
|
this.app.setCanvasFillMode(FILLMODE_FILL_WINDOW);
|
|
93
227
|
this.app.setCanvasResolution(RESOLUTION_AUTO);
|
|
@@ -360,6 +494,22 @@ class AppElement extends AsyncElement {
|
|
|
360
494
|
return this._antialias;
|
|
361
495
|
}
|
|
362
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Sets the graphics backend.
|
|
499
|
+
* @param value - The graphics backend ('webgpu', 'webgl2', or 'null').
|
|
500
|
+
*/
|
|
501
|
+
set backend(value: 'webgpu' | 'webgl2' | 'null') {
|
|
502
|
+
this._backend = value;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Gets the graphics backend.
|
|
507
|
+
* @returns The graphics backend.
|
|
508
|
+
*/
|
|
509
|
+
get backend() {
|
|
510
|
+
return this._backend;
|
|
511
|
+
}
|
|
512
|
+
|
|
363
513
|
/**
|
|
364
514
|
* Sets the depth flag.
|
|
365
515
|
* @param value - The depth flag.
|
|
@@ -422,7 +572,7 @@ class AppElement extends AsyncElement {
|
|
|
422
572
|
}
|
|
423
573
|
|
|
424
574
|
static get observedAttributes() {
|
|
425
|
-
return ['alpha', 'antialias', 'depth', 'stencil', 'high-resolution'];
|
|
575
|
+
return ['alpha', 'antialias', 'backend', 'depth', 'stencil', 'high-resolution'];
|
|
426
576
|
}
|
|
427
577
|
|
|
428
578
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
|
|
@@ -433,6 +583,11 @@ class AppElement extends AsyncElement {
|
|
|
433
583
|
case 'antialias':
|
|
434
584
|
this.antialias = newValue !== 'false';
|
|
435
585
|
break;
|
|
586
|
+
case 'backend':
|
|
587
|
+
if (newValue === 'webgpu' || newValue === 'webgl2' || newValue === 'null') {
|
|
588
|
+
this.backend = newValue;
|
|
589
|
+
}
|
|
590
|
+
break;
|
|
436
591
|
case 'depth':
|
|
437
592
|
this.depth = newValue !== 'false';
|
|
438
593
|
break;
|
package/src/asset.ts
CHANGED
|
@@ -63,7 +63,7 @@ const processBufferView = (
|
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* The AssetElement interface provides properties and methods for manipulating
|
|
66
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
66
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/ | `<pc-asset>`} elements.
|
|
67
67
|
* The AssetElement interface also inherits the properties and methods of the
|
|
68
68
|
* {@link HTMLElement} interface.
|
|
69
69
|
*/
|
|
@@ -103,6 +103,7 @@ class AssetElement extends HTMLElement {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
} else {
|
|
106
|
+
// @ts-ignore
|
|
106
107
|
this.asset = new Asset(id, type, { url: src });
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -15,7 +15,7 @@ const tonemaps = new Map([
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* The CameraComponentElement interface provides properties and methods for manipulating
|
|
18
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
18
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-camera/ | `<pc-camera>`} elements.
|
|
19
19
|
* The CameraComponentElement interface also inherits the properties and methods of the
|
|
20
20
|
* {@link HTMLElement} interface.
|
|
21
21
|
*
|
|
@@ -5,7 +5,7 @@ import { parseQuat, parseVec3 } from '../utils';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The CollisionComponentElement interface provides properties and methods for manipulating
|
|
8
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
8
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-collision/ | `<pc-collision>`} elements.
|
|
9
9
|
* The CollisionComponentElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
11
|
*
|
|
@@ -6,7 +6,7 @@ import { parseColor, parseVec2, parseVec4 } from '../utils';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The ElementComponentElement interface provides properties and methods for manipulating
|
|
9
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
9
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-element/ | `<pc-element>`} elements.
|
|
10
10
|
* The ElementComponentElement interface also inherits the properties and methods of the
|
|
11
11
|
* {@link HTMLElement} interface.
|
|
12
12
|
*
|
|
@@ -17,7 +17,7 @@ const shadowTypes = new Map([
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The LightComponentElement interface provides properties and methods for manipulating
|
|
20
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
20
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-light/ | `<pc-light>`} elements.
|
|
21
21
|
* The LightComponentElement interface also inherits the properties and methods of the
|
|
22
22
|
* {@link HTMLElement} interface.
|
|
23
23
|
*
|
|
@@ -4,7 +4,7 @@ import { ComponentElement } from './component';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The ListenerComponentElement interface provides properties and methods for manipulating
|
|
7
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
7
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-listener/ | `<pc-listener>`} elements.
|
|
8
8
|
* The ListenerComponentElement interface also inherits the properties and methods of the
|
|
9
9
|
* {@link HTMLElement} interface.
|
|
10
10
|
*
|
|
@@ -5,7 +5,7 @@ import { AssetElement } from '../asset';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The ParticleSystemComponentElement interface provides properties and methods for manipulating
|
|
8
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
8
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-particles/ | `<pc-particles>`} elements.
|
|
9
9
|
* The ParticleSystemComponentElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@ import { MaterialElement } from '../material';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The RenderComponentElement interface provides properties and methods for manipulating
|
|
8
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
8
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-render/ | `<pc-render>`} elements.
|
|
9
9
|
* The RenderComponentElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@ import { parseVec3 } from '../utils';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The RigidBodyComponentElement interface provides properties and methods for manipulating
|
|
8
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
8
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-rigidbody/ | `<pc-rigidbody>`} elements.
|
|
9
9
|
* The RigidBodyComponentElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
11
|
*
|
|
@@ -5,7 +5,7 @@ import { parseVec2 } from '../utils';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The ScreenComponentElement interface provides properties and methods for manipulating
|
|
8
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
8
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-screen/ | `<pc-screen>`} elements.
|
|
9
9
|
* The ScreenComponentElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
11
|
*
|
|
@@ -24,7 +24,7 @@ declare global {
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* The ScriptComponentElement interface provides properties and methods for manipulating
|
|
27
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
27
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scripts/ | `<pc-scripts>`} elements.
|
|
28
28
|
* The ScriptComponentElement interface also inherits the properties and methods of the
|
|
29
29
|
* {@link HTMLElement} interface.
|
|
30
30
|
*
|
|
@@ -4,7 +4,7 @@ import { ComponentElement } from './component';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The SoundComponentElement interface provides properties and methods for manipulating
|
|
7
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
7
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-sounds/ | `<pc-sounds>`} elements.
|
|
8
8
|
* The SoundComponentElement interface also inherits the properties and methods of the
|
|
9
9
|
* {@link HTMLElement} interface.
|
|
10
10
|
*
|
|
@@ -5,14 +5,16 @@ import { AssetElement } from '../asset';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The SplatComponentElement interface provides properties and methods for manipulating
|
|
8
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
8
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-splat/ | `<pc-splat>`} elements.
|
|
9
9
|
* The SplatComponentElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
11
|
*
|
|
12
12
|
* @category Components
|
|
13
13
|
*/
|
|
14
14
|
class SplatComponentElement extends ComponentElement {
|
|
15
|
-
private _asset
|
|
15
|
+
private _asset = '';
|
|
16
|
+
|
|
17
|
+
private _castShadows = false;
|
|
16
18
|
|
|
17
19
|
/** @ignore */
|
|
18
20
|
constructor() {
|
|
@@ -21,7 +23,8 @@ class SplatComponentElement extends ComponentElement {
|
|
|
21
23
|
|
|
22
24
|
getInitialComponentData() {
|
|
23
25
|
return {
|
|
24
|
-
asset: AssetElement.get(this._asset)
|
|
26
|
+
asset: AssetElement.get(this._asset),
|
|
27
|
+
castShadows: this._castShadows
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -53,8 +56,31 @@ class SplatComponentElement extends ComponentElement {
|
|
|
53
56
|
return this._asset;
|
|
54
57
|
}
|
|
55
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Sets whether the splat casts shadows.
|
|
61
|
+
* @param value - Whether the splat casts shadows.
|
|
62
|
+
*/
|
|
63
|
+
set castShadows(value: boolean) {
|
|
64
|
+
this._castShadows = value;
|
|
65
|
+
if (this.component) {
|
|
66
|
+
this.component.castShadows = value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Gets whether the splat casts shadows.
|
|
72
|
+
* @returns Whether the splat casts shadows.
|
|
73
|
+
*/
|
|
74
|
+
get castShadows() {
|
|
75
|
+
return this._castShadows;
|
|
76
|
+
}
|
|
77
|
+
|
|
56
78
|
static get observedAttributes() {
|
|
57
|
-
return [
|
|
79
|
+
return [
|
|
80
|
+
...super.observedAttributes,
|
|
81
|
+
'asset',
|
|
82
|
+
'cast-shadows'
|
|
83
|
+
];
|
|
58
84
|
}
|
|
59
85
|
|
|
60
86
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
|
|
@@ -64,6 +90,9 @@ class SplatComponentElement extends ComponentElement {
|
|
|
64
90
|
case 'asset':
|
|
65
91
|
this.asset = newValue;
|
|
66
92
|
break;
|
|
93
|
+
case 'cast-shadows':
|
|
94
|
+
this.castShadows = this.hasAttribute('cast-shadows');
|
|
95
|
+
break;
|
|
67
96
|
}
|
|
68
97
|
}
|
|
69
98
|
}
|
package/src/entity.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppBase, Entity, Vec3 } from 'playcanvas';
|
|
2
2
|
|
|
3
3
|
import { AsyncElement } from './async-element';
|
|
4
4
|
import { parseVec3 } from './utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The EntityElement interface provides properties and methods for manipulating
|
|
8
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
8
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/ | `<pc-entity>`} elements.
|
|
9
9
|
* The EntityElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
11
|
*/
|
|
@@ -50,7 +50,7 @@ class EntityElement extends AsyncElement {
|
|
|
50
50
|
*/
|
|
51
51
|
entity: Entity | null = null;
|
|
52
52
|
|
|
53
|
-
createEntity(app:
|
|
53
|
+
createEntity(app: AppBase) {
|
|
54
54
|
// Create a new entity
|
|
55
55
|
this.entity = new Entity(this.getAttribute('name') || this._name, app);
|
|
56
56
|
|
|
@@ -105,7 +105,7 @@ class EntityElement extends AsyncElement {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
buildHierarchy(app:
|
|
108
|
+
buildHierarchy(app: AppBase) {
|
|
109
109
|
if (!this.entity) return;
|
|
110
110
|
|
|
111
111
|
const closestEntity = this.closestEntity;
|
package/src/material.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { parseColor } from './utils';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The MaterialElement interface provides properties and methods for manipulating
|
|
8
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
8
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-material/ | `<pc-material>`} elements.
|
|
9
9
|
* The MaterialElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
11
|
*/
|
package/src/model.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { AsyncElement } from './async-element';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The ModelElement interface provides properties and methods for manipulating
|
|
8
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
8
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-model/ | `<pc-model>`} elements.
|
|
9
9
|
* The ModelElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
11
|
*/
|
package/src/module.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { basisInitialize, WasmModule } from 'playcanvas';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The ModuleElement interface provides properties and methods for manipulating
|
|
5
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
5
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-module/ | `<pc-module>`} elements.
|
|
6
6
|
* The ModuleElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*/
|
|
@@ -17,22 +17,15 @@ class ModuleElement extends HTMLElement {
|
|
|
17
17
|
|
|
18
18
|
private async loadModule(): Promise<void> {
|
|
19
19
|
const name = this.getAttribute('name')!;
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
20
|
+
const glueUrl = this.getAttribute('glue')!;
|
|
21
|
+
const wasmUrl = this.getAttribute('wasm')!;
|
|
22
|
+
const fallbackUrl = this.getAttribute('fallback')!;
|
|
23
|
+
const config = { glueUrl, wasmUrl, fallbackUrl };
|
|
23
24
|
|
|
24
25
|
if (name === 'Basis') {
|
|
25
|
-
basisInitialize(
|
|
26
|
-
glueUrl: glue,
|
|
27
|
-
wasmUrl: wasm,
|
|
28
|
-
fallbackUrl: fallback
|
|
29
|
-
});
|
|
26
|
+
basisInitialize(config);
|
|
30
27
|
} else {
|
|
31
|
-
WasmModule.setConfig(name,
|
|
32
|
-
glueUrl: glue,
|
|
33
|
-
wasmUrl: wasm,
|
|
34
|
-
fallbackUrl: fallback
|
|
35
|
-
});
|
|
28
|
+
WasmModule.setConfig(name, config);
|
|
36
29
|
|
|
37
30
|
await new Promise<void>((resolve) => {
|
|
38
31
|
WasmModule.getInstance(name, () => resolve());
|
package/src/scene.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { parseColor, parseVec3 } from './utils';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The SceneElement interface provides properties and methods for manipulating
|
|
9
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
9
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scene/ | `<pc-scene>`} elements.
|
|
10
10
|
* The SceneElement interface also inherits the properties and methods of the
|
|
11
11
|
* {@link HTMLElement} interface.
|
|
12
12
|
*/
|