@playcanvas/web-components 0.17.0 → 0.18.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 +4 -0
- package/dist/app.d.ts +4 -0
- package/dist/asset.d.cts +13 -3
- package/dist/asset.d.ts +13 -3
- package/dist/components/anim-clip.d.cts +4 -0
- package/dist/components/anim-clip.d.ts +4 -0
- 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 +268 -7
- package/dist/entity-base.d.cts +1 -1
- package/dist/entity-base.d.ts +1 -1
- package/dist/entity-owner.d.cts +2 -2
- package/dist/entity-owner.d.ts +2 -2
- package/dist/entity.d.cts +6 -1
- package/dist/entity.d.ts +6 -1
- 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 +5 -0
- package/dist/model.d.ts +5 -0
- package/dist/node.d.cts +6 -1
- package/dist/node.d.ts +6 -1
- package/dist/pwc.cjs +284 -28
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +284 -28
- 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 +285 -29
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.cts +3 -0
- package/dist/scene.d.ts +3 -0
- package/dist/sky.d.cts +4 -0
- package/dist/sky.d.ts +4 -0
- package/dist/vscode.html-custom-data.json +237 -62
- package/dist/wasm.d.cts +4 -0
- package/dist/wasm.d.ts +4 -0
- package/dist/web-types.json +115 -69
- package/package.json +1 -1
- package/src/app.ts +4 -0
- package/src/asset.ts +13 -4
- package/src/components/anim-clip.ts +4 -0
- 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 +2 -2
- package/src/entity-owner.ts +2 -2
- package/src/entity.ts +6 -1
- package/src/index.ts +12 -1
- package/src/material.ts +19 -8
- package/src/model.ts +5 -0
- package/src/node.ts +6 -1
- package/src/scene.ts +3 -0
- package/src/sky.ts +4 -0
- package/src/wasm.ts +4 -0
|
@@ -18,6 +18,10 @@ const orientations = new Map<'horizontal' | 'vertical', number>([
|
|
|
18
18
|
*
|
|
19
19
|
* Engine component: {@link ScrollbarComponent} (`scrollbar`).
|
|
20
20
|
*
|
|
21
|
+
* @elementSummary The `<pc-scrollbar>` element gives its entity a draggable handle reporting a
|
|
22
|
+
* position from 0 to 1, which a `<pc-scroll-view>` references to scroll its content. Must be a
|
|
23
|
+
* child of a `<pc-entity>`, `<pc-model>` or `<pc-node>`.
|
|
24
|
+
*
|
|
21
25
|
* @category Components
|
|
22
26
|
*/
|
|
23
27
|
class ScrollbarComponentElement extends ComponentElement {
|
|
@@ -12,6 +12,10 @@ import { ComponentElement } from './component';
|
|
|
12
12
|
*
|
|
13
13
|
* Engine component: {@link SoundComponent} (`sound`).
|
|
14
14
|
*
|
|
15
|
+
* @elementSummary The `<pc-sound>` element holds the `<pc-sound-slot>` children that play sounds at
|
|
16
|
+
* its entity, along with the positional audio settings they share. Must be a child of a
|
|
17
|
+
* `<pc-entity>`, `<pc-model>` or `<pc-node>`.
|
|
18
|
+
*
|
|
15
19
|
* @category Components
|
|
16
20
|
*/
|
|
17
21
|
class SoundComponentElement extends ComponentElement {
|
|
@@ -10,6 +10,9 @@ import { SoundComponentElement } from './sound-component';
|
|
|
10
10
|
* The SoundSlotElement interface provides properties and methods for manipulating
|
|
11
11
|
* `<pc-sound-slot>` elements. The SoundSlotElement interface also inherits the properties and
|
|
12
12
|
* methods of the {@link AsyncElement} interface.
|
|
13
|
+
*
|
|
14
|
+
* @elementSummary The `<pc-sound-slot>` element declares one named sound on its parent `<pc-sound>`
|
|
15
|
+
* — its asset, volume, pitch, looping and autoplay. Must be a direct child of `<pc-sound>`.
|
|
13
16
|
*/
|
|
14
17
|
class SoundSlotElement extends AsyncElement {
|
|
15
18
|
private _asset = '';
|
package/src/entity-base.ts
CHANGED
|
@@ -78,7 +78,7 @@ class EntityBaseElement extends AsyncElement {
|
|
|
78
78
|
* Tracks whether an inline `onpointer*` attribute is present. The browser itself compiles and
|
|
79
79
|
* runs these attributes — they are standard `GlobalEventHandlers`, so setting one replaces
|
|
80
80
|
* the previous handler and removing it removes the handler, exactly like `onclick` on any
|
|
81
|
-
* HTML element. But because they bypass {@link addEventListener}, the connect/disconnect
|
|
81
|
+
* HTML element. But because they bypass {@link EventTarget.addEventListener}, the connect/disconnect
|
|
82
82
|
* bookkeeping that lets the application lazily attach its canvas pointer handlers must be
|
|
83
83
|
* kept in sync here.
|
|
84
84
|
*
|
|
@@ -122,7 +122,7 @@ class EntityBaseElement extends AsyncElement {
|
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Whether the element has a listener for an event type, registered either with
|
|
125
|
-
* {@link addEventListener} or with the matching inline `onpointer*` attribute. Read by the
|
|
125
|
+
* {@link EventTarget.addEventListener} or with the matching inline `onpointer*` attribute. Read by the
|
|
126
126
|
* containing `<pc-app>` element to gate pointer event synthesis.
|
|
127
127
|
*
|
|
128
128
|
* @param type - The event type.
|
package/src/entity-owner.ts
CHANGED
|
@@ -69,7 +69,7 @@ class EntityOwnerElement extends EntityBaseElement {
|
|
|
69
69
|
private _tags: string[] = [];
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* Whether the hierarchy has been built for this entity — set once
|
|
72
|
+
* Whether the hierarchy has been built for this entity — set once `_buildHierarchy` has
|
|
73
73
|
* parented it. Read by subclasses that gate work on the entity being in the scene graph.
|
|
74
74
|
*/
|
|
75
75
|
protected _built = false;
|
|
@@ -170,7 +170,7 @@ class EntityOwnerElement extends EntityBaseElement {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
|
-
* Called by
|
|
173
|
+
* Called by `_buildHierarchy` once the backing entity has been parented — exactly once
|
|
174
174
|
* per build cycle. The default announces readiness, which is what a parented `<pc-entity>`
|
|
175
175
|
* means; `<pc-model>` overrides it to start loading content instead, because its readiness
|
|
176
176
|
* tracks the content settling rather than the host entering the scene graph.
|
package/src/entity.ts
CHANGED
|
@@ -12,9 +12,14 @@ import { parseBool, parseTags, parseVec3 } from './parse';
|
|
|
12
12
|
*
|
|
13
13
|
* The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
|
|
14
14
|
* intersects this entity's geometry. They are only generated while the entity has a listener for
|
|
15
|
-
* them, registered either with {@link addEventListener} or with the matching inline `onpointer*`
|
|
15
|
+
* them, registered either with {@link EventTarget.addEventListener} or with the matching inline `onpointer*`
|
|
16
16
|
* attribute.
|
|
17
17
|
*
|
|
18
|
+
* @elementSummary The `<pc-entity>` element creates an entity: a named, transformable node of the
|
|
19
|
+
* scene hierarchy, and the host for component elements such as `<pc-camera>`, `<pc-light>` and
|
|
20
|
+
* `<pc-render>`. Place it in the `<pc-scene>`, or nest it under another `<pc-entity>`, a
|
|
21
|
+
* `<pc-model>` or a `<pc-node>` to parent it there.
|
|
22
|
+
*
|
|
18
23
|
* @attribute {boolean} enabled - The enabled state of the entity.
|
|
19
24
|
* @attribute {string} name - The name of the entity.
|
|
20
25
|
* @attribute {string} position - The position of the entity.
|
package/src/index.ts
CHANGED
|
@@ -134,6 +134,17 @@ export {
|
|
|
134
134
|
whenReady
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
+
export type { AddressMode, MagFilterMode, MinFilterMode } from './asset';
|
|
137
138
|
export type { AsyncElementTagName } from './async-element';
|
|
139
|
+
export type { JointType, MotionMode } from './components/joint-component';
|
|
140
|
+
export type {
|
|
141
|
+
BlendType,
|
|
142
|
+
ColorChannel,
|
|
143
|
+
CullMode,
|
|
144
|
+
FresnelModel,
|
|
145
|
+
OccludeSpecular,
|
|
146
|
+
OpacityDither,
|
|
147
|
+
ScalarChannel
|
|
148
|
+
} from './material';
|
|
138
149
|
export type { HierarchyMaterial, HierarchyNode } from './model';
|
|
139
|
-
export type { MaterialOverrides } from './node';
|
|
150
|
+
export type { MaterialOverrides, NodeBindingState } from './node';
|
package/src/material.ts
CHANGED
|
@@ -29,7 +29,8 @@ import type { AppElement } from './app';
|
|
|
29
29
|
import { useAsset } from './asset';
|
|
30
30
|
import { parseBool, parseColor, parseEnum, parseNumber, parseVec2 } from './parse';
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
/** The blend modes for a material. */
|
|
33
|
+
export type BlendType =
|
|
33
34
|
| 'none'
|
|
34
35
|
| 'normal'
|
|
35
36
|
| 'additive'
|
|
@@ -56,7 +57,8 @@ const blendTypes = new Map<BlendType, number>([
|
|
|
56
57
|
['subtractive', BLEND_SUBTRACTIVE]
|
|
57
58
|
]);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
/** The face culling modes for a material. */
|
|
61
|
+
export type CullMode = 'none' | 'back' | 'front' | 'front-and-back';
|
|
60
62
|
|
|
61
63
|
const cullModes = new Map<CullMode, number>([
|
|
62
64
|
['none', CULLFACE_NONE],
|
|
@@ -65,14 +67,16 @@ const cullModes = new Map<CullMode, number>([
|
|
|
65
67
|
['front-and-back', CULLFACE_FRONTANDBACK]
|
|
66
68
|
]);
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
/** The Fresnel models for a material. */
|
|
71
|
+
export type FresnelModel = 'none' | 'schlick';
|
|
69
72
|
|
|
70
73
|
const fresnelModels = new Map<FresnelModel, number>([
|
|
71
74
|
['none', FRESNEL_NONE],
|
|
72
75
|
['schlick', FRESNEL_SCHLICK]
|
|
73
76
|
]);
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
/** The specular occlusion modes for a material. */
|
|
79
|
+
export type OccludeSpecular = 'none' | 'ao' | 'gloss-dependent';
|
|
76
80
|
|
|
77
81
|
const occludeSpeculars = new Map<OccludeSpecular, number>([
|
|
78
82
|
['none', SPECOCC_NONE],
|
|
@@ -80,17 +84,20 @@ const occludeSpeculars = new Map<OccludeSpecular, number>([
|
|
|
80
84
|
['gloss-dependent', SPECOCC_GLOSSDEPENDENT]
|
|
81
85
|
]);
|
|
82
86
|
|
|
87
|
+
/** The opacity dithering modes for a material. */
|
|
88
|
+
export type OpacityDither = 'none' | 'bayer8' | 'bluenoise' | 'ignnoise';
|
|
89
|
+
|
|
83
90
|
// The DITHER_* constants are strings whose values are exactly these names, so a parsed value is
|
|
84
91
|
// assigned to the material unchanged rather than mapped through a table.
|
|
85
|
-
type OpacityDither = 'none' | 'bayer8' | 'bluenoise' | 'ignnoise';
|
|
86
|
-
|
|
87
92
|
const opacityDithers: OpacityDither[] = ['none', 'bayer8', 'bluenoise', 'ignnoise'];
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
/** The texture channels a color map can sample. */
|
|
95
|
+
export type ColorChannel = 'r' | 'g' | 'b' | 'a' | 'rgb';
|
|
90
96
|
|
|
91
97
|
const colorChannels: ColorChannel[] = ['r', 'g', 'b', 'a', 'rgb'];
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
/** The texture channels a scalar map can sample. */
|
|
100
|
+
export type ScalarChannel = 'r' | 'g' | 'b' | 'a';
|
|
94
101
|
|
|
95
102
|
const scalarChannels: ScalarChannel[] = ['r', 'g', 'b', 'a'];
|
|
96
103
|
|
|
@@ -136,6 +143,10 @@ type TextureSlot =
|
|
|
136
143
|
* The two aliases are documented here rather than on an accessor, because they resolve to the
|
|
137
144
|
* `gloss` properties and would otherwise inherit gloss's description - which reads inverted.
|
|
138
145
|
*
|
|
146
|
+
* @elementSummary The `<pc-material>` element defines a physically based material, which
|
|
147
|
+
* `<pc-render>` elements apply by naming its `id`. It is metal/rough by default, with `metalness`
|
|
148
|
+
* starting at 0. Must be a direct child of `<pc-app>`.
|
|
149
|
+
*
|
|
139
150
|
* @attribute {number} roughness - The roughness of the material, from 0 (shiny) to 1 (rough). An
|
|
140
151
|
* alias for `gloss` that also inverts it, so do not combine it with the `gloss` attributes.
|
|
141
152
|
* @attribute {string} roughness-map - The id of the `pc-asset` to use as the roughness map. An
|
package/src/model.ts
CHANGED
|
@@ -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.
|
package/src/node.ts
CHANGED
|
@@ -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,
|
package/src/scene.ts
CHANGED
|
@@ -9,6 +9,9 @@ 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 and gravity settings. Must be a direct child of `<pc-app>`.
|
|
12
15
|
*/
|
|
13
16
|
class SceneElement extends AsyncElement {
|
|
14
17
|
/**
|
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.
|