@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.
@@ -0,0 +1,79 @@
1
+ import { GSplatComponent } from 'playcanvas';
2
+ import { ComponentElement } from './component';
3
+ /**
4
+ * The GSplatComponentElement interface provides properties and methods for manipulating
5
+ * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-gsplat/ | `<pc-gsplat>`} elements.
6
+ * The GSplatComponentElement interface also inherits the properties and methods of the
7
+ * {@link HTMLElement} interface.
8
+ *
9
+ * @category Components
10
+ */
11
+ declare class GSplatComponentElement extends ComponentElement {
12
+ private _asset;
13
+ private _castShadows;
14
+ private _lodBaseDistance;
15
+ private _lodMultiplier;
16
+ /** @ignore */
17
+ constructor();
18
+ getInitialComponentData(): {
19
+ asset: import("playcanvas").Asset | null | undefined;
20
+ castShadows: boolean;
21
+ lodBaseDistance: number;
22
+ lodMultiplier: number;
23
+ };
24
+ /**
25
+ * Gets the underlying PlayCanvas gsplat component.
26
+ * @returns The gsplat component.
27
+ */
28
+ get component(): GSplatComponent | null;
29
+ /**
30
+ * Sets id of the `pc-asset` to use for the splat.
31
+ * @param value - The asset ID.
32
+ */
33
+ set asset(value: string);
34
+ /**
35
+ * Gets the id of the `pc-asset` to use for the splat.
36
+ * @returns The asset ID.
37
+ */
38
+ get asset(): string;
39
+ /**
40
+ * Sets whether the splat casts shadows.
41
+ * @param value - Whether the splat casts shadows.
42
+ */
43
+ set castShadows(value: boolean);
44
+ /**
45
+ * Gets whether the splat casts shadows.
46
+ * @returns Whether the splat casts shadows.
47
+ */
48
+ get castShadows(): boolean;
49
+ /**
50
+ * Sets the base distance for the first LOD transition (LOD 0 to LOD 1). Splats closer than
51
+ * this distance use the highest quality LOD. Each subsequent LOD level transitions at a
52
+ * progressively larger distance, controlled by {@link lodMultiplier}. Clamped to a minimum of
53
+ * 0.1. Defaults to 5. Only affects assets that contain LOD levels (e.g. `.lod-meta.json`).
54
+ * @param value - The LOD base distance.
55
+ */
56
+ set lodBaseDistance(value: number);
57
+ /**
58
+ * Gets the base distance for the first LOD transition.
59
+ * @returns The LOD base distance.
60
+ */
61
+ get lodBaseDistance(): number;
62
+ /**
63
+ * Sets the multiplier between successive LOD distance thresholds. Each LOD level transitions
64
+ * at this factor times the previous level's distance, creating a geometric progression. Lower
65
+ * values keep higher quality at distance; higher values switch to coarser LODs sooner. Clamped
66
+ * to a minimum of 1.2. Defaults to 3. Only affects assets that contain LOD levels (e.g.
67
+ * `.lod-meta.json`).
68
+ * @param value - The LOD multiplier.
69
+ */
70
+ set lodMultiplier(value: number);
71
+ /**
72
+ * Gets the multiplier between successive LOD distance thresholds.
73
+ * @returns The LOD multiplier.
74
+ */
75
+ get lodMultiplier(): number;
76
+ static get observedAttributes(): string[];
77
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
78
+ }
79
+ export { GSplatComponentElement };
package/dist/index.d.ts CHANGED
@@ -25,9 +25,9 @@ import { ScriptComponentElement } from './components/script-component';
25
25
  import { ScriptElement } from './components/script';
26
26
  import { SoundComponentElement } from './components/sound-component';
27
27
  import { SoundSlotElement } from './components/sound-slot';
28
- import { SplatComponentElement } from './components/splat-component';
28
+ import { GSplatComponentElement } from './components/gsplat-component';
29
29
  import { MaterialElement } from './material';
30
30
  import { ModelElement } from './model';
31
31
  import { SceneElement } from './scene';
32
32
  import { SkyElement } from './sky';
