@playcanvas/web-components 0.3.0 → 0.5.0

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.
Files changed (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +84 -84
  3. package/dist/components/light-component.d.ts +48 -0
  4. package/dist/components/splat-component.d.ts +0 -13
  5. package/dist/pwc.cjs +275 -207
  6. package/dist/pwc.cjs.map +1 -1
  7. package/dist/pwc.js +275 -207
  8. package/dist/pwc.js.map +1 -1
  9. package/dist/pwc.min.js +1 -1
  10. package/dist/pwc.min.js.map +1 -1
  11. package/dist/pwc.mjs +276 -208
  12. package/dist/pwc.mjs.map +1 -1
  13. package/package.json +76 -66
  14. package/src/app.ts +612 -606
  15. package/src/asset.ts +159 -159
  16. package/src/async-element.ts +46 -46
  17. package/src/colors.ts +150 -150
  18. package/src/components/camera-component.ts +557 -557
  19. package/src/components/collision-component.ts +183 -183
  20. package/src/components/component.ts +97 -97
  21. package/src/components/element-component.ts +367 -367
  22. package/src/components/light-component.ts +570 -466
  23. package/src/components/listener-component.ts +30 -30
  24. package/src/components/particlesystem-component.ts +155 -155
  25. package/src/components/render-component.ts +147 -147
  26. package/src/components/rigidbody-component.ts +227 -227
  27. package/src/components/screen-component.ts +157 -157
  28. package/src/components/script-component.ts +270 -270
  29. package/src/components/script.ts +90 -90
  30. package/src/components/sound-component.ts +230 -230
  31. package/src/components/sound-slot.ts +288 -288
  32. package/src/components/splat-component.ts +102 -133
  33. package/src/entity.ts +360 -360
  34. package/src/index.ts +63 -63
  35. package/src/material.ts +141 -141
  36. package/src/model.ts +111 -111
  37. package/src/module.ts +43 -43
  38. package/src/scene.ts +217 -217
  39. package/src/sky.ts +293 -293
  40. package/src/utils.ts +71 -71
@@ -1,133 +1,102 @@
1
- import { GSplatComponent } from 'playcanvas';
2
-
3
- import { ComponentElement } from './component';
4
- import { AssetElement } from '../asset';
5
-
6
- /**
7
- * The SplatComponentElement interface provides properties and methods for manipulating
8
- * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-splat/ | `<pc-splat>`} elements.
9
- * The SplatComponentElement interface also inherits the properties and methods of the
10
- * {@link HTMLElement} interface.
11
- *
12
- * @category Components
13
- */
14
- class SplatComponentElement extends ComponentElement {
15
- private _asset = '';
16
-
17
- private _castShadows = false;
18
-
19
- private _unified = false;
20
-
21
- /** @ignore */
22
- constructor() {
23
- super('gsplat');
24
- }
25
-
26
- getInitialComponentData() {
27
- return {
28
- asset: AssetElement.get(this._asset),
29
- castShadows: this._castShadows,
30
- unified: this._unified
31
- };
32
- }
33
-
34
- /**
35
- * Gets the underlying PlayCanvas splat component.
36
- * @returns The splat component.
37
- */
38
- get component(): GSplatComponent | null {
39
- return super.component as GSplatComponent | null;
40
- }
41
-
42
- /**
43
- * Sets id of the `pc-asset` to use for the splat.
44
- * @param value - The asset ID.
45
- */
46
- set asset(value: string) {
47
- this._asset = value;
48
- const asset = AssetElement.get(value);
49
- if (this.component && asset) {
50
- this.component.asset = asset;
51
- }
52
- }
53
-
54
- /**
55
- * Gets the id of the `pc-asset` to use for the splat.
56
- * @returns The asset ID.
57
- */
58
- get asset() {
59
- return this._asset;
60
- }
61
-
62
- /**
63
- * Sets whether the splat casts shadows.
64
- * @param value - Whether the splat casts shadows.
65
- */
66
- set castShadows(value: boolean) {
67
- this._castShadows = value;
68
- if (this.component) {
69
- this.component.castShadows = value;
70
- }
71
- }
72
-
73
- /**
74
- * Gets whether the splat casts shadows.
75
- * @returns Whether the splat casts shadows.
76
- */
77
- get castShadows() {
78
- return this._castShadows;
79
- }
80
-
81
- /**
82
- * Sets whether the splat supports global sorting and LOD streaming. This property can only be
83
- * changed when the component is disabled.
84
- * @param value - Whether the splat supports global sorting and LOD streaming.
85
- */
86
- set unified(value: boolean) {
87
- if (this.component && this.component.enabled) {
88
- console.warn('The "unified" property can only be changed when the component is disabled.');
89
- return;
90
- }
91
- this._unified = value;
92
- if (this.component) {
93
- this.component.unified = value;
94
- }
95
- }
96
-
97
- /**
98
- * Gets whether the splat supports global sorting and LOD streaming.
99
- * @returns Whether the splat supports global sorting and LOD streaming.
100
- */
101
- get unified() {
102
- return this._unified;
103
- }
104
-
105
- static get observedAttributes() {
106
- return [
107
- ...super.observedAttributes,
108
- 'asset',
109
- 'cast-shadows',
110
- 'unified'
111
- ];
112
- }
113
-
114
- attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
115
- super.attributeChangedCallback(name, _oldValue, newValue);
116
-
117
- switch (name) {
118
- case 'asset':
119
- this.asset = newValue;
120
- break;
121
- case 'cast-shadows':
122
- this.castShadows = this.hasAttribute('cast-shadows');
123
- break;
124
- case 'unified':
125
- this.unified = this.hasAttribute('unified');
126
- break;
127
- }
128
- }
129
- }
130
-
131
- customElements.define('pc-splat', SplatComponentElement);
132
-
133
- export { SplatComponentElement };
1
+ import { GSplatComponent } from 'playcanvas';
2
+
3
+ import { ComponentElement } from './component';
4
+ import { AssetElement } from '../asset';
5
+
6
+ /**
7
+ * The SplatComponentElement interface provides properties and methods for manipulating
8
+ * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-splat/ | `<pc-splat>`} elements.
9
+ * The SplatComponentElement interface also inherits the properties and methods of the
10
+ * {@link HTMLElement} interface.
11
+ *
12
+ * @category Components
13
+ */
14
+ class SplatComponentElement extends ComponentElement {
15
+ private _asset = '';
16
+
17
+ private _castShadows = false;
18
+
19
+ /** @ignore */
20
+ constructor() {
21
+ super('gsplat');
22
+ }
23
+
24
+ getInitialComponentData() {
25
+ return {
26
+ asset: AssetElement.get(this._asset),
27
+ castShadows: this._castShadows
28
+ };
29
+ }
30
+
31
+ /**
32
+ * Gets the underlying PlayCanvas splat component.
33
+ * @returns The splat component.
34
+ */
35
+ get component(): GSplatComponent | null {
36
+ return super.component as GSplatComponent | null;
37
+ }
38
+
39
+ /**
40
+ * Sets id of the `pc-asset` to use for the splat.
41
+ * @param value - The asset ID.
42
+ */
43
+ set asset(value: string) {
44
+ this._asset = value;
45
+ const asset = AssetElement.get(value);
46
+ if (this.component && asset) {
47
+ this.component.asset = asset;
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Gets the id of the `pc-asset` to use for the splat.
53
+ * @returns The asset ID.
54
+ */
55
+ get asset() {
56
+ return this._asset;
57
+ }
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
+
78
+ static get observedAttributes() {
79
+ return [
80
+ ...super.observedAttributes,
81
+ 'asset',
82
+ 'cast-shadows'
83
+ ];
84
+ }
85
+
86
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
87
+ super.attributeChangedCallback(name, _oldValue, newValue);
88
+
89
+ switch (name) {
90
+ case 'asset':
91
+ this.asset = newValue;
92
+ break;
93
+ case 'cast-shadows':
94
+ this.castShadows = this.hasAttribute('cast-shadows');
95
+ break;
96
+ }
97
+ }
98
+ }
99
+
100
+ customElements.define('pc-splat', SplatComponentElement);
101
+
102
+ export { SplatComponentElement };