@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/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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
|
-
| [User Guide](https://developer.playcanvas.com/user-manual/
|
|
8
|
+
| [User Guide](https://developer.playcanvas.com/user-manual/web-components) | [API Reference](https://api.playcanvas.com/web-components/) | [Examples](https://playcanvas.github.io/web-components/examples) | [Blog](https://blog.playcanvas.com/) | [Forum](https://forum.playcanvas.com/) | [Discord](https://discord.gg/RSaMRzg) |
|
|
9
9
|
|
|
10
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. Check out this simple example:
|
|
11
11
|
|
package/dist/app.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppBase } from 'playcanvas';
|
|
2
2
|
import { AsyncElement } from './async-element';
|
|
3
3
|
/**
|
|
4
4
|
* The AppElement 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-app/ | `<pc-app>`} elements.
|
|
6
6
|
* The AppElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*/
|
|
@@ -12,6 +12,7 @@ declare class AppElement extends AsyncElement {
|
|
|
12
12
|
*/
|
|
13
13
|
private _canvas;
|
|
14
14
|
private _alpha;
|
|
15
|
+
private _backend;
|
|
15
16
|
private _antialias;
|
|
16
17
|
private _depth;
|
|
17
18
|
private _stencil;
|
|
@@ -24,7 +25,7 @@ declare class AppElement extends AsyncElement {
|
|
|
24
25
|
/**
|
|
25
26
|
* The PlayCanvas application instance.
|
|
26
27
|
*/
|
|
27
|
-
app:
|
|
28
|
+
app: AppBase | null;
|
|
28
29
|
/**
|
|
29
30
|
* Creates a new AppElement instance.
|
|
30
31
|
*
|
|
@@ -62,6 +63,16 @@ declare class AppElement extends AsyncElement {
|
|
|
62
63
|
* @returns The antialias flag.
|
|
63
64
|
*/
|
|
64
65
|
get antialias(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the graphics backend.
|
|
68
|
+
* @param value - The graphics backend ('webgpu', 'webgl2', or 'null').
|
|
69
|
+
*/
|
|
70
|
+
set backend(value: 'webgpu' | 'webgl2' | 'null');
|
|
71
|
+
/**
|
|
72
|
+
* Gets the graphics backend.
|
|
73
|
+
* @returns The graphics backend.
|
|
74
|
+
*/
|
|
75
|
+
get backend(): "webgpu" | "webgl2" | "null";
|
|
65
76
|
/**
|
|
66
77
|
* Sets the depth flag.
|
|
67
78
|
* @param value - The depth flag.
|
package/dist/asset.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Asset } from 'playcanvas';
|
|
2
2
|
/**
|
|
3
3
|
* The AssetElement interface provides properties and methods for manipulating
|
|
4
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
4
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/ | `<pc-asset>`} elements.
|
|
5
5
|
* The AssetElement interface also inherits the properties and methods of the
|
|
6
6
|
* {@link HTMLElement} interface.
|
|
7
7
|
*/
|
|
@@ -2,7 +2,7 @@ import { CameraComponent, Color, Vec4 } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The CameraComponentElement 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-camera/ | `<pc-camera>`} elements.
|
|
6
6
|
* The CameraComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { CollisionComponent, Quat, Vec3 } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The CollisionComponentElement 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-collision/ | `<pc-collision>`} elements.
|
|
6
6
|
* The CollisionComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { Color, ElementComponent, Vec2, Vec4 } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The ElementComponentElement 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-element/ | `<pc-element>`} elements.
|
|
6
6
|
* The ElementComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { Color, LightComponent } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The LightComponentElement 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-light/ | `<pc-light>`} elements.
|
|
6
6
|
* The LightComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { AudioListenerComponent } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The ListenerComponentElement 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-listener/ | `<pc-listener>`} elements.
|
|
6
6
|
* The ListenerComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { ParticleSystemComponent } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The ParticleSystemComponentElement 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-particles/ | `<pc-particles>`} elements.
|
|
6
6
|
* The ParticleSystemComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { RenderComponent, StandardMaterial } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The RenderComponentElement 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-render/ | `<pc-render>`} elements.
|
|
6
6
|
* The RenderComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { RigidBodyComponent, Vec3 } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The RigidBodyComponentElement 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-rigidbody/ | `<pc-rigidbody>`} elements.
|
|
6
6
|
* The RigidBodyComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { ScreenComponent, Vec2 } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The ScreenComponentElement 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-screen/ | `<pc-screen>`} elements.
|
|
6
6
|
* The ScreenComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -18,7 +18,7 @@ declare global {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* The ScriptComponentElement interface provides properties and methods for manipulating
|
|
21
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
21
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scripts/ | `<pc-scripts>`} elements.
|
|
22
22
|
* The ScriptComponentElement interface also inherits the properties and methods of the
|
|
23
23
|
* {@link HTMLElement} interface.
|
|
24
24
|
*
|
|
@@ -2,7 +2,7 @@ import { SoundComponent } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The SoundComponentElement 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-sounds/ | `<pc-sounds>`} elements.
|
|
6
6
|
* The SoundComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { GSplatComponent } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
/**
|
|
4
4
|
* The SplatComponentElement 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-splat/ | `<pc-splat>`} elements.
|
|
6
6
|
* The SplatComponentElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*
|
package/dist/entity.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppBase, Entity, Vec3 } from 'playcanvas';
|
|
2
2
|
import { AsyncElement } from './async-element';
|
|
3
3
|
/**
|
|
4
4
|
* The EntityElement 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-entity/ | `<pc-entity>`} elements.
|
|
6
6
|
* The EntityElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
8
|
*/
|
|
@@ -39,8 +39,8 @@ declare class EntityElement extends AsyncElement {
|
|
|
39
39
|
* The PlayCanvas entity instance.
|
|
40
40
|
*/
|
|
41
41
|
entity: Entity | null;
|
|
42
|
-
createEntity(app:
|
|
43
|
-
buildHierarchy(app:
|
|
42
|
+
createEntity(app: AppBase): void;
|
|
43
|
+
buildHierarchy(app: AppBase): void;
|
|
44
44
|
connectedCallback(): void;
|
|
45
45
|
disconnectedCallback(): void;
|
|
46
46
|
/**
|
package/dist/material.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Color, StandardMaterial } from 'playcanvas';
|
|
2
2
|
/**
|
|
3
3
|
* The MaterialElement interface provides properties and methods for manipulating
|
|
4
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
4
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-material/ | `<pc-material>`} elements.
|
|
5
5
|
* The MaterialElement interface also inherits the properties and methods of the
|
|
6
6
|
* {@link HTMLElement} interface.
|
|
7
7
|
*/
|
package/dist/model.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncElement } from './async-element';
|
|
2
2
|
/**
|
|
3
3
|
* The ModelElement interface provides properties and methods for manipulating
|
|
4
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
4
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-model/ | `<pc-model>`} elements.
|
|
5
5
|
* The ModelElement interface also inherits the properties and methods of the
|
|
6
6
|
* {@link HTMLElement} interface.
|
|
7
7
|
*/
|
package/dist/module.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The ModuleElement interface provides properties and methods for manipulating
|
|
3
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-module/ | `<pc-module>`} elements.
|
|
4
4
|
* The ModuleElement interface also inherits the properties and methods of the
|
|
5
5
|
* {@link HTMLElement} interface.
|
|
6
6
|
*/
|
package/dist/pwc.cjs
CHANGED
|
@@ -40,7 +40,7 @@ class AsyncElement extends HTMLElement {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* The ModuleElement interface provides properties and methods for manipulating
|
|
43
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
43
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-module/ | `<pc-module>`} elements.
|
|
44
44
|
* The ModuleElement interface also inherits the properties and methods of the
|
|
45
45
|
* {@link HTMLElement} interface.
|
|
46
46
|
*/
|
|
@@ -74,7 +74,7 @@ customElements.define('pc-module', ModuleElement);
|
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* The AppElement interface provides properties and methods for manipulating
|
|
77
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
77
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-app/ | `<pc-app>`} elements.
|
|
78
78
|
* The AppElement interface also inherits the properties and methods of the
|
|
79
79
|
* {@link HTMLElement} interface.
|
|
80
80
|
*/
|
|
@@ -91,6 +91,7 @@ class AppElement extends AsyncElement {
|
|
|
91
91
|
*/
|
|
92
92
|
this._canvas = null;
|
|
93
93
|
this._alpha = true;
|
|
94
|
+
this._backend = 'webgl2';
|
|
94
95
|
this._antialias = true;
|
|
95
96
|
this._depth = true;
|
|
96
97
|
this._stencil = true;
|
|
@@ -125,18 +126,84 @@ class AppElement extends AsyncElement {
|
|
|
125
126
|
// Create and append the canvas to the element
|
|
126
127
|
this._canvas = document.createElement('canvas');
|
|
127
128
|
this.appendChild(this._canvas);
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
// Configure device types based on backend selection
|
|
130
|
+
const backendToDeviceTypes = {
|
|
131
|
+
webgpu: ['webgpu', 'webgl2'], // fallback to webgl2 if webgpu not available
|
|
132
|
+
webgl2: ['webgl2'],
|
|
133
|
+
null: ['null']
|
|
134
|
+
};
|
|
135
|
+
const deviceTypes = backendToDeviceTypes[this._backend] || [];
|
|
136
|
+
const device = await playcanvas.createGraphicsDevice(this._canvas, {
|
|
137
|
+
// @ts-ignore - alpha needs to be documented
|
|
138
|
+
alpha: this._alpha,
|
|
139
|
+
antialias: this._antialias,
|
|
140
|
+
depth: this._depth,
|
|
141
|
+
deviceTypes: deviceTypes,
|
|
142
|
+
stencil: this._stencil
|
|
138
143
|
});
|
|
139
|
-
|
|
144
|
+
device.maxPixelRatio = this._highResolution ? window.devicePixelRatio : 1;
|
|
145
|
+
const createOptions = new playcanvas.AppOptions();
|
|
146
|
+
createOptions.graphicsDevice = device;
|
|
147
|
+
createOptions.keyboard = new playcanvas.Keyboard(window);
|
|
148
|
+
createOptions.mouse = new playcanvas.Mouse(this._canvas);
|
|
149
|
+
createOptions.componentSystems = [
|
|
150
|
+
playcanvas.AnimComponentSystem,
|
|
151
|
+
playcanvas.AnimationComponentSystem,
|
|
152
|
+
playcanvas.AudioListenerComponentSystem,
|
|
153
|
+
playcanvas.ButtonComponentSystem,
|
|
154
|
+
playcanvas.CameraComponentSystem,
|
|
155
|
+
playcanvas.CollisionComponentSystem,
|
|
156
|
+
playcanvas.ElementComponentSystem,
|
|
157
|
+
playcanvas.GSplatComponentSystem,
|
|
158
|
+
playcanvas.JointComponentSystem,
|
|
159
|
+
playcanvas.LayoutChildComponentSystem,
|
|
160
|
+
playcanvas.LayoutGroupComponentSystem,
|
|
161
|
+
playcanvas.LightComponentSystem,
|
|
162
|
+
playcanvas.ModelComponentSystem,
|
|
163
|
+
playcanvas.ParticleSystemComponentSystem,
|
|
164
|
+
playcanvas.RenderComponentSystem,
|
|
165
|
+
playcanvas.RigidBodyComponentSystem,
|
|
166
|
+
playcanvas.ScreenComponentSystem,
|
|
167
|
+
playcanvas.ScriptComponentSystem,
|
|
168
|
+
playcanvas.ScrollbarComponentSystem,
|
|
169
|
+
playcanvas.ScrollViewComponentSystem,
|
|
170
|
+
playcanvas.SoundComponentSystem,
|
|
171
|
+
playcanvas.SpriteComponentSystem,
|
|
172
|
+
playcanvas.ZoneComponentSystem
|
|
173
|
+
];
|
|
174
|
+
createOptions.resourceHandlers = [
|
|
175
|
+
playcanvas.AnimClipHandler,
|
|
176
|
+
playcanvas.AnimationHandler,
|
|
177
|
+
playcanvas.AnimStateGraphHandler,
|
|
178
|
+
playcanvas.AudioHandler,
|
|
179
|
+
playcanvas.BinaryHandler,
|
|
180
|
+
playcanvas.CssHandler,
|
|
181
|
+
playcanvas.ContainerHandler,
|
|
182
|
+
playcanvas.CubemapHandler,
|
|
183
|
+
playcanvas.FolderHandler,
|
|
184
|
+
playcanvas.FontHandler,
|
|
185
|
+
playcanvas.GSplatHandler,
|
|
186
|
+
playcanvas.HierarchyHandler,
|
|
187
|
+
playcanvas.HtmlHandler,
|
|
188
|
+
playcanvas.JsonHandler,
|
|
189
|
+
playcanvas.MaterialHandler,
|
|
190
|
+
playcanvas.ModelHandler,
|
|
191
|
+
playcanvas.RenderHandler,
|
|
192
|
+
playcanvas.ScriptHandler,
|
|
193
|
+
playcanvas.SceneHandler,
|
|
194
|
+
playcanvas.ShaderHandler,
|
|
195
|
+
playcanvas.SpriteHandler,
|
|
196
|
+
playcanvas.TemplateHandler,
|
|
197
|
+
playcanvas.TextHandler,
|
|
198
|
+
playcanvas.TextureAtlasHandler,
|
|
199
|
+
playcanvas.TextureHandler
|
|
200
|
+
];
|
|
201
|
+
createOptions.soundManager = new playcanvas.SoundManager();
|
|
202
|
+
createOptions.lightmapper = playcanvas.Lightmapper;
|
|
203
|
+
createOptions.batchManager = playcanvas.BatchManager;
|
|
204
|
+
createOptions.xr = playcanvas.XrManager;
|
|
205
|
+
this.app = new playcanvas.AppBase(this._canvas);
|
|
206
|
+
this.app.init(createOptions);
|
|
140
207
|
this.app.setCanvasFillMode(playcanvas.FILLMODE_FILL_WINDOW);
|
|
141
208
|
this.app.setCanvasResolution(playcanvas.RESOLUTION_AUTO);
|
|
142
209
|
this._pickerCreate();
|
|
@@ -364,6 +431,20 @@ class AppElement extends AsyncElement {
|
|
|
364
431
|
get antialias() {
|
|
365
432
|
return this._antialias;
|
|
366
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Sets the graphics backend.
|
|
436
|
+
* @param value - The graphics backend ('webgpu', 'webgl2', or 'null').
|
|
437
|
+
*/
|
|
438
|
+
set backend(value) {
|
|
439
|
+
this._backend = value;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Gets the graphics backend.
|
|
443
|
+
* @returns The graphics backend.
|
|
444
|
+
*/
|
|
445
|
+
get backend() {
|
|
446
|
+
return this._backend;
|
|
447
|
+
}
|
|
367
448
|
/**
|
|
368
449
|
* Sets the depth flag.
|
|
369
450
|
* @param value - The depth flag.
|
|
@@ -419,7 +500,7 @@ class AppElement extends AsyncElement {
|
|
|
419
500
|
return this._stencil;
|
|
420
501
|
}
|
|
421
502
|
static get observedAttributes() {
|
|
422
|
-
return ['alpha', 'antialias', 'depth', 'stencil', 'high-resolution'];
|
|
503
|
+
return ['alpha', 'antialias', 'backend', 'depth', 'stencil', 'high-resolution'];
|
|
423
504
|
}
|
|
424
505
|
attributeChangedCallback(name, _oldValue, newValue) {
|
|
425
506
|
switch (name) {
|
|
@@ -429,6 +510,11 @@ class AppElement extends AsyncElement {
|
|
|
429
510
|
case 'antialias':
|
|
430
511
|
this.antialias = newValue !== 'false';
|
|
431
512
|
break;
|
|
513
|
+
case 'backend':
|
|
514
|
+
if (newValue === 'webgpu' || newValue === 'webgl2' || newValue === 'null') {
|
|
515
|
+
this.backend = newValue;
|
|
516
|
+
}
|
|
517
|
+
break;
|
|
432
518
|
case 'depth':
|
|
433
519
|
this.depth = newValue !== 'false';
|
|
434
520
|
break;
|
|
@@ -658,7 +744,7 @@ const parseVec4 = (value) => {
|
|
|
658
744
|
|
|
659
745
|
/**
|
|
660
746
|
* The EntityElement interface provides properties and methods for manipulating
|
|
661
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
747
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/ | `<pc-entity>`} elements.
|
|
662
748
|
* The EntityElement interface also inherits the properties and methods of the
|
|
663
749
|
* {@link HTMLElement} interface.
|
|
664
750
|
*/
|
|
@@ -1195,7 +1281,7 @@ const processBufferView = (gltfBuffer, buffers, continuation) => {
|
|
|
1195
1281
|
};
|
|
1196
1282
|
/**
|
|
1197
1283
|
* The AssetElement interface provides properties and methods for manipulating
|
|
1198
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
1284
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/ | `<pc-asset>`} elements.
|
|
1199
1285
|
* The AssetElement interface also inherits the properties and methods of the
|
|
1200
1286
|
* {@link HTMLElement} interface.
|
|
1201
1287
|
*/
|
|
@@ -1357,7 +1443,7 @@ class ComponentElement extends AsyncElement {
|
|
|
1357
1443
|
|
|
1358
1444
|
/**
|
|
1359
1445
|
* The ListenerComponentElement interface provides properties and methods for manipulating
|
|
1360
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
1446
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-listener/ | `<pc-listener>`} elements.
|
|
1361
1447
|
* The ListenerComponentElement interface also inherits the properties and methods of the
|
|
1362
1448
|
* {@link HTMLElement} interface.
|
|
1363
1449
|
*
|
|
@@ -1389,7 +1475,7 @@ const tonemaps = new Map([
|
|
|
1389
1475
|
]);
|
|
1390
1476
|
/**
|
|
1391
1477
|
* The CameraComponentElement interface provides properties and methods for manipulating
|
|
1392
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
1478
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-camera/ | `<pc-camera>`} elements.
|
|
1393
1479
|
* The CameraComponentElement interface also inherits the properties and methods of the
|
|
1394
1480
|
* {@link HTMLElement} interface.
|
|
1395
1481
|
*
|
|
@@ -1870,7 +1956,7 @@ customElements.define('pc-camera', CameraComponentElement);
|
|
|
1870
1956
|
|
|
1871
1957
|
/**
|
|
1872
1958
|
* The CollisionComponentElement interface provides properties and methods for manipulating
|
|
1873
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
1959
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-collision/ | `<pc-collision>`} elements.
|
|
1874
1960
|
* The CollisionComponentElement interface also inherits the properties and methods of the
|
|
1875
1961
|
* {@link HTMLElement} interface.
|
|
1876
1962
|
*
|
|
@@ -2017,7 +2103,7 @@ customElements.define('pc-collision', CollisionComponentElement);
|
|
|
2017
2103
|
|
|
2018
2104
|
/**
|
|
2019
2105
|
* The ElementComponentElement interface provides properties and methods for manipulating
|
|
2020
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
2106
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-element/ | `<pc-element>`} elements.
|
|
2021
2107
|
* The ElementComponentElement interface also inherits the properties and methods of the
|
|
2022
2108
|
* {@link HTMLElement} interface.
|
|
2023
2109
|
*
|
|
@@ -2322,7 +2408,7 @@ const shadowTypes = new Map([
|
|
|
2322
2408
|
]);
|
|
2323
2409
|
/**
|
|
2324
2410
|
* The LightComponentElement interface provides properties and methods for manipulating
|
|
2325
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
2411
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-light/ | `<pc-light>`} elements.
|
|
2326
2412
|
* The LightComponentElement interface also inherits the properties and methods of the
|
|
2327
2413
|
* {@link HTMLElement} interface.
|
|
2328
2414
|
*
|
|
@@ -2719,7 +2805,7 @@ customElements.define('pc-light', LightComponentElement);
|
|
|
2719
2805
|
|
|
2720
2806
|
/**
|
|
2721
2807
|
* The ParticleSystemComponentElement interface provides properties and methods for manipulating
|
|
2722
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
2808
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-particles/ | `<pc-particles>`} elements.
|
|
2723
2809
|
* The ParticleSystemComponentElement interface also inherits the properties and methods of the
|
|
2724
2810
|
* {@link HTMLElement} interface.
|
|
2725
2811
|
*
|
|
@@ -2851,7 +2937,7 @@ customElements.define('pc-particles', ParticleSystemComponentElement);
|
|
|
2851
2937
|
|
|
2852
2938
|
/**
|
|
2853
2939
|
* The MaterialElement interface provides properties and methods for manipulating
|
|
2854
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
2940
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-material/ | `<pc-material>`} elements.
|
|
2855
2941
|
* The MaterialElement interface also inherits the properties and methods of the
|
|
2856
2942
|
* {@link HTMLElement} interface.
|
|
2857
2943
|
*/
|
|
@@ -2968,7 +3054,7 @@ customElements.define('pc-material', MaterialElement);
|
|
|
2968
3054
|
|
|
2969
3055
|
/**
|
|
2970
3056
|
* The RenderComponentElement interface provides properties and methods for manipulating
|
|
2971
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3057
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-render/ | `<pc-render>`} elements.
|
|
2972
3058
|
* The RenderComponentElement interface also inherits the properties and methods of the
|
|
2973
3059
|
* {@link HTMLElement} interface.
|
|
2974
3060
|
*
|
|
@@ -3091,7 +3177,7 @@ customElements.define('pc-render', RenderComponentElement);
|
|
|
3091
3177
|
|
|
3092
3178
|
/**
|
|
3093
3179
|
* The RigidBodyComponentElement interface provides properties and methods for manipulating
|
|
3094
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3180
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-rigidbody/ | `<pc-rigidbody>`} elements.
|
|
3095
3181
|
* The RigidBodyComponentElement interface also inherits the properties and methods of the
|
|
3096
3182
|
* {@link HTMLElement} interface.
|
|
3097
3183
|
*
|
|
@@ -3279,7 +3365,7 @@ customElements.define('pc-rigidbody', RigidBodyComponentElement);
|
|
|
3279
3365
|
|
|
3280
3366
|
/**
|
|
3281
3367
|
* The ScreenComponentElement interface provides properties and methods for manipulating
|
|
3282
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3368
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-screen/ | `<pc-screen>`} elements.
|
|
3283
3369
|
* The ScreenComponentElement interface also inherits the properties and methods of the
|
|
3284
3370
|
* {@link HTMLElement} interface.
|
|
3285
3371
|
*
|
|
@@ -3406,7 +3492,7 @@ customElements.define('pc-screen', ScreenComponentElement);
|
|
|
3406
3492
|
|
|
3407
3493
|
/**
|
|
3408
3494
|
* The ScriptComponentElement interface provides properties and methods for manipulating
|
|
3409
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3495
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scripts/ | `<pc-scripts>`} elements.
|
|
3410
3496
|
* The ScriptComponentElement interface also inherits the properties and methods of the
|
|
3411
3497
|
* {@link HTMLElement} interface.
|
|
3412
3498
|
*
|
|
@@ -3714,7 +3800,7 @@ customElements.define('pc-script', ScriptElement);
|
|
|
3714
3800
|
|
|
3715
3801
|
/**
|
|
3716
3802
|
* The SoundComponentElement interface provides properties and methods for manipulating
|
|
3717
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
3803
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-sounds/ | `<pc-sounds>`} elements.
|
|
3718
3804
|
* The SoundComponentElement interface also inherits the properties and methods of the
|
|
3719
3805
|
* {@link HTMLElement} interface.
|
|
3720
3806
|
*
|
|
@@ -3948,6 +4034,9 @@ class SoundSlotElement extends AsyncElement {
|
|
|
3948
4034
|
}
|
|
3949
4035
|
this.soundSlot = this.soundElement.component.addSlot(this._name, options);
|
|
3950
4036
|
this.asset = this._asset;
|
|
4037
|
+
if (this._autoPlay) {
|
|
4038
|
+
this.soundSlot.play();
|
|
4039
|
+
}
|
|
3951
4040
|
this._onReady();
|
|
3952
4041
|
}
|
|
3953
4042
|
disconnectedCallback() {
|
|
@@ -4157,7 +4246,7 @@ customElements.define('pc-sound', SoundSlotElement);
|
|
|
4157
4246
|
|
|
4158
4247
|
/**
|
|
4159
4248
|
* The SplatComponentElement interface provides properties and methods for manipulating
|
|
4160
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
4249
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-splat/ | `<pc-splat>`} elements.
|
|
4161
4250
|
* The SplatComponentElement interface also inherits the properties and methods of the
|
|
4162
4251
|
* {@link HTMLElement} interface.
|
|
4163
4252
|
*
|
|
@@ -4241,7 +4330,7 @@ customElements.define('pc-splat', SplatComponentElement);
|
|
|
4241
4330
|
|
|
4242
4331
|
/**
|
|
4243
4332
|
* The ModelElement interface provides properties and methods for manipulating
|
|
4244
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
4333
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-model/ | `<pc-model>`} elements.
|
|
4245
4334
|
* The ModelElement interface also inherits the properties and methods of the
|
|
4246
4335
|
* {@link HTMLElement} interface.
|
|
4247
4336
|
*/
|
|
@@ -4337,7 +4426,7 @@ customElements.define('pc-model', ModelElement);
|
|
|
4337
4426
|
|
|
4338
4427
|
/**
|
|
4339
4428
|
* The SceneElement interface provides properties and methods for manipulating
|
|
4340
|
-
* {@link https://developer.playcanvas.com/user-manual/
|
|
4429
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scene/ | `<pc-scene>`} elements.
|
|
4341
4430
|
* The SceneElement interface also inherits the properties and methods of the
|
|
4342
4431
|
* {@link HTMLElement} interface.
|
|
4343
4432
|
*/
|