Hi, I’m encounter some issue when try to export the model along with animation that load form FBXLoader
It keep showing error like this
Error: THREE.GLTFExporter: Morph target name not found: 0
After some investigation, I found the following
Inside examples/jsm/loaders/FBXLoader.js
generateMorphTrack( rawTracks ) {
const curves = rawTracks.DeformPercent.curves.morph;
const values = curves.values.map( function ( val ) {
return val / 100;
} );
const morphNum = sceneGraph.getObjectByName( rawTracks.modelName ).morphTargetDictionary[ rawTracks.morphName ];
return new NumberKeyframeTrack( rawTracks.modelName + '.morphTargetInfluences[' + morphNum + ']', curves.times, values );
}
When it generate morph target track, it will generate the track with the name something like head.morphTargetInfluences[0]
where 0
is the index obtain from morphTargetDictionary
by object name if I understand it correctly.
BUT inside examples/jsm/exporters/GLTFExporter.js
on mergeMorphTargetTracks
const targetCount = sourceTrackNode.morphTargetInfluences.length;
const targetIndex = sourceTrackNode.morphTargetDictionary[ sourceTrackBinding.propertyIndex ];
if ( targetIndex === undefined ) {
throw new Error( 'THREE.GLTFExporter: Morph target name not found: ' + sourceTrackBinding.propertyIndex );
}
it try to get targetIndex
from morphTargetDictionary
by sourceTrackBinding.propertyIndex
which in this case will alway result in undefined
because sourceTrackBinding.propertyIndex
is not the morph target name, its already morph target index (0
in my above example).
This is example of my morphTargetDictionary
(just standard 52 blend shapes)
{
browDownLeft: 41
browDownRight: 42
browInnerUp: 43
browOuterUpLeft: 44
browOuterUpRight: 45
...
}
I don’t know whether this is an intended behavior or not? or I do miss something else?
I also try to import my FBX model with its animation inside ThreeJS Editor website as well, when I’m try export it in GLTF, I encounter with the same error. (If the animation is not contains morph target, everything work just fine though)