Three.js: GLTFLoader changes meshnames

Created on 29 Oct 2019  Â·  3Comments  Â·  Source: mrdoob/three.js

Hey,

I recently found out that GLTFLoader changes the names of the meshes.

Simple example:
AB.zip

There's a gltf file in the zip. If you open it up with a text editor, you can see that it has one mesh in it, with the following name: A / B.

If you load it with GLTFLoader, that name becomes A__B (you can try here, see the console: https://gltf-viewer.donmccurdy.com/ )

So space () becomes underscore (_), while slash (/) gets simply removed.

Is this a bug, or is there a valid reason why this is happening?

@donmccurdy ?

Question

Most helpful comment

That's correct – we alter the names so that they're compatible with the three.js animation system.

If you're trying to preserve specific data for each object in your application, you could also use "Custom Properties" in Blender, with that option enabled in the export settings. Your custom key/value data will be set on the objects as mesh.userData.*.

All 3 comments

This is related to the sanitization of node names in context of the animation system's property binding.

https://github.com/mrdoob/three.js/blob/a4e573604cf1694db8f0059798bc97653fd538a6/src/animation/PropertyBinding.js#L138-L149

That's correct – we alter the names so that they're compatible with the three.js animation system.

If you're trying to preserve specific data for each object in your application, you could also use "Custom Properties" in Blender, with that option enabled in the export settings. Your custom key/value data will be set on the objects as mesh.userData.*.

Ok, got it, thanks! :)

Was this page helpful?
0 / 5 - 0 ratings