@playcanvas/web-components 0.14.0 → 0.15.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/components/joint-component.d.cts +521 -0
- package/dist/components/joint-component.d.ts +521 -0
- package/dist/custom-elements.json +916 -0
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/pwc.cjs +917 -14
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +917 -14
- 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 +917 -15
- package/dist/pwc.mjs.map +1 -1
- package/dist/vscode.html-custom-data.json +192 -0
- package/dist/web-types.json +348 -1
- package/package.json +3 -2
- package/src/app.ts +18 -0
- package/src/components/joint-component.ts +984 -0
- package/src/entity.ts +28 -7
- package/src/index.ts +4 -0
- package/src/node.ts +2 -7
package/src/entity.ts
CHANGED
|
@@ -4,6 +4,33 @@ import { Entity, Vec3 } from 'playcanvas';
|
|
|
4
4
|
import { EntityBaseElement, POINTER_ATTRIBUTES } from './entity-base';
|
|
5
5
|
import { parseBool, parseTags, parseVec3 } from './parse';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Creates and parents the entities of every descendant `<pc-entity>` of `root`, in two passes so
|
|
9
|
+
* that no parent's existence depends on document order. Called wherever a subtree could not build
|
|
10
|
+
* itself: an element inserted into an application that is already running, and a `<pc-node>` whose
|
|
11
|
+
* children waited for it to bind.
|
|
12
|
+
*
|
|
13
|
+
* Descendants that are not yet custom elements are skipped, because there is nothing useful to do
|
|
14
|
+
* for them and reaching for `_createEntity` would throw. A subtree cloned from a `<template>`
|
|
15
|
+
* arrives entirely unupgraded — template content lives in an inert document, where custom element
|
|
16
|
+
* definitions are never looked up — and appending the clone upgrades its elements in tree order,
|
|
17
|
+
* an element before its descendants. So a sweep from an element's own `connectedCallback` sees
|
|
18
|
+
* plain `HTMLElement`s below it. Each becomes an `EntityElement` moments later and its own
|
|
19
|
+
* `connectedCallback` creates and parents it, by which time the ancestor it parents under has its
|
|
20
|
+
* entity — the same guarantee tree order gives this sweep.
|
|
21
|
+
*
|
|
22
|
+
* @param root - The element whose descendant entities to build.
|
|
23
|
+
* @param app - The application to create the entities in.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export const buildDescendantEntities = (root: Element, app: AppBase) => {
|
|
27
|
+
const children = Array.from(root.querySelectorAll('pc-entity')).filter(
|
|
28
|
+
(child): child is EntityElement => child instanceof EntityElement
|
|
29
|
+
);
|
|
30
|
+
children.forEach((child) => child._createEntity(app));
|
|
31
|
+
children.forEach((child) => child._buildHierarchy(app));
|
|
32
|
+
};
|
|
33
|
+
|
|
7
34
|
/**
|
|
8
35
|
* The EntityElement interface provides properties and methods for manipulating
|
|
9
36
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/ | `<pc-entity>`} elements.
|
|
@@ -172,13 +199,7 @@ class EntityElement extends EntityBaseElement {
|
|
|
172
199
|
this._buildHierarchy(app);
|
|
173
200
|
|
|
174
201
|
// Handle any child entities that might exist
|
|
175
|
-
|
|
176
|
-
childEntities.forEach((child) => {
|
|
177
|
-
child._createEntity(app);
|
|
178
|
-
});
|
|
179
|
-
childEntities.forEach((child) => {
|
|
180
|
-
child._buildHierarchy(app);
|
|
181
|
-
});
|
|
202
|
+
buildDescendantEntities(this, app);
|
|
182
203
|
}
|
|
183
204
|
}
|
|
184
205
|
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { CameraComponentElement } from './components/camera-component';
|
|
|
21
21
|
import { CollisionComponentElement } from './components/collision-component';
|
|
22
22
|
import { ComponentElement } from './components/component';
|
|
23
23
|
import { ElementComponentElement } from './components/element-component';
|
|
24
|
+
import { JointComponentElement } from './components/joint-component';
|
|
24
25
|
import { LayoutChildComponentElement } from './components/layoutchild-component';
|
|
25
26
|
import { LayoutGroupComponentElement } from './components/layoutgroup-component';
|
|
26
27
|
import { LightComponentElement } from './components/light-component';
|
|
@@ -50,6 +51,7 @@ import type {
|
|
|
50
51
|
|
|
51
52
|
declare global {
|
|
52
53
|
interface HTMLElementEventMap {
|
|
54
|
+
break: CustomEvent;
|
|
53
55
|
scriptattributeschange: ScriptAttributesChangeEvent;
|
|
54
56
|
scriptenablechange: ScriptEnableChangeEvent;
|
|
55
57
|
scriptnamechange: ScriptNameChangeEvent;
|
|
@@ -64,6 +66,7 @@ declare global {
|
|
|
64
66
|
'pc-element': ElementComponentElement;
|
|
65
67
|
'pc-entity': EntityElement;
|
|
66
68
|
'pc-gsplat': GSplatComponentElement;
|
|
69
|
+
'pc-joint': JointComponentElement;
|
|
67
70
|
'pc-layoutchild': LayoutChildComponentElement;
|
|
68
71
|
'pc-layoutgroup': LayoutGroupComponentElement;
|
|
69
72
|
'pc-light': LightComponentElement;
|
|
@@ -98,6 +101,7 @@ export {
|
|
|
98
101
|
CollisionComponentElement,
|
|
99
102
|
ComponentElement,
|
|
100
103
|
ElementComponentElement,
|
|
104
|
+
JointComponentElement,
|
|
101
105
|
LayoutChildComponentElement,
|
|
102
106
|
LayoutGroupComponentElement,
|
|
103
107
|
ParticleSystemComponentElement,
|
package/src/node.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Entity, EventHandle, GraphNode, Material, MeshInstance, Quat, Rend
|
|
|
2
2
|
import { Vec3 } from 'playcanvas';
|
|
3
3
|
|
|
4
4
|
import { ComponentElement } from './components/component';
|
|
5
|
+
import { buildDescendantEntities } from './entity';
|
|
5
6
|
import type { EntityElement } from './entity';
|
|
6
7
|
import { EntityBaseElement, POINTER_ATTRIBUTES } from './entity-base';
|
|
7
8
|
import { MaterialElement } from './material';
|
|
@@ -490,13 +491,7 @@ class NodeElement extends EntityBaseElement {
|
|
|
490
491
|
if (!app) {
|
|
491
492
|
return;
|
|
492
493
|
}
|
|
493
|
-
|
|
494
|
-
childEntities.forEach((child) => {
|
|
495
|
-
child._createEntity(app);
|
|
496
|
-
});
|
|
497
|
-
childEntities.forEach((child) => {
|
|
498
|
-
child._buildHierarchy(app);
|
|
499
|
-
});
|
|
494
|
+
buildDescendantEntities(this, app);
|
|
500
495
|
}
|
|
501
496
|
|
|
502
497
|
/**
|