@playcanvas/web-components 0.8.1 → 0.9.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.
- package/dist/app.d.ts +10 -2
- package/dist/asset.d.ts +18 -3
- package/dist/async-element.d.ts +51 -4
- package/dist/components/button-component.d.ts +10 -4
- package/dist/components/camera-component.d.ts +9 -4
- package/dist/components/collision-component.d.ts +9 -4
- package/dist/components/component.d.ts +7 -1
- package/dist/components/element-component.d.ts +17 -12
- package/dist/components/gsplat-component.d.ts +6 -1
- package/dist/components/layoutchild-component.d.ts +6 -1
- package/dist/components/layoutgroup-component.d.ts +21 -15
- package/dist/components/light-component.d.ts +12 -6
- package/dist/components/listener-component.d.ts +6 -1
- package/dist/components/particlesystem-component.d.ts +6 -1
- package/dist/components/render-component.d.ts +13 -4
- package/dist/components/rigidbody-component.d.ts +9 -4
- package/dist/components/screen-component.d.ts +6 -1
- package/dist/components/script-component.d.ts +116 -16
- package/dist/components/script.d.ts +72 -8
- package/dist/components/scrollbar-component.d.ts +10 -4
- package/dist/components/scrollview-component.d.ts +17 -10
- package/dist/components/sound-component.d.ts +6 -1
- package/dist/components/sound-slot.d.ts +8 -3
- package/dist/entity.d.ts +26 -2
- package/dist/index.d.ts +3 -2
- package/dist/material.d.ts +10 -0
- package/dist/model.d.ts +5 -0
- package/dist/module.d.ts +5 -0
- package/dist/pwc.cjs +1574 -853
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +1574 -853
- 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 +1575 -855
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +14 -5
- package/dist/sky.d.ts +6 -0
- package/dist/utils.d.ts +81 -23
- package/package.json +23 -13
- package/src/app.ts +38 -12
- package/src/asset.ts +61 -8
- package/src/async-element.ts +86 -5
- package/src/components/button-component.ts +26 -19
- package/src/components/camera-component.ts +29 -23
- package/src/components/collision-component.ts +19 -13
- package/src/components/component.ts +32 -13
- package/src/components/element-component.ts +58 -52
- package/src/components/gsplat-component.ts +14 -7
- package/src/components/layoutchild-component.ts +16 -9
- package/src/components/layoutgroup-component.ts +38 -31
- package/src/components/light-component.ts +33 -31
- package/src/components/listener-component.ts +8 -2
- package/src/components/particlesystem-component.ts +8 -2
- package/src/components/render-component.ts +19 -8
- package/src/components/rigidbody-component.ts +21 -15
- package/src/components/screen-component.ts +15 -9
- package/src/components/script-component.ts +512 -125
- package/src/components/script.ts +116 -16
- package/src/components/scrollbar-component.ts +19 -12
- package/src/components/scrollview-component.ts +37 -29
- package/src/components/sound-component.ts +16 -9
- package/src/components/sound-slot.ts +23 -14
- package/src/entity.ts +61 -71
- package/src/index.ts +5 -2
- package/src/material.ts +34 -1
- package/src/model.ts +6 -0
- package/src/module.ts +6 -0
- package/src/scene.ts +25 -12
- package/src/sky.ts +34 -16
- package/src/utils.ts +180 -40
|
@@ -2,6 +2,7 @@ import { GSplatComponent } from 'playcanvas';
|
|
|
2
2
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
4
|
import { AssetElement } from '../asset';
|
|
5
|
+
import { parseBool, parseNumber } from '../utils';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The GSplatComponentElement interface provides properties and methods for manipulating
|
|
@@ -44,8 +45,8 @@ class GSplatComponentElement extends ComponentElement {
|
|
|
44
45
|
* Gets the underlying PlayCanvas gsplat component.
|
|
45
46
|
* @returns The gsplat component.
|
|
46
47
|
*/
|
|
47
|
-
get component(): GSplatComponent
|
|
48
|
-
return super.component as GSplatComponent
|
|
48
|
+
get component(): GSplatComponent {
|
|
49
|
+
return super.component as GSplatComponent;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
/**
|
|
@@ -195,19 +196,19 @@ class GSplatComponentElement extends ComponentElement {
|
|
|
195
196
|
this.asset = newValue;
|
|
196
197
|
break;
|
|
197
198
|
case 'cast-shadows':
|
|
198
|
-
this.castShadows =
|
|
199
|
+
this.castShadows = parseBool(newValue, false);
|
|
199
200
|
break;
|
|
200
201
|
case 'lod-base-distance':
|
|
201
|
-
this.lodBaseDistance =
|
|
202
|
+
this.lodBaseDistance = parseNumber(newValue, 5, name);
|
|
202
203
|
break;
|
|
203
204
|
case 'lod-multiplier':
|
|
204
|
-
this.lodMultiplier =
|
|
205
|
+
this.lodMultiplier = parseNumber(newValue, 3, name);
|
|
205
206
|
break;
|
|
206
207
|
case 'lod-range-min':
|
|
207
|
-
this.lodRangeMin =
|
|
208
|
+
this.lodRangeMin = parseNumber(newValue, 0, name);
|
|
208
209
|
break;
|
|
209
210
|
case 'lod-range-max':
|
|
210
|
-
this.lodRangeMax =
|
|
211
|
+
this.lodRangeMax = parseNumber(newValue, 99, name);
|
|
211
212
|
break;
|
|
212
213
|
}
|
|
213
214
|
}
|
|
@@ -215,4 +216,10 @@ class GSplatComponentElement extends ComponentElement {
|
|
|
215
216
|
|
|
216
217
|
customElements.define('pc-gsplat', GSplatComponentElement);
|
|
217
218
|
|
|
219
|
+
declare global {
|
|
220
|
+
interface HTMLElementTagNameMap {
|
|
221
|
+
'pc-gsplat': GSplatComponentElement;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
218
225
|
export { GSplatComponentElement };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LayoutChildComponent } from 'playcanvas';
|
|
2
2
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
|
+
import { parseBool, parseNumber } from '../utils';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The LayoutChildComponentElement interface provides properties and methods for manipulating
|
|
@@ -46,8 +47,8 @@ class LayoutChildComponentElement extends ComponentElement {
|
|
|
46
47
|
* Gets the underlying PlayCanvas layout child component.
|
|
47
48
|
* @returns The layout child component.
|
|
48
49
|
*/
|
|
49
|
-
get component(): LayoutChildComponent
|
|
50
|
-
return super.component as LayoutChildComponent
|
|
50
|
+
get component(): LayoutChildComponent {
|
|
51
|
+
return super.component as LayoutChildComponent;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
/**
|
|
@@ -203,25 +204,25 @@ class LayoutChildComponentElement extends ComponentElement {
|
|
|
203
204
|
|
|
204
205
|
switch (name) {
|
|
205
206
|
case 'min-width':
|
|
206
|
-
this.minWidth =
|
|
207
|
+
this.minWidth = parseNumber(newValue, 0, name);
|
|
207
208
|
break;
|
|
208
209
|
case 'min-height':
|
|
209
|
-
this.minHeight =
|
|
210
|
+
this.minHeight = parseNumber(newValue, 0, name);
|
|
210
211
|
break;
|
|
211
212
|
case 'max-width':
|
|
212
|
-
this.maxWidth = newValue
|
|
213
|
+
this.maxWidth = parseNumber(newValue, null, name);
|
|
213
214
|
break;
|
|
214
215
|
case 'max-height':
|
|
215
|
-
this.maxHeight = newValue
|
|
216
|
+
this.maxHeight = parseNumber(newValue, null, name);
|
|
216
217
|
break;
|
|
217
218
|
case 'fit-width-proportion':
|
|
218
|
-
this.fitWidthProportion =
|
|
219
|
+
this.fitWidthProportion = parseNumber(newValue, 0, name);
|
|
219
220
|
break;
|
|
220
221
|
case 'fit-height-proportion':
|
|
221
|
-
this.fitHeightProportion =
|
|
222
|
+
this.fitHeightProportion = parseNumber(newValue, 0, name);
|
|
222
223
|
break;
|
|
223
224
|
case 'exclude-from-layout':
|
|
224
|
-
this.excludeFromLayout = newValue
|
|
225
|
+
this.excludeFromLayout = parseBool(newValue, false);
|
|
225
226
|
break;
|
|
226
227
|
}
|
|
227
228
|
}
|
|
@@ -229,4 +230,10 @@ class LayoutChildComponentElement extends ComponentElement {
|
|
|
229
230
|
|
|
230
231
|
customElements.define('pc-layoutchild', LayoutChildComponentElement);
|
|
231
232
|
|
|
233
|
+
declare global {
|
|
234
|
+
interface HTMLElementTagNameMap {
|
|
235
|
+
'pc-layoutchild': LayoutChildComponentElement;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
232
239
|
export { LayoutChildComponentElement };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { FITTING_NONE, FITTING_STRETCH, FITTING_SHRINK, FITTING_BOTH, LayoutGroupComponent, ORIENTATION_HORIZONTAL, ORIENTATION_VERTICAL, Vec2, Vec4 } from 'playcanvas';
|
|
2
2
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
|
-
import { parseEnum, parseVec2, parseVec4 } from '../utils';
|
|
4
|
+
import { parseBool, parseEnum, parseVec2, parseVec4 } from '../utils';
|
|
5
5
|
|
|
6
|
-
const orientations = new Map<
|
|
6
|
+
const orientations = new Map<'horizontal' | 'vertical', number>([
|
|
7
7
|
['horizontal', ORIENTATION_HORIZONTAL],
|
|
8
8
|
['vertical', ORIENTATION_VERTICAL]
|
|
9
9
|
]);
|
|
10
10
|
|
|
11
|
-
const fittings = new Map<
|
|
11
|
+
const fittings = new Map<'none' | 'stretch' | 'shrink' | 'both', number>([
|
|
12
12
|
['none', FITTING_NONE],
|
|
13
13
|
['stretch', FITTING_STRETCH],
|
|
14
14
|
['shrink', FITTING_SHRINK],
|
|
@@ -24,7 +24,7 @@ const fittings = new Map<string, number>([
|
|
|
24
24
|
* @category Components
|
|
25
25
|
*/
|
|
26
26
|
class LayoutGroupComponentElement extends ComponentElement {
|
|
27
|
-
private _orientation:
|
|
27
|
+
private _orientation: 'horizontal' | 'vertical' = 'horizontal';
|
|
28
28
|
|
|
29
29
|
private _reverseX = false;
|
|
30
30
|
|
|
@@ -36,9 +36,9 @@ class LayoutGroupComponentElement extends ComponentElement {
|
|
|
36
36
|
|
|
37
37
|
private _spacing = new Vec2(0, 0);
|
|
38
38
|
|
|
39
|
-
private _widthFitting:
|
|
39
|
+
private _widthFitting: 'none' | 'stretch' | 'shrink' | 'both' = 'none';
|
|
40
40
|
|
|
41
|
-
private _heightFitting:
|
|
41
|
+
private _heightFitting: 'none' | 'stretch' | 'shrink' | 'both' = 'none';
|
|
42
42
|
|
|
43
43
|
private _wrap = false;
|
|
44
44
|
|
|
@@ -49,14 +49,14 @@ class LayoutGroupComponentElement extends ComponentElement {
|
|
|
49
49
|
|
|
50
50
|
getInitialComponentData() {
|
|
51
51
|
return {
|
|
52
|
-
orientation: this._orientation,
|
|
52
|
+
orientation: orientations.get(this._orientation),
|
|
53
53
|
reverseX: this._reverseX,
|
|
54
54
|
reverseY: this._reverseY,
|
|
55
55
|
alignment: this._alignment,
|
|
56
56
|
padding: this._padding,
|
|
57
57
|
spacing: this._spacing,
|
|
58
|
-
widthFitting: this._widthFitting,
|
|
59
|
-
heightFitting: this._heightFitting,
|
|
58
|
+
widthFitting: fittings.get(this._widthFitting),
|
|
59
|
+
heightFitting: fittings.get(this._heightFitting),
|
|
60
60
|
wrap: this._wrap
|
|
61
61
|
};
|
|
62
62
|
}
|
|
@@ -65,18 +65,19 @@ class LayoutGroupComponentElement extends ComponentElement {
|
|
|
65
65
|
* Gets the underlying PlayCanvas layout group component.
|
|
66
66
|
* @returns The layout group component.
|
|
67
67
|
*/
|
|
68
|
-
get component(): LayoutGroupComponent
|
|
69
|
-
return super.component as LayoutGroupComponent
|
|
68
|
+
get component(): LayoutGroupComponent {
|
|
69
|
+
return super.component as LayoutGroupComponent;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Sets the orientation of the layout group. Can be `horizontal`
|
|
73
|
+
* Sets the orientation of the layout group. Can be `horizontal` or `vertical`. Defaults to
|
|
74
|
+
* `horizontal`.
|
|
74
75
|
* @param value - The orientation.
|
|
75
76
|
*/
|
|
76
|
-
set orientation(value:
|
|
77
|
+
set orientation(value: 'horizontal' | 'vertical') {
|
|
77
78
|
this._orientation = value;
|
|
78
79
|
if (this.component) {
|
|
79
|
-
this.component.orientation = value;
|
|
80
|
+
this.component.orientation = orientations.get(value) ?? ORIENTATION_HORIZONTAL;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -184,14 +185,14 @@ class LayoutGroupComponentElement extends ComponentElement {
|
|
|
184
185
|
}
|
|
185
186
|
|
|
186
187
|
/**
|
|
187
|
-
* Sets the fitting mode along the horizontal axis. Can be `none
|
|
188
|
-
*
|
|
188
|
+
* Sets the fitting mode along the horizontal axis. Can be `none`, `stretch`, `shrink` or
|
|
189
|
+
* `both`. Defaults to `none`.
|
|
189
190
|
* @param value - The width fitting mode.
|
|
190
191
|
*/
|
|
191
|
-
set widthFitting(value:
|
|
192
|
+
set widthFitting(value: 'none' | 'stretch' | 'shrink' | 'both') {
|
|
192
193
|
this._widthFitting = value;
|
|
193
194
|
if (this.component) {
|
|
194
|
-
this.component.widthFitting = value;
|
|
195
|
+
this.component.widthFitting = fittings.get(value) ?? FITTING_NONE;
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
|
|
@@ -204,14 +205,14 @@ class LayoutGroupComponentElement extends ComponentElement {
|
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
/**
|
|
207
|
-
* Sets the fitting mode along the vertical axis. Can be `none
|
|
208
|
-
*
|
|
208
|
+
* Sets the fitting mode along the vertical axis. Can be `none`, `stretch`, `shrink` or
|
|
209
|
+
* `both`. Defaults to `none`.
|
|
209
210
|
* @param value - The height fitting mode.
|
|
210
211
|
*/
|
|
211
|
-
set heightFitting(value:
|
|
212
|
+
set heightFitting(value: 'none' | 'stretch' | 'shrink' | 'both') {
|
|
212
213
|
this._heightFitting = value;
|
|
213
214
|
if (this.component) {
|
|
214
|
-
this.component.heightFitting = value;
|
|
215
|
+
this.component.heightFitting = fittings.get(value) ?? FITTING_NONE;
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
218
|
|
|
@@ -262,31 +263,31 @@ class LayoutGroupComponentElement extends ComponentElement {
|
|
|
262
263
|
|
|
263
264
|
switch (name) {
|
|
264
265
|
case 'orientation':
|
|
265
|
-
this.orientation = parseEnum(newValue, orientations,
|
|
266
|
+
this.orientation = parseEnum(newValue, orientations, 'horizontal', name);
|
|
266
267
|
break;
|
|
267
268
|
case 'reverse-x':
|
|
268
|
-
this.reverseX = newValue
|
|
269
|
+
this.reverseX = parseBool(newValue, false);
|
|
269
270
|
break;
|
|
270
271
|
case 'reverse-y':
|
|
271
|
-
this.reverseY = newValue
|
|
272
|
+
this.reverseY = parseBool(newValue, false);
|
|
272
273
|
break;
|
|
273
274
|
case 'alignment':
|
|
274
|
-
this.alignment = parseVec2(newValue);
|
|
275
|
+
this.alignment = parseVec2(newValue, new Vec2(0, 1), name);
|
|
275
276
|
break;
|
|
276
277
|
case 'padding':
|
|
277
|
-
this.padding = parseVec4(newValue);
|
|
278
|
+
this.padding = parseVec4(newValue, Vec4.ZERO, name);
|
|
278
279
|
break;
|
|
279
280
|
case 'spacing':
|
|
280
|
-
this.spacing = parseVec2(newValue);
|
|
281
|
+
this.spacing = parseVec2(newValue, Vec2.ZERO, name);
|
|
281
282
|
break;
|
|
282
283
|
case 'width-fitting':
|
|
283
|
-
this.widthFitting = parseEnum(newValue, fittings,
|
|
284
|
+
this.widthFitting = parseEnum(newValue, fittings, 'none', name);
|
|
284
285
|
break;
|
|
285
286
|
case 'height-fitting':
|
|
286
|
-
this.heightFitting = parseEnum(newValue, fittings,
|
|
287
|
+
this.heightFitting = parseEnum(newValue, fittings, 'none', name);
|
|
287
288
|
break;
|
|
288
289
|
case 'wrap':
|
|
289
|
-
this.wrap = newValue
|
|
290
|
+
this.wrap = parseBool(newValue, false);
|
|
290
291
|
break;
|
|
291
292
|
}
|
|
292
293
|
}
|
|
@@ -294,4 +295,10 @@ class LayoutGroupComponentElement extends ComponentElement {
|
|
|
294
295
|
|
|
295
296
|
customElements.define('pc-layoutgroup', LayoutGroupComponentElement);
|
|
296
297
|
|
|
298
|
+
declare global {
|
|
299
|
+
interface HTMLElementTagNameMap {
|
|
300
|
+
'pc-layoutgroup': LayoutGroupComponentElement;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
297
304
|
export { LayoutGroupComponentElement };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Color, LightComponent, SHADOW_PCF1_16F, SHADOW_PCF1_32F, SHADOW_PCF3_16F, SHADOW_PCF3_32F, SHADOW_PCF5_16F, SHADOW_PCF5_32F, SHADOW_PCSS_32F, SHADOW_VSM_16F, SHADOW_VSM_32F } from 'playcanvas';
|
|
2
2
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
|
-
import { parseColor } from '../utils';
|
|
4
|
+
import { parseBool, parseColor, parseEnum, parseNumber } from '../utils';
|
|
5
5
|
|
|
6
|
-
const shadowTypes = new Map([
|
|
6
|
+
const shadowTypes = new Map<'pcf1-16f' | 'pcf1-32f' | 'pcf3-16f' | 'pcf3-32f' | 'pcf5-16f' | 'pcf5-32f' | 'vsm-16f' | 'vsm-32f' | 'pcss-32f', number>([
|
|
7
7
|
['pcf1-16f', SHADOW_PCF1_16F],
|
|
8
8
|
['pcf1-32f', SHADOW_PCF1_32F],
|
|
9
9
|
['pcf3-16f', SHADOW_PCF3_16F],
|
|
@@ -48,7 +48,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
48
48
|
|
|
49
49
|
private _shadowType: 'pcf1-16f' | 'pcf1-32f' | 'pcf3-16f' | 'pcf3-32f' | 'pcf5-16f' | 'pcf5-32f' | 'vsm-16f' | 'vsm-32f' | 'pcss-32f' = 'pcf3-32f';
|
|
50
50
|
|
|
51
|
-
private _type = 'directional';
|
|
51
|
+
private _type: 'directional' | 'omni' | 'spot' = 'directional';
|
|
52
52
|
|
|
53
53
|
private _vsmBias = 0.01;
|
|
54
54
|
|
|
@@ -95,8 +95,8 @@ class LightComponentElement extends ComponentElement {
|
|
|
95
95
|
* Gets the underlying PlayCanvas light component.
|
|
96
96
|
* @returns The light component.
|
|
97
97
|
*/
|
|
98
|
-
get component(): LightComponent
|
|
99
|
-
return super.component as LightComponent
|
|
98
|
+
get component(): LightComponent {
|
|
99
|
+
return super.component as LightComponent;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
@@ -338,15 +338,11 @@ class LightComponentElement extends ComponentElement {
|
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
/**
|
|
341
|
-
* Sets the type of the light.
|
|
341
|
+
* Sets the type of the light. Can be `directional`, `omni` or `spot`. Defaults to
|
|
342
|
+
* `directional`.
|
|
342
343
|
* @param value - The type.
|
|
343
344
|
*/
|
|
344
|
-
set type(value:
|
|
345
|
-
if (!['directional', 'omni', 'spot'].includes(value)) {
|
|
346
|
-
console.warn(`Invalid light type '${value}', using default type '${this._type}'.`);
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
|
|
345
|
+
set type(value: 'directional' | 'omni' | 'spot') {
|
|
350
346
|
this._type = value;
|
|
351
347
|
if (this.component) {
|
|
352
348
|
this.component.type = value;
|
|
@@ -505,61 +501,61 @@ class LightComponentElement extends ComponentElement {
|
|
|
505
501
|
|
|
506
502
|
switch (name) {
|
|
507
503
|
case 'color':
|
|
508
|
-
this.color = parseColor(newValue);
|
|
504
|
+
this.color = parseColor(newValue, Color.WHITE, name);
|
|
509
505
|
break;
|
|
510
506
|
case 'cast-shadows':
|
|
511
|
-
this.castShadows =
|
|
507
|
+
this.castShadows = parseBool(newValue, false);
|
|
512
508
|
break;
|
|
513
509
|
case 'inner-cone-angle':
|
|
514
|
-
this.innerConeAngle =
|
|
510
|
+
this.innerConeAngle = parseNumber(newValue, 40, name);
|
|
515
511
|
break;
|
|
516
512
|
case 'intensity':
|
|
517
|
-
this.intensity =
|
|
513
|
+
this.intensity = parseNumber(newValue, 1, name);
|
|
518
514
|
break;
|
|
519
515
|
case 'normal-offset-bias':
|
|
520
|
-
this.normalOffsetBias =
|
|
516
|
+
this.normalOffsetBias = parseNumber(newValue, 0.05, name);
|
|
521
517
|
break;
|
|
522
518
|
case 'outer-cone-angle':
|
|
523
|
-
this.outerConeAngle =
|
|
519
|
+
this.outerConeAngle = parseNumber(newValue, 45, name);
|
|
524
520
|
break;
|
|
525
521
|
case 'penumbra-falloff':
|
|
526
|
-
this.penumbraFalloff =
|
|
522
|
+
this.penumbraFalloff = parseNumber(newValue, 1, name);
|
|
527
523
|
break;
|
|
528
524
|
case 'penumbra-size':
|
|
529
|
-
this.penumbraSize =
|
|
525
|
+
this.penumbraSize = parseNumber(newValue, 1, name);
|
|
530
526
|
break;
|
|
531
527
|
case 'range':
|
|
532
|
-
this.range =
|
|
528
|
+
this.range = parseNumber(newValue, 10, name);
|
|
533
529
|
break;
|
|
534
530
|
case 'shadow-bias':
|
|
535
|
-
this.shadowBias =
|
|
531
|
+
this.shadowBias = parseNumber(newValue, 0.2, name);
|
|
536
532
|
break;
|
|
537
533
|
case 'shadow-distance':
|
|
538
|
-
this.shadowDistance =
|
|
534
|
+
this.shadowDistance = parseNumber(newValue, 16, name);
|
|
539
535
|
break;
|
|
540
536
|
case 'shadow-blocker-samples':
|
|
541
|
-
this.shadowBlockerSamples =
|
|
537
|
+
this.shadowBlockerSamples = parseNumber(newValue, 16, name);
|
|
542
538
|
break;
|
|
543
539
|
case 'shadow-resolution':
|
|
544
|
-
this.shadowResolution =
|
|
540
|
+
this.shadowResolution = parseNumber(newValue, 1024, name);
|
|
545
541
|
break;
|
|
546
542
|
case 'shadow-intensity':
|
|
547
|
-
this.shadowIntensity =
|
|
543
|
+
this.shadowIntensity = parseNumber(newValue, 1, name);
|
|
548
544
|
break;
|
|
549
545
|
case 'shadow-samples':
|
|
550
|
-
this.shadowSamples =
|
|
546
|
+
this.shadowSamples = parseNumber(newValue, 16, name);
|
|
551
547
|
break;
|
|
552
548
|
case 'shadow-type':
|
|
553
|
-
this.shadowType = newValue
|
|
549
|
+
this.shadowType = parseEnum(newValue, shadowTypes, 'pcf3-32f', name);
|
|
554
550
|
break;
|
|
555
551
|
case 'type':
|
|
556
|
-
this.type = newValue;
|
|
552
|
+
this.type = parseEnum(newValue, ['directional', 'omni', 'spot'], 'directional', name);
|
|
557
553
|
break;
|
|
558
554
|
case 'vsm-bias':
|
|
559
|
-
this.vsmBias =
|
|
555
|
+
this.vsmBias = parseNumber(newValue, 0.01, name);
|
|
560
556
|
break;
|
|
561
557
|
case 'vsm-blur-size':
|
|
562
|
-
this.vsmBlurSize =
|
|
558
|
+
this.vsmBlurSize = parseNumber(newValue, 11, name);
|
|
563
559
|
break;
|
|
564
560
|
}
|
|
565
561
|
}
|
|
@@ -567,4 +563,10 @@ class LightComponentElement extends ComponentElement {
|
|
|
567
563
|
|
|
568
564
|
customElements.define('pc-light', LightComponentElement);
|
|
569
565
|
|
|
566
|
+
declare global {
|
|
567
|
+
interface HTMLElementTagNameMap {
|
|
568
|
+
'pc-light': LightComponentElement;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
570
572
|
export { LightComponentElement };
|
|
@@ -20,11 +20,17 @@ class ListenerComponentElement extends ComponentElement {
|
|
|
20
20
|
* Gets the underlying PlayCanvas audio listener component.
|
|
21
21
|
* @returns The audio listener component.
|
|
22
22
|
*/
|
|
23
|
-
get component(): AudioListenerComponent
|
|
24
|
-
return super.component as AudioListenerComponent
|
|
23
|
+
get component(): AudioListenerComponent {
|
|
24
|
+
return super.component as AudioListenerComponent;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
customElements.define('pc-listener', ListenerComponentElement);
|
|
29
29
|
|
|
30
|
+
declare global {
|
|
31
|
+
interface HTMLElementTagNameMap {
|
|
32
|
+
'pc-listener': ListenerComponentElement;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
export { ListenerComponentElement };
|
|
@@ -40,8 +40,8 @@ class ParticleSystemComponentElement extends ComponentElement {
|
|
|
40
40
|
* Gets the underlying PlayCanvas particle system component.
|
|
41
41
|
* @returns The particle system component.
|
|
42
42
|
*/
|
|
43
|
-
get component(): ParticleSystemComponent
|
|
44
|
-
return super.component as ParticleSystemComponent
|
|
43
|
+
get component(): ParticleSystemComponent {
|
|
44
|
+
return super.component as ParticleSystemComponent;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
private applyConfig(resource: any) {
|
|
@@ -152,4 +152,10 @@ class ParticleSystemComponentElement extends ComponentElement {
|
|
|
152
152
|
|
|
153
153
|
customElements.define('pc-particles', ParticleSystemComponentElement);
|
|
154
154
|
|
|
155
|
+
declare global {
|
|
156
|
+
interface HTMLElementTagNameMap {
|
|
157
|
+
'pc-particles': ParticleSystemComponentElement;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
155
161
|
export { ParticleSystemComponentElement };
|
|
@@ -2,6 +2,7 @@ import { RenderComponent, StandardMaterial } from 'playcanvas';
|
|
|
2
2
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
4
|
import { MaterialElement } from '../material';
|
|
5
|
+
import { parseBool, parseEnum } from '../utils';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The RenderComponentElement interface provides properties and methods for manipulating
|
|
@@ -9,6 +10,10 @@ import { MaterialElement } from '../material';
|
|
|
9
10
|
* The RenderComponentElement interface also inherits the properties and methods of the
|
|
10
11
|
* {@link HTMLElement} interface.
|
|
11
12
|
*
|
|
13
|
+
* This element renders one of the engine's built-in primitives, selected with `type` (defaulting
|
|
14
|
+
* to `box`). It does not cover the engine's `asset` render type, since there is no way to supply
|
|
15
|
+
* a render asset here — use `pc-model` for glTF content instead.
|
|
16
|
+
*
|
|
12
17
|
* @category Components
|
|
13
18
|
*/
|
|
14
19
|
class RenderComponentElement extends ComponentElement {
|
|
@@ -18,7 +23,7 @@ class RenderComponentElement extends ComponentElement {
|
|
|
18
23
|
|
|
19
24
|
private _receiveShadows = true;
|
|
20
25
|
|
|
21
|
-
private _type: '
|
|
26
|
+
private _type: 'box' | 'capsule' | 'cone' | 'cylinder' | 'plane' | 'sphere' = 'box';
|
|
22
27
|
|
|
23
28
|
/** @ignore */
|
|
24
29
|
constructor() {
|
|
@@ -38,15 +43,15 @@ class RenderComponentElement extends ComponentElement {
|
|
|
38
43
|
* Gets the underlying PlayCanvas render component.
|
|
39
44
|
* @returns The render component.
|
|
40
45
|
*/
|
|
41
|
-
get component(): RenderComponent
|
|
42
|
-
return super.component as RenderComponent
|
|
46
|
+
get component(): RenderComponent {
|
|
47
|
+
return super.component as RenderComponent;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
/**
|
|
46
51
|
* Sets the type of the render component.
|
|
47
52
|
* @param value - The type.
|
|
48
53
|
*/
|
|
49
|
-
set type(value: '
|
|
54
|
+
set type(value: 'box' | 'capsule' | 'cone' | 'cylinder' | 'plane' | 'sphere') {
|
|
50
55
|
this._type = value;
|
|
51
56
|
if (this.component) {
|
|
52
57
|
this.component.type = value;
|
|
@@ -57,7 +62,7 @@ class RenderComponentElement extends ComponentElement {
|
|
|
57
62
|
* Gets the type of the render component.
|
|
58
63
|
* @returns The type.
|
|
59
64
|
*/
|
|
60
|
-
get type(): '
|
|
65
|
+
get type(): 'box' | 'capsule' | 'cone' | 'cylinder' | 'plane' | 'sphere' {
|
|
61
66
|
return this._type;
|
|
62
67
|
}
|
|
63
68
|
|
|
@@ -127,16 +132,16 @@ class RenderComponentElement extends ComponentElement {
|
|
|
127
132
|
|
|
128
133
|
switch (name) {
|
|
129
134
|
case 'cast-shadows':
|
|
130
|
-
this.castShadows = newValue
|
|
135
|
+
this.castShadows = parseBool(newValue, true);
|
|
131
136
|
break;
|
|
132
137
|
case 'material':
|
|
133
138
|
this.material = newValue;
|
|
134
139
|
break;
|
|
135
140
|
case 'receive-shadows':
|
|
136
|
-
this.receiveShadows = newValue
|
|
141
|
+
this.receiveShadows = parseBool(newValue, true);
|
|
137
142
|
break;
|
|
138
143
|
case 'type':
|
|
139
|
-
this.type = newValue
|
|
144
|
+
this.type = parseEnum(newValue, ['box', 'capsule', 'cone', 'cylinder', 'plane', 'sphere'], 'box', name);
|
|
140
145
|
break;
|
|
141
146
|
}
|
|
142
147
|
}
|
|
@@ -144,4 +149,10 @@ class RenderComponentElement extends ComponentElement {
|
|
|
144
149
|
|
|
145
150
|
customElements.define('pc-render', RenderComponentElement);
|
|
146
151
|
|
|
152
|
+
declare global {
|
|
153
|
+
interface HTMLElementTagNameMap {
|
|
154
|
+
'pc-render': RenderComponentElement;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
147
158
|
export { RenderComponentElement };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RigidBodyComponent, Vec3 } from 'playcanvas';
|
|
2
2
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
|
-
import { parseVec3 } from '../utils';
|
|
4
|
+
import { parseEnum, parseNumber, parseVec3 } from '../utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The RigidBodyComponentElement interface provides properties and methods for manipulating
|
|
@@ -55,7 +55,7 @@ class RigidBodyComponentElement extends ComponentElement {
|
|
|
55
55
|
/**
|
|
56
56
|
* The type of the rigidbody.
|
|
57
57
|
*/
|
|
58
|
-
private _type:
|
|
58
|
+
private _type: 'static' | 'dynamic' | 'kinematic' = 'static';
|
|
59
59
|
|
|
60
60
|
/** @ignore */
|
|
61
61
|
constructor() {
|
|
@@ -80,8 +80,8 @@ class RigidBodyComponentElement extends ComponentElement {
|
|
|
80
80
|
* Gets the underlying PlayCanvas rigidbody component.
|
|
81
81
|
* @returns The rigidbody component.
|
|
82
82
|
*/
|
|
83
|
-
get component(): RigidBodyComponent
|
|
84
|
-
return super.component as RigidBodyComponent
|
|
83
|
+
get component(): RigidBodyComponent {
|
|
84
|
+
return super.component as RigidBodyComponent;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
set angularDamping(value: number) {
|
|
@@ -172,10 +172,10 @@ class RigidBodyComponentElement extends ComponentElement {
|
|
|
172
172
|
return this._rollingFriction;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
set type(value:
|
|
175
|
+
set type(value: 'static' | 'dynamic' | 'kinematic') {
|
|
176
176
|
this._type = value;
|
|
177
177
|
if (this.component) {
|
|
178
|
-
this.component.type = value
|
|
178
|
+
this.component.type = value;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -192,31 +192,31 @@ class RigidBodyComponentElement extends ComponentElement {
|
|
|
192
192
|
|
|
193
193
|
switch (name) {
|
|
194
194
|
case 'angular-damping':
|
|
195
|
-
this.angularDamping =
|
|
195
|
+
this.angularDamping = parseNumber(newValue, 0, name);
|
|
196
196
|
break;
|
|
197
197
|
case 'angular-factor':
|
|
198
|
-
this.angularFactor = parseVec3(newValue);
|
|
198
|
+
this.angularFactor = parseVec3(newValue, Vec3.ONE, name);
|
|
199
199
|
break;
|
|
200
200
|
case 'friction':
|
|
201
|
-
this.friction =
|
|
201
|
+
this.friction = parseNumber(newValue, 0.5, name);
|
|
202
202
|
break;
|
|
203
203
|
case 'linear-damping':
|
|
204
|
-
this.linearDamping =
|
|
204
|
+
this.linearDamping = parseNumber(newValue, 0, name);
|
|
205
205
|
break;
|
|
206
206
|
case 'linear-factor':
|
|
207
|
-
this.linearFactor = parseVec3(newValue);
|
|
207
|
+
this.linearFactor = parseVec3(newValue, Vec3.ONE, name);
|
|
208
208
|
break;
|
|
209
209
|
case 'mass':
|
|
210
|
-
this.mass =
|
|
210
|
+
this.mass = parseNumber(newValue, 1, name);
|
|
211
211
|
break;
|
|
212
212
|
case 'restitution':
|
|
213
|
-
this.restitution =
|
|
213
|
+
this.restitution = parseNumber(newValue, 0, name);
|
|
214
214
|
break;
|
|
215
215
|
case 'rolling-friction':
|
|
216
|
-
this.rollingFriction =
|
|
216
|
+
this.rollingFriction = parseNumber(newValue, 0, name);
|
|
217
217
|
break;
|
|
218
218
|
case 'type':
|
|
219
|
-
this.type = newValue;
|
|
219
|
+
this.type = parseEnum(newValue, ['static', 'dynamic', 'kinematic'], 'static', name);
|
|
220
220
|
break;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
@@ -224,4 +224,10 @@ class RigidBodyComponentElement extends ComponentElement {
|
|
|
224
224
|
|
|
225
225
|
customElements.define('pc-rigidbody', RigidBodyComponentElement);
|
|
226
226
|
|
|
227
|
+
declare global {
|
|
228
|
+
interface HTMLElementTagNameMap {
|
|
229
|
+
'pc-rigidbody': RigidBodyComponentElement;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
227
233
|
export { RigidBodyComponentElement };
|