question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GLTFExporter Bug - MorphTargetAnimations Break Export

See original GitHub issue

Bug

Any exported scene with Morph Target animations not targeting the root node will fail. In my case it was an animation with multiple meshes each with Morph Targets and each having tracks for each of their Morph Target influences.

See Lines (1593-1597):

if ( trackProperty === PATH_PROPERTIES.morphTargetInfluences ) {

    outputItemSize /= trackNode.morphTargetInfluences.length;

}

You end up getting an error “cannot get length of undefined” from the middle line (1595). Because the trackNode var will always point to the root node of your export rather than the node actually being targeted by that animation track.

This is because the function GLTFExporter.Utils.mergeMorphTargetTracks() will always set a merged morphTargetTrack name to “.morphTargetInfluences”.

In turn, when this track is processed, the trackBinding var gets malformed where all properties are undefined except for the propertyName which is equal to “morphTargetInfluences”. Then the trackNode var tries to find the node by checking the trackBinding.nodeName which is undefined, causing the trackNode to always default to the root node of the export. var trackNode = THREE.PropertyBinding.findNode( root, trackBinding.nodeName );

Any exported scene with Morph Target animations not targeting the root node will fail. This is why.

Fix

I figured out a two line fix for this. But my understanding of merged morphtarget tracks is slim.

On line 2256 (currently blank). Add: mergedTrack["targetCount"]=targetCount;

And then change line 1595 to: outputItemSize /= track.targetCount;

Basically all this fix does is add the MorphTargetInfluences length (previously calculated for the targetCount var) to the merged MorphTarget track. Then we are able to reference the appropriate morphTargetInfluence length when the merged track is being processed, even though we don’t have a reference to the correct node.

If anyone has any insight for a better fix. Please let me know you’re up for taking a stab at it. Otherwise I’ll submit this fix as a PR.

I think ideally I’d like an export option for not merging morphtarget tracks, but that will be it’s own Feature Request post.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
donmccurdycommented, Sep 29, 2019

Anywhere I can go to suggest this feature for GLTF 3.0?

Filed to https://github.com/KhronosGroup/glTF/issues/1675 – feel free to comment there if my summary missed anything!

1reaction
Bug-Reapercommented, Nov 19, 2019

Hey @abelnation I’m going to make a PR for this tonight. I’m not sure it will solve your issue though as this change is specific to the GLTFExporter lib.

If you want to screenshot the console errors you get, I can confirm and also possibly address related problems in other parts of the codebase. Great to see other people doing more advanced morph target programming in threejs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GLTF 3D Exporter Broken (Not Solved Yet) | BeamNG
Im trying to export cars from the game but the output file only weights 4 Bytes (Yes, only 4 Bytes) and doesn't open...
Read more >
How the glTF Exporter Handles Unreal Engine Content
The glTF exporter can export several types of Asset from Unreal Engine. When you export an Asset that ... Mesh clothing Assets. Morph...
Read more >
ThreeJS exportGLTF(scene) | GLB textures broken after export ...
I am trying to export a collada scene with threejs using GLTFexporter from the browser, the scene renders perfectly with threejs in collada ......
Read more >
gltf exporter is ignoring collection and scene active/inactive ...
Short description of error. working with scenes and exporting to gltf is ignoring which scene is active and which collections are active.
Read more >
MSFS - Problem using the new Asobo GltF exporter with Blender
gltf" error, could not be found. I've set up my export and textures path as per the tutorials and using either the Objects...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found