# How to get MorphTarget from Blender export

**URL:** <https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333>\
**Category:** Content creation (3dsMax, Maya, Blender, glTF)\
**Created:** [October 13, 2019, 9:27am UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333 "2019-10-13T09:27:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [October 13, 2019, 9:27am UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/1 "2019-10-13T09:27:27Z")

</div>

Hello,

I create a simple Shape Key in Blender - that transforms a CUBE into a SPHERE (nothing else).

Export is successful and I see how to set up MorphTargetManager, but …

> How to reference MorphTarget instance from Blender export?

* * *

DETAILS:

- Here is the shape key setup: value 1, and the CUBE as a SPHERE.  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/8/81c345cde378c229e89a63b6e8e5d3cd6082f18a.png)
- The target is named ‘KeyMorph1’

-The .babylon exports as expected:

```auto
"morphTargetManagers":[{"id":937964
,"targets":[{"name":"KeyMorph1"
,"positions":[-0.4394,-0.8788,...]

```

- In the ImportMesh, this was the best attempt:

```auto
        nx.testBox = newMeshes[0];
        nx.testBox.position.copyFrom({x: 0, y: 10, z: 0});
        nx.testBox.isVisible = true;

        var manager = new BABYLON.MorphTargetManager();
        nx.testBox.morphTargetManager = manager;

        //HOW TO CORRECTLY INSTANTIATE MORPH TARGET from ShapeKey: KeyMorph1?
        nx.target1 = BABYLON.MorphTarget.FromMesh(nx.testBox, "KeyMorph1", 0.5);
        manager.addTarget(nx.target1);

```

Am I missing something? Searched everywhere, a good example might help others.

At runtime: nx.target1.influence = 1; //does nothing.

Thanks,

Maybe @JCPalmer

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [October 13, 2019, 5:46pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/2 "2019-10-13T17:46:45Z")

</div>

Export wise, you shouldn’t be exporting with a one on a key. The exporter writes the mesh with modifiers applied. Not sure what happens. You intend the mesh to be exported to be the same as basis, right?

You would get the MorphTargetManager already created in the mesh, I am pretty sure, and set targets by themselves or in combination to values 0-1. Nothing special about Blender being the source. There’s gotta be a doc page on that.

---

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [October 13, 2019, 6:05pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/3 "2019-10-13T18:05:18Z")

</div>

You rock JCP as always.

I’m gonna jump into FORTNITE LIVE EVENT with my son… then I get to dig into this.

Thank you for being around.

---

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [October 13, 2019, 8:01pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/4 "2019-10-13T20:01:49Z")

</div>

UNDERSTOOD - did not EXPORT with it on value 1. Just to show the SUCCESS STATE.

Export is same as basis - correct. But TRUE - I could easily make that mistake.

…

MorphTargetManager already created in the mesh… ok I will double-check:

CONFIRMED (after import):

nx.testBox.morphTargetManager  
null

nx.testBox.morphTargetManagers  
undefined

So (as above) - creating morphTargetManager and applying to imported mesh.

CONFIRMED: Not in the Submeshes.

QUESTION:

> Is it NOT BEING IMPORTED THROUGH ImportMesh???

QUESTION (not in docs and hard to find in PG):

> Or, syntax to get the .babylon export “KeyMorph1” into BABYLON.MorphTarget instance?

---

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [October 13, 2019, 8:59pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/5 "2019-10-13T20:59:28Z")

</div>

Ah ha! ImportMesh is NOT IMPORTING MorphTargetManagers???

Blender .babylon exports them successfully, but it appears ImportMesh does not import…

I upgraded to v3.2. Was this something that was implemented after that?

Where should MorphTargetManagers be imported? Is it in parameter 4? Thx.

: )

---

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [October 14, 2019, 6:21am UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/6 "2019-10-14T06:21:59Z")

</div>

SOLVED IT!!!

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/1/1f5b9bd61a9f26eb04b32b2fe586b119d6d562ed.jpeg)

It was not easy. Just in case someone else is looking for example of how to IMPORT BLENDER SHAPEKEYS into BABYLON via MORPHTARGETMANAGER.

There were multiple points of difficulties.

