@playcanvas/web-components 0.17.0 → 0.19.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 +5 -3
- package/dist/app.d.cts +28 -3
- package/dist/app.d.ts +28 -3
- package/dist/asset.d.cts +13 -3
- package/dist/asset.d.ts +13 -3
- package/dist/components/anim-clip.d.cts +3 -1
- package/dist/components/anim-clip.d.ts +3 -1
- package/dist/components/anim-component.d.cts +5 -0
- package/dist/components/anim-component.d.ts +5 -0
- package/dist/components/audio-listener-component.d.cts +4 -0
- package/dist/components/audio-listener-component.d.ts +4 -0
- package/dist/components/button-component.d.cts +5 -0
- package/dist/components/button-component.d.ts +5 -0
- package/dist/components/camera-component.d.cts +35 -1
- package/dist/components/camera-component.d.ts +35 -1
- package/dist/components/collision-component.d.cts +4 -0
- package/dist/components/collision-component.d.ts +4 -0
- package/dist/components/element-component.d.cts +4 -0
- package/dist/components/element-component.d.ts +4 -0
- package/dist/components/gsplat-component.d.cts +4 -0
- package/dist/components/gsplat-component.d.ts +4 -0
- package/dist/components/joint-component.d.cts +12 -2
- package/dist/components/joint-component.d.ts +12 -2
- package/dist/components/layout-child-component.d.cts +4 -0
- package/dist/components/layout-child-component.d.ts +4 -0
- package/dist/components/layout-group-component.d.cts +4 -0
- package/dist/components/layout-group-component.d.ts +4 -0
- package/dist/components/light-component.d.cts +50 -1
- package/dist/components/light-component.d.ts +50 -1
- package/dist/components/particle-system-component.d.cts +4 -0
- package/dist/components/particle-system-component.d.ts +4 -0
- package/dist/components/render-component.d.cts +5 -0
- package/dist/components/render-component.d.ts +5 -0
- package/dist/components/rigid-body-component.d.cts +5 -0
- package/dist/components/rigid-body-component.d.ts +5 -0
- package/dist/components/screen-component.d.cts +4 -0
- package/dist/components/screen-component.d.ts +4 -0
- package/dist/components/script-component.d.cts +3 -0
- package/dist/components/script-component.d.ts +3 -0
- package/dist/components/script-instance.d.cts +4 -0
- package/dist/components/script-instance.d.ts +4 -0
- package/dist/components/scroll-view-component.d.cts +4 -0
- package/dist/components/scroll-view-component.d.ts +4 -0
- package/dist/components/scrollbar-component.d.cts +4 -0
- package/dist/components/scrollbar-component.d.ts +4 -0
- package/dist/components/sound-component.d.cts +4 -0
- package/dist/components/sound-component.d.ts +4 -0
- package/dist/components/sound-slot.d.cts +3 -0
- package/dist/components/sound-slot.d.ts +3 -0
- package/dist/custom-elements.json +338 -7
- package/dist/entity-base.d.cts +5 -4
- package/dist/entity-base.d.ts +5 -4
- package/dist/entity-owner.d.cts +2 -2
- package/dist/entity-owner.d.ts +2 -2
- package/dist/entity.d.cts +13 -2
- package/dist/entity.d.ts +13 -2
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/material.d.cts +18 -7
- package/dist/material.d.ts +18 -7
- package/dist/model.d.cts +11 -0
- package/dist/model.d.ts +11 -0
- package/dist/node.d.cts +12 -1
- package/dist/node.d.ts +12 -1
- package/dist/pwc.cjs +601 -206
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +601 -206
- 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 +602 -207
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.cts +19 -0
- package/dist/scene.d.ts +19 -0
- package/dist/sky.d.cts +4 -0
- package/dist/sky.d.ts +4 -0
- package/dist/vscode.html-custom-data.json +257 -62
- package/dist/wasm.d.cts +4 -0
- package/dist/wasm.d.ts +4 -0
- package/dist/web-types.json +169 -69
- package/package.json +3 -3
- package/src/app.ts +150 -71
- package/src/asset.ts +13 -4
- package/src/components/anim-clip.ts +3 -1
- package/src/components/anim-component.ts +5 -0
- package/src/components/audio-listener-component.ts +4 -0
- package/src/components/button-component.ts +5 -0
- package/src/components/camera-component.ts +63 -6
- package/src/components/collision-component.ts +4 -0
- package/src/components/element-component.ts +4 -0
- package/src/components/gsplat-component.ts +4 -0
- package/src/components/joint-component.ts +12 -2
- package/src/components/layout-child-component.ts +4 -0
- package/src/components/layout-group-component.ts +4 -0
- package/src/components/light-component.ts +108 -17
- package/src/components/particle-system-component.ts +4 -0
- package/src/components/render-component.ts +5 -0
- package/src/components/rigid-body-component.ts +5 -0
- package/src/components/screen-component.ts +4 -0
- package/src/components/script-component.ts +3 -0
- package/src/components/script-instance.ts +4 -0
- package/src/components/scroll-view-component.ts +4 -0
- package/src/components/scrollbar-component.ts +4 -0
- package/src/components/sound-component.ts +4 -0
- package/src/components/sound-slot.ts +3 -0
- package/src/entity-base.ts +28 -16
- package/src/entity-owner.ts +2 -2
- package/src/entity.ts +16 -4
- package/src/index.ts +12 -1
- package/src/material.ts +19 -8
- package/src/model.ts +14 -2
- package/src/node.ts +15 -3
- package/src/scene.ts +35 -1
- package/src/sky.ts +4 -0
- package/src/wasm.ts +4 -0
package/src/model.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ContainerResource, Entity, EventHandle } from 'playcanvas';
|
|
|
2
2
|
import { Vec3 } from 'playcanvas';
|
|
3
3
|
|
|
4
4
|
import { useAsset } from './asset';
|
|
5
|
-
import {
|
|
5
|
+
import { EVENT_ATTRIBUTES } from './entity-base';
|
|
6
6
|
import { buildDescendantEntities, EntityOwnerElement } from './entity-owner';
|
|
7
7
|
import { parseBool, parseTags, parseVec3 } from './parse';
|
|
8
8
|
|
|
@@ -125,6 +125,11 @@ const formatHierarchy = (root: HierarchyNode, counts: ReadonlyMap<string, number
|
|
|
125
125
|
* intersects the model's geometry, exactly as for `<pc-entity>` — a hit on a content node that no
|
|
126
126
|
* `pc-node` fronts resolves to this element.
|
|
127
127
|
*
|
|
128
|
+
* @elementSummary The `<pc-model>` element instantiates a 3D model from a container asset
|
|
129
|
+
* (typically a GLB) beneath an entity of its own, so the element's transform and tags place the
|
|
130
|
+
* instance in the scene. Its `<pc-node>` children override what the asset authored. Place it in the
|
|
131
|
+
* `<pc-scene>`, or nest it under a `<pc-entity>`, another `<pc-model>` or a `<pc-node>`.
|
|
132
|
+
*
|
|
128
133
|
* @attribute {boolean} enabled - The enabled state of the model.
|
|
129
134
|
* @attribute {string} name - The name of the model.
|
|
130
135
|
* @attribute {string} position - The position of the model.
|
|
@@ -138,11 +143,17 @@ const formatHierarchy = (root: HierarchyNode, counts: ReadonlyMap<string, number
|
|
|
138
143
|
* model.
|
|
139
144
|
* @attribute {string} onpointerup - Script to run when a pointer button is released over the
|
|
140
145
|
* model.
|
|
146
|
+
* @attribute {string} onclick - Script to run when the model is clicked: a primary pointer
|
|
147
|
+
* button pressed and then released over it.
|
|
141
148
|
* @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the model.
|
|
142
149
|
* @fires {PointerEvent} pointerleave - Fired when the pointer moves off the model.
|
|
143
150
|
* @fires {PointerEvent} pointermove - Fired when the pointer moves over the model.
|
|
144
151
|
* @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the model.
|
|
145
152
|
* @fires {PointerEvent} pointerup - Fired when a pointer button is released over the model.
|
|
153
|
+
* @fires {PointerEvent} click - Fired when a primary pointer button is pressed and then released
|
|
154
|
+
* over the model. A press and release that picked different entities fires on their nearest
|
|
155
|
+
* common ancestor instead, as in the DOM. `detail` carries the click count, so a double click
|
|
156
|
+
* arrives as a click whose `detail` is 2.
|
|
146
157
|
* @fires {Event} load - Fired each time a container asset finishes instantiating, including
|
|
147
158
|
* re-instantiation after `asset` changes. Does not bubble — listen on this element, or use a
|
|
148
159
|
* capture-phase listener on an ancestor.
|
|
@@ -430,7 +441,7 @@ class ModelElement extends EntityOwnerElement {
|
|
|
430
441
|
}
|
|
431
442
|
|
|
432
443
|
static get observedAttributes() {
|
|
433
|
-
return ['asset', 'enabled', 'name', 'position', 'rotation', 'scale', 'tags', ...
|
|
444
|
+
return ['asset', 'enabled', 'name', 'position', 'rotation', 'scale', 'tags', ...EVENT_ATTRIBUTES];
|
|
434
445
|
}
|
|
435
446
|
|
|
436
447
|
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
|
|
@@ -461,6 +472,7 @@ class ModelElement extends EntityOwnerElement {
|
|
|
461
472
|
case 'onpointerdown':
|
|
462
473
|
case 'onpointerup':
|
|
463
474
|
case 'onpointermove':
|
|
475
|
+
case 'onclick':
|
|
464
476
|
this._updateInlineHandler(name, newValue);
|
|
465
477
|
break;
|
|
466
478
|
}
|
package/src/node.ts
CHANGED
|
@@ -2,7 +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 { EntityBaseElement,
|
|
5
|
+
import { EntityBaseElement, EVENT_ATTRIBUTES } from './entity-base';
|
|
6
6
|
import { buildDescendantEntities } from './entity-owner';
|
|
7
7
|
import type { EntityOwnerElement } from './entity-owner';
|
|
8
8
|
import { MaterialElement } from './material';
|
|
@@ -15,7 +15,7 @@ import { parseBool, parseTags, parseVec3 } from './parse';
|
|
|
15
15
|
* `missing`/`ambiguous`/`duplicate` when resolution failed — each accompanied by a warning
|
|
16
16
|
* naming the cause.
|
|
17
17
|
*/
|
|
18
|
-
type NodeBindingState = 'pending' | 'bound' | 'missing' | 'ambiguous' | 'duplicate';
|
|
18
|
+
export type NodeBindingState = 'pending' | 'bound' | 'missing' | 'ambiguous' | 'duplicate';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* The authored values a bound node's overrides displaced, captured per property when the first
|
|
@@ -164,6 +164,11 @@ const levenshtein = (a: string, b: string): number => {
|
|
|
164
164
|
* The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
|
|
165
165
|
* intersects the bound node's geometry, exactly as for `<pc-entity>`.
|
|
166
166
|
*
|
|
167
|
+
* @elementSummary The `<pc-node>` element binds to a node inside the hierarchy a `<pc-model>`
|
|
168
|
+
* instantiated and declares overrides against it: a transform, an enabled state, tags, components
|
|
169
|
+
* to add, or content to attach. Its `name` is a lookup, never a rename. Must be a descendant of
|
|
170
|
+
* `<pc-model>`.
|
|
171
|
+
*
|
|
167
172
|
* @attribute {string} name - The name of the node to bind, resolved within the nearest ancestor
|
|
168
173
|
* `pc-model` (or `pc-node`) once it has instantiated.
|
|
169
174
|
* @attribute {number} index - Which match to bind when `name` matches more than one node,
|
|
@@ -188,11 +193,17 @@ const levenshtein = (a: string, b: string): number => {
|
|
|
188
193
|
* node.
|
|
189
194
|
* @attribute {string} onpointerup - Script to run when a pointer button is released over the
|
|
190
195
|
* node.
|
|
196
|
+
* @attribute {string} onclick - Script to run when the node is clicked: a primary pointer
|
|
197
|
+
* button pressed and then released over it.
|
|
191
198
|
* @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the node.
|
|
192
199
|
* @fires {PointerEvent} pointerleave - Fired when the pointer moves off the node.
|
|
193
200
|
* @fires {PointerEvent} pointermove - Fired when the pointer moves over the node.
|
|
194
201
|
* @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the node.
|
|
195
202
|
* @fires {PointerEvent} pointerup - Fired when a pointer button is released over the node.
|
|
203
|
+
* @fires {PointerEvent} click - Fired when a primary pointer button is pressed and then released
|
|
204
|
+
* over the node. A press and release that picked different entities fires on their nearest
|
|
205
|
+
* common ancestor instead, as in the DOM. `detail` carries the click count, so a double click
|
|
206
|
+
* arrives as a click whose `detail` is 2.
|
|
196
207
|
*/
|
|
197
208
|
class NodeElement extends EntityBaseElement {
|
|
198
209
|
private _name = '';
|
|
@@ -928,7 +939,7 @@ class NodeElement extends EntityBaseElement {
|
|
|
928
939
|
'rotation',
|
|
929
940
|
'scale',
|
|
930
941
|
'tags',
|
|
931
|
-
...
|
|
942
|
+
...EVENT_ATTRIBUTES
|
|
932
943
|
];
|
|
933
944
|
}
|
|
934
945
|
|
|
@@ -977,6 +988,7 @@ class NodeElement extends EntityBaseElement {
|
|
|
977
988
|
case 'onpointerdown':
|
|
978
989
|
case 'onpointerup':
|
|
979
990
|
case 'onpointermove':
|
|
991
|
+
case 'onclick':
|
|
980
992
|
this._updateInlineHandler(name, newValue);
|
|
981
993
|
break;
|
|
982
994
|
}
|
package/src/scene.ts
CHANGED
|
@@ -9,8 +9,17 @@ import { parseColor, parseEnum, parseNumber, parseVec3 } from './parse';
|
|
|
9
9
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scene/ | `<pc-scene>`} elements.
|
|
10
10
|
* The SceneElement interface also inherits the properties and methods of the
|
|
11
11
|
* {@link HTMLElement} interface.
|
|
12
|
+
*
|
|
13
|
+
* @elementSummary The `<pc-scene>` element holds the entity hierarchy the application renders,
|
|
14
|
+
* along with the scene-wide fog, exposure and gravity settings. Must be a direct child of
|
|
15
|
+
* `<pc-app>`.
|
|
12
16
|
*/
|
|
13
17
|
class SceneElement extends AsyncElement {
|
|
18
|
+
/**
|
|
19
|
+
* The exposure of the scene.
|
|
20
|
+
*/
|
|
21
|
+
private _exposure = 1;
|
|
22
|
+
|
|
14
23
|
/**
|
|
15
24
|
* The fog type of the scene.
|
|
16
25
|
*/
|
|
@@ -93,6 +102,8 @@ class SceneElement extends AsyncElement {
|
|
|
93
102
|
|
|
94
103
|
private _updateSceneSettings() {
|
|
95
104
|
if (this._scene) {
|
|
105
|
+
this._scene.exposure = this._exposure;
|
|
106
|
+
|
|
96
107
|
this._scene.fog.type = this._fog;
|
|
97
108
|
this._scene.fog.color = this._fogColor;
|
|
98
109
|
this._scene.fog.density = this._fogDensity;
|
|
@@ -114,6 +125,26 @@ class SceneElement extends AsyncElement {
|
|
|
114
125
|
this.closestApp?.app?.systems.rigidbody?.gravity.copy(value);
|
|
115
126
|
}
|
|
116
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Sets the exposure of the scene, which tweaks the overall brightness of the rendered image.
|
|
130
|
+
* Ignored if the scene is using physical units. Defaults to 1.
|
|
131
|
+
* @param value - The exposure.
|
|
132
|
+
*/
|
|
133
|
+
set exposure(value: number) {
|
|
134
|
+
this._exposure = value;
|
|
135
|
+
if (this.scene) {
|
|
136
|
+
this.scene.exposure = value;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Gets the exposure of the scene.
|
|
142
|
+
* @returns The exposure.
|
|
143
|
+
*/
|
|
144
|
+
get exposure() {
|
|
145
|
+
return this._exposure;
|
|
146
|
+
}
|
|
147
|
+
|
|
117
148
|
/**
|
|
118
149
|
* Sets the fog type of the scene. Can be `none`, `linear`, `exp` or `exp2`. Defaults to
|
|
119
150
|
* `none`.
|
|
@@ -230,11 +261,14 @@ class SceneElement extends AsyncElement {
|
|
|
230
261
|
}
|
|
231
262
|
|
|
232
263
|
static get observedAttributes() {
|
|
233
|
-
return ['fog', 'fog-color', 'fog-density', 'fog-start', 'fog-end', 'gravity'];
|
|
264
|
+
return ['exposure', 'fog', 'fog-color', 'fog-density', 'fog-start', 'fog-end', 'gravity'];
|
|
234
265
|
}
|
|
235
266
|
|
|
236
267
|
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
|
|
237
268
|
switch (name) {
|
|
269
|
+
case 'exposure':
|
|
270
|
+
this.exposure = parseNumber(newValue, 1, name);
|
|
271
|
+
break;
|
|
238
272
|
case 'fog':
|
|
239
273
|
this.fog = parseEnum(newValue, ['none', 'linear', 'exp', 'exp2'], 'none', name);
|
|
240
274
|
break;
|
package/src/sky.ts
CHANGED
|
@@ -10,6 +10,10 @@ import { parseBool, parseEnum, parseNumber, parseVec3 } from './parse';
|
|
|
10
10
|
* The SkyElement interface provides properties and methods for manipulating
|
|
11
11
|
* `<pc-sky>` elements. The SkyElement interface also inherits the properties and
|
|
12
12
|
* methods of the {@link HTMLElement} interface.
|
|
13
|
+
*
|
|
14
|
+
* @elementSummary The `<pc-sky>` element renders a skybox from a texture asset, projected as an
|
|
15
|
+
* infinite background, a box or a dome, and optionally lights the scene from it. Must be a direct
|
|
16
|
+
* child of `<pc-scene>`.
|
|
13
17
|
*/
|
|
14
18
|
class SkyElement extends AsyncElement {
|
|
15
19
|
private _asset = '';
|
package/src/wasm.ts
CHANGED
|
@@ -17,6 +17,10 @@ import { AsyncElement } from './async-element';
|
|
|
17
17
|
* A `<pc-wasm>` without a `name` warns and never becomes ready; a containing `<pc-app>` still
|
|
18
18
|
* boots.
|
|
19
19
|
*
|
|
20
|
+
* @elementSummary The `<pc-wasm>` element loads a WebAssembly module the engine needs before the
|
|
21
|
+
* application starts — `Ammo` for physics, `Basis` or `DracoDecoderModule` for compressed assets.
|
|
22
|
+
* Must be a direct child of `<pc-app>`.
|
|
23
|
+
*
|
|
20
24
|
* @attribute {string} name - The name of the WebAssembly module to configure, e.g. `Basis` or
|
|
21
25
|
* `Ammo`.
|
|
22
26
|
* @attribute {string} glue - The URL of the module's glue script.
|