playcanvas / playcanvas/engine
access textures inside a gltf material content handler
@slimbuck is already working on this.
Since Sep 4, 2023.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
Description
When loading assets we can pass a container handler to hook into loading process. In case of gltf material, we can pass preprocess, process, postprocess hooks.
As for now, the only way to access textures is inside the process hook
https://github.com/playcanvas/engine/blob/de6e47f760faa54ad0b8f1655c57e1e302bff617/src/framework/parsers/glb-parser.js#L1724
However, passing a process hook then skips the default implementation of createMaterial
https://github.com/playcanvas/engine/blob/de6e47f760faa54ad0b8f1655c57e1e302bff617/src/framework/parsers/glb-parser.js#L1717
Unfortunately createMaterial is currently not exposed to the public API, so we can not apply custom processing steps on top of the default implementation. This prevents custom gltf extension that rely on custom textures from adding their functionality.
Suggestions
- Pass textures also down to the
postprocessphase - Expose
createMaterialto the public API somehow https://github.com/playcanvas/engine/blob/de6e47f760faa54ad0b8f1655c57e1e302bff617/src/framework/parsers/glb-parser.js#L1168 - Preferably also expose
extractTextureTransformhttps://github.com/playcanvas/engine/blob/de6e47f760faa54ad0b8f1655c57e1e302bff617/src/framework/parsers/glb-parser.js#L899
Links
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.