Editor:Uncaught TypeError: normal.clone is not a function (GLTFExporter.js)

I import a gltf file into Editor, and when I export it,2cen.gltf (1.2 MB) i got this error

Uncaught TypeError: normal.clone is not a function
at createNormalizedNormalAttribute (GLTFExporter.js:297)
at processMesh (GLTFExporter.js:1240)
at processNode (GLTFExporter.js:1812)
at processNode (GLTFExporter.js:1860)
at processNode (GLTFExporter.js:1860)
at processScene (GLTFExporter.js:1921)
at processInput (GLTFExporter.js:1974)
at GLTFExporter.parse (GLTFExporter.js:2004)
at UIRow. (Menubar.File.js:272)
createNormalizedNormalAttribute @ GLTFExporter.js:297
processMesh @ GLTFExporter.js:1240
processNode @ GLTFExporter.js:1812
processNode @ GLTFExporter.js:1860
processNode @ GLTFExporter.js:1860
processScene @ GLTFExporter.js:1921
processInput @ GLTFExporter.js:1974
parse @ GLTFExporter.js:2004
(anonymous) @ Menubar.File.js:272

and here is my GLTF file,who can help me ,thanks!

Unfortunately, you hit a know limitation of the engine’s geometry system. Your asset contains interleaved attributes which cause runtime errors in the editor (on each save) and when exporting to glTF. That’s because InterleavedBufferAttribute has no clone() and toJSON() methods.

I’ve submitted a simple fix for this issue earlier this year by just de-interleaving the data (see https://github.com/mrdoob/three.js/pull/18537). But unfortunately, the approach was not accepted.

Implementing clone() and toJSON() methods on attribute level that retain the interleaved structure is not possible (since multiple attributes share a common interleaved buffer). This can only be done on BufferGeometry level.

Anyway, I would appreciate if you can file an issue for this at GitHub. With more attention, we can maybe implement de-interleaving so clone() and toJSON() do not produce runtime errors anymore.

Thank you , I have created a issue on the project , What I can do to make up before the fix is applied?

Well, you would need to implement both methods by yourself according to the above PR.

I think I would prefer to add interleaved support to bufferGeometry.clone() first, so that the cloned geometry can remain interleaved. Cloning an interleaved attribute in isolation is tricky. :confused:

I don’t think this is even possible. I mean an isolated clone of a single interleaved attribute. Or do I overlook something obvious :thinking:? AFAICT, de-interleaving is the only option in this case.

1 Like

Possible, but the options aren’t great:

A. shallow clone the attribute, keeping a reference to the same data (inconsistent with non-interleaved .clone()?)
B. deeply clone the attribute, duplicating all the other attributes’ data, which would now be disconnected from other attributes and just taking up space.
C. clone changes type from interleaved to non-interleaved

So yeah I’m not really excited about any of these options. But cloning the whole geometry can work more cleanly.