Open donmccurdy opened 7 months ago
Picking up from https://github.com/pmndrs/react-three-fiber/issues/2498, another issue to consider is that three.js must clone materials when they're reused by incompatible meshes. Presence of vertex colors and vertex tangents would be one example of this. The same prepass could do this change as well, outputting a GLB with N copies of a reused material, each having a unique name.
I don't see a better alternative than mutating the GLB. I'd have to concur with this.
Currently gltfjsx relies on matching the exact implementation of GLTFLoader's
createUniqueName
...https://github.com/pmndrs/gltfjsx/blob/8bf87e1913b941ae16a1c57817d08e865f8568f6/src/bin/GLTFLoader.js#L1911C1-L1924
... to ensure that names in JSX match names GLTFLoader will output, given the same file. However, it's difficult for three.js to guarantee indefinitely that the same .glb file will always result in the same names in future releases. When the file contains duplicate names, GLTFLoader must assign suffixes like
_1
or_2
, and refactoring or performance changes in GLTFLoader could change the order in which suffixes are assigned.I'd like to add a step to gltfjsx, pre-processing the input to ensure unique names, so that GLTFLoader's
createUniqueName
will have nothing to de-duplicate at runtime. That would be an additional step insrc/utils/transform.js
. Are others OK with this change?Related: