Skip to content

Commit e564a0e

Browse files
authored
fix: Apply GSplat unified property while it is disabled (#299)
1 parent 5e577ca commit e564a0e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@playcanvas/react": patch
3+
---
4+
5+
Fix GSplat `unified` property not being applied correctly. This fix allows users to load Gaussian Splats with LODs.
6+

packages/lib/src/components/GSplat.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,29 @@ componentDefinition.schema = {
3636
validate: (val: unknown) => val instanceof Asset,
3737
errorMsg: (val: unknown) => `Invalid value for prop "asset": "${JSON.stringify(val)}". Expected an Asset.`,
3838
default: null
39+
},
40+
// `unified` is a special property that can not be modified while the component is enabled
41+
unified: {
42+
validate: (val: unknown) => typeof val === 'boolean',
43+
errorMsg: (val: unknown) => `Invalid value for prop "unified": "${JSON.stringify(val)}". Expected a boolean.`,
44+
default: false,
45+
apply: (instance: GSplatComponent, props: Record<string, unknown>, key: string) => {
46+
const value = props[key] as boolean;
47+
48+
if (instance.unified === value) {
49+
return;
50+
}
51+
52+
// If not enabled, just set directly
53+
if (!instance.enabled) {
54+
instance.unified = value;
55+
return;
56+
}
57+
58+
// Temporarily disable component, set value, re-enable
59+
instance.enabled = false;
60+
instance.unified = value;
61+
instance.enabled = true;
62+
}
3963
}
40-
}
64+
}

0 commit comments

Comments
 (0)