Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FBXLoader: Add UnitScaleFactor to scene's userData. #27187

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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