Jump to content

Coordinate Transformation Puzzle


Recommended Posts


          How would WORLDSPACE Mouse Pick and Move (observable), translate into LOCALSPACE of a picked mesh?

     CONTEXT: a smaller child cube is picked and moved around on a parent cube.

     BEHAVIOR: without parent rotation, Pick Move works as expected.

                          After parent rotation the following RESULTS:

                           -Z move by mouse in WORLD SPACE results in -Z move of child object in LOCAL SPACE. So, it does not follow the mouse... in WORLDSPACE.

     GOAL:  rotated LOCALSPACE child to follow WORLDSPACE mouse move (e.g. converting -Z mousemove into +X rotated child move). Strange but true.

     QUESTION: How to convert the WORLDSPACE mouse  into LOCALSPACE ... and is that the correct way?

     The "Frame of Reference" docs are excellent. Found out that vectors do not work in TransformCoordinates. 

     So, guessing that the World Coordinate on Move needs to be converted to local before the vector is calculated... then move the child in local space. Hmmm.

     Any tips or examples on something like that?


Link to comment
Share on other sites


         Thanks to @Convergence and this thread... 

            The solution of converting MouseMove WORLDSPACE into rotated child cube LOCALSPACE was:

            var invertParentWorldMatrix = parentObj.getWorldMatrix().clone();
            var local_position = BABYLON.Vector3.TransformCoordinates(pickPointMove, invertParentWorldMatrix);

Hope that helps someone else.

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.

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.


  • Recently Browsing   0 members

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