Skip to content

Instantly share code, notes, and snippets.

@AndrewRayCode
Last active February 10, 2017 04:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AndrewRayCode/746be166c3008a03167206aec4a46531 to your computer and use it in GitHub Desktop.
Save AndrewRayCode/746be166c3008a03167206aec4a46531 to your computer and use it in GitHub Desktop.

The Three.js Blender exporter has been broken for at least the last 10 releases of Three.js. It's had at least 20 individual authors and contributors, most of whom have left the project never to return. Nevertheless, I have successfully imported animated (both with rigging and morph target) meshes into Three.js. Here's all the things I've encountered which you need to know about:

  • The exporter flips all vertices, faces, etc in the mesh you export. There used to be a "Flip Y/Z" option in the exporter, but it was removed when the exporter was rewritten. Since then speculation is the Blender API changed, or some other change after this one mangled the faces on export. For now we're stuck with it until we track it down.
  • mrdoob/three.js#8723 Invalid json is exported for all files with animations, so you have to delete a key manually from the json
  • mrdoob/three.js#8710 morph target exporting doesn't work with "apply modifiers"
  • mrdoob/three.js#8592 normals didn't export correctly until r76
  • mrdoob/three.js#7724 morph targets exported in a completely invalid format (need to use a script to modify the exported json file to make them work)
  • I didn't make a ticket for it yet but exporting a scene will crash the JSONLoader, you need to use the "ObjectLoader"
  • I didn't make a ticket for it yet but exporting a single model (only thing in blender scene) with "heirarchy" and "scene" checked will incorrectly export a file that will crash the ObjectLoader, and must be loaded with the JSONLoader
  • mrdoob/three.js#8673 the exporter flips random faces, still not sure why, so you frequently have to set your material to doubleside for your model to show correctly in your scene
  • mrdoob/three.js#8677 (comment) you need to use these exact settings or else the export will crash three
  • mrdoob/three.js#8677 (comment) the animationmixer class, which is used in the examples for animating blender models, has no documentaiton. You have to analyze the source and the examples to understand the API.
  • I also haven't made a ticket for it, but if your mesh has "empty" vertices, as in vertices that don't have faces associated with them, it will crash three, so make sure to clean up your mesh in blender, I added a comment about it here http://stackoverflow.com/questions/35288245/three-js-imported-obj-model-commandbuffercontextrender-warning-render-count#comment62407270_35288245
  • I haven't made a ticket for it, but you HAVE to export your model with nothing selected in the scene, and it MUST be in the "idle" pose - as in all bones in their neutral position. Otherwise your animation will be garbled
  • You need to reset your mesh location, rotaiton and scale in Blender before export. You should probably do this before rigging but it might be fine doing it after. Select your mesh, and hit Ctrl-A, then pick "rotation", then repeat for location and scale. Do the same for your armature. This applies any local translations directly to the object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment