Skip to content

Commit 6b0c51e

Browse files
authored
FBXLoader: Add coordinate system correction for Z-up. (#33332)
1 parent bc05118 commit 6b0c51e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

examples/jsm/loaders/FBXLoader.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,24 @@ class FBXTreeParser {
10121012

10131013
sceneGraph.animations = animations;
10141014

1015+
// Apply coordinate system correction. FBX files can use different
1016+
// up-axis conventions (Y-up or Z-up). Three.js uses Y-up, so rotate
1017+
// the scene when the file uses Z-up (UpAxis === 2).
1018+
1019+
if ( 'GlobalSettings' in fbxTree && 'UpAxis' in fbxTree.GlobalSettings ) {
1020+
1021+
const upAxis = fbxTree.GlobalSettings.UpAxis.value;
1022+
1023+
if ( upAxis === 2 ) {
1024+
1025+
console.warn( 'THREE.FBXLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted.' );
1026+
1027+
sceneGraph.rotation.set( - Math.PI / 2, 0, 0 );
1028+
1029+
}
1030+
1031+
}
1032+
10151033
}
10161034

10171035
// parse nodes in FBXTree.Objects.Model

0 commit comments

Comments
 (0)