The biggest was that ImportMesh was NOT IMPORTING. And the syntax to check if it is imported… I still have not seen. And it never did import.

The solution was this:

```auto
     BABYLON.SceneLoader.ImportMesh("", "./3d/", "minKeyMorph.babylon", nx.scene, function (newMeshes, particleSystems, skeletons) {
        nx.testBox = newMeshes[0];
        nx.testBox.position.copyFrom({x: -200, y: 50, z: -172.94191286506089});
        nx.testBox.position.y += 15;
        nx.testBox.isVisible = true;

        var manager = new BABYLON.MorphTargetManager();
        nx.testBox.morphTargetManager = manager;
                nx.target = new BABYLON.MorphTarget("key1", 0);
        
//forced to embed morphtarget-.
nx.target.setPositions([-0.4394,-0.8788,-0.8788,-0.8788,-0.8788,-0.4394,-0.5373,-1.0747,-0.5373,-0.8788,0.8788,-0.4394,-0.4394,0.8788,-0.8788,-0.5373,1.0747,-0.5373,0.8788,0.8788,-0.4394,0.8788,0.4394,-0.8788,1.0747,0.5373,-0.5373,-0.8788,0.4394,-0.8788,-0.5373,0.5373,-1.0747,-1.0747,0.5373,0.5373,-0.762,0.762,0.762,-0.8788,0.4394,0.8788,-0.5373,-0.5373,1.0747,-0.762,-0.762,0.762,-0.8788,-0.4394,0.8788
            ,-0.5883,0,1.1766,-0.5373,0.5373,1.0747,0.5883,0,1.1766,0,0.5883,1.1766,0.5373,0.5373,1.0747,0.4394,-0.8788,0.8788,0,-0.5883,1.1766,0.5373,-0.5373,1.0747,-1.1766,0,0.5883,-1.0747,-0.5373,0.5373,-1.1766,0,-0.5883,-1.1766,-0.5883,0,-1.0747,-0.5373,-0.5373,-1.1766,0.5883,0,-1.0747,0.5373,-0.5373,-0.5883,0,-1.1766,-0.8788,-0.4394,-0.8788
            ,-0.5373,-0.5373,-1.0747,0.5883,0,-1.1766,0,-0.5883,-1.1766,0.5373,-0.5373,-1.0747,0.4394,0.8788,-0.8788,0,0.5883,-1.1766,0.5373,0.5373,-1.0747,1.1766,0,-0.5883,0.8788,-0.4394,-0.8788,1.0747,-0.5373,-0.5373,1.1766,0,0.5883,1.1766,-0.5883,0,1.0747,-0.5373,0.5373,0.8788,0.8788,0.4394,1.1766,0.5883,0,1.0747,0.5373,0.5373,0,1.1766,-0.5883
            ,0.5373,1.0747,-0.5373,0,1.1766,0.5883,0.5883,1.1766,0,0.5373,1.0747,0.5373,-0.5373,1.0747,0.5373,-0.9317,0.9317,0,-0.5883,1.1766,0,-0.5373,-1.0747,0.5373,-0.9317,-0.9317,0,-0.8788,-0.8788,0.4394,0.5883,-1.1766,0,0,-1.1766,0.5883,0.5373,-1.0747,0.5373,0.5373,-1.0747,-0.5373,0,-0.9317,-0.9317,0,-1.1766,-0.5883,0,-1.3146,0
            ,0.9317,-0.9317,0,0.8788,-0.8788,-0.4394,0.4394,-0.8788,-0.8788,0,-0.9317,0.9317,0.8788,-0.8788,0.4394,0.762,-0.762,0.762,-0.4394,-0.8788,0.8788,-0.5883,-1.1766,0,0,1.3146,0,-0.4394,0.8788,0.8788,0,0.9317,0.9317,-0.8788,0.8788,0.4394,0.9317,0.9317,0,0.4394,0.8788,0.8788,0.762,0.762,0.762,0.762,0.762,-0.762,1.3146,0,0
            ,0.8788,0.4394,0.8788,0.9317,0,0.9317,0.8788,-0.4394,0.8788,0.762,-0.762,-0.762,0,0,-1.3146,0.9317,0,-0.9317,-0.762,-0.762,-0.762,-1.3146,0,0,-0.9317,0,-0.9317,-0.762,0.762,-0.762,0,0,1.3146,-0.9317,0,0.9317,0,0.9317,-0.9317]);

        manager.addTarget(nx.target);
        nx.target.influence = 0;

        //nx.target.influence = 1; //at runtime.
     });

```

