|
@@ -869,11 +869,17 @@ var FBXLoader = ( function () {
|
|
|
|
|
|
if ( node.userData.transformData ) {
|
|
if ( node.userData.transformData ) {
|
|
|
|
|
|
- if ( node.parent ) node.userData.transformData.parentMatrixWorld = node.parent.matrix;
|
|
|
|
|
|
+ if ( node.parent ) {
|
|
|
|
+
|
|
|
|
+ node.userData.transformData.parentMatrix = node.parent.matrix;
|
|
|
|
+ node.userData.transformData.parentMatrixWorld = node.parent.matrixWorld;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
var transform = generateTransform( node.userData.transformData );
|
|
var transform = generateTransform( node.userData.transformData );
|
|
|
|
|
|
node.applyMatrix4( transform );
|
|
node.applyMatrix4( transform );
|
|
|
|
+ node.updateWorldMatrix();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4027,6 +4033,7 @@ var FBXLoader = ( function () {
|
|
var lRotationPivotM = new Matrix4();
|
|
var lRotationPivotM = new Matrix4();
|
|
|
|
|
|
var lParentGX = new Matrix4();
|
|
var lParentGX = new Matrix4();
|
|
|
|
+ var lParentLX = new Matrix4();
|
|
var lGlobalT = new Matrix4();
|
|
var lGlobalT = new Matrix4();
|
|
|
|
|
|
var inheritType = ( transformData.inheritType ) ? transformData.inheritType : 0;
|
|
var inheritType = ( transformData.inheritType ) ? transformData.inheritType : 0;
|
|
@@ -4054,6 +4061,7 @@ var FBXLoader = ( function () {
|
|
var array = transformData.postRotation.map( MathUtils.degToRad );
|
|
var array = transformData.postRotation.map( MathUtils.degToRad );
|
|
array.push( transformData.eulerOrder );
|
|
array.push( transformData.eulerOrder );
|
|
lPostRotationM.makeRotationFromEuler( tempEuler.fromArray( array ) );
|
|
lPostRotationM.makeRotationFromEuler( tempEuler.fromArray( array ) );
|
|
|
|
+ lPostRotationM.invert();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4066,37 +4074,44 @@ var FBXLoader = ( function () {
|
|
if ( transformData.rotationPivot ) lRotationPivotM.setPosition( tempVec.fromArray( transformData.rotationPivot ) );
|
|
if ( transformData.rotationPivot ) lRotationPivotM.setPosition( tempVec.fromArray( transformData.rotationPivot ) );
|
|
|
|
|
|
// parent transform
|
|
// parent transform
|
|
- if ( transformData.parentMatrixWorld ) lParentGX = transformData.parentMatrixWorld;
|
|
|
|
|
|
+ if ( transformData.parentMatrixWorld ) {
|
|
|
|
+
|
|
|
|
+ lParentLX.copy( transformData.parentMatrix );
|
|
|
|
+ lParentGX.copy( transformData.parentMatrixWorld );
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var lLRM = new Matrix4().copy( lPreRotationM ).multiply( lRotationM ).multiply( lPostRotationM );
|
|
// Global Rotation
|
|
// Global Rotation
|
|
- var lLRM = lPreRotationM.multiply( lRotationM ).multiply( lPostRotationM );
|
|
|
|
var lParentGRM = new Matrix4();
|
|
var lParentGRM = new Matrix4();
|
|
- lParentGX.extractRotation( lParentGRM );
|
|
|
|
|
|
+ lParentGRM.extractRotation( lParentGX );
|
|
|
|
|
|
// Global Shear*Scaling
|
|
// Global Shear*Scaling
|
|
var lParentTM = new Matrix4();
|
|
var lParentTM = new Matrix4();
|
|
lParentTM.copyPosition( lParentGX );
|
|
lParentTM.copyPosition( lParentGX );
|
|
|
|
|
|
var lParentGSM = new Matrix4();
|
|
var lParentGSM = new Matrix4();
|
|
- lParentGSM.copy( lParentGRM ).invert().multiply( lParentGX );
|
|
|
|
|
|
+ var lParentGRSM = new Matrix4().copy( lParentTM ).invert().multiply( lParentGX );
|
|
|
|
+ lParentGSM.copy( lParentGRM ).invert().multiply( lParentGRSM );
|
|
|
|
+ var lLSM = lScalingM;
|
|
|
|
|
|
var lGlobalRS = new Matrix4();
|
|
var lGlobalRS = new Matrix4();
|
|
|
|
|
|
if ( inheritType === 0 ) {
|
|
if ( inheritType === 0 ) {
|
|
|
|
|
|
- lGlobalRS.copy( lParentGRM ).multiply( lLRM ).multiply( lParentGSM ).multiply( lScalingM );
|
|
|
|
|
|
+ lGlobalRS.copy( lParentGRM ).multiply( lLRM ).multiply( lParentGSM ).multiply( lLSM );
|
|
|
|
|
|
} else if ( inheritType === 1 ) {
|
|
} else if ( inheritType === 1 ) {
|
|
|
|
|
|
- lGlobalRS.copy( lParentGRM ).multiply( lParentGSM ).multiply( lLRM ).multiply( lScalingM );
|
|
|
|
|
|
+ lGlobalRS.copy( lParentGRM ).multiply( lParentGSM ).multiply( lLRM ).multiply( lLSM );
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
- var lParentLSM_inv = new Matrix4();
|
|
|
|
- lParentLSM_inv.copy( lScalingM ).invert();
|
|
|
|
- var lParentGSM_noLocal = new Matrix4().multiply( lParentGSM ).multiply( lParentLSM_inv );
|
|
|
|
|
|
+ var lParentLSM = new Matrix4().scale( new Vector3().setFromMatrixScale( lParentLX ) );
|
|
|
|
+ var lParentLSM_inv = new Matrix4().copy( lParentLSM ).invert();
|
|
|
|
+ var lParentGSM_noLocal = new Matrix4().copy( lParentGSM ).multiply( lParentLSM_inv );
|
|
|
|
|
|
- lGlobalRS.copy( lParentGRM ).multiply( lLRM ).multiply( lParentGSM_noLocal ).multiply( lScalingM );
|
|
|
|
|
|
+ lGlobalRS.copy( lParentGRM ).multiply( lLRM ).multiply( lParentGSM_noLocal ).multiply( lLSM );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4113,7 +4128,10 @@ var FBXLoader = ( function () {
|
|
var lGlobalTranslation = new Matrix4().copy( lParentGX ).multiply( lLocalTWithAllPivotAndOffsetInfo );
|
|
var lGlobalTranslation = new Matrix4().copy( lParentGX ).multiply( lLocalTWithAllPivotAndOffsetInfo );
|
|
lGlobalT.copyPosition( lGlobalTranslation );
|
|
lGlobalT.copyPosition( lGlobalTranslation );
|
|
|
|
|
|
- lTransform = new Matrix4().multiply( lGlobalT ).multiply( lGlobalRS );
|
|
|
|
|
|
+ lTransform = new Matrix4().copy( lGlobalT ).multiply( lGlobalRS );
|
|
|
|
+
|
|
|
|
+ // from global to local
|
|
|
|
+ lTransform.premultiply( lParentGX.invert() );
|
|
|
|
|
|
return lTransform;
|
|
return lTransform;
|
|
|
|
|