@playcanvas/web-components 0.10.0 → 0.11.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/entity.d.ts CHANGED
@@ -63,12 +63,26 @@ declare class EntityElement extends AsyncElement {
63
63
  private _built;
64
64
  private _entity;
65
65
  /**
66
- * The PlayCanvas entity instance. Available once the element is ready await
67
- * {@link whenReady} or the element's `ready()` promise before accessing it.
68
- * @returns The entity instance.
66
+ * The application element this entity is registered with, cached at creation time so the
67
+ * entity can be unregistered even once this element has left the DOM.
69
68
  */
70
- get entity(): Entity;
69
+ private _appElement;
70
+ /**
71
+ * The PlayCanvas entity instance. `null` until the element is ready, and again once it has
72
+ * been removed from the document — await {@link whenReady} or the element's `ready()`
73
+ * promise before accessing it.
74
+ * @returns The entity instance, or `null`.
75
+ */
76
+ get entity(): Entity | null;
71
77
  createEntity(app: AppBase): void;
78
+ /**
79
+ * Handles the destruction of the backing entity. Resets the element so a later re-insertion
80
+ * starts clean: `_built` must be cleared alongside `_entity`, or buildHierarchy would bail
81
+ * and a re-created entity would never be parented.
82
+ *
83
+ * @param entity - The entity that was destroyed.
84
+ */
85
+ private _onEntityDestroy;
72
86
  buildHierarchy(app: AppBase): void;
73
87
  connectedCallback(): void;
74
88
  disconnectedCallback(): void;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The slim progress bar `<pc-app>` shows while it boots and preloads. An implementation detail of
3
+ * AppElement rather than a custom element, so its shape can change without a breaking change.
4
+ *
5
+ * All styling is inline, so the library injects no stylesheet. The colors and height resolve CSS
6
+ * custom properties — `--pc-loading-bar-color`, `--pc-loading-bar-background` and
7
+ * `--pc-loading-bar-height` — so a page can theme the bar from `pc-app` or `:root`.
8
+ */
9
+ declare class LoadingBar {
10
+ private _track;
11
+ private _fill;
12
+ private _sweep;
13
+ private _removal;
14
+ /**
15
+ * Creates the bar and appends it to `parent`, starting in the indeterminate state.
16
+ * @param parent - The element to append the bar to.
17
+ */
18
+ constructor(parent: HTMLElement);
19
+ /**
20
+ * Reflects preload progress, switching the bar from indeterminate to determinate on the first
21
+ * call.
22
+ * @param loaded - The number of assets that have finished loading.
23
+ * @param total - The number of assets being preloaded.
24
+ */
25
+ progress(loaded: number, total: number): void;
26
+ /**
27
+ * Fills the bar, fades it out and removes it. Idempotent.
28
+ */
29
+ complete(): void;
30
+ /**
31
+ * Removes the bar immediately, cancelling any pending fade. Idempotent.
32
+ */
33
+ destroy(): void;
34
+ }
35
+ export { LoadingBar };
@@ -22,8 +22,14 @@ type TextureSlot = 'aoMap' | 'diffuseMap' | 'emissiveMap' | 'glossMap' | 'height
22
22
  * created on insertion.
23
23
  *
24
24
  * The element is metal/rough by default: unlike a bare `StandardMaterial` it enables the metalness
25
- * workflow, which is what the `metalness-*` attributes assume and what glTF means by PBR. The
26
- * `roughness` and `roughness-map` attributes are aliases for `gloss` and `gloss-map` that
25
+ * workflow, which is what the `metalness-*` attributes assume and what glTF means by PBR. It also
26
+ * defaults `metalness` to 0 rather than the engine's 1, because those two defaults have to be
27
+ * chosen together - the engine's 1 is unreachable under its own `useMetalness` of false, and with
28
+ * the workflow on it would make every material fully metallic, so `<pc-material diffuse="crimson">`
29
+ * would render as dark tinted reflections of an environment that may not exist rather than as a
30
+ * crimson surface. `metalness="1"` remains one attribute away.
31
+ *
32
+ * The `roughness` and `roughness-map` attributes are aliases for `gloss` and `gloss-map` that
27
33
  * additionally invert the gloss channel; do not mix the two families on one element.
28
34
  *
29
35
  * The two aliases are documented here rather than on an accessor, because they resolve to the
package/dist/parse.d.ts CHANGED
@@ -58,12 +58,14 @@ export declare const parseColor: <T extends Color | null>(value: string | null,
58
58
  * the value is invalid — the latter also logs a warning listing the valid names.
59
59
  *
60
60
  * @param value - The attribute value to parse (`null` when the attribute is absent).
61
- * @param valid - The valid names: an array, or a map whose keys are the valid names.
61
+ * @param valid - The valid names: an array, or a map whose keys are the valid names. Only the keys
62
+ * are read, so the map's value type is unconstrained - engine enums are mostly numeric constants,
63
+ * but some (e.g. `SCALEMODE_BLEND`) are strings.
62
64
  * @param defaultValue - The value to use when the attribute is absent or invalid.
63
65
  * @param attribute - The attribute name, used in the warning message.
64
66
  * @returns The resolved enum name.
65
67
  */
66
- export declare const parseEnum: <T extends string>(value: string | null, valid: readonly T[] | ReadonlyMap<T, number>, defaultValue: T, attribute: string) => T;
68
+ export declare const parseEnum: <T extends string>(value: string | null, valid: readonly T[] | ReadonlyMap<T, unknown>, defaultValue: T, attribute: string) => T;
67
69
  /**
68
70
  * Parses a number attribute value. Returns the parsed number when the value is a finite number.
69
71
  * Returns `defaultValue` when the attribute is absent (`null`), or when the value is not a