@playcanvas/web-components 0.15.0 → 0.17.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.cts +14 -13
- package/dist/app.d.ts +14 -13
- package/dist/async-element.d.cts +13 -13
- package/dist/async-element.d.ts +13 -13
- package/dist/components/anim-clip.d.cts +127 -0
- package/dist/components/anim-clip.d.ts +127 -0
- package/dist/components/anim-component.d.cts +235 -0
- package/dist/components/anim-component.d.ts +235 -0
- package/dist/components/{listener-component.d.cts → audio-listener-component.d.cts} +7 -5
- package/dist/components/{listener-component.d.ts → audio-listener-component.d.ts} +7 -5
- package/dist/components/button-component.d.cts +5 -1
- package/dist/components/button-component.d.ts +5 -1
- package/dist/components/camera-component.d.cts +2 -0
- package/dist/components/camera-component.d.ts +2 -0
- package/dist/components/collision-component.d.cts +5 -1
- package/dist/components/collision-component.d.ts +5 -1
- package/dist/components/component.d.cts +3 -2
- package/dist/components/component.d.ts +3 -2
- package/dist/components/element-component.d.cts +7 -0
- package/dist/components/element-component.d.ts +7 -0
- package/dist/components/gsplat-component.d.cts +2 -0
- package/dist/components/gsplat-component.d.ts +2 -0
- package/dist/components/joint-component.d.cts +2 -0
- package/dist/components/joint-component.d.ts +2 -0
- package/dist/components/{layoutchild-component.d.cts → layout-child-component.d.cts} +3 -1
- package/dist/components/{layoutchild-component.d.ts → layout-child-component.d.ts} +3 -1
- package/dist/components/{layoutgroup-component.d.cts → layout-group-component.d.cts} +3 -1
- package/dist/components/{layoutgroup-component.d.ts → layout-group-component.d.ts} +3 -1
- package/dist/components/light-component.d.cts +2 -0
- package/dist/components/light-component.d.ts +2 -0
- package/dist/components/{particlesystem-component.d.cts → particle-system-component.d.cts} +3 -1
- package/dist/components/{particlesystem-component.d.ts → particle-system-component.d.ts} +3 -1
- package/dist/components/render-component.d.cts +2 -0
- package/dist/components/render-component.d.ts +2 -0
- package/dist/components/{rigidbody-component.d.cts → rigid-body-component.d.cts} +3 -1
- package/dist/components/{rigidbody-component.d.ts → rigid-body-component.d.ts} +3 -1
- package/dist/components/screen-component.d.cts +2 -0
- package/dist/components/screen-component.d.ts +2 -0
- package/dist/components/script-component.d.cts +23 -12
- package/dist/components/script-component.d.ts +23 -12
- package/dist/components/{script.d.cts → script-instance.d.cts} +7 -7
- package/dist/components/{script.d.ts → script-instance.d.ts} +7 -7
- package/dist/components/{scrollview-component.d.cts → scroll-view-component.d.cts} +3 -1
- package/dist/components/{scrollview-component.d.ts → scroll-view-component.d.ts} +3 -1
- package/dist/components/scrollbar-component.d.cts +2 -0
- package/dist/components/scrollbar-component.d.ts +2 -0
- package/dist/components/sound-component.d.cts +3 -1
- package/dist/components/sound-component.d.ts +3 -1
- package/dist/components/sound-slot.d.cts +2 -2
- package/dist/components/sound-slot.d.ts +2 -2
- package/dist/custom-elements.json +3154 -2005
- package/dist/entity-base.d.cts +6 -5
- package/dist/entity-base.d.ts +6 -5
- package/dist/entity-owner.d.cts +118 -0
- package/dist/entity-owner.d.ts +118 -0
- package/dist/entity.d.cts +8 -101
- package/dist/entity.d.ts +8 -101
- package/dist/index.d.cts +26 -21
- package/dist/index.d.ts +26 -21
- package/dist/model.d.cts +67 -24
- package/dist/model.d.ts +67 -24
- package/dist/pwc.cjs +1766 -619
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +1766 -619
- 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 +1762 -618
- package/dist/pwc.mjs.map +1 -1
- package/dist/vscode.html-custom-data.json +203 -89
- package/dist/{module.d.cts → wasm.d.cts} +6 -6
- package/dist/{module.d.ts → wasm.d.ts} +6 -6
- package/dist/web-types.json +556 -273
- package/package.json +7 -7
- package/src/app.ts +45 -35
- package/src/async-element.ts +14 -14
- package/src/components/anim-clip.ts +395 -0
- package/src/components/anim-component.ts +719 -0
- package/src/components/{listener-component.ts → audio-listener-component.ts} +8 -6
- package/src/components/button-component.ts +5 -1
- package/src/components/camera-component.ts +2 -0
- package/src/components/collision-component.ts +5 -1
- package/src/components/component.ts +4 -3
- package/src/components/element-component.ts +7 -0
- package/src/components/gsplat-component.ts +2 -0
- package/src/components/joint-component.ts +2 -0
- package/src/components/{layoutchild-component.ts → layout-child-component.ts} +4 -2
- package/src/components/{layoutgroup-component.ts → layout-group-component.ts} +4 -2
- package/src/components/light-component.ts +2 -0
- package/src/components/{particlesystem-component.ts → particle-system-component.ts} +4 -2
- package/src/components/render-component.ts +2 -0
- package/src/components/{rigidbody-component.ts → rigid-body-component.ts} +4 -2
- package/src/components/screen-component.ts +2 -0
- package/src/components/script-component.ts +63 -42
- package/src/components/{script.ts → script-instance.ts} +14 -14
- package/src/components/{scrollview-component.ts → scroll-view-component.ts} +4 -2
- package/src/components/scrollbar-component.ts +2 -0
- package/src/components/sound-component.ts +4 -2
- package/src/components/sound-slot.ts +4 -4
- package/src/entity-base.ts +6 -5
- package/src/entity-owner.ts +298 -0
- package/src/entity.ts +15 -270
- package/src/index.ts +32 -24
- package/src/model.ts +159 -79
- package/src/node.ts +9 -5
- package/src/{module.ts → wasm.ts} +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -7,34 +7,37 @@
|
|
|
7
7
|
* @module EngineWebComponents
|
|
8
8
|
*/
|
|
9
9
|
import { AsyncElement, whenReady } from './async-element.js';
|
|
10
|
-
import {
|
|
10
|
+
import { WasmElement } from './wasm.js';
|
|
11
11
|
import { AppElement } from './app.js';
|
|
12
12
|
import { EntityElement } from './entity.js';
|
|
13
|
+
import { ModelElement } from './model.js';
|
|
13
14
|
import { AssetElement } from './asset.js';
|
|
14
|
-
import {
|
|
15
|
+
import { AnimComponentElement } from './components/anim-component.js';
|
|
16
|
+
import { AnimClipElement } from './components/anim-clip.js';
|
|
17
|
+
import { AudioListenerComponentElement } from './components/audio-listener-component.js';
|
|
15
18
|
import { ButtonComponentElement } from './components/button-component.js';
|
|
16
19
|
import { CameraComponentElement } from './components/camera-component.js';
|
|
17
20
|
import { CollisionComponentElement } from './components/collision-component.js';
|
|
18
21
|
import { ComponentElement } from './components/component.js';
|
|
19
22
|
import { ElementComponentElement } from './components/element-component.js';
|
|
20
23
|
import { JointComponentElement } from './components/joint-component.js';
|
|
21
|
-
import { LayoutChildComponentElement } from './components/
|
|
22
|
-
import { LayoutGroupComponentElement } from './components/
|
|
24
|
+
import { LayoutChildComponentElement } from './components/layout-child-component.js';
|
|
25
|
+
import { LayoutGroupComponentElement } from './components/layout-group-component.js';
|
|
23
26
|
import { LightComponentElement } from './components/light-component.js';
|
|
24
|
-
import { ParticleSystemComponentElement } from './components/
|
|
27
|
+
import { ParticleSystemComponentElement } from './components/particle-system-component.js';
|
|
25
28
|
import { RenderComponentElement } from './components/render-component.js';
|
|
26
|
-
import { RigidBodyComponentElement } from './components/
|
|
29
|
+
import { RigidBodyComponentElement } from './components/rigid-body-component.js';
|
|
27
30
|
import { ScreenComponentElement } from './components/screen-component.js';
|
|
28
31
|
import { ScrollbarComponentElement } from './components/scrollbar-component.js';
|
|
29
|
-
import { ScrollViewComponentElement } from './components/
|
|
32
|
+
import { ScrollViewComponentElement } from './components/scroll-view-component.js';
|
|
30
33
|
import { ScriptComponentElement } from './components/script-component.js';
|
|
31
|
-
import {
|
|
34
|
+
import { ScriptInstanceElement } from './components/script-instance.js';
|
|
32
35
|
import { SoundComponentElement } from './components/sound-component.js';
|
|
33
36
|
import { SoundSlotElement } from './components/sound-slot.js';
|
|
34
37
|
import { GSplatComponentElement } from './components/gsplat-component.js';
|
|
35
38
|
import { EntityBaseElement } from './entity-base.js';
|
|
39
|
+
import { EntityOwnerElement } from './entity-owner.js';
|
|
36
40
|
import { MaterialElement } from './material.js';
|
|
37
|
-
import { ModelElement } from './model.js';
|
|
38
41
|
import { NodeElement } from './node.js';
|
|
39
42
|
import { SceneElement } from './scene.js';
|
|
40
43
|
import { SkyElement } from './sky.js';
|
|
@@ -47,6 +50,8 @@ declare global {
|
|
|
47
50
|
scriptnamechange: ScriptNameChangeEvent;
|
|
48
51
|
}
|
|
49
52
|
interface HTMLElementTagNameMap {
|
|
53
|
+
'pc-anim': AnimComponentElement;
|
|
54
|
+
'pc-anim-clip': AnimClipElement;
|
|
50
55
|
'pc-app': AppElement;
|
|
51
56
|
'pc-asset': AssetElement;
|
|
52
57
|
'pc-button': ButtonComponentElement;
|
|
@@ -56,29 +61,29 @@ declare global {
|
|
|
56
61
|
'pc-entity': EntityElement;
|
|
57
62
|
'pc-gsplat': GSplatComponentElement;
|
|
58
63
|
'pc-joint': JointComponentElement;
|
|
59
|
-
'pc-
|
|
60
|
-
'pc-
|
|
64
|
+
'pc-layout-child': LayoutChildComponentElement;
|
|
65
|
+
'pc-layout-group': LayoutGroupComponentElement;
|
|
61
66
|
'pc-light': LightComponentElement;
|
|
62
|
-
'pc-listener':
|
|
67
|
+
'pc-audio-listener': AudioListenerComponentElement;
|
|
63
68
|
'pc-material': MaterialElement;
|
|
64
69
|
'pc-model': ModelElement;
|
|
65
|
-
'pc-
|
|
70
|
+
'pc-wasm': WasmElement;
|
|
66
71
|
'pc-node': NodeElement;
|
|
67
|
-
'pc-
|
|
72
|
+
'pc-particle-system': ParticleSystemComponentElement;
|
|
68
73
|
'pc-render': RenderComponentElement;
|
|
69
|
-
'pc-
|
|
74
|
+
'pc-rigid-body': RigidBodyComponentElement;
|
|
70
75
|
'pc-scene': SceneElement;
|
|
71
76
|
'pc-screen': ScreenComponentElement;
|
|
72
|
-
'pc-script':
|
|
73
|
-
'pc-
|
|
77
|
+
'pc-script-instance': ScriptInstanceElement;
|
|
78
|
+
'pc-script': ScriptComponentElement;
|
|
74
79
|
'pc-scrollbar': ScrollbarComponentElement;
|
|
75
|
-
'pc-
|
|
80
|
+
'pc-scroll-view': ScrollViewComponentElement;
|
|
76
81
|
'pc-sky': SkyElement;
|
|
77
|
-
'pc-sound': SoundSlotElement;
|
|
78
|
-
'pc-
|
|
82
|
+
'pc-sound-slot': SoundSlotElement;
|
|
83
|
+
'pc-sound': SoundComponentElement;
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
|
-
export { AsyncElement,
|
|
86
|
+
export { AsyncElement, WasmElement, AppElement, EntityElement, AssetElement, AnimComponentElement, AnimClipElement, ButtonComponentElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, JointComponentElement, LayoutChildComponentElement, LayoutGroupComponentElement, ParticleSystemComponentElement, LightComponentElement, AudioListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScrollbarComponentElement, ScrollViewComponentElement, ScriptComponentElement, ScriptInstanceElement, SoundComponentElement, SoundSlotElement, GSplatComponentElement, EntityBaseElement, EntityOwnerElement, MaterialElement, ModelElement, NodeElement, SceneElement, SkyElement, whenReady };
|
|
82
87
|
export type { AsyncElementTagName } from './async-element.js';
|
|
83
88
|
export type { HierarchyMaterial, HierarchyNode } from './model.js';
|
|
84
89
|
export type { MaterialOverrides } from './node.js';
|
package/dist/model.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Entity } from 'playcanvas';
|
|
2
|
-
import {
|
|
2
|
+
import { EntityOwnerElement } from './entity-owner.cjs';
|
|
3
3
|
/**
|
|
4
4
|
* One material assignment of a {@link HierarchyNode} with a render component: a mesh instance's
|
|
5
5
|
* position within the component and the runtime name of its current material.
|
|
@@ -61,14 +61,42 @@ type HierarchyNode = {
|
|
|
61
61
|
* The ModelElement interface also inherits the properties and methods of the
|
|
62
62
|
* {@link HTMLElement} interface.
|
|
63
63
|
*
|
|
64
|
-
* The element
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* hierarchy. A `pc-model` outside a `pc-app`, or referencing an unknown asset id, warns and never
|
|
70
|
-
* becomes ready.
|
|
64
|
+
* The element creates and fronts a stable host entity: `entity` is that host, created when the
|
|
65
|
+
* application builds its hierarchy and kept across `asset` changes, so the element's transform
|
|
66
|
+
* and tags are instance placement that composes with whatever transform the asset authored on
|
|
67
|
+
* its root. The instantiated content is parented beneath the host and exposed as
|
|
68
|
+
* {@link contentEntity}.
|
|
71
69
|
*
|
|
70
|
+
* The element becomes ready once its current asset selection has settled: the container asset
|
|
71
|
+
* has loaded and its content root has been parented beneath the host, the load has failed
|
|
72
|
+
* (`contentEntity` stays `null` — listen for `error`, or check `contentEntity`, to tell the
|
|
73
|
+
* outcomes apart), or no asset is assigned at all. Changing `asset` re-arms readiness and
|
|
74
|
+
* instantiates anew, so a `ready()` obtained after the change resolves against the new content.
|
|
75
|
+
* A `pc-model` outside a `pc-app`, or referencing an unknown asset id, warns and never becomes
|
|
76
|
+
* ready.
|
|
77
|
+
*
|
|
78
|
+
* The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
|
|
79
|
+
* intersects the model's geometry, exactly as for `<pc-entity>` — a hit on a content node that no
|
|
80
|
+
* `pc-node` fronts resolves to this element.
|
|
81
|
+
*
|
|
82
|
+
* @attribute {boolean} enabled - The enabled state of the model.
|
|
83
|
+
* @attribute {string} name - The name of the model.
|
|
84
|
+
* @attribute {string} position - The position of the model.
|
|
85
|
+
* @attribute {string} rotation - The rotation of the model.
|
|
86
|
+
* @attribute {string} scale - The scale of the model.
|
|
87
|
+
* @attribute {string} tags - The tags of the model.
|
|
88
|
+
* @attribute {string} onpointerenter - Script to run when the pointer moves onto the model.
|
|
89
|
+
* @attribute {string} onpointerleave - Script to run when the pointer moves off the model.
|
|
90
|
+
* @attribute {string} onpointermove - Script to run when the pointer moves over the model.
|
|
91
|
+
* @attribute {string} onpointerdown - Script to run when a pointer button is pressed over the
|
|
92
|
+
* model.
|
|
93
|
+
* @attribute {string} onpointerup - Script to run when a pointer button is released over the
|
|
94
|
+
* model.
|
|
95
|
+
* @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the model.
|
|
96
|
+
* @fires {PointerEvent} pointerleave - Fired when the pointer moves off the model.
|
|
97
|
+
* @fires {PointerEvent} pointermove - Fired when the pointer moves over the model.
|
|
98
|
+
* @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the model.
|
|
99
|
+
* @fires {PointerEvent} pointerup - Fired when a pointer button is released over the model.
|
|
72
100
|
* @fires {Event} load - Fired each time a container asset finishes instantiating, including
|
|
73
101
|
* re-instantiation after `asset` changes. Does not bubble — listen on this element, or use a
|
|
74
102
|
* capture-phase listener on an ancestor.
|
|
@@ -76,14 +104,14 @@ type HierarchyNode = {
|
|
|
76
104
|
* error in `message`. Does not bubble. The element still becomes ready — readiness means the load
|
|
77
105
|
* settled, not that it succeeded.
|
|
78
106
|
*/
|
|
79
|
-
declare class ModelElement extends
|
|
107
|
+
declare class ModelElement extends EntityOwnerElement {
|
|
80
108
|
private _asset;
|
|
81
|
-
private
|
|
109
|
+
private _contentEntity;
|
|
82
110
|
/**
|
|
83
|
-
* Incremented on every new load
|
|
84
|
-
* load that resumes from an await or a load callback abandons
|
|
85
|
-
* on, so a superseded load can neither instantiate a second
|
|
86
|
-
*
|
|
111
|
+
* Incremented on every new load, on disconnect, and when the host entity dies, and captured
|
|
112
|
+
* by a load when it starts. A load that resumes from an await or a load callback abandons
|
|
113
|
+
* itself if the value has moved on, so a superseded load can neither instantiate a second
|
|
114
|
+
* content root nor parent one under a host a newer cycle has already replaced.
|
|
87
115
|
*/
|
|
88
116
|
private _loadGeneration;
|
|
89
117
|
/**
|
|
@@ -94,11 +122,12 @@ declare class ModelElement extends AsyncElement {
|
|
|
94
122
|
private _loadHandle;
|
|
95
123
|
private _errorHandle;
|
|
96
124
|
/**
|
|
97
|
-
* The root entity of the instantiated model
|
|
98
|
-
*
|
|
99
|
-
*
|
|
125
|
+
* The root entity of the instantiated model content, parented beneath the host entity.
|
|
126
|
+
* `null` until the container asset has loaded and been instantiated, after a failed load,
|
|
127
|
+
* and again once the element has been removed from the document.
|
|
128
|
+
* @returns The content root entity, or `null`.
|
|
100
129
|
*/
|
|
101
|
-
get
|
|
130
|
+
get contentEntity(): Entity | null;
|
|
102
131
|
/**
|
|
103
132
|
* Returns a snapshot of the instantiated node tree, or `null` while there is none (the
|
|
104
133
|
* container asset has not loaded, or the element has left the document). One call grounds a
|
|
@@ -109,23 +138,37 @@ declare class ModelElement extends AsyncElement {
|
|
|
109
138
|
* is the printable form.
|
|
110
139
|
*
|
|
111
140
|
* The snapshot is plain data, computed afresh each call: it does not follow later changes
|
|
112
|
-
* to the hierarchy, and mutating it changes nothing.
|
|
141
|
+
* to the hierarchy, and mutating it changes nothing. It covers the instantiated content
|
|
142
|
+
* only — the host entity the element fronts is not part of the asset's node tree.
|
|
113
143
|
*
|
|
114
144
|
* @returns The root of the instantiated node tree, or `null`.
|
|
115
145
|
*/
|
|
116
146
|
hierarchy(): HierarchyNode | null;
|
|
117
147
|
connectedCallback(): void;
|
|
118
148
|
disconnectedCallback(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Starts (or restarts) the content load once the host has been parented. Readiness is not
|
|
151
|
+
* announced here — it tracks the content settling, not the host entering the scene graph.
|
|
152
|
+
*/
|
|
153
|
+
protected _onBuilt(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Extends the owner reset for the content: the engine's destroy cascade has already taken
|
|
156
|
+
* the content root down with the host subtree, so only the reference and the in-flight load
|
|
157
|
+
* are dropped here. The next build re-creates the host and re-instantiates the content.
|
|
158
|
+
*
|
|
159
|
+
* @param entity - The host entity that was destroyed.
|
|
160
|
+
*/
|
|
161
|
+
protected _onEntityDestroy(entity: Entity): void;
|
|
119
162
|
private _detachLoadHandlers;
|
|
120
163
|
/**
|
|
121
|
-
* Resolves readiness and dispatches the `load` event. Called once the instantiated
|
|
122
|
-
* has been parented —
|
|
123
|
-
* model's
|
|
164
|
+
* Resolves readiness and dispatches the `load` event. Called once the instantiated content
|
|
165
|
+
* has been parented beneath the host — the host itself is already in the scene graph by
|
|
166
|
+
* then, so a ready model's content always has world transforms.
|
|
124
167
|
*/
|
|
125
168
|
private _announceLoad;
|
|
126
169
|
private _instantiate;
|
|
127
|
-
private
|
|
128
|
-
private
|
|
170
|
+
private _destroyContent;
|
|
171
|
+
private _loadContent;
|
|
129
172
|
/**
|
|
130
173
|
* Sets the id of the `pc-asset` to use for the model.
|
|
131
174
|
* @param value - The asset ID.
|
package/dist/model.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Entity } from 'playcanvas';
|
|
2
|
-
import {
|
|
2
|
+
import { EntityOwnerElement } from './entity-owner.js';
|
|
3
3
|
/**
|
|
4
4
|
* One material assignment of a {@link HierarchyNode} with a render component: a mesh instance's
|
|
5
5
|
* position within the component and the runtime name of its current material.
|
|
@@ -61,14 +61,42 @@ type HierarchyNode = {
|
|
|
61
61
|
* The ModelElement interface also inherits the properties and methods of the
|
|
62
62
|
* {@link HTMLElement} interface.
|
|
63
63
|
*
|
|
64
|
-
* The element
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* hierarchy. A `pc-model` outside a `pc-app`, or referencing an unknown asset id, warns and never
|
|
70
|
-
* becomes ready.
|
|
64
|
+
* The element creates and fronts a stable host entity: `entity` is that host, created when the
|
|
65
|
+
* application builds its hierarchy and kept across `asset` changes, so the element's transform
|
|
66
|
+
* and tags are instance placement that composes with whatever transform the asset authored on
|
|
67
|
+
* its root. The instantiated content is parented beneath the host and exposed as
|
|
68
|
+
* {@link contentEntity}.
|
|
71
69
|
*
|
|
70
|
+
* The element becomes ready once its current asset selection has settled: the container asset
|
|
71
|
+
* has loaded and its content root has been parented beneath the host, the load has failed
|
|
72
|
+
* (`contentEntity` stays `null` — listen for `error`, or check `contentEntity`, to tell the
|
|
73
|
+
* outcomes apart), or no asset is assigned at all. Changing `asset` re-arms readiness and
|
|
74
|
+
* instantiates anew, so a `ready()` obtained after the change resolves against the new content.
|
|
75
|
+
* A `pc-model` outside a `pc-app`, or referencing an unknown asset id, warns and never becomes
|
|
76
|
+
* ready.
|
|
77
|
+
*
|
|
78
|
+
* The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
|
|
79
|
+
* intersects the model's geometry, exactly as for `<pc-entity>` — a hit on a content node that no
|
|
80
|
+
* `pc-node` fronts resolves to this element.
|
|
81
|
+
*
|
|
82
|
+
* @attribute {boolean} enabled - The enabled state of the model.
|
|
83
|
+
* @attribute {string} name - The name of the model.
|
|
84
|
+
* @attribute {string} position - The position of the model.
|
|
85
|
+
* @attribute {string} rotation - The rotation of the model.
|
|
86
|
+
* @attribute {string} scale - The scale of the model.
|
|
87
|
+
* @attribute {string} tags - The tags of the model.
|
|
88
|
+
* @attribute {string} onpointerenter - Script to run when the pointer moves onto the model.
|
|
89
|
+
* @attribute {string} onpointerleave - Script to run when the pointer moves off the model.
|
|
90
|
+
* @attribute {string} onpointermove - Script to run when the pointer moves over the model.
|
|
91
|
+
* @attribute {string} onpointerdown - Script to run when a pointer button is pressed over the
|
|
92
|
+
* model.
|
|
93
|
+
* @attribute {string} onpointerup - Script to run when a pointer button is released over the
|
|
94
|
+
* model.
|
|
95
|
+
* @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the model.
|
|
96
|
+
* @fires {PointerEvent} pointerleave - Fired when the pointer moves off the model.
|
|
97
|
+
* @fires {PointerEvent} pointermove - Fired when the pointer moves over the model.
|
|
98
|
+
* @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the model.
|
|
99
|
+
* @fires {PointerEvent} pointerup - Fired when a pointer button is released over the model.
|
|
72
100
|
* @fires {Event} load - Fired each time a container asset finishes instantiating, including
|
|
73
101
|
* re-instantiation after `asset` changes. Does not bubble — listen on this element, or use a
|
|
74
102
|
* capture-phase listener on an ancestor.
|
|
@@ -76,14 +104,14 @@ type HierarchyNode = {
|
|
|
76
104
|
* error in `message`. Does not bubble. The element still becomes ready — readiness means the load
|
|
77
105
|
* settled, not that it succeeded.
|
|
78
106
|
*/
|
|
79
|
-
declare class ModelElement extends
|
|
107
|
+
declare class ModelElement extends EntityOwnerElement {
|
|
80
108
|
private _asset;
|
|
81
|
-
private
|
|
109
|
+
private _contentEntity;
|
|
82
110
|
/**
|
|
83
|
-
* Incremented on every new load
|
|
84
|
-
* load that resumes from an await or a load callback abandons
|
|
85
|
-
* on, so a superseded load can neither instantiate a second
|
|
86
|
-
*
|
|
111
|
+
* Incremented on every new load, on disconnect, and when the host entity dies, and captured
|
|
112
|
+
* by a load when it starts. A load that resumes from an await or a load callback abandons
|
|
113
|
+
* itself if the value has moved on, so a superseded load can neither instantiate a second
|
|
114
|
+
* content root nor parent one under a host a newer cycle has already replaced.
|
|
87
115
|
*/
|
|
88
116
|
private _loadGeneration;
|
|
89
117
|
/**
|
|
@@ -94,11 +122,12 @@ declare class ModelElement extends AsyncElement {
|
|
|
94
122
|
private _loadHandle;
|
|
95
123
|
private _errorHandle;
|
|
96
124
|
/**
|
|
97
|
-
* The root entity of the instantiated model
|
|
98
|
-
*
|
|
99
|
-
*
|
|
125
|
+
* The root entity of the instantiated model content, parented beneath the host entity.
|
|
126
|
+
* `null` until the container asset has loaded and been instantiated, after a failed load,
|
|
127
|
+
* and again once the element has been removed from the document.
|
|
128
|
+
* @returns The content root entity, or `null`.
|
|
100
129
|
*/
|
|
101
|
-
get
|
|
130
|
+
get contentEntity(): Entity | null;
|
|
102
131
|
/**
|
|
103
132
|
* Returns a snapshot of the instantiated node tree, or `null` while there is none (the
|
|
104
133
|
* container asset has not loaded, or the element has left the document). One call grounds a
|
|
@@ -109,23 +138,37 @@ declare class ModelElement extends AsyncElement {
|
|
|
109
138
|
* is the printable form.
|
|
110
139
|
*
|
|
111
140
|
* The snapshot is plain data, computed afresh each call: it does not follow later changes
|
|
112
|
-
* to the hierarchy, and mutating it changes nothing.
|
|
141
|
+
* to the hierarchy, and mutating it changes nothing. It covers the instantiated content
|
|
142
|
+
* only — the host entity the element fronts is not part of the asset's node tree.
|
|
113
143
|
*
|
|
114
144
|
* @returns The root of the instantiated node tree, or `null`.
|
|
115
145
|
*/
|
|
116
146
|
hierarchy(): HierarchyNode | null;
|
|
117
147
|
connectedCallback(): void;
|
|
118
148
|
disconnectedCallback(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Starts (or restarts) the content load once the host has been parented. Readiness is not
|
|
151
|
+
* announced here — it tracks the content settling, not the host entering the scene graph.
|
|
152
|
+
*/
|
|
153
|
+
protected _onBuilt(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Extends the owner reset for the content: the engine's destroy cascade has already taken
|
|
156
|
+
* the content root down with the host subtree, so only the reference and the in-flight load
|
|
157
|
+
* are dropped here. The next build re-creates the host and re-instantiates the content.
|
|
158
|
+
*
|
|
159
|
+
* @param entity - The host entity that was destroyed.
|
|
160
|
+
*/
|
|
161
|
+
protected _onEntityDestroy(entity: Entity): void;
|
|
119
162
|
private _detachLoadHandlers;
|
|
120
163
|
/**
|
|
121
|
-
* Resolves readiness and dispatches the `load` event. Called once the instantiated
|
|
122
|
-
* has been parented —
|
|
123
|
-
* model's
|
|
164
|
+
* Resolves readiness and dispatches the `load` event. Called once the instantiated content
|
|
165
|
+
* has been parented beneath the host — the host itself is already in the scene graph by
|
|
166
|
+
* then, so a ready model's content always has world transforms.
|
|
124
167
|
*/
|
|
125
168
|
private _announceLoad;
|
|
126
169
|
private _instantiate;
|
|
127
|
-
private
|
|
128
|
-
private
|
|
170
|
+
private _destroyContent;
|
|
171
|
+
private _loadContent;
|
|
129
172
|
/**
|
|
130
173
|
* Sets the id of the `pc-asset` to use for the model.
|
|
131
174
|
* @param value - The asset ID.
|