Jump to content

Mesh Rotation Bug


ChrisR
 Share

Recommended Posts

So while i have been messing around with rotating objects, i came across a small bug in the babylonjs file.

 

Under Mesh.rotate:

 

If the space is in World space, and it has a parent, the code looks like:

                if (this.parent) {                    var invertParentWorldMatrix = this.parent.getWorldMatrix().clone();                    invertParentWorldMatrix.invert();                    axis = Vector3.TransformNormal(axis, invertParentWorldMatrix);                }

This causes the mesh to grow exponentially in size as its being rotated.

 

Simple fix add axis.normalize() to the end: So

               if (this.parent) {                    var invertParentWorldMatrix = this.parent.getWorldMatrix().clone();                    invertParentWorldMatrix.invert();                    axis = Vector3.TransformNormal(axis, invertParentWorldMatrix);                    axis.normalize();                }

I'm sure to whomever updates the babylon files this will make sence to normalize the axis before applying it to rotate.

 

Or maybe you would prefer it in Math.RotationAxis to normalize the axis before use as a better precaution?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...