2

I've had a good hunt but can't find the solution:

the GLTFExport for Three.js allows for specific objects to be exported when they're named in the exporter.

My situation:

I have a random number of Object3Ds with child Meshes in my scene that I'd like to export, however I have removed everything from my scene apart from the objects and their child meshes and a helper to show face normals direction, and I still get the error:

Uncaught Error: THREE.GLTFExporter: userData can't be serialized

Previously I didn't have the Object3Ds and just had the meshes by themselves as children of the scene and the export worked fine. Unfortunately having the meshes within the Objects is needed for the program to work and the documentation suggests that they can be exported.

Can anyone think of a way around this issue?

4

1 回答 1

1

userData 是每个 Object3D 上通常设置为 {} 的字段。它旨在允许用户(您)将自己的数据存储在 Object3D 或派生类上,而不会弄乱对象的内部结构。您可能在场景中的 object3D 上设置了一些 .userData 。

查找的简单方法是scene.traverse((o)=>{console.log(o.userData)})查看是否有 userData 存储在您的任何对象上。

您可以在使用 var sceneCopy = scene.clone(true); 导出之前制作场景的副本;

然后sceneCopy.traverse((o)=>{o.userData={};});

然后尝试导出sceneCopy。

试一试,如果它不起作用,请回到这里 :)

hth

于 2018-06-24T03:08:34.040 回答