@playcanvas/web-components 0.1.8 → 0.1.9
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/dist/app.d.ts +10 -1
- package/dist/asset.d.ts +3 -1
- package/dist/async-element.d.ts +2 -1
- package/dist/components/camera-component.d.ts +4 -4
- package/dist/components/collision-component.d.ts +4 -4
- package/dist/components/component.d.ts +3 -1
- package/dist/components/element-component.d.ts +4 -1
- package/dist/components/gsplat-component.d.ts +4 -1
- package/dist/components/light-component.d.ts +4 -4
- package/dist/components/listener-component.d.ts +4 -1
- package/dist/components/render-component.d.ts +4 -1
- package/dist/components/rigidbody-component.d.ts +4 -4
- package/dist/components/screen-component.d.ts +4 -1
- package/dist/components/script-component.d.ts +4 -1
- package/dist/components/script.d.ts +3 -1
- package/dist/components/sound-component.d.ts +4 -1
- package/dist/components/sound-slot.d.ts +3 -1
- package/dist/entity.d.ts +7 -3
- package/dist/material.d.ts +3 -1
- package/dist/model.d.ts +3 -1
- package/dist/module.d.ts +6 -0
- package/dist/pwc.cjs +161 -77
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +161 -77
- 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 +161 -77
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +3 -1
- package/dist/sky.d.ts +3 -1
- package/package.json +8 -8
- package/src/app.ts +28 -1
- package/src/asset.ts +3 -1
- package/src/async-element.ts +2 -1
- package/src/components/camera-component.ts +4 -4
- package/src/components/collision-component.ts +4 -4
- package/src/components/component.ts +3 -1
- package/src/components/element-component.ts +4 -2
- package/src/components/gsplat-component.ts +4 -1
- package/src/components/light-component.ts +4 -4
- package/src/components/listener-component.ts +4 -1
- package/src/components/render-component.ts +4 -1
- package/src/components/rigidbody-component.ts +4 -4
- package/src/components/screen-component.ts +4 -1
- package/src/components/script-component.ts +4 -1
- package/src/components/script.ts +3 -1
- package/src/components/sound-component.ts +4 -1
- package/src/components/sound-slot.ts +3 -1
- package/src/entity.ts +61 -31
- package/src/material.ts +3 -1
- package/src/model.ts +3 -1
- package/src/module.ts +6 -0
- package/src/scene.ts +13 -11
- package/src/sky.ts +3 -1
|
@@ -4,7 +4,9 @@ import { ComponentElement } from './component';
|
|
|
4
4
|
import { parseColor } from '../utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The LightComponentElement interface provides properties and methods for manipulating
|
|
8
|
+
* `<pc-light>` elements. The LightComponentElement interface also inherits the properties and
|
|
9
|
+
* methods of the {@link HTMLElement} interface.
|
|
8
10
|
*
|
|
9
11
|
* @category Components
|
|
10
12
|
*/
|
|
@@ -31,9 +33,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
31
33
|
|
|
32
34
|
private _type = 'directional';
|
|
33
35
|
|
|
34
|
-
/**
|
|
35
|
-
* Creates a new LightComponentElement.
|
|
36
|
-
*/
|
|
36
|
+
/** @ignore */
|
|
37
37
|
constructor() {
|
|
38
38
|
super('light');
|
|
39
39
|
}
|
|
@@ -3,11 +3,14 @@ import { AudioListenerComponent } from 'playcanvas';
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* The ListenerComponentElement interface provides properties and methods for manipulating
|
|
7
|
+
* `<pc-listener>` elements. The ListenerComponentElement interface also inherits the properties
|
|
8
|
+
* and methods of the {@link HTMLElement} interface.
|
|
7
9
|
*
|
|
8
10
|
* @category Components
|
|
9
11
|
*/
|
|
10
12
|
class ListenerComponentElement extends ComponentElement {
|
|
13
|
+
/** @ignore */
|
|
11
14
|
constructor() {
|
|
12
15
|
super('audiolistener');
|
|
13
16
|
}
|
|
@@ -4,7 +4,9 @@ import { ComponentElement } from './component';
|
|
|
4
4
|
import { MaterialElement } from '../material';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The RenderComponentElement interface provides properties and methods for manipulating
|
|
8
|
+
* `<pc-render>` elements. The RenderComponentElement interface also inherits the properties and
|
|
9
|
+
* methods of the {@link HTMLElement} interface.
|
|
8
10
|
*
|
|
9
11
|
* @category Components
|
|
10
12
|
*/
|
|
@@ -17,6 +19,7 @@ class RenderComponentElement extends ComponentElement {
|
|
|
17
19
|
|
|
18
20
|
private _type: 'asset' | 'box' | 'capsule' | 'cone' | 'cylinder' | 'plane' | 'sphere' = 'asset';
|
|
19
21
|
|
|
22
|
+
/** @ignore */
|
|
20
23
|
constructor() {
|
|
21
24
|
super('render');
|
|
22
25
|
}
|
|
@@ -4,7 +4,9 @@ import { ComponentElement } from './component';
|
|
|
4
4
|
import { parseVec3 } from '../utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The RigidBodyComponentElement interface provides properties and methods for manipulating
|
|
8
|
+
* `<pc-rigidbody>` elements. The RigidBodyComponentElement interface also inherits the properties
|
|
9
|
+
* and methods of the {@link HTMLElement} interface.
|
|
8
10
|
*
|
|
9
11
|
* @category Components
|
|
10
12
|
*/
|
|
@@ -54,9 +56,7 @@ class RigidBodyComponentElement extends ComponentElement {
|
|
|
54
56
|
*/
|
|
55
57
|
private _type: string = 'static';
|
|
56
58
|
|
|
57
|
-
/**
|
|
58
|
-
* Creates a new RigidBodyComponentElement.
|
|
59
|
-
*/
|
|
59
|
+
/** @ignore */
|
|
60
60
|
constructor() {
|
|
61
61
|
super('rigidbody');
|
|
62
62
|
}
|
|
@@ -4,7 +4,9 @@ import { ComponentElement } from './component';
|
|
|
4
4
|
import { parseVec2 } from '../utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The ScreenComponentElement interface provides properties and methods for manipulating
|
|
8
|
+
* `<pc-screen>` elements. The ScreenComponentElement interface also inherits the properties and
|
|
9
|
+
* methods of the {@link HTMLElement} interface.
|
|
8
10
|
*
|
|
9
11
|
* @category Components
|
|
10
12
|
*/
|
|
@@ -21,6 +23,7 @@ class ScreenComponentElement extends ComponentElement {
|
|
|
21
23
|
|
|
22
24
|
private _scaleBlend = 0.5;
|
|
23
25
|
|
|
26
|
+
/** @ignore */
|
|
24
27
|
constructor() {
|
|
25
28
|
super('screen');
|
|
26
29
|
}
|
|
@@ -26,13 +26,16 @@ declare global {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* The ScriptComponentElement interface provides properties and methods for manipulating
|
|
30
|
+
* `<pc-scripts>` elements. The ScriptComponentElement interface also inherits the properties and
|
|
31
|
+
* methods of the {@link HTMLElement} interface.
|
|
30
32
|
*
|
|
31
33
|
* @category Components
|
|
32
34
|
*/
|
|
33
35
|
class ScriptComponentElement extends ComponentElement {
|
|
34
36
|
private observer: MutationObserver;
|
|
35
37
|
|
|
38
|
+
/** @ignore */
|
|
36
39
|
constructor() {
|
|
37
40
|
super('script');
|
|
38
41
|
|
package/src/components/script.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The ScriptElement interface provides properties and methods for manipulating
|
|
3
|
+
* `<pc-script>` elements. The ScriptElement interface also inherits the properties and
|
|
4
|
+
* methods of the {@link HTMLElement} interface.
|
|
3
5
|
*/
|
|
4
6
|
class ScriptElement extends HTMLElement {
|
|
5
7
|
private _attributes: string = '{}';
|
|
@@ -3,7 +3,9 @@ import { SoundComponent } from 'playcanvas';
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* The SoundComponentElement interface provides properties and methods for manipulating
|
|
7
|
+
* `<pc-sounds>` elements. The SoundComponentElement interface also inherits the properties and
|
|
8
|
+
* methods of the {@link HTMLElement} interface.
|
|
7
9
|
*
|
|
8
10
|
* @category Components
|
|
9
11
|
*/
|
|
@@ -22,6 +24,7 @@ class SoundComponentElement extends ComponentElement {
|
|
|
22
24
|
|
|
23
25
|
private _volume: number = 1;
|
|
24
26
|
|
|
27
|
+
/** @ignore */
|
|
25
28
|
constructor() {
|
|
26
29
|
super('sound');
|
|
27
30
|
}
|
|
@@ -5,7 +5,9 @@ import { AsyncElement } from '../async-element';
|
|
|
5
5
|
import { SoundComponentElement } from './sound-component';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The SoundSlotElement interface provides properties and methods for manipulating
|
|
9
|
+
* `<pc-sound>` elements. The SoundSlotElement interface also inherits the properties and
|
|
10
|
+
* methods of the {@link AsyncElement} interface.
|
|
9
11
|
*/
|
|
10
12
|
class SoundSlotElement extends AsyncElement {
|
|
11
13
|
private _asset: string = '';
|
package/src/entity.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Entity, Vec3 } from 'playcanvas';
|
|
1
|
+
import { Application, 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
|
+
* `<pc-entity>` elements. The EntityElement interface also inherits the properties and
|
|
9
|
+
* methods of the {@link HTMLElement} interface.
|
|
8
10
|
*/
|
|
9
11
|
class EntityElement extends AsyncElement {
|
|
10
12
|
/**
|
|
@@ -42,42 +44,69 @@ class EntityElement extends AsyncElement {
|
|
|
42
44
|
*/
|
|
43
45
|
entity: Entity | null = null;
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
createEntity(app: Application) {
|
|
48
|
+
// Create a new entity
|
|
49
|
+
this.entity = new Entity(this.getAttribute('name') || this._name, app);
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
const enabled = this.getAttribute('enabled');
|
|
52
|
+
if (enabled) {
|
|
53
|
+
this.entity.enabled = enabled !== 'false';
|
|
54
|
+
}
|
|
51
55
|
|
|
52
|
-
const
|
|
56
|
+
const position = this.getAttribute('position');
|
|
57
|
+
if (position) {
|
|
58
|
+
this.entity.setLocalPosition(parseVec3(position));
|
|
59
|
+
}
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
const rotation = this.getAttribute('rotation');
|
|
62
|
+
if (rotation) {
|
|
63
|
+
this.entity.setLocalEulerAngles(parseVec3(rotation));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const scale = this.getAttribute('scale');
|
|
67
|
+
if (scale) {
|
|
68
|
+
this.entity.setLocalScale(parseVec3(scale));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const tags = this.getAttribute('tags');
|
|
72
|
+
if (tags) {
|
|
73
|
+
this.entity.tags.add(tags.split(',').map(tag => tag.trim()));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
buildHierarchy(app: Application) {
|
|
78
|
+
if (!this.entity) return;
|
|
71
79
|
|
|
72
80
|
const closestEntity = this.closestEntity;
|
|
73
|
-
if (closestEntity) {
|
|
74
|
-
closestEntity.
|
|
75
|
-
closestEntity.entity!.addChild(this.entity!);
|
|
76
|
-
this._onReady();
|
|
77
|
-
});
|
|
81
|
+
if (closestEntity?.entity) {
|
|
82
|
+
closestEntity.entity.addChild(this.entity);
|
|
78
83
|
} else {
|
|
79
84
|
app.root.addChild(this.entity);
|
|
80
|
-
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this._onReady();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
connectedCallback() {
|
|
91
|
+
// Wait for app to be ready
|
|
92
|
+
const closestApp = this.closestApp;
|
|
93
|
+
if (!closestApp) return;
|
|
94
|
+
|
|
95
|
+
// If app is already running, create entity immediately
|
|
96
|
+
if (closestApp.hierarchyReady) {
|
|
97
|
+
const app = closestApp.app!;
|
|
98
|
+
|
|
99
|
+
this.createEntity(app);
|
|
100
|
+
this.buildHierarchy(app);
|
|
101
|
+
|
|
102
|
+
// Handle any child entities that might exist
|
|
103
|
+
const childEntities = this.querySelectorAll<EntityElement>('pc-entity');
|
|
104
|
+
childEntities.forEach((child) => {
|
|
105
|
+
child.createEntity(app);
|
|
106
|
+
});
|
|
107
|
+
childEntities.forEach((child) => {
|
|
108
|
+
child.buildHierarchy(app);
|
|
109
|
+
});
|
|
81
110
|
}
|
|
82
111
|
}
|
|
83
112
|
|
|
@@ -89,6 +118,7 @@ class EntityElement extends AsyncElement {
|
|
|
89
118
|
(child as EntityElement).entity = null;
|
|
90
119
|
});
|
|
91
120
|
|
|
121
|
+
// Destroy the entity
|
|
92
122
|
this.entity.destroy();
|
|
93
123
|
this.entity = null;
|
|
94
124
|
}
|
package/src/material.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { AssetElement } from './asset';
|
|
|
4
4
|
import { parseColor } from './utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The MaterialElement interface provides properties and methods for manipulating
|
|
8
|
+
* `<pc-material>` elements. The MaterialElement interface also inherits the properties and
|
|
9
|
+
* methods of the {@link HTMLElement} interface.
|
|
8
10
|
*/
|
|
9
11
|
class MaterialElement extends HTMLElement {
|
|
10
12
|
private _diffuse = new Color(1, 1, 1);
|
package/src/model.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { AssetElement } from './asset';
|
|
|
4
4
|
import { AsyncElement } from './async-element';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The ModelElement interface provides properties and methods for manipulating
|
|
8
|
+
* `<pc-model>` elements. The ModelElement interface also inherits the properties and
|
|
9
|
+
* methods of the {@link HTMLElement} interface.
|
|
8
10
|
*/
|
|
9
11
|
class ModelElement extends AsyncElement {
|
|
10
12
|
private _asset: string = '';
|
package/src/module.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { basisInitialize, WasmModule } from 'playcanvas';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* The ModuleElement interface provides properties and methods for manipulating
|
|
5
|
+
* `<pc-module>` elements. The ModuleElement interface also inherits the properties and
|
|
6
|
+
* methods of the {@link HTMLElement} interface.
|
|
7
|
+
*/
|
|
3
8
|
class ModuleElement extends HTMLElement {
|
|
4
9
|
private loadPromise: Promise<void>;
|
|
5
10
|
|
|
11
|
+
/** @ignore */
|
|
6
12
|
constructor() {
|
|
7
13
|
super();
|
|
8
14
|
this.loadPromise = this.loadModule();
|
package/src/scene.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { AsyncElement } from './async-element';
|
|
|
4
4
|
import { parseColor } from './utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The SceneElement interface provides properties and methods for manipulating
|
|
8
|
+
* `<pc-scene>` elements. The SceneElement interface also inherits the properties and
|
|
9
|
+
* methods of the {@link HTMLElement} interface.
|
|
8
10
|
*/
|
|
9
11
|
class SceneElement extends AsyncElement {
|
|
10
12
|
/**
|
|
@@ -48,11 +50,11 @@ class SceneElement extends AsyncElement {
|
|
|
48
50
|
|
|
49
51
|
updateSceneSettings() {
|
|
50
52
|
if (this.scene) {
|
|
51
|
-
this.scene.
|
|
52
|
-
this.scene.
|
|
53
|
-
this.scene.
|
|
54
|
-
this.scene.
|
|
55
|
-
this.scene.
|
|
53
|
+
this.scene.fog.type = this._fog;
|
|
54
|
+
this.scene.fog.color = this._fogColor;
|
|
55
|
+
this.scene.fog.density = this._fogDensity;
|
|
56
|
+
this.scene.fog.start = this._fogStart;
|
|
57
|
+
this.scene.fog.end = this._fogEnd;
|
|
56
58
|
// ... set other properties on the scene as well
|
|
57
59
|
}
|
|
58
60
|
}
|
|
@@ -64,7 +66,7 @@ class SceneElement extends AsyncElement {
|
|
|
64
66
|
set fog(value) {
|
|
65
67
|
this._fog = value;
|
|
66
68
|
if (this.scene) {
|
|
67
|
-
this.scene.
|
|
69
|
+
this.scene.fog.type = value;
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -83,7 +85,7 @@ class SceneElement extends AsyncElement {
|
|
|
83
85
|
set fogColor(value: Color) {
|
|
84
86
|
this._fogColor = value;
|
|
85
87
|
if (this.scene) {
|
|
86
|
-
this.scene.
|
|
88
|
+
this.scene.fog.color = value;
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
|
|
@@ -102,7 +104,7 @@ class SceneElement extends AsyncElement {
|
|
|
102
104
|
set fogDensity(value: number) {
|
|
103
105
|
this._fogDensity = value;
|
|
104
106
|
if (this.scene) {
|
|
105
|
-
this.scene.
|
|
107
|
+
this.scene.fog.density = value;
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
|
|
@@ -121,7 +123,7 @@ class SceneElement extends AsyncElement {
|
|
|
121
123
|
set fogStart(value: number) {
|
|
122
124
|
this._fogStart = value;
|
|
123
125
|
if (this.scene) {
|
|
124
|
-
this.scene.
|
|
126
|
+
this.scene.fog.start = value;
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
|
|
@@ -140,7 +142,7 @@ class SceneElement extends AsyncElement {
|
|
|
140
142
|
set fogEnd(value: number) {
|
|
141
143
|
this._fogEnd = value;
|
|
142
144
|
if (this.scene) {
|
|
143
|
-
this.scene.
|
|
145
|
+
this.scene.fog.end = value;
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
|
package/src/sky.ts
CHANGED
|
@@ -5,7 +5,9 @@ import { AsyncElement } from './async-element';
|
|
|
5
5
|
import { parseVec3 } from './utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The SkyElement interface provides properties and methods for manipulating
|
|
9
|
+
* `<pc-sky>` elements. The SkyElement interface also inherits the properties and
|
|
10
|
+
* methods of the {@link HTMLElement} interface.
|
|
9
11
|
*/
|
|
10
12
|
class SkyElement extends AsyncElement {
|
|
11
13
|
private _asset = '';
|