@playcanvas/web-components 0.5.0 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcanvas/web-components",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "author": "PlayCanvas <support@playcanvas.com>",
5
5
  "homepage": "https://playcanvas.com",
6
6
  "description": "Web Components for the PlayCanvas Engine",
@@ -55,18 +55,18 @@
55
55
  "@rollup/plugin-terser": "1.0.0",
56
56
  "@rollup/plugin-typescript": "12.3.0",
57
57
  "@tweenjs/tween.js": "25.0.0",
58
- "@typescript-eslint/eslint-plugin": "8.60.0",
59
- "@typescript-eslint/parser": "8.60.0",
60
- "concurrently": "10.0.0",
58
+ "@typescript-eslint/eslint-plugin": "8.61.0",
59
+ "@typescript-eslint/parser": "8.61.0",
60
+ "concurrently": "10.0.3",
61
61
  "earcut": "3.0.2",
62
62
  "eslint": "9.39.4",
63
- "eslint-import-resolver-typescript": "4.4.4",
63
+ "eslint-import-resolver-typescript": "4.4.5",
64
64
  "globals": "17.6.0",
65
- "mediabunny": "1.45.4",
65
+ "mediabunny": "1.46.0",
66
66
  "opentype.js": "2.0.0",
67
- "playcanvas": "2.19.1",
67
+ "playcanvas": "2.19.7",
68
68
  "publint": "0.3.21",
69
- "rollup": "4.60.4",
69
+ "rollup": "4.62.0",
70
70
  "serve": "14.2.6",
71
71
  "tslib": "2.8.1",
72
72
  "typedoc": "0.28.19",
