@playcanvas/web-components 0.11.0 → 0.11.1
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 +1 -1
- package/dist/app.d.ts +18 -38
- package/dist/asset.d.ts +8 -7
- package/dist/async-element.d.ts +21 -5
- package/dist/components/button-component.d.ts +3 -7
- package/dist/components/camera-component.d.ts +3 -7
- package/dist/components/collision-component.d.ts +3 -7
- package/dist/components/component.d.ts +22 -4
- package/dist/components/element-component.d.ts +4 -8
- package/dist/components/gsplat-component.d.ts +2 -7
- package/dist/components/layoutchild-component.d.ts +2 -7
- package/dist/components/layoutgroup-component.d.ts +3 -7
- package/dist/components/light-component.d.ts +3 -7
- package/dist/components/listener-component.d.ts +1 -6
- package/dist/components/particlesystem-component.d.ts +2 -7
- package/dist/components/render-component.d.ts +2 -7
- package/dist/components/rigidbody-component.d.ts +3 -7
- package/dist/components/screen-component.d.ts +3 -7
- package/dist/components/script-component.d.ts +8 -20
- package/dist/components/script.d.ts +2 -22
- package/dist/components/scrollbar-component.d.ts +2 -7
- package/dist/components/scrollview-component.d.ts +3 -7
- package/dist/components/sound-component.d.ts +2 -7
- package/dist/components/sound-slot.d.ts +8 -6
- package/dist/custom-elements.json +5049 -10696
- package/dist/entity.d.ts +5 -11
- package/dist/index.d.ts +37 -0
- package/dist/material.d.ts +12 -12
- package/dist/model.d.ts +21 -5
- package/dist/module.d.ts +0 -6
- package/dist/parse.d.ts +2 -1
- package/dist/pwc.cjs +496 -136
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +496 -136
- 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 +1 -1
- package/dist/pwc.min.mjs.map +1 -1
- package/dist/pwc.mjs +496 -136
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +4 -7
- package/dist/sky.d.ts +13 -5
- package/dist/vscode.html-custom-data.json +26 -26
- package/dist/web-types.json +545 -536
- package/package.json +8 -7
- package/src/app.ts +142 -70
- package/src/asset.ts +34 -28
- package/src/async-element.ts +34 -8
- package/src/components/button-component.ts +5 -9
- package/src/components/camera-component.ts +24 -10
- package/src/components/collision-component.ts +26 -15
- package/src/components/component.ts +58 -8
- package/src/components/element-component.ts +26 -30
- package/src/components/gsplat-component.ts +4 -9
- package/src/components/layoutchild-component.ts +4 -9
- package/src/components/layoutgroup-component.ts +14 -9
- package/src/components/light-component.ts +42 -12
- package/src/components/listener-component.ts +1 -7
- package/src/components/particlesystem-component.ts +7 -15
- package/src/components/render-component.ts +5 -10
- package/src/components/rigidbody-component.ts +23 -16
- package/src/components/screen-component.ts +5 -9
- package/src/components/script-component.ts +108 -46
- package/src/components/script.ts +38 -33
- package/src/components/scrollbar-component.ts +6 -16
- package/src/components/scrollview-component.ts +16 -11
- package/src/components/sound-component.ts +10 -15
- package/src/components/sound-slot.ts +30 -20
- package/src/entity.ts +42 -19
- package/src/index.ts +45 -1
- package/src/loading-bar.ts +8 -8
- package/src/material.ts +63 -37
- package/src/model.ts +69 -14
- package/src/module.ts +8 -7
- package/src/parse.ts +62 -17
- package/src/scene.ts +12 -9
- package/src/sky.ts +50 -9
package/src/async-element.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { AppElement } from './app';
|
|
2
|
-
import { EntityElement } from './entity';
|
|
1
|
+
import type { AppElement } from './app';
|
|
2
|
+
import type { EntityElement } from './entity';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Base class for all PlayCanvas Web Components that initialize asynchronously.
|
|
6
6
|
*
|
|
7
|
-
* @fires {CustomEvent} ready - Fired
|
|
8
|
-
*
|
|
7
|
+
* @fires {CustomEvent} ready - Fired when the element is fully initialized — once per readiness
|
|
8
|
+
* cycle, so an element that is torn down and re-initialized (for example by removing and
|
|
9
|
+
* re-inserting it) fires it again. Bubbles and is composed.
|
|
9
10
|
*/
|
|
10
11
|
class AsyncElement extends HTMLElement {
|
|
11
12
|
private _readyPromise: Promise<void>;
|
|
12
13
|
|
|
13
14
|
private _readyResolve!: () => void;
|
|
14
15
|
|
|
16
|
+
private _readyResolved = false;
|
|
17
|
+
|
|
15
18
|
/** @ignore */
|
|
16
19
|
constructor() {
|
|
17
20
|
super();
|
|
@@ -26,7 +29,7 @@ class AsyncElement extends HTMLElement {
|
|
|
26
29
|
* @returns The closest app element, or `null`.
|
|
27
30
|
*/
|
|
28
31
|
get closestApp(): AppElement | null {
|
|
29
|
-
return this.parentElement?.closest('pc-app') as AppElement | null ?? null;
|
|
32
|
+
return (this.parentElement?.closest('pc-app') as AppElement | null) ?? null;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/**
|
|
@@ -35,22 +38,45 @@ class AsyncElement extends HTMLElement {
|
|
|
35
38
|
* @returns The closest entity element, or `null`.
|
|
36
39
|
*/
|
|
37
40
|
get closestEntity(): EntityElement | null {
|
|
38
|
-
return this.parentElement?.closest('pc-entity') as EntityElement | null ?? null;
|
|
41
|
+
return (this.parentElement?.closest('pc-entity') as EntityElement | null) ?? null;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/**
|
|
42
45
|
* Called when the element is fully initialized and ready. Subclasses should call this when
|
|
43
46
|
* they're ready. Resolves the ready promise and dispatches a bubbling, composed `ready`
|
|
44
|
-
* event.
|
|
47
|
+
* event. Signals at most once per readiness cycle: a repeat call before {@link _resetReady}
|
|
48
|
+
* has re-armed the promise does nothing.
|
|
45
49
|
*/
|
|
46
50
|
protected _onReady() {
|
|
51
|
+
if (this._readyResolved) return;
|
|
52
|
+
this._readyResolved = true;
|
|
47
53
|
this._readyResolve();
|
|
48
54
|
this.dispatchEvent(new CustomEvent('ready', { bubbles: true, composed: true }));
|
|
49
55
|
}
|
|
50
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Returns the ready promise to its pending state. Subclasses should call this when the
|
|
59
|
+
* resource their readiness announced is torn down (typically from `disconnectedCallback`),
|
|
60
|
+
* so that a later re-initialization can signal readiness again. Does nothing while the
|
|
61
|
+
* promise is still pending — an in-flight waiter carries over to the next readiness cycle
|
|
62
|
+
* rather than being stranded on a promise nothing will ever resolve.
|
|
63
|
+
*/
|
|
64
|
+
protected _resetReady() {
|
|
65
|
+
if (!this._readyResolved) return;
|
|
66
|
+
this._readyResolved = false;
|
|
67
|
+
this._readyPromise = new Promise<void>((resolve) => {
|
|
68
|
+
this._readyResolve = resolve;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
51
72
|
/**
|
|
52
73
|
* Returns a promise that resolves with this element when it's ready. This is the low-level
|
|
53
74
|
* primitive underlying {@link whenReady}, which is the recommended way to wait for elements.
|
|
75
|
+
*
|
|
76
|
+
* Readiness tracks the element's current lifecycle: once a ready element is torn down (for
|
|
77
|
+
* example by removing it from the document), this returns a fresh promise that resolves when
|
|
78
|
+
* the element is next ready. A promise obtained earlier stays resolved — call this again
|
|
79
|
+
* after re-inserting an element rather than reusing a promise from before its removal.
|
|
54
80
|
* @returns A promise that resolves with this element when it's ready.
|
|
55
81
|
*/
|
|
56
82
|
ready(): Promise<this> {
|
|
@@ -63,7 +89,7 @@ class AsyncElement extends HTMLElement {
|
|
|
63
89
|
* classes extend {@link AsyncElement}).
|
|
64
90
|
*/
|
|
65
91
|
type AsyncElementTagName = {
|
|
66
|
-
[K in keyof HTMLElementTagNameMap]: HTMLElementTagNameMap[K] extends AsyncElement ? K : never
|
|
92
|
+
[K in keyof HTMLElementTagNameMap]: HTMLElementTagNameMap[K] extends AsyncElement ? K : never;
|
|
67
93
|
}[keyof HTMLElementTagNameMap];
|
|
68
94
|
|
|
69
95
|
/**
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ButtonComponent } from 'playcanvas';
|
|
2
|
+
import { BUTTON_TRANSITION_MODE_SPRITE_CHANGE, BUTTON_TRANSITION_MODE_TINT, Color, Vec4 } from 'playcanvas';
|
|
2
3
|
|
|
3
4
|
import { AssetElement } from '../asset';
|
|
4
|
-
import { ComponentElement } from './component';
|
|
5
5
|
import { getEntity, parseBool, parseColor, parseEnum, parseNumber, parseVec4 } from '../parse';
|
|
6
6
|
|
|
7
|
+
import { ComponentElement } from './component';
|
|
8
|
+
|
|
7
9
|
const transitionModes = new Map<'tint' | 'sprite', number>([
|
|
8
10
|
['tint', BUTTON_TRANSITION_MODE_TINT],
|
|
9
11
|
['sprite', BUTTON_TRANSITION_MODE_SPRITE_CHANGE]
|
|
@@ -51,7 +53,7 @@ class ButtonComponentElement extends ComponentElement {
|
|
|
51
53
|
super('button');
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
getInitialComponentData() {
|
|
56
|
+
protected getInitialComponentData() {
|
|
55
57
|
const data: Record<string, any> = {
|
|
56
58
|
active: this._active,
|
|
57
59
|
hitPadding: this._hitPadding,
|
|
@@ -448,10 +450,4 @@ class ButtonComponentElement extends ComponentElement {
|
|
|
448
450
|
|
|
449
451
|
customElements.define('pc-button', ButtonComponentElement);
|
|
450
452
|
|
|
451
|
-
declare global {
|
|
452
|
-
interface HTMLElementTagNameMap {
|
|
453
|
-
'pc-button': ButtonComponentElement;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
453
|
export { ButtonComponentElement };
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import { CameraComponent
|
|
1
|
+
import type { CameraComponent } from 'playcanvas';
|
|
2
|
+
import {
|
|
3
|
+
Color,
|
|
4
|
+
Vec4,
|
|
5
|
+
GAMMA_NONE,
|
|
6
|
+
GAMMA_SRGB,
|
|
7
|
+
PROJECTION_ORTHOGRAPHIC,
|
|
8
|
+
PROJECTION_PERSPECTIVE,
|
|
9
|
+
TONEMAP_LINEAR,
|
|
10
|
+
TONEMAP_FILMIC,
|
|
11
|
+
TONEMAP_NEUTRAL,
|
|
12
|
+
TONEMAP_ACES2,
|
|
13
|
+
TONEMAP_ACES,
|
|
14
|
+
TONEMAP_HEJL,
|
|
15
|
+
TONEMAP_NONE,
|
|
16
|
+
XRTYPE_VR
|
|
17
|
+
} from 'playcanvas';
|
|
2
18
|
|
|
3
|
-
import { ComponentElement } from './component';
|
|
4
19
|
import { parseBool, parseColor, parseEnum, parseNumber, parseVec4 } from '../parse';
|
|
5
20
|
|
|
21
|
+
import { ComponentElement } from './component';
|
|
22
|
+
|
|
6
23
|
const projections = new Map<'perspective' | 'orthographic', number>([
|
|
7
24
|
['perspective', PROJECTION_PERSPECTIVE],
|
|
8
25
|
['orthographic', PROJECTION_ORTHOGRAPHIC]
|
|
@@ -68,7 +85,7 @@ class CameraComponentElement extends ComponentElement {
|
|
|
68
85
|
super('camera');
|
|
69
86
|
}
|
|
70
87
|
|
|
71
|
-
getInitialComponentData() {
|
|
88
|
+
protected getInitialComponentData() {
|
|
72
89
|
return {
|
|
73
90
|
clearColor: this._clearColor,
|
|
74
91
|
clearColorBuffer: this._clearColorBuffer,
|
|
@@ -101,7 +118,10 @@ class CameraComponentElement extends ComponentElement {
|
|
|
101
118
|
* @param type - The type of XR mode to start.
|
|
102
119
|
* @param space - The space to start the camera in.
|
|
103
120
|
*/
|
|
104
|
-
startXr(
|
|
121
|
+
startXr(
|
|
122
|
+
type: 'immersive-ar' | 'immersive-vr',
|
|
123
|
+
space: 'bounded-floor' | 'local' | 'local-floor' | 'unbounded' | 'viewer'
|
|
124
|
+
) {
|
|
105
125
|
if (this.component && this.xrAvailable) {
|
|
106
126
|
this.component.startXr(type, space, {
|
|
107
127
|
callback: (err: any) => {
|
|
@@ -559,10 +579,4 @@ class CameraComponentElement extends ComponentElement {
|
|
|
559
579
|
|
|
560
580
|
customElements.define('pc-camera', CameraComponentElement);
|
|
561
581
|
|
|
562
|
-
declare global {
|
|
563
|
-
interface HTMLElementTagNameMap {
|
|
564
|
-
'pc-camera': CameraComponentElement;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
582
|
export { CameraComponentElement };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { CollisionComponent
|
|
1
|
+
import type { CollisionComponent } from 'playcanvas';
|
|
2
|
+
import { Quat, Vec3 } from 'playcanvas';
|
|
2
3
|
|
|
3
|
-
import { ComponentElement } from './component';
|
|
4
4
|
import { parseBool, parseEnum, parseNumber, parseQuat, parseVec3 } from '../parse';
|
|
5
5
|
|
|
6
|
+
import { ComponentElement } from './component';
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* The CollisionComponentElement interface provides properties and methods for manipulating
|
|
8
10
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-collision/ | `<pc-collision>`} elements.
|
|
@@ -14,17 +16,17 @@ import { parseBool, parseEnum, parseNumber, parseQuat, parseVec3 } from '../pars
|
|
|
14
16
|
class CollisionComponentElement extends ComponentElement {
|
|
15
17
|
private _angularOffset: Quat = new Quat();
|
|
16
18
|
|
|
17
|
-
private _axis
|
|
19
|
+
private _axis = 1;
|
|
18
20
|
|
|
19
|
-
private _convexHull
|
|
21
|
+
private _convexHull = false;
|
|
20
22
|
|
|
21
23
|
private _halfExtents: Vec3 = new Vec3(0.5, 0.5, 0.5);
|
|
22
24
|
|
|
23
|
-
private _height
|
|
25
|
+
private _height = 2;
|
|
24
26
|
|
|
25
27
|
private _linearOffset: Vec3 = new Vec3();
|
|
26
28
|
|
|
27
|
-
private _radius
|
|
29
|
+
private _radius = 0.5;
|
|
28
30
|
|
|
29
31
|
private _type: 'box' | 'capsule' | 'compound' | 'cone' | 'cylinder' | 'mesh' | 'sphere' = 'box';
|
|
30
32
|
|
|
@@ -33,7 +35,7 @@ class CollisionComponentElement extends ComponentElement {
|
|
|
33
35
|
super('collision');
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
getInitialComponentData() {
|
|
38
|
+
protected getInitialComponentData() {
|
|
37
39
|
return {
|
|
38
40
|
axis: this._axis,
|
|
39
41
|
angularOffset: this._angularOffset,
|
|
@@ -143,7 +145,17 @@ class CollisionComponentElement extends ComponentElement {
|
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
static get observedAttributes() {
|
|
146
|
-
return [
|
|
148
|
+
return [
|
|
149
|
+
...super.observedAttributes,
|
|
150
|
+
'angular-offset',
|
|
151
|
+
'axis',
|
|
152
|
+
'convex-hull',
|
|
153
|
+
'half-extents',
|
|
154
|
+
'height',
|
|
155
|
+
'linear-offset',
|
|
156
|
+
'radius',
|
|
157
|
+
'type'
|
|
158
|
+
];
|
|
147
159
|
}
|
|
148
160
|
|
|
149
161
|
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
|
|
@@ -172,7 +184,12 @@ class CollisionComponentElement extends ComponentElement {
|
|
|
172
184
|
this.radius = parseNumber(newValue, 0.5, name);
|
|
173
185
|
break;
|
|
174
186
|
case 'type':
|
|
175
|
-
this.type = parseEnum(
|
|
187
|
+
this.type = parseEnum(
|
|
188
|
+
newValue,
|
|
189
|
+
['box', 'capsule', 'compound', 'cone', 'cylinder', 'mesh', 'sphere'],
|
|
190
|
+
'box',
|
|
191
|
+
name
|
|
192
|
+
);
|
|
176
193
|
break;
|
|
177
194
|
}
|
|
178
195
|
}
|
|
@@ -180,10 +197,4 @@ class CollisionComponentElement extends ComponentElement {
|
|
|
180
197
|
|
|
181
198
|
customElements.define('pc-collision', CollisionComponentElement);
|
|
182
199
|
|
|
183
|
-
declare global {
|
|
184
|
-
interface HTMLElementTagNameMap {
|
|
185
|
-
'pc-collision': CollisionComponentElement;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
200
|
export { CollisionComponentElement };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component } from 'playcanvas';
|
|
1
|
+
import type { Component } from 'playcanvas';
|
|
2
2
|
|
|
3
|
-
import { AppElement } from '../app';
|
|
3
|
+
import type { AppElement } from '../app';
|
|
4
4
|
import { AsyncElement } from '../async-element';
|
|
5
5
|
import { parseBool } from '../parse';
|
|
6
6
|
|
|
@@ -18,6 +18,15 @@ class ComponentElement extends AsyncElement {
|
|
|
18
18
|
|
|
19
19
|
private _appElement: AppElement | null = null;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Incremented on every connect and disconnect. connectedCallback captures the value on entry
|
|
23
|
+
* and abandons itself wherever it resumes from an await if the value has moved on — so a
|
|
24
|
+
* callback whose element was removed cannot act on a torn-down tree, and one whose element
|
|
25
|
+
* was removed and re-inserted (which runs a callback of its own) cannot add the component a
|
|
26
|
+
* second time.
|
|
27
|
+
*/
|
|
28
|
+
private _connectionGeneration = 0;
|
|
29
|
+
|
|
21
30
|
/**
|
|
22
31
|
* Creates a new ComponentElement instance.
|
|
23
32
|
*
|
|
@@ -30,38 +39,78 @@ class ComponentElement extends AsyncElement {
|
|
|
30
39
|
this._componentName = componentName;
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Returns the data the component is created with. Overridden by subclasses to supply the
|
|
44
|
+
* initial values of their cached properties.
|
|
45
|
+
*
|
|
46
|
+
* @returns The initial component data.
|
|
47
|
+
*/
|
|
48
|
+
protected getInitialComponentData() {
|
|
35
49
|
return {};
|
|
36
50
|
}
|
|
37
51
|
|
|
38
|
-
async
|
|
52
|
+
private async _addComponent() {
|
|
53
|
+
const generation = this._connectionGeneration;
|
|
54
|
+
|
|
39
55
|
const entityElement = this.closestEntity;
|
|
40
56
|
if (!entityElement) {
|
|
41
57
|
// A component can only exist on an entity, so an element placed outside one is inert.
|
|
42
58
|
// It still becomes ready (with a null `component`), so warn rather than fail silently
|
|
43
59
|
const label = this.id ? ` '${this.id}'` : '';
|
|
44
|
-
console.warn(
|
|
60
|
+
console.warn(
|
|
61
|
+
`${this.tagName.toLowerCase()}${label} must be a descendant of pc-entity - component not added`
|
|
62
|
+
);
|
|
45
63
|
return;
|
|
46
64
|
}
|
|
47
65
|
|
|
48
66
|
await entityElement.ready();
|
|
67
|
+
|
|
68
|
+
// The element may have been removed, or removed and re-inserted, while the entity became
|
|
69
|
+
// ready — the component belongs to the connection that owns the current generation.
|
|
70
|
+
if (generation !== this._connectionGeneration) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
49
74
|
// Add the component to the entity
|
|
50
75
|
const data = this.getInitialComponentData();
|
|
51
76
|
this._component = entityElement.entity!.addComponent(this._componentName, data);
|
|
52
77
|
}
|
|
53
78
|
|
|
54
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Configures the newly added component. Overridden by subclasses whose setup goes beyond
|
|
81
|
+
* the initial data — child-element handling, asset resolution and the like.
|
|
82
|
+
*/
|
|
83
|
+
protected initComponent() {
|
|
84
|
+
// optional hook
|
|
85
|
+
}
|
|
55
86
|
|
|
56
87
|
async connectedCallback() {
|
|
88
|
+
const generation = ++this._connectionGeneration;
|
|
89
|
+
|
|
57
90
|
this._appElement = this.closestApp ?? null;
|
|
58
91
|
await this._appElement?.ready();
|
|
59
|
-
|
|
92
|
+
|
|
93
|
+
// The element may have been removed, or removed and re-inserted, while the application
|
|
94
|
+
// became ready. A re-insertion runs a connectedCallback of its own, so a stale resume
|
|
95
|
+
// must not add the component alongside it.
|
|
96
|
+
if (generation !== this._connectionGeneration) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
await this._addComponent();
|
|
101
|
+
|
|
102
|
+
if (generation !== this._connectionGeneration) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
60
106
|
this.initComponent();
|
|
61
107
|
this._onReady();
|
|
62
108
|
}
|
|
63
109
|
|
|
64
110
|
disconnectedCallback() {
|
|
111
|
+
// Invalidate any connectedCallback still suspended on an await
|
|
112
|
+
this._connectionGeneration++;
|
|
113
|
+
|
|
65
114
|
// Remove the component when the element is disconnected. Skip this when the owning
|
|
66
115
|
// application has already been destroyed — removing a <pc-app> disconnects it before
|
|
67
116
|
// its children, taking the component systems with it.
|
|
@@ -70,6 +119,7 @@ class ComponentElement extends AsyncElement {
|
|
|
70
119
|
}
|
|
71
120
|
this._component = null;
|
|
72
121
|
this._appElement = null;
|
|
122
|
+
this._resetReady();
|
|
73
123
|
}
|
|
74
124
|
|
|
75
125
|
/**
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ElementComponent } from 'playcanvas';
|
|
2
|
+
import { Color, Vec2, Vec4 } from 'playcanvas';
|
|
2
3
|
|
|
3
4
|
import { AssetElement } from '../asset';
|
|
4
|
-
import { ComponentElement } from './component';
|
|
5
5
|
import { parseBool, parseColor, parseEnum, parseNumber, parseVec2, parseVec4 } from '../parse';
|
|
6
6
|
|
|
7
|
+
import { ComponentElement } from './component';
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* The ElementComponentElement interface provides properties and methods for manipulating
|
|
9
11
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-element/ | `<pc-element>`} elements.
|
|
@@ -15,62 +17,62 @@ import { parseBool, parseColor, parseEnum, parseNumber, parseVec2, parseVec4 } f
|
|
|
15
17
|
class ElementComponentElement extends ComponentElement {
|
|
16
18
|
private _anchor: Vec4 = new Vec4(0.5, 0.5, 0.5, 0.5);
|
|
17
19
|
|
|
18
|
-
private _autoWidth
|
|
20
|
+
private _autoWidth = true;
|
|
19
21
|
|
|
20
|
-
private _autoHeight
|
|
22
|
+
private _autoHeight = true;
|
|
21
23
|
|
|
22
|
-
private _autoFitWidth
|
|
24
|
+
private _autoFitWidth = false;
|
|
23
25
|
|
|
24
|
-
private _autoFitHeight
|
|
26
|
+
private _autoFitHeight = false;
|
|
25
27
|
|
|
26
28
|
private _color: Color = new Color(1, 1, 1, 1);
|
|
27
29
|
|
|
28
|
-
private _enableMarkup
|
|
30
|
+
private _enableMarkup = false;
|
|
29
31
|
|
|
30
|
-
private _fontAsset
|
|
32
|
+
private _fontAsset = '';
|
|
31
33
|
|
|
32
|
-
private _fontSize
|
|
34
|
+
private _fontSize = 32;
|
|
33
35
|
|
|
34
|
-
private _maxFontSize
|
|
36
|
+
private _maxFontSize = 32;
|
|
35
37
|
|
|
36
|
-
private _minFontSize
|
|
38
|
+
private _minFontSize = 8;
|
|
37
39
|
|
|
38
|
-
private _height
|
|
40
|
+
private _height = 0;
|
|
39
41
|
|
|
40
|
-
private _lineHeight
|
|
42
|
+
private _lineHeight = 32;
|
|
41
43
|
|
|
42
44
|
private _margin: Vec4 | null = null;
|
|
43
45
|
|
|
44
|
-
private _mask
|
|
46
|
+
private _mask = false;
|
|
45
47
|
|
|
46
|
-
private _opacity
|
|
48
|
+
private _opacity = 1;
|
|
47
49
|
|
|
48
50
|
private _pivot: Vec2 = new Vec2(0.5, 0.5);
|
|
49
51
|
|
|
50
52
|
private _pixelsPerUnit: number | null = null;
|
|
51
53
|
|
|
52
|
-
private _spriteAsset
|
|
54
|
+
private _spriteAsset = '';
|
|
53
55
|
|
|
54
|
-
private _spriteFrame
|
|
56
|
+
private _spriteFrame = 0;
|
|
55
57
|
|
|
56
|
-
private _text
|
|
58
|
+
private _text = '';
|
|
57
59
|
|
|
58
|
-
private _textureAsset
|
|
60
|
+
private _textureAsset = '';
|
|
59
61
|
|
|
60
62
|
private _type: 'group' | 'image' | 'text' = 'group';
|
|
61
63
|
|
|
62
|
-
private _useInput
|
|
64
|
+
private _useInput = false;
|
|
63
65
|
|
|
64
|
-
private _width
|
|
66
|
+
private _width = 0;
|
|
65
67
|
|
|
66
|
-
private _wrapLines
|
|
68
|
+
private _wrapLines = false;
|
|
67
69
|
|
|
68
70
|
/** @ignore */
|
|
69
71
|
constructor() {
|
|
70
72
|
super('element');
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
initComponent() {
|
|
75
|
+
protected initComponent() {
|
|
74
76
|
const component = this.component as any;
|
|
75
77
|
if (!component) {
|
|
76
78
|
return;
|
|
@@ -89,7 +91,7 @@ class ElementComponentElement extends ComponentElement {
|
|
|
89
91
|
component._dirtifyMask?.();
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
getInitialComponentData() {
|
|
94
|
+
protected getInitialComponentData() {
|
|
93
95
|
const data: Record<string, any> = {
|
|
94
96
|
anchor: this._anchor,
|
|
95
97
|
autoWidth: this._autoWidth,
|
|
@@ -774,10 +776,4 @@ class ElementComponentElement extends ComponentElement {
|
|
|
774
776
|
|
|
775
777
|
customElements.define('pc-element', ElementComponentElement);
|
|
776
778
|
|
|
777
|
-
declare global {
|
|
778
|
-
interface HTMLElementTagNameMap {
|
|
779
|
-
'pc-element': ElementComponentElement;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
|
|
783
779
|
export { ElementComponentElement };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { GSplatComponent } from 'playcanvas';
|
|
1
|
+
import type { GSplatComponent } from 'playcanvas';
|
|
2
2
|
|
|
3
|
-
import { ComponentElement } from './component';
|
|
4
3
|
import { AssetElement } from '../asset';
|
|
5
4
|
import { parseBool, parseNumber } from '../parse';
|
|
6
5
|
|
|
6
|
+
import { ComponentElement } from './component';
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* The GSplatComponentElement interface provides properties and methods for manipulating
|
|
9
10
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-gsplat/ | `<pc-gsplat>`} elements.
|
|
@@ -30,7 +31,7 @@ class GSplatComponentElement extends ComponentElement {
|
|
|
30
31
|
super('gsplat');
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
getInitialComponentData() {
|
|
34
|
+
protected getInitialComponentData() {
|
|
34
35
|
return {
|
|
35
36
|
asset: AssetElement.get(this._asset),
|
|
36
37
|
castShadows: this._castShadows,
|
|
@@ -216,10 +217,4 @@ class GSplatComponentElement extends ComponentElement {
|
|
|
216
217
|
|
|
217
218
|
customElements.define('pc-gsplat', GSplatComponentElement);
|
|
218
219
|
|
|
219
|
-
declare global {
|
|
220
|
-
interface HTMLElementTagNameMap {
|
|
221
|
-
'pc-gsplat': GSplatComponentElement;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
220
|
export { GSplatComponentElement };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { LayoutChildComponent } from 'playcanvas';
|
|
1
|
+
import type { LayoutChildComponent } from 'playcanvas';
|
|
2
2
|
|
|
3
|
-
import { ComponentElement } from './component';
|
|
4
3
|
import { parseBool, parseNumber } from '../parse';
|
|
5
4
|
|
|
5
|
+
import { ComponentElement } from './component';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* The LayoutChildComponentElement interface provides properties and methods for manipulating
|
|
8
9
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-layoutchild/ | `<pc-layoutchild>`} elements.
|
|
@@ -31,7 +32,7 @@ class LayoutChildComponentElement extends ComponentElement {
|
|
|
31
32
|
super('layoutchild');
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
getInitialComponentData() {
|
|
35
|
+
protected getInitialComponentData() {
|
|
35
36
|
return {
|
|
36
37
|
minWidth: this._minWidth,
|
|
37
38
|
minHeight: this._minHeight,
|
|
@@ -230,10 +231,4 @@ class LayoutChildComponentElement extends ComponentElement {
|
|
|
230
231
|
|
|
231
232
|
customElements.define('pc-layoutchild', LayoutChildComponentElement);
|
|
232
233
|
|
|
233
|
-
declare global {
|
|
234
|
-
interface HTMLElementTagNameMap {
|
|
235
|
-
'pc-layoutchild': LayoutChildComponentElement;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
234
|
export { LayoutChildComponentElement };
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LayoutGroupComponent } from 'playcanvas';
|
|
2
|
+
import {
|
|
3
|
+
FITTING_NONE,
|
|
4
|
+
FITTING_STRETCH,
|
|
5
|
+
FITTING_SHRINK,
|
|
6
|
+
FITTING_BOTH,
|
|
7
|
+
ORIENTATION_HORIZONTAL,
|
|
8
|
+
ORIENTATION_VERTICAL,
|
|
9
|
+
Vec2,
|
|
10
|
+
Vec4
|
|
11
|
+
} from 'playcanvas';
|
|
2
12
|
|
|
3
|
-
import { ComponentElement } from './component';
|
|
4
13
|
import { parseBool, parseEnum, parseVec2, parseVec4 } from '../parse';
|
|
5
14
|
|
|
15
|
+
import { ComponentElement } from './component';
|
|
16
|
+
|
|
6
17
|
const orientations = new Map<'horizontal' | 'vertical', number>([
|
|
7
18
|
['horizontal', ORIENTATION_HORIZONTAL],
|
|
8
19
|
['vertical', ORIENTATION_VERTICAL]
|
|
@@ -47,7 +58,7 @@ class LayoutGroupComponentElement extends ComponentElement {
|
|
|
47
58
|
super('layoutgroup');
|
|
48
59
|
}
|
|
49
60
|
|
|
50
|
-
getInitialComponentData() {
|
|
61
|
+
protected getInitialComponentData() {
|
|
51
62
|
return {
|
|
52
63
|
orientation: orientations.get(this._orientation),
|
|
53
64
|
reverseX: this._reverseX,
|
|
@@ -295,10 +306,4 @@ class LayoutGroupComponentElement extends ComponentElement {
|
|
|
295
306
|
|
|
296
307
|
customElements.define('pc-layoutgroup', LayoutGroupComponentElement);
|
|
297
308
|
|
|
298
|
-
declare global {
|
|
299
|
-
interface HTMLElementTagNameMap {
|
|
300
|
-
'pc-layoutgroup': LayoutGroupComponentElement;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
309
|
export { LayoutGroupComponentElement };
|