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

GLTFExporter Fix Morph #12967

Merged
merged 2 commits into from
Feb 20, 2018
Merged

GLTFExporter Fix Morph #12967

merged 2 commits into from
Feb 20, 2018

Conversation

takahirox
Copy link
Collaborator

@takahirox takahirox commented Dec 25, 2017

This PR fixes GLTFExporter Morph.

  • glTF 2.0 morph supports only POSITION/NORMAL/TANGENT. So let's skip others.
  • Three.js morph attribute has absolute values while the one of glTF has relative values. So we need to convert.

You can see that the second one fixes a morph issue on Don's glTF viewer
https://gltf-viewer.donmccurdy.com/

Without this change scene.zip
With this change scene_fix.zip

Zip files include glTF AnimationMorphCube model loaded with GLTFLoader and then exported with GLTFExporter

https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedMorphCube

/cc @fernandojsg @donmccurdy

Copy link
Collaborator

@donmccurdy donmccurdy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@@ -800,9 +800,41 @@ THREE.GLTFExporter.prototype = {

for ( var attributeName in geometry.morphAttributes ) {

// glTF 2.0 morph supports only POSITION/NORMAL/TANGENT.
//
// @TODO TANGENT support
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I wouldn't bother adding a @\TODO about this since three.js doesn't support stored tangents currently...


var baseAttribute = geometry.attributes[ attributeName ];
// Clones attribute not to override
var attribute2 = attribute.clone();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you rename this relativeAttribute or something like that? Comment above it wouldn't be necessary in that case.

@takahirox
Copy link
Collaborator Author

Updated. Thanks for the comments.

Regarding absolute/relative comment, let me keep it because I think it'll be helpful for new developers.
And I've added warning message for non-POSITION/NORMAL morph.

@takahirox
Copy link
Collaborator Author

takahirox commented Feb 19, 2018

/ping @fernandojsg for the review

@mrdoob mrdoob added this to the r91 milestone Feb 20, 2018
@mrdoob
Copy link
Owner

mrdoob commented Feb 20, 2018

Sorry, I lost track of this PR. I'll merge for now, we can amend if @fernandojsg has any comments.

@mrdoob mrdoob merged commit 707b44a into mrdoob:dev Feb 20, 2018
@mrdoob
Copy link
Owner

mrdoob commented Feb 20, 2018

Thanks!

@takahirox takahirox deleted the GLTFExporterMorph branch February 24, 2018 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants