Skip to content

Commit

Permalink
Merge pull request mrdoob#15017 from looeee/fbxloader_use_array_filter
Browse files Browse the repository at this point in the history
FBXLoader: use Array.filter instead of forEach
  • Loading branch information
mrdoob authored Oct 8, 2018
2 parents 63560a1 + 14ecfab commit 0d80834
Showing 1 changed file with 34 additions and 36 deletions.
70 changes: 34 additions & 36 deletions examples/js/loaders/FBXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,11 @@ THREE.FBXLoader = ( function () {

if ( morphTargetNode.attrType !== 'BlendShapeChannel' ) return;

var targetRelationships = connections.get( parseInt( child.ID ) );
rawMorphTarget.geoID = connections.get( parseInt( child.ID ) ).children.filter( function ( child ) {

targetRelationships.children.forEach( function ( child ) {
return child.relationship === undefined;

if ( child.relationship === undefined ) rawMorphTarget.geoID = child.ID;

} );
} )[ 0 ].ID;

rawMorphTargets.push( rawMorphTarget );

Expand Down Expand Up @@ -2488,62 +2486,62 @@ THREE.FBXLoader = ( function () {

if ( layerCurveNodes[ i ] === undefined ) {

var modelID;
var modelID = connections.get( child.ID ).parents.filter( function ( parent ) {

connections.get( child.ID ).parents.forEach( function ( parent ) {
return parent.relationship !== undefined;

if ( parent.relationship !== undefined ) modelID = parent.ID;
} )[ 0 ].ID;

} );
if ( modelID !== undefined ) {

var rawModel = fbxTree.Objects.Model[ modelID.toString() ];
var rawModel = fbxTree.Objects.Model[ modelID.toString() ];

var node = {
var node = {

modelName: THREE.PropertyBinding.sanitizeNodeName( rawModel.attrName ),
ID: rawModel.id,
initialPosition: [ 0, 0, 0 ],
initialRotation: [ 0, 0, 0 ],
initialScale: [ 1, 1, 1 ],
modelName: THREE.PropertyBinding.sanitizeNodeName( rawModel.attrName ),
ID: rawModel.id,
initialPosition: [ 0, 0, 0 ],
initialRotation: [ 0, 0, 0 ],
initialScale: [ 1, 1, 1 ],

};
};

sceneGraph.traverse( function ( child ) {
sceneGraph.traverse( function ( child ) {

if ( child.ID = rawModel.id ) {
if ( child.ID = rawModel.id ) {

node.transform = child.matrix;
node.transform = child.matrix;

if ( child.userData.transformData ) node.eulerOrder = child.userData.transformData.eulerOrder;
if ( child.userData.transformData ) node.eulerOrder = child.userData.transformData.eulerOrder;

}
}

} );
} );

if ( ! node.transform ) node.transform = new THREE.Matrix4();
if ( ! node.transform ) node.transform = new THREE.Matrix4();

// if the animated model is pre rotated, we'll have to apply the pre rotations to every
// animation value as well
if ( 'PreRotation' in rawModel ) node.preRotation = rawModel.PreRotation.value;
if ( 'PostRotation' in rawModel ) node.postRotation = rawModel.PostRotation.value;
// if the animated model is pre rotated, we'll have to apply the pre rotations to every
// animation value as well
if ( 'PreRotation' in rawModel ) node.preRotation = rawModel.PreRotation.value;
if ( 'PostRotation' in rawModel ) node.postRotation = rawModel.PostRotation.value;

layerCurveNodes[ i ] = node;
layerCurveNodes[ i ] = node;

}

}

layerCurveNodes[ i ][ curveNode.attr ] = curveNode;
if ( layerCurveNodes[ i ] ) layerCurveNodes[ i ][ curveNode.attr ] = curveNode;

} else if ( curveNode.curves.morph !== undefined ) {

if ( layerCurveNodes[ i ] === undefined ) {

var deformerID;
var deformerID = connections.get( child.ID ).parents.filter( function ( parent ) {

connections.get( child.ID ).parents.forEach( function ( parent ) {
return parent.relationship !== undefined;

if ( parent.relationship !== undefined ) deformerID = parent.ID;

} );
} )[ 0 ].ID;

var morpherID = connections.get( deformerID ).parents[ 0 ].ID;
var geoID = connections.get( morpherID ).parents[ 0 ].ID;
Expand Down Expand Up @@ -4003,7 +4001,7 @@ THREE.FBXLoader = ( function () {
lParentGRSM = lParentTM.getInverse( lParentTM ).multiply( lParentGX );
lParentGSM = lParentGRM.getInverse( lParentGRM ).multiply( lParentGRSM );
lLSM = lScalingM;

var lGlobalRS;
if ( inheritType === 0 ) {

Expand Down

0 comments on commit 0d80834

Please sign in to comment.