@playcanvas/web-components 0.3.0 → 0.6.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 (43) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +84 -84
  3. package/dist/components/gsplat-component.d.ts +79 -0
  4. package/dist/components/light-component.d.ts +48 -0
  5. package/dist/index.d.ts +2 -2
  6. package/dist/pwc.cjs +324 -203
  7. package/dist/pwc.cjs.map +1 -1
  8. package/dist/pwc.js +324 -203
  9. package/dist/pwc.js.map +1 -1
  10. package/dist/pwc.min.js +1 -1
  11. package/dist/pwc.min.js.map +1 -1
  12. package/dist/pwc.mjs +325 -204
  13. package/dist/pwc.mjs.map +1 -1
  14. package/package.json +76 -66
  15. package/src/app.ts +612 -606
  16. package/src/asset.ts +159 -159
  17. package/src/async-element.ts +46 -46
  18. package/src/colors.ts +150 -150
  19. package/src/components/camera-component.ts +557 -557
  20. package/src/components/collision-component.ts +183 -183
  21. package/src/components/component.ts +97 -97
  22. package/src/components/element-component.ts +367 -367
  23. package/src/components/gsplat-component.ts +161 -0
  24. package/src/components/light-component.ts +570 -466
  25. package/src/components/listener-component.ts +30 -30
  26. package/src/components/particlesystem-component.ts +155 -155
  27. package/src/components/render-component.ts +147 -147
  28. package/src/components/rigidbody-component.ts +227 -227
  29. package/src/components/screen-component.ts +157 -157
  30. package/src/components/script-component.ts +270 -270
  31. package/src/components/script.ts +90 -90
  32. package/src/components/sound-component.ts +230 -230
  33. package/src/components/sound-slot.ts +288 -288
  34. package/src/entity.ts +360 -360
  35. package/src/index.ts +63 -63
  36. package/src/material.ts +141 -141
  37. package/src/model.ts +111 -111
  38. package/src/module.ts +43 -43
  39. package/src/scene.ts +217 -217
  40. package/src/sky.ts +293 -293
  41. package/src/utils.ts +71 -71
  42. package/dist/components/splat-component.d.ts +0 -61
  43. package/src/components/splat-component.ts +0 -133
