File tree 1 file changed +40
-2
lines changed
1 file changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -830,11 +830,49 @@ THREE.GLTFExporter.prototype = {
830
830
831
831
var target = { } ;
832
832
833
+ var warned = false ;
834
+
833
835
for ( var attributeName in geometry . morphAttributes ) {
834
836
837
+ // glTF 2.0 morph supports only POSITION/NORMAL/TANGENT.
838
+ // Three.js doesn't support TANGENT yet.
839
+
840
+ if ( attributeName !== 'position' && attributeName !== 'normal' ) {
841
+
842
+ if ( ! warned ) {
843
+
844
+ console . warn ( 'GLTFExporter: Only POSITION and NORMAL morph are supported.' ) ;
845
+ warned = true ;
846
+
847
+ }
848
+
849
+ continue ;
850
+
851
+ }
852
+
835
853
var attribute = geometry . morphAttributes [ attributeName ] [ i ] ;
836
- attributeName = nameConversion [ attributeName ] || attributeName . toUpperCase ( ) ;
837
- target [ attributeName ] = processAccessor ( attribute , geometry ) ;
854
+
855
+ // Three.js morph attribute has absolute values while the one of glTF has relative values.
856
+ //
857
+ // glTF 2.0 Specification:
858
+ // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#morph-targets
859
+
860
+ var baseAttribute = geometry . attributes [ attributeName ] ;
861
+ // Clones attribute not to override
862
+ var relativeAttribute = attribute . clone ( ) ;
863
+
864
+ for ( var j = 0 , jl = attribute . count ; j < jl ; j ++ ) {
865
+
866
+ relativeAttribute . setXYZ (
867
+ j ,
868
+ attribute . getX ( j ) - baseAttribute . getX ( j ) ,
869
+ attribute . getY ( j ) - baseAttribute . getY ( j ) ,
870
+ attribute . getZ ( j ) - baseAttribute . getZ ( j )
871
+ ) ;
872
+
873
+ }
874
+
875
+ target [ attributeName . toUpperCase ( ) ] = processAccessor ( relativeAttribute , geometry ) ;
838
876
839
877
}
840
878
You can’t perform that action at this time.
0 commit comments