diff --git a/packages/lib/src/components/GSplat.tsx b/packages/lib/src/components/GSplat.tsx index 7ee469d..1eaa637 100644 --- a/packages/lib/src/components/GSplat.tsx +++ b/packages/lib/src/components/GSplat.tsx @@ -36,5 +36,29 @@ componentDefinition.schema = { validate: (val: unknown) => val instanceof Asset, errorMsg: (val: unknown) => `Invalid value for prop "asset": "${JSON.stringify(val)}". Expected an Asset.`, default: null + }, + // `unified` is a special property that can not be modified while the component is enabled + unified: { + validate: (val: unknown) => typeof val === 'boolean', + errorMsg: (val: unknown) => `Invalid value for prop "unified": "${JSON.stringify(val)}". Expected a boolean.`, + default: false, + apply: (instance: GSplatComponent, props: Record, key: string) => { + const value = props[key] as boolean; + + if (instance.unified === value) { + return; + } + + // If not enabled, just set directly + if (!instance.enabled) { + instance.unified = value; + return; + } + + // Temporarily disable component, set value, re-enable + instance.enabled = false; + instance.unified = value; + instance.enabled = true; + } } -} \ No newline at end of file +}