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 support rotated pivots #12717

Merged
merged 6 commits into from
Nov 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions examples/js/loaders/FBXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1255,10 +1255,14 @@
}

// Functions use the infoObject and given indices to return value array of geometry.
// infoObject can be materialInfo, normalInfo, UVInfo or colorInfo
// polygonVertexIndex - Index of vertex in draw order (which index of the index buffer refers to this vertex).
// polygonIndex - Index of polygon in geometry.
// vertexIndex - Index of vertex inside vertex buffer (used because some data refers to old index buffer that we don't use anymore).
// Parameters:
// - polygonVertexIndex - Index of vertex in draw order (which index of the index buffer refers to this vertex).
// - polygonIndex - Index of polygon in geometry.
// - vertexIndex - Index of vertex inside vertex buffer (used because some data refers to old index buffer that we don't use anymore).
// - infoObject: can be materialInfo, normalInfo, UVInfo or colorInfo
// Index type:
// - Direct: index is same as polygonVertexIndex
// - IndexToDirect: infoObject has it's own set of indices
var dataArray = [];

var GetData = {
Expand Down Expand Up @@ -1902,7 +1906,26 @@

}

// allow transformed pivots - see https://github.com/mrdoob/three.js/issues/11895
// rotated pivots - note: rotation must be applied before translation here
if ( 'GeometricRotation' in modelNode.properties ) {

var array = modelNode.properties.GeometricRotation.value.map( THREE.Math.degToRad );

model.traverse( function ( child ) {

if ( child.geometry ) {

child.geometry.rotateX( array[ 0 ] );
child.geometry.rotateY( array[ 1 ] );
child.geometry.rotateZ( array[ 2 ] );

}

} );

}

// translated pivots
if ( 'GeometricTranslation' in modelNode.properties ) {

var array = modelNode.properties.GeometricTranslation.value;
Expand Down