Support Custom Asset Loading For GSplat Component
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- react, typescript
Línea de trabajo
Empieza en validation.ts leyendo getPseudoPublicProps y createComponentDefinition; después, sigue cómo las propiedades que solo tienen getter, como GSplatComponent.id, entran en el esquema y se aplican. Usa el ejemplo de Asset personalizado y el error de GSplat reportado para verificar que los Assets personalizados válidos ya no provoquen la asignación de la id de solo lectura, mientras el comportamiento existente de los componentes permanece intacto.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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!
- Lenguaje dominante
- TypeScript
- Estrellas
- 535
- Forks
- 60
- Merge medio
- 2 d 13 h
- PR fusionados (30 d)
- 13
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de playcanvas/react
-
Review the unified gsplat APIAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
playcanvas/react#320 ·
Los mantenedores suelen responder en 1 día
-
Expose reference from <Application /> componentQuizá libre de nuevo @abstrakt8 la tomó hace 242 días y no hay ningún pull request abierto. Abiertoenhancement
playcanvas/react#309 · 1 reacción · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
playcanvas/react#308 · 8 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
playcanvas/react#306 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
ElementComponent has a bug.Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
playcanvas/react#303 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de playcanvas/react
Issues similares
-
area/frontend good first issue kind/cooldown
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
voidzero-dev/oxc-angular-compiler#511 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
langchain-ai/deepagentsjs#898 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
anomalyco/models.dev#8509 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug documentation P2 UI/UX
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día