Skip to content

Commit 3fc29d7

Browse files
Expose unified attribute on pc-splat (#216)
* Expose unified attribute on pc-splat * Update src/components/splat-component.ts Co-authored-by: Copilot <[email protected]> * Update src/components/splat-component.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 182db3a commit 3fc29d7

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/components/splat-component.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class SplatComponentElement extends ComponentElement {
1616

1717
private _castShadows = false;
1818

19+
private _unified = false;
20+
1921
/** @ignore */
2022
constructor() {
2123
super('gsplat');
@@ -24,7 +26,8 @@ class SplatComponentElement extends ComponentElement {
2426
getInitialComponentData() {
2527
return {
2628
asset: AssetElement.get(this._asset),
27-
castShadows: this._castShadows
29+
castShadows: this._castShadows,
30+
unified: this._unified
2831
};
2932
}
3033

@@ -75,11 +78,36 @@ class SplatComponentElement extends ComponentElement {
7578
return this._castShadows;
7679
}
7780

81+
/**
82+
* Sets whether the splat supports global sorting and LOD streaming. This property can only be
83+
* changed when the component is disabled.
84+
* @param value - Whether the splat supports global sorting and LOD streaming.
85+
*/
86+
set unified(value: boolean) {
87+
if (this.component && this.component.enabled) {
88+
console.warn('The "unified" property can only be changed when the component is disabled.');
89+
return;
90+
}
91+
this._unified = value;
92+
if (this.component) {
93+
this.component.unified = value;
94+
}
95+
}
96+
97+
/**
98+
* Gets whether the splat supports global sorting and LOD streaming.
99+
* @returns Whether the splat supports global sorting and LOD streaming.
100+
*/
101+
get unified() {
102+
return this._unified;
103+
}
104+
78105
static get observedAttributes() {
79106
return [
80107
...super.observedAttributes,
81108
'asset',
82-
'cast-shadows'
109+
'cast-shadows',
110+
'unified'
83111
];
84112
}
85113

@@ -93,6 +121,9 @@ class SplatComponentElement extends ComponentElement {
93121
case 'cast-shadows':
94122
this.castShadows = this.hasAttribute('cast-shadows');
95123
break;
124+
case 'unified':
125+
this.unified = this.hasAttribute('unified');
126+
break;
96127
}
97128
}
98129
}

0 commit comments

Comments
 (0)