Skip to content

Commit

Permalink
FBXLoader: Add UnitScaleFactor to scene's userData. (#27187)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Nov 14, 2023
1 parent e964cbb commit 75cb813
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions examples/jsm/loaders/FBXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ class FBXTreeParser {

this.bindSkeleton( deformers.skeletons, geometryMap, modelMap );

this.createAmbientLight();
this.addGlobalSceneSettings();

sceneGraph.traverse( function ( node ) {

Expand Down Expand Up @@ -1468,20 +1468,31 @@ class FBXTreeParser {

}

// Parse ambient color in FBXTree.GlobalSettings - if it's not set to black (default), create an ambient light
createAmbientLight() {
addGlobalSceneSettings() {

if ( 'GlobalSettings' in fbxTree && 'AmbientColor' in fbxTree.GlobalSettings ) {
if ( 'GlobalSettings' in fbxTree ) {

const ambientColor = fbxTree.GlobalSettings.AmbientColor.value;
const r = ambientColor[ 0 ];
const g = ambientColor[ 1 ];
const b = ambientColor[ 2 ];
if ( 'AmbientColor' in fbxTree.GlobalSettings ) {

if ( r !== 0 || g !== 0 || b !== 0 ) {
// Parse ambient color - if it's not set to black (default), create an ambient light

const color = new Color( r, g, b ).convertSRGBToLinear();
sceneGraph.add( new AmbientLight( color, 1 ) );
const ambientColor = fbxTree.GlobalSettings.AmbientColor.value;
const r = ambientColor[ 0 ];
const g = ambientColor[ 1 ];
const b = ambientColor[ 2 ];

if ( r !== 0 || g !== 0 || b !== 0 ) {

const color = new Color( r, g, b ).convertSRGBToLinear();
sceneGraph.add( new AmbientLight( color, 1 ) );

}

}

if ( 'UnitScaleFactor' in fbxTree.GlobalSettings ) {

sceneGraph.userData.unitScaleFactor = fbxTree.GlobalSettings.UnitScaleFactor.value;

}

Expand Down

0 comments on commit 75cb813

Please sign in to comment.