@playcanvas/web-components 0.9.0 → 0.10.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/README.md +18 -0
- package/dist/app.d.ts +3 -2
- package/dist/asset.d.ts +16 -1
- package/dist/async-element.d.ts +3 -0
- package/dist/components/button-component.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/component.d.ts +1 -1
- package/dist/components/element-component.d.ts +1 -1
- package/dist/components/gsplat-component.d.ts +1 -1
- package/dist/components/layoutchild-component.d.ts +1 -1
- package/dist/components/layoutgroup-component.d.ts +1 -1
- package/dist/components/light-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.d.ts +8 -1
- package/dist/components/scrollbar-component.d.ts +1 -1
- package/dist/components/scrollview-component.d.ts +1 -1
- package/dist/components/sound-component.d.ts +1 -1
- package/dist/components/sound-slot.d.ts +9 -1
- package/dist/custom-elements.json +16231 -0
- package/dist/entity.d.ts +19 -1
- package/dist/material.d.ts +966 -4
- package/dist/model.d.ts +1 -1
- package/dist/module.d.ts +10 -0
- package/dist/{utils.d.ts → parse.d.ts} +63 -33
- package/dist/pwc.cjs +2677 -586
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +2677 -586
- 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.min.mjs +2 -0
- package/dist/pwc.min.mjs.map +1 -0
- package/dist/pwc.mjs +2678 -587
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +1 -1
- package/dist/sky.d.ts +1 -1
- package/dist/vscode.html-custom-data.json +1795 -0
- package/dist/web-types.json +3592 -0
- package/package.json +29 -11
- package/src/app.ts +6 -5
- package/src/asset.ts +19 -2
- package/src/async-element.ts +3 -0
- package/src/components/button-component.ts +6 -6
- package/src/components/camera-component.ts +2 -2
- package/src/components/collision-component.ts +2 -2
- package/src/components/component.ts +2 -2
- package/src/components/element-component.ts +6 -6
- package/src/components/gsplat-component.ts +3 -3
- package/src/components/layoutchild-component.ts +2 -2
- package/src/components/layoutgroup-component.ts +2 -2
- package/src/components/light-component.ts +2 -2
- package/src/components/particlesystem-component.ts +2 -2
- package/src/components/render-component.ts +10 -5
- package/src/components/rigidbody-component.ts +2 -2
- package/src/components/screen-component.ts +2 -2
- package/src/components/script-component.ts +4 -4
- package/src/components/script.ts +9 -2
- package/src/components/scrollbar-component.ts +3 -3
- package/src/components/scrollview-component.ts +6 -6
- package/src/components/sound-component.ts +2 -2
- package/src/components/sound-slot.ts +31 -9
- package/src/entity.ts +25 -7
- package/src/material.ts +2396 -59
- package/src/model.ts +2 -2
- package/src/module.ts +10 -0
- package/src/{utils.ts → parse.ts} +104 -65
- package/src/scene.ts +2 -2
- package/src/sky.ts +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SCROLL_MODE_BOUNCE, SCROLL_MODE_CLAMP, SCROLL_MODE_INFINITE, SCROLLBAR_VISIBILITY_SHOW_ALWAYS, SCROLLBAR_VISIBILITY_SHOW_WHEN_REQUIRED, ScrollViewComponent, Vec2 } from 'playcanvas';
|
|
2
2
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
|
-
import { getEntity, parseBool, parseEnum, parseNumber, parseVec2 } from '../
|
|
4
|
+
import { getEntity, parseBool, parseEnum, parseNumber, parseVec2 } from '../parse';
|
|
5
5
|
|
|
6
6
|
const scrollModes = new Map<'clamp' | 'bounce' | 'infinite', number>([
|
|
7
7
|
['clamp', SCROLL_MODE_CLAMP],
|
|
@@ -377,7 +377,7 @@ class ScrollViewComponentElement extends ComponentElement {
|
|
|
377
377
|
];
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
|
|
380
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
|
|
381
381
|
super.attributeChangedCallback(name, _oldValue, newValue);
|
|
382
382
|
|
|
383
383
|
switch (name) {
|
|
@@ -409,16 +409,16 @@ class ScrollViewComponentElement extends ComponentElement {
|
|
|
409
409
|
this.verticalScrollbarVisibility = parseEnum(newValue, visibilities, 'when-required', name);
|
|
410
410
|
break;
|
|
411
411
|
case 'viewport':
|
|
412
|
-
this.viewport = newValue;
|
|
412
|
+
this.viewport = newValue ?? '';
|
|
413
413
|
break;
|
|
414
414
|
case 'content':
|
|
415
|
-
this.content = newValue;
|
|
415
|
+
this.content = newValue ?? '';
|
|
416
416
|
break;
|
|
417
417
|
case 'horizontal-scrollbar':
|
|
418
|
-
this.horizontalScrollbar = newValue;
|
|
418
|
+
this.horizontalScrollbar = newValue ?? '';
|
|
419
419
|
break;
|
|
420
420
|
case 'vertical-scrollbar':
|
|
421
|
-
this.verticalScrollbar = newValue;
|
|
421
|
+
this.verticalScrollbar = newValue ?? '';
|
|
422
422
|
break;
|
|
423
423
|
}
|
|
424
424
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SoundComponent } from 'playcanvas';
|
|
2
2
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
|
-
import { parseBool, parseEnum, parseNumber } from '../
|
|
4
|
+
import { parseBool, parseEnum, parseNumber } from '../parse';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The SoundComponentElement interface provides properties and methods for manipulating
|
|
@@ -197,7 +197,7 @@ class SoundComponentElement extends ComponentElement {
|
|
|
197
197
|
];
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
|
|
200
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
|
|
201
201
|
super.attributeChangedCallback(name, _oldValue, newValue);
|
|
202
202
|
|
|
203
203
|
switch (name) {
|
|
@@ -3,7 +3,7 @@ import { SoundSlot } from 'playcanvas';
|
|
|
3
3
|
import { AssetElement } from '../asset';
|
|
4
4
|
import { AsyncElement } from '../async-element';
|
|
5
5
|
import { SoundComponentElement } from './sound-component';
|
|
6
|
-
import { parseBool, parseNumber } from '../
|
|
6
|
+
import { parseBool, parseNumber } from '../parse';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The SoundSlotElement interface provides properties and methods for manipulating
|
|
@@ -29,13 +29,31 @@ class SoundSlotElement extends AsyncElement {
|
|
|
29
29
|
|
|
30
30
|
private _volume: number = 1;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* The `<pc-sounds>` this slot was added to, captured at connect time.
|
|
34
|
+
*
|
|
35
|
+
* `disconnectedCallback` cannot rediscover it: by the time the element is disconnected its
|
|
36
|
+
* `parentElement` is already `null`, so a lookup would both fail to find the component and
|
|
37
|
+
* emit a misleading "must be a direct child" warning for what is an ordinary removal.
|
|
38
|
+
*/
|
|
39
|
+
private _soundElement: SoundComponentElement | null = null;
|
|
40
|
+
|
|
32
41
|
/**
|
|
33
42
|
* The sound slot.
|
|
34
43
|
*/
|
|
35
44
|
soundSlot: SoundSlot | null = null;
|
|
36
45
|
|
|
37
46
|
async connectedCallback() {
|
|
38
|
-
|
|
47
|
+
const soundElement = this.soundElement;
|
|
48
|
+
await soundElement?.ready();
|
|
49
|
+
|
|
50
|
+
// The element may have been removed, or its parent torn down, while we were waiting. A
|
|
51
|
+
// <pc-app> disconnects before its children, so by the time we resume the component can
|
|
52
|
+
// already be gone - see the matching guard in disconnectedCallback below.
|
|
53
|
+
const component = soundElement?.component;
|
|
54
|
+
if (!this.isConnected || !component) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
39
57
|
|
|
40
58
|
const options = {
|
|
41
59
|
autoPlay: this._autoPlay,
|
|
@@ -49,7 +67,8 @@ class SoundSlotElement extends AsyncElement {
|
|
|
49
67
|
options.duration = this._duration;
|
|
50
68
|
}
|
|
51
69
|
|
|
52
|
-
this.
|
|
70
|
+
this._soundElement = soundElement;
|
|
71
|
+
this.soundSlot = component.addSlot(this._name, options);
|
|
53
72
|
this.asset = this._asset;
|
|
54
73
|
if (this._autoPlay) {
|
|
55
74
|
this.soundSlot!.play();
|
|
@@ -59,9 +78,12 @@ class SoundSlotElement extends AsyncElement {
|
|
|
59
78
|
}
|
|
60
79
|
|
|
61
80
|
disconnectedCallback() {
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
|
|
81
|
+
// Uses the cached parent rather than a fresh lookup, since parentElement is already null
|
|
82
|
+
// by now. The component itself is null if the parent <pc-sound> (or the whole <pc-app>) is
|
|
83
|
+
// being torn down — parents disconnect first and have already removed the component.
|
|
84
|
+
this._soundElement?.component?.removeSlot(this._name);
|
|
85
|
+
this._soundElement = null;
|
|
86
|
+
this.soundSlot = null;
|
|
65
87
|
}
|
|
66
88
|
|
|
67
89
|
protected get soundElement(): SoundComponentElement | null {
|
|
@@ -253,10 +275,10 @@ class SoundSlotElement extends AsyncElement {
|
|
|
253
275
|
return ['asset', 'auto-play', 'duration', 'loop', 'name', 'overlap', 'pitch', 'start-time', 'volume'];
|
|
254
276
|
}
|
|
255
277
|
|
|
256
|
-
attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
|
|
278
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
|
|
257
279
|
switch (name) {
|
|
258
280
|
case 'asset':
|
|
259
|
-
this.asset = newValue;
|
|
281
|
+
this.asset = newValue ?? '';
|
|
260
282
|
break;
|
|
261
283
|
case 'auto-play':
|
|
262
284
|
this.autoPlay = parseBool(newValue, false);
|
|
@@ -268,7 +290,7 @@ class SoundSlotElement extends AsyncElement {
|
|
|
268
290
|
this.loop = parseBool(newValue, false);
|
|
269
291
|
break;
|
|
270
292
|
case 'name':
|
|
271
|
-
this.name = newValue;
|
|
293
|
+
this.name = newValue ?? '';
|
|
272
294
|
break;
|
|
273
295
|
case 'overlap':
|
|
274
296
|
this.overlap = parseBool(newValue, false);
|
package/src/entity.ts
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import { AppBase, Entity, Vec3 } from 'playcanvas';
|
|
2
2
|
|
|
3
3
|
import { AsyncElement } from './async-element';
|
|
4
|
-
import { parseBool, parseVec3 } from './
|
|
4
|
+
import { parseBool, parseTags, parseVec3 } from './parse';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The EntityElement interface provides properties and methods for manipulating
|
|
8
8
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/ | `<pc-entity>`} elements.
|
|
9
9
|
* The EntityElement interface also inherits the properties and methods of the
|
|
10
10
|
* {@link HTMLElement} interface.
|
|
11
|
+
*
|
|
12
|
+
* The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
|
|
13
|
+
* intersects this entity's geometry. They are only generated while the entity has a listener for
|
|
14
|
+
* them, registered either with {@link addEventListener} or with the matching inline `onpointer*`
|
|
15
|
+
* attribute.
|
|
16
|
+
*
|
|
17
|
+
* @attribute {string} onpointerenter - Script to run when the pointer moves onto the entity.
|
|
18
|
+
* @attribute {string} onpointerleave - Script to run when the pointer moves off the entity.
|
|
19
|
+
* @attribute {string} onpointermove - Script to run when the pointer moves over the entity.
|
|
20
|
+
* @attribute {string} onpointerdown - Script to run when a pointer button is pressed over the
|
|
21
|
+
* entity.
|
|
22
|
+
* @attribute {string} onpointerup - Script to run when a pointer button is released over the
|
|
23
|
+
* entity.
|
|
24
|
+
* @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the entity.
|
|
25
|
+
* @fires {PointerEvent} pointerleave - Fired when the pointer moves off the entity.
|
|
26
|
+
* @fires {PointerEvent} pointermove - Fired when the pointer moves over the entity.
|
|
27
|
+
* @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the entity.
|
|
28
|
+
* @fires {PointerEvent} pointerup - Fired when a pointer button is released over the entity.
|
|
11
29
|
*/
|
|
12
30
|
class EntityElement extends AsyncElement {
|
|
13
31
|
/**
|
|
@@ -83,9 +101,9 @@ class EntityElement extends AsyncElement {
|
|
|
83
101
|
entity.setLocalEulerAngles(parseVec3(this.getAttribute('rotation'), Vec3.ZERO, 'rotation'));
|
|
84
102
|
entity.setLocalScale(parseVec3(this.getAttribute('scale'), Vec3.ONE, 'scale'));
|
|
85
103
|
|
|
86
|
-
const tags = this.getAttribute('tags');
|
|
87
|
-
if (tags) {
|
|
88
|
-
entity.tags.add(tags
|
|
104
|
+
const tags = parseTags(this.getAttribute('tags'));
|
|
105
|
+
if (tags.length > 0) {
|
|
106
|
+
entity.tags.add(tags);
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
109
|
|
|
@@ -297,13 +315,13 @@ class EntityElement extends AsyncElement {
|
|
|
297
315
|
];
|
|
298
316
|
}
|
|
299
317
|
|
|
300
|
-
attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
|
|
318
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
|
|
301
319
|
switch (name) {
|
|
302
320
|
case 'enabled':
|
|
303
321
|
this.enabled = parseBool(newValue, true);
|
|
304
322
|
break;
|
|
305
323
|
case 'name':
|
|
306
|
-
this.name = newValue;
|
|
324
|
+
this.name = newValue ?? 'Untitled';
|
|
307
325
|
break;
|
|
308
326
|
case 'position':
|
|
309
327
|
this.position = parseVec3(newValue, Vec3.ZERO, name);
|
|
@@ -315,7 +333,7 @@ class EntityElement extends AsyncElement {
|
|
|
315
333
|
this.scale = parseVec3(newValue, Vec3.ONE, name);
|
|
316
334
|
break;
|
|
317
335
|
case 'tags':
|
|
318
|
-
this.tags = newValue
|
|
336
|
+
this.tags = parseTags(newValue);
|
|
319
337
|
break;
|
|
320
338
|
case 'onpointerenter':
|
|
321
339
|
case 'onpointerleave':
|