Przeglądaj źródła

FBXLoader: Fix opacity fallback. (#33325)

Michael Herzog 1 tydzień temu
rodzic
commit
e62f72d7de

+ 6 - 2
examples/jsm/loaders/FBXLoader.js

@@ -601,7 +601,8 @@ class FBXTreeParser {
 
 		}
 
-		// the transparency handling is implemented based on Blender/Unity's approach: https://github.com/sobotka/blender-addons/blob/7d80f2f97161fc8e353a657b179b9aa1f8e5280b/io_scene_fbx/import_fbx.py#L1444-L1459
+		// the transparency handling is implemented based on Blender's approach:
+		// https://github.com/blender/blender/blob/main/scripts/addons_core/io_scene_fbx/import_fbx.py
 
 		parameters.opacity = 1 - ( materialNode.TransparencyFactor ? parseFloat( materialNode.TransparencyFactor.value ) : 0 );
 
@@ -611,7 +612,10 @@ class FBXTreeParser {
 
 			if ( parameters.opacity === null ) {
 
-				parameters.opacity = 1 - ( materialNode.TransparentColor ? parseFloat( materialNode.TransparentColor.value[ 0 ] ) : 0 );
+				// Default to opaque. Some exporters (e.g. 3ds Max) define TransparentColor
+				// as white (1,1,1) without intending transparency, which makes the Unity-style
+				// fallback of `1 - TransparentColor.r` produce incorrect zero opacity.
+				parameters.opacity = 1;
 
 			}
 

BIN
examples/models/fbx/Head_69.fbx


BIN
examples/models/fbx/exampleWindow.fbx


+ 4 - 1
examples/webgl_loader_fbx.html

@@ -54,13 +54,16 @@
 				'warrior/Warrior',
 				'stanford-bunny',
 				'mixamo',
-				'RotationTest'
+				'RotationTest',
+				'exampleWindow',
+				'Head_69',
 			];
 
 			const scales = new Map();
 			scales.set( 'warrior/Warrior', 100 );
 			scales.set( 'archer/ArcherRi01', 100 );
 			scales.set( 'stanford-bunny', 0.001 );
+			scales.set( 'Head_69', 100 );
 
 			init();
 

粤ICP备19079148号