-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Support all dragAxis #15844
base: master
Are you sure you want to change the base?
Support all dragAxis #15844
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -452,7 +452,7 @@ export class PointerDragBehavior implements Behavior<AbstractMesh> { | |
|
||
// Project delta drag from the drag plane onto the drag axis | ||
pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector); | ||
dragLength = Vector3.Dot(this._tmpVector, this._worldDragAxis); | ||
dragLength = Vector3.Dot(this._tmpVector, this._worldDragAxis) / (Vector3.Dot(this._worldDragAxis, this._worldDragAxis) || 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the bugfix! Instead of dividing the dot product by the length of this._worldDragAxis squared, could you please normalize this._worldDragAxis before this line? Something like: this._worldDragAxis.normalize(); Then this line can remain unchanged: Thanks again! |
||
this._worldDragAxis.scaleToRef(dragLength, this._dragDelta); | ||
} else { | ||
dragLength = this._dragDelta.length(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a little unintuitive to dot a vector with itself. To me it would be a little more clear to do:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird to me. What is the intended computation? get lengh of this._tmpVector projected on this._worldDragAxis ? in that case, is normalizing this._worldDragAxis just enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the dot because this is the notation you can find in Vector projection formulas but I understand it may be more readable with lengthSquared instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CedricGuillemet Yes it could work too, let me know which solution you think is the best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CedricGuillemet if I normalized it's in place, so I have to clone, I know it's a negligible impact, but maybe the lengthSquared is also more readable ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was still thinking about it...And now I think it's more understandable with a normalize() ^^