This is the DOC I used to make the minimal shapekey…  
[easyblend.org/html/animation/shape\_keys.html](http://easyblend.org/html/animation/shape_keys.html)

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [October 14, 2019, 5:01pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/7 "2019-10-14T17:01:32Z")

</div>

Maybe trying it the easy way would be better. I am a little sick, and was answering from a tablet where I cannot really check things. ImportMesh / Append are calling Mesh.Parse() to load the JSON file. If there is a morfManagerTargetId, which you show as 937964 in your original post, then  
`mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);`

[see](https://github.com/BabylonJS/Babylon.js/blob/master/src/Meshes/mesh.ts#L3256) Just use that.

---

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [October 14, 2019, 6:56pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/8 "2019-10-14T18:56:39Z")

</div>

Oh SNAP! I try that…

… that code is great.

Hope you feel better.

Thanks JCP : )

---

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [October 16, 2019, 4:53pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/9 "2019-10-16T16:53:46Z")

</div>

Digging deeper and deeper - and it is FASCINATING!

RESULTS of getMorphTargetManagerById

- Very helpful fo someone (hard to find), for me the result is:

- Blender Shape Keys had issues after export (surprise).

* * *

> We also see a way to _manipulate the vertices directly with JS!!!_

[Parent Objects off a HERO origin and interpolate]. So simple. Needs a TEST.

It causes extra work (re-doing POSE animations [always] \<exclude EYE.), but, may result in

> COMPLETE PROGRAMMATIC FREEDOM, (PERFORMANCE OPS) and ANM-PRECISION.

* * *

LIKE that potential very much! Going for it.

> ANIMATION PRECISION is a GUIDING (DESIGN) PRINCIPLE.

_We choose close-to-the-metal ANM~PRECISION methodology wherever we can get it!_

It will FAIL! For unexpected reason… and that’s ok. Will push it through that door.

> Prefer BABYLON logic over BLENDER logic (is an ongoing trend).

* * *

Thanks much! Confirm on null would be cool. Love MorphTargets.

Also, I’ll update (yet another) strange saga. As we try dangerous things!

That EYE had better moove!

![orby2](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/6/66b9a04edb1ab66f233a443601d1934286341a17.png)

PRECISELY (during full body armature deforms).

This eye is the reason for everything. : )

🦅

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [October 16, 2019, 5:16pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/10 "2019-10-16T17:16:27Z")

</div>

The `getMorphTargetManagerById` should be being called by the `importMesh` itself, and **everything** already setup. If not, it is probably a BUG. @Deltakosh, `importMesh` gets skeleton and materials. Shouldn’t it also get the morph manager?

Try `scene.Append` for now. All this other stuff is just confusing.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 16, 2019, 5:30pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/11 "2019-10-16T17:30:19Z")

</div>

Yeah importMesh gets extended over time but did not include the morphtarget. Not really a bug though

I agree, just use Append

---

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [October 16, 2019, 5:30pm UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/12 "2019-10-16T17:30:47Z")

</div>

Awesome!

Will try…

---

<div class="post-metadata">

**Author:** ![aFalcon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/afalcon/32/7015_2.png) [@aFalcon](https://forum.babylonjs.com/u/aFalcon)\
**Post date:** [October 18, 2019, 6:50am UTC](https://forum.babylonjs.com/t/how-to-get-morphtarget-from-blender-export/6333/13 "2019-10-18T06:50:52Z")

</div>

SOLVED

Eye-Ball ANM, simultaneous to Body ANMs.

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/8/8c51e3807cbe1771aa29186782451340028ebefb.png)

Zero Shape Keys (or Vertex Groups with Constraint complications).

Simple and clean - parent eye to body, then interpolate into relative position with JS.

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/4/456f35913a70a1f7cd14b5d64f7b56315cb5986c.png)

EyeBallFactory

🦅
