-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
DragControls: Fix drag object in local coordinate #15131
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
Conversation
I expect the problem is simply caused by the rotated parent object. Can you confirm? Also, I suggest you avoid |
maybe...but i'm not very clear.I found this problem incidentally when I was using it.
but It seems that there is no other way to get the world position. |
Check the source code for vector.setFromMatrixPosition( object.matrixWorld ); |
Exactly. Therefore, parent's transform should be taken into account when performing world space transformations. I would expect similar issue to arise with scaled parent (a common case when importing objects from different world units) |
|
In your use case, _selected.parent.worldToLocal()inverts the parent's world matrix repeatedly. This method should not be called in tight loops. Can you compute the necessary inverse and reuse it? |
|
@WestLangley Just double-checking... Are you suggesting changes to this PR? |
I am suggesting the OP avoid calling |
|
@WestLangley thanks, could you please help to check |
|
@sweerwen Yes, that is what I had in mind. I have not tested your code, however. These convenience methods are just that: convenient. However, they are not necessarily efficient. Thanks for making the change. |
|
Looks good 👍 |
|
Thanks! |
when drag an object who's local position and rotation not equal world position and rotation will cause a wrong effect