diff --git a/examples/jsm/loaders/FBXLoader.js b/examples/jsm/loaders/FBXLoader.js index eb7dd870ac7d27..519c3b3e55b60f 100644 --- a/examples/jsm/loaders/FBXLoader.js +++ b/examples/jsm/loaders/FBXLoader.js @@ -1012,6 +1012,24 @@ class FBXTreeParser { sceneGraph.animations = animations; + // Apply coordinate system correction. FBX files can use different + // up-axis conventions (Y-up or Z-up). Three.js uses Y-up, so rotate + // the scene when the file uses Z-up (UpAxis === 2). + + if ( 'GlobalSettings' in fbxTree && 'UpAxis' in fbxTree.GlobalSettings ) { + + const upAxis = fbxTree.GlobalSettings.UpAxis.value; + + if ( upAxis === 2 ) { + + 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.' ); + + sceneGraph.rotation.set( - Math.PI / 2, 0, 0 ); + + } + + } + } // parse nodes in FBXTree.Objects.Model diff --git a/package-lock.json b/package-lock.json index f7b71cad5d149f..8878c024bb40df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1214,9 +1214,9 @@ "license": "MIT" }, "node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz", + "integrity": "sha512-9ZLprWS6EENmhEOpjCYW2c8VkmOvckIJZfkr7rBW6dObmfgJ/L1GpSYW5Hpo9lDz4D1+n0Ckz8rU7FwHDQiG/w==", "dev": true, "license": "MIT", "dependencies": { @@ -2613,9 +2613,9 @@ } }, "node_modules/lodash": { - "version": "4.17.23", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz", - "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==", + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", "dev": true, "license": "MIT" },