@playcanvas/web-components 0.2.6 → 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -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 +120 -31
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +120 -31
- 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 +121 -32
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +1 -1
- package/package.json +14 -14
- package/src/app.ts +170 -15
- package/src/asset.ts +1 -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 +1 -1
- package/src/entity.ts +4 -4
- package/src/material.ts +1 -1
- package/src/model.ts +1 -1
- package/src/module.ts +1 -1
- package/src/scene.ts +1 -1
package/dist/pwc.js
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* The ModuleElement interface provides properties and methods for manipulating
|
|
45
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
45
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-module/ | `<pc-module>`} elements.
|
|
46
46
|
* The ModuleElement interface also inherits the properties and methods of the
|
|
47
47
|
* {@link HTMLElement} interface.
|
|
48
48
|
*/
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* The AppElement interface provides properties and methods for manipulating
|
|
79
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
79
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-app/ | `<pc-app>`} elements.
|
|
80
80
|
* The AppElement interface also inherits the properties and methods of the
|
|
81
81
|
* {@link HTMLElement} interface.
|
|
82
82
|
*/
|
|
@@ -93,6 +93,7 @@
|
|
|
93
93
|
*/
|
|
94
94
|
this._canvas = null;
|
|
95
95
|
this._alpha = true;
|
|
96
|
+
this._backend = 'webgl2';
|
|
96
97
|
this._antialias = true;
|
|
97
98
|
this._depth = true;
|
|
98
99
|
this._stencil = true;
|
|
@@ -127,18 +128,84 @@
|
|
|
127
128
|
// Create and append the canvas to the element
|
|
128
129
|
this._canvas = document.createElement('canvas');
|
|
129
130
|
this.appendChild(this._canvas);
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
// Configure device types based on backend selection
|
|
132
|
+
const backendToDeviceTypes = {
|
|
133
|
+
webgpu: ['webgpu', 'webgl2'], // fallback to webgl2 if webgpu not available
|
|
134
|
+
webgl2: ['webgl2'],
|
|
135
|
+
null: ['null']
|
|
136
|
+
};
|
|
137
|
+
const deviceTypes = backendToDeviceTypes[this._backend] || [];
|
|
138
|
+
const device = await playcanvas.createGraphicsDevice(this._canvas, {
|
|
139
|
+
// @ts-ignore - alpha needs to be documented
|
|
140
|
+
alpha: this._alpha,
|
|
141
|
+
antialias: this._antialias,
|
|
142
|
+
depth: this._depth,
|
|
143
|
+
deviceTypes: deviceTypes,
|
|
144
|
+
stencil: this._stencil
|
|
140
145
|
});
|
|
141
|
-
|
|
146
|
+
device.maxPixelRatio = this._highResolution ? window.devicePixelRatio : 1;
|
|
147
|
+
const createOptions = new playcanvas.AppOptions();
|
|
148
|
+
createOptions.graphicsDevice = device;
|
|
149
|
+
createOptions.keyboard = new playcanvas.Keyboard(window);
|
|
150
|
+
createOptions.mouse = new playcanvas.Mouse(this._canvas);
|
|
151
|
+
createOptions.componentSystems = [
|
|
152
|
+
playcanvas.AnimComponentSystem,
|
|
153
|
+
playcanvas.AnimationComponentSystem,
|
|
154
|
+
playcanvas.AudioListenerComponentSystem,
|
|
155
|
+
playcanvas.ButtonComponentSystem,
|
|
156
|
+
playcanvas.CameraComponentSystem,
|
|
157
|
+
playcanvas.CollisionComponentSystem,
|
|
158
|
+
playcanvas.ElementComponentSystem,
|
|
159
|
+
playcanvas.GSplatComponentSystem,
|
|
160
|
+
playcanvas.JointComponentSystem,
|
|
161
|
+
playcanvas.LayoutChildComponentSystem,
|
|
162
|
+
playcanvas.LayoutGroupComponentSystem,
|
|
163
|
+
playcanvas.LightComponentSystem,
|
|
164
|
+
playcanvas.ModelComponentSystem,
|
|
165
|
+
playcanvas.ParticleSystemComponentSystem,
|
|
166
|
+
playcanvas.RenderComponentSystem,
|
|
167
|
+
playcanvas.RigidBodyComponentSystem,
|
|
168
|
+
playcanvas.ScreenComponentSystem,
|
|
169
|
+
playcanvas.ScriptComponentSystem,
|
|
170
|
+
playcanvas.ScrollbarComponentSystem,
|
|
171
|
+
playcanvas.ScrollViewComponentSystem,
|
|
172
|
+
playcanvas.SoundComponentSystem,
|
|
173
|
+
playcanvas.SpriteComponentSystem,
|
|
174
|
+
playcanvas.ZoneComponentSystem
|
|
175
|
+
];
|
|
176
|
+
createOptions.resourceHandlers = [
|
|
177
|
+
playcanvas.AnimClipHandler,
|
|
178
|
+
playcanvas.AnimationHandler,
|
|
179
|
+
playcanvas.AnimStateGraphHandler,
|
|
180
|
+
playcanvas.AudioHandler,
|
|
181
|
+
playcanvas.BinaryHandler,
|
|
182
|
+
playcanvas.CssHandler,
|
|
183
|
+
playcanvas.ContainerHandler,
|
|
184
|
+
playcanvas.CubemapHandler,
|
|
185
|
+
playcanvas.FolderHandler,
|
|
186
|
+
playcanvas.FontHandler,
|
|
187
|
+
playcanvas.GSplatHandler,
|
|
188
|
+
playcanvas.HierarchyHandler,
|
|
189
|
+
playcanvas.HtmlHandler,
|
|
190
|
+
playcanvas.JsonHandler,
|
|
191
|
+
playcanvas.MaterialHandler,
|
|
192
|
+
playcanvas.ModelHandler,
|
|
193
|
+
playcanvas.RenderHandler,
|
|
194
|
+
playcanvas.ScriptHandler,
|
|
195
|
+
playcanvas.SceneHandler,
|
|
196
|
+
playcanvas.ShaderHandler,
|
|
197
|
+
playcanvas.SpriteHandler,
|
|
198
|
+
playcanvas.TemplateHandler,
|
|
199
|
+
playcanvas.TextHandler,
|
|
200
|
+
playcanvas.TextureAtlasHandler,
|
|
201
|
+
playcanvas.TextureHandler
|
|
202
|
+
];
|
|
203
|
+
createOptions.soundManager = new playcanvas.SoundManager();
|
|
204
|
+
createOptions.lightmapper = playcanvas.Lightmapper;
|
|
205
|
+
createOptions.batchManager = playcanvas.BatchManager;
|
|
206
|
+
createOptions.xr = playcanvas.XrManager;
|
|
207
|
+
this.app = new playcanvas.AppBase(this._canvas);
|
|
208
|
+
this.app.init(createOptions);
|
|
142
209
|
this.app.setCanvasFillMode(playcanvas.FILLMODE_FILL_WINDOW);
|
|
143
210
|
this.app.setCanvasResolution(playcanvas.RESOLUTION_AUTO);
|
|
144
211
|
this._pickerCreate();
|
|
@@ -366,6 +433,20 @@
|
|
|
366
433
|
get antialias() {
|
|
367
434
|
return this._antialias;
|
|
368
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Sets the graphics backend.
|
|
438
|
+
* @param value - The graphics backend ('webgpu', 'webgl2', or 'null').
|
|
439
|
+
*/
|
|
440
|
+
set backend(value) {
|
|
441
|
+
this._backend = value;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Gets the graphics backend.
|
|
445
|
+
* @returns The graphics backend.
|
|
446
|
+
*/
|
|
447
|
+
get backend() {
|
|
448
|
+
return this._backend;
|
|
449
|
+
}
|
|
369
450
|
/**
|
|
370
451
|
* Sets the depth flag.
|
|
371
452
|
* @param value - The depth flag.
|
|
@@ -421,7 +502,7 @@
|
|
|
421
502
|
return this._stencil;
|
|
422
503
|
}
|
|
423
504
|
static get observedAttributes() {
|
|
424
|
-
return ['alpha', 'antialias', 'depth', 'stencil', 'high-resolution'];
|
|
505
|
+
return ['alpha', 'antialias', 'backend', 'depth', 'stencil', 'high-resolution'];
|
|
425
506
|
}
|
|
426
507
|
attributeChangedCallback(name, _oldValue, newValue) {
|
|
427
508
|
switch (name) {
|
|
@@ -431,6 +512,11 @@
|
|
|
431
512
|
case 'antialias':
|
|
432
513
|
this.antialias = newValue !== 'false';
|
|
433
514
|
break;
|
|
515
|
+
case 'backend':
|
|
516
|
+
if (newValue === 'webgpu' || newValue === 'webgl2' || newValue === 'null') {
|
|
517
|
+
this.backend = newValue;
|
|
518
|
+
}
|
|
519
|
+
break;
|
|
434
520
|
case 'depth':
|
|
435
521
|
this.depth = newValue !== 'false';
|
|
436
522
|
break;
|
|
@@ -660,7 +746,7 @@
|
|
|
660
746
|
|
|
661
747
|
/**
|
|
662
748
|
* The EntityElement interface provides properties and methods for manipulating
|
|
663
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
749
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/ | `<pc-entity>`} elements.
|
|
664
750
|
* The EntityElement interface also inherits the properties and methods of the
|
|
665
751
|
* {@link HTMLElement} interface.
|
|
666
752
|
*/
|
|
@@ -1197,7 +1283,7 @@
|
|
|
1197
1283
|
};
|
|
1198
1284
|
/**
|
|
1199
1285
|
* The AssetElement interface provides properties and methods for manipulating
|
|
1200
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
1286
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/ | `<pc-asset>`} elements.
|
|
1201
1287
|
* The AssetElement interface also inherits the properties and methods of the
|
|
1202
1288
|
* {@link HTMLElement} interface.
|
|
1203
1289
|
*/
|
|
@@ -1359,7 +1445,7 @@
|
|
|
1359
1445
|
|
|
1360
1446
|
/**
|
|
1361
1447
|
* The ListenerComponentElement interface provides properties and methods for manipulating
|
|
1362
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
1448
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-listener/ | `<pc-listener>`} elements.
|
|
1363
1449
|
* The ListenerComponentElement interface also inherits the properties and methods of the
|
|
1364
1450
|
* {@link HTMLElement} interface.
|
|
1365
1451
|
*
|
|
@@ -1391,7 +1477,7 @@
|
|
|
1391
1477
|
]);
|
|
1392
1478
|
/**
|
|
1393
1479
|
* The CameraComponentElement interface provides properties and methods for manipulating
|
|
1394
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
1480
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-camera/ | `<pc-camera>`} elements.
|
|
1395
1481
|
* The CameraComponentElement interface also inherits the properties and methods of the
|
|
1396
1482
|
* {@link HTMLElement} interface.
|
|
1397
1483
|
*
|
|
@@ -1872,7 +1958,7 @@
|
|
|
1872
1958
|
|
|
1873
1959
|
/**
|
|
1874
1960
|
* The CollisionComponentElement interface provides properties and methods for manipulating
|
|
1875
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
1961
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-collision/ | `<pc-collision>`} elements.
|
|
1876
1962
|
* The CollisionComponentElement interface also inherits the properties and methods of the
|
|
1877
1963
|
* {@link HTMLElement} interface.
|
|
1878
1964
|
*
|
|
@@ -2019,7 +2105,7 @@
|
|
|
2019
2105
|
|
|
2020
2106
|
/**
|
|
2021
2107
|
* The ElementComponentElement interface provides properties and methods for manipulating
|
|
2022
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
2108
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-element/ | `<pc-element>`} elements.
|
|
2023
2109
|
* The ElementComponentElement interface also inherits the properties and methods of the
|
|
2024
2110
|
* {@link HTMLElement} interface.
|
|
2025
2111
|
*
|
|
@@ -2324,7 +2410,7 @@
|
|
|
2324
2410
|
]);
|
|
2325
2411
|
/**
|
|
2326
2412
|
* The LightComponentElement interface provides properties and methods for manipulating
|
|
2327
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
2413
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-light/ | `<pc-light>`} elements.
|
|
2328
2414
|
* The LightComponentElement interface also inherits the properties and methods of the
|
|
2329
2415
|
* {@link HTMLElement} interface.
|
|
2330
2416
|
*
|
|
@@ -2721,7 +2807,7 @@
|
|
|
2721
2807
|
|
|
2722
2808
|
/**
|
|
2723
2809
|
* The ParticleSystemComponentElement interface provides properties and methods for manipulating
|
|
2724
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
2810
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-particles/ | `<pc-particles>`} elements.
|
|
2725
2811
|
* The ParticleSystemComponentElement interface also inherits the properties and methods of the
|
|
2726
2812
|
* {@link HTMLElement} interface.
|
|
2727
2813
|
*
|
|
@@ -2853,7 +2939,7 @@
|
|
|
2853
2939
|
|
|
2854
2940
|
/**
|
|
2855
2941
|
* The MaterialElement interface provides properties and methods for manipulating
|
|
2856
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
2942
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-material/ | `<pc-material>`} elements.
|
|
2857
2943
|
* The MaterialElement interface also inherits the properties and methods of the
|
|
2858
2944
|
* {@link HTMLElement} interface.
|
|
2859
2945
|
*/
|
|
@@ -2970,7 +3056,7 @@
|
|
|
2970
3056
|
|
|
2971
3057
|
/**
|
|
2972
3058
|
* The RenderComponentElement interface provides properties and methods for manipulating
|
|
2973
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3059
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-render/ | `<pc-render>`} elements.
|
|
2974
3060
|
* The RenderComponentElement interface also inherits the properties and methods of the
|
|
2975
3061
|
* {@link HTMLElement} interface.
|
|
2976
3062
|
*
|
|
@@ -3093,7 +3179,7 @@
|
|
|
3093
3179
|
|
|
3094
3180
|
/**
|
|
3095
3181
|
* The RigidBodyComponentElement interface provides properties and methods for manipulating
|
|
3096
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3182
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-rigidbody/ | `<pc-rigidbody>`} elements.
|
|
3097
3183
|
* The RigidBodyComponentElement interface also inherits the properties and methods of the
|
|
3098
3184
|
* {@link HTMLElement} interface.
|
|
3099
3185
|
*
|
|
@@ -3281,7 +3367,7 @@
|
|
|
3281
3367
|
|
|
3282
3368
|
/**
|
|
3283
3369
|
* The ScreenComponentElement interface provides properties and methods for manipulating
|
|
3284
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3370
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-screen/ | `<pc-screen>`} elements.
|
|
3285
3371
|
* The ScreenComponentElement interface also inherits the properties and methods of the
|
|
3286
3372
|
* {@link HTMLElement} interface.
|
|
3287
3373
|
*
|
|
@@ -3408,7 +3494,7 @@
|
|
|
3408
3494
|
|
|
3409
3495
|
/**
|
|
3410
3496
|
* The ScriptComponentElement interface provides properties and methods for manipulating
|
|
3411
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3497
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scripts/ | `<pc-scripts>`} elements.
|
|
3412
3498
|
* The ScriptComponentElement interface also inherits the properties and methods of the
|
|
3413
3499
|
* {@link HTMLElement} interface.
|
|
3414
3500
|
*
|
|
@@ -3716,7 +3802,7 @@
|
|
|
3716
3802
|
|
|
3717
3803
|
/**
|
|
3718
3804
|
* The SoundComponentElement interface provides properties and methods for manipulating
|
|
3719
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3805
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-sounds/ | `<pc-sounds>`} elements.
|
|
3720
3806
|
* The SoundComponentElement interface also inherits the properties and methods of the
|
|
3721
3807
|
* {@link HTMLElement} interface.
|
|
3722
3808
|
*
|
|
@@ -3950,6 +4036,9 @@
|
|
|
3950
4036
|
}
|
|
3951
4037
|
this.soundSlot = this.soundElement.component.addSlot(this._name, options);
|
|
3952
4038
|
this.asset = this._asset;
|
|
4039
|
+
if (this._autoPlay) {
|
|
4040
|
+
this.soundSlot.play();
|
|
4041
|
+
}
|
|
3953
4042
|
this._onReady();
|
|
3954
4043
|
}
|
|
3955
4044
|
disconnectedCallback() {
|
|
@@ -4159,7 +4248,7 @@
|
|
|
4159
4248
|
|
|
4160
4249
|
/**
|
|
4161
4250
|
* The SplatComponentElement interface provides properties and methods for manipulating
|
|
4162
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
4251
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-splat/ | `<pc-splat>`} elements.
|
|
4163
4252
|
* The SplatComponentElement interface also inherits the properties and methods of the
|
|
4164
4253
|
* {@link HTMLElement} interface.
|
|
4165
4254
|
*
|
|
@@ -4243,7 +4332,7 @@
|
|
|
4243
4332
|
|
|
4244
4333
|
/**
|
|
4245
4334
|
* The ModelElement interface provides properties and methods for manipulating
|
|
4246
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
4335
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-model/ | `<pc-model>`} elements.
|
|
4247
4336
|
* The ModelElement interface also inherits the properties and methods of the
|
|
4248
4337
|
* {@link HTMLElement} interface.
|
|
4249
4338
|
*/
|
|
@@ -4339,7 +4428,7 @@
|
|
|
4339
4428
|
|
|
4340
4429
|
/**
|
|
4341
4430
|
* The SceneElement interface provides properties and methods for manipulating
|
|
4342
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
4431
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scene/ | `<pc-scene>`} elements.
|
|
4343
4432
|
* The SceneElement interface also inherits the properties and methods of the
|
|
4344
4433
|
* {@link HTMLElement} interface.
|
|
4345
4434
|
*/
|