Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Support Custom Asset Loading For GSplat Component

Aperta
#315 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
react, typescript
Ambito
frontend, web-dev

Direzione di ricerca

Inizia in validation.ts leggendo getPseudoPublicProps e createComponentDefinition, quindi segui come le proprietà accessibili solo tramite getter, come GSplatComponent.id, entrano nello schema e vengono applicate. Usa l'esempio di Asset personalizzato e l'errore GSplat segnalato per verificare che gli Asset personalizzati validi non attivino più l'assegnazione dell'id di sola lettura, mentre il comportamento esistente dei componenti rimane intatto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

I'm trying to use the component with a custom-loaded asset instead of relying on useSplat(url). My use case requires preprocessing .ply files with a @playcanvas/splat-transform based loader , similar to how the superSplat loader works.

Here is 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)

Root Cause

The root cause is that getPseudoPublicProps (validation.ts) includes getter-only props. When descriptor.get exists and hasSetter is false, it still adds the property with isDefinedWithSetter: false: ->The component schema generation in createComponentDefinition doesn't filter out getter-only properties like GSplatComponent.id when building the prop schema. This path (which would be for custom asset loading) isn't currently supported or tested, so the schema application fails.

In detail the trigger is the assignment step that triggers the error. id is always in the schema, always gets a default, and is always included in safeProps. When applyProps runs, it tries to assign every prop, including id, and that assignment throws because id has no setter.
So:
It’s not the asset loading path that sets id.
It’s the generic “apply all schema props” logic that tries to set id to its default.
The failure would occur even with asset={null} or no props at all, because id is always present in the schema and always applied

I've already prepared a fix PR to support custom asset loaders. I believe the fix should be fairly minor and should allow custom asset loading as long as it abides by the Asset class defined in the documentation.

GSplat asset Property Documentation (PlayCanvas React API):

"asset? number | Asset
'Sets the gsplat asset for this gsplat component. Can also be an asset id. Gets the gsplat asset id for this gsplat component.'

Note: Assuming React support is meant to be flexible, having full loader control is essential IMO and not supporting valid custom Assets is a bit of a bummer. So I'll ensure my fix is up to par and it should only provide extra support without harming functionality.

Conclusion

Just wanted to share to see if anyone had similar type errors or issues I noticed the Element Component bug and from what I can tell it could also be resolved from my fix while not necessarily being a direct application. Even some proper handling in this area should be required as some custom error handling and debug support would be nice - as mentioned by the user of the element component issue. :)

I hope everyone is having a great day!

Lingua principale
TypeScript
Stelle
530
Fork
60
Merge medio
2g 13h
PR unite (30g)
13

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di playcanvas/react

Tutte le issue di playcanvas/react

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.