@@ -0,0 +1,161 @@
1
+ import { GSplatComponent } from 'playcanvas';
2
+
3
+ import { ComponentElement } from './component';
4
+ import { AssetElement } from '../asset';
5
+
6
+ /**
7
+ * The GSplatComponentElement interface provides properties and methods for manipulating
8
+ * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-gsplat/ | `<pc-gsplat>`} elements.
9
+ * The GSplatComponentElement interface also inherits the properties and methods of the
10
+ * {@link HTMLElement} interface.
11
+ *
12
+ * @category Components
13
+ */
14
+ class GSplatComponentElement extends ComponentElement {
15
+ private _asset = '';
16
+
17
+ private _castShadows = false;
18
+
19
+ private _lodBaseDistance = 5;
20
+
21
+ private _lodMultiplier = 3;
22
+
23
+ /** @ignore */
24
+ constructor() {
25
+ super('gsplat');
26
+ }
27
+
28
+ getInitialComponentData() {
29
+ return {
30
+ asset: AssetElement.get(this._asset),
31
+ castShadows: this._castShadows,
32
+ lodBaseDistance: this._lodBaseDistance,
33
+ lodMultiplier: this._lodMultiplier
34
+ };
35
+ }
36
+
37
+ /**
38
+ * Gets the underlying PlayCanvas gsplat component.
39
+ * @returns The gsplat component.
40
+ */
41
+ get component(): GSplatComponent | null {
42
+ return super.component as GSplatComponent | null;
43
+ }
44
+
45
+ /**
46
+ * Sets id of the `pc-asset` to use for the splat.
47
+ * @param value - The asset ID.
48
+ */
49
+ set asset(value: string) {
50
+ this._asset = value;
51
+ const asset = AssetElement.get(value);
52
+ if (this.component && asset) {
53
+ this.component.asset = asset;
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Gets the id of the `pc-asset` to use for the splat.
59
+ * @returns The asset ID.
60
+ */
61
+ get asset() {
62
+ return this._asset;
63
+ }
64
+
65
+ /**
66
+ * Sets whether the splat casts shadows.
67
+ * @param value - Whether the splat casts shadows.
68
+ */
69
+ set castShadows(value: boolean) {
70
+ this._castShadows = value;
71
+ if (this.component) {
72
+ this.component.castShadows = value;
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Gets whether the splat casts shadows.
78
+ * @returns Whether the splat casts shadows.
79
+ */
80
+ get castShadows() {
81
+ return this._castShadows;
82
+ }
83
+
84
+ /**
85
+ * Sets the base distance for the first LOD transition (LOD 0 to LOD 1). Splats closer than
86
+ * this distance use the highest quality LOD. Each subsequent LOD level transitions at a
87
+ * progressively larger distance, controlled by {@link lodMultiplier}. Clamped to a minimum of
88
+ * 0.1. Defaults to 5. Only affects assets that contain LOD levels (e.g. `.lod-meta.json`).
89
+ * @param value - The LOD base distance.
90
+ */
91
+ set lodBaseDistance(value: number) {
92
+ this._lodBaseDistance = value;
93
+ if (this.component) {
94
+ this.component.lodBaseDistance = value;
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Gets the base distance for the first LOD transition.
100
+ * @returns The LOD base distance.
101
+ */
102
+ get lodBaseDistance() {
103
+ return this._lodBaseDistance;
104
+ }
105
+
106
+ /**
107
+ * Sets the multiplier between successive LOD distance thresholds. Each LOD level transitions
108
+ * at this factor times the previous level's distance, creating a geometric progression. Lower
109
+ * values keep higher quality at distance; higher values switch to coarser LODs sooner. Clamped
110
+ * to a minimum of 1.2. Defaults to 3. Only affects assets that contain LOD levels (e.g.
111
+ * `.lod-meta.json`).
112
+ * @param value - The LOD multiplier.
113
+ */
114
+ set lodMultiplier(value: number) {
115
+ this._lodMultiplier = value;
116
+ if (this.component) {
117
+ this.component.lodMultiplier = value;
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Gets the multiplier between successive LOD distance thresholds.
123
+ * @returns The LOD multiplier.
124
+ */
125
+ get lodMultiplier() {
126
+ return this._lodMultiplier;
127
+ }
128
+
129
+ static get observedAttributes() {
130
+ return [
131
+ ...super.observedAttributes,
132
+ 'asset',
133
+ 'cast-shadows',
134
+ 'lod-base-distance',
135
+ 'lod-multiplier'
136
+ ];
137
+ }
138
+
139
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
140
+ super.attributeChangedCallback(name, _oldValue, newValue);
141
+
142
+ switch (name) {
143
+ case 'asset':
144
+ this.asset = newValue;
145
+ break;
146
+ case 'cast-shadows':
147
+ this.castShadows = this.hasAttribute('cast-shadows');
148
+ break;
149
+ case 'lod-base-distance':
150
+ this.lodBaseDistance = Number(newValue);
151
+ break;
152
+ case 'lod-multiplier':
153
+ this.lodMultiplier = Number(newValue);
154
+ break;
155
+ }
156
+ }
157
+ }
158
+
159
+ customElements.define('pc-gsplat', GSplatComponentElement);
160
+
161
+ export { GSplatComponentElement };
package/src/index.ts CHANGED
@@ -29,7 +29,7 @@ import { ScriptComponentElement } from './components/script-component';
29
29
  import { ScriptElement } from './components/script';
30
30
  import { SoundComponentElement } from './components/sound-component';
31
31
  import { SoundSlotElement } from './components/sound-slot';
32
- import { SplatComponentElement } from './components/splat-component';
32
+ import { GSplatComponentElement } from './components/gsplat-component';
33
33
  import { MaterialElement } from './material';
34
34
  import { ModelElement } from './model';
35
35
  import { SceneElement } from './scene';
@@ -55,7 +55,7 @@ export {
55
55
  ScriptElement,
56
56
  SoundComponentElement,
57
57
  SoundSlotElement,
58
- SplatComponentElement,
58
+ GSplatComponentElement,
59
59
  MaterialElement,
60
60
  ModelElement,
61
61
  SceneElement,
@@ -1,48 +0,0 @@
1
- import { GSplatComponent } from 'playcanvas';
2
- import { ComponentElement } from './component';
3
- /**
4
- * The SplatComponentElement interface provides properties and methods for manipulating
5
- * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-splat/ | `<pc-splat>`} elements.
6
- * The SplatComponentElement interface also inherits the properties and methods of the
7
- * {@link HTMLElement} interface.
8
- *
9
- * @category Components
10
- */
11
- declare class SplatComponentElement extends ComponentElement {
12
- private _asset;
13
- private _castShadows;
14
- /** @ignore */
15
- constructor();
16
- getInitialComponentData(): {
17
- asset: import("playcanvas").Asset | null | undefined;
18
- castShadows: boolean;
19
- };
20
- /**
21
- * Gets the underlying PlayCanvas splat component.
22
- * @returns The splat component.
23
- */
24
- get component(): GSplatComponent | null;
25
- /**
26
- * Sets id of the `pc-asset` to use for the splat.
27
- * @param value - The asset ID.
28
- */
29
- set asset(value: string);
30
- /**
31
- * Gets the id of the `pc-asset` to use for the splat.
32
- * @returns The asset ID.
33
- */
34
- get asset(): string;
35
- /**
36
- * Sets whether the splat casts shadows.
37
- * @param value - Whether the splat casts shadows.
38
- */
39
- set castShadows(value: boolean);
40
- /**
41
- * Gets whether the splat casts shadows.
42
- * @returns Whether the splat casts shadows.
43
- */
44
- get castShadows(): boolean;
45
- static get observedAttributes(): string[];
46
- attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
47
- }
48
- export { SplatComponentElement };
@@ -1,102 +0,0 @@
1
- import { GSplatComponent } from 'playcanvas';
2
-
3
- import { ComponentElement } from './component';
4
- import { AssetElement } from '../asset';
5
-
6
- /**
7
- * The SplatComponentElement interface provides properties and methods for manipulating
8
- * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-splat/ | `<pc-splat>`} elements.
9
- * The SplatComponentElement interface also inherits the properties and methods of the
10
- * {@link HTMLElement} interface.
11
- *
12
- * @category Components
13
- */
14
- class SplatComponentElement extends ComponentElement {
15
- private _asset = '';
16
-
17
- private _castShadows = false;
18
-
19
- /** @ignore */
20
- constructor() {
21
- super('gsplat');
22
- }
23
-
24
- getInitialComponentData() {
25
- return {
26
- asset: AssetElement.get(this._asset),
27
- castShadows: this._castShadows
28
- };
29
- }
30
-
31
- /**
32
- * Gets the underlying PlayCanvas splat component.
33
- * @returns The splat component.
34
- */
35
- get component(): GSplatComponent | null {
36
- return super.component as GSplatComponent | null;
37
- }
38
-
39
- /**
40
- * Sets id of the `pc-asset` to use for the splat.
41
- * @param value - The asset ID.
42
- */
43
- set asset(value: string) {
44
- this._asset = value;
45
- const asset = AssetElement.get(value);
46
- if (this.component && asset) {
47
- this.component.asset = asset;
48
- }
49
- }
50
-
51
- /**
52
- * Gets the id of the `pc-asset` to use for the splat.
53
- * @returns The asset ID.
54
- */
55
- get asset() {
56
- return this._asset;
57
- }
58
-
59
- /**
60
- * Sets whether the splat casts shadows.
61
- * @param value - Whether the splat casts shadows.
62
- */
63
- set castShadows(value: boolean) {
64
- this._castShadows = value;
65
- if (this.component) {
66
- this.component.castShadows = value;
67
- }
68
- }
69
-
70
- /**
71
- * Gets whether the splat casts shadows.
72
- * @returns Whether the splat casts shadows.
73
- */
74
- get castShadows() {
75
- return this._castShadows;
76
- }
77
-
78
- static get observedAttributes() {
79
- return [
80
- ...super.observedAttributes,
81
- 'asset',
82
- 'cast-shadows'
83
- ];
84
- }
85
-
86
- attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
87
- super.attributeChangedCallback(name, _oldValue, newValue);
88
-
89
- switch (name) {
90
- case 'asset':
91
- this.asset = newValue;
92
- break;
93
- case 'cast-shadows':
94
- this.castShadows = this.hasAttribute('cast-shadows');
95
- break;
96
- }
97
- }
98
- }
99
-
100
- customElements.define('pc-splat', SplatComponentElement);
101
-
102
- export { SplatComponentElement };