@@ -1,227 +1,227 @@
1
- import { RigidBodyComponent, Vec3 } from 'playcanvas';
2
-
3
- import { ComponentElement } from './component';
4
- import { parseVec3 } from '../utils';
5
-
6
- /**
7
- * The RigidBodyComponentElement interface provides properties and methods for manipulating
8
- * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-rigidbody/ | `<pc-rigidbody>`} elements.
9
- * The RigidBodyComponentElement interface also inherits the properties and methods of the
10
- * {@link HTMLElement} interface.
11
- *
12
- * @category Components
13
- */
14
- class RigidBodyComponentElement extends ComponentElement {
15
- /**
16
- * The angular damping of the rigidbody.
17
- */
18
- private _angularDamping: number = 0;
19
-
20
- /**
21
- * The angular factor of the rigidbody.
22
- */
23
- private _angularFactor: Vec3 = new Vec3(1, 1, 1);
24
-
25
- /**
26
- * The friction of the rigidbody.
27
- */
28
- private _friction: number = 0.5;
29
-
30
- /**
31
- * The linear damping of the rigidbody.
32
- */
33
- private _linearDamping: number = 0;
34
-
35
- /**
36
- * The linear factor of the rigidbody.
37
- */
38
- private _linearFactor: Vec3 = new Vec3(1, 1, 1);
39
-
40
- /**
41
- * The mass of the rigidbody.
42
- */
43
- private _mass: number = 1;
44
-
45
- /**
46
- * The restitution of the rigidbody.
47
- */
48
- private _restitution: number = 0;
49
-
50
- /**
51
- * The rolling friction of the rigidbody.
52
- */
53
- private _rollingFriction: number = 0;
54
-
55
- /**
56
- * The type of the rigidbody.
57
- */
58
- private _type: string = 'static';
59
-
60
- /** @ignore */
61
- constructor() {
62
- super('rigidbody');
63
- }
64
-
65
- getInitialComponentData() {
66
- return {
67
- angularDamping: this._angularDamping,
68
- angularFactor: this._angularFactor,
69
- friction: this._friction,
70
- linearDamping: this._linearDamping,
71
- linearFactor: this._linearFactor,
72
- mass: this._mass,
73
- restitution: this._restitution,
74
- rollingFriction: this._rollingFriction,
75
- type: this._type
76
- };
77
- }
78
-
79
- /**
80
- * Gets the underlying PlayCanvas rigidbody component.
81
- * @returns The rigidbody component.
82
- */
83
- get component(): RigidBodyComponent | null {
84
- return super.component as RigidBodyComponent | null;
85
- }
86
-
87
- set angularDamping(value: number) {
88
- this._angularDamping = value;
89
- if (this.component) {
90
- this.component.angularDamping = value;
91
- }
92
- }
93
-
94
- get angularDamping() {
95
- return this._angularDamping;
96
- }
97
-
98
- set angularFactor(value: Vec3) {
99
- this._angularFactor = value;
100
- if (this.component) {
101
- this.component.angularFactor = value;
102
- }
103
- }
104
-
105
- get angularFactor() {
106
- return this._angularFactor;
107
- }
108
-
109
- set friction(value: number) {
110
- this._friction = value;
111
- if (this.component) {
112
- this.component.friction = value;
113
- }
114
- }
115
-
116
- get friction() {
117
- return this._friction;
118
- }
119
-
120
- set linearDamping(value: number) {
121
- this._linearDamping = value;
122
- if (this.component) {
123
- this.component.linearDamping = value;
124
- }
125
- }
126
-
127
- get linearDamping() {
128
- return this._linearDamping;
129
- }
130
-
131
- set linearFactor(value: Vec3) {
132
- this._linearFactor = value;
133
- if (this.component) {
134
- this.component.linearFactor = value;
135
- }
136
- }
137
-
138
- get linearFactor() {
139
- return this._linearFactor;
140
- }
141
-
142
- set mass(value: number) {
143
- this._mass = value;
144
- if (this.component) {
145
- this.component.mass = value;
146
- }
147
- }
148
-
149
- get mass() {
150
- return this._mass;
151
- }
152
-
153
- set restitution(value: number) {
154
- this._restitution = value;
155
- if (this.component) {
156
- this.component.restitution = value;
157
- }
158
- }
159
-
160
- get restitution() {
161
- return this._restitution;
162
- }
163
-
164
- set rollingFriction(value: number) {
165
- this._rollingFriction = value;
166
- if (this.component) {
167
- this.component.rollingFriction = value;
168
- }
169
- }
170
-
171
- get rollingFriction() {
172
- return this._rollingFriction;
173
- }
174
-
175
- set type(value: string) {
176
- this._type = value;
177
- if (this.component) {
178
- this.component.type = value as 'static' | 'dynamic' | 'kinematic';
179
- }
180
- }
181
-
182
- get type() {
183
- return this._type;
184
- }
185
-
186
- static get observedAttributes() {
187
- return [...super.observedAttributes, 'angular-damping', 'angular-factor', 'friction', 'linear-damping', 'linear-factor', 'mass', 'restitution', 'rolling-friction', 'type'];
188
- }
189
-
190
- attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
191
- super.attributeChangedCallback(name, _oldValue, newValue);
192
-
193
- switch (name) {
194
- case 'angular-damping':
195
- this.angularDamping = parseFloat(newValue);
196
- break;
197
- case 'angular-factor':
198
- this.angularFactor = parseVec3(newValue);
199
- break;
200
- case 'friction':
201
- this.friction = parseFloat(newValue);
202
- break;
203
- case 'linear-damping':
204
- this.linearDamping = parseFloat(newValue);
205
- break;
206
- case 'linear-factor':
207
- this.linearFactor = parseVec3(newValue);
208
- break;
209
- case 'mass':
210
- this.mass = parseFloat(newValue);
211
- break;
212
- case 'restitution':
213
- this.restitution = parseFloat(newValue);
214
- break;
215
- case 'rolling-friction':
216
- this.rollingFriction = parseFloat(newValue);
217
- break;
218
- case 'type':
219
- this.type = newValue;
220
- break;
221
- }
222
- }
223
- }
224
-
225
- customElements.define('pc-rigidbody', RigidBodyComponentElement);
226
-
227
- export { RigidBodyComponentElement };
1
+ import { RigidBodyComponent, Vec3 } from 'playcanvas';
2
+
3
+ import { ComponentElement } from './component';
4
+ import { parseVec3 } from '../utils';
5
+
6
+ /**
7
+ * The RigidBodyComponentElement interface provides properties and methods for manipulating
8
+ * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-rigidbody/ | `<pc-rigidbody>`} elements.
9
+ * The RigidBodyComponentElement interface also inherits the properties and methods of the
10
+ * {@link HTMLElement} interface.
11
+ *
12
+ * @category Components
13
+ */
14
+ class RigidBodyComponentElement extends ComponentElement {
15
+ /**
16
+ * The angular damping of the rigidbody.
17
+ */
18
+ private _angularDamping: number = 0;
19
+
20
+ /**
21
+ * The angular factor of the rigidbody.
22
+ */
23
+ private _angularFactor: Vec3 = new Vec3(1, 1, 1);
24
+
25
+ /**
26
+ * The friction of the rigidbody.
27
+ */
28
+ private _friction: number = 0.5;
29
+
30
+ /**
31
+ * The linear damping of the rigidbody.
32
+ */
33
+ private _linearDamping: number = 0;
34
+
35
+ /**
36
+ * The linear factor of the rigidbody.
37
+ */
38
+ private _linearFactor: Vec3 = new Vec3(1, 1, 1);
39
+
40
+ /**
41
+ * The mass of the rigidbody.
42
+ */
43
+ private _mass: number = 1;
44
+
45
+ /**
46
+ * The restitution of the rigidbody.
47
+ */
48
+ private _restitution: number = 0;
49
+
50
+ /**
51
+ * The rolling friction of the rigidbody.
52
+ */
53
+ private _rollingFriction: number = 0;
54
+
55
+ /**
56
+ * The type of the rigidbody.
57
+ */
58
+ private _type: string = 'static';
59
+
60
+ /** @ignore */
61
+ constructor() {
62
+ super('rigidbody');
63
+ }
64
+
65
+ getInitialComponentData() {
66
+ return {
67
+ angularDamping: this._angularDamping,
68
+ angularFactor: this._angularFactor,
69
+ friction: this._friction,
70
+ linearDamping: this._linearDamping,
71
+ linearFactor: this._linearFactor,
72
+ mass: this._mass,
73
+ restitution: this._restitution,
74
+ rollingFriction: this._rollingFriction,
75
+ type: this._type
76
+ };
77
+ }
78
+
79
+ /**
80
+ * Gets the underlying PlayCanvas rigidbody component.
81
+ * @returns The rigidbody component.
82
+ */
83
+ get component(): RigidBodyComponent | null {
84
+ return super.component as RigidBodyComponent | null;
85
+ }
86
+
87
+ set angularDamping(value: number) {
88
+ this._angularDamping = value;
89
+ if (this.component) {
90
+ this.component.angularDamping = value;
91
+ }
92
+ }
93
+
94
+ get angularDamping() {
95
+ return this._angularDamping;
96
+ }
97
+
98
+ set angularFactor(value: Vec3) {
99
+ this._angularFactor = value;
100
+ if (this.component) {
101
+ this.component.angularFactor = value;
102
+ }
103
+ }
104
+
105
+ get angularFactor() {
106
+ return this._angularFactor;
107
+ }
108
+
109
+ set friction(value: number) {
110
+ this._friction = value;
111
+ if (this.component) {
112
+ this.component.friction = value;
113
+ }
114
+ }
115
+
116
+ get friction() {
117
+ return this._friction;
118
+ }
119
+
120
+ set linearDamping(value: number) {
121
+ this._linearDamping = value;
122
+ if (this.component) {
123
+ this.component.linearDamping = value;
124
+ }
125
+ }
126
+
127
+ get linearDamping() {
128
+ return this._linearDamping;
129
+ }
130
+
131
+ set linearFactor(value: Vec3) {
132
+ this._linearFactor = value;
133
+ if (this.component) {
134
+ this.component.linearFactor = value;
135
+ }
136
+ }
137
+
138
+ get linearFactor() {
139
+ return this._linearFactor;
140
+ }
141
+
142
+ set mass(value: number) {
143
+ this._mass = value;
144
+ if (this.component) {
145
+ this.component.mass = value;
146
+ }
147
+ }
148
+
149
+ get mass() {
150
+ return this._mass;
151
+ }
152
+
153
+ set restitution(value: number) {
154
+ this._restitution = value;
155
+ if (this.component) {
156
+ this.component.restitution = value;
157
+ }
158
+ }
159
+
160
+ get restitution() {
161
+ return this._restitution;
162
+ }
163
+
164
+ set rollingFriction(value: number) {
165
+ this._rollingFriction = value;
166
+ if (this.component) {
167
+ this.component.rollingFriction = value;
168
+ }
169
+ }
170
+
171
+ get rollingFriction() {
172
+ return this._rollingFriction;
173
+ }
174
+
175
+ set type(value: string) {
176
+ this._type = value;
177
+ if (this.component) {
178
+ this.component.type = value as 'static' | 'dynamic' | 'kinematic';
179
+ }
180
+ }
181
+
182
+ get type() {
183
+ return this._type;
184
+ }
185
+
186
+ static get observedAttributes() {
187
+ return [...super.observedAttributes, 'angular-damping', 'angular-factor', 'friction', 'linear-damping', 'linear-factor', 'mass', 'restitution', 'rolling-friction', 'type'];
188
+ }
189
+
190
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
191
+ super.attributeChangedCallback(name, _oldValue, newValue);
192
+
193
+ switch (name) {
194
+ case 'angular-damping':
195
+ this.angularDamping = parseFloat(newValue);
196
+ break;
197
+ case 'angular-factor':
198
+ this.angularFactor = parseVec3(newValue);
199
+ break;
200
+ case 'friction':
201
+ this.friction = parseFloat(newValue);
202
+ break;
203
+ case 'linear-damping':
204
+ this.linearDamping = parseFloat(newValue);
205
+ break;
206
+ case 'linear-factor':
207
+ this.linearFactor = parseVec3(newValue);
208
+ break;
209
+ case 'mass':
210
+ this.mass = parseFloat(newValue);
211
+ break;
212
+ case 'restitution':
213
+ this.restitution = parseFloat(newValue);
214
+ break;
215
+ case 'rolling-friction':
216
+ this.rollingFriction = parseFloat(newValue);
217
+ break;
218
+ case 'type':
219
+ this.type = newValue;
220
+ break;
221
+ }
222
+ }
223
+ }
224
+
225
+ customElements.define('pc-rigidbody', RigidBodyComponentElement);
226
+
227
+ export { RigidBodyComponentElement };