Code Monkey home page Code Monkey logo

Comments (6)

zellski avatar zellski commented on June 19, 2024

Hey @birdimus -- you're talking about face normals being flipped as a consequence of the negative scale reversing the winding order of the triangles, right? If so believe you're right in that this is something the tool should handle. I'll investigate further.

from fbx2gltf.

birdimus avatar birdimus commented on June 19, 2024

Yes, exactly. In the case I'm looking at, the transform scale is (-1, 1, 1)

from fbx2gltf.

zellski avatar zellski commented on June 19, 2024

@birdimus I've chatted with some folks and pondered a bit. It's not really the role of a converter to fix this. The glTF spec says:

Implementation Note: If the determinant of the transform is a negative value, the winding order of the mesh triangle faces should be reversed. This supports negative scales for mirroring geometry.

but this is really an instruction for the loader/client on how to interpret glTF, not how to create it. Furthermore, three.js explicitly warns against using negative scale in this situation; if you do, do it internally in the authoring program and then transform it before export.

That said, it's clear from researching the issue and reading forums and the like that this is a common issue that people face, and I'd be up for adding a command line flag that tries as hard as it can to apply magic and do the right thing. This is far from the top of the TODO-list, though, so in the meantime is there anything you can do at the Blender/Maya/Modo/whatnot level?

from fbx2gltf.

birdimus avatar birdimus commented on June 19, 2024

Yeah, for an individual file, I can open it in maya and freeze the transform.
For bulk conversion, that becomes untenable.

A lot of modelers will flip geo by scaling one axis to -1.
If Three is known to have issues, could we not 'bake' negative scale at import time - so the export only delivered 'valid' positive scaled transforms?

It's not urgent, but it did catch my attention. Thanks for thinking about it.

from fbx2gltf.

zellski avatar zellski commented on June 19, 2024

Hmm. I'll think about baking the scaling. Non-uniform scaling is tricky. The only practical way to do it I can think of would be to entirely collapse the entire tree beneath any node that has negative scaling and turn it all into a static mesh. Someone more up on their transformational algebra might be able to come up with a more elegant solution. In any case, a full bake is probably fine a lot of the time -- but obviously it won't work well in conjunction with rigged animation or anything along those lines.

Maybe the command line option could literally be --bake-all-geometries, and that'd just also helpfully get rid of negative transforms on the way...

from fbx2gltf.

zellski avatar zellski commented on June 19, 2024

I'm closing this because it's too far down on my TODO list, which in turn is because:

  • This kind of scaling is actually perfectly valid in glTF
  • The only solution I came up with was a massive geometry bake
  • It won't work in combination with animations anyway

If three.js has issues rendering valid glTF, that's going to have to be a three.js fix.

from fbx2gltf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.