Blender exporter doesn’t export shape keys

Description of the problem

Many of the Blender examples have morph targets, however I’ve been trying to export a mesh from Blender and morph targets aren’t exported.

You can see shape keys are set up in Blender, and keyed in the “Shape Key Editor” view:
screen shot 2016-04-21 at 4 43 43 pm
screen shot 2016-04-21 at 4 43 41 pm

However on export to JSON there are no morph targets. Only one empty array under they "geometry" key, "morphTargets":[],.

Exporter settings include morph:

screen shot 2016-04-21 at 4 45 33 pm

You can download the .blend file in question to try this out: eye-test.blend.zip

Three.js version
  • Dev
  • r76

Author: Fantashit

1 thought on “Blender exporter doesn’t export shape keys

  1. UPDATE: I found a workflow that works for me:

    1. comment out lines 472->503 of exporter/api/object.py in your blender add-ons folder
    2. restart blender
    3. export your file with the following settings, note that you must choose “Geometry”, not “BufferGeometry”.

    screen shot 2017-03-21 at 1 43 02 pm

    1. then, on the three.js side you can load and initialize morph targets with code like this:
    var objectLoader = new THREE.ObjectLoader();
    
    objectLoader.load("path/export.json", (group) => {
       group.children[0].material.morphTargets = true;
       group.children[0].material.needsUpdate = true;
       group.children[0].updateMorphTargets();
       scene.add(group.children[0]);
    });
    

    and modify morph target influences by modifying the mesh.morphTargetInfluences, which contains floats between 0. and 1. corresponding to each shape key. seems like no “needsUpdate” calls are necessary, you can just set them and the mesh will update. Like so:

    mesh.morphTargetInstances[0] = 1.

Comments are closed.