Open alinen opened 7 years ago
Some more info: Changing the FBX export options broke my fix above. I am now sending the vertexID to the macro like so
GetLayerElement (pLayerElementNormals, normalIndex, FbxVector4, normal, index, vertexID, [this] (FbxVector4 &V) { _in_normals.push_back (V) ; }) ;
And then using the following modified macro
int indexV =-1 ; \
T V ; \
if ( layerElt ) { \
if (layerElt->GetMappingMode() == FbxLayerElement:: eByControlPoint ) indexV = vIndex; \
else indexV =(layerElt->GetReferenceMode () == FbxLayerElement::eDirect ? index : layerElt->GetIndexArray () [index]) ; \
V =layerElt->GetDirectArray ().GetAt (indexV) ; \
lambda (V) ; \
}
And the FBX you would need for testing are here
https://github.com/alinen/FBX-glTF/models/airplane/airplane.fbx https://github.com/alinen/FBX-glTF/models/drone/DRONE_Shell.fbx
Again, advice would be appreciated!
The resulting glTF has incorrect normals as a result.
To work around the issue, I have changed the macro GetLayerElement to use the MappingMode rather than the ReferenceMode, like so
define GetLayerElement(layerElt, indexV, T, V, index, lambda) \
Models that demonstrate the problem are here
https://github.com/alinen/FBX-glTF/tree/master/three.js/models/drone_shell (needs updated three.js too) https://github.com/alinen/FBX-glTF/tree/master/three.js/models/airplane
I would be interested in knowing the proper fix!