Skip to content

Commit

Permalink
ArcRotateCamera: Modify rotation logic to use invertRotation flag (#1…
Browse files Browse the repository at this point in the history
…2762)

* Add logic to allow invertRotation to affect ArcRotateCamera

* Moved inverse calls to just one line

* lint/format fix

Former-commit-id: 33cadbadabd6815ac8d7294efa3f0a92917beb85
  • Loading branch information
PolygonalSun committed Jul 19, 2022
1 parent 6171e39 commit e9130e6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/dev/core/src/Cameras/arcRotateCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ export class ArcRotateCamera extends TargetCamera {
this.inputs.checkInputs();
// Inertia
if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
const directionModifier = this.invertRotation ? -1 : 1;
let inertialAlphaOffset = this.inertialAlphaOffset;
if (this.beta <= 0) {
inertialAlphaOffset *= -1;
Expand All @@ -921,9 +922,9 @@ export class ArcRotateCamera extends TargetCamera {
if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
inertialAlphaOffset *= -1;
}
this.alpha += inertialAlphaOffset;
this.alpha += inertialAlphaOffset * directionModifier;

this.beta += this.inertialBetaOffset;
this.beta += this.inertialBetaOffset * directionModifier;

this.radius -= this.inertialRadiusOffset;
this.inertialAlphaOffset *= this.inertia;
Expand Down

0 comments on commit e9130e6

Please sign in to comment.