Hello! I think I’ve found a bug in PC react relating to the component schema generator. This issue arose when trying to utilize custom asset loading & splat-transform. From what I’ve read they are supported uses for playcanvas react and the issue seems to be unintentional. I go over what I believe the issue is in depth on this issue Issue #315
TLDR My Implementation:
const fileSystem = new UrlReadFileSystem(typeof window !== 'undefined' ? window.location.origin : '');
async function load(filename: string, app: pc.Application, fileSystem: UrlReadFileSystem): Promise<Asset> {
const gsplatData = await loadGSplatData(filename, fileSystem);
const resource = new pc.GSplatResource(app.graphicsDevice, gsplatData);
const asset = new Asset(filename, 'gsplat', { url: `/assets/temp-splats/${filename}` });
asset.resource = resource;
asset.loaded = true;
app.assets.add(asset);
return asset;
}
const Scene = () => {
const [cur_asset, setCurAsset] = useState<Asset | null>(null);
const app = CreateApp();
useEffect(() => {
if (!app) return;
load('/assets/temp-splats/scene.ply', app, fileSystem)
.then(setCurAsset)
.catch(console.error);
}, [app]);
return (
<Entity name="splat">
{cur_asset && <GSplat asset={cur_asset} />}
</Entity>
);
};
When trying to pass a custom-constructed Asset to , I get:
Cannot set property id of #<GSplatComponent> which has only a getter
at createComponentDefinition (validation.ts:382)
Currently my solution is to ditch the GSplat Component entirely and manually structure using the playcanvas engine api and that has been working wonderfully but is a good chunk more code. I’m unsure if its intended but the schema generator includes getter only props in its apply logic rather than skipping them or setting them to read-only. I have submitted a PR that fixes this but if its actually intended to use getter only props because of some kind of bypass or logic involving the dual uses of the Asset property being both a setter and a getter then it may be more than just my simple fix required.
I thought I’d post on the forums here just in case I missed something and to bring some more attention to the issue as it seems that the playcanvas react repo is updated much more infrequently than other playcanvas repositories. I’d love to hear any kind of feedback and its entirely possible I’ve made a mistake in my code but I’ve been able to recreate it in a few different methods and rule from what I can tell every other culprit out.
Thanks for reading!
My GitHub username is No-LAN-B