33
- export { AsyncElement, ModuleElement, AppElement, EntityElement, AssetElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, ParticleSystemComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, SplatComponentElement, MaterialElement, ModelElement, SceneElement, SkyElement };
33
+ export { AsyncElement, ModuleElement, AppElement, EntityElement, AssetElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, ParticleSystemComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, GSplatComponentElement, MaterialElement, ModelElement, SceneElement, SkyElement };
package/dist/pwc.cjs CHANGED
@@ -4365,29 +4365,33 @@ class SoundSlotElement extends AsyncElement {
4365
4365
  customElements.define('pc-sound', SoundSlotElement);
4366
4366
 
4367
4367
  /**
4368
- * The SplatComponentElement interface provides properties and methods for manipulating
4369
- * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-splat/ | `<pc-splat>`} elements.
4370
- * The SplatComponentElement interface also inherits the properties and methods of the
4368
+ * The GSplatComponentElement interface provides properties and methods for manipulating
4369
+ * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-gsplat/ | `<pc-gsplat>`} elements.
4370
+ * The GSplatComponentElement interface also inherits the properties and methods of the
4371
4371
  * {@link HTMLElement} interface.
4372
4372
  *
4373
4373
  * @category Components
4374
4374
  */
4375
- class SplatComponentElement extends ComponentElement {
4375
+ class GSplatComponentElement extends ComponentElement {
4376
4376
  /** @ignore */
4377
4377
  constructor() {
4378
4378
  super('gsplat');
4379
4379
  this._asset = '';
4380
4380
  this._castShadows = false;
4381
+ this._lodBaseDistance = 5;
4382
+ this._lodMultiplier = 3;
4381
4383
  }
4382
4384
  getInitialComponentData() {
4383
4385
  return {
4384
4386
  asset: AssetElement.get(this._asset),
4385
- castShadows: this._castShadows
4387
+ castShadows: this._castShadows,
4388
+ lodBaseDistance: this._lodBaseDistance,
4389
+ lodMultiplier: this._lodMultiplier
4386
4390
  };
4387
4391
  }
4388
4392
  /**
4389
- * Gets the underlying PlayCanvas splat component.
4390
- * @returns The splat component.
4393
+ * Gets the underlying PlayCanvas gsplat component.
4394
+ * @returns The gsplat component.
4391
4395
  */
4392
4396
  get component() {
4393
4397
  return super.component;
@@ -4427,11 +4431,54 @@ class SplatComponentElement extends ComponentElement {
4427
4431
  get castShadows() {
4428
4432
  return this._castShadows;
4429
4433
  }
4434
+ /**
4435
+ * Sets the base distance for the first LOD transition (LOD 0 to LOD 1). Splats closer than
4436
+ * this distance use the highest quality LOD. Each subsequent LOD level transitions at a
4437
+ * progressively larger distance, controlled by {@link lodMultiplier}. Clamped to a minimum of
4438
+ * 0.1. Defaults to 5. Only affects assets that contain LOD levels (e.g. `.lod-meta.json`).
4439
+ * @param value - The LOD base distance.
4440
+ */
4441
+ set lodBaseDistance(value) {
4442
+ this._lodBaseDistance = value;
4443
+ if (this.component) {
4444
+ this.component.lodBaseDistance = value;
4445
+ }
4446
+ }
4447
+ /**
4448
+ * Gets the base distance for the first LOD transition.
4449
+ * @returns The LOD base distance.
4450
+ */
4451
+ get lodBaseDistance() {
4452
+ return this._lodBaseDistance;
4453
+ }
4454
+ /**
4455
+ * Sets the multiplier between successive LOD distance thresholds. Each LOD level transitions
4456
+ * at this factor times the previous level's distance, creating a geometric progression. Lower
4457
+ * values keep higher quality at distance; higher values switch to coarser LODs sooner. Clamped
4458
+ * to a minimum of 1.2. Defaults to 3. Only affects assets that contain LOD levels (e.g.
4459
+ * `.lod-meta.json`).
4460
+ * @param value - The LOD multiplier.
4461
+ */
4462
+ set lodMultiplier(value) {
4463
+ this._lodMultiplier = value;
4464
+ if (this.component) {
4465
+ this.component.lodMultiplier = value;
4466
+ }
4467
+ }
4468
+ /**
4469
+ * Gets the multiplier between successive LOD distance thresholds.
4470
+ * @returns The LOD multiplier.
4471
+ */
4472
+ get lodMultiplier() {
4473
+ return this._lodMultiplier;
4474
+ }
4430
4475
  static get observedAttributes() {
4431
4476
  return [
4432
4477
  ...super.observedAttributes,
4433
4478
  'asset',
4434
- 'cast-shadows'
4479
+ 'cast-shadows',
4480
+ 'lod-base-distance',
4481
+ 'lod-multiplier'
4435
4482
  ];
4436
4483
  }
4437
4484
  attributeChangedCallback(name, _oldValue, newValue) {
@@ -4443,10 +4490,16 @@ class SplatComponentElement extends ComponentElement {
4443
4490
  case 'cast-shadows':
4444
4491
  this.castShadows = this.hasAttribute('cast-shadows');
4445
4492
  break;
4493
+ case 'lod-base-distance':
4494
+ this.lodBaseDistance = Number(newValue);
4495
+ break;
4496
+ case 'lod-multiplier':
4497
+ this.lodMultiplier = Number(newValue);
4498
+ break;
4446
4499
  }
4447
4500
  }
4448
4501
  }
4449
- customElements.define('pc-splat', SplatComponentElement);
4502
+ customElements.define('pc-gsplat', GSplatComponentElement);
4450
4503
 
4451
4504
  /**
4452
4505
  * The ModelElement interface provides properties and methods for manipulating
@@ -4992,6 +5045,7 @@ exports.CollisionComponentElement = CollisionComponentElement;
4992
5045
  exports.ComponentElement = ComponentElement;
4993
5046
  exports.ElementComponentElement = ElementComponentElement;
4994
5047
  exports.EntityElement = EntityElement;
5048
+ exports.GSplatComponentElement = GSplatComponentElement;
4995
5049
  exports.LightComponentElement = LightComponentElement;
4996
5050
  exports.ListenerComponentElement = ListenerComponentElement;
4997
5051
  exports.MaterialElement = MaterialElement;
@@ -5007,5 +5061,4 @@ exports.ScriptElement = ScriptElement;
5007
5061
  exports.SkyElement = SkyElement;
5008
5062
  exports.SoundComponentElement = SoundComponentElement;
5009
5063
  exports.SoundSlotElement = SoundSlotElement;
5010
- exports.SplatComponentElement = SplatComponentElement;
5011
5064
  //# sourceMappingURL=pwc.cjs.map