Преглед изворни кода

FBXLoader: Fix morph deltas. (#33350)

Michael Herzog пре 1 месец
родитељ
комит
446f223ae6

+ 8 - 1
examples/jsm/loaders/FBXLoader.js

@@ -2364,6 +2364,13 @@ class GeometryParser {
 		parentGeo.morphAttributes.position = [];
 		// parentGeo.morphAttributes.normal = []; // not implemented
 
+		// Morph attribute positions are stored as deltas (morphTargetsRelative = true), so the
+		// translation component of the geometric transform must not be applied to them — only the
+		// rotation/scale part. Otherwise every delta gets the geometric translation added, which
+		// shifts morphed vertices away from their intended position by `weight * translation` as
+		// the influence increases.
+		const morphPreTransform = preTransform.clone().setPosition( 0, 0, 0 );
+
 		const scope = this;
 		morphTargets.forEach( function ( morphTarget ) {
 
@@ -2373,7 +2380,7 @@ class GeometryParser {
 
 				if ( morphGeoNode !== undefined ) {
 
-					scope.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, rawTarget.name );
+					scope.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, morphPreTransform, rawTarget.name );
 
 				}
 

BIN
examples/models/fbx/morph-translation.fbx


+ 1 - 0
examples/webgl_loader_fbx.html

@@ -57,6 +57,7 @@
 				'RotationTest',
 				'exampleWindow',
 				'Head_69',
+				'morph-translation',
 			];
 
 			const scales = new Map();

粤ICP备19079148号