playcanvas / playcanvas/engine

access textures inside a gltf material content handler

Open
#5,606 0 comments 0 reactions 1 assignee View on GitHub

@slimbuck is already working on this.

Since Sep 4, 2023.

area: gltf enhancement
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
  1. Pass textures also down to the postprocess phase
  2. Expose createMaterial to the public API somehow https://github.com/playcanvas/engine/blob/de6e47f760faa54ad0b8f1655c57e1e302bff617/src/framework/parsers/glb-parser.js#L1168
  3. Preferably also expose extractTextureTransform https://github.com/playcanvas/engine/blob/de6e47f760faa54ad0b8f1655c57e1e302bff617/src/framework/parsers/glb-parser.js#L899
Links

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.