Skip to content

Commit b17fe84

Browse files
authored
Expose SplatComponent#castShadows (#155)
1 parent 7b6e93d commit b17fe84

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

src/components/splat-component.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import { AssetElement } from '../asset';
1212
* @category Components
1313
*/
1414
class SplatComponentElement extends ComponentElement {
15-
private _asset: string = '';
15+
private _asset = '';
16+
17+
private _castShadows = false;
1618

1719
/** @ignore */
1820
constructor() {
@@ -21,7 +23,8 @@ class SplatComponentElement extends ComponentElement {
2123

2224
getInitialComponentData() {
2325
return {
24-
asset: AssetElement.get(this._asset)
26+
asset: AssetElement.get(this._asset),
27+
castShadows: this._castShadows
2528
};
2629
}
2730

@@ -53,8 +56,31 @@ class SplatComponentElement extends ComponentElement {
5356
return this._asset;
5457
}
5558

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+
5678
static get observedAttributes() {
57-
return [...super.observedAttributes, 'asset'];
79+
return [
80+
...super.observedAttributes,
81+
'asset',
82+
'cast-shadows'
83+
];
5884
}
5985

6086
attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
@@ -64,6 +90,9 @@ class SplatComponentElement extends ComponentElement {
6490
case 'asset':
6591
this.asset = newValue;
6692
break;
93+
case 'cast-shadows':
94+
this.castShadows = this.hasAttribute('cast-shadows');
95+
break;
6796
}
6897
}
6998
}

0 commit comments

Comments
 (0)