Skip to content

Commit e62f72d

Browse files
authored
FBXLoader: Fix opacity fallback. (#33325)
1 parent 9c53443 commit e62f72d

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

examples/jsm/loaders/FBXLoader.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,8 @@ class FBXTreeParser {
601601

602602
}
603603

604-
// 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
604+
// the transparency handling is implemented based on Blender's approach:
605+
// https://github.com/blender/blender/blob/main/scripts/addons_core/io_scene_fbx/import_fbx.py
605606

606607
parameters.opacity = 1 - ( materialNode.TransparencyFactor ? parseFloat( materialNode.TransparencyFactor.value ) : 0 );
607608

@@ -611,7 +612,10 @@ class FBXTreeParser {
611612

612613
if ( parameters.opacity === null ) {
613614

614-
parameters.opacity = 1 - ( materialNode.TransparentColor ? parseFloat( materialNode.TransparentColor.value[ 0 ] ) : 0 );
615+
// Default to opaque. Some exporters (e.g. 3ds Max) define TransparentColor
616+
// as white (1,1,1) without intending transparency, which makes the Unity-style
617+
// fallback of `1 - TransparentColor.r` produce incorrect zero opacity.
618+
parameters.opacity = 1;
615619

616620
}
617621

examples/models/fbx/Head_69.fbx

1.99 MB
Binary file not shown.
68.9 KB
Binary file not shown.

examples/webgl_loader_fbx.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@
5454
'warrior/Warrior',
5555
'stanford-bunny',
5656
'mixamo',
57-
'RotationTest'
57+
'RotationTest',
58+
'exampleWindow',
59+
'Head_69',
5860
];
5961

6062
const scales = new Map();
6163
scales.set( 'warrior/Warrior', 100 );
6264
scales.set( 'archer/ArcherRi01', 100 );
6365
scales.set( 'stanford-bunny', 0.001 );
66+
scales.set( 'Head_69', 100 );
6467

6568
init();
6669

0 commit comments

Comments
 (0)