Skip to content

Commit 31f7abf

Browse files
authored
FBXLoader: Improve transparency handling. (#29544)
1 parent 47fb8fe commit 31f7abf

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

examples/jsm/loaders/FBXLoader.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,19 @@ class FBXTreeParser {
571571

572572
}
573573

574-
if ( materialNode.Opacity ) {
574+
// 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
575575

576-
parameters.opacity = parseFloat( materialNode.Opacity.value );
576+
parameters.opacity = ( materialNode.TransparencyFactor ? parseFloat( materialNode.TransparencyFactor.value ) : 1 );
577+
578+
if ( parameters.opacity === 1 || parameters.opacity === 0 ) {
579+
580+
parameters.opacity = ( materialNode.Opacity ? parseFloat( materialNode.Opacity.value ) : null );
581+
582+
if ( parameters.opacity === null ) {
583+
584+
parameters.opacity = ( materialNode.TransparentColor ? parseFloat( materialNode.TransparentColor.value[ 0 ] ) : 1 );
585+
586+
}
577587

578588
}
579589

0 commit comments

Comments
 (0)