-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
SceneUtils: Added up axis conversion support #11540
Conversation
@WestLangley What do you think about this approach? I've tried to decouple things by using a matrix that determines the actual type of the conversion (e.g. |
Yes, you seem to be on the right track. This is just a change of basis, right? So you are given a scene and an animation expressed in one basis, and you want to convert the scene and animation to another basis -- the three.js basis. If it is convenient to assume that conversion is a pure rotation plus, perhaps, a reflection -- and if it simplifies the math -- that is fine, but that assumption is not necessary. I see you are making assumptions when you transform the vertex normals and do not use a normal matrix for that purpose. It is not sufficient to refer to a basis as "z-up"; the basis may be left- or right-handed. I suggest you use different terminology. Your I do not follow your implementation of Related: link. |
Yeah, that's right. The current used matrix ensures that the handedness stays untouched. So it converts a right-handed Z-UP to right-handed Y-UP. To be precise, the matrix swaps
What kind of assumptions do i make here? Do you mean i assume that the translation part of a conversion matrix is always zero? But yeah, using a 3x3 normal matrix (without translation) is of course more correct.
I thought this is necessary so BTW: Thanks for your feedback so far! 😊 |
I'll improve this. |
I'd like to move forward with this PR because i need this logic in If the implementation or the terminology of methods and variables is not 100% satisfying, then i have no problem to outsource the code to I initially thought that the code might be interesting not only for |
That's fine
See my comments -- and the video I linked to above. |
@mrdoob As an aside, this is a handy utility to convert a scene from one basis to another, but it needs to be called every time the scene is loaded. I expect it would be better to implement the same logic in the exporter, itself. |
@mrdoob I think this PR is ready to merge now. @WestLangley Any objections? |
My only concern is my prior comment about implementing this in the exporter, instead. |
@Mugen87 How about adding this in the examples folder for now? Actually, I would vote for adding this to |
... and remove usage of If there is an example that requires a mesh and its wireframe, use this pattern: mesh.add( wireframe ); |
This PR introduces
SceneUtils.convertFromZUp()
that converts the up axis of a hierarchy of objects and corresponding animations to thethree.js
standard (Y up
). I've developed this in a way, so it is easy to create more conversion methods. You only have to define a conversion matrix and create a new instance ofUpAxisConverter
. Just have a look at the implementation ofSceneUtils. convertFromZUp()
.